Mercurial > mercurial > hgweb_searcher03.cgi
diff src/preview.cpp @ 22:92188f60323d default tip
Implement Masking function on Preview Dialog.
author | pyon@macmini |
---|---|
date | Sat, 04 Apr 2015 17:23:46 +0900 |
parents | de222bc84e48 |
children |
line wrap: on
line diff
--- a/src/preview.cpp Wed Dec 17 00:52:43 2014 +0900 +++ b/src/preview.cpp Sat Apr 04 17:23:46 2015 +0900 @@ -1,5 +1,5 @@ // Filename : preview.cpp -// Last Change: 11-Jun-2014. +// Last Change: 2015-04-03 11:57:55. // #include "marksheet.h" @@ -83,6 +83,9 @@ void PThumbnailPanel::OnClick5( wxMouseEvent& WXUNUSED(event) ) { Preview( 5 ); } void PThumbnailPanel::Preview( int n ) { + if ( n == 0 ) m_parent->EnableMaskButton( true ); + else m_parent->EnableMaskButton( false ); + if ( m_imagefiles.GetCount() < n + 1 ) return; SetImageList( n ); m_parent->SetPreviewImage( n ); @@ -154,6 +157,10 @@ m_buttonPrint = new wxButton( this, ID_PRINT, wxT("印刷"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerMenu->Add( m_buttonPrint, 0, wxALL, 5 ); + m_buttonMaskPrint = new wxButton( this, ID_MPRINT, wxT("マスク印刷"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerMenu->Add( m_buttonMaskPrint, 0, wxALL, 5 ); + m_buttonMaskPrint->Enable( false ); + bSizerMenu->Add( 0, 0, 0, 0, 5 ); m_buttonClose = new wxButton( this, wxID_CANCEL, wxT("閉じる"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -169,14 +176,15 @@ PreviewDialog::~PreviewDialog() { m_scrolledWindow->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PreviewDialog::OnWheel ), NULL, this ); - m_bitmap->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( PreviewDialog::OnDClick ), NULL, this ); - m_bitmap->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( PreviewDialog::OnStartRGesture ), NULL, this ); - m_bitmap->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( PreviewDialog::OnEndRGesture ), NULL, this ); + m_bitmap->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( PreviewDialog::OnDClick ), NULL, this ); + m_bitmap->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( PreviewDialog::OnStartRGesture ), NULL, this ); + m_bitmap->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( PreviewDialog::OnEndRGesture ), NULL, this ); } // Event Table BEGIN_EVENT_TABLE( PreviewDialog, wxDialog ) - EVT_BUTTON( ID_PRINT, PreviewDialog::OnPrint ) + EVT_BUTTON( ID_PRINT, PreviewDialog::OnPrint ) + EVT_BUTTON( ID_MPRINT, PreviewDialog::OnMaskPrint ) END_EVENT_TABLE() #define WIDTH 2480 @@ -317,3 +325,44 @@ p.Print( NULL, &hpout, true ); } +/* マスク印刷 */ +void PreviewDialog::OnMaskPrint( wxCommandEvent& WXUNUSED(event) ) +{ + wxString html; + html = html + wxT("<html><body>\n"); + + wxString tmpjpg = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("preview.jpg"); + + wxImage img_org( m_imagefiles[m_preview], wxBITMAP_TYPE_JPEG ); + int ver = GetMarksheetVersion( m_imagefiles[m_preview] ); + if ( ver == 2 ) { + img_org.SetRGB( m_mask1, 255, 255, 255 ); // cm name + img_org.SetRGB( m_mask2, 255, 255, 255 ); // cm no. + img_org.SetRGB( m_mask3, 255, 255, 255 ); // barcode + } + else { // 古いマークシート ver == 1 + img_org.SetRGB( m_mask1old, 255, 255, 255 ); // cm name + img_org.SetRGB( m_mask2old, 255, 255, 255 ); // cm no. + img_org.SetRGB( m_mask3old, 255, 255, 255 ); // barcode + } + img_org.SaveFile( tmpjpg ); + + 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 ); +} + +void PreviewDialog::EnableMaskButton( bool flag ) +{ + if ( flag ) m_buttonMaskPrint->Enable( true ); + else m_buttonMaskPrint->Enable( false ); +} +