Mercurial > mercurial > hgweb_searcher03.cgi
diff src/bprint.cpp @ 12:52958cd4a073
Implement Force Mask button in Batch Print Mode.
author | pyon@macmini |
---|---|
date | Sun, 18 May 2014 19:49:15 +0900 |
parents | 4967d1e2b30c |
children | bbd65edf71d4 |
line wrap: on
line diff
--- a/src/bprint.cpp Wed May 07 20:38:57 2014 +0900 +++ b/src/bprint.cpp Sun May 18 19:49:15 2014 +0900 @@ -1,5 +1,5 @@ // Filename : bprint.cpp -// Last Change: 01-Nov-2013. +// Last Change: 16-May-2014. // #include "bprint.h" @@ -55,8 +55,16 @@ m_buttonClear = new wxButton( this, ID_BPCLEAR, wxT("クリア"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerButton->Add( m_buttonClear, 0, wxALL, 5 ); - m_buttonPrint = new wxButton( this, ID_BPPRINT, wxT("印刷"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonMaskPrint = new wxButton( this, ID_BPFFMP, wxT("FFMP"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButton->Add( m_buttonMaskPrint, 0, wxALL, 5 ); + + m_buttonPrint = new wxButton( this, ID_BPPRINT, wxT("一括印刷"), wxDefaultPosition, wxDefaultSize, 0 ); bSizerButton->Add( m_buttonPrint, 0, wxALL, 5 ); + + m_buttonLdLog = new wxButton( this, ID_BPLDLOG, wxT("一括印刷ログ"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButton->Add( m_buttonLdLog, 0, wxALL, 5 ); + + bSizerButton->Add( 0, 20, 0, 0, 5 ); bSizerButton->Add( 0, 20, 0, 0, 5 ); @@ -83,7 +91,9 @@ BEGIN_EVENT_TABLE( FrameBatchPrint, wxDialog ) EVT_GRID_CELL_CHANGING( FrameBatchPrint::OnInput ) EVT_BUTTON( ID_BPCLEAR, FrameBatchPrint::OnClear ) + EVT_BUTTON( ID_BPFFMP, FrameBatchPrint::OnMaskPrint ) EVT_BUTTON( ID_BPPRINT, FrameBatchPrint::OnPrint ) + EVT_BUTTON( ID_BPLDLOG, FrameBatchPrint::OnLoadLog ) END_EVENT_TABLE() // Event Handlers & Functions @@ -132,7 +142,7 @@ if ( !dir.IsOpened() ) return; wxString html; - html = html + wxT("<html><body>\n"); + html = wxT("<html><body>\n"); wxString file; bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES ); @@ -188,6 +198,51 @@ WriteLog( log ); } +/* 一枚目強制マスク印刷 */ +void FrameBatchPrint::OnMaskPrint( wxCommandEvent& WXUNUSED(event) ) +{ + wxArrayInt rows = m_grid->GetSelectedRows(); + if ( rows.GetCount() != 1 ) { + wxMessageDialog md( this, wxT("1件のみ選択してください."), wxT("Message"), wxOK|wxICON_INFORMATION ); + md.ShowModal(); + return; + } + + wxString path = m_grid->GetCellValue( rows[0], 2 ); + wxDir dir( path ); + if ( !dir.IsOpened() ) return; + + wxPrintDialogData pd; + wxPrinter p( &pd ); + p.PrintDialog( NULL ); + + // 印刷用の html を作成 + wxString file; + if ( dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES ) ) { + wxString tmpdir = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH; + file = path + wxFILE_SEP_PATH + file; + file.Replace( wxFILE_SEP_PATH, wxT("/") ); + wxString tmpjpg = wxString::Format( wxT("%stmp.jpg"), tmpdir ); + + wxImage img_org( file, wxBITMAP_TYPE_JPEG ); + 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 + img_org.SaveFile( tmpjpg ); + + wxString html; + html = wxT("<html><body>\n"); + 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 ); + hpout.SetHtmlText( html, wxEmptyString, false ); + p.Print( NULL, &hpout, false ); + } +} + /* 入力禁止 */ void FrameBatchPrint::SetGridReadOnly( void ) { @@ -196,7 +251,46 @@ m_grid->SetReadOnly( r, c, true ); } -/* 印刷ログ */ +/* 印刷ログ表示 */ +void FrameBatchPrint::OnLoadLog( wxCommandEvent& WXUNUSED(event) ) +{ + wxFileDialog fd( this, wxT("Choose a file"), wxT("log"), wxEmptyString, wxT("log files (*.log)|bp_*.log"), wxFD_OPEN|wxFD_FILE_MUST_EXIST ); + if ( fd.ShowModal() == wxID_CANCEL ) + return; + + m_grid->ClearGrid(); + + wxTextFile logfile; + logfile.Open( fd.GetPath() ); + + // + int d = logfile.GetLineCount() - m_grid->GetNumberRows(); + if ( d > 0 ) + m_grid->AppendRows( d, true ); + + wxArrayString hhsno; + wxString hhs, path, stat; + for ( int n = 0; n < logfile.GetLineCount(); n++ ) { + hhs = logfile[n].AfterLast( wxFILE_SEP_PATH ); + stat = hhs.AfterFirst( ' ' ); + hhs = hhs.BeforeFirst( ' ' ); + path = logfile[n]; + if ( !stat.IsEmpty() ) { + path = path.BeforeFirst( ' ' ); + } + m_grid->SetCellValue( n, 0, hhs ); + m_grid->SetCellValue( n, 2, path ); + m_grid->SetCellValue( n, 3, stat ); + hhsno.Add( hhs ); + } + for ( int n = 0; n < hhsno.GetCount(); n++ ) { + wxArrayString info = wxSplit( GetHhsInfoByHhsNo( hhsno[n] ), '_', '\\' ); + m_grid->SetCellValue( n, 1, info[0] ); + } + logfile.Close(); +} + +/* 印刷ログ出力 */ void FrameBatchPrint::WriteLog( wxArrayString logline ) { wxDateTime now = wxDateTime::Now();