Mercurial > mercurial > hgweb_renren.cgi
changeset 0:00c5161d67b8 default tip
first release.
author | pyon@macmini |
---|---|
date | Tue, 29 Oct 2013 19:23:03 +0900 |
parents | |
children | |
files | Makefile include/main.h include/myframe.h src/main.cpp src/myframe.cpp |
diffstat | 5 files changed, 331 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Tue Oct 29 19:23:03 2013 +0900 @@ -0,0 +1,92 @@ +# Makefile for wxWidgets Application +# Last Change: 29-Oct-2013. +# by Takayuki Mutoh +# + +PROGNAME = renren + +### 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-2.9 -I/local/include/wx-2.9 -D_LARGEFILE_SOURCE=unknown -D__WXMSW__ -mthreads +WXLIBS = -L/local/lib -Wl,--subsystem,windows -mwindows /local/lib/libwx_mswu_richtext-2.9.a /local/lib/libwx_mswu_xrc-2.9.a /local/lib/libwx_mswu_webview-2.9.a /local/lib/libwx_mswu_qa-2.9.a /local/lib/libwx_baseu_net-2.9.a /local/lib/libwx_mswu_html-2.9.a /local/lib/libwx_mswu_adv-2.9.a /local/lib/libwx_mswu_core-2.9.a /local/lib/libwx_baseu_xml-2.9.a /local/lib/libwx_baseu-2.9.a -lwxregexu-2.9 -lwxexpat-2.9 -lwxtiff-2.9 -lwxjpeg-2.9 -lwxpng-2.9 -lwxzlib-2.9 -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): $(OBJ) + $(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-2.9 +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/include/main.h Tue Oct 29 19:23:03 2013 +0900 @@ -0,0 +1,24 @@ +// Filename : main.h +// Last Change: 29-Oct-2013. +// +#include "wx/wx.h" +#include "wx/config.h" +#include "wx/fileconf.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/include/myframe.h Tue Oct 29 19:23:03 2013 +0900 @@ -0,0 +1,59 @@ +// Filename : myframe.h +// Last Change: 29-Oct-2013. +// + +#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/dir.h> +#include <wx/frame.h> + +/// Class MyFrame +class MyFrame : public wxFrame +{ + DECLARE_EVENT_TABLE() + private: + bool state1; + bool state2; + bool state3; + + protected: + wxTextCtrl* m_textCtrl1l; + wxButton* m_button1; + wxTextCtrl* m_textCtrl1r; + wxTextCtrl* m_textCtrl2l; + wxButton* m_button2; + wxTextCtrl* m_textCtrl2r; + wxTextCtrl* m_textCtrl3l; + wxButton* m_button3; + wxTextCtrl* m_textCtrl3r; + + public: + MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ); + ~MyFrame(); + + void OnButton1( wxCommandEvent& WXUNUSED(event) ); + void OnButton2( wxCommandEvent& WXUNUSED(event) ); + void OnButton3( wxCommandEvent& WXUNUSED(event) ); + void InitControl( void ); + void Exchange( wxTextCtrl* left, wxTextCtrl* right, bool sw ); +}; + +enum { + ID_BTN1 = wxID_HIGHEST + 1, + ID_BTN2, + ID_BTN3, +}; + +#endif //__MYFRAME_H__ +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main.cpp Tue Oct 29 19:23:03 2013 +0900 @@ -0,0 +1,33 @@ +// Filename : main.cpp +// Last Change: 29-Oct-2013. +// +#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; + + MyFrame *mainframe = new MyFrame( NULL, wxID_ANY, wxT("RenRen"), wxDefaultPosition, wxSize( 280, 140 ), wxCAPTION|wxCLOSE_BOX ); + mainframe->Show( true ); + mainframe->InitControl(); + + return true; +} + +int MyApp::OnExit() +{ + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/myframe.cpp Tue Oct 29 19:23:03 2013 +0900 @@ -0,0 +1,123 @@ +// Filename : myframe.cpp +// Last Change: 29-Oct-2013. +// +#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->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxGridSizer* gSizer = new wxGridSizer( 0, 3, 0, 0 ); + + m_textCtrl1l = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); + gSizer->Add( m_textCtrl1l, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_button1 = new wxButton( this, ID_BTN1, wxT("<->"), wxDefaultPosition, wxSize( 50, -1 ), 0 ); + gSizer->Add( m_button1, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_textCtrl1r = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); + gSizer->Add( m_textCtrl1r, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_textCtrl2l = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); + gSizer->Add( m_textCtrl2l, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_button2 = new wxButton( this, ID_BTN2, wxT("<->"), wxDefaultPosition, wxSize( 50, -1 ), 0 ); + gSizer->Add( m_button2, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_textCtrl2r = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); + gSizer->Add( m_textCtrl2r, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_textCtrl3l = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); + gSizer->Add( m_textCtrl3l, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_button3 = new wxButton( this, ID_BTN3, wxT("<->"), wxDefaultPosition, wxSize( 50, -1 ), 0 ); + gSizer->Add( m_button3, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_textCtrl3r = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); + gSizer->Add( m_textCtrl3r, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + + this->SetSizer( gSizer ); + this->Layout(); + + this->Centre( wxBOTH ); +} + +MyFrame::~MyFrame() +{ +} + +// Event Table +BEGIN_EVENT_TABLE( MyFrame, wxFrame ) + EVT_BUTTON( ID_BTN1, MyFrame::OnButton1 ) + EVT_BUTTON( ID_BTN2, MyFrame::OnButton2 ) + EVT_BUTTON( ID_BTN3, MyFrame::OnButton3 ) +END_EVENT_TABLE() + +// Event Handlers & Functions +void MyFrame::OnButton1( wxCommandEvent& WXUNUSED(event) ) +{ + Exchange( m_textCtrl1l, m_textCtrl1r, state1 ); + state1 = !state1; +} + +void MyFrame::OnButton2( wxCommandEvent& WXUNUSED(event) ) +{ + Exchange( m_textCtrl2l, m_textCtrl2r, state2 ); + state2 = !state2; +} + +void MyFrame::OnButton3( wxCommandEvent& WXUNUSED(event) ) +{ + Exchange( m_textCtrl3l, m_textCtrl3r, state3 ); + state3 = !state3; +} + +void MyFrame::InitControl( void ) +{ + wxString file = wxT( "Z1400000.dta" ); + m_textCtrl1r->SetValue( file ); + m_textCtrl2r->SetValue( file ); + m_textCtrl3r->SetValue( file ); + + wxDir dir( wxGetCwd() ); + if ( !dir.IsOpened() ) return; + + bool cout = dir.GetFirst( &file, wxT("*.dta"), wxDIR_FILES ); + if ( cout ) { + m_textCtrl1l->SetValue( file ); + cout = dir.GetNext( &file ); + } + if ( cout ) { + m_textCtrl2l->SetValue( file ); + cout = dir.GetNext( &file ); + } + if ( cout ) { + m_textCtrl3l->SetValue( file ); + cout = dir.GetNext( &file ); + } + + state1 = true; + state2 = true; + state3 = true; +} + +void MyFrame::Exchange( wxTextCtrl* left, wxTextCtrl* right, bool sw ) +{ + wxString from, to; + + if ( sw ) { + from = wxGetCwd() + wxFILE_SEP_PATH + left->GetValue(); + to = wxGetCwd() + wxFILE_SEP_PATH + right->GetValue(); + left->SetBackgroundColour( *wxYELLOW ); + } + else { + from = wxGetCwd() + wxFILE_SEP_PATH + right->GetValue(); + to = wxGetCwd() + wxFILE_SEP_PATH + left->GetValue(); + right->SetBackgroundColour( *wxYELLOW ); + } + Refresh( true, NULL ); + wxRenameFile( from, to, false ); +} +