1%% options 2 3# __CHANGE__ 001: Correct copyright owner if necessary. 4copyright owner = Dirk Krause 5 6# __CHANGE__ 003: Correct copyright year(s) if necessary. 7copyright year = 2013-xxxx 8 9# __CHANGE__ 002: Correct license type if necessary. 10# Use "bsd", "gpl", "lgpl", or "commercial". 11SPDX-License-Identifier: BSD-3-Clause 12 13 14 15%% wx-gui 16 17type = frame 18contents = mainSizer 19icon = winprint_icon 20tool bar = tbMain 21status bar = 1 sTexts[8] 22menu bar = mbMain 23 24[wxToolBar tbMain] 25contents = bRun 26contents = bExit 27 28[wxToolBarToolBase bRun] 29text = sTexts[15] 30bitmap = xpm_run_conversion 31id = WinprintFrame_Print 32tip = sTexts[16] 33 34[wxToolBarToolBase bExit] 35text = sTexts[1] 36bitmap = xpm_exit_program 37id = WinprintFrame_Quit 38tip = sTexts[2] 39 40[wxMenuBar mbMain] 41contents = menuFile 42contents = menuHelp 43 44[wxMenu menuFile] 45text = sTexts[0] 46contents = miFilePrint 47contents = miFileExit 48 49[wxMenuItem miFilePrint] 50id = WinprintFrame_Print 51text = sTexts[15] 52tip = sTexts[16] 53 54[wxMenuItem miFileExit] 55id = WinprintFrame_Quit 56text = sTexts[1] 57tip = sTexts[2] 58 59[wxMenu menuHelp] 60text = sTexts[3] 61contents = miHelpAbout 62contents = miHelpContents 63 64[wxMenuItem miHelpAbout] 65id = WinprintFrame_Help_About 66text = sTexts[4] 67tip = sTexts[5] 68 69[wxMenuItem miHelpContents] 70id = WinprintFrame_Help_Contents 71text = sTexts[6] 72tip = sTexts[7] 73 74[wxBoxSizer mainSizer] 75direction = horizontal 76contents = $space(10) 77contents = verticalSizer 78contents = $space(10) 79 80[wxBoxSizer verticalSizer] 81direction = vertical 82grow = yes 83proportion = 1 84contents = $space(10) 85contents = contentsSizer 86contents = $space(10) 87 88[wxGridBagSizer contentsSizer] 89grid = 5 5 90 91# __CHANGE__ 015: The dummy label was added to have at least 92# one GUI element in the sizer. 93# Remove tStatus (next 4 lines) and add the real 94# window contents here. 95contents = tStatus 0 0 1 1 left 96 97[wxStaticText tStatus] 98text = sTexts[13] 99 100 101 102%% header start 103 104#ifdef DK3_USE_WX 105#undef DK3_USE_WX 106#endif 107/** Use wxWidgets libraries to build GUI programs. 108*/ 109#define DK3_USE_WX 1 110 111 112%% class start 113class WinprintFrame : public DkWxFrame 114{ 115 private: 116 117 /** Event table for frame. 118 */ 119#if wxCHECK_VERSION(3,0,0) 120 wxDECLARE_EVENT_TABLE(); 121#else 122 DECLARE_EVENT_TABLE() 123#endif 124 125 protected: 126 127 /** Black color for status label. 128 */ 129 wxColour cBlack; 130 131 /** Green color for status label. 132 */ 133 wxColour cGreen; 134 135 /** Red color for status label. 136 */ 137 wxColour cRed; 138 139 /** Printer names. 140 */ 141 DK3_PCWXCHAR *pNames; 142 143 /** Printer names as wxString array. 144 */ 145 wxString *wxsNames; 146 147 /** Size of printer names array. 148 */ 149 size_t nNames; 150 151 /** Index of default printer in array. 152 */ 153 int nDefPrinter; 154 155 /** File dialog x position. 156 */ 157 int fdx; 158 159 /** File dialog y position. 160 */ 161 int fdy; 162 163 /** Printer chooser dialog x position. 164 */ 165 int pcx; 166 167 /** Printer chooser dialog y position. 168 */ 169 int pcy; 170 171 /** Localized texts. 172 */ 173 wxChar const * const *sTexts; 174 175 /** Non-localized texts. 176 */ 177 wxChar const * const *sNlWx; 178 179 /** Non-localized texts. 180 */ 181 dkChar const * const *sNlDk; 182 183 /** Print configuration. 184 */ 185 dk3_print_conf_t *pc; 186 187 /** Use default printer. 188 */ 189 BOOL bUseDefaultPrinter; 190 191 /** Use named printer. 192 */ 193 wxChar const *sNamedPrinter; 194 195 /** Named file to process. 196 */ 197 wxChar const *sNamedFile; 198 199 /** Communicator object. 200 */ 201 DkWxCommunicator *pComm; 202 203 /** Time to close the application. 204 */ 205 dk3_time_t timeClose; 206 207 /** Flag: Closing the application is scheduled. 208 */ 209 BOOL bCloseScheduled; 210 211 /** Flag: Autostart wanted. 212 */ 213 BOOL bAutostartWanted; 214 215%% class end 216 217 public: 218 219 /** Constructor. 220 @param wxid Window ID. 221 @param applicationHelper Application helper object. 222 @param hc Help controller for online help. 223 @param argc Number of command line arguments. 224 @param argv Command line arguments array. 225 @param localizedTexts Localized wxChar texts. 226 @param nlWx Non-localized wxChar texts. 227 @param nlDk Non-localized dkChar texts. 228 @param pPrintConf Print configuration. 229 */ 230 WinprintFrame( 231 int wxid, 232 DkWxAppHelper *applicationHelper, 233 DkWxHelpController *hc, 234 int argc, 235 wxChar **argv, 236 wxChar const * const *localizedTexts, 237 wxChar const * const *nlWx, 238 dkChar const * const *nlDk, 239 dk3_print_conf_t *pPrintConf, 240 DK3_PCWXCHAR *printerNames, 241 size_t numberOfPrinters, 242 int defaultPrinterIndex 243 ); 244 245 /** Destructor. 246 */ 247 ~WinprintFrame(); 248 249 /** Check whether we can close the window. 250 @param isLast Flag: Last main window to close. 251 */ 252 bool 253 canClose(bool isLast); 254 255 /** Handler for File/Exit. 256 @param event Event to process. 257 */ 258 void 259 OnQuit(wxCommandEvent & event); 260 261 /** Handler for Help/About. 262 @param event Event to process. 263 */ 264 void 265 OnAbout(wxCommandEvent & event); 266 267 /** Handler for Help/Contents. 268 @param event Event to process. 269 */ 270 void 271 OnHelpContents(wxCommandEvent & event); 272 273 /** Handler for print menu item. 274 @param event Event to process. 275 */ 276 void 277 OnPrint(wxCommandEvent & event); 278 279 /* __CHANGE__ 008: Remove OnIdle if no idle processing required. 280 */ 281 /** Handler for idle events. 282 */ 283 void 284 OnIdle(wxIdleEvent & event); 285 286 /* __CHANGE__ 017: Event handlers for further events. 287 */ 288 289 /* __CHANGE__ 014: Add further methods. 290 */ 291 292 /** Run print job for given file name. 293 @param filename Name of file to print. 294 */ 295 int 296 runFileNameJob(wxChar const *filename); 297 298 /** Run for a print job. 299 */ 300 int runJob(void); 301 302 /** Set error status. 303 @param txt Error message text. 304 @param filename Current filename to process. 305 */ 306 void setErrorStatus(wxChar const *txt, wxChar const *filename); 307 308}; 309 310%% header end 311 312%% module start 313 314#include "dk3conf.h" 315#include <winprint/winprint.h> 316#if 0 317#include <libdk3c/dkt-version.h> 318#endif 319#include <libdk4wx/dk4verswx.h> 320#include "gui-img/shared/toolbar/run-conversion.xpm" 321#include "gui-img/shared/toolbar/exit-program.xpm" 322 323 324#if !defined(__WXMSW__) 325#include "gui-img/icons/winprint.xpm" 326#endif 327 328 329 330$!trace-include 331 332 333 334/* __CHANGE__ 017: Add further events. */ 335/* __CHANGE__ 008: Remove OnIdle if no idle processing required. */ 336 337#if wxCHECK_VERSION(3,0,0) 338wxBEGIN_EVENT_TABLE(WinprintFrame,wxFrame) 339#else 340BEGIN_EVENT_TABLE(WinprintFrame,wxFrame) 341#endif 342 EVT_MENU(WinprintFrame_Quit, WinprintFrame::OnQuit) 343 EVT_MENU(WinprintFrame_Print, WinprintFrame::OnPrint) 344 EVT_MENU(WinprintFrame_Help_About, WinprintFrame::OnAbout) 345 EVT_MENU(WinprintFrame_Help_Contents, WinprintFrame::OnHelpContents) 346 EVT_IDLE(WinprintFrame::OnIdle) 347#if wxCHECK_VERSION(3,0,0) 348wxEND_EVENT_TABLE() 349#else 350END_EVENT_TABLE() 351#endif 352 353 354 355#if __GNUC__ 356#pragma GCC diagnostic push 357#pragma GCC diagnostic ignored "-Wmissing-field-initializers" 358#endif 359 360static const wxCmdLineEntryDesc winprint_cmd_line_desc[] = { 361 { 362 wxCMD_LINE_OPTION, 363 wxT_2("P"), 364 wxT_2("printer"), 365 wxT_2("choose printer"), 366 wxCMD_LINE_VAL_STRING 367 }, 368 { 369 wxCMD_LINE_SWITCH, 370 wxT_2("d"), 371 wxT_2("default"), 372 wxT_2("Use default printer") 373 }, 374 { 375 wxCMD_LINE_PARAM, 376 NULL, 377 NULL, 378 wxT_2("input file"), 379 wxCMD_LINE_VAL_STRING, 380 wxCMD_LINE_PARAM_OPTIONAL 381 }, 382 { wxCMD_LINE_NONE } 383}; 384 385#if __GNUC__ 386#pragma GCC diagnostic pop 387#endif 388 389 390%% constructor start 391WinprintFrame::WinprintFrame( 392 int wxid, 393 DkWxAppHelper *applicationHelper, 394 DkWxHelpController *hc, 395 int argc, 396 wxChar **argv, 397 wxChar const * const *localizedTexts, 398 wxChar const * const *nlWx, 399 dkChar const * const *nlDk, 400 dk3_print_conf_t *pPrintConf, 401 DK3_PCWXCHAR *printerNames, 402 size_t numberOfPrinters, 403 int defaultPrinterIndex 404) : DkWxFrame(nlWx[0], applicationHelper, hc, wxid), 405 cBlack(0, 0, 0), 406 cGreen(0, 127, 0), 407 cRed(127, 0, 0) 408{ 409 /* __CHANGE__ 012: Add further local variables. 410 */ 411 size_t i; /* Traverse pNames when creating wxsNames. */ 412 413 /* __CHANGE__ 012: Initialize further local variables. 414 */ 415 fdx = -1; fdy = -1; 416 pcx = -1; pcy = -1; 417 wxsNames = NULL; 418 pNames = printerNames; 419 nNames = numberOfPrinters; 420 nDefPrinter = defaultPrinterIndex; 421 pComm = NULL; 422 bCloseScheduled = false; 423 bAutostartWanted = false; 424 timeClose = (dk3_time_t)0UL; 425 sNamedFile = NULL; 426 sNamedPrinter = NULL; 427 bUseDefaultPrinter = false; 428 sTexts = localizedTexts; 429 sNlWx = nlWx; 430 sNlDk = nlDk; 431 pc = pPrintConf; 432#if defined(__WXMSW__) 433 wxIcon winprint_icon(sNlWx[4]); 434#else 435 wxIcon winprint_icon(winprint_xpm); 436#endif 437 /* __CHANGE__ 011: Initialize further class members. 438 */ 439%% constructor end 440 if(dkctGUILayoutOK) { 441 SetTitle(nlWx[0]); 442 } 443 if((pNames) && (nNames > 0)) { 444 wxsNames = new wxString[nNames]; 445 if(wxsNames) { 446 for(i = 0; i < nNames; i++) { 447 wxsNames[i] = wxString(pNames[i]); 448 } 449 } 450 } 451 pComm = new DkWxCommunicator( 452 applicationHelper->getWxEncoding(), 453 applicationHelper->getDkEncoding() 454 ); 455 if(argc > 1) { 456 bAutostartWanted = true; 457 { 458 wxChar const *ptr; 459 int res = -1; 460 wxCmdLineParser parser(winprint_cmd_line_desc, argc, argv); 461 { 462 wxLogNull log; 463 res = parser.Parse(false); 464 } 465 if(0 == res) { 466 wxString sPrinter(wxT("")); 467 if(pComm) { 468 pComm->autostartEnable(true); 469 } 470 if(parser.Found(wxT("d"))) { 471 /* Use default printer */ 472 bUseDefaultPrinter = true; 473 } else { 474 if(parser.Found(wxT("P"), &sPrinter)) { 475 /* Use named printer */ 476 wxCStrData printerstrdata = sPrinter.c_str(); 477 ptr = (wxChar const *)printerstrdata; 478 if(ptr) { 479 if(sNamedPrinter) { 480 dk3_release(sNamedPrinter); 481 } 482 sNamedPrinter = dk3wxs_dup(ptr); 483 } 484 } 485 } 486 if(parser.GetParamCount() > 0) { 487 wxString cmdfn; 488 wxString fullPath; 489 /* Print named file(s) */ 490 cmdfn = parser.GetParam(0); 491 wxFileName fn(cmdfn); 492 fn.Normalize( 493 wxPATH_NORM_LONG | wxPATH_NORM_DOTS 494 | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE 495 ); 496 fullPath = fn.GetFullPath(); 497 wxCStrData fullpathstrdata = fullPath.c_str(); 498 ptr = (wxChar const *)fullpathstrdata; 499 if(ptr) { 500 if(sNamedFile) { 501 dk3_release(sNamedFile); 502 } 503 sNamedFile = dk3wxs_dup(ptr); 504 } 505 } 506 } 507 } 508 } 509} 510 511 512 513%% module end 514 515 516 517WinprintFrame::~WinprintFrame() 518{ 519 size_t i; /* Index of current string to delete. */ 520 /* __CHANGE__ 011: Release resources allocated by further class members. 521 */ 522 if(wxsNames) { 523 for(i = 0; i < nNames; i++) { 524 wxsNames[i] = wxString(wxT("")); 525 } 526 delete [] wxsNames; 527 } 528 dk3_cpp_release(pComm); 529 if(sNamedPrinter) { 530 dk3_release(sNamedPrinter); 531 sNamedPrinter = NULL; 532 } 533 if(sNamedFile) { 534 dk3_release(sNamedFile); 535 sNamedFile = NULL; 536 } 537} 538 539 540 541bool 542WinprintFrame::canClose(bool isLast) 543{ 544 bool back = true; 545 546 /* __CHANGE__ 013: Check for unsaved data. 547 */ 548 549 return back; 550} 551 552 553void 554WinprintFrame::OnQuit(wxCommandEvent & event) 555{ 556 Close(); 557} 558 559 560 561void 562WinprintFrame::OnAbout(wxCommandEvent & event) 563{ 564 wxString text(wxT("")); /* Text to show. */ 565 wxString title(wxT("")); /* Windows title. */ 566 567 /* Construct message text. */ 568 text.Append(sNlWx[0]); 569 text.Append(sNlWx[7]); 570#if 0 571 text.Append(sNlWx[1]); 572#else 573 text.Append( DKT_VERSION_WX ); 574#endif 575 text.Append(sNlWx[8]); 576 text.Append(sTexts[9]); 577 text.Append(sNlWx[2]); 578 text.Append(sNlWx[8]); 579 text.Append(sNlWx[8]); 580 text.Append(sTexts[11]); 581 text.Append(sNlWx[8]); 582 text.Append(sNlWx[9]); 583 text.Append(sNlWx[8]); 584 text.Append(sNlWx[8]); 585 text.Append(sTexts[12]); 586 text.Append(sNlWx[8]); 587 text.Append(sNlWx[10]); 588 text.Append(sNlWx[8]); 589 text.Append(sNlWx[11]); 590 text.Append(sNlWx[8]); 591 text.Append(sNlWx[12]); 592 text.Append(sNlWx[8]); 593 text.Append(sNlWx[13]); 594 text.Append(sNlWx[8]); 595 text.Append(sNlWx[14]); 596 text.Append(sNlWx[8]); 597 text.Append(sNlWx[15]); 598 text.Append(sNlWx[8]); 599 600 /* Construct dialog box title. */ 601 title.Append(sTexts[10]); 602 title.Append(sNlWx[0]); 603 604 /* Show dialog box. */ 605 wxMessageBox(text, title, wxOK, this); 606 607 /* __CHANGE__ 019: Create better about box. 608 */ 609} 610 611 612 613void 614WinprintFrame::OnHelpContents(wxCommandEvent & event) 615{ 616 openHelp(); 617} 618 619/* __CHANGE__ 017: Event handlers for further events. 620*/ 621 622void 623WinprintFrame::OnPrint(wxCommandEvent & event) 624{ 625 (void)runJob(); 626} 627 628 629/* __CHANGE__ 014: Implementation of further methods. 630*/ 631 632 633/* __CHANGE__ 008: Remove OnIdle if no idle processing required. 634*/ 635 636void 637WinprintFrame::OnIdle(wxIdleEvent & event) 638{ 639 static BOOL firstIdle = true; /* Flag: First idle event of application. */ 640 dk3_time_t ct; /* Current time. */ 641 int res; /* Operation result. */ 642 $? "+ WinprintFrame::OnIdle" 643 /* __CHANGE__ 644 */ 645 if(firstIdle) { $? ". first idle event" 646 firstIdle = false; 647 tStatus->SetLabel(wxT("")); 648 Refresh(); 649 Update(); 650 /* For autostart */ 651 event.RequestMore(); 652 } else { $? ". not the first idle event" 653 if(!bCloseScheduled) { $? ". no close scheduled" 654 if(pComm) { $? ". pComm" 655 if((bAutostartWanted) && (pComm->autostartCanRun())) { 656 $? ". autostart wanted and possible" 657 res = runJob(); 658 if(res > 0) { $? ". request more" 659 event.RequestMore(); 660 } 661 } else { $? ". autostart not wanted or not possible" 662 if(pComm->autostartIsFinished()) { $? ". autostart finished" 663 if(!(timeClose)) { $? ". no close time yet" 664 if(pComm->getLogLevel() > DK3_LL_WARNING) { $? ". can close" 665 dk3sf_time(&timeClose); $? ". close time scheduled" 666 event.RequestMore(); 667 tStatus->SetLabel(sTexts[14]); $? ". tStatus 14" 668 tStatus->SetForegroundColour(cGreen); 669 Refresh(); 670 Update(); 671 } else { 672 tStatus->SetLabel(pComm->getText()); $? ". tStatus pComm" 673 tStatus->SetForegroundColour(cRed); 674 Refresh(); 675 Update(); 676 wxMessageBox( 677 pComm->getText(), sTexts[29], (wxICON_ERROR | wxOK), this 678 ); 679 dk3sf_time(&timeClose); $? ". can close" 680 event.RequestMore(); 681 } 682 } 683 } 684 if(timeClose) { $? ". found scheduled close time" 685 dk3sf_time(&ct); 686 if(ct > (timeClose + (dk3_time_t)1UL)) { $? ". close now" 687 timeClose = (dk3_time_t)0UL; 688 bCloseScheduled = true; 689 Show(false); 690 Close(); 691 } else { $? ". can not yet close" 692 event.RequestMore(); 693 } 694 } 695 } 696 } else { $? "! pComm" 697 /* ERROR: No communicator */ 698 if(timeClose) { 699 dk3sf_time(&ct); 700 if(ct > (timeClose * (dk3_time_t)1UL)) { 701 timeClose = (dk3_time_t)0UL; 702 bCloseScheduled = true; 703 Show(false); 704 Close(); 705 } else { 706 event.RequestMore(); 707 } 708 } 709 } 710 } else { $? ". close scheduled" 711 } 712 } 713 event.Skip(); 714 $? "- WinprintFrame::OnIdle" 715} 716 717 718 719int 720WinprintFrame::runFileNameJob(wxChar const *filename) 721{ 722 wxChar prbuf[512]; /* Printer name system enc */ 723 wxChar const *printername = NULL; /* Printer name */ 724 int res = 0; /* Operation result */ 725 int ok = 0; /* Flag: Success */ 726 int back = 0; /* Function result */ 727 $? "+ runFileNameJob" 728 if(filename) { $? ". have file" 729 if(bUseDefaultPrinter) { $? ". use default printer" 730 if(pc) { $? ". have print conf" 731 if(pc->defPrinter) { $? ". default printer" 732 if((pc->defPrinter->name)) { $? ". default printer name ok" 733 res = dk3wxs_from_dkstr( 734 prbuf, 735 DK3_SIZEOF(prbuf,wxChar), 736 pHelper->getWxEncoding(), 737 (pc->defPrinter)->name, 738 pHelper->getDkEncoding() 739 ); 740 if(res) { $? ". name conversion ok" 741 printername = prbuf; 742 } else { $? "! name conversion failed" 743 /* ERROR: Failed to convert printer name! */ 744 setErrorStatus(sTexts[24], filename); $? ". setErrorStatus 24" 745 } 746 } else { $? "! no default printer name" 747 /* ERROR: No default printer name */ 748 setErrorStatus(sTexts[25], filename); $? ". setErrorStatus 25" 749 } 750 } else { $? "! no default printer" 751 /* ERROR: No default printer */ 752 setErrorStatus(sTexts[25], filename); $? ". setErrorStatus 25" 753 } 754 } else { $? "! no print conf" 755 /* ERROR: No print configuration */ 756 setErrorStatus(sTexts[26], filename); $? ". setErrorStatus 26" 757 } 758 } else { $? ". non-default printer" 759 if(sNamedPrinter) { $? ". named printer" 760 printername = sNamedPrinter; 761 } else { $? ". choose printer" 762 if((pNames) && (wxsNames) && (nNames > 0)) { $? ". variables" 763 WinprintChooserDialog dlg(this, sTexts[30], sTexts, wxsNames, nNames); 764 dlg.setCurrentPrinter(nDefPrinter); 765 pHelper->setRelatedPosition(this, &dlg, &pcx, &pcy); 766 if(wxID_OK == dlg.ShowModal()) { $? ". dialog ok" 767 nDefPrinter = dlg.getCurrentPrinter(); 768 if((nDefPrinter >= 0) && (nDefPrinter < (int)nNames)) { $? ". ok" 769 printername = pNames[nDefPrinter]; 770 } else { $? "! wrong index" 771 /* BUG: Illegal return value from dialog */ 772 setErrorStatus(sTexts[26], filename); $? ". setErrorStatus 26" 773 } 774 } else { $? ". aborted by user" 775 /* ERROR: Aborted by user */ 776 setErrorStatus(sTexts[19], filename); $? ". setErrorStatus 19" 777 } 778 dlg.GetPosition(&pcx, &pcy); 779 } else { $? "! variables" 780 /* ERROR: No printer configuration */ 781 setErrorStatus(sTexts[26], filename); $? ". setErrorStatus 26" 782 } 783 } 784 } 785 } else { $? "! no file name" 786 } 787 if((filename) && (printername)) { $? ". both names ok" 788 /* wxMessageBox(filename, printername); */ 789 if(pComm) { $? ". communicator ok" 790 DkWxProgressDialog *pd; 791 pComm->prepareRun(); 792 pd = new DkWxProgressDialog( 793 (DkWxFrame *)this, 794 pComm, 795 NULL, 796 sTexts[20], 797 filename, 798 sTexts[21], 799 sTexts[22], 800 sTexts[23] 801 ); 802 if(pd) { $? ". pd" 803 WinprintThread *pt; 804 pt = new WinprintThread( 805 pComm, sTexts, pHelper, pc, filename, printername 806 ); 807 if(pt) { $? ". pt" 808 if(wxTHREAD_NO_ERROR == pt->Create()) { $? ". pt->Create" 809 pt->SetPriority(WXTHREAD_DEFAULT_PRIORITY); 810 pt->Run(); 811 pd->chooseModalPosition(); 812 pd->ShowModal(); 813 ok = 1; 814 if(pComm->getLogLevel() <= DK3_LL_WARNING) { $? "! warning" 815 /* ERRORS occured */ 816 tStatus->SetLabel(pComm->getText()); $? ". tStatus pComm" 817 tStatus->SetForegroundColour(cRed); 818 } else { $? ". success" 819 /* Transfer succeeeded */ 820 if(!(bAutostartWanted)) { 821 tStatus->SetLabel(sTexts[37]); $? ". tStatus 37" 822 tStatus->SetForegroundColour(cGreen); 823 } 824 } 825 Refresh(); 826 Update(); 827 back = 1; 828 } else { $? "! pt->Create" 829 /* ERROR: Create method failed! */ 830 setErrorStatus(sTexts[27], filename); $? ". setErrorStatus 27" 831 } 832 } else { $? "! pt" 833 /* ERROR: Failed to create thread */ 834 setErrorStatus(sTexts[27], filename); $? ". setErrorStatus 27" 835 } 836 pd->Destroy(); 837 } else { $? "! pd" 838 /* ERROR: Failed to create progress dialog */ 839 setErrorStatus(sTexts[28], filename); $? ". setErrorStatus 28" 840 } 841 } else { $? "! communicator" 842 /* ###### ERROR: No communicator */ 843 } 844 } else { $? "! name missing" 845 if(pComm) { 846 if(!(filename)) { 847 } 848 if(!(printername)) { 849 } 850 } else { 851 /* ##### ERROR: No communicator */ 852 } 853 } 854 $? "- runFileNameJob %d", back 855 return back; 856} 857 858 859 860int 861WinprintFrame::runJob(void) 862{ 863 wxString path; /* File path. */ 864 wxChar const *filename = NULL; /* File name. */ 865 int back = 0; 866 $? "+ WinprintFrame::runJob" 867 tStatus->SetLabel(sTexts[17]); $? ". tStatus 17" 868 tStatus->SetForegroundColour(cBlack); 869 Refresh(); 870 Update(); 871 if(sNamedFile) { $? ". named file" 872 filename = sNamedFile; 873 back = runFileNameJob(filename); 874 } else { $? ". no named file" 875 wxString s(wxT("")); 876 s.Append(wxT("Print files (*.prn)|*.prn")); 877 s.Append(wxT("|All files (*.*)|*.*")); 878#if wxCHECK_VERSION(2, 9, 0) 879 wxFileDialog dlg(this, sTexts[18], wxT("."), wxT(""), s, wxFD_OPEN); 880#else 881 wxFileDialog dlg(this, sTexts[18], wxT("."), wxT(""), s, wxOPEN); 882#endif 883 pHelper->setRelatedPosition(this, &dlg, &fdx, &fdy); 884 if(wxID_OK == dlg.ShowModal()) { 885 path = dlg.GetPath(); 886 wxCStrData pathstrdata = path.c_str(); 887 filename = (wxChar const *)pathstrdata; 888 if (NULL != filename) { 889 back = runFileNameJob(filename); 890 } 891 } else { 892 /* Aborted by user */ 893 setErrorStatus(sTexts[19], NULL); $? ". setErrorStatus 19" 894 } 895 dlg.GetPosition(&fdx, &fdy); 896 } 897 $? "- WinprintFrame::runJob %d", back 898 return back; 899} 900 901 902 903void 904WinprintFrame::setErrorStatus(wxChar const *txt, wxChar const *filename) 905{ 906 if(pComm) { 907 pComm->prepareRun(); 908 pComm->addWxText(txt); 909 pComm->setLogLevel(DK3_LL_ERROR); 910 pComm->setUpdates(((filename) ? filename : wxT("")), 1000); 911 pComm->setRunning(0); 912 } 913 tStatus->SetLabel(txt); 914 tStatus->SetForegroundColour(cRed); 915 Refresh(); 916 Update(); 917} 918 919 920