Mercurial > mercurial > hgweb_searcher03.cgi
comparison src/myframe.cpp @ 10:29021e6e1ebe
Implement thumbnail list in PreviewDialog.
| author | pyon@macmini |
|---|---|
| date | Mon, 28 Apr 2014 18:14:04 +0900 |
| parents | b455f2d8aac9 |
| children | dfcf8c973219 |
comparison
equal
deleted
inserted
replaced
| 9:b455f2d8aac9 | 10:29021e6e1ebe |
|---|---|
| 1 // Filename : myframe.cpp | 1 // Filename : myframe.cpp |
| 2 // Last Change: 24-Apr-2014. | 2 // Last Change: 28-Apr-2014. |
| 3 // | 3 // |
| 4 #include "main.h" | 4 #include "main.h" |
| 5 #include "db.h" | 5 #include "db.h" |
| 6 #include "about.h" | 6 #include "about.h" |
| 7 #include "kana.h" | 7 #include "kana.h" |
| 11 #include "param.h" | 11 #include "param.h" |
| 12 #include "marksheet.h" | 12 #include "marksheet.h" |
| 13 #include "myframe.h" | 13 #include "myframe.h" |
| 14 #include "bprint.h" | 14 #include "bprint.h" |
| 15 | 15 |
| 16 #define DEBUG 1 | |
| 16 | 17 |
| 17 /////////////////////////////////////////////////////////////// | 18 /////////////////////////////////////////////////////////////// |
| 18 // カスタム検索ボックス | 19 // カスタム検索ボックス |
| 19 MySearchBox::MySearchBox( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style ) | 20 MySearchBox::MySearchBox( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style ) |
| 20 : wxSearchCtrl( parent, id, value, pos, size, style ) | 21 : wxSearchCtrl( parent, id, value, pos, size, style ) |
| 102 this->SetBackgroundColour( wxColour( 192, 192, 192 ) ); | 103 this->SetBackgroundColour( wxColour( 192, 192, 192 ) ); |
| 103 | 104 |
| 104 wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); | 105 wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); |
| 105 wxBitmap bmp = wxBitmap( thumb, wxBITMAP_TYPE_PNG ); | 106 wxBitmap bmp = wxBitmap( thumb, wxBITMAP_TYPE_PNG ); |
| 106 | 107 |
| 107 m_bitmap0 = new wxStaticBitmap( this, ID_THBMP0, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); | 108 m_bitmap0 = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); |
| 108 bSizer->Add( m_bitmap0, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 109 bSizer->Add( m_bitmap0, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
| 109 m_bitmap0->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick0 ), NULL, this ); | 110 m_bitmap0->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick0 ), NULL, this ); |
| 110 | 111 |
| 111 m_bitmap1 = new wxStaticBitmap( this, ID_THBMP1, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); | 112 m_bitmap1 = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); |
| 112 bSizer->Add( m_bitmap1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 113 bSizer->Add( m_bitmap1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
| 113 m_bitmap1->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick1 ), NULL, this ); | 114 m_bitmap1->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick1 ), NULL, this ); |
| 114 | 115 |
| 115 m_bitmap2 = new wxStaticBitmap( this, ID_THBMP2, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); | 116 m_bitmap2 = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); |
| 116 bSizer->Add( m_bitmap2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 117 bSizer->Add( m_bitmap2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
| 117 m_bitmap2->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick2 ), NULL, this ); | 118 m_bitmap2->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick2 ), NULL, this ); |
| 118 | 119 |
| 119 m_bitmap3 = new wxStaticBitmap( this, ID_THBMP3, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); | 120 m_bitmap3 = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); |
| 120 bSizer->Add( m_bitmap3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 121 bSizer->Add( m_bitmap3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
| 121 m_bitmap3->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick3 ), NULL, this ); | 122 m_bitmap3->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick3 ), NULL, this ); |
| 122 | 123 |
| 123 m_bitmap4 = new wxStaticBitmap( this, ID_THBMP4, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); | 124 m_bitmap4 = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); |
| 124 bSizer->Add( m_bitmap4, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 125 bSizer->Add( m_bitmap4, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
| 125 m_bitmap4->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick4 ), NULL, this ); | 126 m_bitmap4->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick4 ), NULL, this ); |
| 126 | 127 |
| 127 m_bitmap5 = new wxStaticBitmap( this, ID_THBMP5, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); | 128 m_bitmap5 = new wxStaticBitmap( this, wxID_ANY, bmp, wxDefaultPosition, wxSize( THUMB_W, THUMB_H ), 0 ); |
| 128 bSizer->Add( m_bitmap5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); | 129 bSizer->Add( m_bitmap5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); |
| 129 m_bitmap5->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick5 ), NULL, this ); | 130 m_bitmap5->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick5 ), NULL, this ); |
| 130 | 131 |
| 131 this->SetSizer( bSizer ); | 132 this->SetSizer( bSizer ); |
| 132 this->Layout(); | 133 this->Layout(); |
| 142 m_bitmap5->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick5 ), NULL, this ); | 143 m_bitmap5->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( ThumbnailPanel::OnDClick5 ), NULL, this ); |
| 143 } | 144 } |
| 144 | 145 |
| 145 // Functions | 146 // Functions |
| 146 /* サムネイル表示 */ | 147 /* サムネイル表示 */ |
| 147 void ThumbnailPanel::SetImages( wxString dirpath ) | 148 void ThumbnailPanel::SetCacheImages( wxString dirpath ) |
| 148 { | 149 { |
| 149 wxDir dir( dirpath ); | 150 wxDir dir( dirpath ); |
| 150 if ( !dir.IsOpened() ) return; | 151 if ( !dir.IsOpened() ) return; |
| 152 | |
| 151 m_imagefiles.Clear(); | 153 m_imagefiles.Clear(); |
| 152 wxDir::GetAllFiles( dirpath, &m_imagefiles, wxT("*.jpg"), wxDIR_FILES ); | 154 wxDir::GetAllFiles( dirpath, &m_imagefiles, wxT("*.jpg"), wxDIR_FILES ); |
| 153 | 155 |
| 154 wxString cachedir = wxT("cache") + dirpath.AfterLast( ':' ); | 156 wxString cachedir = wxT("cache") + dirpath.AfterLast( ':' ); |
| 155 wxDir cdir( cachedir ); | 157 wxDir cdir( cachedir ); |
| 156 if ( !cdir.IsOpened() ) return; | 158 if ( !cdir.IsOpened() ) return; |
| 157 | 159 |
| 158 wxArrayString cachefiles; | 160 m_cachefiles.Clear(); |
| 159 wxDir::GetAllFiles( cachedir, &cachefiles, wxT("*.png"), wxDIR_FILES ); | 161 wxDir::GetAllFiles( cachedir, &m_cachefiles, wxT("*.png"), wxDIR_FILES ); |
| 160 | 162 |
| 161 wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); | 163 wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); |
| 162 int n = cachefiles.GetCount(); | 164 int n = m_cachefiles.GetCount(); |
| 163 if ( n < 6 ) { | 165 if ( n < 6 ) { |
| 164 while ( n < 6 ) { | 166 while ( n < 6 ) { |
| 165 cachefiles.Add( thumb ); | 167 m_cachefiles.Add( thumb ); |
| 166 n++; | 168 n++; |
| 167 } | 169 } |
| 168 } | 170 } |
| 169 | 171 |
| 170 wxBitmap bmp; | 172 wxBitmap bmp; |
| 171 bmp.LoadFile( cachefiles[0], wxBITMAP_TYPE_PNG ); m_bitmap0->SetBitmap( bmp ); | 173 bmp.LoadFile( m_cachefiles[0], wxBITMAP_TYPE_PNG ); m_bitmap0->SetBitmap( bmp ); |
| 172 bmp.LoadFile( cachefiles[1], wxBITMAP_TYPE_PNG ); m_bitmap1->SetBitmap( bmp ); | 174 bmp.LoadFile( m_cachefiles[1], wxBITMAP_TYPE_PNG ); m_bitmap1->SetBitmap( bmp ); |
| 173 bmp.LoadFile( cachefiles[2], wxBITMAP_TYPE_PNG ); m_bitmap2->SetBitmap( bmp ); | 175 bmp.LoadFile( m_cachefiles[2], wxBITMAP_TYPE_PNG ); m_bitmap2->SetBitmap( bmp ); |
| 174 bmp.LoadFile( cachefiles[3], wxBITMAP_TYPE_PNG ); m_bitmap3->SetBitmap( bmp ); | 176 bmp.LoadFile( m_cachefiles[3], wxBITMAP_TYPE_PNG ); m_bitmap3->SetBitmap( bmp ); |
| 175 bmp.LoadFile( cachefiles[4], wxBITMAP_TYPE_PNG ); m_bitmap4->SetBitmap( bmp ); | 177 bmp.LoadFile( m_cachefiles[4], wxBITMAP_TYPE_PNG ); m_bitmap4->SetBitmap( bmp ); |
| 176 bmp.LoadFile( cachefiles[5], wxBITMAP_TYPE_PNG ); m_bitmap5->SetBitmap( bmp ); | 178 bmp.LoadFile( m_cachefiles[5], wxBITMAP_TYPE_PNG ); m_bitmap5->SetBitmap( bmp ); |
| 177 } | 179 } |
| 178 /* 画像クリックで拡大表示 */ | 180 /* 画像クリックダブルで拡大表示 */ |
| 179 void ThumbnailPanel::OnDClick0( wxMouseEvent& WXUNUSED(event) ) { Preview( 0 ); } | 181 void ThumbnailPanel::OnDClick0( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 0 ); } |
| 180 void ThumbnailPanel::OnDClick1( wxMouseEvent& WXUNUSED(event) ) { Preview( 1 ); } | 182 void ThumbnailPanel::OnDClick1( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 1 ); } |
| 181 void ThumbnailPanel::OnDClick2( wxMouseEvent& WXUNUSED(event) ) { Preview( 2 ); } | 183 void ThumbnailPanel::OnDClick2( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 2 ); } |
| 182 void ThumbnailPanel::OnDClick3( wxMouseEvent& WXUNUSED(event) ) { Preview( 3 ); } | 184 void ThumbnailPanel::OnDClick3( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 3 ); } |
| 183 void ThumbnailPanel::OnDClick4( wxMouseEvent& WXUNUSED(event) ) { Preview( 4 ); } | 185 void ThumbnailPanel::OnDClick4( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 4 ); } |
| 184 void ThumbnailPanel::OnDClick5( wxMouseEvent& WXUNUSED(event) ) { Preview( 5 ); } | 186 void ThumbnailPanel::OnDClick5( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 5 ); } |
| 185 void ThumbnailPanel::Preview( int n ) | 187 void ThumbnailPanel::DoPreview( int n ) |
| 186 { | 188 { |
| 187 if ( m_imagefiles.GetCount() < n ) return; | 189 if ( m_imagefiles.GetCount() < n + 1 ) return; |
| 188 | 190 |
| 189 PreviewDialog* pd = new PreviewDialog( this, wxID_ANY, wxT("プレビュー"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR ); | 191 PreviewDialog* pd = new PreviewDialog( this, wxID_ANY, wxT("プレビュー"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxFRAME_NO_TASKBAR ); |
| 190 pd->Show(); | 192 pd->Show(); |
| 191 pd->Maximize( true ); | 193 pd->Maximize( true ); |
| 192 pd->SetImage( m_imagefiles[n] ); | 194 pd->SetFiles( m_imagefiles, m_cachefiles ); |
| 195 pd->SetPreviewImage( n ); | |
| 193 } | 196 } |
| 194 | 197 |
| 195 /////////////////////////////////////////////////////////////// | 198 /////////////////////////////////////////////////////////////// |
| 196 // メインフレーム | 199 // メインフレーム |
| 197 #define WINL_W 480 | 200 #define WINL_W 480 |
| 774 | 777 |
| 775 item.SetColumn( 2 ); | 778 item.SetColumn( 2 ); |
| 776 item.SetMask( wxLIST_MASK_TEXT ); | 779 item.SetMask( wxLIST_MASK_TEXT ); |
| 777 m_listCtrl->GetItem( item ); | 780 m_listCtrl->GetItem( item ); |
| 778 | 781 |
| 779 m_thumbPanel->SetImages( item.GetText() ); | 782 m_thumbPanel->SetCacheImages( item.GetText() ); |
| 780 } | 783 } |
| 781 /* ステータスバーにメッセージを出力 */ | 784 /* ステータスバーにメッセージを出力 */ |
| 782 void MyFrame::SetStatusMessage( wxString msg, long n ) | 785 void MyFrame::SetStatusMessage( wxString msg, long n ) |
| 783 { | 786 { |
| 784 if ( GetStatusBar() ) | 787 if ( GetStatusBar() ) |
