changeset 3:75fefb53d983

update preview.
author pyon@macmini
date Sat, 09 Apr 2011 12:48:20 +0900
parents 0830b0d7c550
children d924b09ea2f3
files include/common.h include/myframe.h include/preview.h include/symbol.h makefile src/main.cpp src/myframe.cpp src/preview.cpp
diffstat 5 files changed, 122 insertions(+), 83 deletions(-) [+]
line wrap: on
line diff
--- a/include/myframe.h	Thu Apr 07 19:56:47 2011 +0900
+++ b/include/myframe.h	Sat Apr 09 12:48:20 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : myframe.h
-// Last Change: 31-Mar-2011.
+// Last Change: 09-Apr-2011.
 //
 #ifndef MYFRAME
 #define MYFRAME
@@ -84,7 +84,7 @@
     void OnOpenDataDir( wxCommandEvent& event );
     void OnUpdateHhsDb( wxCommandEvent& event );
 
-    //void OnHhsSearch( wxCommandEvent& event ); after version 2.7
+    //void OnHhsSearch( wxCommandEvent& event ); after version 2.11
     void OnMkIndex( wxCommandEvent& event );
     void SaveConfig( wxCloseEvent& event );
 };
--- a/include/preview.h	Thu Apr 07 19:56:47 2011 +0900
+++ b/include/preview.h	Sat Apr 09 12:48:20 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : hhsdb.h
-// Last Change: 07-Apr-2011.
+// Last Change: 09-Apr-2011.
 //
 #ifndef __PREVIEW__
 #define __PREVIEW__
@@ -24,39 +24,45 @@
 #include <wx/frame.h>
 
 ///////////////////////////////////////////////////////////////////////////////
-/// Class MyFramePreview
+/// Class FramePreview
 ///////////////////////////////////////////////////////////////////////////////
-class MyFramePreview : public wxFrame 
+class FramePreview : public wxFrame 
 {
+    DECLARE_EVENT_TABLE()
 	private:
 	
 	protected:
-		wxStaticText* m_staticText1;
-		wxStaticBitmap* m_bitmap1;
-		wxStaticText* m_staticText2;
-		wxStaticBitmap* m_bitmap2;
-		wxStaticText* m_staticText3;
-		wxStaticBitmap* m_bitmap3;
-		wxStaticText* m_staticText4;
-		wxStaticBitmap* m_bitmap4;
-		wxStaticText* m_staticText5;
-		wxStaticBitmap* m_bitmap5;
-		wxScrolledWindow* m_scrolledWindow;
-		wxStaticBitmap* m_bitmap;
-		wxStaticText* m_staticText;
-		wxTextCtrl* m_textCtrl;
-		wxStaticText* m_staticTextLarge;
-		wxSlider* m_slider;
-		wxStaticText* m_staticTextSmall;
-		
-		wxButton* m_buttonPrint;
-		wxButton* m_buttonPrintAll;
-		wxButton* m_buttonClose;
+		wxStaticText*	    m_staticText1;
+		wxStaticBitmap*		m_bitmap1;
+		wxStaticText*		m_staticText2;
+		wxStaticBitmap*		m_bitmap2;
+		wxStaticText*		m_staticText3;
+		wxStaticBitmap*		m_bitmap3;
+		wxStaticText*		m_staticText4;
+		wxStaticBitmap*		m_bitmap4;
+		wxStaticText*		m_staticText5;
+		wxStaticBitmap*		m_bitmap5;
+
+		wxScrolledWindow*	m_scrolledWindow;
+		wxStaticBitmap*		m_bitmap;
+
+		wxStaticText*		m_staticText;
+		wxTextCtrl*	    	m_textCtrl;
+		wxStaticText*		m_staticTextLarge;
+		wxSlider*	    	m_slider;
+		wxStaticText*		m_staticTextSmall;
+		wxButton*	        m_buttonPrint;
+		wxButton*       	m_buttonPrintAll;
+		wxButton*       	m_buttonClose;
 	
 	public:
 		
-		MyFramePreview( wxWindow* parent, wxWindowID id = ID_IMGFRM, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 512,394 ), long style = wxCAPTION|wxFRAME_NO_TASKBAR|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxTAB_TRAVERSAL );
-		~MyFramePreview();
+		FramePreview( wxWindow* parent, wxWindowID id = ID_IMGFRM, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 512,394 ), long style = wxCAPTION|wxFRAME_NO_TASKBAR|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxTAB_TRAVERSAL );
+		~FramePreview();
+
+        void CloseFrame(wxCommandEvent&);
+        void LoadImages(wxString);
+        void SetThumbnail(wxStaticText*, wxStaticBitmap*, wxString, wxString);
 	
 };
 
