0
|
1 // Filename : main.cpp
|
|
2 // Last Change: 08-Mar-2011.
|
|
3 //
|
|
4
|
|
5 #include "common.h"
|
|
6 #include "main.h"
|
|
7 #include "myframe.h"
|
|
8
|
|
9 IMPLEMENT_APP(MyApp)
|
|
10
|
|
11 IMPLEMENT_CLASS( MyApp, wxApp )
|
|
12
|
|
13 MyApp::MyApp()
|
|
14 {
|
|
15 }
|
|
16 MyApp::~MyApp()
|
|
17 {
|
|
18 }
|
|
19
|
|
20 bool MyApp::OnInit()
|
|
21 {
|
|
22 if ( !wxApp::OnInit() ) return false;
|
|
23
|
|
24 ConfInit();
|
|
25
|
|
26 MyFrame *mainframe = new MyFrame( NULL, ID_MAIN, wxT("Searcher v2") );
|
|
27 mainframe->SetSize( rect );
|
|
28 mainframe->Show(true);
|
|
29
|
|
30 return true;
|
|
31 }
|
|
32
|
|
33 int MyApp::OnExit()
|
|
34 {
|
|
35 config->SetPath( wxT("/Geometry") );
|
|
36 config->Write( wxT("x"), rect.x );
|
|
37 config->Write( wxT("y"), rect.y );
|
|
38 config->Write( wxT("w"), rect.width );
|
|
39 config->Write( wxT("h"), rect.height );
|
|
40
|
|
41 wxString key;
|
|
42 config->SetPath( wxT("/SearchHistory") );
|
|
43 for ( int i=0; i<5; i++ ) {
|
|
44 key.Printf( wxT("h%02d"), i );
|
|
45 config->Write( key, searchhist[i] );
|
|
46 }
|
|
47
|
|
48
|
|
49 delete config;
|
|
50
|
|
51 return 0;
|
|
52 }
|
|
53
|
|
54 void MyApp::ConfInit()
|
|
55 {
|
|
56 conf_file = wxGetCwd() + wxFILE_SEP_PATH + MYAPPNAME + wxT(".conf");
|
|
57 config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
|
|
58
|
|
59 config->SetPath( wxT("/Geometry") );
|
|
60 config->Read( wxT("x"), &rect.x );
|
|
61 config->Read( wxT("y"), &rect.y );
|
|
62 config->Read( wxT("w"), &rect.width );
|
|
63 config->Read( wxT("h"), &rect.height );
|
|
64
|
|
65 wxString key;
|
|
66 wxString value;
|
|
67 config->SetPath( wxT("/SearchHistory") );
|
|
68 for ( int i=0; i<5; i++ ) {
|
|
69 key.Printf( wxT("h%02d"), i );
|
|
70 config->Read( key, &value );
|
|
71 searchhist.Add( value );
|
|
72 }
|
|
73
|
|
74 config->SetPath( wxT("/RootDir") );
|
|
75 config->Read( wxT("rootdir"), &rootdir );
|
|
76 }
|
|
77
|