KiCad PCB EDA Suite
dialog_print_generic.h
Go to the documentation of this file.
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 
19 #ifndef DIALOG_PRINT_GENERIC_H
20 #define DIALOG_PRINT_GENERIC_H
21 
23 #include <wx/valnum.h>
24 #include <widgets/unit_binder.h>
25 
26 class wxConfigBase;
27 class EDA_DRAW_FRAME;
28 struct PRINTOUT_SETTINGS;
29 
31 {
32 public:
34  virtual ~DIALOG_PRINT_GENERIC();
35 
40  void ForcePrintBorder( bool aValue );
41 
42 protected:
46  virtual wxPrintout* createPrintout( const wxString& aTitle ) = 0;
47 
48  virtual void saveSettings();
49 
50  wxSizer* getMainSizer()
51  {
52  return bUpperSizer;
53  }
54 
55  wxGridBagSizer* getOptionsSizer()
56  {
57  return gbOptionsSizer;
58  }
59 
60  wxStaticBox* getOptionsBox()
61  {
62  return sbOptionsSizer->GetStaticBox();
63  }
64 
68  double getScaleValue() const;
69 
74  void setScaleValue( double aValue );
75 
76  // There is no TransferDataFromWindow() so options are saved
77  // even if the dialog is closed without printing
78  bool TransferDataToWindow() override;
79 
80  wxConfigBase* m_config;
81 
83 
84 private:
85  void onPageSetup( wxCommandEvent& event ) override;
86  void onPrintPreview( wxCommandEvent& event ) override;
87  void onPrintButtonClick( wxCommandEvent& event ) override;
88 
89  // onClose* handlers are needed to save the dialogs settings as TransferDataFromWindow()
90  // is not called for 'Cancel' button that closes the window
91  void onCloseButton( wxCommandEvent& event ) override;
92  void onClose( wxCloseEvent& event ) override;
93 
94  void onSetCustomScale( wxCommandEvent& event ) override;
95 
96  void initPrintData();
97 
98  wxFloatingPointValidator<double> m_scaleValidator;
99 
100  static wxPrintData* s_PrintData;
101  static wxPageSetupDialogData* s_pageSetupData;
102 };
103 
104 #endif // DIALOG_PRINT_GENERIC_H
Class PRINT_PARAMETERS handles the parameters used to print a board drawing.
Definition: printout.h:30
void onCloseButton(wxCommandEvent &event) override
void onPageSetup(wxCommandEvent &event) override
Class DIALOG_PRINT_GENERIC_BASE.
The base class for create windows for drawing purpose.
Definition: draw_frame.h:78
wxStaticBox * getOptionsBox()
void onPrintButtonClick(wxCommandEvent &event) override
void setScaleValue(double aValue)
Select a corresponding scale radio button and update custom scale value if needed.
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 &#39;print border and title block&#39; to a requested value and hides the corresponding checkbox...
double getScaleValue() const
Return scale value selected in the dialog.
void onPrintPreview(wxCommandEvent &event) override
void onSetCustomScale(wxCommandEvent &event) override
virtual wxPrintout * createPrintout(const wxString &aTitle)=0
Create a printout with a requested title.
wxFloatingPointValidator< double > m_scaleValidator