comparison src/hist.cpp @ 2:c066fde99517

Added Batch Print Mode.
author pyon@macmini
date Fri, 23 Aug 2013 18:32:09 +0900
parents 7b6dab24f4b8
children
comparison
equal deleted inserted replaced
1:7b6dab24f4b8 2:c066fde99517
1 // Filename : hist.cpp 1 // Filename : hist.cpp
2 // Last Change: 02-Aug-2013. 2 // Last Change: 22-Aug-2013.
3 // 3 //
4 #include "hist.h" 4 #include "hist.h"
5 5
6 HistDialog::HistDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 6 HistDialog::HistDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
7 : wxDialog( parent, id, title, pos, size, style ) 7 : wxDialog( parent, id, title, pos, size, style )
25 itemCol.SetText( wxT("住所") ); 25 itemCol.SetText( wxT("住所") );
26 m_listCtrl->InsertColumn( 3, itemCol ); 26 m_listCtrl->InsertColumn( 3, itemCol );
27 m_listCtrl->SetColumnWidth( 3, 240 ); 27 m_listCtrl->SetColumnWidth( 3, 240 );
28 itemCol.SetText( wxT("検索日時") ); 28 itemCol.SetText( wxT("検索日時") );
29 m_listCtrl->InsertColumn( 4, itemCol ); 29 m_listCtrl->InsertColumn( 4, itemCol );
30 m_listCtrl->SetColumnWidth( 4, 80 ); 30 m_listCtrl->SetColumnWidth( 4, 120 );
31 31
32 bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 ); 32 bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );
33 33
34 wxBoxSizer* bSizerBtn = new wxBoxSizer( wxHORIZONTAL ); 34 wxBoxSizer* bSizerBtn = new wxBoxSizer( wxHORIZONTAL );
35 35
58 EVT_LIST_ITEM_ACTIVATED( ID_LISTHIST, HistDialog::OnSelectItem ) 58 EVT_LIST_ITEM_ACTIVATED( ID_LISTHIST, HistDialog::OnSelectItem )
59 EVT_BUTTON( ID_SETHIST, HistDialog::OnSet ) 59 EVT_BUTTON( ID_SETHIST, HistDialog::OnSet )
60 END_EVENT_TABLE() 60 END_EVENT_TABLE()
61 61
62 62
63 void HistDialog::OnSelectItem( wxListEvent& WXUNUSED(event) ) 63 void HistDialog::OnSelectItem( wxListEvent& event )
64 { 64 {
65 int i = event.GetIndex();
66 wxListItem item;
67 item.SetId( i );
68
69 item.SetColumn( 1 );
70 item.SetMask( wxLIST_MASK_TEXT );
71 m_listCtrl->GetItem( item );
72 m_hhsno = item.GetText();
73
74 if ( IsModal() )
75 EndModal( wxID_OK );
76 else {
77 SetReturnCode( wxID_OK );
78 Show( false );
79 }
65 } 80 }
66 81
67 void HistDialog::OnSet( wxCommandEvent& WXUNUSED(event) ) 82 void HistDialog::OnSet( wxCommandEvent& WXUNUSED(event) )
68 { 83 {
84 long i = -1;
85 for ( ;; ) {
86 i = m_listCtrl->GetNextItem( i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
87 if ( i == -1 ) break;
69 88
89 wxListItem item;
90 item.SetId( i );
91
92 item.SetColumn( 1 );
93 item.SetMask( wxLIST_MASK_TEXT );
94 m_listCtrl->GetItem( item );
95 m_hhsno = item.GetText();
96 }
97
98 if ( IsModal() )
99 EndModal( wxID_OK );
100 else {
101 SetReturnCode( wxID_OK );
102 Show( false );
103 }
70 } 104 }
71 105
72 void HistDialog::ReadHistoryList( void ) 106 void HistDialog::ReadHistoryList( void )
73 { 107 {
74 wxTextFile file; 108 wxTextFile file;
75 wxString filename = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("history"); 109 wxString filename = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("history");
76 wxString buf; 110 wxString buf;
77 111
78 if ( file.Open( filename ) ) { 112 if ( file.Open( filename ) ) {
79 113
80 for ( size_t i = 0; i<file.GetLineCount(); i++ ) { 114 for ( size_t i = 0; i < file.GetLineCount(); i++ ) {
81 115
82 int col = 0; 116 int col = 0;
83 m_listCtrl->InsertItem( i, -1 ); 117 m_listCtrl->InsertItem( i, -1 );
84 buf.Printf( wxT("%02d"), i + 1 ); 118 buf.Printf( wxT("%02d"), i + 1 );
85 m_listCtrl->SetItem( i, col, buf, -1 ); // No 119 m_listCtrl->SetItem( i, col, buf, -1 ); // No
86 120
87 wxStringTokenizer tkz( file[i], wxT(":") ); 121 wxStringTokenizer tkz( file[i], wxT("#") );
88 while ( tkz.HasMoreTokens() ) { 122 while ( tkz.HasMoreTokens() ) {
89 col++; 123 col++;
90 wxString token = tkz.GetNextToken(); 124 wxString token = tkz.GetNextToken();
91 m_listCtrl->SetItem( i, col, token, -1 ); 125 m_listCtrl->SetItem( i, col, token, -1 );
92 } 126 }
93 if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour(wxT("WHEAT")) ); 127 if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour( wxT("WHEAT") ) );
94 } 128 }
95 } 129 }
96 file.Close(); 130 file.Close();
97 } 131 }
98 132