Mercurial > mercurial > hgweb_searcher2.cgi
comparison src/myframe.cpp @ 12:9452ed888d10
start EazyPrint implementation.
| author | pyon@macmini |
|---|---|
| date | Sun, 26 Jun 2011 13:43:46 +0900 |
| parents | 07adad93df84 |
| children | 3e045b68738a |
comparison
equal
deleted
inserted
replaced
| 11:07adad93df84 | 12:9452ed888d10 |
|---|---|
| 1 // Filename : mainframe.cpp | 1 // Filename : mainframe.cpp |
| 2 // Last Change: 23-Jun-2011. | 2 // Last Change: 24-Jun-2011. |
| 3 // | 3 // |
| 4 #include "wx/html/htmprint.h" | |
| 5 #include "wx/print.h" | |
| 4 | 6 |
| 5 #include "symbol.h" | 7 #include "symbol.h" |
| 6 #include "common.h" | 8 #include "common.h" |
| 7 #include "myframe.h" | 9 #include "myframe.h" |
| 8 #include "hhsdb.h" | 10 #include "hhsdb.h" |
| 161 h->Show(true); | 163 h->Show(true); |
| 162 g->Show(false); | 164 g->Show(false); |
| 163 | 165 |
| 164 wxRegEx reHhs(wxT("^0[1238][0-9]{8}$")); // 1:被保番チェック | 166 wxRegEx reHhs(wxT("^0[1238][0-9]{8}$")); // 1:被保番チェック |
| 165 wxRegEx reCno(wxT("^[0-9]{1,2}$")); // 2:開くフォルダの番号 | 167 wxRegEx reCno(wxT("^[0-9]{1,2}$")); // 2:開くフォルダの番号 |
| 166 wxRegEx rePrint(wxT("^\.[0-9]*$")); // 3:印刷するフォルダの番号 | 168 wxRegEx rePrint(wxT("^\\.[0-9]*$")); // 3:印刷するフォルダの番号 |
| 167 | 169 |
| 168 wxString cmd; | 170 wxString cmd; |
| 169 cmd = this->GetLineText(0); | 171 cmd = this->GetLineText(0); |
| 170 int cond = 0; | 172 int cond = 0; |
| 171 if ( reHhs.Matches( cmd ) ) | 173 if ( reHhs.Matches( cmd ) ) |
| 313 // 検索履歴をログに保存 | 315 // 検索履歴をログに保存 |
| 314 wxString logfn = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("log.txt"); | 316 wxString logfn = wxGetCwd() + wxFILE_SEP_PATH + wxT("tmp") + wxFILE_SEP_PATH + wxT("log.txt"); |
| 315 wxTextFile logFile; | 317 wxTextFile logFile; |
| 316 logFile.Open( logfn ); | 318 logFile.Open( logfn ); |
| 317 wxDateTime now = wxDateTime::Now(); | 319 wxDateTime now = wxDateTime::Now(); |
| 318 wxString log = now.Format() + wxT(" " ) + cmd + wxT(" ") + path[val]; | 320 wxString log = now.Format() + wxT(" ") + cmd + wxT(" ") + path[val]; |
| 319 logFile.AddLine( log ); | 321 logFile.AddLine( log ); |
| 320 logFile.Write(); | 322 logFile.Write(); |
| 321 logFile.Close(); | 323 logFile.Close(); |
| 322 | 324 |
| 323 break; | 325 break; |
| 327 this->SetSelection( 0, this->GetLastPosition() ); | 329 this->SetSelection( 0, this->GetLastPosition() ); |
| 328 if ( path.IsEmpty() ) { | 330 if ( path.IsEmpty() ) { |
| 329 mf->m_statusBar->SetStatusText( wxT("不適切な入力です.警告コード3"), 0 ); | 331 mf->m_statusBar->SetStatusText( wxT("不適切な入力です.警告コード3"), 0 ); |
| 330 break; | 332 break; |
| 331 } | 333 } |
| 332 wxMessageBox(wxT("333")); | 334 PrintImages( path[0] ); |
| 333 break; | 335 break; |
| 334 } | 336 } |
| 335 // 制御用コマンド | 337 // 制御用コマンド |
| 336 case 0: { | 338 case 0: { |
| 337 | |
| 338 path.Clear(); | 339 path.Clear(); |
| 339 if ( cmd.Cmp(wxT("s")) == 0 ) { | 340 if ( cmd.Cmp(wxT("s")) == 0 ) { |
| 340 hr->LoadPage( wxT("html/start.html") ); | 341 hr->LoadPage( wxT("html/start.html") ); |
| 341 this->ChangeValue( wxEmptyString ); | 342 this->ChangeValue( wxEmptyString ); |
| 342 mf->m_statusBar->SetStatusText( wxEmptyString, 0 ); | 343 mf->m_statusBar->SetStatusText( wxEmptyString, 0 ); |
| 376 break; | 377 break; |
| 377 } | 378 } |
| 378 } | 379 } |
| 379 } | 380 } |
| 380 | 381 |
| 382 // functions | |
| 383 void MyCmdBox::PrintImages( wxString& path ) | |
| 384 { | |
| 385 wxHtmlPrintout* hpout = new wxHtmlPrintout( wxT("Searcher2") ); | |
| 386 hpout->SetMargins( 0,0,0,0,0 ); | |
| 387 wxPrintDialogData* pd; | |
| 388 wxPrinter* p = new wxPrinter( pd ); | |
| 389 | |
| 390 wxDir dir(path); | |
| 391 wxString file; | |
| 392 if ( !dir.IsOpened() ) return; | |
| 393 | |
| 394 bool cout = dir.GetFirst( &file, wxT("*.jpg"), wxDIR_FILES ); | |
| 395 while ( cout ) { | |
| 396 file = path + wxFILE_SEP_PATH + file; | |
| 397 file.Replace( wxT("\\"), wxT("/") ); | |
| 398 wxString html; | |
| 399 html = html + wxT("<html><body>"); | |
| 400 html = html + wxT("<img src=\"") + file + wxT("\" width=\"750\" height=\"1060\"/>"); | |
| 401 html = html + wxT("</body></html>"); | |
| 402 | |
| 403 hpout->SetHtmlText( html, wxEmptyString, false ); | |
| 404 p->Print( NULL, hpout, false ); | |
| 405 cout = dir.GetNext( &file ); | |
| 406 } | |
| 407 return; | |
| 408 } | |
| 409 | |
| 381 ////////////////////////////////////////////////////////////////////////// | 410 ////////////////////////////////////////////////////////////////////////// |
| 382 // frame constructor | 411 // frame constructor |
| 383 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title ) | 412 MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title ) |
| 384 : wxFrame( parent, id, title ) | 413 : wxFrame( parent, id, title ) |
| 385 { | 414 { |
