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