view src/main.cpp @ 1:eaa27e4ed5be

add client_ui.go
author pyon@macmini
date Mon, 01 Oct 2018 23:18:29 +0900
parents d3b8cd5aeb70
children 7fe3417cefc8
line wrap: on
line source

// Filename   : main.cpp
// Last Change: 2018-10-01 Mon 23:14:59.
//
#include "main.h"
#include "auth.h"
#include "rsearcher.h"

IMPLEMENT_APP( MyApp )

IMPLEMENT_CLASS( MyApp, wxApp )

MyApp::MyApp()
{
    develop = true;
}
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 );
    MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxT( "Re:Searcher" ), wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE );

    if ( develop ) {
        authdlg->InDevelop( true );
        mainframe->InDevelop( true );
    }

    authdlg->ShowModal();
    authdlg->Destroy();

    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 を削除
}