1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  */
5 
6 #ifndef CONFIGURATIONPANEL_H
7 #define CONFIGURATIONPANEL_H
8 
9 #include "globals.h"
10 #include "settings.h"
11 #include "scrollingdialog.h"
12 #include <wx/panel.h>
13 #include <wx/string.h>
14 
15 class wxButton;
16 class wxWindow;
17 
18 /** @brief Base class for plugin configuration panels. */
19 class DLLIMPORT cbConfigurationPanel : public wxPanel
20 {
21     public:
cbConfigurationPanel()22         cbConfigurationPanel() : m_parentDialog(0) { ; }
~cbConfigurationPanel()23         ~cbConfigurationPanel() override{}
24 
25         /// @return the panel's title.
26         virtual wxString GetTitle() const = 0;
27         /// @return the panel's bitmap base name. You must supply two bitmaps: \<basename\>.png and \<basename\>-off.png...
28         virtual wxString GetBitmapBaseName() const = 0;
29         /// Called when the user chooses to apply the configuration.
30         virtual void OnApply() = 0;
31         /// Called when the user chooses to cancel the configuration.
32         virtual void OnCancel() = 0;
33 
34         /// Sets the panel's parent dialog
SetParentDialog(wxWindow * dialog)35         void SetParentDialog(wxWindow* dialog)
36         {
37             m_parentDialog = dialog;
38         }
39         /// Gets the panel's parent dialog
SetParentDialog()40         wxWindow* SetParentDialog()
41         {
42             return m_parentDialog;
43         }
44         /** Call global cbMessageBox with m_parentDialog as parent window when
45             no parent window specified */
46         int cbMessageBox(const wxString& message, const wxString& caption = wxEmptyString, int style = wxOK, wxWindow *parent = NULL, int x = -1, int y = -1)
47         {
48             if (parent)
49                 return ::cbMessageBox(message, caption, style, parent, x, y);
50             else
51                 return ::cbMessageBox(message, caption, style, m_parentDialog, x, y);
52         }
53     private:
54         wxWindow* m_parentDialog;
55 };
56 
57 /// @brief A simple dialog that wraps a cbConfigurationPanel.
58 class DLLIMPORT cbConfigurationDialog : public wxScrollingDialog
59 {
60     public:
61         cbConfigurationDialog(wxWindow* parent, int id, const wxString& title);
62         void AttachConfigurationPanel(cbConfigurationPanel* panel);
63         ~cbConfigurationDialog() override;
64 
65         void EndModal(int retCode) override;
66     protected:
67         cbConfigurationPanel* m_pPanel;
68         wxButton* m_pOK;
69         wxButton* m_pCancel;
70     private:
71 
72 };
73 
74 #endif // CONFIGURATIONPANEL_H
75