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