changeset 9:b455f2d8aac9

Implement Preview.
author pyon@macmini
date Thu, 24 Apr 2014 18:31:39 +0900
parents 4967d1e2b30c
children 29021e6e1ebe
files Changes Makefile TODO doc/Searcher 03 の新機能.docx doc/Searcher 03 の新機能.pdf image/thumbnail.png include/common.h include/db.h include/myframe.h include/preview.h src/db.cpp src/myframe.cpp src/preview.cpp
diffstat 13 files changed, 461 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Fri Nov 01 18:44:37 2013 +0900
+++ b/Changes	Thu Apr 24 18:31:39 2014 +0900
@@ -1,3 +1,9 @@
+version 03.10
+2014-05-01
+ Suggestion function comes back.
+ Implement thumbmail view & preview.
+
+----
 version 03.09
 2013-11-01
  Fixed bug.
--- a/Makefile	Fri Nov 01 18:44:37 2013 +0900
+++ b/Makefile	Thu Apr 24 18:31:39 2014 +0900
@@ -1,5 +1,5 @@
 # Makefile for wxWidgets Application
-# Last Change: 11-Sep-2013.
+# Last Change: 05-Feb-2014.
 # by Takayuki Mutoh
 #
 
@@ -13,8 +13,8 @@
 
 # For Microsoft Windows
 ifdef COMSPEC
-WXCXXFLAGS = -I/local/lib/wx/include/msw-unicode-static-2.9 -I/local/include/wx-2.9 -D_LARGEFILE_SOURCE=unknown -D__WXMSW__ -mthreads
-WXLIBS = -L/local/lib -Wl,--subsystem,windows -mwindows /local/lib/libwx_mswu_richtext-2.9.a /local/lib/libwx_mswu_xrc-2.9.a /local/lib/libwx_mswu_webview-2.9.a /local/lib/libwx_mswu_qa-2.9.a /local/lib/libwx_baseu_net-2.9.a /local/lib/libwx_mswu_html-2.9.a /local/lib/libwx_mswu_adv-2.9.a /local/lib/libwx_mswu_core-2.9.a /local/lib/libwx_baseu_xml-2.9.a /local/lib/libwx_baseu-2.9.a -lwxregexu-2.9 -lwxexpat-2.9 -lwxtiff-2.9 -lwxjpeg-2.9 -lwxpng-2.9 -lwxzlib-2.9 -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32
+WXCXXFLAGS = -I/local/lib/wx/include/msw-unicode-static-3.0 -I/local/include/wx-3.0 -D_LARGEFILE_SOURCE=unknown -D__WXMSW__ -mthreads
+WXLIBS = -L/local/lib -Wl,--subsystem,windows -mwindows /local/lib/libwx_mswu_richtext-3.0.a /local/lib/libwx_mswu_xrc-3.0.a /local/lib/libwx_mswu_webview-3.0.a /local/lib/libwx_mswu_qa-3.0.a /local/lib/libwx_baseu_net-3.0.a /local/lib/libwx_mswu_html-3.0.a /local/lib/libwx_mswu_adv-3.0.a /local/lib/libwx_mswu_core-3.0.a /local/lib/libwx_baseu_xml-3.0.a /local/lib/libwx_baseu-3.0.a -lwxregexu-3.0 -lwxexpat-3.0 -lwxtiff-3.0 -lwxjpeg-3.0 -lwxpng-3.0 -lwxzlib-3.0 -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32
 EXECUTABLE = $(PROGNAME).exe
 
 # For Apple OSX
@@ -37,6 +37,7 @@
 	  $(OBJDIR)/hist.o \
 	  $(OBJDIR)/index.o \
 	  $(OBJDIR)/param.o \
+	  $(OBJDIR)/preview.o \
 	  $(OBJDIR)/bprint.o \
 	  $(OBJDIR)/db.o \
 	  $(OBJDIR)/marksheet.o \
@@ -83,6 +84,12 @@
 $(OBJDIR)/param.o: param.cpp param.h common.h
 	$(CXX) -c $< -o $@ $(CXXFLAGS)
 
+$(OBJDIR)/thumbnail.o: thumbnail.cpp thumbnail.h common.h
+	$(CXX) -c $< -o $@ $(CXXFLAGS)
+
+$(OBJDIR)/preview.o: preview.cpp preview.h common.h
+	$(CXX) -c $< -o $@ $(CXXFLAGS)
+
 $(OBJDIR)/bprint.o: bprint.cpp bprint.h marksheet.h common.h dndfile.h
 	$(CXX) -c $< -o $@ $(CXXFLAGS)
 
@@ -99,7 +106,7 @@
 # for icon
 ifdef COMSPEC
 $(OBJDIR)/sample_rc.o: sample.rc
-	windres -i sample.rc -o $@ -I/local/include/wx-2.9
+	windres -i sample.rc -o $@ -I/local/include/wx-3.0
 endif
 
 $(EXECUTABLE): $(PROGNAME)