--- a/src/main.cpp	Thu Apr 07 19:56:47 2011 +0900
+++ b/src/main.cpp	Sat Apr 09 12:48:20 2011 +0900
@@ -1,10 +1,11 @@
 // Filename   : main.cpp
-// Last Change: 08-Mar-2011.
+// Last Change: 09-Apr-2011.
 //
 
 #include "common.h"
 #include "main.h"
 #include "myframe.h"
+#include "preview.h"
 
 IMPLEMENT_APP(MyApp)
 
@@ -21,11 +22,18 @@
 {
     if ( !wxApp::OnInit() ) return false;
 
+    wxImage::AddHandler( new wxJPEGHandler );
+
     ConfInit();
 
+    /*
     MyFrame *mainframe = new MyFrame( NULL, ID_MAIN, wxT("Searcher v2") );
     mainframe->SetSize( rect );
     mainframe->Show(true);
+    */
+
+    FramePreview *a = new FramePreview( NULL, ID_IMGFRM, wxEmptyString, wxDefaultPosition, wxSize( 512,394 ), wxCAPTION|wxFRAME_NO_TASKBAR|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxTAB_TRAVERSAL );
+    a->Show(true);
 
     return true;
 }
--- a/src/myframe.cpp	Thu Apr 07 19:56:47 2011 +0900
+++ b/src/myframe.cpp	Sat Apr 09 12:48:20 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : mainframe.cpp
-// Last Change: 07-Apr-2011.
+// Last Change: 09-Apr-2011.
 //
 
 #include "symbol.h"
@@ -226,7 +226,7 @@
             htmlbody += wxT(" ( ") + hhs + wxT(" )");
             htmlbody += wxT("<br /><br />検索結果");
             htmlbody += wxT("<table border=1>");
-            htmlbody += wxT("<tr bgcolor=\"#ffcc33\"><th>番号</th><th>日付</th><th>フォルダ</th><th>操作</th></tr>");
+            htmlbody += wxT("<tr bgcolor=\"#ffcc33\"><th>番号</th><th>日付</th><th>フォルダ</th></tr>");
 
             wxRegEx reDate(wxT("(^.*20[0-9]{2}.)(20[0-9]{2})([0-2][0-9])([0-9]{2})(.*$)"));
 
@@ -248,9 +248,6 @@
                 htmlbody += wxT("<td align=\"center\">") + wxString::Format(wxT("%d"),i++) + wxT("</td>");  // 番号
                 htmlbody += wxT("<td>") + date + wxT("</td>");  // 日付
                 htmlbody += wxT("<td>") + q.GetString(0) + wxT("</td></tr>"); // フォルダパス
-                //htmlbody += wxT("<td>") + wxT("プレビュー") + wxT("</td></tr>");
-                //htmlbody += wxT("<td>") + wxT("印刷") + wxT("</td></tr>");
-                //htmlbody += wxT("<td>") + wxT("フォルダを開く") + wxT("</td></tr>");
             }
             stmt.Finalize();
             ccndb.Close();
@@ -401,7 +398,7 @@
 	wxBoxSizer* bSizerHead;
 	bSizerHead = new wxBoxSizer( wxHORIZONTAL );
 	
-    /* after version 2.7
+    /* after version 2.11
 	m_staticTextHname = new wxStaticText( m_panelHead, wxID_ANY, wxT("氏名カナ検索"), wxDefaultPosition, wxDefaultSize, 0 );
 	bSizerHead->Add( m_staticTextHname, 0, wxALL, 5 );
 	
@@ -439,7 +436,7 @@
 	m_html = new wxHtmlWindow( m_splitter, ID_HTML, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
     m_html->LoadPage( wxT("html/start.html") );
 	
-    /* after version 2.7
+    /* after version 2.11
 	// 被保険者カナ検索Grid
 	m_gridHhs = new wxGrid( m_panelHtml, ID_HLST, wxDefaultPosition, wxDefaultSize, 0 );
 	m_gridHhs->CreateGrid( 0, 5 );
@@ -532,7 +529,7 @@
     EVT_MENU( ID_MODD,    MyFrame::OnOpenDataDir )
     EVT_MENU( ID_MHELP,   MyFrame::OnHelp )
 
-	//EVT_TEXT_ENTER( ID_SRCHHHS, MyFrame::OnHhsSearch ) after version 2.7
+	//EVT_TEXT_ENTER( ID_SRCHHHS, MyFrame::OnHhsSearch ) after version 2.11
     EVT_BUTTON( ID_MKIDX, MyFrame::OnMkIndex )
 
     EVT_CLOSE( MyFrame::SaveConfig )
@@ -576,7 +573,7 @@
 }
 
 /* 被保険者検索 */
