Mercurial > mercurial > hgweb_searcher03.cgi
changeset 1:7b6dab24f4b8
Gui parts complete.
author | pyon@macmini |
---|---|
date | Sun, 04 Aug 2013 21:42:49 +0900 |
parents | 0c0701a935f8 |
children | c066fde99517 |
files | Makefile TODO include/about.h include/common.h include/db.h include/hist.h include/index.h include/kana.h include/main.h include/mask.h include/myframe.h include/sqlite3.h sample.rc src/about.cpp src/db.cpp src/hist.cpp src/index.cpp src/kana.cpp src/main.cpp src/mask.cpp src/myframe.cpp src/wxsqlite3.cpp |
diffstat | 15 files changed, 444 insertions(+), 155 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Sun Jul 21 16:07:19 2013 +0900 +++ b/Makefile Sun Aug 04 21:42:49 2013 +0900 @@ -1,5 +1,5 @@ # Makefile for wxWidgets Application -# Last Change: 21-Jul-2013. +# Last Change: 01-Aug-2013. # by Takayuki Mutoh # @@ -37,6 +37,7 @@ $(OBJDIR)/hist.o \ $(OBJDIR)/index.o \ $(OBJDIR)/mask.o \ + $(OBJDIR)/db.o \ $(OBJDIR)/wxsqlite3.o ifdef COMSPEC @@ -62,24 +63,27 @@ -mkdir -p $(OBJDIR) $(CXX) -c $< -o $@ $(CXXFLAGS) -$(OBJDIR)/myframe.o: myframe.cpp myframe.h common.h +$(OBJDIR)/myframe.o: myframe.cpp myframe.h common.h db.h $(CXX) -c $< -o $@ $(CXXFLAGS) $(OBJDIR)/about.o: about.cpp about.h common.h $(CXX) -c $< -o $@ $(CXXFLAGS) -$(OBJDIR)/kana.o: kana.cpp kana.h common.h +$(OBJDIR)/kana.o: kana.cpp kana.h common.h db.h $(CXX) -c $< -o $@ $(CXXFLAGS) $(OBJDIR)/hist.o: hist.cpp hist.h common.h $(CXX) -c $< -o $@ $(CXXFLAGS) -$(OBJDIR)/index.o: index.cpp index.h common.h +$(OBJDIR)/index.o: index.cpp index.h common.h db.h $(CXX) -c $< -o $@ $(CXXFLAGS) $(OBJDIR)/mask.o: mask.cpp mask.h common.h $(CXX) -c $< -o $@ $(CXXFLAGS) +$(OBJDIR)/db.o: db.cpp db.h common.h + $(CXX) -c $< -o $@ $(CXXFLAGS) + $(OBJDIR)/wxsqlite3.o: wxsqlite3.cpp $(CXX) -c $< -o $@ $(CXXFLAGS)
--- a/TODO Sun Jul 21 16:07:19 2013 +0900 +++ b/TODO Sun Aug 04 21:42:49 2013 +0900 @@ -1,4 +1,4 @@ /*====================*/ /* TODO */ /*====================*/ - +Right-Click Menu ( Print, Adapt Height, Adapt Width, x %, ... )
--- a/include/common.h Sun Jul 21 16:07:19 2013 +0900 +++ b/include/common.h Sun Aug 04 21:42:49 2013 +0900 @@ -1,5 +1,5 @@ // Filename : common.h -// Last Change: 21-Jul-2013. +// Last Change: 02-Aug-2013. // #ifndef __COMMON_H__ #define __COMMON_H__ @@ -36,6 +36,7 @@ #include <wx/textfile.h> #include <wx/tokenzr.h> #include <wx/msgdlg.h> +#include <wx/regex.h> #include <wx/xrc/xmlres.h> #endif
--- a/include/db.h Sun Jul 21 16:07:19 2013 +0900 +++ b/include/db.h Sun Aug 04 21:42:49 2013 +0900 @@ -1,18 +1,23 @@ // Filename : db.h -// Last Change: 21-Jul-2013. +// Last Change: 02-Aug-2013. // #ifndef __DB_H__ #define __DB_H__ #include "common.h" -wxString GetHhsNameByNo( wxString hhsno ); -wxArrayString GetHhsByKana( wxString kana, bool fuzzy ); +// $BHoJ]HV$GHoJ]81<T>pJs$r<hF@(B +wxString GetHhsInfoByHhsNo( wxString hhsno ); +// $B;aL>%+%J$GHoJ]81<T$r8!:w(B +wxArrayString GetHhsInfoByKana( wxString kana, bool fuzzy ); +// $BHoJ]81<THV9f$+$i%U%!%$%k%Q%9$r<hF@(B wxArrayString GetPathByHhsNo( wxString hhsno ); +// $B9g5DBN3+:EF|$r<hF@(B wxArrayString GetCcnDate( void ); wxArrayString GetCcnByDate( wxString date ); wxArrayString GetHhsNoByCcn( wxString ccn, wxString date ); wxArrayString GetPathByHhsNo( wxString hhs ); +// $B%$%s%G%C%/%9$r99?7(B void UpdateIndex( wxArrayString paths ); #endif //__DB_H__
--- a/include/hist.h Sun Jul 21 16:07:19 2013 +0900 +++ b/include/hist.h Sun Aug 04 21:42:49 2013 +0900 @@ -1,5 +1,5 @@ // Filename : hist.h -// Last Change: 21-Jul-2013. +// Last Change: 02-Aug-2013. // #ifndef __HIST_H__ #define __HIST_H__ @@ -21,12 +21,15 @@ HistDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ); ~HistDialog(); - void SetupHistoryList( void ); + void OnSelectItem( wxListEvent& WXUNUSED(event) ); + void OnSet( wxCommandEvent& WXUNUSED(event) ); + void ReadHistoryList( void ); }; enum { ID_LISTHIST = wxID_HIGHEST + 30, + ID_SETHIST, };
--- a/include/kana.h Sun Jul 21 16:07:19 2013 +0900 +++ b/include/kana.h Sun Aug 04 21:42:49 2013 +0900 @@ -1,5 +1,5 @@ // Filename : kana.h -// Last Change: 21-Jul-2013. +// Last Change: 04-Aug-2013. // #ifndef __KANA_H__ #define __KANA_H__ @@ -10,6 +10,8 @@ { DECLARE_EVENT_TABLE() private: + wxArrayString m_hhs; + wxString m_hhsno; protected: @@ -24,11 +26,22 @@ KanaDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ); ~KanaDialog(); + void OnSearch( wxCommandEvent& WXUNUSED(event) ); + void OnFuzzyCheck( wxCommandEvent& WXUNUSED(event) ); + void OnSelectItem( wxListEvent& WXUNUSED(event) ); + void OnSet( wxCommandEvent& WXUNUSED(event) ); + void UpdateList( void ); + + // Accessor + wxString GetHhsNo() const { return m_hhsno; } }; enum { - ID_LISTKANA = wxID_HIGHEST + 20, + ID_SEARCHKANA = wxID_HIGHEST + 20, + ID_LISTKANA, + ID_FUZZY, + ID_SETKANA, }; #endif //__KANA_H__
--- a/include/mask.h Sun Jul 21 16:07:19 2013 +0900 +++ b/include/mask.h Sun Aug 04 21:42:49 2013 +0900 @@ -1,5 +1,5 @@ // Filename : mask.h -// Last Change: 21-Jul-2013. +// Last Change: 04-Aug-2013. // #ifndef __MASK_H__ @@ -42,16 +42,26 @@ wxButton* m_buttonCancel; wxButton* m_buttonSet; - wxFileConfig *config; - wxString conf_file; + long x, y, w, h; + wxRect m_mask1; + wxRect m_mask2; + wxRect m_mask3; public: MaskDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ); ~MaskDialog(); - void GetParams( void ); - void SetParams( wxCommandEvent& WXUNUSED(event) ); + void OnSet( wxCommandEvent& WXUNUSED(event) ); + void LoadParams( void ); + + // Accessor + void SetMask1( wxRect rect ) { m_mask1 = rect; } + void SetMask2( wxRect rect ) { m_mask2 = rect; } + void SetMask3( wxRect rect ) { m_mask3 = rect; } + wxRect GetMask1() const { return m_mask1; } + wxRect GetMask2() const { return m_mask2; } + wxRect GetMask3() const { return m_mask3; } }; enum {
--- a/include/myframe.h Sun Jul 21 16:07:19 2013 +0900 +++ b/include/myframe.h Sun Aug 04 21:42:49 2013 +0900 @@ -1,15 +1,38 @@ // Filename : myframe.h -// Last Change: 21-Jul-2013. +// Last Change: 04-Aug-2013. // #ifndef __MYFRAME_H__ #define __MYFRAME_H__ #include "common.h" +/////////////////////////////////////////////////////////////// +// $B%+%9%?%`8!:w%\%C%/%9(B +class MySearchBox : public wxSearchCtrl +{ + DECLARE_EVENT_TABLE() + private: + + public: + MySearchBox( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ); + ~MySearchBox(); + + void OnKey( wxKeyEvent& event ); + void PrintImages(); +}; + + +/////////////////////////////////////////////////////////////// +// $B%a%$%s%U%l!<%`(B class MyFrame : public wxFrame { DECLARE_EVENT_TABLE() private: + wxFileConfig* config; + wxString conf_file; + wxRect m_mask1; + wxRect m_mask2; + wxRect m_mask3; protected: wxMenuBar* m_menubar; @@ -20,8 +43,8 @@ wxTextCtrl* m_textCtrlName; wxTextCtrl* m_textCtrlAddr; wxListCtrl* m_listCtrl; - //wxStaticText* m_staticText; - wxSearchCtrl* m_searchCtrl; + wxStaticText* m_staticText; + MySearchBox* m_searchBox; wxButton* m_buttonKana; wxButton* m_buttonHist; wxPanel* m_panelR; @@ -36,12 +59,15 @@ void OnViewMode( wxCommandEvent& event ); void OnIndex( wxCommandEvent& WXUNUSED(event) ); + void LoadMaskParam( void ); void OnMaskParam( wxCommandEvent& WXUNUSED(event) ); void OnOpenAppDir( wxCommandEvent& WXUNUSED(event) ); void OnOpenHhsDir( wxListEvent& event ); void OnKana( wxCommandEvent& WXUNUSED(event) ); void OnHistory( wxCommandEvent& WXUNUSED(event) ); + void UpdateList( void ); + void SetStatusMessage( wxString msg, long n ); void OnWinSize( wxSizeEvent& event ); void OnWinMove( wxMoveEvent& WXUNUSED(event) ); void TellLocation( void ); @@ -49,13 +75,6 @@ void OnAbout( wxCommandEvent& WXUNUSED(event) ); void SaveConfig( wxCloseEvent& WXUNUSED(event) ); - /* - void m_splitterOnIdle( wxIdleEvent& ) { - m_splitter->SetSashPosition( 0 ); - m_splitter->Disconnect( wxEVT_IDLE, wxIdleEventHandler( MyFrame::m_splitterOnIdle ), NULL, this ); - } - */ - }; enum { @@ -65,6 +84,7 @@ ID_MNAPPDIR, ID_MNABOUT, ID_LIST, + ID_SEARCH, ID_KANA, ID_HIST, };
--- a/sample.rc Sun Jul 21 16:07:19 2013 +0900 +++ b/sample.rc Sun Aug 04 21:42:49 2013 +0900 @@ -16,10 +16,10 @@ // first icon in the executable and the icons are sorted both by their order // (Win9x) and by alphabetically (!) (NT), so put this icon first and give it // a name starting with "a" -aaaaaaaa ICON "sample.ico" +aaaaaaaa ICON "image/sample.ico" // this icon is used with wxFrame::SetIcon() -sample ICON "sample.ico" +sample ICON "image/sample.ico" // set this to 1 if you don't want to use manifest resource (manifest resource // is needed to enable visual styles on Windows XP - see docs/msw/winxp.txt
--- a/src/db.cpp Sun Jul 21 16:07:19 2013 +0900 +++ b/src/db.cpp Sun Aug 04 21:42:49 2013 +0900 @@ -1,34 +1,41 @@ // Filename : db.cpp -// Last Change: 21-Jul-2013. +// Last Change: 02-Aug-2013. // #include "db.h" #include "wx/wxsqlite3.h" -/* $BHoJ]81<THV9f$+$iHoJ]81<TL>$r<hF@(B */ -wxString GetHhsNameByNo( wxString hhsno ) +/* $BHoJ]HV$GHoJ]81<T>pJs$r<hF@(B */ +wxString GetHhsInfoByHhsNo( wxString hhsno ) { - wxString name; + wxString name, addr; wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("hhs.db"); wxSQLite3Database hhsdb; hhsdb.Open( gszFile ); - wxSQLite3Statement stmt = hhsdb.PrepareStatement("SELECT name FROM hhs_master WHERE hhsno = ?"); + wxSQLite3Statement stmt = hhsdb.PrepareStatement("SELECT name, addr FROM hhs_master WHERE hhsno = ?"); stmt.Bind( 1, hhsno ); wxSQLite3ResultSet q = stmt.ExecuteQuery(); if ( !q.IsNull(0) ) { while ( q.NextRow() ) { name = q.GetString(0); + addr = q.GetString(1); } } stmt.Finalize(); hhsdb.Close(); - return name; + if ( name.IsEmpty() ) { + return wxEmptyString; + } + else { + return name + wxT("_") + addr; + } } -/* $B%+%J$+$iHoJ]81<T>pJs$r<hF@(B */ -wxArrayString GetHhsByKana( wxString kana, bool fuzzy ) + +// $B;aL>%+%J$GHoJ]81<T>pJs$r8!:w(B +wxArrayString GetHhsInfoByKana( wxString kana, bool fuzzy ) { wxArrayString data; @@ -36,7 +43,10 @@ wxSQLite3Database hhsdb; hhsdb.Open( gszFile ); - wxSQLite3Statement stmt = hhsdb.PrepareStatement("SELECT hhs_no, kana, name, birth, addr FROM hhs_master WHERE kana = ? ORDER BY kana, birth DESC"); + wxString sql = wxT( "SELECT hhsno, kana, name, birth, addr FROM hhs_master WHERE kana = ? ORDER BY kana, birth;" ); + //if ( fuzzy ) ;//***** + + wxSQLite3Statement stmt = hhsdb.PrepareStatement( sql ); stmt.Bind( 1, kana ); wxSQLite3ResultSet q = stmt.ExecuteQuery(); @@ -82,7 +92,7 @@ return date_path; } -/* $B3+:EF|$r<hF@(B */ +/* $B9g5DBN3+:EF|$r<hF@(B */ wxArrayString GetCcnDate( void ) { wxArrayString date_cnt; @@ -107,7 +117,7 @@ return date_cnt; } -/* $B9g5DBN$r<hF@(B */ +/* $BF|IU$+$i?3::2q$r<hF@(B */ wxArrayString GetCcnByDate( wxString date ) { wxArrayString ccn_cnt; @@ -133,7 +143,7 @@ return ccn_cnt; } -/* $BHoJ]81<THV9f$r<hF@(B */ +/* $B9g5DBN$+$iHoJ]81<THV9f$r<hF@(B */ wxArrayString GetHhsNoByCcn( wxString ccn, wxString date ) { wxArrayString hhsno;
--- a/src/hist.cpp Sun Jul 21 16:07:19 2013 +0900 +++ b/src/hist.cpp Sun Aug 04 21:42:49 2013 +0900 @@ -1,5 +1,5 @@ // Filename : hist.cpp -// Last Change: 21-Jul-2013. +// Last Change: 02-Aug-2013. // #include "hist.h" @@ -15,19 +15,19 @@ wxListItem itemCol; itemCol.SetText( wxT("歴番") ); m_listCtrl->InsertColumn( 0, itemCol ); - m_listCtrl->SetColumnWidth( 0, 50 ); + m_listCtrl->SetColumnWidth( 0, 40 ); itemCol.SetText( wxT("被保険者番号") ); m_listCtrl->InsertColumn( 1, itemCol ); - m_listCtrl->SetColumnWidth( 1, 80 ); + m_listCtrl->SetColumnWidth( 1, 90 ); itemCol.SetText( wxT("氏名") ); m_listCtrl->InsertColumn( 2, itemCol ); m_listCtrl->SetColumnWidth( 2, 80 ); itemCol.SetText( wxT("住所") ); m_listCtrl->InsertColumn( 3, itemCol ); - m_listCtrl->SetColumnWidth( 3, 300 ); - itemCol.SetText( wxT("検索時刻") ); + m_listCtrl->SetColumnWidth( 3, 240 ); + itemCol.SetText( wxT("検索日時") ); m_listCtrl->InsertColumn( 4, itemCol ); - m_listCtrl->SetColumnWidth( 4, 100 ); + m_listCtrl->SetColumnWidth( 4, 80 ); bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); @@ -36,7 +36,7 @@ m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("キャンセル"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerBtn->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_buttonSet = new wxButton( this, wxID_OK, wxT("セット"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonSet = new wxButton( this, ID_SETHIST, wxT("セット"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerBtn->Add( m_buttonSet, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); bSizerTop->Add( bSizerBtn, 0, wxALIGN_RIGHT|wxALL, 5 ); @@ -46,7 +46,7 @@ this->Centre( wxBOTH ); - SetupHistoryList(); + ReadHistoryList(); } HistDialog::~HistDialog() @@ -55,13 +55,22 @@ // Event Table BEGIN_EVENT_TABLE( HistDialog, wxDialog ) - //EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnOpenHhsDir ) - //EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) + EVT_LIST_ITEM_ACTIVATED( ID_LISTHIST, HistDialog::OnSelectItem ) + EVT_BUTTON( ID_SETHIST, HistDialog::OnSet ) END_EVENT_TABLE() -void HistDialog::SetupHistoryList( void ) { +void HistDialog::OnSelectItem( wxListEvent& WXUNUSED(event) ) +{ +} +void HistDialog::OnSet( wxCommandEvent& WXUNUSED(event) ) +{ + +} + +void HistDialog::ReadHistoryList( void ) +{ wxTextFile file; wxString filename = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("history"); wxString buf;
--- a/src/kana.cpp Sun Jul 21 16:07:19 2013 +0900 +++ b/src/kana.cpp Sun Aug 04 21:42:49 2013 +0900 @@ -1,5 +1,5 @@ // Filename : kana.cpp -// Last Change: 21-Jul-2013. +// Last Change: 04-Aug-2013. // #include "kana.h" @@ -15,14 +15,14 @@ // wxBoxSizer* bSizerSearch = new wxBoxSizer( wxHORIZONTAL ); - m_searchCtrl = new wxSearchCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + m_searchCtrl = new wxSearchCtrl( this, ID_SEARCHKANA, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); #ifndef __WXMAC__ m_searchCtrl->ShowSearchButton( true ); #endif m_searchCtrl->ShowCancelButton( false ); bSizerSearch->Add( m_searchCtrl, 1, wxALL|wxEXPAND, 5 ); - m_checkBox = new wxCheckBox( this, wxID_ANY, wxT("部分一致"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkBox = new wxCheckBox( this, ID_FUZZY, wxT("部分一致"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerSearch->Add( m_checkBox, 0, wxALL|wxEXPAND, 5 ); bSizerTop->Add( bSizerSearch, 0, wxALL|wxEXPAND, 5 ); @@ -31,21 +31,24 @@ m_listCtrl = new wxListCtrl( this, ID_LISTKANA, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL ); wxListItem itemCol; - itemCol.SetText( wxT("被保険者番号") ); + itemCol.SetText( wxT("通番") ); m_listCtrl->InsertColumn( 0, itemCol ); - m_listCtrl->SetColumnWidth( 0, 80 ); + m_listCtrl->SetColumnWidth( 0, 40 ); + itemCol.SetText( wxT("被保険者番号") ); + m_listCtrl->InsertColumn( 1, itemCol ); + m_listCtrl->SetColumnWidth( 1, 90 ); itemCol.SetText( wxT("カナ") ); - m_listCtrl->InsertColumn( 1, itemCol ); - m_listCtrl->SetColumnWidth( 1, 100 ); - itemCol.SetText( wxT("氏名") ); m_listCtrl->InsertColumn( 2, itemCol ); m_listCtrl->SetColumnWidth( 2, 100 ); - itemCol.SetText( wxT("生年月日") ); + itemCol.SetText( wxT("氏名") ); m_listCtrl->InsertColumn( 3, itemCol ); - m_listCtrl->SetColumnWidth( 3, 60 ); + m_listCtrl->SetColumnWidth( 3, 100 ); + itemCol.SetText( wxT("生年月日") ); + m_listCtrl->InsertColumn( 4, itemCol ); + m_listCtrl->SetColumnWidth( 4, 60 ); itemCol.SetText( wxT("住所") ); - m_listCtrl->InsertColumn( 4, itemCol ); - m_listCtrl->SetColumnWidth( 4, 180 ); + m_listCtrl->InsertColumn( 5, itemCol ); + m_listCtrl->SetColumnWidth( 5, 180 ); bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); @@ -55,7 +58,7 @@ m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("キャンセル"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerBtn->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_buttonSet = new wxButton( this, wxID_OK, wxT("セット"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonSet = new wxButton( this, ID_SETKANA, wxT("セット"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerBtn->Add( m_buttonSet, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); bSizerTop->Add( bSizerBtn, 0, wxALIGN_RIGHT|wxALL, 5 ); @@ -64,6 +67,10 @@ this->Layout(); this->Centre( wxBOTH ); + + m_searchCtrl->SetFocus(); + m_searchCtrl->SetValue( wxT("全角で入力してネ! (性と名の間は全角スペースで)") ); + m_searchCtrl->SelectAll(); } KanaDialog::~KanaDialog() @@ -72,37 +79,90 @@ // Event Table BEGIN_EVENT_TABLE( KanaDialog, wxDialog ) - //EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnOpenHhsDir ) - //EVT_BUTTON( ID_HIST, MyFrame::OnHistory ) + EVT_TEXT_ENTER( ID_SEARCHKANA, KanaDialog::OnSearch ) + EVT_CHECKBOX( ID_FUZZY, KanaDialog::OnFuzzyCheck ) + EVT_LIST_ITEM_ACTIVATED( ID_LISTKANA, KanaDialog::OnSelectItem ) + EVT_BUTTON( ID_SETKANA, KanaDialog::OnSet ) END_EVENT_TABLE() // Event Handlers & Functions -/* -void KanaDialog::Search( void ) { +void KanaDialog::OnSearch( wxCommandEvent& WXUNUSED(event) ) +{ + UpdateList(); +} + +void KanaDialog::OnFuzzyCheck( wxCommandEvent& WXUNUSED(event) ) +{ + UpdateList(); +} - wxTextFile file; - wxString filename = wxGetCwd() + wxFILE_SEP_PATH + wxT(".history"); - wxString buf; +void KanaDialog::OnSelectItem( wxListEvent& WXUNUSED(event) ) +{ + m_hhsno = wxT("hoge"); + if ( IsModal() ) + EndModal( wxID_OK ); + else { + SetReturnCode( wxID_OK ); + Show( false ); + } +} - if ( file.Open( filename ) ) { +void KanaDialog::OnSet( wxCommandEvent& WXUNUSED(event) ) +{ + m_hhsno = wxT("hoge"); + if ( IsModal() ) + EndModal( wxID_OK ); + else { + SetReturnCode( wxID_OK ); + Show( false ); + } +} - for ( size_t i = 0; i<file.GetLineCount(); i++ ) { +void KanaDialog::UpdateList( void ) +{ + m_listCtrl->DeleteAllItems(); - int col = 0; - m_listCtrl->InsertItem( i, -1 ); - buf.Printf( wxT("%02d"), i + 1 ); - m_listCtrl->SetItem( i, col, buf, -1 ); // No + wxString s = m_searchCtrl->GetValue(); + if ( s.Len() < 3 ) { + wxMessageBox( wxT("指定する文字列は 3文字以上としてください.") ); + return; + } + + /* + wxRegEx reKana( "^[アイウエオカキクケコサシスセソナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンガギグゲコザジズゼゾダヂヅデドバビブベボパピプペポァィゥェォャュョ ]+$" ); + if ( !reKana.Matches( s ) ) { + wxMessageBox( wxT("カタカナで入力してください.") ); + return; + } + */ + + bool fuzzy = m_checkBox->IsChecked(); + m_hhs = GetHhsInfoByKana( s, fuzzy ); - wxStringTokenizer tkz( file[i], wxT(":") ); - while ( tkz.HasMoreTokens() ) { - col++; - wxString token = tkz.GetNextToken(); - m_listCtrl->SetItem( i, col, token, -1 ); - } - if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour(wxT("WHEAT")) ); + if ( m_hhs.GetCount() > 200 ) { + wxMessageBox( wxT("該当件数が 200 件を超えました.\n条件を変えてみてください.") ); + return; + } + else if ( m_hhs.IsEmpty() ){ + wxMessageBox( wxT("該当なし.") ); + return; + } + + wxString buf; + for ( int i = 0; i < m_hhs.GetCount(); i++ ) { + int col = 0; + m_listCtrl->InsertItem( i, -1 ); + buf.Printf( wxT("%02d"), i + 1 ); + m_listCtrl->SetItem( i, col, buf, -1 ); // No + + wxStringTokenizer tkz( m_hhs[i], wxT("_") ); + while ( tkz.HasMoreTokens() ) { + col++; + wxString token = tkz.GetNextToken(); + m_listCtrl->SetItem( i, col, token, -1 ); } + if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour(wxT("WHEAT")) ); } - file.Close(); } -*/ +
--- a/src/main.cpp Sun Jul 21 16:07:19 2013 +0900 +++ b/src/main.cpp Sun Aug 04 21:42:49 2013 +0900 @@ -1,5 +1,5 @@ // Filename : main.cpp -// Last Change: 20-Jul-2013. +// Last Change: 23-Jul-2013. // #include "main.h" #include "myframe.h" @@ -48,12 +48,15 @@ config->Read( wxT("y"), &rect.y ); config->Read( wxT("w"), &rect.width ); config->Read( wxT("h"), &rect.height ); + delete config; WriteLog( wxT("Setting Parameters read.") ); } 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 );
--- a/src/mask.cpp Sun Jul 21 16:07:19 2013 +0900 +++ b/src/mask.cpp Sun Aug 04 21:42:49 2013 +0900 @@ -1,5 +1,5 @@ // Filename : mask.cpp -// Last Change: 21-Jul-2013. +// Last Change: 04-Aug-2013. // #include "mask.h" @@ -93,67 +93,63 @@ this->Layout(); this->Centre( wxBOTH ); - - conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("app.conf"); - config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); - - GetParams(); } MaskDialog::~MaskDialog() { - delete config; } // Event Table BEGIN_EVENT_TABLE( MaskDialog, wxDialog ) - EVT_BUTTON( ID_SETPARAM, MaskDialog::SetParams ) + EVT_BUTTON( ID_SETPARAM, MaskDialog::OnSet ) END_EVENT_TABLE() -void MaskDialog::GetParams( void ) +// Event Handlers & Functions +void MaskDialog::OnSet( wxCommandEvent& WXUNUSED(event) ) { - wxString x, y, w, h; - - config->SetPath( wxT("/Mask") ); - - config->Read( wxT("x1"), &x ); - config->Read( wxT("y1"), &y ); - config->Read( wxT("w1"), &w ); - config->Read( wxT("h1"), &h ); - - m_textCtrlM1x->SetValue( x ); - m_textCtrlM1y->SetValue( y ); - m_textCtrlM1w->SetValue( w ); - m_textCtrlM1h->SetValue( h ); + wxString buf; + buf = m_textCtrlM1x->GetValue(); buf.ToLong( &x, 10 ); + buf = m_textCtrlM1y->GetValue(); buf.ToLong( &y, 10 ); + buf = m_textCtrlM1w->GetValue(); buf.ToLong( &w, 10 ); + buf = m_textCtrlM1h->GetValue(); buf.ToLong( &h, 10 ); + m_mask1.SetPosition( wxPoint( x, y ) ); + m_mask1.SetSize( wxSize( w, h ) ); - config->Read( wxT("x2"), &x ); - config->Read( wxT("y2"), &y ); - config->Read( wxT("w2"), &w ); - config->Read( wxT("h2"), &h ); - - m_textCtrlM2x->SetValue( x ); - m_textCtrlM2y->SetValue( y ); - m_textCtrlM2w->SetValue( w ); - m_textCtrlM2h->SetValue( h ); + buf = m_textCtrlM2x->GetValue(); buf.ToLong( &x, 10 ); + buf = m_textCtrlM2y->GetValue(); buf.ToLong( &y, 10 ); + buf = m_textCtrlM2w->GetValue(); buf.ToLong( &w, 10 ); + buf = m_textCtrlM2h->GetValue(); buf.ToLong( &h, 10 ); + m_mask2.SetPosition( wxPoint( x, y ) ); + m_mask2.SetSize( wxSize( w, h ) ); - config->Read( wxT("x3"), &x ); - config->Read( wxT("y3"), &y ); - config->Read( wxT("w3"), &w ); - config->Read( wxT("h3"), &h ); + buf = m_textCtrlM3x->GetValue(); buf.ToLong( &x, 10 ); + buf = m_textCtrlM3y->GetValue(); buf.ToLong( &y, 10 ); + buf = m_textCtrlM3w->GetValue(); buf.ToLong( &w, 10 ); + buf = m_textCtrlM3h->GetValue(); buf.ToLong( &h, 10 ); + m_mask3.SetPosition( wxPoint( x, y ) ); + m_mask3.SetSize( wxSize( w, h ) ); - m_textCtrlM3x->SetValue( x ); - m_textCtrlM3y->SetValue( y ); - m_textCtrlM3w->SetValue( w ); - m_textCtrlM3h->SetValue( h ); + if ( IsModal() ) + EndModal( wxID_OK ); + else { + SetReturnCode( wxID_OK ); + Show( false ); + } } -void MaskDialog::SetParams( wxCommandEvent& WXUNUSED(event) ) +void MaskDialog::LoadParams( void ) { - config->SetPath( wxT("/Mask") ); - - config->Write( wxT("h3"), m_textCtrlM3h->GetValue() ); - config->Flush(); - - Close(); + m_textCtrlM1x->SetValue( wxString::Format( wxT("%d"), m_mask1.GetX() ) ); + m_textCtrlM1y->SetValue( wxString::Format( wxT("%d"), m_mask1.GetY() ) ); + m_textCtrlM1w->SetValue( wxString::Format( wxT("%d"), m_mask1.GetWidth() ) ); + m_textCtrlM1h->SetValue( wxString::Format( wxT("%d"), m_mask1.GetHeight() ) ); + m_textCtrlM2x->SetValue( wxString::Format( wxT("%d"), m_mask2.GetX() ) ); + m_textCtrlM2y->SetValue( wxString::Format( wxT("%d"), m_mask2.GetY() ) ); + m_textCtrlM2w->SetValue( wxString::Format( wxT("%d"), m_mask2.GetWidth() ) ); + m_textCtrlM2h->SetValue( wxString::Format( wxT("%d"), m_mask2.GetHeight() ) ); + m_textCtrlM3x->SetValue( wxString::Format( wxT("%d"), m_mask3.GetX() ) ); + m_textCtrlM3y->SetValue( wxString::Format( wxT("%d"), m_mask3.GetY() ) ); + m_textCtrlM3w->SetValue( wxString::Format( wxT("%d"), m_mask3.GetWidth() ) ); + m_textCtrlM3h->SetValue( wxString::Format( wxT("%d"), m_mask3.GetHeight() ) ); }
--- a/src/myframe.cpp Sun Jul 21 16:07:19 2013 +0900 +++ b/src/myframe.cpp Sun Aug 04 21:42:49 2013 +0900 @@ -1,7 +1,8 @@ // Filename : myframe.cpp -// Last Change: 21-Jul-2013. +// Last Change: 04-Aug-2013. // #include "main.h" +#include "db.h" #include "myframe.h" #include "about.h" #include "kana.h" @@ -9,6 +10,69 @@ #include "index.h" #include "mask.h" +/////////////////////////////////////////////////////////////// +// カスタム検索ボックス +MySearchBox::MySearchBox( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style ) + : wxSearchCtrl( parent, id, value, pos, size, style ) +{ +} + +MySearchBox::~MySearchBox() +{ +} + +// Event Table +BEGIN_EVENT_TABLE( MySearchBox, wxSearchCtrl ) + EVT_CHAR( MySearchBox::OnKey ) +END_EVENT_TABLE() + +// Event Handlers & Functions +void MySearchBox::OnKey( wxKeyEvent& event ) +{ + wxString s = GetValue(); + // statustext( s.Len() ); + + if ( event.GetKeyCode() == 45 ) { // テンキーの '-' キーで1文字削除 + wxString t = GetStringSelection(); + if ( t.IsEmpty() ) { + long p = GetInsertionPoint(); + if ( p > 0 ) Remove( p - 1, p ); + } + else { + Cut(); + } + return; + } + + if ( event.GetKeyCode() == WXK_RETURN ) { + + if ( s.IsSameAs( wxT("+") ) ) { + wxMessageBox(wxT("pripri")); + return; + } + + wxRegEx reHhs( wxT("^0[1238][0-9]{8}$") ); + if ( reHhs.Matches( s ) ) { + wxString t = GetHhsInfoByHhsNo( s ); + wxArrayString array = GetPathByHhsNo( s ); + wxMessageBox( t ); + return; + } + + wxRegEx reNo( wxT("^[0-9]{1,2}$") ); + if ( reNo.Matches( s ) ) { + return; + } + + //m_parent->SetStatusMessage(wxT("bad input"), 0 ); + return; + } + + event.Skip(); +} + +/////////////////////////////////////////////////////////////// +// メインフレーム #define WINL_W 400 #define LOGO_W 200 #define LOGO_H 92 @@ -18,7 +82,6 @@ #include "sample.xpm" #endif - MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) { @@ -60,10 +123,10 @@ wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); m_splitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D ); - //m_splitter->Connect( wxEVT_IDLE, wxIdleEventHandler( MyFrame::m_splitterOnIdle ), NULL, this ); + wxBoxSizer* bSizerL = new wxBoxSizer( wxVERTICAL ); + // left-pane m_panelL = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizerL = new wxBoxSizer( wxVERTICAL ); wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png"); wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG ); @@ -91,20 +154,21 @@ wxBoxSizer* bSizerCmd = new wxBoxSizer( wxHORIZONTAL ); - //m_staticText = new wxStaticText( m_panelL, wxID_ANY, wxT("コマンド?"), wxDefaultPosition, wxDefaultSize, 0 ); - //bSizerCmd->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + m_staticText = new wxStaticText( m_panelL, wxID_ANY, wxT("コマンド?"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerCmd->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_searchCtrl = new wxSearchCtrl( m_panelL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + m_searchBox = new MySearchBox( m_panelL, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); #ifndef __WXMAC__ - m_searchCtrl->ShowSearchButton( true ); + m_searchBox->ShowSearchButton( true ); #endif - m_searchCtrl->ShowCancelButton( false ); - bSizerCmd->Add( m_searchCtrl, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + m_searchBox->ShowCancelButton( false ); + m_searchBox->SetFocus(); + bSizerCmd->Add( m_searchBox, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_buttonKana = new wxButton( m_panelL, ID_KANA, wxT("カナ検索"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerCmd->Add( m_buttonKana, 0, wxALL, 5 ); + m_buttonKana = new wxButton( m_panelL, ID_KANA, wxT("カナ検索"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); + bSizerCmd->Add( m_buttonKana, 0, wxLEFT|wxALIGN_CENTER_VERTICAL, 20 ); - m_buttonHist = new wxButton( m_panelL, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonHist = new wxButton( m_panelL, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxSize( 65, -1 ), 0 ); bSizerCmd->Add( m_buttonHist, 0, wxALL, 5 ); bSizerL->Add( bSizerCmd, 0, wxEXPAND, 5 ); @@ -113,6 +177,7 @@ m_panelL->Layout(); bSizerL->Fit( m_panelL ); + // right-pane m_panelR = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizerR = new wxBoxSizer( wxHORIZONTAL ); @@ -127,17 +192,21 @@ bSizerR->Fit( m_panelR ); m_panelR->Show( false ); + m_splitter->Initialize( m_panelL ); bSizerTop->Add( m_splitter, 1, wxEXPAND, 5 ); this->SetSizer( bSizerTop ); this->Layout(); // ステータスバー Statusbar - m_statusBar = this->CreateStatusBar( 4, wxST_SIZEGRIP, wxID_ANY ); + m_statusBar = new wxStatusBar( this, wxID_ANY, wxST_SIZEGRIP ); int widths[] = { 200, 100, -1, 90 }; - m_statusBar->SetStatusWidths( WXSIZEOF(widths), widths ); + m_statusBar->SetFieldsCount( 4, widths ); + this->SetStatusBar( m_statusBar ); + SetStatusText( wxT("被保番を入力してスタート!") ); this->Centre( wxBOTH ); + LoadMaskParam(); } MyFrame::~MyFrame() @@ -168,12 +237,72 @@ index->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); index->ShowModal(); } +/* マスクパラメータを設定ファイルから読み込む */ +void MyFrame::LoadMaskParam( void ) +{ + conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("app.conf"); + config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); + + int x, y, w, h; + + config->SetPath( wxT("/Mask") ); + + config->Read( wxT("x1"), &x ); + config->Read( wxT("y1"), &y ); + config->Read( wxT("w1"), &w ); + config->Read( wxT("h1"), &h ); + m_mask1.SetPosition( wxPoint( x, y ) ); + m_mask1.SetSize( wxSize( w, h ) ); + + config->Read( wxT("x2"), &x ); + config->Read( wxT("y2"), &y ); + config->Read( wxT("w2"), &w ); + config->Read( wxT("h2"), &h ); + m_mask2.SetPosition( wxPoint( x, y ) ); + m_mask2.SetSize( wxSize( w, h ) ); + + config->Read( wxT("x3"), &x ); + config->Read( wxT("y3"), &y ); + config->Read( wxT("w3"), &w ); + config->Read( wxT("h3"), &h ); + m_mask3.SetPosition( wxPoint( x, y ) ); + m_mask3.SetSize( wxSize( w, h ) ); + +} /* マスクパラメータ設定ダイアログ */ void MyFrame::OnMaskParam( wxCommandEvent& WXUNUSED(event) ) { MaskDialog* mask = new MaskDialog( this, wxID_ANY, wxT("マスク位置とサイズの指定"), wxDefaultPosition, wxSize( 400, 210 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); + mask->SetMask1( m_mask1 ); + mask->SetMask2( m_mask2 ); + mask->SetMask3( m_mask3 ); + mask->LoadParams(); mask->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); - mask->ShowModal(); + + if ( mask->ShowModal() == wxID_OK ) { + m_mask1 = mask->GetMask1(); + m_mask2 = mask->GetMask2(); + m_mask3 = mask->GetMask3(); + + config->SetPath( wxT("/Mask") ); + + config->Write( wxT("x1"), m_mask1.GetX() ); + config->Write( wxT("y1"), m_mask1.GetY() ); + config->Write( wxT("w1"), m_mask1.GetWidth() ); + config->Write( wxT("h1"), m_mask1.GetHeight() ); + + config->Write( wxT("x2"), m_mask2.GetX() ); + config->Write( wxT("y2"), m_mask2.GetY() ); + config->Write( wxT("w2"), m_mask2.GetWidth() ); + config->Write( wxT("h2"), m_mask2.GetHeight() ); + + config->Write( wxT("x3"), m_mask3.GetX() ); + config->Write( wxT("y3"), m_mask3.GetY() ); + config->Write( wxT("w3"), m_mask3.GetWidth() ); + config->Write( wxT("h3"), m_mask3.GetHeight() ); + + delete config; + } } /* アプリフォルダを開く */ void MyFrame::OnOpenAppDir( wxCommandEvent& WXUNUSED(event) ) @@ -218,19 +347,43 @@ dvf->Show(true); */ } + /* カナ検索ダイアログ */ void MyFrame::OnKana( wxCommandEvent& WXUNUSED(event) ) { - KanaDialog* kana = new KanaDialog( this, wxID_ANY, wxT("カナ氏名で被保番を検索"), wxDefaultPosition, wxSize( 500, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxRESIZE_BORDER|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); + KanaDialog* kana = new KanaDialog( this, wxID_ANY, wxT("カナ氏名で被保番を検索"), wxDefaultPosition, wxSize( 600, 600 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxRESIZE_BORDER|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); kana->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); - kana->ShowModal(); + + if ( kana->ShowModal() == wxID_OK ) { + wxMessageBox( kana->GetHhsNo() ); + } + + UpdateList(); } /* 検索履歴検索ダイアログ */ void MyFrame::OnHistory( wxCommandEvent& WXUNUSED(event) ) { HistDialog* hist = new HistDialog( this, wxID_ANY, wxT("検索履歴"), wxDefaultPosition, wxSize( 550, 500 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP|wxTAB_TRAVERSAL ); hist->ShowWithEffect( wxSHOW_EFFECT_SLIDE_TO_BOTTOM ); - hist->ShowModal(); + + if ( hist->ShowModal() == wxID_OK ) { + + } + + UpdateList(); +} + +/* 検索結果をリストアップ */ +void MyFrame::UpdateList( void ) +{ + m_listCtrl->DeleteAllItems(); +} + +/* ステータスバーにメッセージを出力 */ +void MyFrame::SetStatusMessage( wxString msg, long n ) +{ + if ( GetStatusBar() ) + SetStatusText( msg, n ); } /* サイズ変更 */ @@ -254,7 +407,9 @@ int y = r.GetY(); int w = r.GetWidth(); int h = r.GetHeight(); - //SetStatusText( wxString::Format(wxT("(%d,%d) %dx%d"),x,y,w,h), 3 ); + + if ( GetStatusBar() ) + SetStatusText( wxString::Format(wxT( "(%d,%d) %dx%d"),x,y,w,h ), 3 ); } /* 終了 */ void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) )