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