0
|
1 // Filename : rsearcher.cpp
|
16
|
2 // Last Change: 2019-07-15 Mon 06:58:17.
|
0
|
3 //
|
|
4
|
2
|
5 #include <wx/arrstr.h>
|
3
|
6 #include <wx/html/htmprint.h>
|
5
|
7 #include <wx/clipbrd.h>
|
4
|
8 #include "id.h"
|
11
|
9 #include "mngdb.h"
|
16
|
10 #include "batchprint.h"
|
|
11 #include "index.h"
|
0
|
12 #include "rsearcher.h"
|
|
13 #include "main.h"
|
|
14
|
5
|
15
|
|
16 /********************/
|
|
17 /** HhsClass **/
|
|
18 /********************/
|
|
19 HhsClass::HhsClass( wxArrayString& buf )
|
|
20 {
|
|
21 no = buf[0];
|
|
22 birth = buf[1];
|
|
23 name = buf[2];
|
|
24 kana = buf[3];
|
|
25 addr = buf[4];
|
|
26 sex = buf[5];
|
|
27 }
|
|
28
|
0
|
29 /********************/
|
|
30 /** MySearchCtrl **/
|
|
31 /********************/
|
|
32 MySearchCtrl::MySearchCtrl( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style )
|
|
33 : wxSearchCtrl( parent, id, value, pos, size, style )
|
|
34 {
|
|
35 m_parent = parent;
|
|
36 SetMaxLength( 10 );
|
|
37 #ifndef __WXMAC__
|
|
38 ShowSearchButton( true );
|
|
39 #endif
|
|
40 ShowCancelButton( false );
|
|
41
|
|
42 wxFont font( 12, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD );
|
|
43 SetFont( font );
|
|
44 }
|
|
45
|
|
46 MySearchCtrl::~MySearchCtrl()
|
|
47 {
|
|
48 }
|
|
49
|
|
50 // Event Table
|
|
51 BEGIN_EVENT_TABLE( MySearchCtrl, wxSearchCtrl )
|
|
52 EVT_CHAR( MySearchCtrl::OnKey )
|
|
53 END_EVENT_TABLE()
|
|
54
|
|
55 // Event Handlers & Functions
|
|
56 void MySearchCtrl::OnKey( wxKeyEvent& event )
|
|
57 {
|
|
58 int kc = event.GetKeyCode();
|
|
59
|
|
60 if ( kc == 13 ) { // Enter
|
2
|
61 SelectAll();
|
0
|
62
|
|
63 MainFrame* f = (MainFrame*)FindWindowById( ID_MAIN );
|
2
|
64 f->Cmd( GetValue() );
|
0
|
65
|
|
66 event.Skip();
|
|
67 return;
|
|
68 }
|
|
69
|
|
70 if ( kc == 45 ) { // Num-Key '-' as Backspace
|
|
71 wxString t = GetStringSelection();
|
|
72 if ( t.IsEmpty() ) {
|
|
73 long p = GetInsertionPoint();
|
|
74 if ( p > 0 ) Remove( p - 1, p );
|
|
75 }
|
|
76 else {
|
|
77 Cut();
|
|
78 }
|
|
79 return;
|
|
80 }
|
|
81
|
|
82 if ( kc == WXK_ESCAPE ) { // clear by ESC
|
|
83 this->Clear();
|
|
84 return;
|
|
85 }
|
|
86
|
|
87 event.Skip();
|
|
88 }
|
|
89
|
|
90 /********************/
|
|
91 /** MyStaticBitmap **/
|
|
92 /********************/
|
|
93 MyStaticBitmap::MyStaticBitmap( wxScrolledWindow *parent, wxWindowID id, const wxBitmap &label, const wxPoint &pos, const wxSize &size, long style, const wxString &name )
|
|
94 : wxStaticBitmap( parent, id, label, pos, size, style, name )
|
|
95 {
|
|
96 m_parent = parent;
|
16
|
97 Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( MyStaticBitmap::OnLeftDown ), NULL, this );
|
|
98 Connect( wxEVT_LEFT_UP, wxMouseEventHandler( MyStaticBitmap::OnLeftUp ), NULL, this );
|
|
99 Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( MyStaticBitmap::OnLeftDClick ), NULL, this );
|
|
100 Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( MyStaticBitmap::OnRightDClick ), NULL, this );
|
|
101 Connect( wxEVT_MOTION, wxMouseEventHandler( MyStaticBitmap::OnMotion ), NULL, this );
|
|
102 Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( MyStaticBitmap::OnWheel ), NULL, this );
|
|
103 Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( MyStaticBitmap::OnStartRGesture ), NULL, this );
|
|
104 Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( MyStaticBitmap::OnEndRGesture ), NULL, this );
|
0
|
105 }
|
|
106
|
|
107 MyStaticBitmap::~MyStaticBitmap()
|
|
108 {
|
16
|
109 Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( MyStaticBitmap::OnLeftDown ), NULL, this );
|
|
110 Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( MyStaticBitmap::OnLeftUp ), NULL, this );
|
|
111 Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( MyStaticBitmap::OnLeftDClick ), NULL, this );
|
|
112 Disconnect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( MyStaticBitmap::OnRightDClick ), NULL, this );
|
|
113 Disconnect( wxEVT_MOTION, wxMouseEventHandler( MyStaticBitmap::OnMotion ), NULL, this );
|
|
114 Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( MyStaticBitmap::OnWheel ), NULL, this );
|
|
115 Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( MyStaticBitmap::OnStartRGesture ), NULL, this );
|
|
116 Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( MyStaticBitmap::OnEndRGesture ), NULL, this );
|
0
|
117 }
|
|
118
|
|
119 // Event Handlers
|
|
120 void MyStaticBitmap::OnWheel( wxMouseEvent& event )
|
|
121 {
|
9
|
122 /*
|
0
|
123 if ( event.ControlDown() ) {
|
|
124 if ( event.GetWheelRotation() < 0 ) {
|
|
125 }
|
|
126 else {
|
|
127 }
|
|
128 return;
|
|
129 }
|
|
130 event.Skip();
|
9
|
131 */
|
0
|
132 }
|
|
133
|
|
134 void MyStaticBitmap::OnLeftDown( wxMouseEvent& event )
|
|
135 {
|
|
136 event.GetPosition( &m_dragx, &m_dragy );
|
|
137 SetCursor( wxCursor( wxCURSOR_SIZING ) );
|
|
138 }
|
|
139
|
|
140 void MyStaticBitmap::OnLeftUp( wxMouseEvent& WXUNUSED(event) )
|
|
141 {
|
|
142 SetCursor( wxCursor( wxCURSOR_ARROW ) );
|
|
143 }
|
|
144
|
9
|
145 void MyStaticBitmap::OnLeftDClick( wxMouseEvent& event )
|
|
146 {
|
|
147 if ( with_stl ) return;
|
|
148 MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN );
|
|
149 mf->ChangeCZoom( 1 );
|
|
150 }
|
|
151
|
|
152 void MyStaticBitmap::OnRightDClick( wxMouseEvent& event )
|
|
153 {
|
|
154 if ( with_stl ) return;
|
|
155 MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN );
|
|
156 mf->ChangeCZoom( -1 );
|
|
157 }
|
|
158
|
0
|
159 void MyStaticBitmap::OnMotion( wxMouseEvent& event )
|
|
160 {
|
5
|
161 if ( event.RightIsDown() ) return;
|
0
|
162 if ( event.Dragging() ) {
|
|
163 int xv, yv, x, y;
|
|
164 m_parent->GetViewStart( &xv, &yv );
|
|
165
|
|
166 event.GetPosition( &x, &y );
|
|
167
|
|
168 int xa = abs( x - m_dragx );
|
|
169 int ya = abs( y - m_dragy );
|
|
170 int xs = x - m_dragx < 0 ? -1 : 1;
|
|
171 int ys = y - m_dragy < 0 ? -1 : 1;
|
|
172
|
|
173 /* handai dakedo sumu-zu
|
|
174 m_parent->Scroll( xv + xs * log10( xa + 1 ), yv + ys * log10( ya + 1 ) );
|
|
175 */
|
|
176 m_parent->Scroll( xv + xs * log10( xa + 1 ), yv + ys * log10( ya + 1 ) );
|
|
177
|
|
178 m_dragx = x; m_dragy = y;
|
|
179 }
|
|
180 }
|
|
181
|
3
|
182 /* right-gesture: start detect */
|
|
183 void MyStaticBitmap::OnStartRGesture( wxMouseEvent& event )
|
|
184 {
|
|
185 event.GetPosition( &cx, &cy );
|
|
186 }
|
|
187
|
|
188 /* right-gesture: judge */
|
|
189 void MyStaticBitmap::OnEndRGesture( wxMouseEvent& event )
|
|
190 {
|
9
|
191 if ( with_stl ) return;
|
3
|
192 int x, y;
|
|
193 event.GetPosition( &x, &y );
|
|
194
|
|
195 int dx = x - cx;
|
|
196 int dy = y - cy;
|
|
197 float rad = fabs( atan2( dy, dx ) );
|
|
198 float pi = 3.14159;
|
|
199
|
|
200 // to right
|
4
|
201 if ( rad < pi / 8 && dx > 0 ) {
|
|
202 ChangeBook( 1 );
|
3
|
203 }
|
|
204 // to left
|
4
|
205 else if ( rad > pi / 8 * 7 && rad < pi && dx < 0 ) {
|
|
206 ChangeBook( -1 );
|
3
|
207 }
|
|
208 // to up-right
|
4
|
209 else if ( rad > pi / 8 && rad < pi / 8 * 3 && dx > 0 ) {
|
5
|
210 MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN );
|
|
211 mf->Close();
|
3
|
212 }
|
4
|
213 // down
|
|
214 else if ( rad > pi / 8 * 3 && rad < pi / 8 * 5 && dy > 0 ) {
|
|
215 MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN );
|
|
216 mf->PrintImages();
|
|
217 }
|
|
218 //wxMessageBox( wxString::Format( "%d %d %f", dx, dy, rad ));
|
3
|
219 }
|
|
220
|
0
|
221 // Functions
|
4
|
222 void MyStaticBitmap::ChangeBook( int i )
|
|
223 {
|
|
224 wxNotebook* nb = (wxNotebook*)FindWindowById( ID_NBOOK );
|
|
225 int n = nb->GetSelection();
|
|
226 if ( i > 0 ) {
|
|
227 if ( n == nb->GetPageCount() - 1 ) return;
|
|
228 nb->SetSelection( ++n );
|
|
229 } else {
|
|
230 if ( n == 0 ) return;
|
|
231 nb->SetSelection( --n );
|
|
232 }
|
|
233 }
|
0
|
234
|
|
235 /********************/
|
9
|
236 /** SatteliteView **/
|
|
237 /********************/
|
|
238 StlFrame::StlFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
|
|
239 : wxFrame( parent, id, title, pos, size, style )
|
|
240 {
|
|
241 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL );
|
|
242
|
|
243 m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
244 m_scrolledWindow->SetScrollRate( 5, 5 );
|
|
245
|
|
246 m_staticBitmap = new MyStaticBitmap( m_scrolledWindow, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
247 m_staticBitmap->WithSatellite( true );
|
|
248
|
|
249 bSizerTop->Add( m_scrolledWindow, 1, wxEXPAND|wxALL, 0 );
|
|
250
|
|
251 this->SetSizer( bSizerTop );
|
|
252 this->Layout();
|
|
253 }
|
|
254
|
|
255 StlFrame::~StlFrame()
|
|
256 {
|
|
257 }
|
|
258
|
|
259 /********************/
|
0
|
260 /** Main Frame **/
|
|
261 /********************/
|
|
262 MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
|
|
263 : wxFrame( parent, id, title, pos, size, style )
|
|
264 {
|
7
|
265 http = RsHttp();
|
1
|
266 CreateControls();
|
5
|
267 SetAccelerator();
|
|
268 LoadBitmaps( wxEmptyString, false );
|
3
|
269 m_timer.SetOwner( this, ID_TIMER );
|
1
|
270 }
|
|
271
|
|
272 MainFrame::~MainFrame()
|
|
273 {
|
|
274 }
|
|
275
|
|
276 // Event Table
|
|
277 BEGIN_EVENT_TABLE( MainFrame, wxFrame )
|
10
|
278 EVT_SPLITTER_DCLICK( ID_SPLIT, MainFrame::OnSplitWin )
|
2
|
279 EVT_DATAVIEW_SELECTION_CHANGED( ID_LIST, MainFrame::OnItemSelected )
|
1
|
280 EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked )
|
10
|
281 EVT_DATAVIEW_SELECTION_CHANGED( ID_LISTKANA, MainFrame::OnKanaItemSelected )
|
|
282 EVT_DATAVIEW_ITEM_ACTIVATED( ID_LISTKANA, MainFrame::OnKanaItemDClicked )
|
1
|
283 EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged )
|
7
|
284 EVT_BUTTON( ID_PSEARCH, MainFrame::OnPasteSearch )
|
3
|
285 EVT_BUTTON( wxID_PRINT, MainFrame::OnPrint )
|
7
|
286 EVT_CLOSE( MainFrame::OnClose )
|
|
287 EVT_IDLE( MainFrame::OnIdle )
|
|
288 EVT_TIMER( ID_TIMER, MainFrame::OnTimer )
|
|
289 // shortcut-key
|
16
|
290 EVT_BUTTON( ID_FOCUS, MainFrame::OnFocus )
|
|
291 EVT_BUTTON( ID_PZOOM, MainFrame::OnPlusZoom )
|
|
292 EVT_BUTTON( ID_MZOOM, MainFrame::OnMinusZoom )
|
|
293 EVT_BUTTON( ID_DARK, MainFrame::OnDark )
|
|
294 EVT_BUTTON( ID_SWIN, MainFrame::OnSatellite )
|
|
295 EVT_BUTTON( ID_UPIDX, MainFrame::OnUpdateIndex )
|
|
296 EVT_BUTTON( ID_DLMAN, MainFrame::OnDownloadManual )
|
|
297 EVT_BUTTON( ID_BPRINT, MainFrame::OnBatchPrint )
|
|
298 EVT_BUTTON( ID_INDEX, MainFrame::OnIndex )
|
|
299 EVT_BUTTON( wxID_HELP, MainFrame::OnHelp )
|
7
|
300 EVT_BUTTON( wxID_CLOSE, MainFrame::OnBClose )
|
16
|
301 EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout )
|
1
|
302 END_EVENT_TABLE()
|
|
303
|
|
304
|
|
305 // Event Handler
|
10
|
306 void MainFrame::OnSplitWin( wxSplitterEvent& WXUNUSED(event) )
|
|
307 {
|
|
308 int w, h;
|
|
309 this->GetSize( &w, &h );
|
|
310 m_splitter->SetSashPosition( w - 200, true );
|
|
311 }
|
|
312
|
2
|
313 void MainFrame::OnItemSelected( wxDataViewEvent& WXUNUSED(event) )
|
|
314 {
|
|
315 int r = m_dataViewListCtrl->GetSelectedRow();
|
9
|
316 if ( r == wxNOT_FOUND ) return;
|
|
317
|
2
|
318 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 );
|
3
|
319 if ( ready.IsSameAs( wxT( "OK" ), true ) ) {
|
|
320 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
321 date.Replace( wxT( "-" ), wxEmptyString, true );
|
5
|
322 LoadBitmaps( date, false );
|
3
|
323 } else {
|
5
|
324 LoadBitmaps( wxEmptyString, false );
|
2
|
325 }
|
|
326 }
|
|
327
|
1
|
328 void MainFrame::OnItemDClicked( wxDataViewEvent& WXUNUSED(event) )
|
|
329 {
|
|
330 int r = m_dataViewListCtrl->GetSelectedRow();
|
3
|
331 wxString status = m_dataViewListCtrl->GetTextValue( r, 2 );
|
|
332 if ( status.IsSameAs( wxT( "OK" ), true ) ) return;
|
|
333
|
2
|
334 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
335 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
336 GetImages( m_hhs, date );
|
5
|
337 if ( LoadBitmaps( date, true ) )
|
|
338 m_dataViewListCtrl->SetTextValue( wxT( "OK" ), r, 2 );
|
1
|
339 }
|
|
340
|
10
|
341 void MainFrame::OnKanaItemSelected( wxDataViewEvent& WXUNUSED(event) )
|
|
342 {
|
|
343 int r = m_dataViewListKana->GetSelectedRow();
|
|
344 if ( r == wxNOT_FOUND ) return;
|
|
345 }
|
|
346
|
|
347 void MainFrame::OnKanaItemDClicked( wxDataViewEvent& WXUNUSED(event) )
|
|
348 {
|
|
349 m_dataViewListCtrl->DeleteAllItems();
|
|
350 wxGetApp().RemoveFile( wxT( ".cache/*" ) );
|
|
351 LoadBitmaps( wxEmptyString, false );
|
|
352
|
|
353 int r = m_dataViewListKana->GetSelectedRow();
|
|
354 m_searchCtrl->SetValue( m_dataViewListKana->GetTextValue( r, 0 ) );
|
|
355 m_textCtrlName->SetValue( m_dataViewListKana->GetTextValue( r, 1 ) );
|
|
356 m_textCtrlAddr->SetValue( m_dataViewListKana->GetTextValue( r, 2 ) );
|
|
357 m_hhs = m_searchCtrl->GetValue();
|
|
358 Search();
|
|
359 }
|
|
360
|
1
|
361 void MainFrame::OnNBookChanged( wxBookCtrlEvent& WXUNUSED(event) )
|
|
362 {
|
|
363 for ( int i = 0; i < m_notebook->GetPageCount(); i++ ) {
|
|
364 m_notebook->SetPageImage( i, 1 );
|
|
365 }
|
|
366 m_notebook->SetPageImage( m_notebook->GetSelection(), 0 );
|
|
367 }
|
|
368
|
7
|
369 void MainFrame::OnBClose( wxCommandEvent& WXUNUSED(event) )
|
|
370 {
|
|
371 Close();
|
|
372 }
|
|
373
|
|
374 void MainFrame::OnClose( wxCloseEvent& WXUNUSED(event) )
|
1
|
375 {
|
7
|
376 Close();
|
|
377 }
|
|
378
|
|
379 void MainFrame::OnFocus( wxCommandEvent& WXUNUSED(event) )
|
|
380 {
|
|
381 m_searchCtrl->SetFocus();
|
1
|
382 }
|
|
383
|
5
|
384 void MainFrame::OnPasteSearch( wxCommandEvent& WXUNUSED(event) )
|
|
385 {
|
8
|
386 m_textCtrlName->SetValue( wxEmptyString );
|
|
387 m_textCtrlAddr->SetValue( wxEmptyString );
|
|
388 m_dataViewListCtrl->DeleteAllItems();
|
|
389 PasteSearch();
|
5
|
390 }
|
|
391
|
3
|
392 void MainFrame::OnPrint( wxCommandEvent& WXUNUSED(event) )
|
|
393 {
|
|
394 PrintImages();
|
|
395 }
|
|
396
|
6
|
397 void MainFrame::OnPlusZoom( wxCommandEvent& WXUNUSED(event) )
|
|
398 {
|
|
399 ChangeCZoom( 1 );
|
|
400 }
|
|
401
|
|
402 void MainFrame::OnMinusZoom( wxCommandEvent& WXUNUSED(event ) )
|
|
403 {
|
|
404 ChangeCZoom( -1 );
|
|
405 }
|
|
406
|
|
407 void MainFrame::OnDark( wxCommandEvent& WXUNUSED(event ) )
|
|
408 {
|
|
409 ChangeColor( m_staticBitmap1 );
|
|
410 ChangeColor( m_staticBitmap2 );
|
|
411 ChangeColor( m_staticBitmap3 );
|
|
412 ChangeColor( m_staticBitmap4 );
|
|
413 ChangeColor( m_staticBitmap5 );
|
|
414 m_dark = !m_dark;
|
|
415 }
|
|
416
|
9
|
417 void MainFrame::OnSatellite( wxCommandEvent& WXUNUSED(event ) )
|
|
418 {
|
|
419 int n = m_notebook->GetSelection();
|
|
420 StlFrame *stl = new StlFrame( this, wxID_ANY, wxT( "Re:Searcher - satellite view" ), wxPoint( 0, 0 ), wxSize( 500, 600 ), wxFRAME_NO_TASKBAR|wxCLOSE_BOX|wxCAPTION|wxRESIZE_BORDER );
|
|
421 wxBitmap bmp;
|
|
422 if ( n == 0 ) bmp = m_staticBitmap1->GetBitmap();
|
|
423 if ( n == 1 ) bmp = m_staticBitmap2->GetBitmap();
|
|
424 if ( n == 2 ) bmp = m_staticBitmap3->GetBitmap();
|
|
425 if ( n == 3 ) bmp = m_staticBitmap4->GetBitmap();
|
|
426 if ( n == 4 ) bmp = m_staticBitmap5->GetBitmap();
|
|
427 stl->SetBitmap( bmp );
|
|
428
|
|
429 int w = bmp.GetWidth();
|
|
430 int h = bmp.GetHeight();
|
|
431 stl->SetScroll( w, h );
|
|
432
|
|
433 stl->Show();
|
|
434 }
|
|
435
|
13
|
436 void MainFrame::OnUpdateIndex( wxCommandEvent& WXUNUSED(event ) )
|
|
437 {
|
15
|
438 GetDB( false, false, true );
|
13
|
439 UpdateIndex();
|
|
440 wxMessageBox( wxT( "update index done." ) );
|
|
441 }
|
|
442
|
|
443 void MainFrame::OnDownloadManual( wxCommandEvent& WXUNUSED(event) )
|
|
444 {
|
|
445 wxString execmd = wxT( "cmd /c start manual.pdf" );
|
|
446 wxExecute( execmd );
|
|
447 }
|
|
448
|
16
|
449 void MainFrame::OnIndex( wxCommandEvent& WXUNUSED(event) )
|
|
450 {
|
|
451 IndexFrame *idx = new IndexFrame( NULL, wxID_ANY, wxT( "Index" ), wxPoint( 0, 0 ), wxSize( 800, 500 ), wxDEFAULT_FRAME_STYLE );
|
|
452 idx->Show( true );
|
|
453 idx->Raise();
|
|
454 }
|
|
455
|
|
456 void MainFrame::OnBatchPrint( wxCommandEvent& WXUNUSED(event) )
|
|
457 {
|
|
458 BatchPrintFrame *bp = new BatchPrintFrame( NULL, wxID_ANY, wxT( "Batch Print" ), wxPoint( 0, 0 ), wxSize( 800, 500 ), wxDEFAULT_FRAME_STYLE );
|
|
459 bp->Show( true );
|
|
460 bp->Raise();
|
|
461 }
|
|
462
|
5
|
463 void MainFrame::OnHelp( wxCommandEvent& WXUNUSED(event) )
|
|
464 {
|
|
465 wxString version, build;
|
10
|
466 version = wxString::Format( wxT( "Re:Searcher -- version %s / %s\n\n" ), RSVER, RSRELEASE );
|
5
|
467 build = wxString::Format( wxT( "build with %s\nrunning under %s." ), wxVERSION_STRING, wxGetOsDescription() );
|
|
468
|
|
469 wxMessageBox( version + build, wxT( "Help" ) );
|
|
470 return;
|
|
471 }
|
|
472
|
3
|
473 void MainFrame::OnLogout( wxCommandEvent& WXUNUSED(event) )
|
|
474 {
|
|
475 wxMessageBox("logout");
|
|
476 return;
|
|
477 }
|
|
478
|
|
479 void MainFrame::OnTimer( wxTimerEvent& WXUNUSED(event) )
|
|
480 {
|
5
|
481 //wxMessageBox( "timer !" );
|
3
|
482 // logout
|
|
483 }
|
|
484
|
|
485 void MainFrame::OnIdle( wxIdleEvent& event )
|
|
486 {
|
|
487 if ( !m_timer.IsRunning() ) {
|
|
488 m_timer.Start( 300 * 1000, wxTIMER_ONE_SHOT );
|
|
489 }
|
|
490 event.RequestMore();
|
|
491 event.Skip();
|
|
492 }
|
|
493
|
1
|
494 // Functions
|
|
495 void MainFrame::CreateControls( void )
|
|
496 {
|
0
|
497 this->SetIcon( wxIcon( wxT( "sample" ) ) );
|
10
|
498 this->SetSizeHints( wxSize( 400, 300 ), wxDefaultSize );
|
5
|
499 this->SetBackgroundColour( wxColour( 30, 80, 40 ) );
|
|
500 //this->SetBackgroundColour( wxColour( 153, 153, 153 ) );
|
0
|
501
|
|
502 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL );
|
10
|
503
|
|
504 m_splitter = new wxSplitterWindow( this, ID_SPLIT, wxDefaultPosition, wxDefaultSize, wxSP_THIN_SASH );
|
|
505 m_splitter->SetMinimumPaneSize( 20 );
|
|
506 m_panelLeft = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
|
507 m_panelLeft->SetBackgroundColour( wxColour( 30, 80, 40 ) );
|
|
508 m_panelRight = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
|
509 m_panelRight->SetBackgroundColour( wxColour( 30, 80, 40 ) );
|
|
510
|
|
511 int w, h;
|
|
512 this->GetSize( &w, &h );
|
|
513 m_splitter->SplitVertically( m_panelLeft, m_panelRight, w - 200 );
|
0
|
514
|
|
515 // Left
|
10
|
516 wxBoxSizer* bSizerLeft = new wxBoxSizer( wxVERTICAL );
|
|
517
|
0
|
518 wxImageList* imgList = new wxImageList( 16, 16, false, 1 );
|
|
519 wxBitmap bmp( wxT( "image/blue.png" ), wxBITMAP_TYPE_PNG );
|
|
520 imgList->Add( bmp, wxNullBitmap );
|
|
521 bmp.LoadFile( wxT( "image/water.png" ), wxBITMAP_TYPE_PNG );
|
|
522 imgList->Add( bmp, wxNullBitmap );
|
|
523
|
10
|
524 m_notebook = new wxNotebook( m_panelLeft, ID_NBOOK, wxDefaultPosition, wxDefaultSize, 0 );
|
0
|
525 m_notebook->SetImageList( imgList );
|
|
526
|
|
527 m_scrolledWindow1 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
528 m_scrolledWindow1->SetScrollRate( 5, 5 );
|
|
529 m_notebook->AddPage( m_scrolledWindow1, wxT( "Image-01" ), false, 0 );
|
|
530
|
|
531 m_scrolledWindow2 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
532 m_scrolledWindow2->SetScrollRate( 5, 5 );
|
|
533 m_notebook->AddPage( m_scrolledWindow2, wxT( "Image-02" ), false, 0 );
|
|
534
|
|
535 m_scrolledWindow3 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
536 m_scrolledWindow3->SetScrollRate( 5, 5 );
|
|
537 m_notebook->AddPage( m_scrolledWindow3, wxT( "Image-03" ), false, 0 );
|
|
538
|
|
539 m_scrolledWindow4 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
540 m_scrolledWindow4->SetScrollRate( 5, 5 );
|
|
541 m_notebook->AddPage( m_scrolledWindow4, wxT( "Image-04" ), false, 0 );
|
|
542
|
|
543 m_scrolledWindow5 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
544 m_scrolledWindow5->SetScrollRate( 5, 5 );
|
|
545 m_notebook->AddPage( m_scrolledWindow5, wxT( "Image-05" ), false, 0 );
|
|
546
|
|
547 m_scrolledWindow6 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
548 m_scrolledWindow6->SetScrollRate( 5, 5 );
|
|
549 m_notebook->AddPage( m_scrolledWindow6, wxT( "Image-06" ), false, 0 );
|
|
550
|
10
|
551 bSizerLeft->Add( m_notebook, 1, wxEXPAND|wxALL, 5 );
|
|
552 m_panelLeft->SetSizer( bSizerLeft );
|
0
|
553
|
|
554 // Right
|
|
555 wxBoxSizer* bSizerRight = new wxBoxSizer( wxVERTICAL );
|
|
556
|
10
|
557 m_searchCtrl = new MySearchCtrl( m_panelRight, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxSize( -1, 24 ), wxTE_PROCESS_ENTER );
|
0
|
558 bSizerRight->Add( m_searchCtrl, 0, wxALL, 5 );
|
|
559 m_searchCtrl->SetFocus();
|
|
560
|
10
|
561 m_textCtrlName = new wxTextCtrl( m_panelRight, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), wxTE_READONLY );
|
0
|
562 m_textCtrlName->SetBackgroundColour( wxColour( 180, 210, 240 ) );
|
|
563 bSizerRight->Add( m_textCtrlName, 0, wxALL, 5 );
|
|
564
|
10
|
565 m_textCtrlAddr = new wxTextCtrl( m_panelRight, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 160, -1 ), wxTE_READONLY );
|
0
|
566 m_textCtrlAddr->SetBackgroundColour( wxColour( 180, 210, 240 ) );
|
|
567 bSizerRight->Add( m_textCtrlAddr, 0, wxALL|wxEXPAND, 5 );
|
|
568
|
10
|
569 m_dataViewListCtrl = new wxDataViewListCtrl( m_panelRight, ID_LIST, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE );
|
|
570 m_dataViewListColumnNo = m_dataViewListCtrl->AppendTextColumn( wxT( "No" ), wxDATAVIEW_CELL_INERT, 30, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
571 m_dataViewListColumnDate = m_dataViewListCtrl->AppendTextColumn( wxT( " Date" ), wxDATAVIEW_CELL_INERT, 80, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
572 m_dataViewListColumnReady = m_dataViewListCtrl->AppendTextColumn( wxT( "Ready" ), wxDATAVIEW_CELL_INERT, 60, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
0
|
573 bSizerRight->Add( m_dataViewListCtrl, 1, wxALL|wxEXPAND, 5 );
|
|
574
|
10
|
575 m_dataViewListKana = new wxDataViewListCtrl( m_panelRight, ID_LISTKANA, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE );
|
|
576 m_dataViewListColumnKNo = m_dataViewListKana->AppendTextColumn( wxT( " No" ), wxDATAVIEW_CELL_INERT, 70, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
577 m_dataViewListColumnName = m_dataViewListKana->AppendTextColumn( wxT( " Name" ), wxDATAVIEW_CELL_INERT, 80, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
578 m_dataViewListColumnAddr = m_dataViewListKana->AppendTextColumn( wxT( " Address" ), wxDATAVIEW_CELL_INERT, -1, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
579 bSizerRight->Add( m_dataViewListKana, 1, wxALL|wxEXPAND, 5 );
|
|
580
|
15
|
581 m_checkListBox = new wxCheckListBox( m_panelRight, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
|
|
582 m_checkListBox->Append( wxT( "1: Marksheet" ) );
|
|
583 m_checkListBox->Append( wxT( "2: Marksheet ( R )" ) );
|
|
584 m_checkListBox->Append( wxT( "3: Special Mention" ) );
|
|
585 m_checkListBox->Append( wxT( "4: Opinion" ) );
|
|
586 m_checkListBox->Append( wxT( "5: Opinion ( R )" ) );
|
|
587 bSizerRight->Add( m_checkListBox, 0, wxALL|wxEXPAND, 5 );
|
|
588
|
10
|
589 m_textCtrlLog = new wxTextCtrl( m_panelRight, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1, 40 ), 0 );
|
|
590 bSizerRight->Add( m_textCtrlLog, 0, wxALL|wxEXPAND, 5 );
|
0
|
591
|
14
|
592 wxFlexGridSizer* fgSizerButton = new wxFlexGridSizer( 0, 2, 0, 0 );
|
|
593 fgSizerButton->SetFlexibleDirection( wxBOTH );
|
|
594 fgSizerButton->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
|
595
|
10
|
596 m_buttonPsearch = new wxButton( m_panelRight, ID_PSEARCH, wxT( "Paste-Search" ), wxDefaultPosition, wxDefaultSize, 0 );
|
14
|
597 fgSizerButton->Add( m_buttonPsearch, 0, wxALL, 5 );
|
5
|
598
|
14
|
599 fgSizerButton->Add( 0, 0, 1, wxEXPAND, 5 );
|
|
600
|
10
|
601 m_buttonPrint = new wxButton( m_panelRight, wxID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 );
|
14
|
602 fgSizerButton->Add( m_buttonPrint, 0, wxALL, 5 );
|
0
|
603
|
14
|
604 m_spinCtrl = new wxSpinCtrl( m_panelRight, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 60, -1 ), wxALIGN_CENTER_HORIZONTAL|wxSP_ARROW_KEYS, 1, 100, 100 );
|
|
605 fgSizerButton->Add( m_spinCtrl, 0, wxALL, 5 );
|
|
606
|
|
607 bSizerRight->Add( fgSizerButton, 0, wxEXPAND, 5 );
|
|
608
|
|
609 /* now building... */
|
10
|
610 m_slider = new wxSlider( m_panelRight, ID_SLDR, 1, 1, 5, wxDefaultPosition, wxSize( -1, 200 ), wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LABELS|wxSL_VERTICAL );
|
|
611 //bSizerRight->Add( m_slider, 0, wxALL, 5 );
|
|
612
|
|
613 m_buttonLogout = new wxButton( m_panelRight, ID_LOGOUT, wxT( "Logout" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
614 //bSizerRight->Add( m_buttonLogout, 0, wxALL, 5 );
|
3
|
615
|
6
|
616 // invisible buttons for shortcut-key
|
7
|
617 m_buttonFocus = new wxButton( this, ID_FOCUS, wxT( "Focus" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
618 m_buttonFocus->Hide();
|
6
|
619 m_buttonPzoom = new wxButton( this, ID_PZOOM, wxT( "ZOOM" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
620 m_buttonPzoom->Hide();
|
|
621 m_buttonMzoom = new wxButton( this, ID_MZOOM, wxT( "zoom" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
622 m_buttonMzoom->Hide();
|
|
623 m_buttonDark = new wxButton( this, ID_DARK, wxT( "Dark" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
624 m_buttonDark->Hide();
|
9
|
625 m_buttonSatellite = new wxButton( this, ID_SWIN, wxT( "Satellite" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
626 m_buttonSatellite->Hide();
|
16
|
627 m_buttonIndex = new wxButton( this, ID_INDEX, wxT( "Index" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
628 m_buttonIndex->Hide();
|
|
629 m_buttonBPrint = new wxButton( this, ID_BPRINT, wxT( "Batch Print" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
630 m_buttonBPrint->Hide();
|
13
|
631 m_buttonDLMan = new wxButton( this, ID_DLMAN, wxT( "Manual" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
632 m_buttonDLMan->Hide();
|
|
633 m_buttonUpdateIndex = new wxButton( this, ID_UPIDX, wxT( "Update Index" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
634 m_buttonUpdateIndex->Hide();
|
10
|
635 m_buttonClose = new wxButton( this, wxID_CLOSE, wxT( "Close" ), wxDefaultPosition, wxDefaultSize, 0 );
|
7
|
636 m_buttonClose->Hide();
|
10
|
637 m_buttonHelp = new wxButton( this, wxID_HELP, wxT( "Help" ), wxDefaultPosition, wxDefaultSize, 0 );
|
6
|
638 m_buttonHelp->Hide();
|
|
639
|
10
|
640 m_panelRight->SetSizer( bSizerRight );
|
0
|
641
|
10
|
642 //
|
|
643 bSizerTop->Add( m_splitter, 1, wxEXPAND, 0 );
|
|
644
|
0
|
645 this->SetSizer( bSizerTop );
|
|
646 this->Layout();
|
|
647
|
|
648 //this->Centre( wxBOTH );
|
14
|
649
|
|
650 SetControlsValue();
|
|
651 }
|
|
652
|
|
653 void MainFrame::SetControlsValue( void )
|
|
654 {
|
0
|
655 m_staticBitmap1 = new MyStaticBitmap( m_scrolledWindow1, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
656 m_staticBitmap2 = new MyStaticBitmap( m_scrolledWindow2, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
657 m_staticBitmap3 = new MyStaticBitmap( m_scrolledWindow3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
658 m_staticBitmap4 = new MyStaticBitmap( m_scrolledWindow4, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
659 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
14
|
660
|
|
661 for ( int i = 0; i < m_checkListBox->GetCount(); i++ )
|
|
662 m_checkListBox->Check( i, true );
|
15
|
663
|
|
664 m_spinCtrl->SetValue( wxGetApp().pzoom );
|
0
|
665 }
|
|
666
|
5
|
667 void MainFrame::SetAccelerator( void )
|
|
668 {
|
16
|
669 wxAcceleratorEntry entries[13];
|
13
|
670 entries[0].Set( wxACCEL_CTRL, (int)'P', wxID_PRINT );
|
|
671 entries[1].Set( wxACCEL_NORMAL, WXK_F1, wxID_HELP );
|
|
672 entries[2].Set( wxACCEL_NORMAL, WXK_F2, ID_DLMAN );
|
16
|
673 entries[3].Set( wxACCEL_NORMAL, WXK_F3, ID_BPRINT );
|
|
674 entries[4].Set( wxACCEL_NORMAL, WXK_F4, ID_FOCUS );
|
|
675 entries[5].Set( wxACCEL_NORMAL, WXK_F7, ID_INDEX );
|
|
676 entries[6].Set( wxACCEL_NORMAL, (int)'Z', ID_PZOOM );
|
|
677 entries[7].Set( wxACCEL_NORMAL, (int)'X', ID_MZOOM );
|
|
678 entries[8].Set( wxACCEL_NORMAL, (int)'D', ID_DARK );
|
|
679 entries[9].Set( wxACCEL_CTRL, (int)'Q', wxID_CLOSE );
|
|
680 entries[10].Set( wxACCEL_SHIFT, (int)'W', ID_SWIN );
|
|
681 entries[11].Set( wxACCEL_SHIFT, (int)'R', ID_UPIDX );
|
|
682 entries[12].Set( wxACCEL_SHIFT, (int)'L', ID_DARK ); // now building ( logout )
|
|
683 wxAcceleratorTable accel( 13, entries );
|
5
|
684 SetAcceleratorTable( accel );
|
|
685 }
|
|
686
|
0
|
687 void MainFrame::Cmd( wxString cmd )
|
|
688 {
|
6
|
689 m_textCtrlName->SetValue( wxEmptyString );
|
|
690 m_textCtrlAddr->SetValue( wxEmptyString );
|
8
|
691 m_dataViewListCtrl->DeleteAllItems();
|
10
|
692 m_dataViewListKana->DeleteAllItems();
|
8
|
693 wxGetApp().RemoveFile( wxT( ".cache/*" ) );
|
5
|
694 LoadBitmaps( wxEmptyString, false );
|
6
|
695
|
5
|
696 wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) );
|
0
|
697
|
2
|
698 if ( cmd.IsSameAs( wxT( "q" ), true ) || cmd.IsSameAs( wxT( "9" ), true ) ) {
|
0
|
699 Close();
|
2
|
700 return;
|
0
|
701 }
|
|
702
|
2
|
703 if ( cmd.IsSameAs( wxT( "c" ), true ) || cmd.IsSameAs( wxT( "cmd" ), true ) ) {
|
|
704 return;
|
|
705 }
|
|
706
|
13
|
707 if ( cmd.IsSameAs( wxT( "3915" ), true ) && m_user.IsSameAs( wxT( "root" ) ) ) {
|
14
|
708 ManageDBFrame *mngframe = new ManageDBFrame( this, wxID_ANY, wxT( "Management Window" ), wxDefaultPosition, wxSize( 400, 160 ), wxCAPTION|wxTAB_TRAVERSAL );
|
13
|
709 mngframe->SetDBdir( m_dbdir );
|
|
710 mngframe->SetServer( m_server );
|
11
|
711 mngframe->Show();
|
13
|
712 m_searchCtrl->Clear();
|
3
|
713 return;
|
|
714 }
|
|
715
|
|
716 if ( cmd.IsSameAs( wxT( "." ), false ) ) {
|
0
|
717 wxString appdir = wxGetCwd();
|
|
718 wxString execmd = wxT( "explorer " ) + appdir;
|
|
719 wxExecute( execmd );
|
|
720 return;
|
|
721 }
|
|
722
|
3
|
723 if ( cmd.IsSameAs( wxT( "*" ), false ) ) {
|
8
|
724 PasteSearch();
|
5
|
725 return;
|
3
|
726 }
|
|
727
|
|
728 if ( cmd.IsSameAs( wxT( "+" ), false ) ) {
|
6
|
729 //PrintImages();
|
3
|
730 return;
|
|
731 }
|
|
732
|
0
|
733 if ( reHhs.Matches( cmd ) ) {
|
2
|
734 m_hhs = m_searchCtrl->GetValue();
|
|
735 Search();
|
|
736 return;
|
|
737 }
|
0
|
738
|
10
|
739 wxString hiragana = wxT( "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをんがぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽぁぃぅぇぉゃゅょっ " );
|
|
740 wxString katakana = wxT( "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンガギグゲコザジズゼゾダヂヅデドバビブベボパピプペポァィゥェォャュョッ " );
|
|
741 wxRegEx reHiraGana( wxT( "^[" ) + hiragana + wxT( "]+$" ) );
|
|
742 wxRegEx reKataKana( wxT( "^[" ) + katakana + wxT( "]+$" ) );
|
|
743
|
|
744 bool fuzzy = false;
|
|
745 if ( cmd.Right( 1 ).IsSameAs( wxT( "%" ) ) ) {
|
|
746 cmd.Replace( wxT( "%" ), wxEmptyString, true );
|
|
747 fuzzy = true;
|
|
748 }
|
|
749
|
|
750 if ( reHiraGana.Matches( cmd ) || reKataKana.Matches( cmd ) ) {
|
|
751 if ( cmd.Len() < 5 ) {
|
|
752 wxMessageBox( wxT( "too short !" ) );
|
|
753 return;
|
|
754 }
|
|
755 if ( reHiraGana.Matches( cmd ) ) {
|
|
756 for ( int i = 0; i < hiragana.Len(); i++ )
|
|
757 cmd.Replace( hiragana[i], katakana[i], true );
|
|
758 }
|
|
759
|
|
760 int match_cnt = 0;
|
|
761 HhsHash::iterator it;
|
|
762 for( it = hhash.begin(); it != hhash.end(); ++it ){
|
|
763 wxString key = it->first, value = it->second->kana;
|
|
764 value.Replace( wxT( " " ), wxEmptyString, true );
|
|
765 if ( value.IsSameAs( cmd ) || ( fuzzy && value.StartsWith( cmd ) ) ) {
|
|
766 wxVector<wxVariant> data;
|
|
767 data.push_back( key );
|
|
768 data.push_back( it->second->name );
|
|
769 data.push_back( it->second->addr );
|
|
770 m_dataViewListKana->AppendItem( data );
|
|
771 data.clear();
|
|
772 m_dataViewListKana->ToggleWindowStyle( wxHSCROLL );
|
|
773 match_cnt++;
|
|
774 }
|
|
775 }
|
|
776
|
|
777 if ( match_cnt == 1 ) {
|
|
778 m_searchCtrl->SetValue( m_dataViewListKana->GetTextValue( 0, 0 ) );
|
|
779 m_textCtrlName->SetValue( m_dataViewListKana->GetTextValue( 0, 1 ) );
|
|
780 m_textCtrlAddr->SetValue( m_dataViewListKana->GetTextValue( 0, 2 ) );
|
|
781 m_hhs = m_searchCtrl->GetValue();
|
|
782 Search();
|
|
783 }
|
|
784
|
|
785 if ( match_cnt == 0 ) {
|
|
786 wxMessageBox( wxT( "No name matched." ) );
|
|
787 }
|
|
788 return;
|
|
789 }
|
|
790
|
3
|
791 wxMessageBox( wxT( "Bad Input !!" ) );
|
0
|
792 }
|
|
793
|
6
|
794 bool MainFrame::LoadBitmap( wxScrolledWindow* sc, MyStaticBitmap* sb, wxString file )
|
0
|
795 {
|
5
|
796 sb->SetBitmap( wxNullBitmap );
|
6
|
797 sb->zoom = 0;
|
5
|
798 sc->Scroll( 0, 0 );
|
|
799
|
|
800 bool ok = true;
|
2
|
801 if ( startup ) {
|
5
|
802 file = wxT( "image/hello.jpg" );
|
2
|
803 startup = false;
|
|
804 }
|
5
|
805 if ( !wxFileExists( file ) ) {
|
|
806 file = wxT( "image/testpattern.jpg" );
|
|
807 ok = false;
|
|
808 }
|
0
|
809 wxBitmap bmp( file, wxBITMAP_TYPE_JPEG );
|
6
|
810 sb->SetOrigImage( bmp );
|
0
|
811 int width = bmp.GetWidth();
|
|
812 int height = bmp.GetHeight();
|
|
813 wxImage img = bmp.ConvertToImage();
|
|
814
|
|
815 int ww, wh;
|
1
|
816 sc->GetSize( &ww, &wh );
|
0
|
817
|
3
|
818 float w = ww - 30;
|
0
|
819 float h = w * height / width;
|
|
820 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
|
5
|
821 sc->SetScrollbars( 10, 10, (int)w / 10, (int)h / 10 );
|
0
|
822
|
5
|
823 return ok;
|
0
|
824 }
|
|
825
|
5
|
826 bool MainFrame::LoadBitmaps( wxString date, bool reload )
|
0
|
827 {
|
5
|
828 bool ok;
|
|
829 ok = LoadBitmap( m_scrolledWindow1, m_staticBitmap1, wxString::Format( wxT( ".cache/%08s_1" ), date ) );
|
|
830 ok = LoadBitmap( m_scrolledWindow2, m_staticBitmap2, wxString::Format( wxT( ".cache/%08s_2" ), date ) );
|
|
831 ok = LoadBitmap( m_scrolledWindow3, m_staticBitmap3, wxString::Format( wxT( ".cache/%08s_3" ), date ) );
|
|
832 ok = LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( wxT( ".cache/%08s_4" ), date ) );
|
|
833 ok = LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( wxT( ".cache/%08s_5" ), date ) );
|
|
834
|
|
835 if ( !ok && reload ) {
|
|
836 wxSleep( 5 );
|
7
|
837 ok = LoadBitmaps( date, false );
|
5
|
838 }
|
|
839 return ok;
|
2
|
840 }
|
|
841
|
6
|
842 void MainFrame::ChangeCZoom( int z )
|
|
843 {
|
|
844 int n = m_notebook->GetSelection();
|
|
845 if ( n == 0 ) ChangeZoom( m_scrolledWindow1, m_staticBitmap1, z );
|
|
846 if ( n == 1 ) ChangeZoom( m_scrolledWindow2, m_staticBitmap2, z );
|
|
847 if ( n == 2 ) ChangeZoom( m_scrolledWindow3, m_staticBitmap3, z );
|
|
848 if ( n == 3 ) ChangeZoom( m_scrolledWindow4, m_staticBitmap4, z );
|
|
849 if ( n == 4 ) ChangeZoom( m_scrolledWindow5, m_staticBitmap5, z );
|
|
850 }
|
|
851
|
|
852 void MainFrame::ChangeZoom( wxScrolledWindow* sc, MyStaticBitmap* sb, int z )
|
|
853 {
|
|
854 if ( z > 0 ) sb->zoom++;
|
|
855 else sb->zoom--;
|
|
856
|
|
857 float zz = pow( 1.1, sb->zoom );
|
|
858
|
|
859 int x, y;
|
|
860 sc->GetViewStart( &x, &y );
|
|
861 sc->Scroll( 0, 0 );
|
|
862 wxBitmap bmp = sb->GetOrigImage();
|
|
863
|
|
864 int width = bmp.GetWidth();
|
|
865 int height = bmp.GetHeight();
|
|
866 wxImage img = bmp.ConvertToImage();
|
|
867
|
|
868 int ww, wh;
|
|
869 sc->GetSize( &ww, &wh );
|
|
870
|
|
871 float w = ww * zz - 30;
|
|
872 float h = w * height / width;
|
|
873 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
|
|
874 sc->SetScrollbars( 10, 10, (int)w / 10, (int)h / 10 );
|
|
875 sc->Scroll( x, y );
|
|
876
|
|
877 if ( m_dark ) ChangeColor( sb );
|
|
878 }
|
|
879
|
|
880 void MainFrame::ChangeColor( MyStaticBitmap* sb )
|
|
881 {
|
|
882 wxBitmap bmp = sb->GetBitmap();
|
|
883 wxImage img = bmp.ConvertToImage();
|
|
884 unsigned char r, g, b;
|
|
885 for ( int x = 0; x < img.GetWidth(); x++ ) {
|
|
886 for ( int y = 0; y < img.GetHeight(); y++ ) {
|
|
887 r = 255 - img.GetRed( x, y );
|
|
888 g = 255 - img.GetGreen( x, y );
|
|
889 b = 255 - img.GetBlue( x, y );
|
|
890 img.SetRGB( x, y, r, g, b );
|
|
891 }
|
|
892 }
|
|
893 sb->SetBitmap( wxBitmap( img ) );
|
|
894 }
|
|
895
|
2
|
896 void MainFrame::GetImages( wxString hhs, wxString date )
|
|
897 {
|
8
|
898 int estimate = http.GetImagesSize( hhs, date ) / 1000000;
|
7
|
899 wxProgressDialog pd( wxT( "Connecting Server" ), wxT( "Start..." ), estimate, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
|
|
900 pd.SetSize( wxSize( 320, 140 ) );
|
|
901
|
14
|
902 unsigned int flag = 0;
|
|
903 if ( m_checkListBox->IsChecked( 0 ) ) flag += 1;
|
|
904 if ( m_checkListBox->IsChecked( 1 ) ) flag += 10;
|
|
905 if ( m_checkListBox->IsChecked( 2 ) ) flag += 100;
|
|
906 if ( m_checkListBox->IsChecked( 3 ) ) flag += 1000;
|
|
907 if ( m_checkListBox->IsChecked( 4 ) ) flag += 10000;
|
|
908 http.GetImages( hhs, date, wxString::Format( wxT( "%d" ), flag ) );
|
7
|
909 for ( int i = 0; i < estimate; i++ ) {
|
8
|
910 wxMilliSleep( 1 );
|
7
|
911 pd.Update( i, wxT( "Now Loading..." ) );
|
|
912 }
|
|
913 }
|
|
914
|
2
|
915 void MainFrame::Search( void )
|
0
|
916 {
|
5
|
917 // hhs info
|
|
918 if ( hhash.count( m_hhs ) ) {
|
|
919 m_textCtrlName->SetValue( hhash[ m_hhs ]->name );
|
|
920 m_textCtrlAddr->SetValue( hhash[ m_hhs ]->addr );
|
|
921 }
|
|
922
|
|
923 // index
|
2
|
924 wxString date;
|
|
925 int match_cnt = 0;
|
|
926 for ( int i = 0; i < m_index.GetCount(); i++ ) {
|
|
927 if ( m_index[i].StartsWith( m_hhs, &date ) ) {
|
|
928 wxVector<wxVariant> data;
|
|
929 data.push_back( wxString::Format( wxT( "%02d" ), ++match_cnt ) );
|
|
930 date = date.Mid( 1, 4 ) + wxT( "-" ) + date.Mid( 5, 2 ) + wxT( "-" ) + date.Mid( 7, 2 );
|
|
931 data.push_back( date );
|
|
932 data.push_back( wxEmptyString );
|
|
933 m_dataViewListCtrl->AppendItem( data );
|
|
934 data.clear();
|
|
935 }
|
|
936 }
|
5
|
937
|
|
938 if ( match_cnt == 0 ) {
|
|
939 wxMessageBox( wxT( "Not Matched !!" ) );
|
|
940 } else {
|
|
941 wxString date = m_dataViewListCtrl->GetTextValue( 0, 1 );
|
|
942 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
943 GetImages( m_hhs, date );
|
|
944 if ( LoadBitmaps( date, true ) ) {
|
|
945 m_dataViewListCtrl->SetTextValue( wxT( "OK" ), 0, 2 );
|
|
946 m_dataViewListCtrl->SelectRow( 0 );
|
|
947 }
|
|
948 }
|
|
949
|
|
950 WriteLog( wxT( "[search] " ) + m_hhs );
|
15
|
951 Raise();
|
2
|
952 }
|
|
953
|
15
|
954 void MainFrame::LoadDB( bool load_hhsdb )
|
2
|
955 {
|
5
|
956 wxProgressDialog pd( wxT( "Load Data" ), wxT( "Now loading..." ), 100, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
|
|
957 pd.SetSize( wxSize( 320, 140 ) );
|
|
958
|
|
959 // index
|
13
|
960 UpdateIndex();
|
3
|
961
|
15
|
962 if ( !load_hhsdb ) {
|
|
963 return;
|
|
964 }
|
|
965 // decrypto hhs
|
5
|
966 wxString key = wxT( "12345678900123456789abcdefabcdef" );
|
|
967 wxArrayString args;
|
|
968 args.Add( wxT( "crypto.exe" ) );
|
|
969 args.Add( wxT( "-d" ) );
|
|
970 args.Add( wxT( "hhs.db" ) );
|
|
971 args.Add( wxT( "-k" ) );
|
|
972 args.Add( key );
|
|
973
|
|
974 wxArrayString output, errors;
|
|
975 wxExecute( wxJoin( args, ' ', '\\' ), output, errors );
|
|
976
|
|
977 for ( int i = 0; i < 100; i++ ) {
|
|
978 wxMilliSleep( 2 );
|
|
979 pd.Update( i, wxString::Format( wxT( "Now loding ... ( %0.1f %% )" ), (float)i ) );
|
|
980 }
|
|
981 if ( errors.GetCount() > 0 ) {
|
8
|
982 wxMessageBox( wxT( "crypto error: " )+ errors[0] );
|
5
|
983 return;
|
|
984 }
|
|
985 for ( int i = 0; i < output.GetCount(); i++ ) {
|
|
986 wxArrayString buf = wxSplit( output[i], ',', '\\' );
|
|
987 hhash[ buf[0] ] = new HhsClass( buf ); // no, birth, name, kana, addr, sex
|
3
|
988 }
|
5
|
989 }
|
|
990
|
13
|
991 void MainFrame::UpdateIndex( void )
|
|
992 {
|
|
993 wxString oldest = wxT( "30001231" );
|
|
994 wxString newest = wxT( "20000401" );
|
|
995 wxTextFile file;
|
|
996 file.Open( wxT( "index.db" ) );
|
|
997 for ( int i = 0; i < file.GetLineCount(); i++ ) {
|
|
998 wxArrayString buf = wxSplit( file.GetLine( i ), ':', '\\' );
|
|
999 if ( oldest.Cmp( buf[1] ) == 1 ) oldest = buf[1];
|
|
1000 if ( newest.Cmp( buf[1] ) == -1 ) newest = buf[1];
|
|
1001 m_index.Add( file.GetLine( i ) );
|
|
1002 }
|
|
1003 file.Close();
|
|
1004 m_index.Sort( true );
|
|
1005 m_textCtrlLog->SetValue( wxT( "Index: " ) + oldest + wxT( " - " ) + newest );
|
|
1006 }
|
|
1007
|
8
|
1008 void MainFrame::PasteSearch( void )
|
5
|
1009 {
|
|
1010 wxString s;
|
|
1011 if ( wxTheClipboard->Open() ) {
|
|
1012 if ( wxTheClipboard->IsSupported( wxDF_TEXT ) ) {
|
|
1013 wxTextDataObject data;
|
|
1014 wxTheClipboard->GetData( data );
|
|
1015 s = data.GetText();
|
|
1016 }
|
|
1017 wxTheClipboard->Close();
|
|
1018 }
|
|
1019
|
|
1020 s.Replace( wxT(" "), wxT(""), true );
|
|
1021 wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) );
|
|
1022 if ( reHhs.Matches( s ) ) {
|
|
1023 m_searchCtrl->SetValue( s );
|
|
1024 m_hhs = m_searchCtrl->GetValue();
|
|
1025 Search();
|
|
1026 return;
|
|
1027 }
|
10
|
1028 wxMessageBox( wxT( "Bad clipboard data !!" ) );
|
3
|
1029 }
|
|
1030
|
|
1031 void MainFrame::PrintImages( void )
|
|
1032 {
|
|
1033 int r = m_dataViewListCtrl->GetSelectedRow();
|
4
|
1034 if ( r == wxNOT_FOUND ) {
|
|
1035 wxMessageBox( wxT( "Not Ready for Print !!" ) );
|
|
1036 return;
|
|
1037 }
|
3
|
1038 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 );
|
|
1039
|
|
1040 if ( !ready.IsSameAs( wxT( "OK" ), true ) ) {
|
|
1041 wxMessageBox( wxT( "Not Ready for Print !!" ) );
|
|
1042 return;
|
|
1043 }
|
|
1044
|
|
1045 wxDateTime now = wxDateTime::Now();
|
|
1046 wxString nowstr = now.Format( "%Y/%m/%d %H:%M", wxDateTime::GMT9 ).c_str();
|
|
1047
|
|
1048 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
1049 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
1050
|
|
1051 wxString html, file;
|
|
1052 html = wxT( "<html><body>\n" );
|
|
1053
|
14
|
1054 int zoom = m_spinCtrl->GetValue();
|
|
1055 wxString imgsz = wxString::Format( wxT( "\" width=\"%d\" height=\"%d\"" ), 750 * zoom / 100, 1060 * zoom / 100 );
|
3
|
1056 for ( int i = 1; i < 6; i++ ) {
|
|
1057 file = wxString::Format( wxT( ".cache/%08s_%d" ), date, i );
|
14
|
1058 html = html + wxT( "<img src=\"" ) + file + imgsz + wxT( "/>\n" );
|
3
|
1059 html = html + wxT( "<div align=right><font size=-2><u>" ) + m_hhs + wxT( "@" ) + m_user + wxT( "#" ) + nowstr + wxT( "</u></font></div>\n\n" );
|
|
1060 }
|
|
1061 html = html + wxT( "</body></html>" );
|
|
1062
|
|
1063 // start printing
|
|
1064 wxHtmlPrintout hpout( wxT( "Re:Searcher" ) );
|
|
1065 hpout.SetMargins( 0, 0, 0, 0, 0 );
|
|
1066 wxPrintDialogData pd;
|
|
1067 wxPrinter p( &pd );
|
|
1068
|
|
1069 hpout.SetHtmlText( html, wxEmptyString, false );
|
|
1070 p.Print( NULL, &hpout, true );
|
5
|
1071
|
|
1072 WriteLog( wxT( "[print]" ) );
|
2
|
1073 }
|
|
1074
|
5
|
1075 void MainFrame::WriteLog( wxString msg )
|
|
1076 {
|
|
1077 wxDateTime now = wxDateTime::Now();
|
|
1078 wxString file = wxGetCwd() + wxFILE_SEP_PATH + wxT( "log" ) + wxFILE_SEP_PATH + now.Format( wxT( "%Y%m%d" ) ) + wxT( ".log" );
|
|
1079
|
|
1080 wxTextFile logfile;
|
|
1081 if ( !wxFileExists( file ) ) logfile.Create( file );
|
|
1082
|
|
1083 logfile.Open( file );
|
|
1084 logfile.AddLine( now.Format( wxT("%Y-%m-%d %H:%M:%S ") ) + msg );
|
|
1085 logfile.Write();
|
|
1086 logfile.Close();
|
|
1087 }
|
|
1088
|
7
|
1089 void MainFrame::Close( void )
|
|
1090 {
|
|
1091 WriteLog( wxT( "[logout]" ) );
|
|
1092 if ( !IsIconized() && !IsMaximized() ) {
|
|
1093 wxGetApp().rect = this->GetRect();
|
|
1094 }
|
15
|
1095 wxGetApp().pzoom = m_spinCtrl->GetValue();
|
7
|
1096 Destroy();
|
|
1097 }
|
|
1098
|
1
|
1099 void MainFrame::InDevelop( bool flag )
|
0
|
1100 {
|
1
|
1101 if ( !flag ) return;
|
0
|
1102
|
15
|
1103 bool cb = false;
|
|
1104 m_checkListBox->Enable( cb );
|
|
1105 //m_checkListBox->Show( cb );
|
|
1106
|
3
|
1107 bool lo = false;
|
|
1108 m_buttonLogout->Enable( lo );
|
|
1109 m_buttonLogout->Show( lo );
|
0
|
1110
|
3
|
1111 bool sl = false;
|
|
1112 m_slider->Enable( sl );
|
|
1113 m_slider->Show( sl );
|
0
|
1114
|
4
|
1115 return;
|
0
|
1116 }
|
|
1117
|