--- a/TODO	Fri Nov 01 18:44:37 2013 +0900
+++ b/TODO	Thu Apr 24 18:31:39 2014 +0900
@@ -1,4 +1,6 @@
 /*====================*/
 /* TODO               */
 /*====================*/
-Right-Click Menu ( Print, Adapt Height, Adapt Width, x %, ... )
+
+1. manual mask dialog
+
Binary file doc/Searcher 03 の新機能.docx has changed
Binary file doc/Searcher 03 の新機能.pdf has changed
Binary file image/thumbnail.png has changed
--- a/include/common.h	Fri Nov 01 18:44:37 2013 +0900
+++ b/include/common.h	Thu Apr 24 18:31:39 2014 +0900
@@ -1,5 +1,5 @@
 // Filename   : common.h
-// Last Change: 23-Aug-2013.
+// Last Change: 23-Apr-2014.
 //
 #ifndef __COMMON_H__
 #define __COMMON_H__
--- a/include/db.h	Fri Nov 01 18:44:37 2013 +0900
+++ b/include/db.h	Thu Apr 24 18:31:39 2014 +0900
@@ -1,5 +1,5 @@
 // Filename   : db.h
-// Last Change: 01-Nov-2013.
+// Last Change: 05-Feb-2014.
 //
 #ifndef __DB_H__
 #define __DB_H__
@@ -8,10 +8,14 @@
 
 // 被保番で被保険者情報を取得
 wxString GetHhsInfoByHhsNo( wxString hhsno );
+// 被保険者番号リストから氏名を取得
+wxArrayString GetHhsInfoByHhsNoList( wxArrayString hhsno );
 // 氏名カナで被保険者を検索
 wxArrayString GetHhsInfoByKana( wxString kana, bool fuzzy );
 // 被保険者番号からファイルパスを取得
 wxArrayString GetPathByHhsNo( wxString hhsno );
+// 審査会情報のある被保険者を取得
+wxArrayString GetJudgedHhsNo( void );
 // 被保険者番号リストから氏名と最新ファイルパスを取得
 wxArrayString GetHhsInfoAndPathByHhsNoList( wxArrayString hhsno );
 /* 被保険者が審査会にかかったかどうか */
--- a/include/myframe.h	Fri Nov 01 18:44:37 2013 +0900
+++ b/include/myframe.h	Thu Apr 24 18:31:39 2014 +0900
@@ -1,5 +1,5 @@
 // Filename   : myframe.h
-// Last Change: 13-Sep-2013.
+// Last Change: 23-Apr-2014.
 //
 #ifndef __MYFRAME_H__
 #define __MYFRAME_H__
@@ -13,14 +13,45 @@
 {
     DECLARE_EVENT_TABLE()
 	private:
+        wxArrayString m_jhhsno;
 
 	public:
 		MySearchBox( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style );
 		~MySearchBox();
 
         void OnKey( wxKeyEvent& event );
+        void SetJudgedHhs( wxArrayString jhhsno ) { m_jhhsno = jhhsno; };
+        void SetMessage( wxString msg );
 };
 
+///////////////////////////////////////////////////////////////
+// サムネイルパネル
+class ThumbnailPanel : public wxPanel 
+{
+	private:
+        wxArrayString m_imagefiles;
+	
+	protected:
+		wxStaticBitmap* m_bitmap0;
+		wxStaticBitmap* m_bitmap1;
+		wxStaticBitmap* m_bitmap2;
+		wxStaticBitmap* m_bitmap3;
+		wxStaticBitmap* m_bitmap4;
+		wxStaticBitmap* m_bitmap5;
+	
+	public:
+		ThumbnailPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ); 
+		~ThumbnailPanel();
+
+        void OnDClick0( wxMouseEvent& event );
+        void OnDClick1( wxMouseEvent& event );
+        void OnDClick2( wxMouseEvent& event );
+        void OnDClick3( wxMouseEvent& event );
+        void OnDClick4( wxMouseEvent& event );
+        void OnDClick5( wxMouseEvent& event );
+        void SetImages( wxString dirpath );	
+        void Preview( int n );
+};
 
 ///////////////////////////////////////////////////////////////
 // メインフレーム
@@ -44,40 +75,38 @@
 		wxMenuBar*        m_menubar;
 		wxMenu*           m_menuFile;
 		wxMenu*           m_menuParam;
-		wxSplitterWindow* m_splitter;
 		wxPanel*          m_panelMain;
-		wxPanel*          m_panelView;
 		wxStaticBitmap*   m_bitmap;
 		wxTextCtrl*       m_textCtrlName;
 		wxTextCtrl*       m_textCtrlAddr;
 		wxListCtrl*       m_listCtrl;
-		wxStaticText*     m_staticText;
+        ThumbnailPanel*   m_thumbPanel;
+		wxStaticText*     m_staticText; // コマンド?
 		MySearchBox*      m_searchBox;
 		wxButton*         m_buttonKana;
 		wxButton*         m_buttonHist;
