diff src/main.cpp @ 0:c174ac668e9f

First commit ! (ver2.8)
author pyon@macmini
date Tue, 05 Apr 2011 18:44:57 +0900
parents
children 75fefb53d983
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main.cpp	Tue Apr 05 18:44:57 2011 +0900
@@ -0,0 +1,77 @@
+// Filename   : main.cpp
+// Last Change: 08-Mar-2011.
+//
+
+#include "common.h"
+#include "main.h"
+#include "myframe.h"
+
+IMPLEMENT_APP(MyApp)
+
+IMPLEMENT_CLASS( MyApp, wxApp )
+
+MyApp::MyApp()
+{
+}
+MyApp::~MyApp()
+{
+}
+
+bool MyApp::OnInit()
+{
+    if ( !wxApp::OnInit() ) return false;
+
+    ConfInit();
+
+    MyFrame *mainframe = new MyFrame( NULL, ID_MAIN, wxT("Searcher v2") );
+    mainframe->SetSize( rect );
+    mainframe->Show(true);
+
+    return true;
+}
+
+int MyApp::OnExit()
+{
+    config->SetPath( wxT("/Geometry") );
+    config->Write( wxT("x"), rect.x );
+    config->Write( wxT("y"), rect.y );
+    config->Write( wxT("w"), rect.width );
+    config->Write( wxT("h"), rect.height );
+
+    wxString key;
+    config->SetPath( wxT("/SearchHistory") );
+    for ( int i=0; i<5; i++ ) {
+        key.Printf( wxT("h%02d"), i );
+        config->Write( key, searchhist[i] );
+    }
+
+
+    delete config;
+
+    return 0;
+}
+
+void MyApp::ConfInit()
+{
+    conf_file = wxGetCwd() + wxFILE_SEP_PATH + MYAPPNAME + wxT(".conf");
+    config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
+
+    config->SetPath( wxT("/Geometry") );
+    config->Read( wxT("x"), &rect.x );
+    config->Read( wxT("y"), &rect.y );
+    config->Read( wxT("w"), &rect.width );
+    config->Read( wxT("h"), &rect.height );
+
+    wxString key;
+    wxString value;
+    config->SetPath( wxT("/SearchHistory") );
+    for ( int i=0; i<5; i++ ) {
+        key.Printf( wxT("h%02d"), i );
+        config->Read( key, &value );
+        searchhist.Add( value );
+    }
+
+    config->SetPath( wxT("/RootDir") );
+    config->Read( wxT("rootdir"), &rootdir );
+}
+