diff 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
line wrap: on
line diff
--- a/src/rsearcher.cpp	Sun Sep 30 17:27:04 2018 +0900
+++ b/src/rsearcher.cpp	Mon Oct 01 23:18:29 2018 +0900
@@ -1,5 +1,5 @@
 // Filename   : rsearcher.cpp
-// Last Change: 2018-09-16 Sun 18:25:30.
+// Last Change: 2018-10-01 Mon 23:15:33.
 //
 
 #include "rsearcher.h"
@@ -147,6 +147,93 @@
 MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 
 	: wxFrame( parent, id, title, pos, size, style )
 {
+	CreateControls();
+}
+
+MainFrame::~MainFrame()
+{
+}
+
+// Event Table
+BEGIN_EVENT_TABLE( MainFrame, wxFrame )
+    EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked )
+    EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged )
+	EVT_BUTTON( ID_TEST, MainFrame::OnTestButton )
+	EVT_CLOSE( MainFrame::SaveConfig )
+    //EVT_IDLE( MainFrame::OnIdle )
+END_EVENT_TABLE()
+
+
+// Event Handler
+void MainFrame::OnItemDClicked( wxDataViewEvent& WXUNUSED(event) )
+{
+    wxMessageBox( "dcli" );
+    int r = m_dataViewListCtrl->GetSelectedRow();
+    wxString no = m_dataViewListCtrl->GetTextValue( r, 0 );
+
+    LoadBitmaps();
+}
+
+void MainFrame::OnNBookChanged( wxBookCtrlEvent& WXUNUSED(event) )
+{
+    for ( int i = 0; i < m_notebook->GetPageCount(); i++ ) {
+        m_notebook->SetPageImage( i, 1 );
+    }
+    m_notebook->SetPageImage( m_notebook->GetSelection(), 0 );
+}
+
+/*
+void MainFrame::OnItemSelected( wxDataViewEvent& event )
+{
+    dclick or select ?
+}
+*/
+
+
+/*
+void MainFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
+{
+}
+
+*/
+void MainFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) )
+{
+    if ( !IsIconized() && !IsMaximized() ) {
+        wxGetApp().rect = this->GetRect();
+    }
+    Destroy();
+}
+
+void MainFrame::OnTestButton( wxCommandEvent& WXUNUSED(event) )
+{
+    /* ok
+    Cmd( m_searchCtrl->GetValue() );
+    Cmd( wxT( "0100012345" ) );
+    */
+
+    wxBitmap bmp( wxT(".cache/01_1"), wxBITMAP_TYPE_JPEG );
+    int width  = bmp.GetWidth();
+    int height = bmp.GetHeight();
+    wxImage img = bmp.ConvertToImage();
+
+    int ww, wh;
+    m_scrolledWindow6->GetSize( &ww, &wh );
+
+    float w = ww;
+    float h = w * height / width;
+    m_staticBitmap6->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
+    m_scrolledWindow6->SetScrollbars( 10, 10, w / 10, h / 10 );
+
+    for ( int i = 0; i < 5; i++ ) {
+        w *= 1.1;
+        h *= 1.1;
+        //m_staticBitmap6->SetImage( i, wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
+    }
+}
+
+// Functions
+void MainFrame::CreateControls( void )
+{
     this->SetIcon( wxIcon( wxT( "sample" ) ) );
 	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
 	//this->SetBackgroundColour( wxColour( 0, 150, 230 ) );
@@ -219,8 +306,8 @@
 	m_buttonPrint = new wxButton( this, ID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 );
 	bSizerRight->Add( m_buttonPrint, 0, wxALL, 5 );
 	
-	m_button = new wxButton( this, ID_TEST, wxT( "MyButton" ), wxDefaultPosition, wxDefaultSize, 0 );
-	bSizerRight->Add( m_button, 0, wxALL, 5 );
+	m_buttonTest = new wxButton( this, ID_TEST, wxT( "Test" ), wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerRight->Add( m_buttonTest, 0, wxALL, 5 );
 	
 	bSizerTop->Add( bSizerRight, 0, wxEXPAND, 5 );
 	
@@ -234,92 +321,8 @@
     m_staticBitmap3 = new MyStaticBitmap( m_scrolledWindow3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
     m_staticBitmap4 = new MyStaticBitmap( m_scrolledWindow4, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
     m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString );
-
-    InDevelop();
-}
-
-MainFrame::~MainFrame()
-{
-}
-
-// Event Table
-BEGIN_EVENT_TABLE( MainFrame, wxFrame )
-    EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked )
-    EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged )
-	EVT_BUTTON( ID_TEST, MainFrame::OnTestButton )
-	EVT_CLOSE( MainFrame::SaveConfig )
-    //EVT_IDLE( MainFrame::OnIdle )
-END_EVENT_TABLE()
-
-
-// Event Handler
-void MainFrame::OnItemDClicked( wxDataViewEvent& WXUNUSED(event) )
-{
-    wxMessageBox( "dcli" );
-    int r = m_dataViewListCtrl->GetSelectedRow();
-    wxString no = m_dataViewListCtrl->GetTextValue( r, 0 );
-
-    LoadBitmaps();
-}
-
-void MainFrame::OnNBookChanged( wxBookCtrlEvent& WXUNUSED(event) )
-{
-    for ( int i = 0; i < m_notebook->GetPageCount(); i++ ) {
-        m_notebook->SetPageImage( i, 1 );
-    }
-    m_notebook->SetPageImage( m_notebook->GetSelection(), 0 );
 }
 