-        wxStaticBitmap*   m_bitmapView;
-        wxListCtrl*       m_listCtrlThumb;
 		wxStatusBar*      m_statusBar;
 	
 	public:
-		
 		MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style );
 		~MyFrame();
 		
         void OnBPrintMode( wxCommandEvent& WXUNUSED(event) );
-        void OnViewStyle( wxCommandEvent& event );
         void OnIndex( wxCommandEvent& WXUNUSED(event) );
         void LoadParam( void );
         void OnDBBackup( wxCommandEvent& WXUNUSED(event) );
         void OnMaskParam( wxCommandEvent& WXUNUSED(event) );
         void OnMarkParam( wxCommandEvent& WXUNUSED(event) );
         void OnOpenAppDir( wxCommandEvent& WXUNUSED(event) );
-        void OnSelectHhsDir( wxListEvent& event );
+        void OpenAppDir( void );
+        void OnDClickItem( wxListEvent& event );
+        void OnSelectItem( wxListEvent& event );
         void OpenHhsDir( int n );
         void OnKana( wxCommandEvent& WXUNUSED(event) );
         void OnHistory( wxCommandEvent& WXUNUSED(event) );
         void OnCommand( wxCommandEvent& WXUNUSED(event) );
         void UpdateList( wxString hhsno );
+        void UpdateThumbmail( int n );
         void PrintImages( wxString hhsno );
         void SetParams( int tab );
 
@@ -91,16 +120,26 @@
 };
 
 enum {
-    ID_MNVIEW = wxID_HIGHEST + 10,
-    ID_MNBPNT,
+    ID_MNBPNT = wxID_HIGHEST + 10,
     ID_MNINDEX,
     ID_MNDBBKUP,
     ID_MNMASKPARAM,
     ID_MNMARKPARAM,
     ID_MNAPPDIR,
     ID_MNABOUT,
+
     ID_LIST,
+
+    ID_THUMB,
+    ID_THBMP0,
+    ID_THBMP1,
+    ID_THBMP2,
+    ID_THBMP3,
+    ID_THBMP4,
+    ID_THBMP5,
+
     ID_SEARCH,
+
     ID_KANA,
     ID_HIST,
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/preview.h	Thu Apr 24 18:31:39 2014 +0900
@@ -0,0 +1,39 @@
+// Filename   : preview.h
+// Last Change: 23-Apr-2014.
+//
+
+#ifndef __PREVIEW_H__
+#define __PREVIEW_H__
+
+#include "common.h"
+
+class PreviewDialog : public wxDialog 
+{
+    DECLARE_EVENT_TABLE()
+	private:
+        wxImageList*      m_imageList;
+        wxString          m_preview;
+        wxString          m_dir;
+	
+	protected:
+        wxScrolledWindow* m_scrolledWindow;
+		wxStaticBitmap*   m_bitmap;
+        wxListCtrl*       m_listCtrl;
+		wxButton*         m_buttonPrint;
+		wxButton*         m_buttonClose;
+	
+	public:
+		PreviewDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ); 
+		~PreviewDialog();
+	
+        void SetImage( wxString file );
+        void OnPrint( wxCommandEvent& event );
+};
+
+enum {
+    ID_PRINT = wxID_HIGHEST + 80,
+    ID_PLIST,
+};
+
+#endif //__PREVIEW_H__
+
--- a/src/db.cpp	Fri Nov 01 18:44:37 2013 +0900
+++ b/src/db.cpp	Thu Apr 24 18:31:39 2014 +0900
@@ -1,5 +1,5 @@
 // Filename   : db.cpp
-// Last Change: 01-Nov-2013.
+// Last Change: 16-Apr-2014.
 //
 
 #include "db.h"
@@ -35,6 +35,39 @@
     }
 }
 
+// 被保険者番号リストから氏名を取得
+wxArrayString GetHhsInfoByHhsNoList( wxArrayString hhsno )
+{
+    wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("hhs.db");
+    wxSQLite3Database hhsdb;
+    hhsdb.Open( gszFile );
+
+    wxString sql = wxT( "SELECT name FROM hhs_master WHERE hhsno = ?;" );
+    wxSQLite3Statement stmt;
+    wxSQLite3ResultSet q;
+
+    wxArrayString result;
+    for ( unsigned int i = 0; i < hhsno.GetCount(); i++ ) {
+        wxString str = hhsno[i];
+        str.Append( wxT("_") );
+
+        stmt = hhsdb.PrepareStatement( sql );
+        stmt.Bind( 1, hhsno[i] );
+        q = stmt.ExecuteQuery();
+        if ( !q.IsNull(0) ) {
+            while ( q.NextRow() ) {
+                str.Append( q.GetString(0) );
+            }
+        }
+
+        result.Add( str );
+    }
+    stmt.Finalize();
+    hhsdb.Close();
+
+    return result;
+}
+
 // 氏名カナで被保険者情報を検索
 wxArrayString GetHhsInfoByKana( wxString kana, bool fuzzy )
 {
@@ -99,6 +132,31 @@
     return path;
 }
 
