0
|
1 // Filename : rsearcher.cpp
|
4
|
2 // Last Change: 2018-10-12 ‹à 16:40:12.
|
0
|
3 //
|
|
4
|
2
|
5 #include <wx/arrstr.h>
|
3
|
6 #include <wx/html/htmprint.h>
|
4
|
7 #include "id.h"
|
0
|
8 #include "rsearcher.h"
|
|
9 #include "main.h"
|
|
10
|
|
11 /********************/
|
|
12 /** MySearchCtrl **/
|
|
13 /********************/
|
|
14 MySearchCtrl::MySearchCtrl( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style )
|
|
15 : wxSearchCtrl( parent, id, value, pos, size, style )
|
|
16 {
|
|
17 m_parent = parent;
|
|
18 SetMaxLength( 10 );
|
|
19 #ifndef __WXMAC__
|
|
20 ShowSearchButton( true );
|
|
21 #endif
|
|
22 ShowCancelButton( false );
|
|
23
|
|
24 wxFont font( 12, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD );
|
|
25 SetFont( font );
|
|
26 }
|
|
27
|
|
28 MySearchCtrl::~MySearchCtrl()
|
|
29 {
|
|
30 }
|
|
31
|
|
32 // Event Table
|
|
33 BEGIN_EVENT_TABLE( MySearchCtrl, wxSearchCtrl )
|
|
34 EVT_CHAR( MySearchCtrl::OnKey )
|
|
35 END_EVENT_TABLE()
|
|
36
|
|
37 // Event Handlers & Functions
|
|
38 void MySearchCtrl::OnKey( wxKeyEvent& event )
|
|
39 {
|
|
40 int kc = event.GetKeyCode();
|
|
41
|
|
42 if ( kc == 13 ) { // Enter
|
2
|
43 SelectAll();
|
0
|
44
|
|
45 MainFrame* f = (MainFrame*)FindWindowById( ID_MAIN );
|
2
|
46 f->Cmd( GetValue() );
|
0
|
47
|
|
48 event.Skip();
|
|
49 return;
|
|
50 }
|
|
51
|
|
52 if ( kc == 45 ) { // Num-Key '-' as Backspace
|
|
53 wxString t = GetStringSelection();
|
|
54 if ( t.IsEmpty() ) {
|
|
55 long p = GetInsertionPoint();
|
|
56 if ( p > 0 ) Remove( p - 1, p );
|
|
57 }
|
|
58 else {
|
|
59 Cut();
|
|
60 }
|
|
61 return;
|
|
62 }
|
|
63
|
|
64 if ( kc == WXK_ESCAPE ) { // clear by ESC
|
|
65 this->Clear();
|
|
66 return;
|
|
67 }
|
|
68
|
|
69 event.Skip();
|
|
70 }
|
|
71
|
|
72 /********************/
|
|
73 /** MyStaticBitmap **/
|
|
74 /********************/
|
|
75 MyStaticBitmap::MyStaticBitmap( wxScrolledWindow *parent, wxWindowID id, const wxBitmap &label, const wxPoint &pos, const wxSize &size, long style, const wxString &name )
|
|
76 : wxStaticBitmap( parent, id, label, pos, size, style, name )
|
|
77 {
|
|
78 m_parent = parent;
|
3
|
79 Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OnLeftDown ), NULL, this );
|
|
80 Connect( wxEVT_LEFT_UP, wxMouseEventHandler( OnLeftUp ), NULL, this );
|
|
81 Connect( wxEVT_MOTION, wxMouseEventHandler( OnMotion ), NULL, this );
|
|
82 Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OnWheel ), NULL, this );
|
|
83
|
|
84 Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OnStartRGesture ), NULL, this );
|
|
85 Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( OnEndRGesture ), NULL, this );
|
0
|
86 }
|
|
87
|
|
88 MyStaticBitmap::~MyStaticBitmap()
|
|
89 {
|
3
|
90 Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( OnLeftDown ), NULL, this );
|
|
91 Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( OnLeftUp ), NULL, this );
|
|
92 Disconnect( wxEVT_MOTION, wxMouseEventHandler( OnMotion ), NULL, this );
|
|
93 Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OnWheel ), NULL, this );
|
|
94
|
|
95 Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OnStartRGesture ), NULL, this );
|
|
96 Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( OnEndRGesture ), NULL, this );
|
0
|
97 }
|
|
98
|
|
99 // Event Handlers
|
|
100 void MyStaticBitmap::OnWheel( wxMouseEvent& event )
|
|
101 {
|
|
102 if ( event.ControlDown() ) {
|
|
103 if ( event.GetWheelRotation() < 0 ) {
|
|
104 if ( m_zoom < 4 ) m_zoom++;
|
|
105 }
|
|
106 else {
|
|
107 if ( m_zoom > 0 ) m_zoom--;
|
|
108 }
|
|
109 SetBitmap( m_bmp[ m_zoom ] );
|
|
110 m_parent->SetScrollbars( 10, 10, m_bmp[ m_zoom ].GetWidth() / 10, m_bmp[ m_zoom ].GetHeight() / 10 );
|
|
111 return;
|
|
112 }
|
|
113 event.Skip();
|
|
114 }
|
|
115
|
|
116 void MyStaticBitmap::OnLeftDown( wxMouseEvent& event )
|
|
117 {
|
|
118 event.GetPosition( &m_dragx, &m_dragy );
|
|
119 SetCursor( wxCursor( wxCURSOR_SIZING ) );
|
|
120 }
|
|
121
|
|
122 void MyStaticBitmap::OnLeftUp( wxMouseEvent& WXUNUSED(event) )
|
|
123 {
|
|
124 SetCursor( wxCursor( wxCURSOR_ARROW ) );
|
|
125 }
|
|
126
|
|
127 void MyStaticBitmap::OnMotion( wxMouseEvent& event )
|
|
128 {
|
|
129 if ( event.Dragging() ) {
|
|
130 int xv, yv, x, y;
|
|
131 m_parent->GetViewStart( &xv, &yv );
|
|
132
|
|
133 event.GetPosition( &x, &y );
|
|
134
|
|
135 int xa = abs( x - m_dragx );
|
|
136 int ya = abs( y - m_dragy );
|
|
137 int xs = x - m_dragx < 0 ? -1 : 1;
|
|
138 int ys = y - m_dragy < 0 ? -1 : 1;
|
|
139
|
|
140 /* handai dakedo sumu-zu
|
|
141 m_parent->Scroll( xv + xs * log10( xa + 1 ), yv + ys * log10( ya + 1 ) );
|
|
142 */
|
|
143 m_parent->Scroll( xv + xs * log10( xa + 1 ), yv + ys * log10( ya + 1 ) );
|
|
144
|
|
145 m_dragx = x; m_dragy = y;
|
|
146 }
|
|
147 }
|
|
148
|
3
|
149 /* right-gesture: start detect */
|
|
150 void MyStaticBitmap::OnStartRGesture( wxMouseEvent& event )
|
|
151 {
|
|
152 event.GetPosition( &cx, &cy );
|
|
153 }
|
|
154
|
|
155 /* right-gesture: judge */
|
|
156 void MyStaticBitmap::OnEndRGesture( wxMouseEvent& event )
|
|
157 {
|
|
158 int x, y;
|
|
159 event.GetPosition( &x, &y );
|
|
160
|
|
161 int dx = x - cx;
|
|
162 int dy = y - cy;
|
|
163 float rad = fabs( atan2( dy, dx ) );
|
|
164 float pi = 3.14159;
|
|
165
|
|
166 // to right
|
4
|
167 if ( rad < pi / 8 && dx > 0 ) {
|
|
168 ChangeBook( 1 );
|
3
|
169 }
|
|
170 // to left
|
4
|
171 else if ( rad > pi / 8 * 7 && rad < pi && dx < 0 ) {
|
|
172 ChangeBook( -1 );
|
3
|
173 }
|
|
174 // to up-right
|
4
|
175 else if ( rad > pi / 8 && rad < pi / 8 * 3 && dx > 0 ) {
|
3
|
176 }
|
4
|
177 // down
|
|
178 else if ( rad > pi / 8 * 3 && rad < pi / 8 * 5 && dy > 0 ) {
|
|
179 MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN );
|
|
180 mf->PrintImages();
|
|
181 }
|
|
182 //wxMessageBox( wxString::Format( "%d %d %f", dx, dy, rad ));
|
3
|
183 }
|
|
184
|
0
|
185 // Functions
|
4
|
186 void MyStaticBitmap::ChangeBook( int i )
|
|
187 {
|
|
188 wxNotebook* nb = (wxNotebook*)FindWindowById( ID_NBOOK );
|
|
189 int n = nb->GetSelection();
|
|
190 if ( i > 0 ) {
|
|
191 if ( n == nb->GetPageCount() - 1 ) return;
|
|
192 nb->SetSelection( ++n );
|
|
193 } else {
|
|
194 if ( n == 0 ) return;
|
|
195 nb->SetSelection( --n );
|
|
196 }
|
|
197 }
|
0
|
198
|
|
199 /********************/
|
|
200 /** Main Frame **/
|
|
201 /********************/
|
|
202 MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
|
|
203 : wxFrame( parent, id, title, pos, size, style )
|
|
204 {
|
1
|
205 CreateControls();
|
3
|
206 LoadDB();
|
|
207 LoadBitmaps( wxEmptyString );
|
|
208 m_timer.SetOwner( this, ID_TIMER );
|
1
|
209 }
|
|
210
|
|
211 MainFrame::~MainFrame()
|
|
212 {
|
2
|
213 RemoveFile( wxT( "auth.db" ) );
|
|
214 RemoveFile( wxT( "hhs.db" ) );
|
|
215 RemoveFile( wxT( ".cache/*" ) );
|
1
|
216 }
|
|
217
|
|
218 // Event Table
|
|
219 BEGIN_EVENT_TABLE( MainFrame, wxFrame )
|
2
|
220 EVT_DATAVIEW_SELECTION_CHANGED( ID_LIST, MainFrame::OnItemSelected )
|
1
|
221 EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked )
|
|
222 EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged )
|
3
|
223 EVT_BUTTON( wxID_PRINT, MainFrame::OnPrint )
|
|
224 EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout )
|
1
|
225 EVT_BUTTON( ID_TEST, MainFrame::OnTestButton )
|
3
|
226 EVT_CLOSE( MainFrame::OnClose )
|
|
227 EVT_IDLE( MainFrame::OnIdle )
|
|
228 EVT_TIMER( ID_TIMER, MainFrame::OnTimer )
|
1
|
229 END_EVENT_TABLE()
|
|
230
|
|
231
|
|
232 // Event Handler
|
2
|
233 void MainFrame::OnItemSelected( wxDataViewEvent& WXUNUSED(event) )
|
|
234 {
|
|
235 int r = m_dataViewListCtrl->GetSelectedRow();
|
|
236 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 );
|
3
|
237 if ( ready.IsSameAs( wxT( "OK" ), true ) ) {
|
|
238 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
239 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
240 LoadBitmaps( date );
|
|
241 } else {
|
|
242 LoadBitmaps( wxEmptyString );
|
2
|
243 }
|
|
244 }
|
|
245
|
1
|
246 void MainFrame::OnItemDClicked( wxDataViewEvent& WXUNUSED(event) )
|
|
247 {
|
|
248 int r = m_dataViewListCtrl->GetSelectedRow();
|
3
|
249 wxString status = m_dataViewListCtrl->GetTextValue( r, 2 );
|
|
250 if ( status.IsSameAs( wxT( "OK" ), true ) ) return;
|
|
251
|
2
|
252 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
253 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
254 GetImages( m_hhs, date );
|
3
|
255 LoadBitmaps( date );
|
|
256
|
|
257 m_dataViewListCtrl->SetTextValue( wxT( "OK" ), r, 2 );
|
1
|
258 }
|
|
259
|
|
260 void MainFrame::OnNBookChanged( wxBookCtrlEvent& WXUNUSED(event) )
|
|
261 {
|
|
262 for ( int i = 0; i < m_notebook->GetPageCount(); i++ ) {
|
|
263 m_notebook->SetPageImage( i, 1 );
|
|
264 }
|
|
265 m_notebook->SetPageImage( m_notebook->GetSelection(), 0 );
|
|
266 }
|
|
267
|
3
|
268 void MainFrame::OnClose( wxCloseEvent& WXUNUSED(event) ) // save config
|
1
|
269 {
|
|
270 if ( !IsIconized() && !IsMaximized() ) {
|
|
271 wxGetApp().rect = this->GetRect();
|
|
272 }
|
|
273 Destroy();
|
|
274 }
|
|
275
|
3
|
276 void MainFrame::OnPrint( wxCommandEvent& WXUNUSED(event) )
|
|
277 {
|
|
278 PrintImages();
|
|
279 }
|
|
280
|
|
281 void MainFrame::OnLogout( wxCommandEvent& WXUNUSED(event) )
|
|
282 {
|
|
283 wxMessageBox("logout");
|
|
284 return;
|
|
285 }
|
|
286
|
1
|
287 void MainFrame::OnTestButton( wxCommandEvent& WXUNUSED(event) )
|
|
288 {
|
2
|
289 return;
|
1
|
290 }
|
|
291
|
3
|
292
|
|
293 void MainFrame::OnTimer( wxTimerEvent& WXUNUSED(event) )
|
|
294 {
|
|
295 wxMessageBox( "timer !" );
|
|
296 // logout
|
|
297 }
|
|
298
|
|
299 void MainFrame::OnIdle( wxIdleEvent& event )
|
|
300 {
|
|
301 if ( !m_timer.IsRunning() ) {
|
|
302 m_timer.Start( 300 * 1000, wxTIMER_ONE_SHOT );
|
|
303 }
|
|
304 event.RequestMore();
|
|
305 event.Skip();
|
|
306 }
|
|
307
|
1
|
308 // Functions
|
|
309 void MainFrame::CreateControls( void )
|
|
310 {
|
0
|
311 this->SetIcon( wxIcon( wxT( "sample" ) ) );
|
|
312 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
|
313 //this->SetBackgroundColour( wxColour( 0, 150, 230 ) );
|
2
|
314 this->SetBackgroundColour( wxColour( 153, 153, 153 ) );
|
0
|
315
|
|
316 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL );
|
|
317
|
|
318 // Left
|
|
319 wxImageList* imgList = new wxImageList( 16, 16, false, 1 );
|
|
320 wxBitmap bmp( wxT( "image/blue.png" ), wxBITMAP_TYPE_PNG );
|
|
321 imgList->Add( bmp, wxNullBitmap );
|
|
322 bmp.LoadFile( wxT( "image/water.png" ), wxBITMAP_TYPE_PNG );
|
|
323 imgList->Add( bmp, wxNullBitmap );
|
|
324
|
|
325 m_notebook = new wxNotebook( this, ID_NBOOK, wxDefaultPosition, wxDefaultSize, 0 );
|
|
326 m_notebook->SetImageList( imgList );
|
|
327
|
|
328 m_scrolledWindow1 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
329 m_scrolledWindow1->SetScrollRate( 5, 5 );
|
|
330 m_notebook->AddPage( m_scrolledWindow1, wxT( "Image-01" ), false, 0 );
|
|
331
|
|
332 m_scrolledWindow2 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
333 m_scrolledWindow2->SetScrollRate( 5, 5 );
|
|
334 m_notebook->AddPage( m_scrolledWindow2, wxT( "Image-02" ), false, 0 );
|
|
335
|
|
336 m_scrolledWindow3 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
337 m_scrolledWindow3->SetScrollRate( 5, 5 );
|
|
338 m_notebook->AddPage( m_scrolledWindow3, wxT( "Image-03" ), false, 0 );
|
|
339
|
|
340 m_scrolledWindow4 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
341 m_scrolledWindow4->SetScrollRate( 5, 5 );
|
|
342 m_notebook->AddPage( m_scrolledWindow4, wxT( "Image-04" ), false, 0 );
|
|
343
|
|
344 m_scrolledWindow5 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
345 m_scrolledWindow5->SetScrollRate( 5, 5 );
|
|
346 m_notebook->AddPage( m_scrolledWindow5, wxT( "Image-05" ), false, 0 );
|
|
347
|
|
348 m_scrolledWindow6 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
|
|
349 m_scrolledWindow6->SetScrollRate( 5, 5 );
|
|
350 m_notebook->AddPage( m_scrolledWindow6, wxT( "Image-06" ), false, 0 );
|
|
351
|
|
352 bSizerTop->Add( m_notebook, 1, wxEXPAND|wxALL, 5 );
|
|
353
|
|
354 // Right
|
|
355 wxBoxSizer* bSizerRight = new wxBoxSizer( wxVERTICAL );
|
|
356
|
|
357 m_searchCtrl = new MySearchCtrl( this, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxSize( -1, 24 ), wxTE_PROCESS_ENTER );
|
|
358 bSizerRight->Add( m_searchCtrl, 0, wxALL, 5 );
|
|
359 m_searchCtrl->SetFocus();
|
|
360
|
|
361 m_textCtrlName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 );
|
|
362 m_textCtrlName->SetBackgroundColour( wxColour( 180, 210, 240 ) );
|
|
363 bSizerRight->Add( m_textCtrlName, 0, wxALL, 5 );
|
|
364
|
2
|
365 m_textCtrlAddr = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 160, -1 ), 0 );
|
0
|
366 m_textCtrlAddr->SetBackgroundColour( wxColour( 180, 210, 240 ) );
|
|
367 bSizerRight->Add( m_textCtrlAddr, 0, wxALL|wxEXPAND, 5 );
|
|
368
|
|
369 m_dataViewListCtrl = new wxDataViewListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE );
|
2
|
370 m_dataViewListColumnNo = m_dataViewListCtrl->AppendTextColumn( wxT( "No" ), wxDATAVIEW_CELL_INERT, 30, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
371 m_dataViewListColumnDate = m_dataViewListCtrl->AppendTextColumn( wxT( "Date" ), wxDATAVIEW_CELL_INERT, 80, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
|
372 m_dataViewListColumnDate = m_dataViewListCtrl->AppendTextColumn( wxT( "Ready" ), wxDATAVIEW_CELL_INERT, 60, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
|
0
|
373
|
|
374 bSizerRight->Add( m_dataViewListCtrl, 1, wxALL|wxEXPAND, 5 );
|
|
375
|
|
376 m_textCtrlLog = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
377 bSizerRight->Add( m_textCtrlLog, 1, wxALL|wxEXPAND, 5 );
|
|
378
|
2
|
379 m_slider = new wxSlider( this, ID_SLDR, 1, 1, 5, wxDefaultPosition, wxSize( -1, 200 ), wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LABELS|wxSL_VERTICAL );
|
0
|
380 bSizerRight->Add( m_slider, 0, wxALL, 5 );
|
|
381
|
3
|
382 m_buttonPrint = new wxButton( this, wxID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 );
|
0
|
383 bSizerRight->Add( m_buttonPrint, 0, wxALL, 5 );
|
|
384
|
3
|
385 m_buttonLogout = new wxButton( this, ID_LOGOUT, wxT( "Logout" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
386 bSizerRight->Add( m_buttonLogout, 0, wxALL, 5 );
|
|
387
|
1
|
388 m_buttonTest = new wxButton( this, ID_TEST, wxT( "Test" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
389 bSizerRight->Add( m_buttonTest, 0, wxALL, 5 );
|
0
|
390
|
|
391 bSizerTop->Add( bSizerRight, 0, wxEXPAND, 5 );
|
|
392
|
|
393 this->SetSizer( bSizerTop );
|
|
394 this->Layout();
|
|
395
|
|
396 //this->Centre( wxBOTH );
|
|
397
|
|
398 m_staticBitmap1 = new MyStaticBitmap( m_scrolledWindow1, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
399 m_staticBitmap2 = new MyStaticBitmap( m_scrolledWindow2, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
400 m_staticBitmap3 = new MyStaticBitmap( m_scrolledWindow3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
401 m_staticBitmap4 = new MyStaticBitmap( m_scrolledWindow4, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
402 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
|
|
403 }
|
|
404
|
|
405 void MainFrame::Cmd( wxString cmd )
|
|
406 {
|
|
407 m_dataViewListCtrl->DeleteAllItems();
|
2
|
408 LoadBitmaps( wxEmptyString );
|
0
|
409
|
2
|
410 if ( cmd.IsSameAs( wxT( "q" ), true ) || cmd.IsSameAs( wxT( "9" ), true ) ) {
|
0
|
411 Close();
|
2
|
412 return;
|
0
|
413 }
|
|
414
|
2
|
415 if ( cmd.IsSameAs( wxT( "c" ), true ) || cmd.IsSameAs( wxT( "cmd" ), true ) ) {
|
|
416 Close();
|
|
417 return;
|
|
418 }
|
|
419
|
3
|
420 if ( cmd.IsSameAs( wxT( "k" ), true ) ) {
|
|
421 // hiragana kensaku
|
|
422 return;
|
|
423 }
|
|
424
|
|
425 if ( cmd.IsSameAs( wxT( "." ), false ) ) {
|
0
|
426 wxString appdir = wxGetCwd();
|
|
427 wxString execmd = wxT( "explorer " ) + appdir;
|
|
428 wxExecute( execmd );
|
|
429 return;
|
|
430 }
|
|
431
|
3
|
432 if ( cmd.IsSameAs( wxT( "*" ), false ) ) {
|
|
433 // cmd = clipboard // paste clipboard
|
|
434 }
|
|
435
|
|
436 if ( cmd.IsSameAs( wxT( "+" ), false ) ) {
|
|
437 // print
|
|
438 return;
|
|
439 }
|
|
440
|
0
|
441 wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) );
|
|
442 if ( reHhs.Matches( cmd ) ) {
|
2
|
443 m_hhs = m_searchCtrl->GetValue();
|
|
444 Search();
|
|
445 return;
|
|
446 }
|
0
|
447
|
3
|
448 wxMessageBox( wxT( "Bad Input !!" ) );
|
0
|
449 }
|
|
450
|
1
|
451 void MainFrame::LoadBitmap( wxScrolledWindow* sc, wxStaticBitmap* sb, wxString file )
|
0
|
452 {
|
2
|
453 if ( startup ) {
|
|
454 file = wxT( "image/hw201810.jpg" );
|
|
455 startup = false;
|
|
456 }
|
|
457 if ( !wxFileExists( file ) ) file = wxT( "image/testpattern.jpg" );
|
0
|
458 wxBitmap bmp( file, wxBITMAP_TYPE_JPEG );
|
|
459 int width = bmp.GetWidth();
|
|
460 int height = bmp.GetHeight();
|
|
461 wxImage img = bmp.ConvertToImage();
|
|
462
|
|
463 int ww, wh;
|
1
|
464 sc->GetSize( &ww, &wh );
|
0
|
465
|
3
|
466 float w = ww - 30;
|
0
|
467 float h = w * height / width;
|
|
468 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
|
1
|
469 sc->SetScrollbars( 10, 10, w / 10, h / 10 );
|
0
|
470
|
|
471 for ( int i = 0; i < 5; i++ ) {
|
|
472 w *= 1.1;
|
|
473 h *= 1.1;
|
|
474 //sb->SetImage( i, wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
|
|
475 }
|
|
476 }
|
|
477
|
2
|
478 void MainFrame::LoadBitmaps( wxString date )
|
0
|
479 {
|
2
|
480 LoadBitmap( m_scrolledWindow1, m_staticBitmap1, wxString::Format( wxT( ".cache/%08s_1" ), date ) );
|
|
481 LoadBitmap( m_scrolledWindow2, m_staticBitmap2, wxString::Format( wxT( ".cache/%08s_2" ), date ) );
|
|
482 LoadBitmap( m_scrolledWindow3, m_staticBitmap3, wxString::Format( wxT( ".cache/%08s_3" ), date ) );
|
|
483 LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( wxT( ".cache/%08s_4" ), date ) );
|
|
484 LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( wxT( ".cache/%08s_5" ), date ) );
|
|
485 }
|
|
486
|
|
487 void MainFrame::GetImages( wxString hhs, wxString date )
|
|
488 {
|
|
489 wxArrayString args; // http get
|
|
490 args.Add( wxT( "client.exe" ) );
|
|
491 args.Add( m_server );
|
|
492 args.Add( hhs );
|
|
493 args.Add( date );
|
|
494
|
|
495 //wxMessageBox( wxJoin( args, ' ', '\\' ) );
|
3
|
496 int estimate = 5;
|
|
497 wxProgressDialog pd( wxT( "Connecting Server" ), wxT( "Start..." ), estimate, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
|
|
498 pd.SetSize( wxSize( 320, 140 ) );
|
|
499
|
2
|
500 wxExecute( wxJoin( args, ' ', '\\' ), wxEXEC_ASYNC|wxEXEC_HIDE_CONSOLE );
|
3
|
501 for ( int i = 0; i < estimate; i++ ) {
|
|
502 wxSleep( 1 );
|
|
503 pd.Update( i, wxT( "Now Loading..." ) );
|
|
504 }
|
0
|
505 }
|
|
506
|
2
|
507 void MainFrame::Search( void )
|
0
|
508 {
|
2
|
509 wxString date;
|
|
510 int match_cnt = 0;
|
|
511 for ( int i = 0; i < m_index.GetCount(); i++ ) {
|
|
512 if ( m_index[i].StartsWith( m_hhs, &date ) ) {
|
|
513 wxVector<wxVariant> data;
|
|
514 data.push_back( wxString::Format( wxT( "%02d" ), ++match_cnt ) );
|
|
515 date = date.Mid( 1, 4 ) + wxT( "-" ) + date.Mid( 5, 2 ) + wxT( "-" ) + date.Mid( 7, 2 );
|
|
516 data.push_back( date );
|
|
517 data.push_back( wxEmptyString );
|
|
518 m_dataViewListCtrl->AppendItem( data );
|
|
519 data.clear();
|
|
520 }
|
|
521 }
|
3
|
522 if ( match_cnt == 0 ) wxMessageBox( wxT( "Not Matched !!" ) );
|
2
|
523 }
|
|
524
|
3
|
525 void MainFrame::LoadDB( void )
|
2
|
526 {
|
|
527 wxTextFile file;
|
|
528 file.Open( wxT( "index.db" ) );
|
|
529 for ( int i = 0; i < file.GetLineCount(); i++ )
|
|
530 m_index.Add( file.GetLine( i ) );
|
|
531 file.Close();
|
|
532 m_index.Sort( true );
|
3
|
533
|
|
534 /*
|
|
535 file.Open( wxT( "hhs.db" ) );
|
|
536 for ( int i = 0; i < file.GetLineCount(); i++ ) {
|
|
537 //
|
|
538 }
|
|
539 file.Close();
|
|
540 */
|
|
541 }
|
|
542
|
|
543 void MainFrame::PrintImages( void )
|
|
544 {
|
|
545 int r = m_dataViewListCtrl->GetSelectedRow();
|
4
|
546 if ( r == wxNOT_FOUND ) {
|
|
547 wxMessageBox( wxT( "Not Ready for Print !!" ) );
|
|
548 return;
|
|
549 }
|
3
|
550 wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 );
|
|
551
|
|
552 if ( !ready.IsSameAs( wxT( "OK" ), true ) ) {
|
|
553 wxMessageBox( wxT( "Not Ready for Print !!" ) );
|
|
554 return;
|
|
555 }
|
|
556
|
|
557 wxDateTime now = wxDateTime::Now();
|
|
558 wxString nowstr = now.Format( "%Y/%m/%d %H:%M", wxDateTime::GMT9 ).c_str();
|
|
559
|
|
560 wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
|
|
561 date.Replace( wxT( "-" ), wxEmptyString, true );
|
|
562
|
|
563 wxString html, file;
|
|
564 html = wxT( "<html><body>\n" );
|
|
565
|
|
566 for ( int i = 1; i < 6; i++ ) {
|
|
567 file = wxString::Format( wxT( ".cache/%08s_%d" ), date, i );
|
|
568 html = html + wxT( "<img src=\"" ) + file + wxT( "\" width=\"750\" height=\"1060\"/>\n" );
|
|
569 html = html + wxT( "<div align=right><font size=-2><u>" ) + m_hhs + wxT( "@" ) + m_user + wxT( "#" ) + nowstr + wxT( "</u></font></div>\n\n" );
|
|
570 }
|
|
571 html = html + wxT( "</body></html>" );
|
|
572
|
|
573 // start printing
|
|
574 wxHtmlPrintout hpout( wxT( "Re:Searcher" ) );
|
|
575 hpout.SetMargins( 0, 0, 0, 0, 0 );
|
|
576 wxPrintDialogData pd;
|
|
577 wxPrinter p( &pd );
|
|
578
|
|
579 hpout.SetHtmlText( html, wxEmptyString, false );
|
|
580 p.Print( NULL, &hpout, true );
|
2
|
581 }
|
|
582
|
|
583 void MainFrame::RemoveFile( wxString pattern )
|
|
584 {
|
|
585 wxString file = wxFindFirstFile( pattern );
|
|
586 while ( !file.empty() ) {
|
|
587 wxRemoveFile( file );
|
|
588 file = wxFindNextFile();
|
|
589 }
|
0
|
590 }
|
|
591
|
1
|
592 void MainFrame::InDevelop( bool flag )
|
0
|
593 {
|
1
|
594 if ( !flag ) return;
|
0
|
595
|
3
|
596 bool lo = false;
|
|
597 m_buttonLogout->Enable( lo );
|
|
598 m_buttonLogout->Show( lo );
|
0
|
599
|
3
|
600 bool sl = false;
|
|
601 m_slider->Enable( sl );
|
|
602 m_slider->Show( sl );
|
0
|
603
|
3
|
604 bool tb = false;
|
1
|
605 m_buttonTest->Enable( tb );
|
|
606 m_buttonTest->Show( tb );
|
|
607
|
4
|
608 return;
|
|
609
|
3
|
610 // search
|
|
611 m_searchCtrl->SetValue( wxT( "0100122642" ) );
|
0
|
612 }
|
|
613
|