0
|
1 // Filename : main.cpp
|
3
|
2 // Last Change: 09-Apr-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
|
3
|
29 /*
|
0
|
30 MyFrame *mainframe = new MyFrame( NULL, ID_MAIN, wxT("Searcher v2") );
|
|
31 mainframe->SetSize( rect );
|
|
32 mainframe->Show(true);
|
3
|
33 */
|
|
34
|
|
35 FramePreview *a = new FramePreview( NULL, ID_IMGFRM, wxEmptyString, wxDefaultPosition, wxSize( 512,394 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxTAB_TRAVERSAL );
|
|
36 a->Show(true);
|
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") );
|
|
51 for ( int i=0; i<5; i++ ) {
|
|
52 key.Printf( wxT("h%02d"), i );
|
|
53 config->Write( key, searchhist[i] );
|
|
54 }
|
|
55
|
|
56
|
|
57 delete config;
|
|
58
|
|
59 return 0;
|
|
60 }
|
|
61
|
|
62 void MyApp::ConfInit()
|
|
63 {
|
|
64 conf_file = wxGetCwd() + wxFILE_SEP_PATH + MYAPPNAME + wxT(".conf");
|
|
65 config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
|
|
66
|
|
67 config->SetPath( wxT("/Geometry") );
|
|
68 config->Read( wxT("x"), &rect.x );
|
|
69 config->Read( wxT("y"), &rect.y );
|
|
70 config->Read( wxT("w"), &rect.width );
|
|
71 config->Read( wxT("h"), &rect.height );
|
|
72
|
|
73 wxString key;
|
|
74 wxString value;
|
|
75 config->SetPath( wxT("/SearchHistory") );
|
|
76 for ( int i=0; i<5; i++ ) {
|
|
77 key.Printf( wxT("h%02d"), i );
|
|
78 config->Read( key, &value );
|
|
79 searchhist.Add( value );
|
|
80 }
|
|
81
|
|
82 config->SetPath( wxT("/RootDir") );
|
|
83 config->Read( wxT("rootdir"), &rootdir );
|
|
84 }
|
|
85
|