0
|
1 // Filename : main.cpp
|
11
|
2 // Last Change: 22-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();
|
11
|
29 InitLog();
|
0
|
30
|
|
31 wxString progname = wxT("A Mover");
|
|
32 wxString verstr = wxString::Format( wxT(" - v%d.%d ( build %d )"), VER, REV, BLD );
|
|
33 wxString title = progname + verstr;
|
|
34
|
|
35 MyFrame *mainframe = new MyFrame( NULL, ID_MAIN, title );
|
|
36 mainframe->SetSize( rect );
|
5
|
37 mainframe->SetMinSize( wxSize( 1200, 400 ) );
|
0
|
38 mainframe->Show(true);
|
|
39 /*
|
|
40 TestFrame *tf = new TestFrame( NULL, ID_TEST, wxT("A Test") );
|
|
41 tf->Show(true);
|
|
42 */
|
|
43
|
|
44 return true;
|
|
45 }
|
|
46
|
|
47 int MyApp::OnExit()
|
|
48 {
|
|
49 config->SetPath( wxT("/Geometry") );
|
|
50 config->Write( wxT("x"), rect.x );
|
|
51 config->Write( wxT("y"), rect.y );
|
|
52 config->Write( wxT("w"), rect.width );
|
|
53 config->Write( wxT("h"), rect.height );
|
|
54
|
|
55 config->SetPath( wxT("/WorkDir") );
|
|
56 config->Write( wxT("workdir"), workdir );
|
|
57
|
|
58 config->SetPath( wxT("/Param") );
|
|
59 config->Write( wxT("lmin"), lmin );
|
|
60 config->Write( wxT("lmax"), lmax );
|
5
|
61 config->Write( wxT("zmin"), zmin );
|
|
62 config->Write( wxT("zmax"), zmax );
|
0
|
63
|
|
64 delete config;
|
|
65
|
|
66 return 0;
|
|
67 }
|
|
68
|
|
69 void MyApp::ConfInit()
|
|
70 {
|
|
71 conf_file = wxGetCwd() + wxFILE_SEP_PATH + MYAPPNAME + wxT(".conf");
|
|
72 config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
|
|
73
|
|
74 config->SetPath( wxT("/Geometry") );
|
|
75 config->Read( wxT("x"), &rect.x );
|
|
76 config->Read( wxT("y"), &rect.y );
|
|
77 config->Read( wxT("w"), &rect.width );
|
|
78 config->Read( wxT("h"), &rect.height );
|
|
79
|
|
80 config->SetPath( wxT("/WorkDir") );
|
|
81 config->Read( wxT("workdir"), &workdir );
|
|
82
|
|
83 config->SetPath( wxT("/Param") );
|
5
|
84 config->Read( wxT("lmin"), &lmin );
|
|
85 config->Read( wxT("lmax"), &lmax );
|
|
86 config->Read( wxT("zmin"), &zmin );
|
|
87 config->Read( wxT("zmax"), &zmax );
|
0
|
88 }
|
|
89
|
11
|
90 void MyApp::InitLog()
|
|
91 {
|
|
92 wxDateTime now = wxDateTime::Now();
|
|
93 wxTextFile logfile;
|
|
94 logfile.Open(wxT("log"));
|
|
95 logfile.Clear();
|
|
96 logfile.AddLine( now.Format(wxT("%F %T ")) + wxT("[Application start...]") );
|
|
97 logfile.Write();
|
|
98 logfile.Close();
|
|
99 }
|
|
100 void MyApp::WriteLog( wxString msg )
|
|
101 {
|
|
102 wxDateTime now = wxDateTime::Now();
|
|
103 wxTextFile logfile;
|
|
104 logfile.Open(wxT("log"));
|
|
105 logfile.AddLine( now.Format(wxT("%F %T ")) + msg );
|
|
106 logfile.Write();
|
|
107 logfile.Close();
|
|
108 }
|
|
109
|