0
|
1 // Filename : rsearcher.cpp
|
11
|
2 // Last Change: 2018-11-09 金 09:01:40.
|
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 )
|
5
|
293 EVT_BUTTON( wxID_HELP, MainFrame::OnHelp )
|
7
|
294 EVT_BUTTON( wxID_CLOSE, MainFrame::OnBClose )
|
3
|
295 EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout )
|
1
|
296 END_EVENT_TABLE()
|
|
297
|
|
298
|
|
299 // Event Handler
|
10
|
300 void MainFrame::OnSplitWin( wxSplitterEvent& WXUNUSED(event) )
|
|
301 {
|
|
302 int w, h;
|
|
303 this->GetSize( &w, &h );
|
|
304 m_splitter->SetSashPosition( w - 200, true );
|
|
305 }
|
|
306
|
2
|
307 void MainFrame::OnItemSelected( wxDataViewEvent& WXUNUSED(event) )
|
|
308 {
|
|
309 int r = m_dataViewListCtrl->GetSelectedRow();
|
9
|
310 if ( r == wxNOT_FOUND ) return;
|
|
311
|
2
|
312 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 );
|
3
|
313 if ( ready.IsSameAs( wxT( "OK" ), true ) ) {
|
|
314 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
315 date.Replace( wxT( "-" ), wxEmptyString, true );
|
5
|
316 LoadBitmaps( date, false );
|
3
|
317 } else {
|
5
|
318 LoadBitmaps( wxEmptyString, false );
|
2
|
319 }
|
|
320 }
|
|
321
|
1
|
322 void MainFrame::OnItemDClicked( wxDataViewEvent& WXUNUSED(event) )
|
|
323 {
|
|
324 int r = m_dataViewListCtrl->GetSelectedRow();
|
3
|
325 wxString status = m_dataViewListCtrl->GetTextValue( r, 2 );
|
|
326 if ( status.IsSameAs( wxT( "OK" ), true ) ) return;
|
|
327
|
2
|
328 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
329 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
330 GetImages( m_hhs, date );
|
5
|
331 if ( LoadBitmaps( date, true ) )
|
|
332 m_dataViewListCtrl->SetTextValue( wxT( "OK" ), r, 2 );
|
1
|
333 }
|
|
334
|
10
|
335 void MainFrame::OnKanaItemSelected( wxDataViewEvent& WXUNUSED(event) )
|
|
336 {
|
|
337 int r = m_dataViewListKana->GetSelectedRow();
|
|
338 if ( r == wxNOT_FOUND ) return;
|
|
339 }
|
|
340
|
|
341 void MainFrame::OnKanaItemDClicked( wxDataViewEvent& WXUNUSED(event) )
|
|
342 {
|
|
343 m_dataViewListCtrl->DeleteAllItems();
|
|
344 wxGetApp().RemoveFile( wxT( ".cache/*" ) );
|
|
345 LoadBitmaps( wxEmptyString, false );
|
|
346
|
|
347 int r = m_dataViewListKana->GetSelectedRow();
|
|
348 m_searchCtrl->SetValue( m_dataViewListKana->GetTextValue( r, 0 ) );
|
|
349 m_textCtrlName->SetValue( m_dataViewListKana->GetTextValue( r, 1 ) );
|
|
350 m_textCtrlAddr->SetValue( m_dataViewListKana->GetTextValue( r, 2 ) );
|
|
351 m_hhs = m_searchCtrl->GetValue();
|
|
352 Search();
|
|
353 }
|
|
354
|
1
|
355 void MainFrame::OnNBookChanged( wxBookCtrlEvent& WXUNUSED(event) )
|
|
356 {
|
|
357 for ( int i = 0; i < m_notebook->GetPageCount(); i++ ) {
|
|
358 m_notebook->SetPageImage( i, 1 );
|
|
359 }
|
|
360 m_notebook->SetPageImage( m_notebook->GetSelection(), 0 );
|
|
361 }
|
|
362
|
7
|
363 void MainFrame::OnBClose( wxCommandEvent& WXUNUSED(event) )
|
|
364 {
|
|
365 Close();
|
|
366 }
|
|
367
|
|
368 void MainFrame::OnClose( wxCloseEvent& WXUNUSED(event) )
|
1
|
369 {
|
7
|
370 Close();
|
|
371 }
|
|
372
|
|
373 void MainFrame::OnFocus( wxCommandEvent& WXUNUSED(event) )
|
|
374 {
|
|
375 m_searchCtrl->SetFocus();
|
1
|
376 }
|
|
377
|
5
|
378 void MainFrame::OnPasteSearch( wxCommandEvent& WXUNUSED(event) )
|
|
379 {
|
8
|
380 m_textCtrlName->SetValue( wxEmptyString );
|
|
381 m_textCtrlAddr->SetValue( wxEmptyString );
|
|
382 m_dataViewListCtrl->DeleteAllItems();
|
|
383 PasteSearch();
|
5
|
384 }
|
|
385
|
3
|
386 void MainFrame::OnPrint( wxCommandEvent& WXUNUSED(event) )
|
|
387 {
|
|
388 PrintImages();
|
|
389 }
|
|
390
|
6
|
391 void MainFrame::OnPlusZoom( wxCommandEvent& WXUNUSED(event) )
|
|
392 {
|
|
393 ChangeCZoom( 1 );
|
|
394 }
|
|
395
|
|
396 void MainFrame::OnMinusZoom( wxCommandEvent& WXUNUSED(event ) )
|
|
397 {
|
|
398 ChangeCZoom( -1 );
|
|
399 }
|
|
400
|
|
401 void MainFrame::OnDark( wxCommandEvent& WXUNUSED(event ) )
|
|
402 {
|
|
403 ChangeColor( m_staticBitmap1 );
|
|
404 ChangeColor( m_staticBitmap2 );
|
|
405 ChangeColor( m_staticBitmap3 );
|
|
406 ChangeColor( m_staticBitmap4 );
|
|
407 ChangeColor( m_staticBitmap5 );
|
|
408 m_dark = !m_dark;
|
|
409 }
|
|
410
|
9
|
411 void MainFrame::OnSatellite( wxCommandEvent& WXUNUSED(event ) )
|
|
412 {
|
|
413 int n = m_notebook->GetSelection();
|
|
414 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 );
|
|
415 wxBitmap bmp;
|
|
416 if ( n == 0 ) bmp = m_staticBitmap1->GetBitmap();
|
|
417 if ( n == 1 ) bmp = m_staticBitmap2->GetBitmap();
|
|
418 if ( n == 2 ) bmp = m_staticBitmap3->GetBitmap();
|
|
419 if ( n == 3 ) bmp = m_staticBitmap4->GetBitmap();
|
|
420 if ( n == 4 ) bmp = m_staticBitmap5->GetBitmap();
|
|
421 stl->SetBitmap( bmp );
|
|
422
|
|
423 int w = bmp.GetWidth();
|
|
424 int h = bmp.GetHeight();
|
|
425 stl->SetScroll( w, h );
|
|
426
|
|
427 stl->Show();
|
|
428 }
|
|
429
|
5
|
430 void MainFrame::OnHelp( wxCommandEvent& WXUNUSED(event) )
|
|
431 {
|
|
432 wxString version, build;
|
10
|
433 version = wxString::Format( wxT( "Re:Searcher -- version %s / %s\n\n" ), RSVER, RSRELEASE );
|
5
|
434 build = wxString::Format( wxT( "build with %s\nrunning under %s." ), wxVERSION_STRING, wxGetOsDescription() );
|
|
435
|
|
436 wxMessageBox( version + build, wxT( "Help" ) );
|
|
437 return;
|
|
438 }
|
|
439
|
3
|
440 void MainFrame::OnLogout( wxCommandEvent& WXUNUSED(event) )
|
|
441 {
|
|
442 wxMessageBox("logout");
|
|
443 return;
|
|
444 }
|
|
445
|
|
446 void MainFrame::OnTimer( wxTimerEvent& WXUNUSED(event) )
|
|
447 {
|
5
|
448 //wxMessageBox( "timer !" );
|
3
|
449 // logout
|
|
450 }
|
|
451
|
|
452 void MainFrame::OnIdle( wxIdleEvent& event )
|
|
453 {
|
|
454 if ( !m_timer.IsRunning() ) {
|
|
455 m_timer.Start( 300 * 1000, wxTIMER_ONE_SHOT );
|
|
456 }
|
|
457 event.RequestMore();
|
|
458 event.Skip();
|
|
459 }
|
|
460
|
1
|
461 // Functions
|
|
462 void MainFrame::CreateControls( void )
|
|
463 {
|
0
|
464 this->SetIcon( wxIcon( wxT( "sample" ) ) );
|
10
|
465 this->SetSizeHints( wxSize( 400, 300 ), wxDefaultSize );
|
5
|
466 this->SetBackgroundColour( wxColour( 30, 80, 40 ) );
|
|
467 //this->SetBackgroundColour( wxColour( 153, 153, 153 ) );
|
0
|
468
|
|
469 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL );
|
10
|
470
|
|
471 m_splitter = new wxSplitterWindow( this, ID_SPLIT, wxDefaultPosition, wxDefaultSize, wxSP_THIN_SASH );
|
|
472 m_splitter->SetMinimumPaneSize( 20 );
|
|
473 m_panelLeft = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
|
474 m_panelLeft->SetBackgroundColour( wxColour( 30, 80, 40 ) );
|
|
475 m_panelRight = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
|
476 m_panelRight->SetBackgroundColour( wxColour( 30, 80, 40 ) );
|
|
477
|
|
478 int w, h;
|
|
479 this->GetSize( &w, &h );
|
|
480 m_splitter->SplitVertically( m_panelLeft, m_panelRight, w - 200 );
|
0
|
481
|
|
482 // Left
|
10
|
483 wxBoxSizer* bSizerLeft = new wxBoxSizer( wxVERTICAL );
|
|
484
|
0
|
485 wxImageList* imgList = new wxImageList( 16, 16, false, 1 );
|
|
486 wxBitmap bmp( wxT( "image/blue.png" ), wxBITMAP_TYPE_PNG );
|
|
487 imgList->Add( bmp, wxNullBitmap );
|
|
488 bmp.LoadFile( wxT( "image/water.png" ), wxBITMAP_TYPE_PNG );
|
|
489 imgList->Add( bmp, wxNullBitmap );
|
|
490
|
10
|
491 m_notebook = new wxNotebook( m_panelLeft, ID_NBOOK, wxDefaultPosition, wxDefaultSize, 0 );
|
0
|
492 m_notebook->SetImageList( imgList );
|
|
493
|
|
494 m_scrolledWindow1 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
495 m_scrolledWindow1->SetScrollRate( 5, 5 );
|
|
496 m_notebook->AddPage( m_scrolledWindow1, wxT( "Image-01" ), false, 0 );
|
|
497
|
|
498 m_scrolledWindow2 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
499 m_scrolledWindow2->SetScrollRate( 5, 5 );
|
|
500 m_notebook->AddPage( m_scrolledWindow2, wxT( "Image-02" ), false, 0 );
|
|
501
|
|
502 m_scrolledWindow3 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
503 m_scrolledWindow3->SetScrollRate( 5, 5 );
|
|
504 m_notebook->AddPage( m_scrolledWindow3, wxT( "Image-03" ), false, 0 );
|
|
505
|
|
506 m_scrolledWindow4 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
507 m_scrolledWindow4->SetScrollRate( 5, 5 );
|
|
508 m_notebook->AddPage( m_scrolledWindow4, wxT( "Image-04" ), false, 0 );
|
|
509
|
|
510 m_scrolledWindow5 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
511 m_scrolledWindow5->SetScrollRate( 5, 5 );
|
|
512 m_notebook->AddPage( m_scrolledWindow5, wxT( "Image-05" ), false, 0 );
|
|
513
|
|
514 m_scrolledWindow6 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
515 m_scrolledWindow6->SetScrollRate( 5, 5 );
|
|
516 m_notebook->AddPage( m_scrolledWindow6, wxT( "Image-06" ), false, 0 );
|
|
517
|
10
|
518 bSizerLeft->Add( m_notebook, 1, wxEXPAND|wxALL, 5 );
|
|
519 m_panelLeft->SetSizer( bSizerLeft );
|
0
|
520
|
|
521 // Right
|
|
522 wxBoxSizer* bSizerRight = new wxBoxSizer( wxVERTICAL );
|
|
523
|
10
|
524 m_searchCtrl = new MySearchCtrl( m_panelRight, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxSize( -1, 24 ), wxTE_PROCESS_ENTER );
|
0
|
525 bSizerRight->Add( m_searchCtrl, 0, wxALL, 5 );
|
|
526 m_searchCtrl->SetFocus();
|
|
527
|
10
|
528 m_textCtrlName = new wxTextCtrl( m_panelRight, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), wxTE_READONLY );
|
0
|
529 m_textCtrlName->SetBackgroundColour( wxColour( 180, 210, 240 ) );
|
|
530 bSizerRight->Add( m_textCtrlName, 0, wxALL, 5 );
|
|
531
|
10
|
532 m_textCtrlAddr = new wxTextCtrl( m_panelRight, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 160, -1 ), wxTE_READONLY );
|
0
|
533 m_textCtrlAddr->SetBackgroundColour( wxColour( 180, 210, 240 ) );
|
|
534 bSizerRight->Add( m_textCtrlAddr, 0, wxALL|wxEXPAND, 5 );
|
|
535
|
10
|
536 m_dataViewListCtrl = new wxDataViewListCtrl( m_panelRight, ID_LIST, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE );
|
|
537 m_dataViewListColumnNo = m_dataViewListCtrl->AppendTextColumn( wxT( "No" ), wxDATAVIEW_CELL_INERT, 30, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
538 m_dataViewListColumnDate = m_dataViewListCtrl->AppendTextColumn( wxT( " Date" ), wxDATAVIEW_CELL_INERT, 80, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
539 m_dataViewListColumnReady = m_dataViewListCtrl->AppendTextColumn( wxT( "Ready" ), wxDATAVIEW_CELL_INERT, 60, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
0
|
540 bSizerRight->Add( m_dataViewListCtrl, 1, wxALL|wxEXPAND, 5 );
|
|
541
|
10
|
542 m_dataViewListKana = new wxDataViewListCtrl( m_panelRight, ID_LISTKANA, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE );
|
|
543 m_dataViewListColumnKNo = m_dataViewListKana->AppendTextColumn( wxT( " No" ), wxDATAVIEW_CELL_INERT, 70, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
544 m_dataViewListColumnName = m_dataViewListKana->AppendTextColumn( wxT( " Name" ), wxDATAVIEW_CELL_INERT, 80, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
545 m_dataViewListColumnAddr = m_dataViewListKana->AppendTextColumn( wxT( " Address" ), wxDATAVIEW_CELL_INERT, -1, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
546 bSizerRight->Add( m_dataViewListKana, 1, wxALL|wxEXPAND, 5 );
|
|
547
|
|
548 m_textCtrlLog = new wxTextCtrl( m_panelRight, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1, 40 ), 0 );
|
|
549 bSizerRight->Add( m_textCtrlLog, 0, wxALL|wxEXPAND, 5 );
|
0
|
550
|
10
|
551 m_buttonPsearch = new wxButton( m_panelRight, ID_PSEARCH, wxT( "Paste-Search" ), wxDefaultPosition, wxDefaultSize, 0 );
|
5
|
552 bSizerRight->Add( m_buttonPsearch, 0, wxALL, 5 );
|
|
553
|
10
|
554 m_buttonPrint = new wxButton( m_panelRight, wxID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 );
|
0
|
555 bSizerRight->Add( m_buttonPrint, 0, wxALL, 5 );
|
|
556
|
10
|
557 // now building...
|
|
558 m_slider = new wxSlider( m_panelRight, ID_SLDR, 1, 1, 5, wxDefaultPosition, wxSize( -1, 200 ), wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LABELS|wxSL_VERTICAL );
|
|
559 //bSizerRight->Add( m_slider, 0, wxALL, 5 );
|
|
560
|
|
561 m_buttonLogout = new wxButton( m_panelRight, ID_LOGOUT, wxT( "Logout" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
562 //bSizerRight->Add( m_buttonLogout, 0, wxALL, 5 );
|
3
|
563
|
6
|
564 // invisible buttons for shortcut-key
|
7
|
565 m_buttonFocus = new wxButton( this, ID_FOCUS, wxT( "Focus" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
566 m_buttonFocus->Hide();
|
6
|
567 m_buttonPzoom = new wxButton( this, ID_PZOOM, wxT( "ZOOM" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
568 m_buttonPzoom->Hide();
|
|
569 m_buttonMzoom = new wxButton( this, ID_MZOOM, wxT( "zoom" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
570 m_buttonMzoom->Hide();
|
|
571 m_buttonDark = new wxButton( this, ID_DARK, wxT( "Dark" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
572 m_buttonDark->Hide();
|
9
|
573 m_buttonSatellite = new wxButton( this, ID_SWIN, wxT( "Satellite" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
574 m_buttonSatellite->Hide();
|
10
|
575 m_buttonClose = new wxButton( this, wxID_CLOSE, wxT( "Close" ), wxDefaultPosition, wxDefaultSize, 0 );
|
7
|
576 m_buttonClose->Hide();
|
10
|
577 m_buttonHelp = new wxButton( this, wxID_HELP, wxT( "Help" ), wxDefaultPosition, wxDefaultSize, 0 );
|
6
|
578 m_buttonHelp->Hide();
|
|
579
|
10
|
580 m_panelRight->SetSizer( bSizerRight );
|
0
|
581
|
10
|
582 //
|
|
583 bSizerTop->Add( m_splitter, 1, wxEXPAND, 0 );
|
|
584
|
0
|
585 this->SetSizer( bSizerTop );
|
|
586 this->Layout();
|
|
587
|
|
588 //this->Centre( wxBOTH );
|
|
589 m_staticBitmap1 = new MyStaticBitmap( m_scrolledWindow1, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
590 m_staticBitmap2 = new MyStaticBitmap( m_scrolledWindow2, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
591 m_staticBitmap3 = new MyStaticBitmap( m_scrolledWindow3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
592 m_staticBitmap4 = new MyStaticBitmap( m_scrolledWindow4, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
593 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
594 }
|
|
595
|
5
|
596 void MainFrame::SetAccelerator( void )
|
|
597 {
|
9
|
598 wxAcceleratorEntry entries[9];
|
6
|
599 entries[0].Set( wxACCEL_CTRL, (int)'P', wxID_PRINT );
|
|
600 entries[1].Set( wxACCEL_NORMAL, WXK_F1, wxID_HELP );
|
7
|
601 entries[2].Set( wxACCEL_NORMAL, WXK_F4, ID_FOCUS );
|
|
602 entries[3].Set( wxACCEL_NORMAL, (int)'Z', ID_PZOOM );
|
|
603 entries[4].Set( wxACCEL_NORMAL, (int)'X', ID_MZOOM );
|
|
604 entries[5].Set( wxACCEL_NORMAL, (int)'D', ID_DARK );
|
9
|
605 entries[6].Set( wxACCEL_CTRL, (int)'Q', wxID_CLOSE );
|
|
606 entries[7].Set( wxACCEL_SHIFT, (int)'W', ID_SWIN );
|
|
607 entries[8].Set( wxACCEL_SHIFT, (int)'L', ID_DARK ); // now building ( logout )
|
7
|
608 wxAcceleratorTable accel( 8, entries );
|
5
|
609 SetAcceleratorTable( accel );
|
|
610 }
|
|
611
|
0
|
612 void MainFrame::Cmd( wxString cmd )
|
|
613 {
|
6
|
614 m_textCtrlName->SetValue( wxEmptyString );
|
|
615 m_textCtrlAddr->SetValue( wxEmptyString );
|
8
|
616 m_dataViewListCtrl->DeleteAllItems();
|
10
|
617 m_dataViewListKana->DeleteAllItems();
|
8
|
618 wxGetApp().RemoveFile( wxT( ".cache/*" ) );
|
5
|
619 LoadBitmaps( wxEmptyString, false );
|
6
|
620
|
5
|
621 wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) );
|
0
|
622
|
2
|
623 if ( cmd.IsSameAs( wxT( "q" ), true ) || cmd.IsSameAs( wxT( "9" ), true ) ) {
|
0
|
624 Close();
|
2
|
625 return;
|
0
|
626 }
|
|
627
|
2
|
628 if ( cmd.IsSameAs( wxT( "c" ), true ) || cmd.IsSameAs( wxT( "cmd" ), true ) ) {
|
|
629 return;
|
|
630 }
|
|
631
|
11
|
632 if ( cmd.IsSameAs( wxT( "3915" ), true ) ) {
|
|
633 ManageDBFrame *mngframe = new ManageDBFrame( this, wxID_ANY, wxT( "Management Window" ), wxDefaultPosition, wxSize( 300, 180 ), wxCAPTION|wxTAB_TRAVERSAL );
|
|
634 mngframe->Show();
|
3
|
635 return;
|
|
636 }
|
|
637
|
|
638 if ( cmd.IsSameAs( wxT( "." ), false ) ) {
|
0
|
639 wxString appdir = wxGetCwd();
|
|
640 wxString execmd = wxT( "explorer " ) + appdir;
|
|
641 wxExecute( execmd );
|
|
642 return;
|
|
643 }
|
|
644
|
3
|
645 if ( cmd.IsSameAs( wxT( "*" ), false ) ) {
|
8
|
646 PasteSearch();
|
5
|
647 return;
|
3
|
648 }
|
|
649
|
|
650 if ( cmd.IsSameAs( wxT( "+" ), false ) ) {
|
6
|
651 //PrintImages();
|
3
|
652 return;
|
|
653 }
|
|
654
|
0
|
655 if ( reHhs.Matches( cmd ) ) {
|
2
|
656 m_hhs = m_searchCtrl->GetValue();
|
|
657 Search();
|
|
658 return;
|
|
659 }
|
0
|
660
|
10
|
661 wxString hiragana = wxT( "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをんがぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽぁぃぅぇぉゃゅょっ " );
|
|
662 wxString katakana = wxT( "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンガギグゲコザジズゼゾダヂヅデドバビブベボパピプペポァィゥェォャュョッ " );
|
|
663 wxRegEx reHiraGana( wxT( "^[" ) + hiragana + wxT( "]+$" ) );
|
|
664 wxRegEx reKataKana( wxT( "^[" ) + katakana + wxT( "]+$" ) );
|
|
665
|
|
666 bool fuzzy = false;
|
|
667 if ( cmd.Right( 1 ).IsSameAs( wxT( "%" ) ) ) {
|
|
668 cmd.Replace( wxT( "%" ), wxEmptyString, true );
|
|
669 fuzzy = true;
|
|
670 }
|
|
671
|
|
672 if ( reHiraGana.Matches( cmd ) || reKataKana.Matches( cmd ) ) {
|
|
673 if ( cmd.Len() < 5 ) {
|
|
674 wxMessageBox( wxT( "too short !" ) );
|
|
675 return;
|
|
676 }
|
|
677 if ( reHiraGana.Matches( cmd ) ) {
|
|
678 for ( int i = 0; i < hiragana.Len(); i++ )
|
|
679 cmd.Replace( hiragana[i], katakana[i], true );
|
|
680 }
|
|
681
|
|
682 int match_cnt = 0;
|
|
683 HhsHash::iterator it;
|
|
684 for( it = hhash.begin(); it != hhash.end(); ++it ){
|
|
685 wxString key = it->first, value = it->second->kana;
|
|
686 value.Replace( wxT( " " ), wxEmptyString, true );
|
|
687 if ( value.IsSameAs( cmd ) || ( fuzzy && value.StartsWith( cmd ) ) ) {
|
|
688 wxVector<wxVariant> data;
|
|
689 data.push_back( key );
|
|
690 data.push_back( it->second->name );
|
|
691 data.push_back( it->second->addr );
|
|
692 m_dataViewListKana->AppendItem( data );
|
|
693 data.clear();
|
|
694 m_dataViewListKana->ToggleWindowStyle( wxHSCROLL );
|
|
695 match_cnt++;
|
|
696 }
|
|
697 }
|
|
698
|
|
699 if ( match_cnt == 1 ) {
|
|
700 m_searchCtrl->SetValue( m_dataViewListKana->GetTextValue( 0, 0 ) );
|
|
701 m_textCtrlName->SetValue( m_dataViewListKana->GetTextValue( 0, 1 ) );
|
|
702 m_textCtrlAddr->SetValue( m_dataViewListKana->GetTextValue( 0, 2 ) );
|
|
703 m_hhs = m_searchCtrl->GetValue();
|
|
704 Search();
|
|
705 }
|
|
706
|
|
707 if ( match_cnt == 0 ) {
|
|
708 wxMessageBox( wxT( "No name matched." ) );
|
|
709 }
|
|
710 return;
|
|
711 }
|
|
712
|
3
|
713 wxMessageBox( wxT( "Bad Input !!" ) );
|
0
|
714 }
|
|
715
|
6
|
716 bool MainFrame::LoadBitmap( wxScrolledWindow* sc, MyStaticBitmap* sb, wxString file )
|
0
|
717 {
|
5
|
718 sb->SetBitmap( wxNullBitmap );
|
6
|
719 sb->zoom = 0;
|
5
|
720 sc->Scroll( 0, 0 );
|
|
721
|
|
722 bool ok = true;
|
2
|
723 if ( startup ) {
|
5
|
724 file = wxT( "image/hello.jpg" );
|
2
|
725 startup = false;
|
|
726 }
|
5
|
727 if ( !wxFileExists( file ) ) {
|
|
728 file = wxT( "image/testpattern.jpg" );
|
|
729 ok = false;
|
|
730 }
|
0
|
731 wxBitmap bmp( file, wxBITMAP_TYPE_JPEG );
|
6
|
732 sb->SetOrigImage( bmp );
|
0
|
733 int width = bmp.GetWidth();
|
|
734 int height = bmp.GetHeight();
|
|
735 wxImage img = bmp.ConvertToImage();
|
|
736
|
|
737 int ww, wh;
|
1
|
738 sc->GetSize( &ww, &wh );
|
0
|
739
|
3
|
740 float w = ww - 30;
|
0
|
741 float h = w * height / width;
|
|
742 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
|
5
|
743 sc->SetScrollbars( 10, 10, (int)w / 10, (int)h / 10 );
|
0
|
744
|
5
|
745 return ok;
|
0
|
746 }
|
|
747
|
5
|
748 bool MainFrame::LoadBitmaps( wxString date, bool reload )
|
0
|
749 {
|
5
|
750 bool ok;
|
|
751 ok = LoadBitmap( m_scrolledWindow1, m_staticBitmap1, wxString::Format( wxT( ".cache/%08s_1" ), date ) );
|
|
752 ok = LoadBitmap( m_scrolledWindow2, m_staticBitmap2, wxString::Format( wxT( ".cache/%08s_2" ), date ) );
|
|
753 ok = LoadBitmap( m_scrolledWindow3, m_staticBitmap3, wxString::Format( wxT( ".cache/%08s_3" ), date ) );
|
|
754 ok = LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( wxT( ".cache/%08s_4" ), date ) );
|
|
755 ok = LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( wxT( ".cache/%08s_5" ), date ) );
|
|
756
|
|
757 if ( !ok && reload ) {
|
|
758 wxSleep( 5 );
|
7
|
759 ok = LoadBitmaps( date, false );
|
5
|
760 }
|
|
761 return ok;
|
2
|
762 }
|
|
763
|
6
|
764 void MainFrame::ChangeCZoom( int z )
|
|
765 {
|
|
766 int n = m_notebook->GetSelection();
|
|
767 if ( n == 0 ) ChangeZoom( m_scrolledWindow1, m_staticBitmap1, z );
|
|
768 if ( n == 1 ) ChangeZoom( m_scrolledWindow2, m_staticBitmap2, z );
|
|
769 if ( n == 2 ) ChangeZoom( m_scrolledWindow3, m_staticBitmap3, z );
|
|
770 if ( n == 3 ) ChangeZoom( m_scrolledWindow4, m_staticBitmap4, z );
|
|
771 if ( n == 4 ) ChangeZoom( m_scrolledWindow5, m_staticBitmap5, z );
|
|
772 }
|
|
773
|
|
774 void MainFrame::ChangeZoom( wxScrolledWindow* sc, MyStaticBitmap* sb, int z )
|
|
775 {
|
|
776 if ( z > 0 ) sb->zoom++;
|
|
777 else sb->zoom--;
|
|
778
|
|
779 float zz = pow( 1.1, sb->zoom );
|
|
780
|
|
781 int x, y;
|
|
782 sc->GetViewStart( &x, &y );
|
|
783 sc->Scroll( 0, 0 );
|
|
784 wxBitmap bmp = sb->GetOrigImage();
|
|
785
|
|
786 int width = bmp.GetWidth();
|
|
787 int height = bmp.GetHeight();
|
|
788 wxImage img = bmp.ConvertToImage();
|
|
789
|
|
790 int ww, wh;
|
|
791 sc->GetSize( &ww, &wh );
|
|
792
|
|
793 float w = ww * zz - 30;
|
|
794 float h = w * height / width;
|
|
795 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
|
|
796 sc->SetScrollbars( 10, 10, (int)w / 10, (int)h / 10 );
|
|
797 sc->Scroll( x, y );
|
|
798
|
|
799 if ( m_dark ) ChangeColor( sb );
|
|
800 }
|
|
801
|
|
802 void MainFrame::ChangeColor( MyStaticBitmap* sb )
|
|
803 {
|
|
804 wxBitmap bmp = sb->GetBitmap();
|
|
805 wxImage img = bmp.ConvertToImage();
|
|
806 unsigned char r, g, b;
|
|
807 for ( int x = 0; x < img.GetWidth(); x++ ) {
|
|
808 for ( int y = 0; y < img.GetHeight(); y++ ) {
|
|
809 r = 255 - img.GetRed( x, y );
|
|
810 g = 255 - img.GetGreen( x, y );
|
|
811 b = 255 - img.GetBlue( x, y );
|
|
812 img.SetRGB( x, y, r, g, b );
|
|
813 }
|
|
814 }
|
|
815 sb->SetBitmap( wxBitmap( img ) );
|
|
816 }
|
|
817
|
2
|
818 void MainFrame::GetImages( wxString hhs, wxString date )
|
|
819 {
|
8
|
820 int estimate = http.GetImagesSize( hhs, date ) / 1000000;
|
7
|
821 wxProgressDialog pd( wxT( "Connecting Server" ), wxT( "Start..." ), estimate, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
|
|
822 pd.SetSize( wxSize( 320, 140 ) );
|
|
823
|
|
824 http.GetImages( hhs, date );
|
|
825 for ( int i = 0; i < estimate; i++ ) {
|
8
|
826 wxMilliSleep( 1 );
|
7
|
827 pd.Update( i, wxT( "Now Loading..." ) );
|
|
828 }
|
|
829 }
|
|
830
|
2
|
831 void MainFrame::Search( void )
|
0
|
832 {
|
5
|
833 // hhs info
|
|
834 if ( hhash.count( m_hhs ) ) {
|
|
835 m_textCtrlName->SetValue( hhash[ m_hhs ]->name );
|
|
836 m_textCtrlAddr->SetValue( hhash[ m_hhs ]->addr );
|
|
837 }
|
|
838
|
|
839 // index
|
2
|
840 wxString date;
|
|
841 int match_cnt = 0;
|
|
842 for ( int i = 0; i < m_index.GetCount(); i++ ) {
|
|
843 if ( m_index[i].StartsWith( m_hhs, &date ) ) {
|
|
844 wxVector<wxVariant> data;
|
|
845 data.push_back( wxString::Format( wxT( "%02d" ), ++match_cnt ) );
|
|
846 date = date.Mid( 1, 4 ) + wxT( "-" ) + date.Mid( 5, 2 ) + wxT( "-" ) + date.Mid( 7, 2 );
|
|
847 data.push_back( date );
|
|
848 data.push_back( wxEmptyString );
|
|
849 m_dataViewListCtrl->AppendItem( data );
|
|
850 data.clear();
|
|
851 }
|
|
852 }
|
5
|
853
|
|
854 if ( match_cnt == 0 ) {
|
|
855 wxMessageBox( wxT( "Not Matched !!" ) );
|
|
856 } else {
|
|
857 wxString date = m_dataViewListCtrl->GetTextValue( 0, 1 );
|
|
858 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
859 GetImages( m_hhs, date );
|
|
860 if ( LoadBitmaps( date, true ) ) {
|
|
861 m_dataViewListCtrl->SetTextValue( wxT( "OK" ), 0, 2 );
|
|
862 m_dataViewListCtrl->SelectRow( 0 );
|
|
863 }
|
|
864 }
|
|
865
|
|
866 WriteLog( wxT( "[search] " ) + m_hhs );
|
2
|
867 }
|
|
868
|
3
|
869 void MainFrame::LoadDB( void )
|
2
|
870 {
|
5
|
871 wxProgressDialog pd( wxT( "Load Data" ), wxT( "Now loading..." ), 100, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
|
|
872 pd.SetSize( wxSize( 320, 140 ) );
|
|
873
|
|
874 // index
|
2
|
875 wxTextFile file;
|
|
876 file.Open( wxT( "index.db" ) );
|
|
877 for ( int i = 0; i < file.GetLineCount(); i++ )
|
|
878 m_index.Add( file.GetLine( i ) );
|
|
879 file.Close();
|
|
880 m_index.Sort( true );
|
3
|
881
|
5
|
882 // decrypto
|
|
883 wxString key = wxT( "12345678900123456789abcdefabcdef" );
|
|
884 wxArrayString args;
|
|
885 args.Add( wxT( "crypto.exe" ) );
|
|
886 args.Add( wxT( "-d" ) );
|
|
887 args.Add( wxT( "hhs.db" ) );
|
|
888 args.Add( wxT( "-k" ) );
|
|
889 args.Add( key );
|
|
890
|
|
891 wxArrayString output, errors;
|
|
892 wxExecute( wxJoin( args, ' ', '\\' ), output, errors );
|
|
893
|
|
894 for ( int i = 0; i < 100; i++ ) {
|
|
895 wxMilliSleep( 2 );
|
|
896 pd.Update( i, wxString::Format( wxT( "Now loding ... ( %0.1f %% )" ), (float)i ) );
|
|
897 }
|
|
898 if ( errors.GetCount() > 0 ) {
|
8
|
899 wxMessageBox( wxT( "crypto error: " )+ errors[0] );
|
5
|
900 return;
|
|
901 }
|
|
902 for ( int i = 0; i < output.GetCount(); i++ ) {
|
|
903 wxArrayString buf = wxSplit( output[i], ',', '\\' );
|
|
904 hhash[ buf[0] ] = new HhsClass( buf ); // no, birth, name, kana, addr, sex
|
3
|
905 }
|
5
|
906 }
|
|
907
|
8
|
908 void MainFrame::PasteSearch( void )
|
5
|
909 {
|
|
910 wxString s;
|
|
911 if ( wxTheClipboard->Open() ) {
|
|
912 if ( wxTheClipboard->IsSupported( wxDF_TEXT ) ) {
|
|
913 wxTextDataObject data;
|
|
914 wxTheClipboard->GetData( data );
|
|
915 s = data.GetText();
|
|
916 }
|
|
917 wxTheClipboard->Close();
|
|
918 }
|
|
919
|
|
920 s.Replace( wxT(" "), wxT(""), true );
|
|
921 wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) );
|
|
922 if ( reHhs.Matches( s ) ) {
|
|
923 m_searchCtrl->SetValue( s );
|
|
924 m_hhs = m_searchCtrl->GetValue();
|
|
925 Search();
|
|
926 return;
|
|
927 }
|
10
|
928 wxMessageBox( wxT( "Bad clipboard data !!" ) );
|
3
|
929 }
|
|
930
|
|
931 void MainFrame::PrintImages( void )
|
|
932 {
|
|
933 int r = m_dataViewListCtrl->GetSelectedRow();
|
4
|
934 if ( r == wxNOT_FOUND ) {
|
|
935 wxMessageBox( wxT( "Not Ready for Print !!" ) );
|
|
936 return;
|
|
937 }
|
3
|
938 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 );
|
|
939
|
|
940 if ( !ready.IsSameAs( wxT( "OK" ), true ) ) {
|
|
941 wxMessageBox( wxT( "Not Ready for Print !!" ) );
|
|
942 return;
|
|
943 }
|
|
944
|
|
945 wxDateTime now = wxDateTime::Now();
|
|
946 wxString nowstr = now.Format( "%Y/%m/%d %H:%M", wxDateTime::GMT9 ).c_str();
|
|
947
|
|
948 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
949 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
950
|
|
951 wxString html, file;
|
|
952 html = wxT( "<html><body>\n" );
|
|
953
|
|
954 for ( int i = 1; i < 6; i++ ) {
|
|
955 file = wxString::Format( wxT( ".cache/%08s_%d" ), date, i );
|
|
956 html = html + wxT( "<img src=\"" ) + file + wxT( "\" width=\"750\" height=\"1060\"/>\n" );
|
|
957 html = html + wxT( "<div align=right><font size=-2><u>" ) + m_hhs + wxT( "@" ) + m_user + wxT( "#" ) + nowstr + wxT( "</u></font></div>\n\n" );
|
|
958 }
|
|
959 html = html + wxT( "</body></html>" );
|
|
960
|
|
961 // start printing
|
|
962 wxHtmlPrintout hpout( wxT( "Re:Searcher" ) );
|
|
963 hpout.SetMargins( 0, 0, 0, 0, 0 );
|
|
964 wxPrintDialogData pd;
|
|
965 wxPrinter p( &pd );
|
|
966
|
|
967 hpout.SetHtmlText( html, wxEmptyString, false );
|
|
968 p.Print( NULL, &hpout, true );
|
5
|
969
|
|
970 WriteLog( wxT( "[print]" ) );
|
2
|
971 }
|
|
972
|
5
|
973 void MainFrame::WriteLog( wxString msg )
|
|
974 {
|
|
975 wxDateTime now = wxDateTime::Now();
|
|
976 wxString file = wxGetCwd() + wxFILE_SEP_PATH + wxT( "log" ) + wxFILE_SEP_PATH + now.Format( wxT( "%Y%m%d" ) ) + wxT( ".log" );
|
|
977
|
|
978 wxTextFile logfile;
|
|
979 if ( !wxFileExists( file ) ) logfile.Create( file );
|
|
980
|
|
981 logfile.Open( file );
|
|
982 logfile.AddLine( now.Format( wxT("%Y-%m-%d %H:%M:%S ") ) + msg );
|
|
983 logfile.Write();
|
|
984 logfile.Close();
|
|
985 }
|
|
986
|
7
|
987 void MainFrame::Close( void )
|
|
988 {
|
|
989 WriteLog( wxT( "[logout]" ) );
|
|
990 if ( !IsIconized() && !IsMaximized() ) {
|
|
991 wxGetApp().rect = this->GetRect();
|
|
992 }
|
|
993 Destroy();
|
|
994 }
|
|
995
|
1
|
996 void MainFrame::InDevelop( bool flag )
|
0
|
997 {
|
1
|
998 if ( !flag ) return;
|
0
|
999
|
3
|
1000 bool lo = false;
|
|
1001 m_buttonLogout->Enable( lo );
|
|
1002 m_buttonLogout->Show( lo );
|
0
|
1003
|
3
|
1004 bool sl = false;
|
|
1005 m_slider->Enable( sl );
|
|
1006 m_slider->Show( sl );
|
0
|
1007
|
4
|
1008 return;
|
0
|
1009 }
|
|
1010
|