Mercurial > mercurial > hgweb_iklist.hg.cgi
comparison src/iklist.cpp @ 2:c0f76f8e67fa draft v1.0
ver 1.0.0 release (add 2 items, time-limit@2022-09-30. & bug fix.)
author | pyon <pyon@macmini> |
---|---|
date | Sat, 28 Aug 2021 09:56:40 +0900 |
parents | 520044113ef0 |
children | d3e201c48ff8 |
comparison
equal
deleted
inserted
replaced
1:13e80a745ef0 | 2:c0f76f8e67fa |
---|---|
1 // Filename : iklist.cpp | 1 // Filename : iklist.cpp |
2 // Last Change: 2021-08-20 金 12:48:51. | 2 // Last Change: 2021-08-27 金 14:20:56. |
3 // | 3 // |
4 #include <wx/textfile.h> | 4 #include <wx/textfile.h> |
5 #include <wx/utils.h> | 5 #include <wx/utils.h> |
6 #include <wx/dir.h> | 6 #include <wx/dir.h> |
7 #include <wx/filefn.h> | 7 #include <wx/filefn.h> |
8 #include <wx/wfstream.h> | 8 #include <wx/wfstream.h> |
9 #include <wx/txtstrm.h> | 9 #include <wx/txtstrm.h> |
10 #include <wx/fs_zip.h> | 10 #include <wx/fs_zip.h> |
11 #include <wx/filesys.h> | 11 #include <wx/filesys.h> |
12 #include <wx/datetime.h> | |
12 #include <wx/msgdlg.h> | 13 #include <wx/msgdlg.h> |
14 #include <wx/fileconf.h> | |
13 | 15 |
14 #include "iklist.h" | 16 #include "iklist.h" |
15 | 17 |
16 /////////////////////////////////////////////////////////////////////////// | 18 /////////////////////////////////////////////////////////////////////////// |
17 | 19 |
18 MainFrame::MainFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) | 20 MainFrame::MainFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) |
19 : wxFrame(parent, id, title, pos, size, style) | 21 : wxFrame(parent, id, title, pos, size, style) |
20 { | 22 { |
23 // Check Limit Date | |
24 wxDateTime today = wxDateTime::Today(); | |
25 wxDateTime limit(30, wxDateTime::Month::Sep, 2022); | |
26 if (today.IsLaterThan(limit)) { | |
27 wxMessageBox(wxT("使用期限が過ぎています.")); | |
28 Close(); | |
29 } | |
30 | |
21 CreateControls(); | 31 CreateControls(); |
22 LoadConfig(); | 32 LoadConfig(); |
33 m_statusBar->SetStatusText(wxString::Format(wxT(" Welcome to I.K.List - version %s"), m_version), 0); | |
23 | 34 |
24 // Connect Events | 35 // Connect Events |
25 m_searchCtrl->Connect(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, wxCommandEventHandler(MainFrame::OnCancel), NULL, this); | 36 m_searchCtrl->Connect(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, wxCommandEventHandler(MainFrame::OnCancel), NULL, this); |
26 m_searchCtrl->Connect(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, wxCommandEventHandler(MainFrame::OnSearch), NULL, this); | 37 m_searchCtrl->Connect(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, wxCommandEventHandler(MainFrame::OnSearch), NULL, this); |
38 m_searchCtrl->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(MainFrame::OnText), NULL, this); | |
27 m_searchCtrl->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MainFrame::OnSearch), NULL, this); | 39 m_searchCtrl->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MainFrame::OnSearch), NULL, this); |
28 m_textCtrl->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MainFrame::OnTextEnter), NULL, this); | 40 m_textCtrl->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MainFrame::OnTextEnter), NULL, this); |
29 m_button->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MainFrame::OnClick), NULL, this); | 41 m_button->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MainFrame::OnClick), NULL, this); |
30 m_choiceCity->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(MainFrame::OnCityChoice), NULL, this); | 42 m_choiceCity->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(MainFrame::OnCityChoice), NULL, this); |
31 m_choiceKind->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(MainFrame::OnKindChoice), NULL, this); | 43 m_choiceKind->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(MainFrame::OnKindChoice), NULL, this); |
39 wxGetEnv(wxT("TEMP"), &tmpdir); | 51 wxGetEnv(wxT("TEMP"), &tmpdir); |
40 wxDir dir(tmpdir); | 52 wxDir dir(tmpdir); |
41 dir.IsOpened(); | 53 dir.IsOpened(); |
42 bool cont = dir.GetFirst(&filename, wxT("iklist-*"), wxDIR_FILES); | 54 bool cont = dir.GetFirst(&filename, wxT("iklist-*"), wxDIR_FILES); |
43 while (cont) { | 55 while (cont) { |
44 wxRemoveFile(tmpdir + wxFILE_SEP_PATH + filename); | 56 wxString file = tmpdir + wxFILE_SEP_PATH + filename; |
57 if (wxFileName::IsFileWritable(file)) | |
58 wxRemoveFile(file); | |
45 cont = dir.GetNext(&filename); | 59 cont = dir.GetNext(&filename); |
46 } | 60 } |
47 | 61 |
48 // Disconnect Events | 62 // Disconnect Events |
49 m_searchCtrl->Disconnect(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, wxCommandEventHandler(MainFrame::OnCancel), NULL, this); | 63 m_searchCtrl->Disconnect(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, wxCommandEventHandler(MainFrame::OnCancel), NULL, this); |
50 m_searchCtrl->Disconnect(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, wxCommandEventHandler(MainFrame::OnSearch), NULL, this); | 64 m_searchCtrl->Disconnect(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, wxCommandEventHandler(MainFrame::OnSearch), NULL, this); |
65 m_searchCtrl->Disconnect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(MainFrame::OnText), NULL, this); | |
51 m_searchCtrl->Disconnect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MainFrame::OnSearch), NULL, this); | 66 m_searchCtrl->Disconnect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MainFrame::OnSearch), NULL, this); |
52 m_textCtrl->Disconnect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MainFrame::OnTextEnter), NULL, this); | |
53 m_button->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MainFrame::OnClick), NULL, this); | |
54 m_choiceCity->Disconnect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(MainFrame::OnCityChoice), NULL, this); | 67 m_choiceCity->Disconnect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(MainFrame::OnCityChoice), NULL, this); |
55 m_choiceKind->Disconnect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(MainFrame::OnKindChoice), NULL, this); | 68 m_choiceKind->Disconnect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(MainFrame::OnKindChoice), NULL, this); |
56 m_dataViewListCtrl->Disconnect(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler(MainFrame::OnListItemActivated), NULL, this); | 69 m_dataViewListCtrl->Disconnect(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler(MainFrame::OnListItemActivated), NULL, this); |
57 } | 70 } |
58 | 71 |
63 } | 76 } |
64 | 77 |
65 void MainFrame::OnCancel(wxCommandEvent& WXUNUSED(event)) | 78 void MainFrame::OnCancel(wxCommandEvent& WXUNUSED(event)) |
66 { | 79 { |
67 m_searchCtrl->Clear(); | 80 m_searchCtrl->Clear(); |
81 SetList(); | |
82 } | |
83 | |
84 void MainFrame::OnText(wxCommandEvent& WXUNUSED(event)) | |
85 { | |
86 SetList(); | |
68 } | 87 } |
69 | 88 |
70 void MainFrame::OnTextEnter(wxCommandEvent& WXUNUSED(event)) | 89 void MainFrame::OnTextEnter(wxCommandEvent& WXUNUSED(event)) |
71 { | 90 { |
72 CheckPassword(); | 91 CheckPassword(); |
93 wxString index = m_dataViewListCtrl->GetTextValue(n, 0); | 112 wxString index = m_dataViewListCtrl->GetTextValue(n, 0); |
94 wxString pdf = MakePDF(index); | 113 wxString pdf = MakePDF(index); |
95 | 114 |
96 wxString cmd = wxT("cmd /c start ") + pdf; | 115 wxString cmd = wxT("cmd /c start ") + pdf; |
97 wxArrayString output, error; | 116 wxArrayString output, error; |
98 wxExecute(cmd, output, error, wxEXEC_HIDE_CONSOLE); | 117 wxExecute(cmd, output, error, wxEXEC_ASYNC|wxEXEC_HIDE_CONSOLE); |
99 } | 118 } |
100 | 119 |
101 // Functions | 120 // Functions |
102 void MainFrame::SetList() | 121 void MainFrame::SetList() |
103 { | 122 { |
104 wxString kw = m_searchCtrl->GetValue(); | 123 wxString text = m_searchCtrl->GetValue(); |
105 wxString city = m_choiceCity->GetString(m_choiceCity->GetSelection()); | 124 wxString city = m_choiceCity->GetString(m_choiceCity->GetSelection()); |
106 wxString kind = m_choiceKind->GetString(m_choiceKind->GetSelection()); | 125 wxString kind = m_choiceKind->GetString(m_choiceKind->GetSelection()); |
107 | 126 |
108 m_dataViewListCtrl->DeleteAllItems(); | 127 m_dataViewListCtrl->DeleteAllItems(); |
109 wxVector<wxVariant> data; | 128 wxVector<wxVariant> data; |
129 unsigned int n = 0; | |
110 for (int i = 0; i < m_data.GetCount(); i++) { | 130 for (int i = 0; i < m_data.GetCount(); i++) { |
111 wxArrayString str = wxSplit(m_data[i], ':'); | 131 wxArrayString str = wxSplit(m_data[i], ':'); |
112 | 132 |
113 data.push_back(wxVariant(wxString::Format(wxT("%04d"), i + 1))); // ID | 133 data.push_back(wxVariant(wxString::Format(wxT("%04d"), i + 1))); // ID |
114 data.push_back(wxVariant(str[0])); // Name | 134 data.push_back(wxVariant(str[0])); // Name |
115 data.push_back(wxVariant(str[1])); // City | 135 data.push_back(wxVariant(str[1])); // City |
116 data.push_back(wxVariant(str[2])); // Kind | 136 data.push_back(wxVariant(str[2])); // Kind |
117 | 137 |
118 unsigned int flag = 0; | 138 bool matched = true; |
119 if (!kw.IsEmpty() && str[0].Find(kw) == wxNOT_FOUND) flag |= 1; | 139 if (!text.IsEmpty() && str[0].Find(text) == wxNOT_FOUND) matched =false; |
120 if (!city.IsEmpty() && str[1].IsSameAs(city)) flag |= 2; | 140 if (!city.IsEmpty() && !str[1].IsSameAs(city)) matched =false; |
121 if (!kind.IsEmpty() && str[2].IsSameAs(kind)) flag |= 4; | 141 if (!kind.IsEmpty() && !str[2].IsSameAs(kind)) matched =false; |
122 if (flag != 0) | 142 |
143 if (!m_inarea && str.GetCount() == 4 && str[3].IsSameAs(wxT("*"))) matched =false; | |
144 | |
145 if (matched) { | |
123 m_dataViewListCtrl->AppendItem(data); | 146 m_dataViewListCtrl->AppendItem(data); |
147 n++; | |
148 } | |
124 | 149 |
125 data.clear(); | 150 data.clear(); |
126 } | 151 } |
127 } | 152 //m_dataViewListCtrl->SetScrollPos(wxVERTICAL, 0, true); |
128 | 153 m_dataViewListCtrl->Scroll(0, 0); |
154 m_statusBar->SetStatusText(wxString::Format(wxT(" %d found."), n), 0); | |
155 } | |
156 #include <wx/sstream.h> | |
129 wxString MainFrame::MakePDF(wxString index) | 157 wxString MainFrame::MakePDF(wxString index) |
130 { | 158 { |
131 wxString file = SearchFile(wxT("data03"), index); | |
132 wxFileInputStream si1(file); | |
133 file = SearchFile(wxT("data04"), index); | |
134 wxFileInputStream si2(file); | |
135 file = SearchFile(wxT("data08"), index); | |
136 wxFileInputStream si3(file); | |
137 | |
138 wxString tmpdir; | 159 wxString tmpdir; |
139 wxGetEnv(wxT("TEMP"), &tmpdir); | 160 wxGetEnv(wxT("TEMP"), &tmpdir); |
140 wxString pdf = tmpdir + "/iklist-" + index + ".pdf"; | 161 wxString pdf = tmpdir + "/iklist-" + index + ".pdf"; |
162 if (wxFile::Exists(pdf)) return pdf; | |
163 | |
164 wxStringInputStream si0(wxT("%PDF")); | |
165 | |
166 wxString file; | |
167 file = SearchFile(wxT("data/03"), index); | |
168 wxFileInputStream si1(file); | |
169 file = SearchFile(wxT("data/04"), index); | |
170 wxFileInputStream si2(file); | |
171 file = SearchFile(wxT("data/08"), index); | |
172 wxFileInputStream si3(file); | |
173 | |
141 wxFileOutputStream so(pdf); | 174 wxFileOutputStream so(pdf); |
175 so << si0; | |
142 so << si1 << si2 << si3; // use chunk buffer to copy if file is big. | 176 so << si1 << si2 << si3; // use chunk buffer to copy if file is big. |
143 | 177 |
144 return pdf; | 178 return pdf; |
145 } | 179 } |
146 | 180 |
158 cont = dir.GetNext(&filename); | 192 cont = dir.GetNext(&filename); |
159 } | 193 } |
160 return directory + wxT("/") + filename; | 194 return directory + wxT("/") + filename; |
161 } | 195 } |
162 | 196 |
197 void MainFrame::LoadConfig() | |
198 { | |
199 wxFileSystem::AddHandler(new wxZipFSHandler); | |
200 wxFileSystem* fs = new wxFileSystem; | |
201 wxString archive = wxT("iklist.lib"); | |
202 | |
203 // Load Password | |
204 wxString pwfn = wxT("p8wypswd5c0x"); | |
205 wxFSFile* pwfile = fs->OpenFile(archive + wxT("#zip:") + pwfn); | |
206 wxString buf; | |
207 if (pwfile) { | |
208 wxInputStream *zstream = pwfile->GetStream(); | |
209 wxTextInputStream tstream(*zstream); | |
210 buf = tstream.ReadLine(); | |
211 delete pwfile; | |
212 } | |
213 for (int i = 0; i < buf.Len(); i++) { // XOR 17 | |
214 m_pswd += wxString::Format(wxT("%c"), buf[i].GetValue() ^ 17); | |
215 } | |
216 | |
217 pwfn = wxT("_p8wypswd5c0x"); | |
218 wxFSFile* gpwfile = fs->OpenFile(archive + wxT("#zip:") + pwfn); | |
219 if (gpwfile) { | |
220 wxInputStream *zstream = gpwfile->GetStream(); | |
221 wxTextInputStream tstream(*zstream); | |
222 buf = tstream.ReadLine(); | |
223 delete gpwfile; | |
224 } | |
225 for (int i = 0; i < buf.Len(); i++) { // XOR 17 | |
226 m_gpswd += wxString::Format(wxT("%c"), buf[i].GetValue() ^ 17); | |
227 } | |
228 | |
229 // Load List | |
230 wxString listfn = wxT("q534list8mor"); | |
231 wxFSFile* listfile = fs->OpenFile(archive + wxT("#zip:") + listfn); | |
232 if (listfile) { | |
233 wxInputStream *zstream = listfile->GetStream(); | |
234 wxTextInputStream tstream(*zstream); | |
235 for (int i = 0; i < 543; i++) { //######################### | |
236 //while (!zstream->Eof()) { | |
237 m_data.Add(tstream.ReadLine()); | |
238 } | |
239 delete listfile; | |
240 } | |
241 | |
242 // Load config | |
243 wxString conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("app.conf"); | |
244 wxFileConfig* conf = new wxFileConfig(wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE); | |
245 conf->SetPath(wxT("/Misc")); | |
246 conf->Read(wxT("version"), &m_version); | |
247 delete conf; | |
248 | |
249 // Set Filter | |
250 wxArrayString filter = GetChoiceArray(1); | |
251 for (int i = 0; i < filter.GetCount(); i++) { | |
252 m_choiceCity->Append(filter[i]); | |
253 } | |
254 m_choiceCity->SetSelection(0); | |
255 | |
256 filter = GetChoiceArray(2); | |
257 for (int i = 0; i < filter.GetCount(); i++) { | |
258 m_choiceKind->Append(filter[i]); | |
259 } | |
260 m_choiceKind->SetSelection(0); | |
261 | |
262 delete fs; | |
263 } | |
264 | |
265 wxArrayString MainFrame::GetChoiceArray(int n) | |
266 { | |
267 wxArrayString filter; | |
268 filter.Add(wxEmptyString); | |
269 for (int i = 0; i < m_data.GetCount(); i++) { | |
270 wxArrayString str = wxSplit(m_data[i], ':'); | |
271 bool seen; | |
272 for (int j = 0; j < filter.GetCount(); j++) { | |
273 if (filter[j].IsSameAs(str[n])) { | |
274 seen = true; | |
275 break; | |
276 } else { | |
277 seen = false; | |
278 } | |
279 } | |
280 if (!seen) filter.Add(str[n]); | |
281 } | |
282 return filter; | |
283 } | |
284 | |
285 void MainFrame::CheckPassword() | |
286 { | |
287 m_inarea = false; | |
288 if (m_textCtrl->GetValue().IsSameAs(m_pswd, true)) { | |
289 m_inarea = true; | |
290 } else if (m_textCtrl->GetValue().IsSameAs(m_gpswd, true)) { | |
291 //; | |
292 } else { | |
293 m_textCtrl->SetBackgroundColour(wxColour(255, 160, 160)); | |
294 m_textCtrl->SelectAll(); | |
295 return; | |
296 } | |
297 m_staticTextWord->SetLabel(wxT("キーワード:")); | |
298 | |
299 m_textCtrl->Disconnect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(MainFrame::OnTextEnter), NULL, this); | |
300 m_button->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MainFrame::OnClick), NULL, this); | |
301 m_textCtrl->Destroy(); | |
302 m_button->Destroy(); | |
303 m_searchCtrl->Show(); | |
304 this->Layout(); | |
305 | |
306 SetList(); | |
307 } | |
308 | |
163 void MainFrame::CreateControls() | 309 void MainFrame::CreateControls() |
164 { | 310 { |
165 this->SetIcon(wxIcon(wxT("sample"))); | 311 this->SetIcon(wxIcon(wxT("sample"))); |
166 this->SetSizeHints(wxDefaultSize, wxDefaultSize); | 312 this->SetSizeHints(wxDefaultSize, wxDefaultSize); |
167 this->SetBackgroundColour(wxColour(130, 170, 210)); | 313 this->SetBackgroundColour(wxColour(130, 170, 210)); |
172 wxBoxSizer* bSizerWord = new wxBoxSizer(wxHORIZONTAL); | 318 wxBoxSizer* bSizerWord = new wxBoxSizer(wxHORIZONTAL); |
173 | 319 |
174 m_staticTextWord = new wxStaticText(this, wxID_ANY, wxT("パスワード:"), wxDefaultPosition, wxDefaultSize, 0); | 320 m_staticTextWord = new wxStaticText(this, wxID_ANY, wxT("パスワード:"), wxDefaultPosition, wxDefaultSize, 0); |
175 bSizerWord->Add(m_staticTextWord, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | 321 bSizerWord->Add(m_staticTextWord, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
176 | 322 |
177 m_searchCtrl = new wxSearchCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(0, -1), 0); | 323 m_textCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200, -1), wxTE_PASSWORD|wxTE_PROCESS_ENTER); |
324 bSizerWord->Add(m_textCtrl, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
325 m_textCtrl->SetFocus(); | |
326 | |
327 m_button = new wxButton(this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxSize(60, -1), 0); | |
328 bSizerWord->Add(m_button, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
329 | |
330 m_searchCtrl = new wxSearchCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200, -1), 0); | |
178 #ifndef __WXMAC__ | 331 #ifndef __WXMAC__ |
179 m_searchCtrl->ShowSearchButton(true); | 332 m_searchCtrl->ShowSearchButton(true); |
180 #endif | 333 #endif |
181 m_searchCtrl->ShowCancelButton(true); | 334 m_searchCtrl->ShowCancelButton(true); |
182 | |
183 bSizerWord->Add(m_searchCtrl, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | 335 bSizerWord->Add(m_searchCtrl, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
184 | |
185 m_textCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200, -1), wxTE_PASSWORD|wxTE_PROCESS_ENTER); | |
186 bSizerWord->Add(m_textCtrl, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
187 m_textCtrl->SetFocus(); | |
188 | |
189 m_button = new wxButton(this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxSize(60, -1), 0); | |
190 bSizerWord->Add(m_button, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | |
191 | 336 |
192 bSizerTop->Add(bSizerWord, 0, wxEXPAND, 5); | 337 bSizerTop->Add(bSizerWord, 0, wxEXPAND, 5); |
193 | 338 |
194 //-- | 339 //-- |
195 wxBoxSizer* bSizerFilter = new wxBoxSizer(wxHORIZONTAL); | 340 wxBoxSizer* bSizerFilter = new wxBoxSizer(wxHORIZONTAL); |
201 bSizerFilter->Add(m_staticTextCity, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | 346 bSizerFilter->Add(m_staticTextCity, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
202 | 347 |
203 wxArrayString m_choiceCityChoices; | 348 wxArrayString m_choiceCityChoices; |
204 m_choiceCity = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceCityChoices, 0); | 349 m_choiceCity = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceCityChoices, 0); |
205 m_choiceCity->SetSelection(0); | 350 m_choiceCity->SetSelection(0); |
351 m_choiceCity->SetBackgroundColour(wxColour(220, 255, 255)); | |
206 bSizerFilter->Add(m_choiceCity, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | 352 bSizerFilter->Add(m_choiceCity, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
207 | 353 |
208 m_staticTextKind = new wxStaticText(this, wxID_ANY, wxT("区分"), wxDefaultPosition, wxDefaultSize, 0); | 354 m_staticTextKind = new wxStaticText(this, wxID_ANY, wxT("区分"), wxDefaultPosition, wxDefaultSize, 0); |
209 bSizerFilter->Add(m_staticTextKind, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | 355 bSizerFilter->Add(m_staticTextKind, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
210 | 356 |
211 wxArrayString m_choiceKindChoices; | 357 wxArrayString m_choiceKindChoices; |
212 m_choiceKind = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceKindChoices, 0); | 358 m_choiceKind = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceKindChoices, 0); |
213 m_choiceKind->SetSelection(0); | 359 m_choiceKind->SetSelection(0); |
360 m_choiceKind->SetBackgroundColour(wxColour(220, 255, 255)); | |
214 bSizerFilter->Add(m_choiceKind, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); | 361 bSizerFilter->Add(m_choiceKind, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); |
215 | 362 |
216 bSizerTop->Add(bSizerFilter, 0, wxEXPAND, 5); | 363 bSizerTop->Add(bSizerFilter, 0, wxEXPAND, 5); |
217 | 364 |
218 //-- | 365 //-- |
223 m_dataViewListColumnKind = m_dataViewListCtrl->AppendTextColumn(wxT(" 区分"), wxDATAVIEW_CELL_INERT, -1, static_cast<wxAlignment>(wxALIGN_LEFT), wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE); | 370 m_dataViewListColumnKind = m_dataViewListCtrl->AppendTextColumn(wxT(" 区分"), wxDATAVIEW_CELL_INERT, -1, static_cast<wxAlignment>(wxALIGN_LEFT), wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE); |
224 bSizerTop->Add(m_dataViewListCtrl, 1, wxALL|wxEXPAND, 5); | 371 bSizerTop->Add(m_dataViewListCtrl, 1, wxALL|wxEXPAND, 5); |
225 | 372 |
226 this->SetSizer(bSizerTop); | 373 this->SetSizer(bSizerTop); |
227 this->Layout(); | 374 this->Layout(); |
375 m_statusBar = this->CreateStatusBar(1, wxSTB_SIZEGRIP, wxID_ANY); | |
376 m_statusBar->SetBackgroundColour(wxColour(130, 170, 210)); | |
228 | 377 |
229 this->Centre(wxBOTH); | 378 this->Centre(wxBOTH); |
230 } | 379 m_searchCtrl->Hide(); |
231 | 380 } |
232 void MainFrame::LoadConfig() | 381 |
233 { | |
234 wxFileSystem::AddHandler(new wxZipFSHandler); | |
235 wxFileSystem* fs = new wxFileSystem; | |
236 wxString archive = wxT("iklist.lib"); | |
237 | |
238 // Load Password | |
239 wxString pwfn = wxT("p8wypswd5c0x"); | |
240 wxFSFile* pwfile = fs->OpenFile(archive + wxT("#zip:") + pwfn); | |
241 if (pwfile) { | |
242 wxInputStream *zstream = pwfile->GetStream(); | |
243 wxTextInputStream tstream(*zstream); | |
244 m_pswd = tstream.ReadLine(); | |
245 delete pwfile; | |
246 } | |
247 | |
248 // Load List | |
249 wxString listfn = wxT("q534list8mor"); | |
250 wxFSFile* listfile = fs->OpenFile(archive + wxT("#zip:") + listfn); | |
251 if (listfile) { | |
252 wxInputStream *zstream = listfile->GetStream(); | |
253 wxTextInputStream tstream(*zstream); | |
254 for (int i = 0; i < 541; i++) { //######################### | |
255 //while (!zstream->Eof()) { | |
256 m_data.Add(tstream.ReadLine()); | |
257 } | |
258 delete listfile; | |
259 } | |
260 | |
261 // Set Filter | |
262 wxArrayString filter1, filter2; | |
263 filter1.Add(wxEmptyString); | |
264 filter2.Add(wxEmptyString); | |
265 for (int i = 0; i < m_data.GetCount(); i++) { | |
266 wxArrayString str = wxSplit(m_data[i], ':'); | |
267 bool flag1, flag2; | |
268 for (int j = 0; j < filter1.GetCount(); j++) { | |
269 if (filter1[j].IsSameAs(str[1])) { | |
270 flag1 = false; | |
271 } else { | |
272 flag1 = true; | |
273 } | |
274 } | |
275 if (flag1) filter1.Add(str[1]); | |
276 | |
277 for (int j = 0; j < filter2.GetCount(); j++) { | |
278 if (filter2[j].IsSameAs(str[2])) { | |
279 flag2 = false; | |
280 } else { | |
281 flag2 = true; | |
282 } | |
283 } | |
284 if (flag2) filter2.Add(str[2]); | |
285 } | |
286 | |
287 for (int i = 0; i < filter1.GetCount(); i++) { | |
288 m_choiceCity->Append(filter1[i]); | |
289 } | |
290 m_choiceCity->SetSelection(0); | |
291 for (int i = 0; i < filter2.GetCount(); i++) { | |
292 m_choiceKind->Append(filter2[i]); | |
293 } | |
294 m_choiceKind->SetSelection(0); | |
295 | |
296 delete fs; | |
297 } | |
298 | |
299 void MainFrame::CheckPassword() | |
300 { | |
301 if (m_textCtrl->GetValue().IsSameAs(m_pswd, true)) { | |
302 m_staticTextWord->SetLabel(wxT("キーワード:")); | |
303 m_searchCtrl->SetSize(200, -1); | |
304 m_textCtrl->SetSize(0, -1); | |
305 m_textCtrl->Hide(); | |
306 m_button->SetSize(0, -1); | |
307 m_button->Hide(); | |
308 SetList(); | |
309 } else { | |
310 m_textCtrl->SetBackgroundColour(wxColour(255, 160, 160)); | |
311 m_textCtrl->SelectAll(); | |
312 } | |
313 } | |
314 |