0
|
1 // Filename : rsearcher.cpp
|
14
|
2 // Last Change: 2018-12-04 火 16:00:36.
|
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
|
14
|
551 m_checkListBox = new wxCheckListBox( m_panelRight, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
|
|
552 m_checkListBox->Append( wxT( "1: Marksheet" ) );
|
|
553 m_checkListBox->Append( wxT( "2: Marksheet ( R )" ) );
|
|
554 m_checkListBox->Append( wxT( "3: Special Mention" ) );
|
|
555 m_checkListBox->Append( wxT( "4: Opinion" ) );
|
|
556 m_checkListBox->Append( wxT( "5: Opinion ( R )" ) );
|
|
557 bSizerRight->Add( m_checkListBox, 0, wxALL|wxEXPAND, 5 );
|
|
558
|
10
|
559 m_dataViewListCtrl = new wxDataViewListCtrl( m_panelRight, ID_LIST, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE );
|
|
560 m_dataViewListColumnNo = m_dataViewListCtrl->AppendTextColumn( wxT( "No" ), wxDATAVIEW_CELL_INERT, 30, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
561 m_dataViewListColumnDate = m_dataViewListCtrl->AppendTextColumn( wxT( " Date" ), wxDATAVIEW_CELL_INERT, 80, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
562 m_dataViewListColumnReady = m_dataViewListCtrl->AppendTextColumn( wxT( "Ready" ), wxDATAVIEW_CELL_INERT, 60, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
0
|
563 bSizerRight->Add( m_dataViewListCtrl, 1, wxALL|wxEXPAND, 5 );
|
|
564
|
10
|
565 m_dataViewListKana = new wxDataViewListCtrl( m_panelRight, ID_LISTKANA, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE );
|
|
566 m_dataViewListColumnKNo = m_dataViewListKana->AppendTextColumn( wxT( " No" ), wxDATAVIEW_CELL_INERT, 70, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
567 m_dataViewListColumnName = m_dataViewListKana->AppendTextColumn( wxT( " Name" ), wxDATAVIEW_CELL_INERT, 80, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
568 m_dataViewListColumnAddr = m_dataViewListKana->AppendTextColumn( wxT( " Address" ), wxDATAVIEW_CELL_INERT, -1, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
569 bSizerRight->Add( m_dataViewListKana, 1, wxALL|wxEXPAND, 5 );
|
|
570
|
|
571 m_textCtrlLog = new wxTextCtrl( m_panelRight, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1, 40 ), 0 );
|
|
572 bSizerRight->Add( m_textCtrlLog, 0, wxALL|wxEXPAND, 5 );
|
0
|
573
|
14
|
574 wxFlexGridSizer* fgSizerButton = new wxFlexGridSizer( 0, 2, 0, 0 );
|
|
575 fgSizerButton->SetFlexibleDirection( wxBOTH );
|
|
576 fgSizerButton->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
|
577
|
10
|
578 m_buttonPsearch = new wxButton( m_panelRight, ID_PSEARCH, wxT( "Paste-Search" ), wxDefaultPosition, wxDefaultSize, 0 );
|
14
|
579 fgSizerButton->Add( m_buttonPsearch, 0, wxALL, 5 );
|
5
|
580
|
14
|
581 fgSizerButton->Add( 0, 0, 1, wxEXPAND, 5 );
|
|
582
|
10
|
583 m_buttonPrint = new wxButton( m_panelRight, wxID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 );
|
14
|
584 fgSizerButton->Add( m_buttonPrint, 0, wxALL, 5 );
|
0
|
585
|
14
|
586 m_spinCtrl = new wxSpinCtrl( m_panelRight, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 60, -1 ), wxALIGN_CENTER_HORIZONTAL|wxSP_ARROW_KEYS, 1, 100, 100 );
|
|
587 fgSizerButton->Add( m_spinCtrl, 0, wxALL, 5 );
|
|
588
|
|
589 bSizerRight->Add( fgSizerButton, 0, wxEXPAND, 5 );
|
|
590
|
|
591 /* now building... */
|
10
|
592 m_slider = new wxSlider( m_panelRight, ID_SLDR, 1, 1, 5, wxDefaultPosition, wxSize( -1, 200 ), wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LABELS|wxSL_VERTICAL );
|
|
593 //bSizerRight->Add( m_slider, 0, wxALL, 5 );
|
|
594
|
|
595 m_buttonLogout = new wxButton( m_panelRight, ID_LOGOUT, wxT( "Logout" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
596 //bSizerRight->Add( m_buttonLogout, 0, wxALL, 5 );
|
3
|
597
|
6
|
598 // invisible buttons for shortcut-key
|
7
|
599 m_buttonFocus = new wxButton( this, ID_FOCUS, wxT( "Focus" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
600 m_buttonFocus->Hide();
|
6
|
601 m_buttonPzoom = new wxButton( this, ID_PZOOM, wxT( "ZOOM" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
602 m_buttonPzoom->Hide();
|
|
603 m_buttonMzoom = new wxButton( this, ID_MZOOM, wxT( "zoom" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
604 m_buttonMzoom->Hide();
|
|
605 m_buttonDark = new wxButton( this, ID_DARK, wxT( "Dark" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
606 m_buttonDark->Hide();
|
9
|
607 m_buttonSatellite = new wxButton( this, ID_SWIN, wxT( "Satellite" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
608 m_buttonSatellite->Hide();
|
13
|
609 m_buttonDLMan = new wxButton( this, ID_DLMAN, wxT( "Manual" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
610 m_buttonDLMan->Hide();
|
|
611 m_buttonUpdateIndex = new wxButton( this, ID_UPIDX, wxT( "Update Index" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
612 m_buttonUpdateIndex->Hide();
|
10
|
613 m_buttonClose = new wxButton( this, wxID_CLOSE, wxT( "Close" ), wxDefaultPosition, wxDefaultSize, 0 );
|
7
|
614 m_buttonClose->Hide();
|
10
|
615 m_buttonHelp = new wxButton( this, wxID_HELP, wxT( "Help" ), wxDefaultPosition, wxDefaultSize, 0 );
|
6
|
616 m_buttonHelp->Hide();
|
|
617
|
10
|
618 m_panelRight->SetSizer( bSizerRight );
|
0
|
619
|
10
|
620 //
|
|
621 bSizerTop->Add( m_splitter, 1, wxEXPAND, 0 );
|
|
622
|
0
|
623 this->SetSizer( bSizerTop );
|
|
624 this->Layout();
|
|
625
|
|
626 //this->Centre( wxBOTH );
|
14
|
627
|
|
628 SetControlsValue();
|
|
629 }
|
|
630
|
|
631 void MainFrame::SetControlsValue( void )
|
|
632 {
|
0
|
633 m_staticBitmap1 = new MyStaticBitmap( m_scrolledWindow1, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
634 m_staticBitmap2 = new MyStaticBitmap( m_scrolledWindow2, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
635 m_staticBitmap3 = new MyStaticBitmap( m_scrolledWindow3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
636 m_staticBitmap4 = new MyStaticBitmap( m_scrolledWindow4, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
637 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
14
|
638
|
|
639 for ( int i = 0; i < m_checkListBox->GetCount(); i++ )
|
|
640 m_checkListBox->Check( i, true );
|
0
|
641 }
|
|
642
|
5
|
643 void MainFrame::SetAccelerator( void )
|
|
644 {
|
13
|
645 wxAcceleratorEntry entries[11];
|
|
646 entries[0].Set( wxACCEL_CTRL, (int)'P', wxID_PRINT );
|
|
647 entries[1].Set( wxACCEL_NORMAL, WXK_F1, wxID_HELP );
|
|
648 entries[2].Set( wxACCEL_NORMAL, WXK_F2, ID_DLMAN );
|
|
649 entries[3].Set( wxACCEL_NORMAL, WXK_F4, ID_FOCUS );
|
|
650 entries[4].Set( wxACCEL_NORMAL, (int)'Z', ID_PZOOM );
|
|
651 entries[5].Set( wxACCEL_NORMAL, (int)'X', ID_MZOOM );
|
|
652 entries[6].Set( wxACCEL_NORMAL, (int)'D', ID_DARK );
|
|
653 entries[7].Set( wxACCEL_CTRL, (int)'Q', wxID_CLOSE );
|
|
654 entries[8].Set( wxACCEL_SHIFT, (int)'W', ID_SWIN );
|
|
655 entries[9].Set( wxACCEL_SHIFT, (int)'R', ID_UPIDX );
|
|
656 entries[10].Set( wxACCEL_SHIFT, (int)'L', ID_DARK ); // now building ( logout )
|
|
657 wxAcceleratorTable accel( 10, entries );
|
5
|
658 SetAcceleratorTable( accel );
|
|
659 }
|
|
660
|
0
|
661 void MainFrame::Cmd( wxString cmd )
|
|
662 {
|
6
|
663 m_textCtrlName->SetValue( wxEmptyString );
|
|
664 m_textCtrlAddr->SetValue( wxEmptyString );
|
8
|
665 m_dataViewListCtrl->DeleteAllItems();
|
10
|
666 m_dataViewListKana->DeleteAllItems();
|
8
|
667 wxGetApp().RemoveFile( wxT( ".cache/*" ) );
|
5
|
668 LoadBitmaps( wxEmptyString, false );
|
6
|
669
|
5
|
670 wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) );
|
0
|
671
|
2
|
672 if ( cmd.IsSameAs( wxT( "q" ), true ) || cmd.IsSameAs( wxT( "9" ), true ) ) {
|
0
|
673 Close();
|
2
|
674 return;
|
0
|
675 }
|
|
676
|
2
|
677 if ( cmd.IsSameAs( wxT( "c" ), true ) || cmd.IsSameAs( wxT( "cmd" ), true ) ) {
|
|
678 return;
|
|
679 }
|
|
680
|
13
|
681 if ( cmd.IsSameAs( wxT( "3915" ), true ) && m_user.IsSameAs( wxT( "root" ) ) ) {
|
14
|
682 ManageDBFrame *mngframe = new ManageDBFrame( this, wxID_ANY, wxT( "Management Window" ), wxDefaultPosition, wxSize( 400, 160 ), wxCAPTION|wxTAB_TRAVERSAL );
|
13
|
683 mngframe->SetDBdir( m_dbdir );
|
|
684 mngframe->SetServer( m_server );
|
11
|
685 mngframe->Show();
|
13
|
686 m_searchCtrl->Clear();
|
3
|
687 return;
|
|
688 }
|
|
689
|
|
690 if ( cmd.IsSameAs( wxT( "." ), false ) ) {
|
0
|
691 wxString appdir = wxGetCwd();
|
|
692 wxString execmd = wxT( "explorer " ) + appdir;
|
|
693 wxExecute( execmd );
|
|
694 return;
|
|
695 }
|
|
696
|
3
|
697 if ( cmd.IsSameAs( wxT( "*" ), false ) ) {
|
8
|
698 PasteSearch();
|
5
|
699 return;
|
3
|
700 }
|
|
701
|
|
702 if ( cmd.IsSameAs( wxT( "+" ), false ) ) {
|
6
|
703 //PrintImages();
|
3
|
704 return;
|
|
705 }
|
|
706
|
0
|
707 if ( reHhs.Matches( cmd ) ) {
|
2
|
708 m_hhs = m_searchCtrl->GetValue();
|
|
709 Search();
|
|
710 return;
|
|
711 }
|
0
|
712
|
10
|
713 wxString hiragana = wxT( "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをんがぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽぁぃぅぇぉゃゅょっ " );
|
|
714 wxString katakana = wxT( "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンガギグゲコザジズゼゾダヂヅデドバビブベボパピプペポァィゥェォャュョッ " );
|
|
715 wxRegEx reHiraGana( wxT( "^[" ) + hiragana + wxT( "]+$" ) );
|
|
716 wxRegEx reKataKana( wxT( "^[" ) + katakana + wxT( "]+$" ) );
|
|
717
|
|
718 bool fuzzy = false;
|
|
719 if ( cmd.Right( 1 ).IsSameAs( wxT( "%" ) ) ) {
|
|
720 cmd.Replace( wxT( "%" ), wxEmptyString, true );
|
|
721 fuzzy = true;
|
|
722 }
|
|
723
|
|
724 if ( reHiraGana.Matches( cmd ) || reKataKana.Matches( cmd ) ) {
|
|
725 if ( cmd.Len() < 5 ) {
|
|
726 wxMessageBox( wxT( "too short !" ) );
|
|
727 return;
|
|
728 }
|
|
729 if ( reHiraGana.Matches( cmd ) ) {
|
|
730 for ( int i = 0; i < hiragana.Len(); i++ )
|
|
731 cmd.Replace( hiragana[i], katakana[i], true );
|
|
732 }
|
|
733
|
|
734 int match_cnt = 0;
|
|
735 HhsHash::iterator it;
|
|
736 for( it = hhash.begin(); it != hhash.end(); ++it ){
|
|
737 wxString key = it->first, value = it->second->kana;
|
|
738 value.Replace( wxT( " " ), wxEmptyString, true );
|
|
739 if ( value.IsSameAs( cmd ) || ( fuzzy && value.StartsWith( cmd ) ) ) {
|
|
740 wxVector<wxVariant> data;
|
|
741 data.push_back( key );
|
|
742 data.push_back( it->second->name );
|
|
743 data.push_back( it->second->addr );
|
|
744 m_dataViewListKana->AppendItem( data );
|
|
745 data.clear();
|
|
746 m_dataViewListKana->ToggleWindowStyle( wxHSCROLL );
|
|
747 match_cnt++;
|
|
748 }
|
|
749 }
|
|
750
|
|
751 if ( match_cnt == 1 ) {
|
|
752 m_searchCtrl->SetValue( m_dataViewListKana->GetTextValue( 0, 0 ) );
|
|
753 m_textCtrlName->SetValue( m_dataViewListKana->GetTextValue( 0, 1 ) );
|
|
754 m_textCtrlAddr->SetValue( m_dataViewListKana->GetTextValue( 0, 2 ) );
|
|
755 m_hhs = m_searchCtrl->GetValue();
|
|
756 Search();
|
|
757 }
|
|
758
|
|
759 if ( match_cnt == 0 ) {
|
|
760 wxMessageBox( wxT( "No name matched." ) );
|
|
761 }
|
|
762 return;
|
|
763 }
|
|
764
|
3
|
765 wxMessageBox( wxT( "Bad Input !!" ) );
|
0
|
766 }
|
|
767
|
6
|
768 bool MainFrame::LoadBitmap( wxScrolledWindow* sc, MyStaticBitmap* sb, wxString file )
|
0
|
769 {
|
5
|
770 sb->SetBitmap( wxNullBitmap );
|
6
|
771 sb->zoom = 0;
|
5
|
772 sc->Scroll( 0, 0 );
|
|
773
|
|
774 bool ok = true;
|
2
|
775 if ( startup ) {
|
5
|
776 file = wxT( "image/hello.jpg" );
|
2
|
777 startup = false;
|
|
778 }
|
5
|
779 if ( !wxFileExists( file ) ) {
|
|
780 file = wxT( "image/testpattern.jpg" );
|
|
781 ok = false;
|
|
782 }
|
0
|
783 wxBitmap bmp( file, wxBITMAP_TYPE_JPEG );
|
6
|
784 sb->SetOrigImage( bmp );
|
0
|
785 int width = bmp.GetWidth();
|
|
786 int height = bmp.GetHeight();
|
|
787 wxImage img = bmp.ConvertToImage();
|
|
788
|
|
789 int ww, wh;
|
1
|
790 sc->GetSize( &ww, &wh );
|
0
|
791
|
3
|
792 float w = ww - 30;
|
0
|
793 float h = w * height / width;
|
|
794 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
|
5
|
795 sc->SetScrollbars( 10, 10, (int)w / 10, (int)h / 10 );
|
0
|
796
|
5
|
797 return ok;
|
0
|
798 }
|
|
799
|
5
|
800 bool MainFrame::LoadBitmaps( wxString date, bool reload )
|
0
|
801 {
|
5
|
802 bool ok;
|
|
803 ok = LoadBitmap( m_scrolledWindow1, m_staticBitmap1, wxString::Format( wxT( ".cache/%08s_1" ), date ) );
|
|
804 ok = LoadBitmap( m_scrolledWindow2, m_staticBitmap2, wxString::Format( wxT( ".cache/%08s_2" ), date ) );
|
|
805 ok = LoadBitmap( m_scrolledWindow3, m_staticBitmap3, wxString::Format( wxT( ".cache/%08s_3" ), date ) );
|
|
806 ok = LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( wxT( ".cache/%08s_4" ), date ) );
|
|
807 ok = LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( wxT( ".cache/%08s_5" ), date ) );
|
|
808
|
|
809 if ( !ok && reload ) {
|
|
810 wxSleep( 5 );
|
7
|
811 ok = LoadBitmaps( date, false );
|
5
|
812 }
|
|
813 return ok;
|
2
|
814 }
|
|
815
|
6
|
816 void MainFrame::ChangeCZoom( int z )
|
|
817 {
|
|
818 int n = m_notebook->GetSelection();
|
|
819 if ( n == 0 ) ChangeZoom( m_scrolledWindow1, m_staticBitmap1, z );
|
|
820 if ( n == 1 ) ChangeZoom( m_scrolledWindow2, m_staticBitmap2, z );
|
|
821 if ( n == 2 ) ChangeZoom( m_scrolledWindow3, m_staticBitmap3, z );
|
|
822 if ( n == 3 ) ChangeZoom( m_scrolledWindow4, m_staticBitmap4, z );
|
|
823 if ( n == 4 ) ChangeZoom( m_scrolledWindow5, m_staticBitmap5, z );
|
|
824 }
|
|
825
|
|
826 void MainFrame::ChangeZoom( wxScrolledWindow* sc, MyStaticBitmap* sb, int z )
|
|
827 {
|
|
828 if ( z > 0 ) sb->zoom++;
|
|
829 else sb->zoom--;
|
|
830
|
|
831 float zz = pow( 1.1, sb->zoom );
|
|
832
|
|
833 int x, y;
|
|
834 sc->GetViewStart( &x, &y );
|
|
835 sc->Scroll( 0, 0 );
|
|
836 wxBitmap bmp = sb->GetOrigImage();
|
|
837
|
|
838 int width = bmp.GetWidth();
|
|
839 int height = bmp.GetHeight();
|
|
840 wxImage img = bmp.ConvertToImage();
|
|
841
|
|
842 int ww, wh;
|
|
843 sc->GetSize( &ww, &wh );
|
|
844
|
|
845 float w = ww * zz - 30;
|
|
846 float h = w * height / width;
|
|
847 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
|
|
848 sc->SetScrollbars( 10, 10, (int)w / 10, (int)h / 10 );
|
|
849 sc->Scroll( x, y );
|
|
850
|
|
851 if ( m_dark ) ChangeColor( sb );
|
|
852 }
|
|
853
|
|
854 void MainFrame::ChangeColor( MyStaticBitmap* sb )
|
|
855 {
|
|
856 wxBitmap bmp = sb->GetBitmap();
|
|
857 wxImage img = bmp.ConvertToImage();
|
|
858 unsigned char r, g, b;
|
|
859 for ( int x = 0; x < img.GetWidth(); x++ ) {
|
|
860 for ( int y = 0; y < img.GetHeight(); y++ ) {
|
|
861 r = 255 - img.GetRed( x, y );
|
|
862 g = 255 - img.GetGreen( x, y );
|
|
863 b = 255 - img.GetBlue( x, y );
|
|
864 img.SetRGB( x, y, r, g, b );
|
|
865 }
|
|
866 }
|
|
867 sb->SetBitmap( wxBitmap( img ) );
|
|
868 }
|
|
869
|
2
|
870 void MainFrame::GetImages( wxString hhs, wxString date )
|
|
871 {
|
8
|
872 int estimate = http.GetImagesSize( hhs, date ) / 1000000;
|
7
|
873 wxProgressDialog pd( wxT( "Connecting Server" ), wxT( "Start..." ), estimate, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
|
|
874 pd.SetSize( wxSize( 320, 140 ) );
|
|
875
|
14
|
876 unsigned int flag = 0;
|
|
877 if ( m_checkListBox->IsChecked( 0 ) ) flag += 1;
|
|
878 if ( m_checkListBox->IsChecked( 1 ) ) flag += 10;
|
|
879 if ( m_checkListBox->IsChecked( 2 ) ) flag += 100;
|
|
880 if ( m_checkListBox->IsChecked( 3 ) ) flag += 1000;
|
|
881 if ( m_checkListBox->IsChecked( 4 ) ) flag += 10000;
|
|
882 http.GetImages( hhs, date, wxString::Format( wxT( "%d" ), flag ) );
|
7
|
883 for ( int i = 0; i < estimate; i++ ) {
|
8
|
884 wxMilliSleep( 1 );
|
7
|
885 pd.Update( i, wxT( "Now Loading..." ) );
|
|
886 }
|
|
887 }
|
|
888
|
2
|
889 void MainFrame::Search( void )
|
0
|
890 {
|
5
|
891 // hhs info
|
|
892 if ( hhash.count( m_hhs ) ) {
|
|
893 m_textCtrlName->SetValue( hhash[ m_hhs ]->name );
|
|
894 m_textCtrlAddr->SetValue( hhash[ m_hhs ]->addr );
|
|
895 }
|
|
896
|
|
897 // index
|
2
|
898 wxString date;
|
|
899 int match_cnt = 0;
|
|
900 for ( int i = 0; i < m_index.GetCount(); i++ ) {
|
|
901 if ( m_index[i].StartsWith( m_hhs, &date ) ) {
|
|
902 wxVector<wxVariant> data;
|
|
903 data.push_back( wxString::Format( wxT( "%02d" ), ++match_cnt ) );
|
|
904 date = date.Mid( 1, 4 ) + wxT( "-" ) + date.Mid( 5, 2 ) + wxT( "-" ) + date.Mid( 7, 2 );
|
|
905 data.push_back( date );
|
|
906 data.push_back( wxEmptyString );
|
|
907 m_dataViewListCtrl->AppendItem( data );
|
|
908 data.clear();
|
|
909 }
|
|
910 }
|
5
|
911
|
|
912 if ( match_cnt == 0 ) {
|
|
913 wxMessageBox( wxT( "Not Matched !!" ) );
|
|
914 } else {
|
|
915 wxString date = m_dataViewListCtrl->GetTextValue( 0, 1 );
|
|
916 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
917 GetImages( m_hhs, date );
|
|
918 if ( LoadBitmaps( date, true ) ) {
|
|
919 m_dataViewListCtrl->SetTextValue( wxT( "OK" ), 0, 2 );
|
|
920 m_dataViewListCtrl->SelectRow( 0 );
|
|
921 }
|
|
922 }
|
|
923
|
|
924 WriteLog( wxT( "[search] " ) + m_hhs );
|
2
|
925 }
|
|
926
|
3
|
927 void MainFrame::LoadDB( void )
|
2
|
928 {
|
5
|
929 wxProgressDialog pd( wxT( "Load Data" ), wxT( "Now loading..." ), 100, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
|
|
930 pd.SetSize( wxSize( 320, 140 ) );
|
|
931
|
|
932 // index
|
13
|
933 UpdateIndex();
|
3
|
934
|
5
|
935 // decrypto
|
|
936 wxString key = wxT( "12345678900123456789abcdefabcdef" );
|
|
937 wxArrayString args;
|
|
938 args.Add( wxT( "crypto.exe" ) );
|
|
939 args.Add( wxT( "-d" ) );
|
|
940 args.Add( wxT( "hhs.db" ) );
|
|
941 args.Add( wxT( "-k" ) );
|
|
942 args.Add( key );
|
|
943
|
|
944 wxArrayString output, errors;
|
|
945 wxExecute( wxJoin( args, ' ', '\\' ), output, errors );
|
|
946
|
|
947 for ( int i = 0; i < 100; i++ ) {
|
|
948 wxMilliSleep( 2 );
|
|
949 pd.Update( i, wxString::Format( wxT( "Now loding ... ( %0.1f %% )" ), (float)i ) );
|
|
950 }
|
|
951 if ( errors.GetCount() > 0 ) {
|
8
|
952 wxMessageBox( wxT( "crypto error: " )+ errors[0] );
|
5
|
953 return;
|
|
954 }
|
|
955 for ( int i = 0; i < output.GetCount(); i++ ) {
|
|
956 wxArrayString buf = wxSplit( output[i], ',', '\\' );
|
|
957 hhash[ buf[0] ] = new HhsClass( buf ); // no, birth, name, kana, addr, sex
|
3
|
958 }
|
5
|
959 }
|
|
960
|
13
|
961 void MainFrame::UpdateIndex( void )
|
|
962 {
|
|
963 wxString oldest = wxT( "30001231" );
|
|
964 wxString newest = wxT( "20000401" );
|
|
965 wxTextFile file;
|
|
966 file.Open( wxT( "index.db" ) );
|
|
967 for ( int i = 0; i < file.GetLineCount(); i++ ) {
|
|
968 wxArrayString buf = wxSplit( file.GetLine( i ), ':', '\\' );
|
|
969 if ( oldest.Cmp( buf[1] ) == 1 ) oldest = buf[1];
|
|
970 if ( newest.Cmp( buf[1] ) == -1 ) newest = buf[1];
|
|
971 m_index.Add( file.GetLine( i ) );
|
|
972 }
|
|
973 file.Close();
|
|
974 m_index.Sort( true );
|
|
975 m_textCtrlLog->SetValue( wxT( "Index: " ) + oldest + wxT( " - " ) + newest );
|
|
976 }
|
|
977
|
8
|
978 void MainFrame::PasteSearch( void )
|
5
|
979 {
|
|
980 wxString s;
|
|
981 if ( wxTheClipboard->Open() ) {
|
|
982 if ( wxTheClipboard->IsSupported( wxDF_TEXT ) ) {
|
|
983 wxTextDataObject data;
|
|
984 wxTheClipboard->GetData( data );
|
|
985 s = data.GetText();
|
|
986 }
|
|
987 wxTheClipboard->Close();
|
|
988 }
|
|
989
|
|
990 s.Replace( wxT(" "), wxT(""), true );
|
|
991 wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) );
|
|
992 if ( reHhs.Matches( s ) ) {
|
|
993 m_searchCtrl->SetValue( s );
|
|
994 m_hhs = m_searchCtrl->GetValue();
|
|
995 Search();
|
|
996 return;
|
|
997 }
|
10
|
998 wxMessageBox( wxT( "Bad clipboard data !!" ) );
|
3
|
999 }
|
|
1000
|
|
1001 void MainFrame::PrintImages( void )
|
|
1002 {
|
|
1003 int r = m_dataViewListCtrl->GetSelectedRow();
|
4
|
1004 if ( r == wxNOT_FOUND ) {
|
|
1005 wxMessageBox( wxT( "Not Ready for Print !!" ) );
|
|
1006 return;
|
|
1007 }
|
3
|
1008 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 );
|
|
1009
|
|
1010 if ( !ready.IsSameAs( wxT( "OK" ), true ) ) {
|
|
1011 wxMessageBox( wxT( "Not Ready for Print !!" ) );
|
|
1012 return;
|
|
1013 }
|
|
1014
|
|
1015 wxDateTime now = wxDateTime::Now();
|
|
1016 wxString nowstr = now.Format( "%Y/%m/%d %H:%M", wxDateTime::GMT9 ).c_str();
|
|
1017
|
|
1018 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
1019 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
1020
|
|
1021 wxString html, file;
|
|
1022 html = wxT( "<html><body>\n" );
|
|
1023
|
14
|
1024 int zoom = m_spinCtrl->GetValue();
|
|
1025 wxString imgsz = wxString::Format( wxT( "\" width=\"%d\" height=\"%d\"" ), 750 * zoom / 100, 1060 * zoom / 100 );
|
3
|
1026 for ( int i = 1; i < 6; i++ ) {
|
|
1027 file = wxString::Format( wxT( ".cache/%08s_%d" ), date, i );
|
14
|
1028 html = html + wxT( "<img src=\"" ) + file + imgsz + wxT( "/>\n" );
|
3
|
1029 html = html + wxT( "<div align=right><font size=-2><u>" ) + m_hhs + wxT( "@" ) + m_user + wxT( "#" ) + nowstr + wxT( "</u></font></div>\n\n" );
|
|
1030 }
|
|
1031 html = html + wxT( "</body></html>" );
|
|
1032
|
|
1033 // start printing
|
|
1034 wxHtmlPrintout hpout( wxT( "Re:Searcher" ) );
|
|
1035 hpout.SetMargins( 0, 0, 0, 0, 0 );
|
|
1036 wxPrintDialogData pd;
|
|
1037 wxPrinter p( &pd );
|
|
1038
|
|
1039 hpout.SetHtmlText( html, wxEmptyString, false );
|
|
1040 p.Print( NULL, &hpout, true );
|
5
|
1041
|
|
1042 WriteLog( wxT( "[print]" ) );
|
2
|
1043 }
|
|
1044
|
5
|
1045 void MainFrame::WriteLog( wxString msg )
|
|
1046 {
|
|
1047 wxDateTime now = wxDateTime::Now();
|
|
1048 wxString file = wxGetCwd() + wxFILE_SEP_PATH + wxT( "log" ) + wxFILE_SEP_PATH + now.Format( wxT( "%Y%m%d" ) ) + wxT( ".log" );
|
|
1049
|
|
1050 wxTextFile logfile;
|
|
1051 if ( !wxFileExists( file ) ) logfile.Create( file );
|
|
1052
|
|
1053 logfile.Open( file );
|
|
1054 logfile.AddLine( now.Format( wxT("%Y-%m-%d %H:%M:%S ") ) + msg );
|
|
1055 logfile.Write();
|
|
1056 logfile.Close();
|
|
1057 }
|
|
1058
|
7
|
1059 void MainFrame::Close( void )
|
|
1060 {
|
|
1061 WriteLog( wxT( "[logout]" ) );
|
|
1062 if ( !IsIconized() && !IsMaximized() ) {
|
|
1063 wxGetApp().rect = this->GetRect();
|
|
1064 }
|
|
1065 Destroy();
|
|
1066 }
|
|
1067
|
1
|
1068 void MainFrame::InDevelop( bool flag )
|
0
|
1069 {
|
1
|
1070 if ( !flag ) return;
|
0
|
1071
|
3
|
1072 bool lo = false;
|
|
1073 m_buttonLogout->Enable( lo );
|
|
1074 m_buttonLogout->Show( lo );
|
0
|
1075
|
3
|
1076 bool sl = false;
|
|
1077 m_slider->Enable( sl );
|
|
1078 m_slider->Show( sl );
|
0
|
1079
|
4
|
1080 return;
|
0
|
1081 }
|
|
1082
|