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