You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
3.0 KiB

  1. /*
  2. * Copyright (C) 2018 CERN
  3. * Author: Maciej Suminski <maciej.suminski@cern.ch>
  4. *
  5. * This program is free software: you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation, either version 3 of the License, or (at your
  8. * option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef DIALOG_PRINT_GENERIC_H
  19. #define DIALOG_PRINT_GENERIC_H
  20. #include "dialog_print_generic_base.h"
  21. #include <wx/valnum.h>
  22. #include <widgets/unit_binder.h>
  23. class EDA_DRAW_FRAME;
  24. struct PRINTOUT_SETTINGS;
  25. class DIALOG_PRINT_GENERIC : public DIALOG_PRINT_GENERIC_BASE
  26. {
  27. public:
  28. DIALOG_PRINT_GENERIC( EDA_DRAW_FRAME* aParent, PRINTOUT_SETTINGS* aSettings );
  29. virtual ~DIALOG_PRINT_GENERIC();
  30. /**
  31. * Set 'print border and title block' to a requested value and hides the
  32. * corresponding checkbox.
  33. */
  34. void ForcePrintBorder( bool aValue );
  35. protected:
  36. /**
  37. * Create a printout with a requested title.
  38. */
  39. virtual wxPrintout* createPrintout( const wxString& aTitle ) = 0;
  40. virtual void saveSettings();
  41. wxSizer* getMainSizer()
  42. {
  43. return bUpperSizer;
  44. }
  45. wxGridBagSizer* getOptionsSizer()
  46. {
  47. return gbOptionsSizer;
  48. }
  49. wxStaticBox* getOptionsBox()
  50. {
  51. return sbOptionsSizer->GetStaticBox();
  52. }
  53. /**
  54. * Return scale value selected in the dialog.
  55. * if this value is outside limits, it will be clamped
  56. */
  57. double getScaleValue();
  58. /**
  59. * Select a corresponding scale radio button and update custom scale value if needed.
  60. * @param aValue is the scale value to be selected (0 stands for fit-to-page).
  61. */
  62. void setScaleValue( double aValue );
  63. // There is no TransferDataFromWindow() so options are saved
  64. // even if the dialog is closed without printing
  65. bool TransferDataToWindow() override;
  66. APP_SETTINGS_BASE* m_config;
  67. PRINTOUT_SETTINGS* m_settings;
  68. private:
  69. void onPageSetup( wxCommandEvent& event ) override;
  70. void onPrintPreview( wxCommandEvent& event ) override;
  71. void onPrintButtonClick( wxCommandEvent& event ) override;
  72. // onClose* handlers are needed to save the dialogs settings as TransferDataFromWindow()
  73. // is not called for 'Cancel' button that closes the window
  74. void onCloseButton( wxCommandEvent& event ) override;
  75. void onClose( wxCloseEvent& event ) override;
  76. void onSetCustomScale( wxCommandEvent& event ) override;
  77. void initPrintData();
  78. wxFloatingPointValidator<double> m_scaleValidator;
  79. static wxPrintData* s_PrintData;
  80. static wxPageSetupDialogData* s_pageSetupData;
  81. };
  82. #endif // DIALOG_PRINT_GENERIC_H