view src/main.cpp @ 0:d3b8cd5aeb70

make repo.
author pyon@macmini
date Sun, 30 Sep 2018 17:27:04 +0900
parents
children eaa27e4ed5be
line wrap: on
line source

// Filename   : main.cpp
// Last Change: 2018-09-29 Sat 15:11:45.
//
#include "main.h"
#include "auth.h"
#include "rsearcher.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  );
	InitSetting();
    GetData();

    AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "" ), wxDefaultPosition, wxDefaultSize );
    authdlg->ShowModal();
    authdlg->Destroy();

    MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxT( "Re:Searcher" ), wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE );
    mainframe->Show( true );

    return true;
}

int MyApp::OnExit()
{
	SaveSetting();
    DeleteData();
    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;
}

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

void MyApp::GetData()
{
    // Go のプログラムを起動し,暗号化さた auth, hhs, index データを取得
}

void MyApp::DeleteData()
{
    // auth.db と hhs.db を削除
}