Mercurial > mercurial > hgweb_searcher03.cgi
view src/main.cpp @ 3:1a64119ab257
Equipment Regist print-target by Drag & Drop.
author | pyon@macmini |
---|---|
date | Tue, 27 Aug 2013 18:50:00 +0900 |
parents | c066fde99517 |
children | 3bb803d8c1d7 |
line wrap: on
line source
// Filename : main.cpp // Last Change: 23-Aug-2013. // #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; wxImage::AddHandler( new wxJPEGHandler ); wxImage::AddHandler( new wxPNGHandler ); InitLog(); InitSetting(); MyFrame *mainframe = new MyFrame( NULL, ID_MAIN, wxT("Searcher 03"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE ); mainframe->SetSize( rect ); mainframe->Show(true); return true; } int MyApp::OnExit() { SaveSetting(); return 0; } void MyApp::InitSetting() { conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("app.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 ); delete config; WriteLog( wxT("Setting Parameters read.") ); } void MyApp::SaveSetting() { config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); 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 ); delete config; WriteLog( wxT("Setting Parameters saved.") ); } void MyApp::InitLog() { log_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("log") + wxFILE_SEP_PATH + wxT("log"); wxTextFile file( log_file ); if ( file.Exists() ) { wxString log_bak = log_file + wxT(".bak"); wxRenameFile( log_file, log_bak, true ); } file.Create(); WriteLog( wxT("[Application start...]") ); } void MyApp::WriteLog( wxString msg ) { wxDateTime now = wxDateTime::Now(); wxTextFile logfile; logfile.Open( log_file ); logfile.AddLine( now.Format(wxT("%Y-%m-%d %H:%M:%S ")) + msg ); logfile.Write(); logfile.Close(); }