diff src/hhsdb.cpp @ 13:bbd65edf71d4

Implement Hhs DB update dialog.
author pyon@macmini
date Sat, 24 May 2014 10:25:13 +0900
parents
children a2ad87cad48b
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hhsdb.cpp	Sat May 24 10:25:13 2014 +0900
@@ -0,0 +1,67 @@
+// Filename   : hhsdb.cpp
+// Last Change: 23-May-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;
+	bSizerTop = new wxBoxSizer( wxVERTICAL );
+	
+	m_filePicker = new wxFilePickerCtrl( this, ID_FPICKR, 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;
+	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.") );
+}
+