1%% options 2 3copyright owner = Dirk Krause 4 5copyright year = 2018-xxxx 6 7SPDX-License-Identifier: BSD-3-Clause 8 9 10 11%% wx-gui 12 13type = frame 14contents = mainSizer 15icon = wxbmpp_icon 16status bar = 1 sTexts[8] 17menu bar = mbMain 18tool bar = tbMain 19 20[wxMenuBar mbMain] 21contents = menuFile 22contents = menuConversion 23contents = menuExtras 24contents = menuHelp 25 26[wxMenu menuFile] 27text = sTexts[0] 28contents = miFileDirectory 29contents = miFileExit 30 31[wxMenu menuConversion] 32text = sTexts[67] 33contents = miConversionRun 34 35[wxMenuItem miFileDirectory] 36id = Bmpp4Frame_Choose_Directory 37text = sTexts[65] 38tip = sTexts[66] 39 40[wxMenuItem miFileExit] 41id = Bmpp4Frame_Quit 42text = sTexts[1] 43tip = sTexts[2] 44 45[wxMenuItem miConversionRun] 46id = Bmpp4Frame_Run_Conversion 47text = sTexts[68] 48tip = sTexts[69] 49 50[wxMenu menuExtras] 51text = sTexts[72] 52contents = miExtrasOptionReset 53 54[wxMenuItem miExtrasOptionReset] 55text = sTexts[73] 56id = Bmpp4Frame_Reset_Options 57tip = sTexts[122] 58 59[wxMenu menuHelp] 60text = sTexts[3] 61contents = miHelpAbout 62contents = miHelpContents 63 64[wxMenuItem miHelpAbout] 65id = Bmpp4Frame_Help_About 66text = sTexts[4] 67tip = sTexts[5] 68 69[wxMenuItem miHelpContents] 70id = Bmpp4Frame_Help_Contents 71text = sTexts[6] 72tip = sTexts[7] 73 74[wxToolBar tbMain] 75contents = bChooseDir 76contents = bRunConversion 77 78[wxToolBarToolBase bChooseDir] 79bitmap = xpm_choose_dir 80text = sTexts[65] 81tip = sTexts[66] 82id = Bmpp4Frame_Choose_Directory 83 84[wxToolBarToolBase bRunConversion] 85bitmap = xpm_run_conversion 86text = sTexts[68] 87tip = sTexts[69] 88id = Bmpp4Frame_Run_Conversion 89 90[wxBoxSizer mainSizer] 91direction = horizontal 92contents = $space(10) 93contents = verticalSizer 94contents = $space(10) 95 96[wxBoxSizer verticalSizer] 97direction = vertical 98grow = yes 99proportion = 1 100contents = $space(10) 101contents = contentsSizer 102contents = $space(10) 103 104[wxGridBagSizer contentsSizer] 105grid = 5 5 106contents = staticline0 0 0 1 11 centered-x centered-y 107contents = lDirectoryName +1 0 1 11 centered-x centered-y 108contents = staticline1 +1 0 1 11 centered-x centered-y 109contents = cbMakeMode +1 0 1 7 left centered-y 110contents = cbColorOutput . 7 1 1 left centered-y 111contents = $space(10,1) . +1 1 1 left centered-y 112contents = lRgbToGray . +1 1 1 left centered-y 113contents = chRgbToGray . +1 1 1 left centered-y 114contents = lOutputMode +1 0 1 1 right centered-y 115contents = chOutputMode . +1 1 2 left centered-y 116contents = cbImgInterpolation . 7 1 4 left centered-y 117contents = lPsLevel +1 0 1 1 right centered-y 118contents = chPsLevel . +1 1 1 left centered-y 119contents = cbDsc . +1 1 1 left centered-y 120contents = cbLzw . +1 1 1 left centered-y 121contents = cbAnBpc . 7 1 4 left centered-y 122contents = lPaperSize +1 0 1 1 right centered-y 123contents = chPaperSizes . +1 1 2 left centered-y 124contents = cbRotation . 3 1 2 left centered-y 125contents = cbAnColor . 7 1 4 left centered-y 126contents = lFinishing +1 0 1 1 right centered-y 127contents = chFinishing . +1 1 2 left centered-y 128contents = cbAnAlpha . 7 1 4 left centered-y 129contents = lResolution +1 0 1 1 right centered-y 130contents = chResolution . +1 1 2 left centered-y 131contents = tfResolution . 3 1 1 left centered-y 132contents = cbSizeLaTeX . 7 1 4 left centered-y 133contents = lBackground +1 0 1 1 right centered-y 134contents = ccBackground . +1 1 1 left centered-y 135contents = cbBackground . 2 1 3 left centered-y 136contents = cbDct . 7 1 4 left centered-y 137contents = cbDctInterpolation +1 7 1 4 left centered-y 138 139 140# 141# Configuration before 2021-08-02 142# 143 144# contents = staticline0 0 0 1 11 centered-x centered-y 145# contents = lDirectoryName +1 0 1 11 centered-x centered-y 146# contents = staticline1 +1 0 1 11 centered-x centered-y 147# contents = cbMakeMode +1 0 1 7 left centered-y 148# contents = cbColorOutput . 7 1 1 left centered-y 149# contents = $space(10,1) . +1 1 1 left centered-y 150# contents = lRgbToGray . +1 1 1 left centered-y 151# contents = chRgbToGray . +1 1 1 left centered-y 152# contents = lOutputMode +1 0 1 1 right centered-y 153# contents = chOutputMode . +1 1 2 left centered-y 154# contents = cbImgInterpolation . 7 1 4 left centered-y 155# contents = lPsLevel +1 0 1 1 right centered-y 156# contents = chPsLevel . +1 1 1 left centered-y 157# contents = cbDsc . +1 1 1 left centered-y 158# contents = cbLzw . +1 1 1 left centered-y 159# contents = cbDct . 7 1 4 left centered-y 160# contents = lPaperSize +1 0 1 1 right centered-y 161# contents = chPaperSizes . +1 1 2 left centered-y 162# contents = cbRotation . 3 1 2 left centered-y 163# contents = cbDctInterpolation . 7 1 4 left centered-y 164# contents = lFinishing +1 0 1 1 right centered-y 165# contents = chFinishing . +1 1 2 left centered-y 166# contents = cbAnBpc . 7 1 4 left centered-y 167# contents = lResolution +1 0 1 1 right centered-y 168# contents = chResolution . +1 1 2 left centered-y 169# contents = tfResolution . 3 1 1 left centered-y 170# contents = cbAnColor . 7 1 4 left centered-y 171# contents = lBackground +1 0 1 1 right centered-y 172# contents = ccBackground . +1 1 1 left centered-y 173# contents = cbBackground . 2 1 3 left centered-y 174# contents = cbAnAlpha . 7 1 4 left centered-y 175 176 177 178[wxStaticLine staticline0] 179grow = yes 180 181[wxStaticText lDirectoryName] 182text = slDirname 183text style = left 184grow = yes 185 186[wxStaticLine staticline1] 187grow = yes 188 189[wxCheckBox cbMakeMode] 190text = sTexts[13] 191tip = sTexts[14] 192 193[wxCheckBox cbColorOutput] 194text = sTexts[15] 195tip = sTexts[16] 196id = Bmpp4Frame_Color_Output 197 198[wxStaticText lRgbToGray] 199text = sTexts[89] 200 201[wxChoice chRgbToGray] 202choices = 13 saRgbToGray 203tip = sTexts[90] 204 205[wxStaticText lOutputMode] 206text = sTexts[17] 207 208[wxChoice chOutputMode] 209choices = 6 saOutputMode 210tip = sTexts[24] 211grow = yes 212id = Bmpp4Frame_Output_Type 213 214[wxCheckBox cbImgInterpolation] 215text = sTexts[25] 216tip = sTexts[26] 217id = Bmpp4Frame_Change_Interpolation 218 219[wxStaticText lPsLevel] 220text = sTexts[27] 221 222[wxChoice chPsLevel] 223choices = 2 saPsLevel 224tip = sTexts[30] 225id = Bmpp4Frame_PS_Level 226 227[wxCheckBox cbDsc] 228text = sTexts[31] 229tip = sTexts[32] 230 231[wxCheckBox cbLzw] 232text = sTexts[33] 233tip = sTexts[34] 234 235[wxCheckBox cbSizeLaTeX] 236text = sTexts[126] 237tip = sTexts[127] 238 239[wxCheckBox cbDct] 240text = sTexts[35] 241tip = sTexts[36] 242 243[wxStaticText lPaperSize] 244text = sTexts[37] 245 246[wxChoice chPaperSizes] 247choices = asPaperSizes 248tip = sTexts[38] 249grow = yes 250 251[wxCheckBox cbRotation] 252text = sTexts[39] 253tip = sTexts[40] 254 255[wxCheckBox cbDctInterpolation] 256text = sTexts[41] 257tip = sTexts[42] 258 259[wxStaticText lFinishing] 260text = sTexts[43] 261 262[wxChoice chFinishing] 263choices = 3 saFinishing 264tip = sTexts[47] 265grow = yes 266 267[wxCheckBox cbAnBpc] 268text = sTexts[48] 269tip = sTexts[49] 270 271[wxStaticText lResolution] 272text = sTexts[50] 273 274[wxChoice chResolution] 275choices = 3 saResolution 276tip = sTexts[51] 277grow = yes 278id = Bmpp4Frame_Resolution 279 280[wxTextCtrl tfResolution] 281text = sTexts[55] 282grow = yes 283 284[wxCheckBox cbAnColor] 285text = sTexts[57] 286tip = sTexts[58] 287 288[wxStaticText lBackground] 289text = sTexts[59] 290 291[Dk4WxColourView ccBackground] 292constructor = applicationHelper, 255, 255, 255 293tip = sTexts[60] 294 295[wxCheckBox cbBackground] 296text = sTexts[61] 297tip = sTexts[62] 298 299[wxCheckBox cbAnAlpha] 300text = sTexts[63] 301tip = sTexts[64] 302 303 304 305 306%% header start 307 308 309 310%% class start 311class Bmpp4Frame : public Dk4WxFrame 312{ 313 private: 314 315 /** Event table for frame. 316 */ 317 318#if wxCHECK_VERSION(3,0,0) 319 wxDECLARE_EVENT_TABLE(); 320#else 321 DECLARE_EVENT_TABLE() 322#endif 323 324 private: 325 326 /** Start time. 327 */ 328 dk4_time_t firsttime; 329 330 /** We are already correcting GUI, no recursive attempt. 331 */ 332 bool bIsCorrecting; 333 334 protected: 335 336 /** Auto start controller. 337 */ 338 Dk4WxAutostartController oAsc; 339 340 /** Text color for status text on error. 341 */ 342 wxColour cRed; 343 344 /** Text color for status text on success. 345 */ 346 wxColour cGreen; 347 348 /** Normal text color. 349 */ 350 wxColour cBlack; 351 352 /** Localized texts. 353 */ 354 wxChar const * const *sTexts; 355 356 /** Non-localized texts. 357 */ 358 wxChar const * const *sNlWx; 359 360 /** Non-localized texts. 361 */ 362 dkChar const * const *sNlDk; 363 364 /* __CHANGE__ 011: Add further member variables. 365 */ 366 367 /** Graphics output configuration. 368 */ 369 dk4_gra_conf_t graconf; 370 371 /** Known paper sizes. 372 */ 373 dk4_paper_size_t *pPaperSizes; 374 375 /** Paper sizes. 376 */ 377 wxArrayString asPaperSizes; 378 379 /** Directory name. 380 */ 381 wxString sDirname; 382 383 /** Number of paper sizes in asPaperSizes. 384 */ 385 size_t szPaperSizes; 386 387 /** Restore and save graphics conversion settings. 388 */ 389 bool bRestoreGx; 390 391 /** Restore and save Make mode setting. 392 */ 393 bool bRestoreMake; 394 395 /** Restore and save location to process. 396 */ 397 bool bRestoreLocation; 398 399 /** Make mode setting from options, if not restored. 400 */ 401 bool bMakeMode; 402 403 /** Automatically start. 404 */ 405 bool bAutorun; 406 407 /** Flag: Processing idle events. 408 */ 409 bool bActive; 410 411%% class end 412 413 public: 414 415 /** Constructor. 416 @param wxid Window ID. 417 @param applicationHelper Application helper object. 418 @param hc Help controller for online help. 419 @param localizedTexts Localized wxChar texts. 420 @param nlWx Non-localized wxChar texts. 421 @param nlDk Non-localized dkChar texts. 422 */ 423 Bmpp4Frame( 424 int wxid, 425 Dk4WxApplicationHelper *applicationHelper, 426 Dk4WxHelpController *hc, 427 wxChar const * const *localizedTexts, 428 wxChar const * const *nlWx, 429 dkChar const * const *nlDk, 430 dk4_gra_conf_t *pgc, 431 wxArrayString *pPapSiz, 432 wxChar *pDir, 433 size_t szPap, 434 bool bRGx, 435 bool bRMa, 436 bool bRLo, 437 bool bMak, 438 bool bRun, 439 dk4_paper_size_t *pSizes 440 ); 441 442 /** Destructor. 443 */ 444 ~Bmpp4Frame(); 445 446 /** Check whether we can close the window. 447 @param isLast Flag: Last main window to close. 448 */ 449 bool 450 CanClose(bool isFinal); 451 452 /** Save current settings. 453 */ 454 void 455 SaveSettings(void); 456 457 /** Restore settings from previous session. 458 */ 459 void 460 RestoreSettings(void); 461 462 463 /** Modify enabled or disabled state of GUI components. 464 */ 465 void 466 CorrectGUI(void); 467 468 /** Check for documents whether paper size is usable. 469 @return True on success, false on error. 470 */ 471 bool 472 CheckPaperSizeForDocuments(void); 473 474 /** Run Conversion. 475 @return True on success, false on error. 476 */ 477 bool 478 RunConversion(void); 479 480 /** Handler for File/Exit. 481 @param event Event to process. 482 */ 483 void 484 OnQuit(wxCommandEvent & event); 485 486 /** Handler for Help/About. 487 @param event Event to process. 488 */ 489 void 490 OnAbout(wxCommandEvent & event); 491 492 /** Handler for Help/Contents. 493 @param event Event to process. 494 */ 495 void 496 OnHelpContents(wxCommandEvent & event); 497 498 /* __CHANGE__ 008: Remove OnIdle if no idle processing required. 499 */ 500 /** Handler for idle events. 501 */ 502 void 503 OnIdle(wxIdleEvent & event); 504 505 /* __CHANGE__ 017: Event handlers for further events. 506 */ 507 508 /** Handler for choose directory command. 509 */ 510 void 511 OnChooseDirectory(wxCommandEvent & event); 512 513 /** Handler for reset options command. 514 */ 515 void 516 OnResetOptions(wxCommandEvent & event); 517 518 519 /** Handler for run conversion command. 520 */ 521 void 522 OnRunConversion(wxCommandEvent & event); 523 524 /** Handler for output type change. 525 */ 526 void 527 OnOutputType(wxCommandEvent & event); 528 529 /** Handler for PS level change. 530 */ 531 void 532 OnPSLevel(wxCommandEvent & event); 533 534 /** Handler for resolution setting change. 535 */ 536 void 537 OnResolution(wxCommandEvent & event); 538 539 /** Handler for interpolation checkbox change. 540 */ 541 void 542 OnInterpolationChange(wxCommandEvent & event); 543 544 /** Handler for color output checkbox change. 545 */ 546 void 547 OnColorOutput(wxCommandEvent & event); 548 549 /* __CHANGE__ 014: Add further methods. 550 */ 551 552 /** Place configuration settings from graconf to GUI. 553 */ 554 void 555 ConfigurationToGUI(void); 556 557 /** Fill graconf from GUI. 558 */ 559 void 560 ConfigurationFromGUI(void); 561 562}; 563 564%% header end 565 566 567/* vim: set ai sw=4 ts=4 : */ 568%% module start 569 570#include <wxbmpp/wxbmpp.h> 571 572#if !defined(__WXMSW__) 573#include "gui-img/icons/dkicon.xpm" 574#endif 575 576#include "gui-img/shared/toolbar/choose-dir.xpm" 577#include "gui-img/shared/toolbar/run-conversion.xpm" 578 579#ifndef DK4MAIXDBL_H_INCLUDED 580#include <libdk4maioxd/dk4maixdbl.h> 581#endif 582 583#ifndef DK4MAOXDBL_H_INCLUDED 584#include <libdk4maioxd/dk4maoxdbl.h> 585#endif 586 587$!trace-include 588 589 590 591/* __CHANGE__ 017: Add further events. */ 592/* __CHANGE__ 008: Remove OnIdle if no idle processing required. */ 593#if wxCHECK_VERSION(3,0,0) 594wxBEGIN_EVENT_TABLE(Bmpp4Frame,wxFrame) 595#else 596BEGIN_EVENT_TABLE(Bmpp4Frame,wxFrame) 597#endif 598 EVT_MENU(Bmpp4Frame_Quit, Bmpp4Frame::OnQuit) 599 EVT_MENU(Bmpp4Frame_Help_About, Bmpp4Frame::OnAbout) 600 EVT_MENU(Bmpp4Frame_Help_Contents, Bmpp4Frame::OnHelpContents) 601 EVT_MENU(Bmpp4Frame_Choose_Directory, Bmpp4Frame::OnChooseDirectory) 602 EVT_MENU(Bmpp4Frame_Run_Conversion, Bmpp4Frame::OnRunConversion) 603 EVT_MENU(Bmpp4Frame_Reset_Options, Bmpp4Frame::OnResetOptions) 604 EVT_CHOICE(Bmpp4Frame_Output_Type, Bmpp4Frame::OnOutputType) 605 EVT_CHOICE(Bmpp4Frame_PS_Level, Bmpp4Frame::OnPSLevel) 606 EVT_CHOICE(Bmpp4Frame_Resolution, Bmpp4Frame::OnResolution) 607 EVT_CHECKBOX(Bmpp4Frame_Color_Output, Bmpp4Frame::OnColorOutput) 608 EVT_CHECKBOX(Bmpp4Frame_Change_Interpolation, Bmpp4Frame::OnInterpolationChange) 609 EVT_IDLE(Bmpp4Frame::OnIdle) 610#if wxCHECK_VERSION(3,0,0) 611wxEND_EVENT_TABLE() 612#else 613END_EVENT_TABLE() 614#endif 615 616 617/** Option name to restore make setting. 618*/ 619static const wxChar * const i_dir_names[] = { 620$!string-table macro=wxT 621wxbmpp.location 622$!end 623}; 624 625 626/** Option name to restore make setting. 627*/ 628static const wxChar * const i_make_names[] = { 629$!string-table macro=wxT 630wxbmpp.make 631$!end 632}; 633 634 635/** Names for saving and restoring options. 636*/ 637static const wxChar * const i_option_names[] = { 638$!string-table macro=wxT 639wxbmpp.paper.choice 640wxbmpp.output.type 641wxbmpp.output.color 642wxbmpp.ps.level 643wxbmpp.ps.dsc 644wxbmpp.ps.lzw 645wxbmpp.paper.rotate 646wxbmpp.paper.duplex 647wxbmpp.resolution.type 648wxbmpp.image.background.red 649wxbmpp.image.background.green 650wxbmpp.image.background.blue 651wxbmpp.image.bg.enforce 652wxbmpp.image.interpolation 653wxbmpp.image.dct 654wxbmpp.image.dct-interpolation 655wxbmpp.image.analysis.bpc 656wxbmpp.image.analysis.color 657wxbmpp.image.analysis.alpha 658wxbmpp.image.rgb-to-gray 659wxbmpp.output.latex 660$!end 661}; 662 663 664#if 0 665/** Names for saving and restoring options. 666*/ 667static const wxChar * const s_option_names[] = { 668$!string-table macro=wxT 669wxbmpp.paper.name 670$!end 671}; 672#endif 673 674 675#if 0 676/** Names for saving and restoring options. 677*/ 678static const wxChar * const d_option_names[] = { 679$!string-table macro=wxT 680wxbmpp.resolution.value 681$!end 682}; 683#endif 684 685 686 687%% constructor start 688Bmpp4Frame::Bmpp4Frame( 689 int wxid, 690 Dk4WxApplicationHelper *applicationHelper, 691 Dk4WxHelpController *hc, 692 wxChar const * const *localizedTexts, 693 wxChar const * const *nlWx, 694 dkChar const * const *nlDk, 695 dk4_gra_conf_t *pgc, 696 wxArrayString *pPapSiz, 697 wxChar *pDir, 698 size_t szPap, 699 bool bRGx, 700 bool bRMa, 701 bool bRLo, 702 bool bMak, 703 bool bRun, 704 dk4_paper_size_t *pSizes 705) : Dk4WxFrame(nlWx[0], applicationHelper, hc, wxid), 706 cRed(127, 0, 0), 707 cGreen(0, 127, 0), 708 cBlack(0, 0, 0), 709 asPaperSizes(*pPapSiz) 710{ 711 wxString saOutputMode[] = { 712 wxString(localizedTexts[18]), 713 wxString(localizedTexts[19]), 714 wxString(localizedTexts[20]), 715 wxString(localizedTexts[21]), 716 wxString(localizedTexts[22]), 717 wxString(localizedTexts[23]) 718 }; 719 wxString saPsLevel[] = { 720 wxString(localizedTexts[28]), 721 wxString(localizedTexts[29]) 722 }; 723 wxString saFinishing[] = { 724 wxString(localizedTexts[44]), 725 wxString(localizedTexts[45]), 726 wxString(localizedTexts[46]) 727 }; 728 wxString saResolution[] = { 729 wxString(localizedTexts[52]), 730 wxString(localizedTexts[53]), 731 wxString(localizedTexts[54]) 732 }; 733 wxString saRgbToGray[] = { 734 wxString(localizedTexts[76]), 735 wxString(localizedTexts[77]), 736 wxString(localizedTexts[78]), 737 wxString(localizedTexts[79]), 738 wxString(localizedTexts[80]), 739 wxString(localizedTexts[81]), 740 wxString(localizedTexts[82]), 741 wxString(localizedTexts[83]), 742 wxString(localizedTexts[84]), 743 wxString(localizedTexts[85]), 744 wxString(localizedTexts[86]), 745 wxString(localizedTexts[87]), 746 wxString(localizedTexts[88]) 747 }; 748 wxString slDirname(localizedTexts[70]); 749 $? "+ Bmpp4Frame::Bmpp4Frame" 750 /* __CHANGE__ 012: Add further local variables. 751 */ 752 753 /* __CHANGE__ 012: Initialize further local variables. 754 */ 755 bIsCorrecting = false; 756 757 sTexts = localizedTexts; 758 sNlWx = nlWx; 759 sNlDk = nlDk; 760#if defined(__WXMSW__) 761 wxIcon wxbmpp_icon(sNlWx[4]); 762#else 763 wxIcon wxbmpp_icon(xpm_dkicon); 764#endif 765 766 /* __CHANGE__ 011: Initialize further class members. 767 */ 768 pPaperSizes = pSizes; 769 DK4_MEMCPY(&graconf,pgc,sizeof(dk4_gra_conf_t)); 770 if (NULL != pDir) { 771 sDirname = wxString(pDir); 772 slDirname = sDirname; 773 } 774 szPaperSizes = szPap; 775 bRestoreGx = bRGx; 776 bRestoreMake = bRMa; 777 bRestoreLocation = bRLo; 778 bMakeMode = bMak; 779 bAutorun = bRun; 780 if (bAutorun) { 781 oAsc.SetAutoStart(true); 782 oAsc.SetAutoExit(true); 783 } 784 else { 785 oAsc.SetAutoStart(false); 786 oAsc.SetAutoExit(false); 787 } 788 bActive = true; 789 dk4time_get(&firsttime); 790 791%% constructor end 792 if(dkctGUILayoutOK) { 793 chOutputMode->SetSelection(0); 794 chPsLevel->SetSelection(0); 795 chFinishing->SetSelection(0); 796 chResolution->SetSelection(0); 797 chPaperSizes->SetSelection(0); 798 chRgbToGray->SetSelection(0); 799 CorrectGUI(); 800 SetTitle(nlWx[0]); 801#if 0 802 /* 2018-05-27 Test for setActive() method. 803 This line was added temporarily just to test the 804 new setActive() method. 805 */ 806 ccBackground->SetActive(false); 807 $? ". ccBackground inactive" 808#endif 809 ccBackground->SetPlaceColourChooser(); 810 } 811 812 /* __CHANGE__ 012: Release resources allocated by local variables. 813 */ 814 815 $? "- Bmpp4Frame::Bmpp4Frame" 816} 817 818%% module end 819 820 821 822Bmpp4Frame::~Bmpp4Frame() 823{ 824 $? "+ Bmpp4Frame::~Bmpp4Frame" 825 826 /* __CHANGE__ 011: Release resources allocated by further class members. 827 */ 828 829 $? "- Bmpp4Frame::~Bmpp4Frame" 830} 831 832 833 834bool 835Bmpp4Frame::CanClose(bool isLast) 836{ 837 bool back = true; 838 $? "+ Bmpp4Frame::CanClose isLast=%d", (isLast ? 1 : 0) 839 840 /* __CHANGE__ 013: Check for unsaved data. 841 */ 842 if (isLast) { 843 SaveSettings(); 844 } 845 846 $? "- Bmpp4Frame::CanClose %d", (back ? 1 : 0) 847 return back; 848} 849 850 851void 852Bmpp4Frame::OnQuit(wxCommandEvent & WXUNUSED(event)) 853{ 854 $? "+ Bmpp4Frame::OnQuit" 855 $? "- Bmpp4Frame::OnQuit" 856 Close(); 857} 858 859 860 861void 862Bmpp4Frame::OnAbout(wxCommandEvent & WXUNUSED(event)) 863{ 864 wxString text(wxT("")); 865 wxString title(wxT("")); 866 $? "+ Bmpp4Frame::OnAbout" 867 /* Construct message text. */ 868 text.Append(sNlWx[0]); 869 text.Append(sNlWx[7]); 870#if 0 871 text.Append(sNlWx[1]); 872#else 873 text.Append(DKT_VERSION_WX); 874#endif 875 text.Append(sNlWx[8]); 876 text.Append(sTexts[9]); 877 text.Append(sNlWx[2]); 878 text.Append(sNlWx[8]); 879 text.Append(sNlWx[8]); 880 text.Append(sTexts[11]); 881 text.Append(sNlWx[8]); 882 text.Append(sNlWx[9]); 883 text.Append(sNlWx[8]); 884 text.Append(sNlWx[8]); 885 text.Append(sTexts[12]); 886 text.Append(sNlWx[8]); 887 text.Append(sNlWx[10]); 888 text.Append(sNlWx[8]); 889 text.Append(sNlWx[11]); 890 text.Append(sNlWx[8]); 891 text.Append(sNlWx[12]); 892 text.Append(sNlWx[8]); 893 text.Append(sNlWx[13]); 894 text.Append(sNlWx[8]); 895 text.Append(sNlWx[14]); 896 text.Append(sNlWx[8]); 897 text.Append(sNlWx[15]); 898 text.Append(sNlWx[8]); 899 900 /* Construct dialog box title. */ 901 title.Append(sTexts[10]); 902 title.Append(sNlWx[0]); 903 904 /* Show dialog box. */ 905 wxMessageBox(text, title); 906 907 /* __CHANGE__ 019: Create better about box. 908 */ 909 $? "- Bmpp4Frame::OnAbout" 910} 911 912 913 914void 915Bmpp4Frame::OnHelpContents(wxCommandEvent & WXUNUSED(event)) 916{ 917 $? "+ Bmpp4Frame::OnHelpContents" 918 DisplayContents(); 919 $? "- Bmpp4Frame::OnHelpContents" 920} 921 922 923/* __CHANGE__ 017: Event handlers for further events. 924*/ 925 926 927void 928Bmpp4Frame::OnChooseDirectory(wxCommandEvent & WXUNUSED(event)) 929{ 930 $? "+ Bmpp4Frame::OnChooseDirectory" 931 wxDirDialog dd( 932 this, sTexts[71], sDirname, (wxDD_DIR_MUST_EXIST | wxDD_CHANGE_DIR) 933 ); 934 pAppHelp->ChooseChildPosition(*this, dd, false); 935 if(dd.ShowModal() == wxID_OK) { 936 sDirname = dd.GetPath(); 937 lDirectoryName->SetLabel(sDirname); 938#if 0 939 lDirectoryName->(wxALIGN_CENTRE_HORIZONTAL); 940#endif 941 Refresh(); 942 Update(); 943 } 944 else { 945 } 946 $? "- Bmpp4Frame::OnChooseDirectory" 947} 948 949 950 951void 952Bmpp4Frame::OnResetOptions(wxCommandEvent & WXUNUSED(event)) 953{ 954 wxString sA4(wxT("a4")); 955 int res; 956 $? "+ OnResetOptions" 957 res = wxMessageBox( 958 sTexts[75], sTexts[74], (wxNO_DEFAULT | wxYES_NO | wxICON_QUESTION) 959 ); 960 if (wxYES == res) { 961 dk4gra_conf_init(&graconf); 962 res = asPaperSizes.Index(sA4); 963 if (wxNOT_FOUND != res) { 964 chPaperSizes->SetSelection(res); 965 dk4mem_cpy( 966 &(graconf.media), 967 &(pPaperSizes[res]), 968 sizeof(dk4_paper_size_t), 969 NULL 970 ); 971 graconf.media.name = NULL; 972 graconf.psi = (size_t)res; 973 graconf.have_psi = 1; 974 } 975 ConfigurationToGUI(); 976 CorrectGUI(); 977 } 978 $? "- OnResetOptions" 979} 980 981 982 983bool 984Bmpp4Frame::CheckPaperSizeForDocuments(void) 985{ 986 bool back = true; 987 if (DK4_GRA_PURPOSE_DOCUMENT == graconf.purpose) { 988 if (graconf.media.w < (graconf.media.i + graconf.media.o)) { 989 back = false; 990 } 991 if (graconf.media.h < (graconf.media.b + graconf.media.t)) { 992 back = false; 993 } 994 } 995 return back; 996} 997 998 999 1000bool 1001Bmpp4Frame::RunConversion(void) 1002{ 1003 wxString errorString(wxT("")); 1004 bool back = false; 1005 $? "+ RunConversion" 1006 1007 /* Transfer GUI state to grahpics output configuration 1008 if not specified on the command line. 1009 */ 1010 if (bRestoreGx) { 1011 ConfigurationFromGUI(); 1012 } 1013 if (!(bAutorun)) { 1014 bMakeMode = ((0 != cbMakeMode->GetValue()) ? (true) : (false)); 1015 } 1016 /* 1017 Check for usable paper size 1018 */ 1019 if (CheckPaperSizeForDocuments()) { 1020 /* 1021 Do conversion operations in idle events or modal dialog. 1022 */ 1023 Bmpp4Progress dPro( 1024 this, pAppHelp, sTexts, sDirname, &graconf, bMakeMode, &errorString 1025 ); 1026 if (dPro.PrepareProcessing()) { 1027 $? ". show windows and run processing" 1028 pAppHelp->ChooseChildPosition(*this, dPro); 1029 if (wxID_OK == dPro.ShowModal()) { 1030 back = true; 1031 } 1032 else { $? "! aborted or errors" 1033 /* ERRROR: Aborted or errors */ 1034 wxMessageBox( 1035 errorString, sTexts[102], 1036 (wxOK | wxCENTRE | wxICON_ERROR), 1037 this 1038 ); 1039 } 1040 $? ". processing done" 1041 } 1042 else { $? "! failed to prepare processing" 1043 /* ERROR: Failed to prepare processing */ 1044 wxMessageBox( 1045 errorString, sTexts[102], 1046 (wxOK | wxCENTRE | wxICON_ERROR), 1047 this 1048 ); 1049 } 1050 $? ". going to clean up" 1051 dPro.Cleanup(); 1052 $? ". clean up done" 1053 } 1054 else { $? "! unusable paper size" 1055 /* ERROR: Unusable paper size */ 1056 wxMessageBox( 1057 sTexts[111], sTexts[102], 1058 (wxOK | wxCENTRE | wxICON_ERROR), 1059 this 1060 ); 1061 } 1062 1063 $? "- RunConversion %d", ((back) ? (1) : (0)) 1064 return back; 1065} 1066 1067 1068 1069void 1070Bmpp4Frame::OnRunConversion(wxCommandEvent & WXUNUSED(event)) 1071{ 1072 $? "+ Bmpp4Frame::OnRunConversion" 1073 (void)RunConversion(); 1074 $? "- Bmpp4Frame::OnRunConversion" 1075} 1076 1077 1078 1079void 1080Bmpp4Frame::OnOutputType(wxCommandEvent & WXUNUSED(event)) 1081{ 1082 $? "+ OnOutputType" 1083 CorrectGUI(); 1084 $? "- OnOutputType" 1085} 1086 1087 1088 1089void 1090Bmpp4Frame::OnPSLevel(wxCommandEvent & WXUNUSED(event)) 1091{ 1092 $? "+ OnPSLevel" 1093 CorrectGUI(); 1094 $? "- OnPSLevel" 1095} 1096 1097 1098 1099void 1100Bmpp4Frame::OnResolution(wxCommandEvent & WXUNUSED(event)) 1101{ 1102 $? "+ OnResolution" 1103 CorrectGUI(); 1104 $? "- OnResolution" 1105} 1106 1107 1108 1109void 1110Bmpp4Frame::OnInterpolationChange(wxCommandEvent & WXUNUSED(event)) 1111{ 1112 $? "+ OnInterpolationChange" 1113 CorrectGUI(); 1114 $? "- OnInterpolationChange" 1115} 1116 1117 1118 1119void 1120Bmpp4Frame::OnColorOutput(wxCommandEvent & WXUNUSED(event)) 1121{ 1122 $? "+ OnColorOutput" 1123 CorrectGUI(); 1124 $? "- OnColorOutput" 1125} 1126 1127 1128 1129/* __CHANGE__ 014: Implementation of further methods. 1130*/ 1131 1132 1133void 1134Bmpp4Frame::SaveSettings(void) 1135{ 1136 int ival[21]; 1137 size_t i; 1138 $? "+ SaveSettings" 1139 if (bRestoreGx) { $? ". save conversion settings" 1140 for (i = 0; i < DK4_SIZEOF(ival,int); i++) { ival[i] = 0; } 1141 ival[ 0] = chPaperSizes->GetSelection(); 1142 ival[ 1] = chOutputMode->GetSelection(); 1143 ival[ 2] = cbColorOutput->GetValue(); 1144 ival[ 3] = chPsLevel->GetSelection(); 1145 ival[ 4] = cbDsc->GetValue(); 1146 ival[ 5] = cbLzw->GetValue(); 1147 ival[ 6] = cbRotation->GetValue(); 1148 ival[ 7] = chFinishing->GetSelection(); 1149 ival[ 8] = chResolution->GetSelection(); 1150 ival[ 9] = ccBackground->Red(); 1151 ival[10] = ccBackground->Green(); 1152 ival[11] = ccBackground->Blue(); 1153 ival[12] = cbBackground->GetValue(); 1154 ival[13] = cbImgInterpolation->GetValue(); 1155 ival[14] = cbDct->GetValue(); 1156 ival[15] = cbDctInterpolation->GetValue(); 1157 ival[16] = cbAnBpc->GetValue(); 1158 ival[17] = cbAnColor->GetValue(); 1159 ival[18] = cbAnAlpha->GetValue(); 1160 ival[19] = chRgbToGray->GetSelection(); 1161 ival[20] = cbSizeLaTeX->GetValue(); 1162 pAppHelp->SetMultiple(i_option_names, ival, 21); 1163 } 1164 if (bRestoreMake) { $? ". save make mode settings" 1165 ival[0] = cbMakeMode->GetValue(); 1166 pAppHelp->SetMultiple(i_make_names, ival, 1); 1167 } 1168 if (bRestoreLocation) { $? ". save location" 1169 pAppHelp->SetString(i_dir_names[0], sDirname); 1170 } 1171 $? "- SaveSettings" 1172} 1173 1174 1175 1176void 1177Bmpp4Frame::RestoreSettings(void) 1178{ 1179 int ival[21]; 1180 size_t i; 1181 $? "+ RestoreSettings" 1182 if (bRestoreGx) { $? ". restore graphics settings" 1183 for (i = 0; i < DK4_SIZEOF(ival,int); i++) { ival[i] = 0; } 1184 ival[ 0] = 0; 1185 ival[ 1] = 0; 1186 ival[ 2] = 1; 1187 ival[ 3] = 1; 1188 ival[ 4] = 1; 1189 ival[ 5] = 0; 1190 ival[ 6] = 1; 1191 ival[ 7] = 1; 1192 ival[ 8] = 0; 1193 ival[ 9] = 255; 1194 ival[10] = 255; 1195 ival[11] = 255; 1196 ival[12] = 0; 1197 ival[13] = 1; 1198 ival[14] = 1; 1199 ival[15] = 0; 1200 ival[16] = 1; 1201 ival[17] = 1; 1202 ival[18] = 1; 1203 ival[19] = 0; 1204 ival[20] = 1; 1205 pAppHelp->GetMultiple(i_option_names, ival, 21); 1206 if ((0 <= ival[0]) && ((int)szPaperSizes > ival[0])) { 1207 chPaperSizes->SetSelection(ival[0]); 1208 } 1209 if (0 <= ival[1]) { chOutputMode->SetSelection(ival[1]); } 1210 cbColorOutput->SetValue((0 != ival[2]) ? (true) : (false)); 1211 if (0 <= ival[3]) { chPsLevel->SetSelection(ival[3]); } 1212 cbDsc->SetValue((0 != ival[4]) ? (true) : (false)); 1213 cbLzw->SetValue((0 != ival[5]) ? (true) : (false)); 1214 cbRotation->SetValue((0 != ival[6]) ? (true) : (false)); 1215 if (0 <= ival[7]) { chFinishing->SetSelection(ival[7]); } 1216 if (0 <= ival[8]) { chResolution->SetSelection(ival[8]); } 1217 ccBackground->SetRGB(ival[9], ival[10], ival[11]); 1218 cbBackground->SetValue((0 != ival[12]) ? (true) : (false)); 1219 cbImgInterpolation->SetValue((0 != ival[13]) ? (true) : (false)); 1220 cbDct->SetValue((0 != ival[14]) ? (true) : (false)); 1221 cbDctInterpolation->SetValue((0 != ival[15]) ? (true) : (false)); 1222 cbAnBpc->SetValue((0 != ival[16]) ? (true) : (false)); 1223 cbAnColor->SetValue((0 != ival[17]) ? (true) : (false)); 1224 cbAnAlpha->SetValue((0 != ival[18]) ? (true) : (false)); 1225 if (0 <= ival[19]) { chRgbToGray->SetSelection(ival[19]); } 1226 cbSizeLaTeX->SetValue((0 != ival[20]) ? (true) : (false)); 1227 } 1228 else { $? ". using graphics conversion options" 1229 ConfigurationToGUI(); 1230 } 1231 if (bRestoreMake) { $? ". restoring make mode" 1232 for (i = 0; i < DK4_SIZEOF(ival,int); i++) { ival[i] = 0; } 1233 ival[ 0] = 0; 1234 pAppHelp->GetMultiple(i_make_names, ival, 1); 1235 cbMakeMode->SetValue((0 != ival[0]) ? (true) : (false)); 1236 bMakeMode = ((0 != ival[0]) ? true : false); 1237 } 1238 else { 1239 cbMakeMode->SetValue(bMakeMode ? (1) : (0)); 1240 } 1241 if (bRestoreLocation) { $? ". restore location" 1242 if (pAppHelp->GetString(i_dir_names[0], &sDirname)) { 1243 lDirectoryName->SetLabel(sDirname); 1244 Refresh(); 1245 Update(); 1246 } 1247 } 1248 $? "- RestoreSettings" 1249} 1250 1251 1252 1253void 1254Bmpp4Frame::CorrectGUI(void) 1255{ 1256 $? "+ CorrectGUI" 1257 if (!bIsCorrecting) { $? ". must correct" 1258 /* 1259 Avoid recursive calls 1260 */ 1261 bIsCorrecting = true; 1262 1263 /* 1264 Enable or disable PS specific components 1265 */ 1266 switch (chOutputMode->GetSelection()) { 1267 case 0 : case 1 : case 2 : { /* PDF */ 1268 chPsLevel->Enable(false); 1269 cbDsc->Enable(false); 1270 cbLzw->Enable(false); 1271 } break; 1272 default : { /* PS or EPS */ 1273 chPsLevel->Enable(true); 1274 cbDsc->Enable(true); 1275 if (0 == chPsLevel->GetSelection()) { /* PS 2 */ 1276 cbLzw->Enable(true); 1277 } 1278 else { /* PS 3 */ 1279 cbLzw->Enable(false); 1280 } 1281 } break; 1282 } 1283 1284 /* 1285 Enable or disable job specific components 1286 */ 1287 switch (chOutputMode->GetSelection()) { 1288 case 2: case 5: { /* document */ 1289 chFinishing->Enable(true); 1290 cbRotation->Enable(true); 1291 chPaperSizes->Enable(true); 1292 cbSizeLaTeX->Enable(false); 1293 } break; 1294 default: { /* not a document */ 1295 chFinishing->Enable(false); 1296 cbRotation->Enable(false); 1297 chPaperSizes->Enable(false); 1298 cbSizeLaTeX->Enable(true); 1299 } break; 1300 } 1301 1302 /* 1303 Enable or disable resolution text input field 1304 */ 1305 switch(chResolution->GetSelection()) { 1306 case 2: { 1307 tfResolution->Enable(true); 1308 } break; 1309 default: { 1310 tfResolution->Enable(false); 1311 } break; 1312 } 1313 1314 /* 1315 Enable or disable Interpolation DCT 1316 */ 1317 if (0 != cbImgInterpolation->GetValue()) { 1318 cbDctInterpolation->Enable(true); 1319 } 1320 else { 1321 cbDctInterpolation->Enable(false); 1322 } 1323 1324 /* 1325 Enable or disable RGB to gray method selection 1326 */ 1327 if (0 != cbColorOutput->GetValue()) { 1328 chRgbToGray->Enable(false); 1329 } 1330 else { 1331 chRgbToGray->Enable(true); 1332 } 1333 1334 /* 1335 Mark as done 1336 */ 1337 bIsCorrecting = false; 1338 /* 1339 Update GUI 1340 */ 1341 Refresh(); 1342 Update(); 1343 } 1344 $? "- CorrectGUI" 1345} 1346 1347 1348 1349void 1350Bmpp4Frame::ConfigurationToGUI(void) 1351{ 1352 wxChar b1[64]; /* Conversion buffer */ 1353 wxChar b2[DK4_SIZEOF(b1,wxChar)]; /* Conversion buffer */ 1354 size_t szb = DK4_SIZEOF(b1,wxChar); /* Size of b1 and b2 (elems) */ 1355 size_t papi = 0; /* Paper size index */ 1356 int res = 0; /* Operation result */ 1357 $? "+ ConfigurationToGUI" 1358 /* Output mode 1359 */ 1360 switch (graconf.driver) { 1361 case DK4_GRA_DRIVER_PS : { 1362 switch (graconf.purpose) { 1363 case DK4_GRA_PURPOSE_DOCUMENT : { 1364 chOutputMode->SetSelection(5); 1365 } break; 1366 default : { 1367 chOutputMode->SetSelection(4); 1368 } break; 1369 } 1370 } break; 1371 case DK4_GRA_DRIVER_EPS : { 1372 chOutputMode->SetSelection(3); 1373 } break; 1374 default : { 1375 switch (graconf.purpose) { 1376 case DK4_GRA_PURPOSE_DOCUMENT : { 1377 chOutputMode->SetSelection(2); 1378 } break; 1379 case DK4_GRA_PURPOSE_IMAGE : { 1380 chOutputMode->SetSelection(1); 1381 } break; 1382 default : { /* DK4_GRA_PURPOSE_OBJECT */ 1383 chOutputMode->SetSelection(0); 1384 } break; 1385 } 1386 } break; 1387 } 1388 /* PS level 1389 */ 1390 chPsLevel->SetSelection((3 == graconf.ps_level) ? (1) : (0)); 1391 /* DSC 1392 */ 1393 cbDsc->SetValue((0 != graconf.ps_dsc) ? (1) : (0)); 1394 /* LZW 1395 */ 1396 cbLzw->SetValue((0 != graconf.ps_lzw) ? (1) : (0)); 1397 /* Paper size 1398 */ 1399 if ((0 != graconf.have_psi) && (szPaperSizes > graconf.psi)) { 1400 chPaperSizes->SetSelection((int)(graconf.psi)); 1401 } 1402 else { 1403 if (0 != graconf.have_psi) { 1404 chPaperSizes->SetSelection((int)(graconf.psi)); 1405 } 1406 else { 1407 res = dk4paper_find_nearest( 1408 &papi, pPaperSizes, szPaperSizes, &(graconf.media), NULL 1409 ); 1410 if ((0 != res) && ((dk4_um_t)(INT_MAX) >= (dk4_um_t)papi)) { 1411 chPaperSizes->SetSelection((int)papi); 1412 } 1413 else { 1414 chPaperSizes->SetSelection(0); 1415 } 1416 } 1417 } 1418 /* Rotate 1419 */ 1420 cbRotation->SetValue((0 != graconf.img_rot) ? 1 : 0); 1421 /* Finishing 1422 */ 1423 if (0 != graconf.doc_tumble) { 1424 chFinishing->SetSelection(2); 1425 } 1426 else { 1427 chFinishing->SetSelection((0 != graconf.doc_duplex) ? (1) : (0)); 1428 } 1429 /* Resolution 1430 */ 1431 if ((0.0 < graconf.xres) && (0.0 < graconf.yres)) { 1432 chResolution->SetSelection(2); 1433 /* 2018-03-28 1434 The buffer overflow reported from wxWidgets libraries 1435 magically disappeared after rebuilding the entire project 1436 with debug messages. 1437 May be rebuilding one module was missing before. 1438 */ 1439 $? ". writing double to buffer" 1440 if (0 != dk4ma_write_wx_double(b1,szb,graconf.xres,0,1,NULL)) { 1441 $? ". b1 written" 1442 if (0 != dk4ma_write_wx_double(b2,szb,graconf.yres,0,1,NULL)) { 1443 $? ". b2 written" 1444 tfResolution->SetValue(wxString(b1) + wxT(" ") + wxString(b2)); 1445 $? ". text field replaced" 1446 } 1447 else { $? "! failed to write b2" 1448 } 1449 } 1450 else { $? "! failed to write b1" 1451 } 1452 $? ". doubles written to buffer" 1453 } 1454 else { 1455 chResolution->SetSelection((graconf.img_ign_res) ? (1) : (0)); 1456 } 1457 /* Background 1458 */ 1459 if ((0 <= graconf.img_bg_r) && (256 > graconf.img_bg_r)) { 1460 if ((0 <= graconf.img_bg_g) && (256 > graconf.img_bg_g)) { 1461 if ((0 <= graconf.img_bg_b) && (256 > graconf.img_bg_b)) { 1462 ccBackground->SetRGB( 1463 graconf.img_bg_r, graconf.img_bg_g, graconf.img_bg_b 1464 ); 1465 } 1466 } 1467 } 1468 /* 1469 Enforce background 1470 */ 1471 cbBackground->SetValue((0 != graconf.img_bg_f) ? (1) : (0)); 1472 /* 1473 Color 1474 */ 1475 cbColorOutput->SetValue((0 != graconf.color) ? (1) : (0)); 1476 /* 1477 Interpolation 1478 */ 1479 cbImgInterpolation->SetValue((0 != graconf.img_int) ? (1) : (0)); 1480 /* 1481 DCT 1482 */ 1483 cbDct->SetValue((0 != graconf.img_dct) ? (1) : (0)); 1484 /* 1485 DCT interpolation 1486 */ 1487 cbDctInterpolation->SetValue((0 != graconf.img_dct_int) ? (1) : (0)); 1488 /* 1489 Analzse bpc 1490 */ 1491 cbAnBpc->SetValue((0 != graconf.img_an_bpc) ? (1) : (0)); 1492 /* 1493 Analzse color 1494 */ 1495 cbAnColor->SetValue((0 != graconf.img_an_color) ? (1) : (0)); 1496 /* 1497 Analyze alpha 1498 */ 1499 cbAnAlpha->SetValue((0 != graconf.img_an_alpha) ? (1) : (0)); 1500 /* 1501 RGB to gray method 1502 */ 1503 if (0 <= graconf.ctx.rgb_to_gray) { 1504 chRgbToGray->SetSelection(graconf.ctx.rgb_to_gray); 1505 } 1506 /* Restrict size for LaTeX 1507 */ 1508 cbSizeLaTeX->SetValue((0 != graconf.restrict_size) ? (1) : (0)); 1509 $? "- ConfigurationToGUI" 1510} 1511 1512 1513 1514void 1515Bmpp4Frame::ConfigurationFromGUI(void) 1516{ 1517 wxChar buffer[128]; 1518 wxChar const *ep; 1519 wxChar *p1 = NULL; 1520 wxChar *p2 = NULL; 1521 double xres = -1.0; 1522 double yres = -1.0; 1523 size_t szbu = DK4_SIZEOF(buffer,wxChar); 1524 int choiceindex; 1525 int ok = 0; 1526 $? "+ ConfigurationFromGUI" 1527 /* Output mode 1528 */ 1529 switch (chOutputMode->GetSelection()) { 1530 case 0 : { 1531 graconf.driver = DK4_GRA_DRIVER_PDF; 1532 graconf.purpose = DK4_GRA_PURPOSE_OBJECT; 1533 } break; 1534 case 1 : { 1535 graconf.driver = DK4_GRA_DRIVER_PDF; 1536 graconf.purpose = DK4_GRA_PURPOSE_IMAGE; 1537 } break; 1538 case 2 : { 1539 graconf.driver = DK4_GRA_DRIVER_PDF; 1540 graconf.purpose = DK4_GRA_PURPOSE_DOCUMENT; 1541 } break; 1542 case 3 : { 1543 graconf.driver = DK4_GRA_DRIVER_EPS; 1544 graconf.purpose = DK4_GRA_PURPOSE_IMAGE; 1545 } break; 1546 case 4 : { 1547 graconf.driver = DK4_GRA_DRIVER_PS; 1548 graconf.purpose = DK4_GRA_PURPOSE_IMAGE; 1549 } break; 1550 case 5 : { 1551 graconf.driver = DK4_GRA_DRIVER_PS; 1552 graconf.purpose = DK4_GRA_PURPOSE_DOCUMENT; 1553 } break; 1554 default : { 1555 graconf.driver = DK4_GRA_DRIVER_PDF; 1556 graconf.purpose = DK4_GRA_PURPOSE_OBJECT; 1557 } break; 1558 } 1559 /* PS level 1560 */ 1561 switch (chPsLevel->GetSelection()) { 1562 case 0 : { 1563 graconf.ps_level = 2; 1564 } break; 1565 default : { 1566 graconf.ps_level = 3; 1567 } break; 1568 } 1569 /* DSC 1570 */ 1571 graconf.ps_dsc = ((0 != cbDsc->GetValue()) ? 1 : 0); 1572 /* 1573 LZW 1574 */ 1575 graconf.ps_lzw = ((0 != cbLzw->GetValue()) ? 1 : 0); 1576 /* 1577 Paper size 1578 */ 1579 choiceindex = chPaperSizes->GetSelection(); 1580 if ((0 <= choiceindex) && (szPaperSizes > (size_t)choiceindex)) { 1581 dk4mem_cpy( 1582 &(graconf.media), 1583 &(pPaperSizes[choiceindex]), 1584 sizeof(dk4_paper_size_t), 1585 NULL 1586 ); 1587 } 1588 /* 1589 Rotate 1590 */ 1591 graconf.img_rot = ((0 != cbRotation->GetValue()) ? 1 : 0); 1592 /* 1593 Finishing 1594 */ 1595 switch (chFinishing->GetSelection()) { 1596 case 2 : { 1597 graconf.doc_duplex = 1; 1598 graconf.doc_tumble = 1; 1599 } break; 1600 case 1 : { 1601 graconf.doc_duplex = 1; 1602 graconf.doc_tumble = 0; 1603 } break; 1604 default : { 1605 graconf.doc_duplex = 0; 1606 graconf.doc_tumble = 0; 1607 } break; 1608 } 1609 /* Resolution 1610 */ 1611 switch (chResolution->GetSelection()) { 1612 case 2 : { /* specify */ 1613 /* ##### TODO: Implementation: Retrieve values from text field */ 1614 wxCStrData valuestrdata = tfResolution->GetValue().c_str(); 1615 if ( 1616 0 != dk4strx_cpy_s( 1617 buffer, szbu, (wxChar const *)valuestrdata, NULL 1618 ) 1619 ) { 1620 p1 = dk4strx_start(buffer, NULL); 1621 if (NULL != p1) { 1622 p2 = dk4strx_next(p1, NULL); 1623 ep = NULL; 1624 if (0 != dk4ma_input_wx_double(&xres, p1, &ep, 1, NULL)) { 1625 ok = 1; 1626 yres = xres; 1627 } 1628 if (NULL != p2) { 1629 ep = NULL; 1630 if (0 == dk4ma_input_wx_double(&yres,p2,&ep,1,NULL)) { 1631 ok = 0; 1632 } 1633 } 1634 if (1 == ok) { 1635 if ((0.0 < xres) && (0.0 < yres)) { 1636 graconf.xres = xres; 1637 graconf.yres = yres; 1638 } 1639 } 1640 } 1641 } 1642 graconf.img_ign_res = 0; 1643 } break; 1644 case 1 : { /* ignore */ 1645 graconf.img_ign_res = 1; 1646 graconf.xres = graconf.yres = 72.0; 1647 } break; 1648 default : { /* chunk */ 1649 graconf.img_ign_res = 0; 1650 graconf.xres = graconf.yres = -1.0; 1651 } break; 1652 } 1653 /* Background 1654 */ 1655 graconf.img_bg_r = ccBackground->Red(); 1656 graconf.img_bg_g = ccBackground->Green(); 1657 graconf.img_bg_b = ccBackground->Blue(); 1658 /* 1659 Enforce background 1660 */ 1661 graconf.img_bg_f = ((0 != cbBackground->GetValue()) ? 1 : 0); 1662 /* 1663 Color 1664 */ 1665 graconf.color = ((0 != cbColorOutput->GetValue()) ? 1 : 0); 1666 /* 1667 Interpolation 1668 */ 1669 graconf.img_int = ((0 != cbImgInterpolation->GetValue()) ? 1 : 0); 1670 /* 1671 DCT 1672 */ 1673 graconf.img_dct = ((0 != cbDct->GetValue()) ? 1 : 0); 1674 /* 1675 DCT interpolation 1676 */ 1677 graconf.img_dct_int = ((0 != cbDctInterpolation->GetValue()) ? 1 : 0); 1678 /* 1679 Analzse bpc 1680 */ 1681 graconf.img_an_bpc = ((0 != cbAnBpc->GetValue()) ? 1 : 0); 1682 /* 1683 Analzse color 1684 */ 1685 graconf.img_an_color = ((0 != cbAnColor->GetValue()) ? 1 : 0); 1686 /* 1687 Analyze alpha 1688 */ 1689 graconf.img_an_alpha = ((0 != cbAnAlpha->GetValue()) ? 1 : 0); 1690 /* 1691 Size restriction for LaTeX 1692 */ 1693 graconf.restrict_size = ((0 != cbSizeLaTeX->GetValue()) ? 1 : 0); 1694 /* 1695 RGB to gray method 1696 */ 1697 switch (chRgbToGray->GetSelection()) { 1698 case 12 : { 1699 graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_CHANNEL_BLUE; 1700 } break; 1701 case 11 : { 1702 graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_CHANNEL_GREEN; 1703 } break; 1704 case 10 : { 1705 graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_CHANNEL_RED; 1706 } break; 1707 case 9 : { 1708 graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_MAX_DECOMPOSITION; 1709 } break; 1710 case 8 : { 1711 graconf.ctx.rgb_to_gray = 1712 DK4_CS_CONV_RGB_TO_GRAY_MEDIUM_DECOMPOSITION; 1713 } break; 1714 case 7 : { 1715 graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_MIN_DECOMPOSITION; 1716 } break; 1717 case 6 : { 1718 graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_DESATURATION; 1719 } break; 1720 case 5 : { 1721 graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_AVERAGE; 1722 } break; 1723 case 4 : { 1724 graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_VERY_FAST; 1725 } break; 1726 case 3 : { 1727 graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_FAST; 1728 } break; 1729 case 2 : { 1730 graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_ITU_BT709; 1731 } break; 1732 case 1 : { 1733 graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_LUMA; 1734 } break; 1735 default : { 1736 graconf.ctx.rgb_to_gray = DK4_CS_CONV_RGB_TO_GRAY_ITU_BT601; 1737 } break; 1738 } 1739 $? "- ConfigurationFromGUI" 1740} 1741 1742 1743 1744void 1745Bmpp4Frame::OnIdle(wxIdleEvent & event) 1746{ 1747#if TRACE_DEBUG 1748 static unsigned long number = 0UL; 1749 dk4_time_t timer; 1750#endif 1751 bool rqm = false; 1752 bool success; 1753 $? "+ Bmpp4Frame::OnIdle" 1754#if TRACE_DEBUG 1755 dk4time_get(&timer); 1756#endif 1757 $? "+ OnIdle %lu %lu", number, (unsigned long)(timer - firsttime) 1758 if (bActive) { $? ". active" 1759 if (bAutorun) { $? ". autorun" 1760 switch (oAsc.GetReaction()) { 1761 case Dk4WxAutostartController::REACTION_START : { $? ". start" 1762 oAsc.StartProcessing(); 1763 success = RunConversion(); 1764 rqm = true; 1765 if (success) { 1766 lDirectoryName->SetLabel(sTexts[91]); 1767 lDirectoryName->SetForegroundColour(cGreen); 1768 } 1769 else { 1770#if 0 1771 oAsc.SetAutoExit(false); 1772 rqm = false; 1773#endif 1774 lDirectoryName->SetLabel(sTexts[92]); 1775 lDirectoryName->SetForegroundColour(cRed); 1776 } 1777 lDirectoryName->Refresh(); 1778 lDirectoryName->Update(); 1779 oAsc.EndProcessing(); $? ". finished, request more" 1780 } break; 1781 case Dk4WxAutostartController::REACTION_MORE : { $? ". more" 1782 rqm = true; 1783 } break; 1784 case Dk4WxAutostartController::REACTION_EXIT : { $? ". exit" 1785 bActive = false; 1786 Show(false); 1787 Close(); 1788 rqm = false; 1789 } break; 1790 default : { /* includes DK4WX_AUTOSTART_REACTION_IGNORE */ 1791 $? ". ignore" 1792 } break; 1793 } 1794 } 1795 else { $? ". no autorun" 1796 } 1797 } 1798 else { $? ". not active" 1799 } 1800#if TRACE_DEBUG 1801 dk4time_get(&timer); 1802#endif 1803 $? "- OnIdle %lu %d %lu", number++, (rqm ? 1 : 0), (unsigned long)(timer - firsttime) 1804 if (rqm) { 1805 event.RequestMore(); 1806 } 1807 event.Skip(); 1808} 1809 1810 1811/* vim: set ai sw=4 ts=4 : */ 1812