-/* after version 2.7
+/* after version 2.11
 void MyFrame::OnHhsSearch(wxCommandEvent& WXUNUSED(event))
 {
     this->m_html->Hide();
--- a/src/preview.cpp	Thu Apr 07 19:56:47 2011 +0900
+++ b/src/preview.cpp	Sat Apr 09 12:48:20 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : preview.cpp
-// Last Change: 07-Apr-2011.
+// Last Change: 09-Apr-2011.
 //
 
 #include "preview.h"
@@ -8,95 +8,74 @@
 // need because it includes almost all "standard" wxWidgets headers)
 #ifndef WX_PRECOMP
     #include "wx/utils.h"
+    #include "wx/dir.h"
 #endif
 
 
-
-MyFramePreview::MyFramePreview( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
+// constructor
+FramePreview::FramePreview( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
 {
-	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
+	this->SetSize( 1600, 900 );
 	
 	wxBoxSizer* bSizer;
 	bSizer = new wxBoxSizer( wxHORIZONTAL );
 	
+    // LeftPain ( thumbnail )
 	wxBoxSizer* bSizerL;
 	bSizerL = new wxBoxSizer( wxVERTICAL );
 	
-	m_staticText1 = new wxStaticText( this, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );
-	m_staticText1->Wrap( -1 );
-	bSizerL->Add( m_staticText1, 0, wxALL, 5 );
-	
+	m_staticText1 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerL->Add( m_staticText1, 0, wxTOP|wxALIGN_CENTRE, 5 );
 	m_bitmap1 = new wxStaticBitmap( this, ID_IMG1, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
-	bSizerL->Add( m_bitmap1, 0, wxALL, 5 );
-	
-	m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );
-	m_staticText2->Wrap( -1 );
-	bSizerL->Add( m_staticText2, 0, wxALL, 5 );
-	
+	bSizerL->Add( m_bitmap1, 0, wxALL|wxALIGN_CENTRE, 5 );
+	m_staticText2 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerL->Add( m_staticText2, 0, wxTOP|wxALIGN_CENTRE, 5 );
 	m_bitmap2 = new wxStaticBitmap( this, ID_IMG2, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
-	bSizerL->Add( m_bitmap2, 0, wxALL, 5 );
-	
-	m_staticText3 = new wxStaticText( this, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );
-	m_staticText3->Wrap( -1 );
-	bSizerL->Add( m_staticText3, 0, wxALL, 5 );
-	
+	bSizerL->Add( m_bitmap2, 0, wxALL|wxALIGN_CENTRE, 5 );
+	m_staticText3 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerL->Add( m_staticText3, 0, wxTOP|wxALIGN_CENTRE, 5 );
 	m_bitmap3 = new wxStaticBitmap( this, ID_IMG3, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
-	bSizerL->Add( m_bitmap3, 0, wxALL, 5 );
-	
-	m_staticText4 = new wxStaticText( this, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );
-	m_staticText4->Wrap( -1 );
-	bSizerL->Add( m_staticText4, 0, wxALL, 5 );
-	
+	bSizerL->Add( m_bitmap3, 0, wxALL|wxALIGN_CENTRE, 5 );
+	m_staticText4 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerL->Add( m_staticText4, 0, wxTOP|wxALIGN_CENTRE, 5 );
 	m_bitmap4 = new wxStaticBitmap( this, ID_IMG4, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
-	bSizerL->Add( m_bitmap4, 0, wxALL, 5 );
-	
-	m_staticText5 = new wxStaticText( this, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );
-	m_staticText5->Wrap( -1 );
-	bSizerL->Add( m_staticText5, 0, wxALL, 5 );
-	
+	bSizerL->Add( m_bitmap4, 0, wxALL|wxALIGN_CENTRE, 5 );
+	m_staticText5 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerL->Add( m_staticText5, 0, wxTOP|wxALIGN_CENTRE, 5 );
 	m_bitmap5 = new wxStaticBitmap( this, ID_IMG5, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
-	bSizerL->Add( m_bitmap5, 0, wxALL, 5 );
+	bSizerL->Add( m_bitmap5, 0, wxALL|wxALIGN_CENTRE, 5 );
 	
 	bSizer->Add( bSizerL, 0, wxEXPAND, 5 );
 	
+    // MainPain ( preview )
 	m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
 	m_scrolledWindow->SetScrollRate( 5, 5 );
 	bSizer->Add( m_scrolledWindow, 1, wxEXPAND | wxALL, 5 );
-	
 	m_bitmap = new wxStaticBitmap( this, ID_IMG, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
 	bSizer->Add( m_bitmap, 0, wxALL, 5 );
 	
+    // RightPain ( manip )
 	wxBoxSizer* bSizerR;
 	bSizerR = new wxBoxSizer( wxVERTICAL );
 	
 	m_staticText = new wxStaticText( this, wxID_ANY, wxT("倍率"), wxDefaultPosition, wxDefaultSize, 0 );
-	m_staticText->Wrap( -1 );
 	bSizerR->Add( m_staticText, 0, wxALL, 5 );
-	
 	m_textCtrl = new wxTextCtrl( this, ID_MGNFY, wxT("100%"), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
 	m_textCtrl->SetMaxLength( 4 ); 
 	bSizerR->Add( m_textCtrl, 0, wxALL, 5 );
-	
 	m_staticTextLarge = new wxStaticText( this, wxID_ANY, wxT("[+]"), wxDefaultPosition, wxDefaultSize, 0 );
-	m_staticTextLarge->Wrap( -1 );
 	bSizerR->Add( m_staticTextLarge, 0, wxALL, 5 );
-	
 	m_slider = new wxSlider( this, ID_SLDR, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LEFT|wxSL_VERTICAL );
 	bSizerR->Add( m_slider, 0, wxALL, 5 );
-	
 	m_staticTextSmall = new wxStaticText( this, wxID_ANY, wxT("[-]"), wxDefaultPosition, wxDefaultSize, 0 );
-	m_staticTextSmall->Wrap( -1 );
 	bSizerR->Add( m_staticTextSmall, 0, wxALL, 5 );
 	
-	
 	bSizerR->Add( 0, 0, 1, wxEXPAND, 5 );
 	
 	m_buttonPrint = new wxButton( this, ID_PRINT, wxT("印刷"), wxDefaultPosition, wxDefaultSize, 0 );
 	bSizerR->Add( m_buttonPrint, 0, wxALL, 5 );
-	
 	m_buttonPrintAll = new wxButton( this, ID_PRTALL, wxT("一括印刷"), wxDefaultPosition, wxDefaultSize, 0 );
 	bSizerR->Add( m_buttonPrintAll, 0, wxALL, 5 );
-	
 	m_buttonClose = new wxButton( this, ID_CLSFRM, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 );
 	bSizerR->Add( m_buttonClose, 0, wxALL, 5 );
 	
@@ -106,9 +85,58 @@
 	this->Layout();
 	
 	this->Centre( wxBOTH );
+
+    LoadImages( wxEmptyString );
 }
 
-MyFramePreview::~MyFramePreview()
+// destructor
+FramePreview::~FramePreview()
 {
 }
 
+// Event Table
+BEGIN_EVENT_TABLE( FramePreview, wxFrame )
+    //EVT_BUTTON( ID_PRINT,  FramePreview::PrintImage )
+    //EVT_BUTTON( ID_PRTALL, FramePreview::PrintAllImages )
+    EVT_BUTTON( ID_CLSFRM, FramePreview::CloseFrame )
+END_EVENT_TABLE()
+
+// Event Handlers
+void FramePreview::CloseFrame(wxCommandEvent& WXUNUSED(event))
+{
+    this->Close();
+    return;
+}
+
+// Functions
+void FramePreview::LoadImages(wxString path)
+{
+    path = wxGetCwd() + wxT("/testdrive");  // now test!
+    wxDir dir(path);
+    wxString file;
+    if ( !dir.IsOpened() ) return;
+
+    bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES );
+    SetThumbnail( this->m_staticText1, this->m_bitmap1, path, file );
+    dir.GetNext( &file );
+    SetThumbnail( this->m_staticText2, this->m_bitmap2, path, file );
+    dir.GetNext( &file );
+    SetThumbnail( this->m_staticText3, this->m_bitmap3, path, file );
+    dir.GetNext( &file );
+    SetThumbnail( this->m_staticText4, this->m_bitmap4, path, file );
+    dir.GetNext( &file );
+    SetThumbnail( this->m_staticText5, this->m_bitmap5, path, file );
+
+    return;
+}
+
+void FramePreview::SetThumbnail( wxStaticText* st, wxStaticBitmap* sb, wxString path, wxString file )
+{
+    st->SetLabel(file);
+    file = path + wxFILE_SEP_PATH + file;
+    wxImage img( file, wxBITMAP_TYPE_JPEG );
+    wxBitmap bmp( img.Scale( 105, 148, wxIMAGE_QUALITY_HIGH ) );
+    sb->SetBitmap( bmp );
+
+    return;
+}