comparison src/rsearcher.cpp @ 1:eaa27e4ed5be

add client_ui.go
author pyon@macmini
date Mon, 01 Oct 2018 23:18:29 +0900
parents d3b8cd5aeb70
children 7fe3417cefc8
comparison
equal deleted inserted replaced
0:d3b8cd5aeb70 1:eaa27e4ed5be
1 // Filename : rsearcher.cpp 1 // Filename : rsearcher.cpp
2 // Last Change: 2018-09-16 Sun 18:25:30. 2 // Last Change: 2018-10-01 Mon 23:15:33.
3 // 3 //
4 4
5 #include "rsearcher.h" 5 #include "rsearcher.h"
6 #include "main.h" 6 #include "main.h"
7 7
145 /** Main Frame **/ 145 /** Main Frame **/
146 /********************/ 146 /********************/
147 MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 147 MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
148 : wxFrame( parent, id, title, pos, size, style ) 148 : wxFrame( parent, id, title, pos, size, style )
149 { 149 {
150 this->SetIcon( wxIcon( wxT( "sample" ) ) ); 150 CreateControls();
151 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
152 //this->SetBackgroundColour( wxColour( 0, 150, 230 ) );
153
154 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL );
155
156 // Left
157 wxImageList* imgList = new wxImageList( 16, 16, false, 1 );
158 wxBitmap bmp( wxT( "image/blue.png" ), wxBITMAP_TYPE_PNG );
159 imgList->Add( bmp, wxNullBitmap );
160 bmp.LoadFile( wxT( "image/water.png" ), wxBITMAP_TYPE_PNG );
161 imgList->Add( bmp, wxNullBitmap );
162
163 m_notebook = new wxNotebook( this, ID_NBOOK, wxDefaultPosition, wxDefaultSize, 0 );
164 m_notebook->SetImageList( imgList );
165
166 m_scrolledWindow1 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
167 m_scrolledWindow1->SetScrollRate( 5, 5 );
168 m_notebook->AddPage( m_scrolledWindow1, wxT( "Image-01" ), false, 0 );
169
170 m_scrolledWindow2 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
171 m_scrolledWindow2->SetScrollRate( 5, 5 );
172 m_notebook->AddPage( m_scrolledWindow2, wxT( "Image-02" ), false, 0 );
173
174 m_scrolledWindow3 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
175 m_scrolledWindow3->SetScrollRate( 5, 5 );
176 m_notebook->AddPage( m_scrolledWindow3, wxT( "Image-03" ), false, 0 );
177
178 m_scrolledWindow4 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
179 m_scrolledWindow4->SetScrollRate( 5, 5 );
180 m_notebook->AddPage( m_scrolledWindow4, wxT( "Image-04" ), false, 0 );
181
182 m_scrolledWindow5 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
183 m_scrolledWindow5->SetScrollRate( 5, 5 );
184 m_notebook->AddPage( m_scrolledWindow5, wxT( "Image-05" ), false, 0 );
185
186 m_scrolledWindow6 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
187 m_scrolledWindow6->SetScrollRate( 5, 5 );
188 m_notebook->AddPage( m_scrolledWindow6, wxT( "Image-06" ), false, 0 );
189
190 bSizerTop->Add( m_notebook, 1, wxEXPAND|wxALL, 5 );
191
192 // Right
193 wxBoxSizer* bSizerRight = new wxBoxSizer( wxVERTICAL );
194
195 m_searchCtrl = new MySearchCtrl( this, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxSize( -1, 24 ), wxTE_PROCESS_ENTER );
196 bSizerRight->Add( m_searchCtrl, 0, wxALL, 5 );
197 m_searchCtrl->SetFocus();
198
199 m_textCtrlName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 );
200 m_textCtrlName->SetBackgroundColour( wxColour( 180, 210, 240 ) );
201 bSizerRight->Add( m_textCtrlName, 0, wxALL, 5 );
202
203 m_textCtrlAddr = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 120, -1 ), 0 );
204 m_textCtrlAddr->SetBackgroundColour( wxColour( 180, 210, 240 ) );
205 bSizerRight->Add( m_textCtrlAddr, 0, wxALL|wxEXPAND, 5 );
206
207 m_dataViewListCtrl = new wxDataViewListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE );
208 m_dataViewListColumnNo = m_dataViewListCtrl->AppendTextColumn( wxT( "No" ), wxDATAVIEW_CELL_INERT, 30, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
209 m_dataViewListColumnDate = m_dataViewListCtrl->AppendTextColumn( wxT( "Date" ), wxDATAVIEW_CELL_INERT, 120, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
210
211 bSizerRight->Add( m_dataViewListCtrl, 1, wxALL|wxEXPAND, 5 );
212
213 m_textCtrlLog = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
214 bSizerRight->Add( m_textCtrlLog, 1, wxALL|wxEXPAND, 5 );
215
216 m_slider = new wxSlider( this, ID_SLDR, 1, 1, 5, wxDefaultPosition, wxSize( -1,200 ), wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LABELS|wxSL_VERTICAL );
217 bSizerRight->Add( m_slider, 0, wxALL, 5 );
218
219 m_buttonPrint = new wxButton( this, ID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 );
220 bSizerRight->Add( m_buttonPrint, 0, wxALL, 5 );
221
222 m_button = new wxButton( this, ID_TEST, wxT( "MyButton" ), wxDefaultPosition, wxDefaultSize, 0 );
223 bSizerRight->Add( m_button, 0, wxALL, 5 );
224
225 bSizerTop->Add( bSizerRight, 0, wxEXPAND, 5 );
226
227 this->SetSizer( bSizerTop );
228 this->Layout();
229
230 //this->Centre( wxBOTH );
231
232 m_staticBitmap1 = new MyStaticBitmap( m_scrolledWindow1, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
233 m_staticBitmap2 = new MyStaticBitmap( m_scrolledWindow2, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
234 m_staticBitmap3 = new MyStaticBitmap( m_scrolledWindow3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
235 m_staticBitmap4 = new MyStaticBitmap( m_scrolledWindow4, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
236 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
237
238 InDevelop();
239 } 151 }
240 152
241 MainFrame::~MainFrame() 153 MainFrame::~MainFrame()
242 { 154 {
243 } 155 }
297 /* ok 209 /* ok
298 Cmd( m_searchCtrl->GetValue() ); 210 Cmd( m_searchCtrl->GetValue() );
299 Cmd( wxT( "0100012345" ) ); 211 Cmd( wxT( "0100012345" ) );
300 */ 212 */
301 213
302 wxBitmap bmp( wxT("db/19970101/img088.jpg"), wxBITMAP_TYPE_JPEG ); 214 wxBitmap bmp( wxT(".cache/01_1"), wxBITMAP_TYPE_JPEG );
303 int width = bmp.GetWidth(); 215 int width = bmp.GetWidth();
304 int height = bmp.GetHeight(); 216 int height = bmp.GetHeight();
305 wxImage img = bmp.ConvertToImage(); 217 wxImage img = bmp.ConvertToImage();
306 218
307 int ww, wh; 219 int ww, wh;
308 m_scrolledWindow1->GetSize( &ww, &wh ); 220 m_scrolledWindow6->GetSize( &ww, &wh );
309 221
310 float w = ww; 222 float w = ww;
311 float h = w * height / width; 223 float h = w * height / width;
312 m_staticBitmap1->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); 224 m_staticBitmap6->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
313 m_scrolledWindow1->SetScrollbars( 10, 10, w / 10, h / 10 ); 225 m_scrolledWindow6->SetScrollbars( 10, 10, w / 10, h / 10 );
314 226
315 for ( int i = 0; i < 5; i++ ) { 227 for ( int i = 0; i < 5; i++ ) {
316 w *= 1.1; 228 w *= 1.1;
317 h *= 1.1; 229 h *= 1.1;
318 m_staticBitmap1->SetImage( i, wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); 230 //m_staticBitmap6->SetImage( i, wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
319 } 231 }
320 } 232 }
321 233
322 // Functions 234 // Functions
235 void MainFrame::CreateControls( void )
236 {
237 this->SetIcon( wxIcon( wxT( "sample" ) ) );
238 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
239 //this->SetBackgroundColour( wxColour( 0, 150, 230 ) );
240
241 wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL );
242
243 // Left
244 wxImageList* imgList = new wxImageList( 16, 16, false, 1 );
245 wxBitmap bmp( wxT( "image/blue.png" ), wxBITMAP_TYPE_PNG );
246 imgList->Add( bmp, wxNullBitmap );
247 bmp.LoadFile( wxT( "image/water.png" ), wxBITMAP_TYPE_PNG );
248 imgList->Add( bmp, wxNullBitmap );
249
250 m_notebook = new wxNotebook( this, ID_NBOOK, wxDefaultPosition, wxDefaultSize, 0 );
251 m_notebook->SetImageList( imgList );
252
253 m_scrolledWindow1 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
254 m_scrolledWindow1->SetScrollRate( 5, 5 );
255 m_notebook->AddPage( m_scrolledWindow1, wxT( "Image-01" ), false, 0 );
256
257 m_scrolledWindow2 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
258 m_scrolledWindow2->SetScrollRate( 5, 5 );
259 m_notebook->AddPage( m_scrolledWindow2, wxT( "Image-02" ), false, 0 );
260
261 m_scrolledWindow3 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
262 m_scrolledWindow3->SetScrollRate( 5, 5 );
263 m_notebook->AddPage( m_scrolledWindow3, wxT( "Image-03" ), false, 0 );
264
265 m_scrolledWindow4 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
266 m_scrolledWindow4->SetScrollRate( 5, 5 );
267 m_notebook->AddPage( m_scrolledWindow4, wxT( "Image-04" ), false, 0 );
268
269 m_scrolledWindow5 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
270 m_scrolledWindow5->SetScrollRate( 5, 5 );
271 m_notebook->AddPage( m_scrolledWindow5, wxT( "Image-05" ), false, 0 );
272
273 m_scrolledWindow6 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
274 m_scrolledWindow6->SetScrollRate( 5, 5 );
275 m_notebook->AddPage( m_scrolledWindow6, wxT( "Image-06" ), false, 0 );
276
277 bSizerTop->Add( m_notebook, 1, wxEXPAND|wxALL, 5 );
278
279 // Right
280 wxBoxSizer* bSizerRight = new wxBoxSizer( wxVERTICAL );
281
282 m_searchCtrl = new MySearchCtrl( this, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxSize( -1, 24 ), wxTE_PROCESS_ENTER );
283 bSizerRight->Add( m_searchCtrl, 0, wxALL, 5 );
284 m_searchCtrl->SetFocus();
285
286 m_textCtrlName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 );
287 m_textCtrlName->SetBackgroundColour( wxColour( 180, 210, 240 ) );
288 bSizerRight->Add( m_textCtrlName, 0, wxALL, 5 );
289
290 m_textCtrlAddr = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 120, -1 ), 0 );
291 m_textCtrlAddr->SetBackgroundColour( wxColour( 180, 210, 240 ) );
292 bSizerRight->Add( m_textCtrlAddr, 0, wxALL|wxEXPAND, 5 );
293
294 m_dataViewListCtrl = new wxDataViewListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE );
295 m_dataViewListColumnNo = m_dataViewListCtrl->AppendTextColumn( wxT( "No" ), wxDATAVIEW_CELL_INERT, 30, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
296 m_dataViewListColumnDate = m_dataViewListCtrl->AppendTextColumn( wxT( "Date" ), wxDATAVIEW_CELL_INERT, 120, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
297
298 bSizerRight->Add( m_dataViewListCtrl, 1, wxALL|wxEXPAND, 5 );
299
300 m_textCtrlLog = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
301 bSizerRight->Add( m_textCtrlLog, 1, wxALL|wxEXPAND, 5 );
302
303 m_slider = new wxSlider( this, ID_SLDR, 1, 1, 5, wxDefaultPosition, wxSize( -1,200 ), wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LABELS|wxSL_VERTICAL );
304 bSizerRight->Add( m_slider, 0, wxALL, 5 );
305
306 m_buttonPrint = new wxButton( this, ID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 );
307 bSizerRight->Add( m_buttonPrint, 0, wxALL, 5 );
308
309 m_buttonTest = new wxButton( this, ID_TEST, wxT( "Test" ), wxDefaultPosition, wxDefaultSize, 0 );
310 bSizerRight->Add( m_buttonTest, 0, wxALL, 5 );
311
312 bSizerTop->Add( bSizerRight, 0, wxEXPAND, 5 );
313
314 this->SetSizer( bSizerTop );
315 this->Layout();
316
317 //this->Centre( wxBOTH );
318
319 m_staticBitmap1 = new MyStaticBitmap( m_scrolledWindow1, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
320 m_staticBitmap2 = new MyStaticBitmap( m_scrolledWindow2, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
321 m_staticBitmap3 = new MyStaticBitmap( m_scrolledWindow3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
322 m_staticBitmap4 = new MyStaticBitmap( m_scrolledWindow4, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
323 m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
324 }
325
323 void MainFrame::Cmd( wxString cmd ) 326 void MainFrame::Cmd( wxString cmd )
324 { 327 {
325 m_dataViewListCtrl->DeleteAllItems(); 328 m_dataViewListCtrl->DeleteAllItems();
326 329
327 if ( cmd.Cmp( wxT( "q" ) ) == 0 || cmd.Cmp( wxT( "9" ) ) == 0 ) { 330 if ( cmd.Cmp( wxT( "q" ) ) == 0 || cmd.Cmp( wxT( "9" ) ) == 0 ) {
357 wxMessageBox( errors[0], wxT( "Error" ) ); 360 wxMessageBox( errors[0], wxT( "Error" ) );
358 } 361 }
359 } 362 }
360 } 363 }
361 364
362 void MainFrame::LoadBitmap( wxStaticBitmap* sb, wxString file ) 365 void MainFrame::LoadBitmap( wxScrolledWindow* sc, wxStaticBitmap* sb, wxString file )
363 { 366 {
364 wxBitmap bmp( file, wxBITMAP_TYPE_JPEG ); 367 wxBitmap bmp( file, wxBITMAP_TYPE_JPEG );
365 int width = bmp.GetWidth(); 368 int width = bmp.GetWidth();
366 int height = bmp.GetHeight(); 369 int height = bmp.GetHeight();
367 wxImage img = bmp.ConvertToImage(); 370 wxImage img = bmp.ConvertToImage();
368 371
369 int ww, wh; 372 int ww, wh;
370 sb->GetSize( &ww, &wh ); 373 sc->GetSize( &ww, &wh );
371 374
372 float w = ww; 375 float w = ww - 50;
373 float h = w * height / width; 376 float h = w * height / width;
374 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); 377 sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
375 //sb->SetScrollbars( 10, 10, w / 10, h / 10 ); 378 sc->SetScrollbars( 10, 10, w / 10, h / 10 );
376 379
377 for ( int i = 0; i < 5; i++ ) { 380 for ( int i = 0; i < 5; i++ ) {
378 w *= 1.1; 381 w *= 1.1;
379 h *= 1.1; 382 h *= 1.1;
380 //sb->SetImage( i, wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); 383 //sb->SetImage( i, wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
381 } 384 }
382 } 385 }
383 386
384 void MainFrame::LoadBitmaps( void ) 387 void MainFrame::LoadBitmaps( void )
385 { 388 {
386 int no = 1; 389 int date = 0;
387 LoadBitmap( m_staticBitmap1, wxString::Format( ".cache/%02d_1", no ) ); 390 LoadBitmap( m_scrolledWindow1, m_staticBitmap1, wxString::Format( ".cache/%08d_1", date ) );
388 LoadBitmap( m_staticBitmap2, wxString::Format( ".cache/%02d_2", no ) ); 391 LoadBitmap( m_scrolledWindow2, m_staticBitmap2, wxString::Format( ".cache/%08d_2", date ) );
389 LoadBitmap( m_staticBitmap3, wxString::Format( ".cache/%02d_3", no ) ); 392 LoadBitmap( m_scrolledWindow3, m_staticBitmap3, wxString::Format( ".cache/%08d_3", date ) );
390 LoadBitmap( m_staticBitmap4, wxString::Format( ".cache/%02d_4", no ) ); 393 LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( ".cache/%08d_4", date ) );
391 LoadBitmap( m_staticBitmap5, wxString::Format( ".cache/%02d_5", no ) ); 394 LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( ".cache/%08d_5", date ) );
392 } 395 }
393 396
394 void MainFrame::GetImage( wxString hhs, wxString no ) 397 void MainFrame::GetImage( wxString hhs, wxString no )
395 { 398 {
396 // http get 399 // http get
397 } 400 }
398 401
399 void MainFrame::InDevelop( void ) 402 void MainFrame::InDevelop( bool flag )
400 { 403 {
404 if ( !flag ) return;
401 LoadBitmaps(); 405 LoadBitmaps();
402 406
403 m_slider->Enable( false ); 407 m_slider->Enable( false );
404 m_slider->Show( false ); 408 m_slider->Show( false );
405 409
406 m_buttonPrint->Enable( false ); 410 m_buttonPrint->Enable( false );
407 m_buttonPrint->Show( false ); 411 m_buttonPrint->Show( false );
408 412
409 m_button->Enable( false ); 413 bool tb = false;
410 m_button->Show( false ); 414 m_buttonTest->Enable( tb );
411 } 415 m_buttonTest->Show( tb );
412 416
417 m_searchCtrl->Enable( false );
418 }
419