view src/main.cpp @ 5:3b734fd6ee2b

v0.2
author pyon@macmini
date Thu, 06 Oct 2011 20:27:54 +0900
parents 1ea4f7981ff5
children 99d612849255
line wrap: on
line source

// Filename   : main.cpp
// Last Change: 02-Oct-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;

    wxImage::AddHandler( new wxJPEGHandler );

    ConfInit();

    MyFrame *mainframe = new MyFrame( NULL, ID_MAIN, wxT("A Mover") );
    mainframe->SetSize( rect );
    mainframe->SetMinSize( wxSize( 580, 680 ) );
    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("/WorkDir") );
    config->Write( wxT("dir"), dir );

    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 );

    config->SetPath( wxT("/WorkDir") );
    config->Read( wxT("dir"), &dir );
}