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.

113 lines
3.2 KiB

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