0
|
1 // Filename : rsearcher.cpp
|
6
|
2 // Last Change: 2018-10-23 ‰Î 13:09:30.
|
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;
|
3
|
94 Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OnLeftDown ), NULL, this );
|
|
95 Connect( wxEVT_LEFT_UP, wxMouseEventHandler( OnLeftUp ), NULL, this );
|
|
96 Connect( wxEVT_MOTION, wxMouseEventHandler( OnMotion ), NULL, this );
|
|
97 Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OnWheel ), NULL, this );
|
|
98
|
|
99 Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OnStartRGesture ), NULL, this );
|
|
100 Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( OnEndRGesture ), NULL, this );
|
0
|
101 }
|
|
102
|
|
103 MyStaticBitmap::~MyStaticBitmap()
|
|
104 {
|
3
|
105 Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OnLeftDown ), NULL, this );
|
|
106 Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( OnLeftUp ), NULL, this );
|
|
107 Disconnect( wxEVT_MOTION, wxMouseEventHandler( OnMotion ), NULL, this );
|
|
108 Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OnWheel ), NULL, this );
|
|
109
|
|
110 Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OnStartRGesture ), NULL, this );
|
|
111 Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( OnEndRGesture ), NULL, this );
|
0
|
112 }
|
|
113
|
|
114 // Event Handlers
|
|
115 void MyStaticBitmap::OnWheel( wxMouseEvent& event )
|
|
116 {
|
|
117 if ( event.ControlDown() ) {
|
|
118 if ( event.GetWheelRotation() < 0 ) {
|
6
|
119 //if ( m_zoom < 4 ) m_zoom++;
|
0
|
120 }
|
|
121 else {
|
6
|
122 //if ( m_zoom > 0 ) m_zoom--;
|
0
|
123 }
|
|
124 return;
|
|
125 }
|
|
126 event.Skip();
|
|
127 }
|
|
128
|
|
129 void MyStaticBitmap::OnLeftDown( wxMouseEvent& event )
|
|
130 {
|
|
131 event.GetPosition( &m_dragx, &m_dragy );
|
|
132 SetCursor( wxCursor( wxCURSOR_SIZING ) );
|
|
133 }
|
|
134
|
|
135 void MyStaticBitmap::OnLeftUp( wxMouseEvent& WXUNUSED(event) )
|
|
136 {
|
|
137 SetCursor( wxCursor( wxCURSOR_ARROW ) );
|
|
138 }
|
|
139
|
|
140 void MyStaticBitmap::OnMotion( wxMouseEvent& event )
|
|
141 {
|
5
|
142 if ( event.RightIsDown() ) return;
|
0
|
143 if ( event.Dragging() ) {
|
|
144 int xv, yv, x, y;
|
|
145 m_parent->GetViewStart( &xv, &yv );
|
|
146
|
|
147 event.GetPosition( &x, &y );
|
|
148
|
|
149 int xa = abs( x - m_dragx );
|
|
150 int ya = abs( y - m_dragy );
|
|
151 int xs = x - m_dragx < 0 ? -1 : 1;
|
|
152 int ys = y - m_dragy < 0 ? -1 : 1;
|
|
153
|
|
154 /* handai dakedo sumu-zu
|
|
155 m_parent->Scroll( xv + xs * log10( xa + 1 ), yv + ys * log10( ya + 1 ) );
|
|
156 */
|
|
157 m_parent->Scroll( xv + xs * log10( xa + 1 ), yv + ys * log10( ya + 1 ) );
|
|
158
|
|
159 m_dragx = x; m_dragy = y;
|
|
160 }
|
|
161 }
|
|
162
|
3
|
163 /* right-gesture: start detect */
|
|
164 void MyStaticBitmap::OnStartRGesture( wxMouseEvent& event )
|
|
165 {
|
|
166 event.GetPosition( &cx, &cy );
|
|
167 }
|
|
168
|
|
169 /* right-gesture: judge */
|
|
170 void MyStaticBitmap::OnEndRGesture( wxMouseEvent& event )
|
|
171 {
|
|
172 int x, y;
|
|
173 event.GetPosition( &x, &y );
|
|
174
|
|
175 int dx = x - cx;
|
|
176 int dy = y - cy;
|
|
177 float rad = fabs( atan2( dy, dx ) );
|
|
178 float pi = 3.14159;
|
|
179
|
|
180 // to right
|
4
|
181 if ( rad < pi / 8 && dx > 0 ) {
|
|
182 ChangeBook( 1 );
|
3
|
183 }
|
|
184 // to left
|
4
|
185 else if ( rad > pi / 8 * 7 && rad < pi && dx < 0 ) {
|
|
186 ChangeBook( -1 );
|
3
|
187 }
|
|
188 // to up-right
|
4
|
189 else if ( rad > pi / 8 && rad < pi / 8 * 3 && dx > 0 ) {
|
5
|
190 MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN );
|
|
191 mf->Close();
|
3
|
192 }
|
4
|
193 // down
|
|
194 else if ( rad > pi / 8 * 3 && rad < pi / 8 * 5 && dy > 0 ) {
|
|
195 MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN );
|
|
196 mf->PrintImages();
|
|
197 }
|
|
198 //wxMessageBox( wxString::Format( "%d %d %f", dx, dy, rad ));
|
3
|
199 }
|
|
200
|
0
|
201 // Functions
|
4
|
202 void MyStaticBitmap::ChangeBook( int i )
|
|
203 {
|
|
204 wxNotebook* nb = (wxNotebook*)FindWindowById( ID_NBOOK );
|
|
205 int n = nb->GetSelection();
|
|
206 if ( i > 0 ) {
|
|
207 if ( n == nb->GetPageCount() - 1 ) return;
|
|
208 nb->SetSelection( ++n );
|
|
209 } else {
|
|
210 if ( n == 0 ) return;
|
|
211 nb->SetSelection( --n );
|
|
212 }
|
|
213 }
|
0
|
214
|
|
215 /********************/
|
|
216 /** Main Frame **/
|
|
217 /********************/
|
|
218 MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
|
|
219 : wxFrame( parent, id, title, pos, size, style )
|
|
220 {
|
1
|
221 CreateControls();
|
5
|
222 SetAccelerator();
|
|
223 LoadBitmaps( wxEmptyString, false );
|
3
|
224 m_timer.SetOwner( this, ID_TIMER );
|
1
|
225 }
|
|
226
|
|
227 MainFrame::~MainFrame()
|
|
228 {
|
|
229 }
|
|
230
|
|
231 // Event Table
|
|
232 BEGIN_EVENT_TABLE( MainFrame, wxFrame )
|
2
|
233 EVT_DATAVIEW_SELECTION_CHANGED( ID_LIST, MainFrame::OnItemSelected )
|
1
|
234 EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked )
|
|
235 EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged )
|
3
|
236 EVT_BUTTON( wxID_PRINT, MainFrame::OnPrint )
|
5
|
237 EVT_BUTTON( ID_PSEARCH, MainFrame::OnPasteSearch )
|
6
|
238 EVT_BUTTON( ID_PZOOM, MainFrame::OnPlusZoom )
|
|
239 EVT_BUTTON( ID_MZOOM, MainFrame::OnMinusZoom )
|
|
240 EVT_BUTTON( ID_DARK, MainFrame::OnDark )
|
5
|
241 EVT_BUTTON( wxID_HELP, MainFrame::OnHelp )
|
3
|
242 EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout )
|
|
243 EVT_CLOSE( MainFrame::OnClose )
|
|
244 EVT_IDLE( MainFrame::OnIdle )
|
|
245 EVT_TIMER( ID_TIMER, MainFrame::OnTimer )
|
1
|
246 END_EVENT_TABLE()
|
|
247
|
|
248
|
|
249 // Event Handler
|
2
|
250 void MainFrame::OnItemSelected( wxDataViewEvent& WXUNUSED(event) )
|
|
251 {
|
|
252 int r = m_dataViewListCtrl->GetSelectedRow();
|
|
253 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 );
|
3
|
254 if ( ready.IsSameAs( wxT( "OK" ), true ) ) {
|
|
255 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
256 date.Replace( wxT( "-" ), wxEmptyString, true );
|
5
|
257 LoadBitmaps( date, false );
|
3
|
258 } else {
|
5
|
259 LoadBitmaps( wxEmptyString, false );
|
2
|
260 }
|
|
261 }
|
|
262
|
1
|
263 void MainFrame::OnItemDClicked( wxDataViewEvent& WXUNUSED(event) )
|
|
264 {
|
|
265 int r = m_dataViewListCtrl->GetSelectedRow();
|
3
|
266 wxString status = m_dataViewListCtrl->GetTextValue( r, 2 );
|
|
267 if ( status.IsSameAs( wxT( "OK" ), true ) ) return;
|
|
268
|
2
|
269 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
270 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
271 GetImages( m_hhs, date );
|
5
|
272 if ( LoadBitmaps( date, true ) )
|
|
273 m_dataViewListCtrl->SetTextValue( wxT( "OK" ), r, 2 );
|
1
|
274 }
|
|
275
|
|
276 void MainFrame::OnNBookChanged( wxBookCtrlEvent& WXUNUSED(event) )
|
|
277 {
|
|
278 for ( int i = 0; i < m_notebook->GetPageCount(); i++ ) {
|
|
279 m_notebook->SetPageImage( i, 1 );
|
|
280 }
|
|
281 m_notebook->SetPageImage( m_notebook->GetSelection(), 0 );
|
|
282 }
|
|
283
|
3
|
284 void MainFrame::OnClose( wxCloseEvent& WXUNUSED(event) ) // save config
|
1
|
285 {
|
5
|
286 WriteLog( wxT( "[logout]" ) );
|
1
|
287 if ( !IsIconized() && !IsMaximized() ) {
|
|
288 wxGetApp().rect = this->GetRect();
|
|
289 }
|
|
290 Destroy();
|
|
291 }
|
|
292
|
5
|
293 void MainFrame::OnPasteSearch( wxCommandEvent& WXUNUSED(event) )
|
|
294 {
|
|
295 PasteSeaarch();
|
|
296 }
|
|
297
|
3
|
298 void MainFrame::OnPrint( wxCommandEvent& WXUNUSED(event) )
|
|
299 {
|
|
300 PrintImages();
|
|
301 }
|
|
302
|
6
|
303 void MainFrame::OnPlusZoom( wxCommandEvent& WXUNUSED(event) )
|
|
304 {
|
|
305 ChangeCZoom( 1 );
|
|
306 }
|
|
307
|
|
308 void MainFrame::OnMinusZoom( wxCommandEvent& WXUNUSED(event ) )
|
|
309 {
|
|
310 ChangeCZoom( -1 );
|
|
311 }
|
|
312
|
|
313 void MainFrame::OnDark( wxCommandEvent& WXUNUSED(event ) )
|
|
314 {
|
|
315 ChangeColor( m_staticBitmap1 );
|
|
316 ChangeColor( m_staticBitmap2 );
|
|
317 ChangeColor( m_staticBitmap3 );
|
|
318 ChangeColor( m_staticBitmap4 );
|
|
319 ChangeColor( m_staticBitmap5 );
|
|
320 m_dark = !m_dark;
|
|
321 }
|
|
322
|
5
|
323 void MainFrame::OnHelp( wxCommandEvent& WXUNUSED(event) )
|
|
324 {
|
|
325 wxString version, build;
|
|
326 version = wxString::Format( wxT( "Re:Searcher-- version %s / %s\n\n" ), RSVER, RSRELEASE );
|
|
327 build = wxString::Format( wxT( "build with %s\nrunning under %s." ), wxVERSION_STRING, wxGetOsDescription() );
|
|
328
|
|
329 wxMessageBox( version + build, wxT( "Help" ) );
|
|
330 return;
|
|
331 }
|
|
332
|
3
|
333 void MainFrame::OnLogout( wxCommandEvent& WXUNUSED(event) )
|
|
334 {
|
|
335 wxMessageBox("logout");
|
|
336 return;
|
|
337 }
|
|
338
|
|
339 void MainFrame::OnTimer( wxTimerEvent& WXUNUSED(event) )
|
|
340 {
|
5
|
341 //wxMessageBox( "timer !" );
|
3
|
342 // logout
|
|
343 }
|
|
344
|
|
345 void MainFrame::OnIdle( wxIdleEvent& event )
|
|
346 {
|
|
347 if ( !m_timer.IsRunning() ) {
|
|
348 m_timer.Start( 300 * 1000, wxTIMER_ONE_SHOT );
|
|
349 }
|
|
350 event.RequestMore();
|
|
351 event.Skip();
|
|
352 }
|
|
353
|
1
|
354 // Functions
|
|
355 void MainFrame::CreateControls( void )
|
|
356 {
|
0
|
357 this->SetIcon( wxIcon( wxT( "sample" ) ) );
|
|
358 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
5
|
359 this->SetBackgroundColour( wxColour( 30, 80, 40 ) );
|
|
360 //this->SetBackgroundColour( wxColour( 153, 153, 153 ) );
|
0
|
361
|
|
362 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL );
|
|
363
|
|
364 // Left
|
|
365 wxImageList* imgList = new wxImageList( 16, 16, false, 1 );
|
|
366 wxBitmap bmp( wxT( "image/blue.png" ), wxBITMAP_TYPE_PNG );
|
|
367 imgList->Add( bmp, wxNullBitmap );
|
|
368 bmp.LoadFile( wxT( "image/water.png" ), wxBITMAP_TYPE_PNG );
|
|
369 imgList->Add( bmp, wxNullBitmap );
|
|
370
|
|
371 m_notebook = new wxNotebook( this, ID_NBOOK, wxDefaultPosition, wxDefaultSize, 0 );
|
|
372 m_notebook->SetImageList( imgList );
|
|
373
|
|
374 m_scrolledWindow1 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
375 m_scrolledWindow1->SetScrollRate( 5, 5 );
|
|
376 m_notebook->AddPage( m_scrolledWindow1, wxT( "Image-01" ), false, 0 );
|
|
377
|
|
378 m_scrolledWindow2 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
379 m_scrolledWindow2->SetScrollRate( 5, 5 );
|
|
380 m_notebook->AddPage( m_scrolledWindow2, wxT( "Image-02" ), false, 0 );
|
|
381
|
|
382 m_scrolledWindow3 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
383 m_scrolledWindow3->SetScrollRate( 5, 5 );
|
|
384 m_notebook->AddPage( m_scrolledWindow3, wxT( "Image-03" ), false, 0 );
|
|
385
|
|
386 m_scrolledWindow4 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
387 m_scrolledWindow4->SetScrollRate( 5, 5 );
|
|
388 m_notebook->AddPage( m_scrolledWindow4, wxT( "Image-04" ), false, 0 );
|
|
389
|
|
390 m_scrolledWindow5 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
391 m_scrolledWindow5->SetScrollRate( 5, 5 );
|
|
392 m_notebook->AddPage( m_scrolledWindow5, wxT( "Image-05" ), false, 0 );
|
|
393
|
|
394 m_scrolledWindow6 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
395 m_scrolledWindow6->SetScrollRate( 5, 5 );
|
|
396 m_notebook->AddPage( m_scrolledWindow6, wxT( "Image-06" ), false, 0 );
|
|
397
|
|
398 bSizerTop->Add( m_notebook, 1, wxEXPAND|wxALL, 5 );
|
|
399
|
|
400 // Right
|
|
401 wxBoxSizer* bSizerRight = new wxBoxSizer( wxVERTICAL );
|
|
402
|
|
403 m_searchCtrl = new MySearchCtrl( this, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxSize( -1, 24 ), wxTE_PROCESS_ENTER );
|
|
404 bSizerRight->Add( m_searchCtrl, 0, wxALL, 5 );
|
|
405 m_searchCtrl->SetFocus();
|
|
406
|
5
|
407 m_textCtrlName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), wxTE_READONLY );
|
0
|
408 m_textCtrlName->SetBackgroundColour( wxColour( 180, 210, 240 ) );
|
|
409 bSizerRight->Add( m_textCtrlName, 0, wxALL, 5 );
|
|
410
|
5
|
411 m_textCtrlAddr = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 160, -1 ), wxTE_READONLY );
|
0
|
412 m_textCtrlAddr->SetBackgroundColour( wxColour( 180, 210, 240 ) );
|
|
413 bSizerRight->Add( m_textCtrlAddr, 0, wxALL|wxEXPAND, 5 );
|
|
414
|
|
415 m_dataViewListCtrl = new wxDataViewListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE );
|
2
|
416 m_dataViewListColumnNo = m_dataViewListCtrl->AppendTextColumn( wxT( "No" ), wxDATAVIEW_CELL_INERT, 30, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
417 m_dataViewListColumnDate = m_dataViewListCtrl->AppendTextColumn( wxT( "Date" ), wxDATAVIEW_CELL_INERT, 80, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
418 m_dataViewListColumnDate = m_dataViewListCtrl->AppendTextColumn( wxT( "Ready" ), wxDATAVIEW_CELL_INERT, 60, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
0
|
419
|
|
420 bSizerRight->Add( m_dataViewListCtrl, 1, wxALL|wxEXPAND, 5 );
|
|
421
|
|
422 m_textCtrlLog = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
423 bSizerRight->Add( m_textCtrlLog, 1, wxALL|wxEXPAND, 5 );
|
|
424
|
2
|
425 m_slider = new wxSlider( this, ID_SLDR, 1, 1, 5, wxDefaultPosition, wxSize( -1, 200 ), wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LABELS|wxSL_VERTICAL );
|
0
|
426 bSizerRight->Add( m_slider, 0, wxALL, 5 );
|
|
427
|
5
|
428 m_buttonPsearch = new wxButton( this, ID_PSEARCH, wxT( "Paste-Search" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
429 bSizerRight->Add( m_buttonPsearch, 0, wxALL, 5 );
|
|
430
|
3
|
431 m_buttonPrint = new wxButton( this, wxID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 );
|
0
|
432 bSizerRight->Add( m_buttonPrint, 0, wxALL, 5 );
|
|
433
|
3
|
434 m_buttonLogout = new wxButton( this, ID_LOGOUT, wxT( "Logout" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
435 bSizerRight->Add( m_buttonLogout, 0, wxALL, 5 );
|
|
436
|
6
|
437 // invisible buttons for shortcut-key
|
|
438 m_buttonPzoom = new wxButton( this, ID_PZOOM, wxT( "ZOOM" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
439 m_buttonPzoom->Hide();
|
|
440 m_buttonMzoom = new wxButton( this, ID_MZOOM, wxT( "zoom" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
441 m_buttonMzoom->Hide();
|
|
442 m_buttonDark = new wxButton( this, ID_DARK, wxT( "Dark" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
443 m_buttonDark->Hide();
|
|
444 m_buttonHelp = new wxButton( this, wxID_HELP, wxT( "Help" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
445 m_buttonHelp->Hide();
|
|
446
|
0
|
447 bSizerTop->Add( bSizerRight, 0, wxEXPAND, 5 );
|
|
448
|
|
449 this->SetSizer( bSizerTop );
|
|
450 this->Layout();
|
|
451
|
|
452 //this->Centre( wxBOTH );
|
|
453
|
|
454 m_staticBitmap1 = new MyStaticBitmap( m_scrolledWindow1, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
455 m_staticBitmap2 = new MyStaticBitmap( m_scrolledWindow2, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
456 m_staticBitmap3 = new MyStaticBitmap( m_scrolledWindow3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
457 m_staticBitmap4 = new MyStaticBitmap( m_scrolledWindow4, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
458 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
459 }
|
|
460
|
5
|
461 void MainFrame::SetAccelerator( void )
|
|
462 {
|
6
|
463 wxAcceleratorEntry entries[5];
|
|
464 entries[0].Set( wxACCEL_CTRL, (int)'P', wxID_PRINT );
|
|
465 entries[1].Set( wxACCEL_NORMAL, WXK_F1, wxID_HELP );
|
|
466 entries[2].Set( wxACCEL_NORMAL, (int)'Z', ID_PZOOM );
|
|
467 entries[3].Set( wxACCEL_NORMAL, (int)'X', ID_MZOOM );
|
|
468 entries[4].Set( wxACCEL_NORMAL, (int)'D', ID_DARK );
|
|
469 wxAcceleratorTable accel( 5, entries );
|
5
|
470 SetAcceleratorTable( accel );
|
|
471 }
|
|
472
|
0
|
473 void MainFrame::Cmd( wxString cmd )
|
|
474 {
|
|
475 m_dataViewListCtrl->DeleteAllItems();
|
6
|
476 m_textCtrlName->SetValue( wxEmptyString );
|
|
477 m_textCtrlAddr->SetValue( wxEmptyString );
|
5
|
478 LoadBitmaps( wxEmptyString, false );
|
6
|
479
|
5
|
480 wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) );
|
0
|
481
|
2
|
482 if ( cmd.IsSameAs( wxT( "q" ), true ) || cmd.IsSameAs( wxT( "9" ), true ) ) {
|
0
|
483 Close();
|
2
|
484 return;
|
0
|
485 }
|
|
486
|
2
|
487 if ( cmd.IsSameAs( wxT( "c" ), true ) || cmd.IsSameAs( wxT( "cmd" ), true ) ) {
|
|
488 return;
|
|
489 }
|
|
490
|
3
|
491 if ( cmd.IsSameAs( wxT( "k" ), true ) ) {
|
|
492 // hiragana kensaku
|
|
493 return;
|
|
494 }
|
|
495
|
|
496 if ( cmd.IsSameAs( wxT( "." ), false ) ) {
|
0
|
497 wxString appdir = wxGetCwd();
|
|
498 wxString execmd = wxT( "explorer " ) + appdir;
|
|
499 wxExecute( execmd );
|
|
500 return;
|
|
501 }
|
|
502
|
3
|
503 if ( cmd.IsSameAs( wxT( "*" ), false ) ) {
|
5
|
504 PasteSeaarch();
|
|
505 return;
|
3
|
506 }
|
|
507
|
|
508 if ( cmd.IsSameAs( wxT( "+" ), false ) ) {
|
6
|
509 //PrintImages();
|
3
|
510 return;
|
|
511 }
|
|
512
|
0
|
513 if ( reHhs.Matches( cmd ) ) {
|
2
|
514 m_hhs = m_searchCtrl->GetValue();
|
|
515 Search();
|
|
516 return;
|
|
517 }
|
0
|
518
|
3
|
519 wxMessageBox( wxT( "Bad Input !!" ) );
|
0
|
520 }
|
|
521
|
6
|
522 bool MainFrame::LoadBitmap( wxScrolledWindow* sc, MyStaticBitmap* sb, wxString file )
|
0
|
523 {
|
5
|
524 sb->SetBitmap( wxNullBitmap );
|
6
|
525 sb->zoom = 0;
|
5
|
526 sc->Scroll( 0, 0 );
|
|
527
|
|
528 bool ok = true;
|
2
|
529 if ( startup ) {
|
5
|
530 file = wxT( "image/hello.jpg" );
|
2
|
531 startup = false;
|
|
532 }
|
5
|
533 if ( !wxFileExists( file ) ) {
|
|
534 file = wxT( "image/testpattern.jpg" );
|
|
535 ok = false;
|
|
536 }
|
0
|
537 wxBitmap bmp( file, wxBITMAP_TYPE_JPEG );
|
6
|
538 sb->SetOrigImage( bmp );
|
0
|
539 int width = bmp.GetWidth();
|
|
540 int height = bmp.GetHeight();
|
|
541 wxImage img = bmp.ConvertToImage();
|
|
542
|
|
543 int ww, wh;
|
1
|
544 sc->GetSize( &ww, &wh );
|
0
|
545
|
3
|
546 float w = ww - 30;
|
0
|
547 float h = w * height / width;
|
|
548 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
|
5
|
549 sc->SetScrollbars( 10, 10, (int)w / 10, (int)h / 10 );
|
0
|
550
|
5
|
551 return ok;
|
0
|
552 }
|
|
553
|
5
|
554 bool MainFrame::LoadBitmaps( wxString date, bool reload )
|
0
|
555 {
|
5
|
556 bool ok;
|
|
557 ok = LoadBitmap( m_scrolledWindow1, m_staticBitmap1, wxString::Format( wxT( ".cache/%08s_1" ), date ) );
|
|
558 ok = LoadBitmap( m_scrolledWindow2, m_staticBitmap2, wxString::Format( wxT( ".cache/%08s_2" ), date ) );
|
|
559 ok = LoadBitmap( m_scrolledWindow3, m_staticBitmap3, wxString::Format( wxT( ".cache/%08s_3" ), date ) );
|
|
560 ok = LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( wxT( ".cache/%08s_4" ), date ) );
|
|
561 ok = LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( wxT( ".cache/%08s_5" ), date ) );
|
|
562
|
|
563 if ( !ok && reload ) {
|
|
564 wxSleep( 5 );
|
|
565 LoadBitmaps( date, false );
|
|
566 }
|
|
567 return ok;
|
2
|
568 }
|
|
569
|
6
|
570 void MainFrame::ChangeCZoom( int z )
|
|
571 {
|
|
572 int n = m_notebook->GetSelection();
|
|
573 if ( n == 0 ) ChangeZoom( m_scrolledWindow1, m_staticBitmap1, z );
|
|
574 if ( n == 1 ) ChangeZoom( m_scrolledWindow2, m_staticBitmap2, z );
|
|
575 if ( n == 2 ) ChangeZoom( m_scrolledWindow3, m_staticBitmap3, z );
|
|
576 if ( n == 3 ) ChangeZoom( m_scrolledWindow4, m_staticBitmap4, z );
|
|
577 if ( n == 4 ) ChangeZoom( m_scrolledWindow5, m_staticBitmap5, z );
|
|
578 }
|
|
579
|
|
580 void MainFrame::ChangeZoom( wxScrolledWindow* sc, MyStaticBitmap* sb, int z )
|
|
581 {
|
|
582 if ( z > 0 ) sb->zoom++;
|
|
583 else sb->zoom--;
|
|
584
|
|
585 float zz = pow( 1.1, sb->zoom );
|
|
586
|
|
587 int x, y;
|
|
588 sc->GetViewStart( &x, &y );
|
|
589 sc->Scroll( 0, 0 );
|
|
590 wxBitmap bmp = sb->GetOrigImage();
|
|
591
|
|
592 int width = bmp.GetWidth();
|
|
593 int height = bmp.GetHeight();
|
|
594 wxImage img = bmp.ConvertToImage();
|
|
595
|
|
596 int ww, wh;
|
|
597 sc->GetSize( &ww, &wh );
|
|
598
|
|
599 float w = ww * zz - 30;
|
|
600 float h = w * height / width;
|
|
601 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
|
|
602 sc->SetScrollbars( 10, 10, (int)w / 10, (int)h / 10 );
|
|
603 sc->Scroll( x, y );
|
|
604
|
|
605 if ( m_dark ) ChangeColor( sb );
|
|
606 }
|
|
607
|
|
608 void MainFrame::ChangeColor( MyStaticBitmap* sb )
|
|
609 {
|
|
610 wxBitmap bmp = sb->GetBitmap();
|
|
611 wxImage img = bmp.ConvertToImage();
|
|
612 unsigned char r, g, b;
|
|
613 for ( int x = 0; x < img.GetWidth(); x++ ) {
|
|
614 for ( int y = 0; y < img.GetHeight(); y++ ) {
|
|
615 r = 255 - img.GetRed( x, y );
|
|
616 g = 255 - img.GetGreen( x, y );
|
|
617 b = 255 - img.GetBlue( x, y );
|
|
618 img.SetRGB( x, y, r, g, b );
|
|
619 }
|
|
620 }
|
|
621 sb->SetBitmap( wxBitmap( img ) );
|
|
622 }
|
|
623
|
2
|
624 void MainFrame::GetImages( wxString hhs, wxString date )
|
|
625 {
|
|
626 wxArrayString args; // http get
|
|
627 args.Add( wxT( "client.exe" ) );
|
|
628 args.Add( m_server );
|
|
629 args.Add( hhs );
|
|
630 args.Add( date );
|
|
631
|
3
|
632 int estimate = 5;
|
|
633 wxProgressDialog pd( wxT( "Connecting Server" ), wxT( "Start..." ), estimate, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
|
|
634 pd.SetSize( wxSize( 320, 140 ) );
|
|
635
|
2
|
636 wxExecute( wxJoin( args, ' ', '\\' ), wxEXEC_ASYNC|wxEXEC_HIDE_CONSOLE );
|
3
|
637 for ( int i = 0; i < estimate; i++ ) {
|
|
638 wxSleep( 1 );
|
|
639 pd.Update( i, wxT( "Now Loading..." ) );
|
|
640 }
|
0
|
641 }
|
|
642
|
2
|
643 void MainFrame::Search( void )
|
0
|
644 {
|
5
|
645 // hhs info
|
|
646 if ( hhash.count( m_hhs ) ) {
|
|
647 m_textCtrlName->SetValue( hhash[ m_hhs ]->name );
|
|
648 m_textCtrlAddr->SetValue( hhash[ m_hhs ]->addr );
|
|
649 }
|
|
650
|
|
651 // index
|
2
|
652 wxString date;
|
|
653 int match_cnt = 0;
|
|
654 for ( int i = 0; i < m_index.GetCount(); i++ ) {
|
|
655 if ( m_index[i].StartsWith( m_hhs, &date ) ) {
|
|
656 wxVector<wxVariant> data;
|
|
657 data.push_back( wxString::Format( wxT( "%02d" ), ++match_cnt ) );
|
|
658 date = date.Mid( 1, 4 ) + wxT( "-" ) + date.Mid( 5, 2 ) + wxT( "-" ) + date.Mid( 7, 2 );
|
|
659 data.push_back( date );
|
|
660 data.push_back( wxEmptyString );
|
|
661 m_dataViewListCtrl->AppendItem( data );
|
|
662 data.clear();
|
|
663 }
|
|
664 }
|
5
|
665
|
|
666 if ( match_cnt == 0 ) {
|
|
667 wxMessageBox( wxT( "Not Matched !!" ) );
|
|
668 } else {
|
|
669 wxString date = m_dataViewListCtrl->GetTextValue( 0, 1 );
|
|
670 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
671 GetImages( m_hhs, date );
|
|
672 if ( LoadBitmaps( date, true ) ) {
|
|
673 m_dataViewListCtrl->SetTextValue( wxT( "OK" ), 0, 2 );
|
|
674 m_dataViewListCtrl->SelectRow( 0 );
|
|
675 }
|
|
676 }
|
|
677
|
|
678 WriteLog( wxT( "[search] " ) + m_hhs );
|
2
|
679 }
|
|
680
|
3
|
681 void MainFrame::LoadDB( void )
|
2
|
682 {
|
5
|
683 wxProgressDialog pd( wxT( "Load Data" ), wxT( "Now loading..." ), 100, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
|
|
684 pd.SetSize( wxSize( 320, 140 ) );
|
|
685
|
|
686 // index
|
2
|
687 wxTextFile file;
|
|
688 file.Open( wxT( "index.db" ) );
|
|
689 for ( int i = 0; i < file.GetLineCount(); i++ )
|
|
690 m_index.Add( file.GetLine( i ) );
|
|
691 file.Close();
|
|
692 m_index.Sort( true );
|
3
|
693
|
5
|
694 // decrypto
|
|
695 wxString key = wxT( "12345678900123456789abcdefabcdef" );
|
|
696 wxArrayString args;
|
|
697 args.Add( wxT( "crypto.exe" ) );
|
|
698 args.Add( wxT( "-d" ) );
|
|
699 args.Add( wxT( "hhs.db" ) );
|
|
700 args.Add( wxT( "-k" ) );
|
|
701 args.Add( key );
|
|
702
|
|
703 wxArrayString output, errors;
|
|
704 wxExecute( wxJoin( args, ' ', '\\' ), output, errors );
|
|
705
|
|
706 for ( int i = 0; i < 100; i++ ) {
|
|
707 wxMilliSleep( 2 );
|
|
708 pd.Update( i, wxString::Format( wxT( "Now loding ... ( %0.1f %% )" ), (float)i ) );
|
|
709 }
|
|
710 if ( errors.GetCount() > 0 ) {
|
|
711 wxMessageBox( errors[0] );
|
|
712 return;
|
|
713 }
|
|
714 for ( int i = 0; i < output.GetCount(); i++ ) {
|
|
715 wxArrayString buf = wxSplit( output[i], ',', '\\' );
|
|
716 hhash[ buf[0] ] = new HhsClass( buf ); // no, birth, name, kana, addr, sex
|
3
|
717 }
|
5
|
718 }
|
|
719
|
|
720 void MainFrame::PasteSeaarch( void )
|
|
721 {
|
|
722 wxString s;
|
|
723 if ( wxTheClipboard->Open() ) {
|
|
724 if ( wxTheClipboard->IsSupported( wxDF_TEXT ) ) {
|
|
725 wxTextDataObject data;
|
|
726 wxTheClipboard->GetData( data );
|
|
727 s = data.GetText();
|
|
728 }
|
|
729 wxTheClipboard->Close();
|
|
730 }
|
|
731
|
|
732 s.Replace( wxT(" "), wxT(""), true );
|
|
733 wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) );
|
|
734 if ( reHhs.Matches( s ) ) {
|
|
735 m_searchCtrl->SetValue( s );
|
|
736 m_hhs = m_searchCtrl->GetValue();
|
|
737 Search();
|
|
738 return;
|
|
739 }
|
|
740 wxMessageBox( wxT( "Bad Input !!" ) );
|
3
|
741 }
|
|
742
|
|
743 void MainFrame::PrintImages( void )
|
|
744 {
|
|
745 int r = m_dataViewListCtrl->GetSelectedRow();
|
4
|
746 if ( r == wxNOT_FOUND ) {
|
|
747 wxMessageBox( wxT( "Not Ready for Print !!" ) );
|
|
748 return;
|
|
749 }
|
3
|
750 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 );
|
|
751
|
|
752 if ( !ready.IsSameAs( wxT( "OK" ), true ) ) {
|
|
753 wxMessageBox( wxT( "Not Ready for Print !!" ) );
|
|
754 return;
|
|
755 }
|
|
756
|
|
757 wxDateTime now = wxDateTime::Now();
|
|
758 wxString nowstr = now.Format( "%Y/%m/%d %H:%M", wxDateTime::GMT9 ).c_str();
|
|
759
|
|
760 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
761 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
762
|
|
763 wxString html, file;
|
|
764 html = wxT( "<html><body>\n" );
|
|
765
|
|
766 for ( int i = 1; i < 6; i++ ) {
|
|
767 file = wxString::Format( wxT( ".cache/%08s_%d" ), date, i );
|
|
768 html = html + wxT( "<img src=\"" ) + file + wxT( "\" width=\"750\" height=\"1060\"/>\n" );
|
|
769 html = html + wxT( "<div align=right><font size=-2><u>" ) + m_hhs + wxT( "@" ) + m_user + wxT( "#" ) + nowstr + wxT( "</u></font></div>\n\n" );
|
|
770 }
|
|
771 html = html + wxT( "</body></html>" );
|
|
772
|
|
773 // start printing
|
|
774 wxHtmlPrintout hpout( wxT( "Re:Searcher" ) );
|
|
775 hpout.SetMargins( 0, 0, 0, 0, 0 );
|
|
776 wxPrintDialogData pd;
|
|
777 wxPrinter p( &pd );
|
|
778
|
|
779 hpout.SetHtmlText( html, wxEmptyString, false );
|
|
780 p.Print( NULL, &hpout, true );
|
5
|
781
|
|
782 WriteLog( wxT( "[print]" ) );
|
2
|
783 }
|
|
784
|
5
|
785 void MainFrame::WriteLog( wxString msg )
|
|
786 {
|
|
787 wxDateTime now = wxDateTime::Now();
|
|
788 wxString file = wxGetCwd() + wxFILE_SEP_PATH + wxT( "log" ) + wxFILE_SEP_PATH + now.Format( wxT( "%Y%m%d" ) ) + wxT( ".log" );
|
|
789
|
|
790 wxTextFile logfile;
|
|
791 if ( !wxFileExists( file ) ) logfile.Create( file );
|
|
792
|
|
793 logfile.Open( file );
|
|
794 logfile.AddLine( now.Format( wxT("%Y-%m-%d %H:%M:%S ") ) + msg );
|
|
795 logfile.Write();
|
|
796 logfile.Close();
|
|
797 }
|
|
798
|
1
|
799 void MainFrame::InDevelop( bool flag )
|
0
|
800 {
|
1
|
801 if ( !flag ) return;
|
0
|
802
|
3
|
803 bool lo = false;
|
|
804 m_buttonLogout->Enable( lo );
|
|
805 m_buttonLogout->Show( lo );
|
0
|
806
|
3
|
807 bool sl = false;
|
|
808 m_slider->Enable( sl );
|
|
809 m_slider->Show( sl );
|
0
|
810
|
4
|
811 return;
|
0
|
812 }
|
|
813
|