0
|
1 // Filename : main.cpp
|
24
|
2 // Last Change: 28-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 );
|
24
|
31 mainframe->SetMinSize( wxSize( 580, 680 ) );
|
0
|
32 mainframe->Show(true);
|
|
33
|
|
34 return true;
|
|
35 }
|
|
36
|
|
37 int MyApp::OnExit()
|
|
38 {
|
|
39 config->SetPath( wxT("/Geometry") );
|
|
40 config->Write( wxT("x"), rect.x );
|
|
41 config->Write( wxT("y"), rect.y );
|
|
42 config->Write( wxT("w"), rect.width );
|
|
43 config->Write( wxT("h"), rect.height );
|
|
44
|
|
45 wxString key;
|
|
46 config->SetPath( wxT("/SearchHistory") );
|
16
|
47 for ( int i=0; i<10; i++ ) {
|
0
|
48 key.Printf( wxT("h%02d"), i );
|
|
49 config->Write( key, searchhist[i] );
|
|
50 }
|
|
51
|
|
52 delete config;
|
|
53
|
|
54 return 0;
|
|
55 }
|
|
56
|
|
57 void MyApp::ConfInit()
|
|
58 {
|
|
59 conf_file = wxGetCwd() + wxFILE_SEP_PATH + MYAPPNAME + wxT(".conf");
|
|
60 config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
|
|
61
|
|
62 config->SetPath( wxT("/Geometry") );
|
|
63 config->Read( wxT("x"), &rect.x );
|
|
64 config->Read( wxT("y"), &rect.y );
|
|
65 config->Read( wxT("w"), &rect.width );
|
|
66 config->Read( wxT("h"), &rect.height );
|
|
67
|
|
68 wxString key;
|
|
69 wxString value;
|
|
70 config->SetPath( wxT("/SearchHistory") );
|
16
|
71 for ( int i=0; i<10; i++ ) {
|
0
|
72 key.Printf( wxT("h%02d"), i );
|
|
73 config->Read( key, &value );
|
|
74 searchhist.Add( value );
|
|
75 }
|
|
76
|
|
77 config->SetPath( wxT("/RootDir") );
|
|
78 config->Read( wxT("rootdir"), &rootdir );
|
|
79 }
|
|
80
|