KiCad PCB EDA Suite
dialog_print_generic.h
Go to the documentation of this file.
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 
20 #ifndef DIALOG_PRINT_GENERIC_H
21 #define DIALOG_PRINT_GENERIC_H
22 
24 #include <wx/valnum.h>
25 #include <widgets/unit_binder.h>
26 
27 class EDA_DRAW_FRAME;
28 struct PRINTOUT_SETTINGS;
29 class wxPageSetupDialogData;
30 class wxPrintout;
31 class wxPrintData;
32 
34 {
35 public:
37  virtual ~DIALOG_PRINT_GENERIC();
38 
43  void ForcePrintBorder( bool aValue );
44 
45 protected:
49  virtual wxPrintout* createPrintout( const wxString& aTitle ) = 0;
50 
51  virtual void saveSettings();
52 
53  wxSizer* getMainSizer()
54  {
55  return m_bUpperSizer;
56  }
57 
58  wxGridBagSizer* getOptionsSizer()
59  {
60  return m_gbOptionsSizer;
61  }
62 
63  wxStaticBox* getOptionsBox()
64  {
65  return m_sbOptionsSizer->GetStaticBox();
66  }
67 
73  double getScaleValue();
74 
80  void setScaleValue( double aValue );
81 
82  // There is no TransferDataFromWindow() so options are saved
83  // even if the dialog is closed without printing
84  bool TransferDataToWindow() override;
85 
86 private:
87  void onPageSetup( wxCommandEvent& event ) override;
88  void onPrintPreview( wxCommandEvent& event ) override;
89  void onPrintButtonClick( wxCommandEvent& event ) override;
90  void onCancelButtonClick( wxCommandEvent& aEvent ) override;
91 
92  // Needed to save the dialogs settings as TransferDataFromWindow()
93  // is not called for 'Cancel' button that closes the window.
94  void onClose( wxCloseEvent& event ) override;
95 
96  void onSetCustomScale( wxCommandEvent& event ) override;
97 
98  void initPrintData();
99 
100 protected:
102 
104 
105 private:
106  wxFloatingPointValidator<double> m_scaleValidator;
107 
108  static wxPrintData* s_PrintData;
109  static wxPageSetupDialogData* s_pageSetupData;
110 };
111 
112 #endif // DIALOG_PRINT_GENERIC_H
double getScaleValue()
Return scale value selected in the dialog.
Handle the parameters used to print a board drawing.
Definition: printout.h:31
void onPageSetup(wxCommandEvent &event) override
void onCancelButtonClick(wxCommandEvent &aEvent) override
Class DIALOG_PRINT_GENERIC_BASE.
The base class for create windows for drawing purpose.
wxStaticBox * getOptionsBox()
void onPrintButtonClick(wxCommandEvent &event) override
void setScaleValue(double aValue)
Select a corresponding scale radio button and update custom scale value if needed.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
PRINTOUT_SETTINGS * m_settings
static wxPrintData * s_PrintData
bool TransferDataToWindow() override
static wxPageSetupDialogData * s_pageSetupData
DIALOG_PRINT_GENERIC(EDA_DRAW_FRAME *aParent, PRINTOUT_SETTINGS *aSettings)
void onClose(wxCloseEvent &event) override
wxGridBagSizer * getOptionsSizer()
void ForcePrintBorder(bool aValue)
Set 'print border and title block' to a requested value and hides the corresponding checkbox.
void onPrintPreview(wxCommandEvent &event) override
APP_SETTINGS_BASE * m_config
void onSetCustomScale(wxCommandEvent &event) override
virtual wxPrintout * createPrintout(const wxString &aTitle)=0
Create a printout with a requested title.
wxFloatingPointValidator< double > m_scaleValidator