13
|
1 // Filename : hhsdb.cpp
|
21
|
2 // Last Change: 12-Dec-2014.
|
13
|
3 //
|
|
4
|
|
5 #include "hhsdb.h"
|
|
6 #include "db.h"
|
|
7
|
|
8 HhsDialog::HhsDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
|
|
9 : wxDialog( parent, id, title, pos, size, style )
|
|
10 {
|
|
11 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
|
12 this->SetBackgroundColour( wxColour( wxT("WHEAT") ) );
|
|
13
|
21
|
14 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
|
13
|
15
|
21
|
16 m_filePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.*"), wxDefaultPosition, wxDefaultSize, wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_USE_TEXTCTRL );
|
13
|
17 bSizerTop->Add( m_filePicker, 0, wxALL|wxEXPAND, 5 );
|
|
18
|
21
|
19 wxBoxSizer* bSizerButton = new wxBoxSizer( wxHORIZONTAL );
|
13
|
20
|
|
21 m_buttonUpdate = new wxButton( this, ID_UPDATE, wxT("更新処理開始"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
22 bSizerButton->Add( m_buttonUpdate, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
23
|
|
24 m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
25 bSizerButton->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
26
|
|
27 bSizerTop->Add( bSizerButton, 0, wxALIGN_RIGHT, 5 );
|
|
28
|
|
29 this->SetSizer( bSizerTop );
|
|
30 this->Layout();
|
|
31
|
|
32 this->Centre( wxBOTH );
|
|
33 }
|
|
34
|
|
35 HhsDialog::~HhsDialog()
|
|
36 {
|
|
37 }
|
|
38
|
|
39 // Event Table
|
|
40 BEGIN_EVENT_TABLE( HhsDialog, wxDialog )
|
|
41 EVT_BUTTON( ID_UPDATE, HhsDialog::OnUpdate )
|
|
42 END_EVENT_TABLE()
|
|
43
|
|
44 void HhsDialog::OnUpdate( wxCommandEvent& WXUNUSED(event) )
|
|
45 {
|
|
46 wxString file = m_filePicker->GetPath();
|
|
47
|
|
48 wxTextFile input( file );
|
|
49 if ( !input.Exists() ) {
|
|
50 wxMessageBox( wxT("指定されたファイルがありません.") );
|
|
51 return;
|
|
52 }
|
|
53
|
|
54 wxArrayString hhs;
|
|
55
|
|
56 wxCSConv cust( wxT("cp932") );
|
|
57 input.Open( cust );
|
|
58 for ( wxString buf = input.GetFirstLine(); !input.Eof(); buf = input.GetNextLine() ) {
|
|
59 hhs.Add( buf );
|
|
60 }
|
|
61 input.Close();
|
|
62 UpdateHhs( hhs );
|
|
63 wxMessageBox( wxT("process done.") );
|
|
64 }
|
|
65
|