view src/hhsdb.cpp @ 22:92188f60323d default tip

Implement Masking function on Preview Dialog.
author pyon@macmini
date Sat, 04 Apr 2015 17:23:46 +0900
parents a2ad87cad48b
children
line wrap: on
line source

// Filename   : hhsdb.cpp
// Last Change: 12-Dec-2014.
//

#include "hhsdb.h"
#include "db.h"

HhsDialog::HhsDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 
    : wxDialog( parent, id, title, pos, size, style )
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
    this->SetBackgroundColour( wxColour( wxT("WHEAT") ) );
	
	wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
	
	m_filePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.*"), wxDefaultPosition, wxDefaultSize, wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_USE_TEXTCTRL );
	bSizerTop->Add( m_filePicker, 0, wxALL|wxEXPAND, 5 );
	
	wxBoxSizer* bSizerButton = new wxBoxSizer( wxHORIZONTAL );
	
	m_buttonUpdate = new wxButton( this, ID_UPDATE, wxT("更新処理開始"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizerButton->Add( m_buttonUpdate, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
	
	m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizerButton->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
	
	bSizerTop->Add( bSizerButton, 0, wxALIGN_RIGHT, 5 );
	
	this->SetSizer( bSizerTop );
	this->Layout();
	
	this->Centre( wxBOTH );
}

HhsDialog::~HhsDialog()
{
}

// Event Table
BEGIN_EVENT_TABLE( HhsDialog, wxDialog )
    EVT_BUTTON( ID_UPDATE, HhsDialog::OnUpdate )
END_EVENT_TABLE()

void HhsDialog::OnUpdate( wxCommandEvent& WXUNUSED(event) )
{
    wxString file = m_filePicker->GetPath();

    wxTextFile input( file );
    if ( !input.Exists() ) {
        wxMessageBox( wxT("指定されたファイルがありません.") );
        return;
    }

    wxArrayString hhs;

    wxCSConv cust( wxT("cp932") );
    input.Open( cust );
    for ( wxString buf = input.GetFirstLine(); !input.Eof(); buf = input.GetNextLine() ) {
        hhs.Add( buf );
    }
    input.Close();
    UpdateHhs( hhs );
    wxMessageBox( wxT("process done.") );
}