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 EDA_DRAW_FRAME;
27 struct PRINTOUT_SETTINGS;
28 
30 {
31 public:
33  virtual ~DIALOG_PRINT_GENERIC();
34 
39  void ForcePrintBorder( bool aValue );
40 
41 protected:
45  virtual wxPrintout* createPrintout( const wxString& aTitle ) = 0;
46 
47  virtual void saveSettings();
48 
49  wxSizer* getMainSizer()
50  {
51  return bUpperSizer;
52  }
53 
54  wxGridBagSizer* getOptionsSizer()
55  {
56  return gbOptionsSizer;
57  }
58 
59  wxStaticBox* getOptionsBox()
60  {
61  return sbOptionsSizer->GetStaticBox();
62  }
63 
68  double getScaleValue();
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 
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
double getScaleValue()
Return scale value selected in the dialog.
PRINT_PARAMETERS handles the parameters used to print a board drawing.
Definition: printout.h:31
void onCloseButton(wxCommandEvent &event) override
void onPageSetup(wxCommandEvent &event) 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:92
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