0
|
1 // Filename : hist.cpp
|
2
|
2 // Last Change: 22-Aug-2013.
|
0
|
3 //
|
|
4 #include "hist.h"
|
|
5
|
|
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 )
|
|
8 {
|
|
9 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
|
10
|
|
11 wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
|
|
12
|
|
13 m_listCtrl = new wxListCtrl( this, ID_LISTHIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL );
|
|
14
|
|
15 wxListItem itemCol;
|
|
16 itemCol.SetText( wxT("歴番") );
|
|
17 m_listCtrl->InsertColumn( 0, itemCol );
|
1
|
18 m_listCtrl->SetColumnWidth( 0, 40 );
|
0
|
19 itemCol.SetText( wxT("被保険者番号") );
|
|
20 m_listCtrl->InsertColumn( 1, itemCol );
|
1
|
21 m_listCtrl->SetColumnWidth( 1, 90 );
|
0
|
22 itemCol.SetText( wxT("氏名") );
|
|
23 m_listCtrl->InsertColumn( 2, itemCol );
|
|
24 m_listCtrl->SetColumnWidth( 2, 80 );
|
|
25 itemCol.SetText( wxT("住所") );
|
|
26 m_listCtrl->InsertColumn( 3, itemCol );
|
1
|
27 m_listCtrl->SetColumnWidth( 3, 240 );
|
|
28 itemCol.SetText( wxT("検索日時") );
|
0
|
29 m_listCtrl->InsertColumn( 4, itemCol );
|
2
|
30 m_listCtrl->SetColumnWidth( 4, 120 );
|
0
|
31
|
|
32 bSizerTop->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );
|
|
33
|
|
34 wxBoxSizer* bSizerBtn = new wxBoxSizer( wxHORIZONTAL );
|
|
35
|
|
36 m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("キャンセル"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
37 bSizerBtn->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
38
|
1
|
39 m_buttonSet = new wxButton( this, ID_SETHIST, wxT("セット"), wxDefaultPosition, wxDefaultSize, 0 );
|
0
|
40 bSizerBtn->Add( m_buttonSet, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
41
|
|
42 bSizerTop->Add( bSizerBtn, 0, wxALIGN_RIGHT|wxALL, 5 );
|
|
43
|
|
44 this->SetSizer( bSizerTop );
|
|
45 this->Layout();
|
|
46
|
|
47 this->Centre( wxBOTH );
|
|
48
|
1
|
49 ReadHistoryList();
|
0
|
50 }
|
|
51
|
|
52 HistDialog::~HistDialog()
|
|
53 {
|
|
54 }
|
|
55
|
|
56 // Event Table
|
|
57 BEGIN_EVENT_TABLE( HistDialog, wxDialog )
|
1
|
58 EVT_LIST_ITEM_ACTIVATED( ID_LISTHIST, HistDialog::OnSelectItem )
|
|
59 EVT_BUTTON( ID_SETHIST, HistDialog::OnSet )
|
0
|
60 END_EVENT_TABLE()
|
|
61
|
|
62
|
2
|
63 void HistDialog::OnSelectItem( wxListEvent& event )
|
1
|
64 {
|
2
|
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 }
|
1
|
80 }
|
0
|
81
|
1
|
82 void HistDialog::OnSet( wxCommandEvent& WXUNUSED(event) )
|
|
83 {
|
2
|
84 long i = -1;
|
|
85 for ( ;; ) {
|
|
86 i = m_listCtrl->GetNextItem( i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
|
87 if ( i == -1 ) break;
|
1
|
88
|
2
|
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 }
|
1
|
104 }
|
|
105
|
|
106 void HistDialog::ReadHistoryList( void )
|
|
107 {
|
0
|
108 wxTextFile file;
|
|
109 wxString filename = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("history");
|
|
110 wxString buf;
|
|
111
|
|
112 if ( file.Open( filename ) ) {
|
|
113
|
2
|
114 for ( size_t i = 0; i < file.GetLineCount(); i++ ) {
|
0
|
115
|
|
116 int col = 0;
|
|
117 m_listCtrl->InsertItem( i, -1 );
|
|
118 buf.Printf( wxT("%02d"), i + 1 );
|
|
119 m_listCtrl->SetItem( i, col, buf, -1 ); // No
|
|
120
|
2
|
121 wxStringTokenizer tkz( file[i], wxT("#") );
|
0
|
122 while ( tkz.HasMoreTokens() ) {
|
|
123 col++;
|
|
124 wxString token = tkz.GetNextToken();
|
|
125 m_listCtrl->SetItem( i, col, token, -1 );
|
|
126 }
|
2
|
127 if ( i % 2 ) m_listCtrl->SetItemBackgroundColour( i, wxColour( wxT("WHEAT") ) );
|
0
|
128 }
|
|
129 }
|
|
130 file.Close();
|
|
131 }
|
|
132
|