changeset 0:6235b9a84d53

First Release.
author pyon@macmini
date Mon, 21 Apr 2014 20:44:57 +0900
parents
children 254045a265e0
files Makefile main.cpp main.h myframe.cpp myframe.h sample.ico sample.png sample.rc sample.xpm
diffstat 9 files changed, 325 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Mon Apr 21 20:44:57 2014 +0900
@@ -0,0 +1,92 @@
+# Makefile for wxWidgets Application
+# Last Change: 21-Apr-2014.
+# by Takayuki Mutoh
+#
+
+PROGNAME = mpos
+
+### Variables ###
+OBJDIR = ./obj
+CXX = g++
+vpath %.cpp ./src
+vpath %.h   ./include
+
+# For Microsoft Windows
+ifdef COMSPEC
+WXCXXFLAGS = -I/local/lib/wx/include/msw-unicode-static-3.0 -I/local/include/wx-3.0 -D_LARGEFILE_SOURCE=unknown -D__WXMSW__ -mthreads
+WXLIBS = -L/local/lib -Wl,--subsystem,windows -mwindows /local/lib/libwx_mswu_richtext-3.0.a /local/lib/libwx_mswu_xrc-3.0.a /local/lib/libwx_mswu_webview-3.0.a /local/lib/libwx_mswu_qa-3.0.a /local/lib/libwx_baseu_net-3.0.a /local/lib/libwx_mswu_html-3.0.a /local/lib/libwx_mswu_adv-3.0.a /local/lib/libwx_mswu_core-3.0.a /local/lib/libwx_baseu_xml-3.0.a /local/lib/libwx_baseu-3.0.a -lwxregexu-3.0 -lwxexpat-3.0 -lwxtiff-3.0 -lwxjpeg-3.0 -lwxpng-3.0 -lwxzlib-3.0 -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32
+EXECUTABLE = $(PROGNAME).exe
+
+# For Apple OSX
+else 
+WXCXXFLAGS = -I/opt/local/lib/wx/include/osx_cocoa-unicode-2.9 -I/opt/local/include/wx-2.9 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__ 
+WXLIBS = -L/opt/local/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -framework QuickTime -lwx_osx_cocoau_richtext-2.9 -lwx_osx_cocoau_xrc-2.9 -lwx_osx_cocoau_webview-2.9 -lwx_osx_cocoau_html-2.9 -lwx_osx_cocoau_qa-2.9 -lwx_osx_cocoau_adv-2.9 -lwx_osx_cocoau_core-2.9 -lwx_baseu_xml-2.9 -lwx_baseu_net-2.9 -lwx_baseu-2.9 
+
+EXECUTABLE = $(PROGNAME).app/Contents/Pkginfo
+
+endif
+
+CXXFLAGS = $(WXCXXFLAGS) -I./include -I./image
+LIBS = $(WXLIBS) -static-libgcc -static-libstdc++
+
+
+OBJ = $(OBJDIR)/main.o \
+	  $(OBJDIR)/myframe.o
+
+ifdef COMSPEC
+OBJMSW = $(OBJ) $(OBJDIR)/sample_rc.o
+endif
+
+
+### Targets ###
+
+all: $(EXECUTABLE)
+
+
+$(PROGNAME): $(OBJMSW)
+	$(CXX) $^ -o $@ $(LIBS)
+
+
+$(OBJDIR)/main.o: main.cpp main.h myframe.h
+	-mkdir -p $(OBJDIR)
+	$(CXX) -c $< -o $@ $(CXXFLAGS)
+
+$(OBJDIR)/myframe.o: myframe.cpp myframe.h
+	$(CXX) -c $< -o $@ $(CXXFLAGS)
+
+
+# for icon
+ifdef COMSPEC
+$(OBJDIR)/sample_rc.o: sample.rc
+	windres -i sample.rc -o $@ -I/local/include/wx-3.0
+endif
+
+$(EXECUTABLE): $(PROGNAME)
+ifdef COMSPEC
+	strip --strip-all $(EXECUTABLE)
+	./$(PROGNAME).exe
+else
+	-mkdir -p $(PROGNAME).app/Contents
+	-mkdir -p $(PROGNAME).app/Contents/MacOS
+	-mkdir -p $(PROGNAME).app/Contents/Resources
+	
+	sed -e "s/IDENTIFIER/$(PROGNAME)/" \
+	-e "s/EXECUTABLE/$(PROGNAME)/" \
+	-e "s/VERSION/0.0/" \
+	Info.plist.in > $(PROGNAME).app/Contents/Info.plist
+	
+	echo -n "APPL????" > $(EXECUTABLE)
+	
+	ln -f $(PROGNAME) $(PROGNAME).app/Contents/MacOS/$(PROGNAME)
+	cp -f wxmac.icns $(PROGNAME).app/Contents/Resources/wxmac.icns
+
+	open $(PROGNAME).app
+endif
+
+clean:
+	rm -f $(PROGNAME) $(PROGNAME).exe
+	rm -f $(OBJDIR)/*.o
+	rm -rf $(PROGNAME).app
+
+.PHONY:	all clean
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Apr 21 20:44:57 2014 +0900
@@ -0,0 +1,34 @@
+// Filename   : main.cpp
+// Last Change: 21-Apr-2014.
+//
+#include "main.h"
+#include "myframe.h"
+
+IMPLEMENT_APP(MyApp)
+
+IMPLEMENT_CLASS( MyApp, wxApp )
+
+MyApp::MyApp()
+{
+}
+MyApp::~MyApp()
+{
+}
+
+bool MyApp::OnInit()
+{
+    if ( !wxApp::OnInit() ) return false;
+
+    long style = wxDEFAULT_FRAME_STYLE;
+    style = style & ~( wxMAXIMIZE_BOX );
+    MyFrame *mainframe = new MyFrame( NULL, wxID_ANY, wxT("Mouse Position"), wxDefaultPosition, wxSize( 200, 200 ), style );
+    mainframe->Show(true);
+
+    return true;
+}
+
+int MyApp::OnExit()
+{
+    return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.h	Mon Apr 21 20:44:57 2014 +0900
@@ -0,0 +1,20 @@
+// Filename   : main.h
+// Last Change: 15-Jan-2014.
+//
+#include "wx/wx.h"
+
+// private classes
+// Define a new application type, each program should derive a class from wxApp
+class MyApp : public wxApp
+{
+    DECLARE_CLASS( MyApp )
+public:
+    MyApp();
+    ~MyApp();
+
+    virtual bool OnInit();
+    virtual int  OnExit();
+};
+
+DECLARE_APP(MyApp)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/myframe.cpp	Mon Apr 21 20:44:57 2014 +0900
@@ -0,0 +1,63 @@
+
+#include "myframe.h"
+
+MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 
+    : wxFrame( parent, id, title, pos, size, style )
+{
+    this->SetIcon( wxIcon( wxT("sample") ) );
+	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
+	this->SetBackgroundColour( wxColour( 0, 0, 0 ) );
+	
+	wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
+	
+	wxBoxSizer* bSizer = new wxBoxSizer( wxHORIZONTAL );
+	
+	m_textCtrlPos = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	bSizer->Add( m_textCtrlPos, 0, wxALL, 5 );
+	
+	m_buttonRec = new wxButton( this, ID_REC, wxT("Record"), wxDefaultPosition, wxSize( -1,-1 ), 0 );
+	bSizer->Add( m_buttonRec, 1, wxALL, 5 );
+	
+	bSizerTop->Add( bSizer, 0, wxEXPAND, 5 );
+	
+	m_textCtrlRec = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
+    m_textCtrlRec->SetFocus();
+	bSizerTop->Add( m_textCtrlRec, 1, wxALL|wxEXPAND, 5 );
+	
+	this->SetSizer( bSizerTop );
+	this->Layout();
+	
+	this->Centre( wxBOTH );
+}
+
+MyFrame::~MyFrame()
+{
+}
+
+// Event Table
+BEGIN_EVENT_TABLE( MyFrame, wxFrame )
+    EVT_MOVE( MyFrame::OnWinMove )
+    EVT_BUTTON( ID_REC, MyFrame::OnRec )
+END_EVENT_TABLE()
+
+// Event Handlers & Functions
+/* ウィンドウ移動したら位置とサイズを表示 */
+void MyFrame::OnWinMove( wxMoveEvent& WXUNUSED(event) )
+{
+    wxRect r = this->GetRect();
+    int x = r.GetX();
+    int y = r.GetY();
+    int w = r.GetWidth();
+    int h = r.GetHeight();
+
+    m_textCtrlPos->SetValue( wxString::Format(wxT( "%5d,%5d"), x, y ) );
+}
+
+void MyFrame::OnRec( wxCommandEvent& WXUNUSED(event) )
+{
+    wxString pos;
+    pos = m_textCtrlPos->GetValue();
+    m_textCtrlRec->AppendText( pos );
+    m_textCtrlRec->WriteText( wxT("\n") );
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/myframe.h	Mon Apr 21 20:44:57 2014 +0900
@@ -0,0 +1,44 @@
+// Filename   : myframe.h
+// Last Change: 21-Apr-2014.
+//
+
+#ifndef __MYFRAME_H__
+#define __MYFRAME_H__
+
+#include <wx/artprov.h>
+#include <wx/xrc/xmlres.h>
+#include <wx/string.h>
+#include <wx/textctrl.h>
+#include <wx/gdicmn.h>
+#include <wx/font.h>
+#include <wx/colour.h>
+#include <wx/settings.h>
+#include <wx/button.h>
+#include <wx/sizer.h>
+#include <wx/frame.h>
+
+
+class MyFrame : public wxFrame 
+{
+    DECLARE_EVENT_TABLE()
+	private:
+	
+	protected:
+		wxTextCtrl* m_textCtrlPos;
+		wxButton*   m_buttonRec;
+		wxTextCtrl* m_textCtrlRec;
+	
+	public:
+		MyFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Mouse Position"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 200,200 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
+		~MyFrame();
+        void OnWinMove( wxMoveEvent& WXUNUSED(event) );
+        void OnRec( wxCommandEvent& WXUNUSED(event) );
+};
+
+enum
+{
+    ID_REC = wxID_HIGHEST + 1,
+};
+
+#endif //__MYFRAME_H__
+
Binary file sample.ico has changed
Binary file sample.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sample.rc	Mon Apr 21 20:44:57 2014 +0900
@@ -0,0 +1,32 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        samples/samples.rc
+// Purpose:     a standard Win32 .rc file for the wxWindows samples
+// Author:      Vadim Zeitlin
+// Modified by:
+// Created:     04.08.03
+// RCS-ID:      $Id: sample.rc 22863 2003-08-14 14:08:53Z VS $
+// Copyright:   (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// this minimal resource file is all what is needed for most of the wxWindows
+// samples
+
+// note that the icon used by the Explorer (i.e. the programs icon) is the
+// first icon in the executable and the icons are sorted both by their order
+// (Win9x) and by alphabetically (!) (NT), so put this icon first and give it
+// a name starting with "a"
+aaaaaaaa ICON "sample.ico"
+
+// this icon is used with wxFrame::SetIcon()
+sample ICON "sample.ico"
+
+// set this to 1 if you don't want to use manifest resource (manifest resource
+// is needed to enable visual styles on Windows XP - see docs/msw/winxp.txt
+// for more information)
+#define wxUSE_NO_MANIFEST 0
+
+// this is not always needed but doesn't hurt (except making the executable
+// very slightly larger): this file contains the standard icons, cursors, ...
+#include "wx/msw/wx.rc"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sample.xpm	Mon Apr 21 20:44:57 2014 +0900
@@ -0,0 +1,40 @@
+/* XPM */
+static const char *sample_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"32 32 2 1",
+". c Black",
+"  c #FFFFFF",
+/* pixels */
+"                                ",
+" .............................. ",
+" .............................. ",
+" ..            ..            .. ",
+" ..            ..            .. ",
+" ..            ..            .. ",
+" ..            ..            .. ",
+" ..            ..            .. ",
+" ..            ..            .. ",
+" ..            ..            .. ",
+" ..            ..            .. ",
+" ..            ..            .. ",
+" .............................. ",
+" .............................. ",
+" ..                           . ",
+" ..                           . ",
+" ..                           . ",
+" ..                           . ",
+" ..                           . ",
+" ..                           . ",
+" .. ..                        . ",
+" .. ..                        . ",
+" ..                           . ",
+" .. ..                        . ",
+" .. ..                        . ",
+" .. ..                        . ",
+" .. ....                      . ",
+" .. ....                      . ",
+" ..                           . ",
+" .............................. ",
+" .............................. ",
+"                                "
+};