+// 審査会情報のある被保険者を取得
+wxArrayString GetJudgedHhsNo( void )
+{
+    wxArrayString hhsno;
+
+    wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db");
+    wxSQLite3Database ccndb;
+    ccndb.Open( gszFile );
+
+    //wxString sql = wxT( "SELECT DISTINCT hhsno FROM path;" );
+    wxString sql = wxT( "SELECT hhsno FROM path ORDER BY path DESC LIMIT 200;" );
+    wxSQLite3Statement stmt = ccndb.PrepareStatement( sql );
+    wxSQLite3ResultSet q = stmt.ExecuteQuery();
+
+    if ( !q.IsNull(0) ) {
+        while ( q.NextRow() ) {
+            hhsno.Add( q.GetString(0) );
+        }
+    }
+    stmt.Finalize();
+    ccndb.Close();
+
+    return hhsno;
+}
+
 /* 被保険者が審査会にかかったかどうか */
 bool IsHhsJudged( wxString hhsno ) 
 {
--- a/src/myframe.cpp	Fri Nov 01 18:44:37 2013 +0900
+++ b/src/myframe.cpp	Thu Apr 24 18:31:39 2014 +0900
@@ -1,17 +1,19 @@
 // Filename   : myframe.cpp
-// Last Change: 01-Nov-2013.
+// Last Change: 24-Apr-2014.
 //
 #include "main.h"
 #include "db.h"
 #include "about.h"
 #include "kana.h"
 #include "hist.h"
+#include "preview.h"
 #include "index.h"
 #include "param.h"
 #include "marksheet.h"
 #include "myframe.h"
 #include "bprint.h"
 
+
 ///////////////////////////////////////////////////////////////
 // カスタム検索ボックス
 MySearchBox::MySearchBox( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style )
@@ -23,6 +25,12 @@
 {
 }
 
+void MySearchBox::SetMessage( wxString msg )
+{
+    wxFrame* p = (wxFrame*)FindWindowById( ID_MAIN );
+    p->SetStatusText( msg, 0 );
+}
+
 // Event Table
 BEGIN_EVENT_TABLE( MySearchBox, wxSearchCtrl )
     EVT_CHAR( MySearchBox::OnKey )
@@ -31,10 +39,15 @@
 // Event Handlers & Functions
 void MySearchBox::OnKey( wxKeyEvent& event )
 {
+    int kc = event.GetKeyCode();
     wxString s = GetValue();
-    // statustext( s.Len() );
 
-    if ( event.GetKeyCode() == 45 ) {   // テンキーの '-' キーで1文字削除
+    if ( kc == 13 ) {
+        event.Skip();
+        return;
+    }
+
+    if (  kc == 45 ) {   // テンキーの '-' キーで1文字削除
         wxString t = GetStringSelection();
         if ( t.IsEmpty() ) {
             long p = GetInsertionPoint();
@@ -46,14 +59,138 @@
         return;
     }
 
-    if ( event.GetKeyCode() == WXK_ESCAPE ) {    // clear by ESC
+    if ( kc == WXK_ESCAPE ) {    // clear by ESC
         this->Clear();
         return;
     }
 
+    // auto-complete
+    Cut();
+    if ( kc >=48 && kc<=57 ) { // [0-9]
+        kc -= 48;
+        wxString input = GetValue() + wxString::Format( wxT("%d"), kc );
+        if ( input.Len() < 5 ) {
+            event.Skip();
+            return;
+        }
+        for ( unsigned int i = 0; i < m_jhhsno.GetCount(); i++ ) {
+            if ( m_jhhsno[i].StartsWith( input ) ) {
+                ChangeValue( m_jhhsno[i] );
+                SetSelection( input.Len(), 10 );
+
+                wxArrayString s = wxSplit( GetHhsInfoByHhsNo( m_jhhsno[i] ), '_', '\\' );
+                wxString msg = wxT("もしかして... ") + s[0] + wxT(" ?!");
+                SetMessage( msg );
+                return;
+            }
+            SetMessage( wxEmptyString );
+        }
+        event.Skip();
+        return;
+    }
     event.Skip();
 }
 
+///////////////////////////////////////////////////////////////
+// サムネイルパネル
+#define THUMB_W 60
+#define THUMB_H 75
+ThumbnailPanel::ThumbnailPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) 
+    : wxPanel( parent, id, pos, size, style )
+{
+	wxBoxSizer* bSizer = new wxBoxSizer( wxHORIZONTAL );
+	this->SetBackgroundColour( wxColour( 192, 192, 192 ) );
+
+    wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png");
+    wxBitmap bmp = wxBitmap( thumb, wxBITMAP_TYPE_PNG );
+	
+	m_bitmap0 = new wxStaticBitmap( this, ID_THBMP0, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 );
+	bSizer->Add( m_bitmap0, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+    m_bitmap0->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick0 ), NULL, this );
+	
+	m_bitmap1 = new wxStaticBitmap( this, ID_THBMP1, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 );
+	bSizer->Add( m_bitmap1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+    m_bitmap1->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick1 ), NULL, this );
+	
+	m_bitmap2 = new wxStaticBitmap( this, ID_THBMP2, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 );
+	bSizer->Add( m_bitmap2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+    m_bitmap2->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick2 ), NULL, this );
+	
+	m_bitmap3 = new wxStaticBitmap( this, ID_THBMP3, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 );
+	bSizer->Add( m_bitmap3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+    m_bitmap3->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick3 ), NULL, this );
+	
+	m_bitmap4 = new wxStaticBitmap( this, ID_THBMP4, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 );
+	bSizer->Add( m_bitmap4, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+    m_bitmap4->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick4 ), NULL, this );
+	
+	m_bitmap5 = new wxStaticBitmap( this, ID_THBMP5, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 );
+	bSizer->Add( m_bitmap5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
+    m_bitmap5->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick5 ), NULL, this );
+	
+	this->SetSizer( bSizer );
+	this->Layout();
+}
+
+ThumbnailPanel::~ThumbnailPanel()
+{
+    m_bitmap0->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick0 ), NULL, this );
+    m_bitmap1->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick1 ), NULL, this );
+    m_bitmap2->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick2 ), NULL, this );
+    m_bitmap3->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick3 ), NULL, this );
+    m_bitmap4->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick4 ), NULL, this );
+    m_bitmap5->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick5 ), NULL, this );
+}
+
+// Functions
+/* サムネイル表示 */
+void ThumbnailPanel::SetImages( wxString dirpath )
+{
+    wxDir dir( dirpath );
+    if ( !dir.IsOpened() ) return;
+    m_imagefiles.Clear();
+    wxDir::GetAllFiles( dirpath, &m_imagefiles, wxT("*.jpg"), wxDIR_FILES );
+
+    wxString cachedir = wxT("cache") + dirpath.AfterLast( ':' );
+    wxDir cdir( cachedir );
+    if ( !cdir.IsOpened() ) return;
+
+    wxArrayString cachefiles;
+    wxDir::GetAllFiles( cachedir, &cachefiles, wxT("*.png"), wxDIR_FILES );
+
+    wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png");
+    int n = cachefiles.GetCount();
+    if ( n < 6 ) {
+        while ( n < 6 ) {
+            cachefiles.Add( thumb );
+            n++;
+        }
+    }
+
+    wxBitmap bmp;
+    bmp.LoadFile( cachefiles[0], wxBITMAP_TYPE_PNG ); m_bitmap0->SetBitmap( bmp );
+    bmp.LoadFile( cachefiles[1], wxBITMAP_TYPE_PNG ); m_bitmap1->SetBitmap( bmp );
+    bmp.LoadFile( cachefiles[2], wxBITMAP_TYPE_PNG ); m_bitmap2->SetBitmap( bmp );
+    bmp.LoadFile( cachefiles[3], wxBITMAP_TYPE_PNG ); m_bitmap3->SetBitmap( bmp );
+    bmp.LoadFile( cachefiles[4], wxBITMAP_TYPE_PNG ); m_bitmap4->SetBitmap( bmp );
+    bmp.LoadFile( cachefiles[5], wxBITMAP_TYPE_PNG ); m_bitmap5->SetBitmap( bmp );
+}
+/* 画像クリックで拡大表示 */
+void ThumbnailPanel::OnDClick0( wxMouseEvent& WXUNUSED(event) ) { Preview( 0 ); }
+void ThumbnailPanel::OnDClick1( wxMouseEvent& WXUNUSED(event) ) { Preview( 1 ); }
+void ThumbnailPanel::OnDClick2( wxMouseEvent& WXUNUSED(event) ) { Preview( 2 ); }
+void ThumbnailPanel::OnDClick3( wxMouseEvent& WXUNUSED(event) ) { Preview( 3 ); }
+void ThumbnailPanel::OnDClick4( wxMouseEvent& WXUNUSED(event) ) { Preview( 4 ); }
+void ThumbnailPanel::OnDClick5( wxMouseEvent& WXUNUSED(event) ) { Preview( 5 ); }
+void ThumbnailPanel::Preview( int n )
+{
+    if ( m_imagefiles.GetCount() < n ) return;
+
+    PreviewDialog* pd = new PreviewDialog( this, wxID_ANY, wxT("プレビュー"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR );
+    pd->Show();
+    pd->Maximize( true );
+    pd->SetImage( m_imagefiles[n] );
+}
 
 ///////////////////////////////////////////////////////////////
 // メインフレーム
@@ -70,9 +207,8 @@
     : wxFrame( parent, id, title, pos, size, style )
 {
 	this->SetSizeHints( wxSize( WINL_W, 500 ), wxDefaultSize );
-	this->SetMinSize( wxSize( WINL_W, 500 ) );
-	this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) );
-    //this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
+	//this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) );
+    this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
 	
     // set the frame icon
     SetIcon(wxICON(sample));