-/*
-void MainFrame::OnItemSelected( wxDataViewEvent& event )
-{
-    dclick or select ?
-}
-*/
-
-
-/*
-void MainFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
-{
-}
-
-*/
-void MainFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) )
-{
-    if ( !IsIconized() && !IsMaximized() ) {
-        wxGetApp().rect = this->GetRect();
-    }
-    Destroy();
-}
-
-void MainFrame::OnTestButton( wxCommandEvent& WXUNUSED(event) )
-{
-    /* ok
-    Cmd( m_searchCtrl->GetValue() );
-    Cmd( wxT( "0100012345" ) );
-    */
-
-    wxBitmap bmp( wxT("db/19970101/img088.jpg"), wxBITMAP_TYPE_JPEG );
-    int width  = bmp.GetWidth();
-    int height = bmp.GetHeight();
-    wxImage img = bmp.ConvertToImage();
-
-    int ww, wh;
-    m_scrolledWindow1->GetSize( &ww, &wh );
-
-    float w = ww;
-    float h = w * height / width;
-    m_staticBitmap1->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
-    m_scrolledWindow1->SetScrollbars( 10, 10, w / 10, h / 10 );
-
-    for ( int i = 0; i < 5; i++ ) {
-        w *= 1.1;
-        h *= 1.1;
-        m_staticBitmap1->SetImage( i, wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
-    }
-}
-
-// Functions
 void MainFrame::Cmd( wxString cmd )
 {
 	m_dataViewListCtrl->DeleteAllItems();
@@ -359,7 +362,7 @@
     }
 }
 
-void MainFrame::LoadBitmap( wxStaticBitmap* sb, wxString file )
+void MainFrame::LoadBitmap( wxScrolledWindow* sc, wxStaticBitmap* sb, wxString file )
 {
     wxBitmap bmp( file, wxBITMAP_TYPE_JPEG );
     int width  = bmp.GetWidth();
@@ -367,12 +370,12 @@
     wxImage img = bmp.ConvertToImage();
 
     int ww, wh;
-    sb->GetSize( &ww, &wh );
+    sc->GetSize( &ww, &wh );
 
-    float w = ww;
+    float w = ww - 50;
     float h = w * height / width;
     sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
-    //sb->SetScrollbars( 10, 10, w / 10, h / 10 );
+    sc->SetScrollbars( 10, 10, w / 10, h / 10 );
 
     for ( int i = 0; i < 5; i++ ) {
         w *= 1.1;
@@ -383,12 +386,12 @@
 
 void MainFrame::LoadBitmaps( void )
 {
-    int no = 1;
-    LoadBitmap( m_staticBitmap1, wxString::Format( ".cache/%02d_1", no ) );
-    LoadBitmap( m_staticBitmap2, wxString::Format( ".cache/%02d_2", no ) );
-    LoadBitmap( m_staticBitmap3, wxString::Format( ".cache/%02d_3", no ) );
-    LoadBitmap( m_staticBitmap4, wxString::Format( ".cache/%02d_4", no ) );
-    LoadBitmap( m_staticBitmap5, wxString::Format( ".cache/%02d_5", no ) );
+    int date = 0;
+    LoadBitmap( m_scrolledWindow1, m_staticBitmap1, wxString::Format( ".cache/%08d_1", date ) );
+    LoadBitmap( m_scrolledWindow2, m_staticBitmap2, wxString::Format( ".cache/%08d_2", date ) );
+    LoadBitmap( m_scrolledWindow3, m_staticBitmap3, wxString::Format( ".cache/%08d_3", date ) );
+    LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( ".cache/%08d_4", date ) );
+    LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( ".cache/%08d_5", date ) );
 }
 
 void MainFrame::GetImage( wxString hhs, wxString no )
@@ -396,8 +399,9 @@
     // http get
 }
 
-void MainFrame::InDevelop( void )
+void MainFrame::InDevelop( bool flag )
 {
+    if ( !flag ) return;
     LoadBitmaps();
     
 	m_slider->Enable( false );
@@ -406,7 +410,10 @@
 	m_buttonPrint->Enable( false );
 	m_buttonPrint->Show( false );
 
-	m_button->Enable( false );
-	m_button->Show( false );
+	bool tb = false;
+	m_buttonTest->Enable( tb );
+	m_buttonTest->Show( tb );
+
+	m_searchCtrl->Enable( false );
 }