Mercurial > mercurial > hgweb_searcher03.cgi
diff 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 |
line wrap: on
line diff
--- a/src/myframe.cpp Thu Apr 24 18:31:39 2014 +0900 +++ b/src/myframe.cpp Mon Apr 28 18:14:04 2014 +0900 @@ -1,5 +1,5 @@ // Filename : myframe.cpp -// Last Change: 24-Apr-2014. +// Last Change: 28-Apr-2014. // #include "main.h" #include "db.h" @@ -13,6 +13,7 @@ #include "myframe.h" #include "bprint.h" +#define DEBUG 1 /////////////////////////////////////////////////////////////// // カスタム検索ボックス @@ -104,27 +105,27 @@ 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 ); + m_bitmap0 = new wxStaticBitmap( this, wxID_ANY, 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 ); + m_bitmap1 = new wxStaticBitmap( this, wxID_ANY, 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 ); + m_bitmap2 = new wxStaticBitmap( this, wxID_ANY, 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 ); + m_bitmap3 = new wxStaticBitmap( this, wxID_ANY, 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 ); + m_bitmap4 = new wxStaticBitmap( this, wxID_ANY, 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 ); + m_bitmap5 = new wxStaticBitmap( this, wxID_ANY, 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 ); @@ -144,10 +145,11 @@ // Functions /* サムネイル表示 */ -void ThumbnailPanel::SetImages( wxString dirpath ) +void ThumbnailPanel::SetCacheImages( wxString dirpath ) { wxDir dir( dirpath ); if ( !dir.IsOpened() ) return; + m_imagefiles.Clear(); wxDir::GetAllFiles( dirpath, &m_imagefiles, wxT("*.jpg"), wxDIR_FILES ); @@ -155,41 +157,42 @@ wxDir cdir( cachedir ); if ( !cdir.IsOpened() ) return; - wxArrayString cachefiles; - wxDir::GetAllFiles( cachedir, &cachefiles, wxT("*.png"), wxDIR_FILES ); + m_cachefiles.Clear(); + wxDir::GetAllFiles( cachedir, &m_cachefiles, wxT("*.png"), wxDIR_FILES ); wxString thumb = wxGetCwd() + wxFILE_SEP_PATH + wxT("image") + wxFILE_SEP_PATH + wxT("thumbnail.png"); - int n = cachefiles.GetCount(); + int n = m_cachefiles.GetCount(); if ( n < 6 ) { while ( n < 6 ) { - cachefiles.Add( thumb ); + m_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 ); + bmp.LoadFile( m_cachefiles[0], wxBITMAP_TYPE_PNG ); m_bitmap0->SetBitmap( bmp ); + bmp.LoadFile( m_cachefiles[1], wxBITMAP_TYPE_PNG ); m_bitmap1->SetBitmap( bmp ); + bmp.LoadFile( m_cachefiles[2], wxBITMAP_TYPE_PNG ); m_bitmap2->SetBitmap( bmp ); + bmp.LoadFile( m_cachefiles[3], wxBITMAP_TYPE_PNG ); m_bitmap3->SetBitmap( bmp ); + bmp.LoadFile( m_cachefiles[4], wxBITMAP_TYPE_PNG ); m_bitmap4->SetBitmap( bmp ); + bmp.LoadFile( m_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 ) +/* 画像クリックダブルで拡大表示 */ +void ThumbnailPanel::OnDClick0( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 0 ); } +void ThumbnailPanel::OnDClick1( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 1 ); } +void ThumbnailPanel::OnDClick2( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 2 ); } +void ThumbnailPanel::OnDClick3( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 3 ); } +void ThumbnailPanel::OnDClick4( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 4 ); } +void ThumbnailPanel::OnDClick5( wxMouseEvent& WXUNUSED(event) ) { DoPreview( 5 ); } +void ThumbnailPanel::DoPreview( int n ) { - if ( m_imagefiles.GetCount() < n ) return; + if ( m_imagefiles.GetCount() < n + 1 ) 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] ); + pd->SetFiles( m_imagefiles, m_cachefiles ); + pd->SetPreviewImage( n ); } /////////////////////////////////////////////////////////////// @@ -776,7 +779,7 @@ item.SetMask( wxLIST_MASK_TEXT ); m_listCtrl->GetItem( item ); - m_thumbPanel->SetImages( item.GetText() ); + m_thumbPanel->SetCacheImages( item.GetText() ); } /* ステータスバーにメッセージを出力 */ void MyFrame::SetStatusMessage( wxString msg, long n )