Mercurial > mercurial > hgweb_searcher03.cgi
comparison src/preview.cpp @ 13:bbd65edf71d4
Implement Hhs DB update dialog.
| author | pyon@macmini |
|---|---|
| date | Sat, 24 May 2014 10:25:13 +0900 |
| parents | 52958cd4a073 |
| children | ac17a73e39b3 |
comparison
equal
deleted
inserted
replaced
| 12:52958cd4a073 | 13:bbd65edf71d4 |
|---|---|
| 1 // Filename : preview.cpp | 1 // Filename : preview.cpp |
| 2 // Last Change: 16-May-2014. | 2 // Last Change: 23-May-2014. |
| 3 // | 3 // |
| 4 | 4 |
| 5 #include "marksheet.h" | 5 #include "marksheet.h" |
| 6 #include "preview.h" | 6 #include "preview.h" |
| 7 #define THUMB_W 60 | 7 #define THUMB_W 60 |
| 57 m_bitmap5->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( PThumbnailPanel::OnClick5 ), NULL, this ); | 57 m_bitmap5->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( PThumbnailPanel::OnClick5 ), NULL, this ); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Functions | 60 // Functions |
| 61 /* サムネイル表示 */ | 61 /* サムネイル表示 */ |
| 62 void PThumbnailPanel::SetFiles( wxArrayString imagefiles, wxArrayString cachefiles ) | 62 void PThumbnailPanel::SetFiles( wxArrayString imagefiles, wxArrayString cachefiles, int select ) |
| 63 { | 63 { |
| 64 m_imagefiles = imagefiles; | 64 m_imagefiles = imagefiles; |
| 65 | 65 |
| 66 wxBitmap bmp; | 66 wxBitmap bmp; |
| 67 bmp.LoadFile( cachefiles[0], wxBITMAP_TYPE_PNG ); m_bitmap0->SetBitmap( bmp ); | 67 m_imageList.Create( THUMB_W, THUMB_H ); |
| 68 bmp.LoadFile( cachefiles[1], wxBITMAP_TYPE_PNG ); m_bitmap1->SetBitmap( bmp ); | 68 |
| 69 bmp.LoadFile( cachefiles[2], wxBITMAP_TYPE_PNG ); m_bitmap2->SetBitmap( bmp ); | 69 bmp.LoadFile( cachefiles[0], wxBITMAP_TYPE_PNG ); m_imageList.Add( bmp ); |
| 70 bmp.LoadFile( cachefiles[3], wxBITMAP_TYPE_PNG ); m_bitmap3->SetBitmap( bmp ); | 70 bmp.LoadFile( cachefiles[1], wxBITMAP_TYPE_PNG ); m_imageList.Add( bmp ); |
| 71 bmp.LoadFile( cachefiles[4], wxBITMAP_TYPE_PNG ); m_bitmap4->SetBitmap( bmp ); | 71 bmp.LoadFile( cachefiles[2], wxBITMAP_TYPE_PNG ); m_imageList.Add( bmp ); |
| 72 bmp.LoadFile( cachefiles[5], wxBITMAP_TYPE_PNG ); m_bitmap5->SetBitmap( bmp ); | 72 bmp.LoadFile( cachefiles[3], wxBITMAP_TYPE_PNG ); m_imageList.Add( bmp ); |
| 73 bmp.LoadFile( cachefiles[4], wxBITMAP_TYPE_PNG ); m_imageList.Add( bmp ); | |
| 74 bmp.LoadFile( cachefiles[5], wxBITMAP_TYPE_PNG ); m_imageList.Add( bmp ); | |
| 75 SetImageList( select ); | |
| 73 } | 76 } |
| 74 /* 画像クリックで拡大表示 */ | 77 /* 画像クリックで拡大表示 */ |
| 75 void PThumbnailPanel::OnClick0( wxMouseEvent& WXUNUSED(event) ) { Preview( 0 ); } | 78 void PThumbnailPanel::OnClick0( wxMouseEvent& WXUNUSED(event) ) { Preview( 0 ); } |
| 76 void PThumbnailPanel::OnClick1( wxMouseEvent& WXUNUSED(event) ) { Preview( 1 ); } | 79 void PThumbnailPanel::OnClick1( wxMouseEvent& WXUNUSED(event) ) { Preview( 1 ); } |
| 77 void PThumbnailPanel::OnClick2( wxMouseEvent& WXUNUSED(event) ) { Preview( 2 ); } | 80 void PThumbnailPanel::OnClick2( wxMouseEvent& WXUNUSED(event) ) { Preview( 2 ); } |
| 79 void PThumbnailPanel::OnClick4( wxMouseEvent& WXUNUSED(event) ) { Preview( 4 ); } | 82 void PThumbnailPanel::OnClick4( wxMouseEvent& WXUNUSED(event) ) { Preview( 4 ); } |
| 80 void PThumbnailPanel::OnClick5( wxMouseEvent& WXUNUSED(event) ) { Preview( 5 ); } | 83 void PThumbnailPanel::OnClick5( wxMouseEvent& WXUNUSED(event) ) { Preview( 5 ); } |
| 81 void PThumbnailPanel::Preview( int n ) | 84 void PThumbnailPanel::Preview( int n ) |
| 82 { | 85 { |
| 83 if ( m_imagefiles.GetCount() < n + 1 ) return; | 86 if ( m_imagefiles.GetCount() < n + 1 ) return; |
| 87 SetImageList( n ); | |
| 84 m_parent->SetPreviewImage( n ); | 88 m_parent->SetPreviewImage( n ); |
| 85 } | 89 } |
| 86 | 90 /* サムネイル表示 */ |
| 91 void PThumbnailPanel::SetImageList( int selected ) | |
| 92 { | |
| 93 m_bitmap0->SetBitmap( m_imageList.GetBitmap(0) ); | |
| 94 m_bitmap1->SetBitmap( m_imageList.GetBitmap(1) ); | |
| 95 m_bitmap2->SetBitmap( m_imageList.GetBitmap(2) ); | |
| 96 m_bitmap3->SetBitmap( m_imageList.GetBitmap(3) ); | |
| 97 m_bitmap4->SetBitmap( m_imageList.GetBitmap(4) ); | |
| 98 m_bitmap5->SetBitmap( m_imageList.GetBitmap(5) ); | |
| 99 | |
| 100 wxImage image = m_imageList.GetBitmap( selected ).ConvertToImage(); | |
| 101 unsigned char *data = image.GetData(); | |
| 102 for ( int y = 0; y < THUMB_H; y++ ) | |
| 103 for ( int x = 0; x <THUMB_W; x++ ) | |
| 104 data[ ( y * THUMB_W + x ) * 3 + 2 ] = 255; // 文字色:黒(0,0,0)->青(0,0,255) | |
| 105 | |
| 106 wxBitmap bmp_mask( image ); | |
| 107 | |
| 108 switch ( selected ) { | |
| 109 case 0: | |
| 110 m_bitmap0->SetBitmap( bmp_mask ); | |
| 111 break; | |
| 112 case 1: | |
| 113 m_bitmap1->SetBitmap( bmp_mask ); | |
| 114 break; | |
| 115 case 2: | |
| 116 m_bitmap2->SetBitmap( bmp_mask ); | |
| 117 break; | |
| 118 case 3: | |
| 119 m_bitmap3->SetBitmap( bmp_mask ); | |
| 120 break; | |
| 121 case 4: | |
| 122 m_bitmap4->SetBitmap( bmp_mask ); | |
| 123 break; | |
| 124 case 5: | |
| 125 m_bitmap5->SetBitmap( bmp_mask ); | |
| 126 break; | |
| 127 } | |
| 128 } | |
| 87 | 129 |
| 88 //////////////////////////////////////////////////////// | 130 //////////////////////////////////////////////////////// |
| 89 // プレビューダイアログ | 131 // プレビューダイアログ |
| 90 PreviewDialog::PreviewDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) | 132 PreviewDialog::PreviewDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) |
| 91 : wxDialog( parent, id, title, pos, size, style ) | 133 : wxDialog( parent, id, title, pos, size, style ) |
| 154 info += wxString::Format( wxT("\n%z = %f"), z ); | 196 info += wxString::Format( wxT("\n%z = %f"), z ); |
| 155 info += wxString::Format( wxT("\n%l = %ld"), l ); | 197 info += wxString::Format( wxT("\n%l = %ld"), l ); |
| 156 m_textInfo->SetValue( info ); | 198 m_textInfo->SetValue( info ); |
| 157 } | 199 } |
| 158 | 200 |
| 159 void PreviewDialog::SetFiles( wxArrayString imagefiles, wxArrayString cachefiles ) | 201 void PreviewDialog::SetFiles( wxArrayString imagefiles, wxArrayString cachefiles, int select ) |
| 160 { | 202 { |
| 161 m_imagefiles = imagefiles; | 203 m_imagefiles = imagefiles; |
| 162 m_cachefiles = cachefiles; | 204 m_cachefiles = cachefiles; |
| 163 m_thumbPanel->SetFiles( m_imagefiles, m_cachefiles ); | 205 m_thumbPanel->SetFiles( m_imagefiles, m_cachefiles, select ); |
| 164 | 206 |
| 165 wxString title = wxT("プレビュー @ ") + m_imagefiles[0].BeforeLast( wxFILE_SEP_PATH ); | 207 wxString title = wxT("プレビュー @ ") + m_imagefiles[0].BeforeLast( wxFILE_SEP_PATH ); |
| 166 this->SetTitle( title ); | 208 this->SetTitle( title ); |
| 167 } | 209 } |
| 168 | 210 |