@@ -89,11 +225,6 @@
 
     m_menuFile->AppendSeparator(); // ----
 
-	wxMenuItem* m_menuItemViewStyle = new wxMenuItem( m_menuFile, ID_MNVIEW, wxString( wxT("ビュースタイル\tF10") ) , wxT("Toggle ViewStyle"), wxITEM_CHECK );
-	m_menuFile->Append( m_menuItemViewStyle );
-
-    m_menuFile->AppendSeparator(); // ----
-
 	wxMenuItem* m_menuItemBkup = new wxMenuItem( m_menuFile, ID_MNDBBKUP, wxString( wxT("DBバックアップ(&B)") ) , wxT("Backup databases"), wxITEM_NORMAL );
 	m_menuFile->Append( m_menuItemBkup );
 
@@ -123,12 +254,10 @@
     //
 	wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
 	
-	m_splitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D );
+	m_panelMain = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
+
 	wxBoxSizer* bSizerMain = new wxBoxSizer( wxVERTICAL );
 	
-    // left-pane
-	m_panelMain = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
-	
     wxString logo = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("logo.png");
     wxBitmap bmp = wxBitmap( logo, wxBITMAP_TYPE_PNG );
 	m_bitmap = new wxStaticBitmap( m_panelMain, wxID_ANY, bmp, wxDefaultPosition, wxSize( LOGO_W, LOGO_H ), 0 );
