0
|
1 // Filename : main.cpp
|
16
|
2 // Last Change: 06-Jul-2011.
|
0
|
3 //
|
|
4
|
|
5 #include "common.h"
|
|
6 #include "main.h"
|
|
7 #include "myframe.h"
|
3
|
8 #include "preview.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);
|
3
|
32
|
10
|
33 /*
|
3
|
34 FramePreview *a = new FramePreview( NULL, ID_IMGFRM, wxEmptyString, wxDefaultPosition, wxSize( 512,394 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxTAB_TRAVERSAL );
|
|
35 a->Show(true);
|
10
|
36 */
|
0
|
37
|
|
38 return true;
|
|
39 }
|
|
40
|
|
41 int MyApp::OnExit()
|
|
42 {
|
|
43 config->SetPath( wxT("/Geometry") );
|
|
44 config->Write( wxT("x"), rect.x );
|
|
45 config->Write( wxT("y"), rect.y );
|
|
46 config->Write( wxT("w"), rect.width );
|
|
47 config->Write( wxT("h"), rect.height );
|
|
48
|
|
49 wxString key;
|
|
50 config->SetPath( wxT("/SearchHistory") );
|
16
|
51 for ( int i=0; i<10; i++ ) {
|
0
|
52 key.Printf( wxT("h%02d"), i );
|
|
53 config->Write( key, searchhist[i] );
|
|
54 }
|
|
55
|
|
56 delete config;
|
|
57
|
|
58 return 0;
|
|
59 }
|
|
60
|
|
61 void MyApp::ConfInit()
|
|
62 {
|
|
63 conf_file = wxGetCwd() + wxFILE_SEP_PATH + MYAPPNAME + wxT(".conf");
|
|
64 config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
|
|
65
|
|
66 config->SetPath( wxT("/Geometry") );
|
|
67 config->Read( wxT("x"), &rect.x );
|
|
68 config->Read( wxT("y"), &rect.y );
|
|
69 config->Read( wxT("w"), &rect.width );
|
|
70 config->Read( wxT("h"), &rect.height );
|
|
71
|
|
72 wxString key;
|
|
73 wxString value;
|
|
74 config->SetPath( wxT("/SearchHistory") );
|
16
|
75 for ( int i=0; i<10; i++ ) {
|
0
|
76 key.Printf( wxT("h%02d"), i );
|
|
77 config->Read( key, &value );
|
|
78 searchhist.Add( value );
|
|
79 }
|
|
80
|
|
81 config->SetPath( wxT("/RootDir") );
|
|
82 config->Read( wxT("rootdir"), &rootdir );
|
|
83 }
|
|
84
|