0
|
1 // Filename : main.cpp
|
4
|
2 // Last Change: 16-Oct-2011.
|
0
|
3 //
|
|
4
|
|
5 #include "common.h"
|
|
6 #include "main.h"
|
|
7 #include "myframe.h"
|
|
8 //#include "testframe.cpp"
|
|
9
|
|
10 IMPLEMENT_APP(MyApp)
|
|
11
|
|
12 IMPLEMENT_CLASS( MyApp, wxApp )
|
|
13
|
|
14 MyApp::MyApp()
|
|
15 {
|
|
16 }
|
|
17 MyApp::~MyApp()
|
|
18 {
|
|
19 }
|
|
20
|
|
21 bool MyApp::OnInit()
|
|
22 {
|
|
23 if ( !wxApp::OnInit() ) return false;
|
|
24
|
|
25 wxImage::AddHandler( new wxJPEGHandler );
|
4
|
26 wxImage::AddHandler( new wxPNGHandler );
|
0
|
27
|
|
28 ConfInit();
|
|
29
|
|
30 wxString progname = wxT("A Mover");
|
|
31 wxString verstr = wxString::Format( wxT(" - v%d.%d ( build %d )"), VER, REV, BLD );
|
|
32 wxString title = progname + verstr;
|
|
33
|
|
34 MyFrame *mainframe = new MyFrame( NULL, ID_MAIN, title );
|
|
35 mainframe->SetSize( rect );
|
1
|
36 mainframe->SetMinSize( wxSize( 1200, 500 ) );
|
0
|
37 mainframe->Show(true);
|
|
38 /*
|
|
39 TestFrame *tf = new TestFrame( NULL, ID_TEST, wxT("A Test") );
|
|
40 tf->Show(true);
|
|
41 */
|
|
42
|
|
43 return true;
|
|
44 }
|
|
45
|
|
46 int MyApp::OnExit()
|
|
47 {
|
|
48 config->SetPath( wxT("/Geometry") );
|
|
49 config->Write( wxT("x"), rect.x );
|
|
50 config->Write( wxT("y"), rect.y );
|
|
51 config->Write( wxT("w"), rect.width );
|
|
52 config->Write( wxT("h"), rect.height );
|
|
53
|
|
54 config->SetPath( wxT("/WorkDir") );
|
|
55 config->Write( wxT("workdir"), workdir );
|
|
56
|
|
57 config->SetPath( wxT("/Param") );
|
|
58 config->Write( wxT("lmin"), lmin );
|
|
59 config->Write( wxT("lmax"), lmax );
|
|
60 config->Write( wxT("bmin"), bmin );
|
|
61 config->Write( wxT("bmax"), bmax );
|
|
62
|
|
63 delete config;
|
|
64
|
|
65 return 0;
|
|
66 }
|
|
67
|
|
68 void MyApp::ConfInit()
|
|
69 {
|
|
70 conf_file = wxGetCwd() + wxFILE_SEP_PATH + MYAPPNAME + wxT(".conf");
|
|
71 config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
|
|
72
|
|
73 config->SetPath( wxT("/Geometry") );
|
|
74 config->Read( wxT("x"), &rect.x );
|
|
75 config->Read( wxT("y"), &rect.y );
|
|
76 config->Read( wxT("w"), &rect.width );
|
|
77 config->Read( wxT("h"), &rect.height );
|
|
78
|
|
79 config->SetPath( wxT("/WorkDir") );
|
|
80 config->Read( wxT("workdir"), &workdir );
|
|
81
|
|
82 config->SetPath( wxT("/Param") );
|
|
83 config->Read( wxT("lmin"), lmin );
|
|
84 config->Read( wxT("lmax"), lmax );
|
|
85 config->Read( wxT("bmin"), bmin );
|
|
86 config->Read( wxT("bmax"), bmax );
|
|
87 }
|
|
88
|