@@ -151,14 +280,19 @@
     itemCol.SetText( wxT("場所") );
     m_listCtrl->InsertColumn( 2, itemCol );
     m_listCtrl->SetColumnWidth( 2, 300 );
-	bSizerMain->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );
+	bSizerMain->Add( m_listCtrl, 1, wxRIGHT|wxLEFT|wxBOTTOM|wxEXPAND, 5 );
+
+    m_thumbPanel = new ThumbnailPanel( m_panelMain, wxID_ANY, wxDefaultPosition, wxSize( -1, 100 ), wxSUNKEN_BORDER );
+	bSizerMain->Add( m_thumbPanel, 0, wxRIGHT|wxLEFT|wxBOTTOM|wxEXPAND, 5 );
 	
+    //
 	wxBoxSizer* bSizerCmd = new wxBoxSizer( wxHORIZONTAL );
 	
 	m_staticText = new wxStaticText( m_panelMain, wxID_ANY, wxT("コマンド?"), wxDefaultPosition, wxDefaultSize, 0 );
 	bSizerCmd->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
 	
 	m_searchBox = new MySearchBox( m_panelMain, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
+    m_searchBox->SetJudgedHhs( GetJudgedHhsNo() );
 	#ifndef __WXMAC__
 	m_searchBox->ShowSearchButton( true );
 	#endif
@@ -172,31 +306,15 @@
 	m_buttonHist = new wxButton( m_panelMain, ID_HIST, wxT("検索履歴"), wxDefaultPosition, wxSize( 65, -1 ), 0 );
 	bSizerCmd->Add( m_buttonHist, 0, wxALL, 5 );
 	
+    //
 	bSizerMain->Add( bSizerCmd, 0, wxEXPAND, 5 );
 	
 	m_panelMain->SetSizer( bSizerMain );
 	m_panelMain->Layout();
 	bSizerMain->Fit( m_panelMain );
-
-    // right-pane
-	m_panelView = new wxPanel( m_splitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
-	wxBoxSizer* bSizerView = new wxBoxSizer( wxHORIZONTAL );
+    bSizerTop->Add( m_panelMain, 1, wxEXPAND|wxALL, 5 );
 
-	m_bitmapView = new wxStaticBitmap( m_panelView, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
-	bSizerView->Add( m_bitmapView, 1, wxALL|wxEXPAND, 5 );
-	
-	m_listCtrlThumb = new wxListCtrl( m_panelView, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_ICON );
-	bSizerView->Add( m_listCtrlThumb, 0, wxALL|wxEXPAND, 5 );
-	
-	m_panelView->SetSizer( bSizerView );
-	m_panelView->Layout();
-	bSizerView->Fit( m_panelView );
-
-    m_panelView->Show( false );
     //
-    m_splitter->Initialize( m_panelMain );
-	bSizerTop->Add( m_splitter, 1, wxEXPAND, 5 );
-	
 	this->SetSizer( bSizerTop );
 	this->Layout();
 
@@ -217,29 +335,34 @@
 
 // Event Table
 BEGIN_EVENT_TABLE( MyFrame, wxFrame )
-    EVT_MENU( ID_MNABOUT, MyFrame::OnAbout )
-    EVT_MENU( wxID_EXIT, MyFrame::OnQuit )
-    EVT_MENU( ID_MNBPNT, MyFrame::OnBPrintMode )
-    EVT_MENU( ID_MNVIEW, MyFrame::OnViewStyle )
-    EVT_MENU( ID_MNINDEX, MyFrame::OnIndex )
-    EVT_MENU( ID_MNDBBKUP, MyFrame::OnDBBackup )
+    EVT_MENU( ID_MNABOUT,     MyFrame::OnAbout )
+    EVT_MENU( wxID_EXIT,      MyFrame::OnQuit )
+    EVT_MENU( ID_MNBPNT,      MyFrame::OnBPrintMode )
+    EVT_MENU( ID_MNINDEX,     MyFrame::OnIndex )
+    EVT_MENU( ID_MNDBBKUP,    MyFrame::OnDBBackup )
     EVT_MENU( ID_MNMASKPARAM, MyFrame::OnMaskParam )
     EVT_MENU( ID_MNMARKPARAM, MyFrame::OnMarkParam )
-    EVT_MENU( ID_MNAPPDIR, MyFrame::OnOpenAppDir )
-    EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnSelectHhsDir )
+    EVT_MENU( ID_MNAPPDIR,    MyFrame::OnOpenAppDir )
+    EVT_LIST_ITEM_SELECTED(  ID_LIST, MyFrame::OnSelectItem )
+    EVT_LIST_ITEM_ACTIVATED( ID_LIST, MyFrame::OnDClickItem )
     EVT_BUTTON( ID_KANA, MyFrame::OnKana )
     EVT_BUTTON( ID_HIST, MyFrame::OnHistory )
+    EVT_TEXT_ENTER( ID_SEARCH, MyFrame::OnCommand )
     EVT_SIZE( MyFrame::OnWinSize )
     EVT_MOVE( MyFrame::OnWinMove )
     EVT_CLOSE( MyFrame::SaveConfig )
-    EVT_TEXT_ENTER( ID_SEARCH, MyFrame::OnCommand )
 END_EVENT_TABLE()
 
 // Event Handlers & Functions
 /* エンターキーフック */
 void MyFrame::OnCommand( wxCommandEvent& event )
 {
-    wxString s = m_searchBox->GetValue();
+    wxString s = m_searchBox->GetLineText(0);
+
+    if ( s.IsSameAs( wxT(".") ) ) {
+        OpenAppDir();
+        return;
+    }
 
     if ( s.IsSameAs( wxT("99") ) ) {
         Close();
@@ -255,6 +378,7 @@
     if ( reHhs.Matches( s ) ) {
         m_hhsno = s;
         UpdateList( m_hhsno );
+        UpdateThumbmail( 0 );
         return;
     }
 
@@ -331,12 +455,13 @@
     config->Read( wxT("lmax"), &lmax );
     config->Read( wxT("zmin"), &zmin );
     config->Read( wxT("zmax"), &zmax );
+
 }
 /* 印刷 */
 void MyFrame::PrintImages( wxString hhsno )
 {
     bool mask_flag = false;
-    wxMessageDialog md( this, wxT("マクスしますか?"), wxT("印刷オプション"), wxYES_NO, wxDefaultPosition );
+    wxMessageDialog md( this, wxT("マスクしますか?"), wxT("印刷オプション"), wxYES_NO, wxDefaultPosition );
     if ( md.ShowModal() == wxID_YES ) {
         mask_flag = true;
     }
@@ -526,29 +651,20 @@
 /* アプリフォルダを開く */
 void MyFrame::OnOpenAppDir( wxCommandEvent& WXUNUSED(event) )
 {
+    OpenAppDir();
+}
+void MyFrame::OpenAppDir( ) 
+{
     wxString appdir = wxGetCwd();
     wxString execmd = wxT("explorer ") + appdir;
     wxExecute( execmd );
 }
-/* ビューの切替え */
-void MyFrame::OnViewStyle( wxCommandEvent& event )
-{
-    if ( event.IsChecked() ) {
-        int x, y;
-        GetSize( &x, &y );
-        SetSize( WINL_W + 500, y );
-        m_splitter->SplitVertically( m_panelMain, m_panelView, 0 );
-    }
-    else {
-        m_splitter->Unsplit();
-        SetSize( WINL_W, -1 );
-    }
-}
 /* 被保険者フォルダを開く */
-void MyFrame::OnSelectHhsDir( wxListEvent& event )
+void MyFrame::OnDClickItem( wxListEvent& event )
 {
     int i = event.GetIndex();
     OpenHhsDir( i );
+    UpdateThumbmail( i );
 }
 /* 番号で指定したフォルダを開く */
 void MyFrame::OpenHhsDir( int n )
@@ -572,6 +688,7 @@
     if ( kana->ShowModal() == wxID_OK ) {
         m_hhsno = kana->GetHhsNo();
         UpdateList( m_hhsno );
+        UpdateThumbmail( 0 );
     }
 }
 /* 検索履歴検索ダイアログ */
@@ -583,6 +700,7 @@
     if ( hist->ShowModal() == wxID_OK ) {
         m_hhsno = hist->GetHhsNo();
         UpdateList( m_hhsno );
+        UpdateThumbmail( 0 );
     }
 }
 
@@ -643,6 +761,23 @@
     hist.Write();
     hist.Close();
 }
+/* フォルダを選択したとき */
+void MyFrame::OnSelectItem( wxListEvent& event )
+{
+    UpdateThumbmail( event.GetIndex() );
+}
+/* サムネイルを更新 */
+void MyFrame::UpdateThumbmail( int n ) 
+{
+    wxListItem item;
+    item.SetId( n );
+
+    item.SetColumn( 2 );
+    item.SetMask( wxLIST_MASK_TEXT );
+    m_listCtrl->GetItem( item );
+
+    m_thumbPanel->SetImages( item.GetText() );
+}
 /* ステータスバーにメッセージを出力 */
 void MyFrame::SetStatusMessage( wxString msg, long n )
 {
@@ -686,6 +821,7 @@
     if ( !IsIconized() && !IsMaximized() ) {
         wxGetApp().rect = this->GetRect();
     }
+    delete config;
     Destroy();
 }
 /* アバウトダイアログ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/preview.cpp	Thu Apr 24 18:31:39 2014 +0900
@@ -0,0 +1,90 @@
+// Filename   : preview.cpp
+// Last Change: 24-Apr-2014.
+//
+
+#include "preview.h"
+#define THUMB_W 60
+#define THUMB_H 75
+
+PreviewDialog::PreviewDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 
+    : wxDialog( parent, id, title, pos, size, style )
+{
+	//this->SetSizeHints( wxDefaultSize, wxDefaultSize );
+	
+	wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL );
+
+    m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxALWAYS_SHOW_SB );
+	m_bitmap = new wxStaticBitmap( m_scrolledWindow, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerTop->Add( m_scrolledWindow, 1, wxALL|wxEXPAND, 5 );
+	
+	wxBoxSizer* bSizerMenu = new wxBoxSizer( wxVERTICAL );
+	
+    /*
+	m_listCtrl = new wxListCtrl( this, ID_PLIST, wxDefaultPosition, wxSize( 140, -1 ), wxLC_ICON );
+    m_imageList = new wxImageList( THUMB_W, THUMB_H );
+    m_listCtrl->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL );
+	bSizerMenu->Add( m_listCtrl, 1, wxRIGHT|wxLEFT|wxBOTTOM|wxEXPAND, 5 );
+    */
+
+	m_buttonPrint = new wxButton( this, ID_PRINT, wxT("印刷"), wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerMenu->Add( m_buttonPrint, 0, wxALL, 5 );
+	bSizerMenu->Add( 0, 0, 1, 0, 5 );
+	
+	m_buttonClose = new wxButton( this, wxID_CANCEL, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 );
+	m_buttonClose->SetDefault(); 
+	bSizerMenu->Add( m_buttonClose, 0, wxALL, 5 );
+
+	bSizerTop->Add( bSizerMenu, 0, wxALL|wxEXPAND, 5 );
+	
+	this->SetSizer( bSizerTop );
+	this->Layout();
+}
+
+PreviewDialog::~PreviewDialog()
+{
+}
+
+// Event Table
+BEGIN_EVENT_TABLE( PreviewDialog, wxDialog )
+    EVT_BUTTON( ID_PRINT, PreviewDialog::OnPrint )
+END_EVENT_TABLE()
+
+#define WIDTH  2480
+#define HEIGHT 3509
+void PreviewDialog::SetImage( wxString file )
+{
+    int w, h;
+    m_scrolledWindow->GetSize( &w, &h );
+    h = h * WIDTH / ( w - 200 );
+
+    wxImage img;
+    img.LoadFile( file, wxBITMAP_TYPE_JPEG );
+    wxBitmap bmp( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) );
+    m_bitmap->SetBitmap( bmp );
+
+    m_scrolledWindow->SetScrollbars( 10, 10, 0, h/10 );
+    m_preview = file;
+}
+
+void PreviewDialog::OnPrint( wxCommandEvent& WXUNUSED(envet) )
+{
+    wxString html;
+    html = html + wxT("<html><body>\n");
+
+    wxString tmpjpg = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("preview.jpg");
+
+    wxCopyFile( m_preview, tmpjpg, true );
+
+    html = html + wxT("<img src=\"") + tmpjpg + wxT("\" width=\"750\" height=\"1060\"/>");
+    html = html + wxT("</body></html>");
+
+    // start printing
+    wxHtmlPrintout hpout( wxT("Searcher03") );
+    hpout.SetMargins( 0, 0, 0, 0, 0 );
+    wxPrintDialogData pd;
+    wxPrinter p( &pd );
+
+    hpout.SetHtmlText( html, wxEmptyString, false );
+    p.Print( NULL, &hpout, true );
+}
+