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