KiCad PCB EDA Suite
paged_dialog.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors.
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 
21 #ifndef PAGED_DIALOG_H
22 #define PAGED_DIALOG_H
23 
24 #include <dialog_shim.h>
25 #include <wx/treebook.h>
26 
27 
28 class WX_INFOBAR;
29 
30 
31 class PAGED_DIALOG : public DIALOG_SHIM
32 {
33 private:
34  wxString m_title;
35 
36  bool m_dirty;
37 
38  wxString m_errorMessage;
39  wxWindow* m_errorCtrl; // the control associated with m_errorMessage
40  int m_errorRow; // the row if m_errorCtrl is a grid
41  int m_errorCol; // the column if m_errorCtrl is a grid
42 
43  wxBoxSizer* m_buttonsSizer;
44 
45  std::vector<bool> m_macHack;
46 
47 public:
48  PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aUseReset = false,
49  const wxString& aAuxiliaryAction = wxEmptyString );
50  ~PAGED_DIALOG() override;
51 
52  wxTreebook* GetTreebook() { return m_treebook; }
53 
54  void SetInitialPage( const wxString& aPage, const wxString& aParentPage = wxEmptyString );
55 
56  void SetModified() { m_modified = true; }
57 
58  void SetError( const wxString& aMessage, const wxString& aPageName, int aCtrlId, int aRow = -1,
59  int aCol = -1 );
60 
61  void SetError( const wxString& aMessage, wxWindow* aPage, wxWindow* aCtrl, int aRow = -1,
62  int aCol = -1 );
63 
64  void AddAuxiliaryAction( const wxString& aTitle, const wxString& aTooltip,
65  std::function<void( wxCommandEvent& )> aHandler );
66 
67 protected:
68  void finishInitialization();
69 
70  bool TransferDataToWindow() override;
71  bool TransferDataFromWindow() override;
72 
73  void OnClose( wxCloseEvent& event );
74  void OnCancel( wxCommandEvent& event );
75  virtual void OnAuxiliaryAction( wxCommandEvent& event ) { event.Skip(); }
76  void OnResetButton( wxCommandEvent& aEvent );
77  void OnUpdateUI( wxUpdateUIEvent& event );
78  void OnPageChange( wxBookCtrlEvent& event );
79  void OnValidate( wxCommandEvent& aEvent );
80 
81  wxTreebook* m_treebook;
82  wxButton* m_auxiliaryButton;
83  wxButton* m_resetButton;
84  wxButton* m_cancelButton;
86 };
87 
88 
89 #endif //PAGED_DIALOG_H
std::vector< bool > m_macHack
Definition: paged_dialog.h:45
void SetInitialPage(const wxString &aPage, const wxString &aParentPage=wxEmptyString)
~PAGED_DIALOG() override
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:83
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
void OnPageChange(wxBookCtrlEvent &event)
bool TransferDataToWindow() override
wxWindow * m_errorCtrl
Definition: paged_dialog.h:39
wxTreebook * GetTreebook()
Definition: paged_dialog.h:52
wxButton * m_auxiliaryButton
Definition: paged_dialog.h:82
bool TransferDataFromWindow() override
void OnUpdateUI(wxUpdateUIEvent &event)
WX_INFOBAR * m_infoBar
Definition: paged_dialog.h:85
wxTreebook * m_treebook
Definition: paged_dialog.h:81
wxButton * m_cancelButton
Definition: paged_dialog.h:84
wxBoxSizer * m_buttonsSizer
Definition: paged_dialog.h:43
wxString m_errorMessage
Definition: paged_dialog.h:38
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:71
virtual void OnAuxiliaryAction(wxCommandEvent &event)
Definition: paged_dialog.h:75
void OnCancel(wxCommandEvent &event)
wxButton * m_resetButton
Definition: paged_dialog.h:83
void OnResetButton(wxCommandEvent &aEvent)
void OnValidate(wxCommandEvent &aEvent)
void AddAuxiliaryAction(const wxString &aTitle, const wxString &aTooltip, std::function< void(wxCommandEvent &)> aHandler)
void finishInitialization()
void OnClose(wxCloseEvent &event)
wxString m_title
Definition: paged_dialog.h:34
PAGED_DIALOG(wxWindow *aParent, const wxString &aTitle, bool aUseReset=false, const wxString &aAuxiliaryAction=wxEmptyString)
void SetModified()
Definition: paged_dialog.h:56