]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbconfigpanel.h
Correct compile error
[bacula/bacula] / bacula / src / wx-console / wxbconfigpanel.h
1 /*
2  *
3  *   Config panel, used to specify parameters (for example clients, filesets... in restore)
4  *
5  *    Nicolas Boichat, April 2004
6  *
7  *    Version $Id$
8  */
9 /*
10    Bacula® - The Network Backup Solution
11
12    Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
13
14    The main author of Bacula is Kern Sibbald, with contributions from
15    many others, a complete list can be found in the file AUTHORS.
16    This program is Free Software; you can redistribute it and/or
17    modify it under the terms of version two of the GNU General Public
18    License as published by the Free Software Foundation and included
19    in the file LICENSE.
20
21    This program is distributed in the hope that it will be useful, but
22    WITHOUT ANY WARRANTY; without even the implied warranty of
23    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24    General Public License for more details.
25
26    You should have received a copy of the GNU General Public License
27    along with this program; if not, write to the Free Software
28    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29    02110-1301, USA.
30
31    Bacula® is a registered trademark of John Walker.
32    The licensor of Bacula is the Free Software Foundation Europe
33    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
34    Switzerland, email:ftf@fsfeurope.org.
35 */
36
37 #ifndef WXBCONFIGPANEL_H
38 #define WXBCONFIGPANEL_H
39
40 #include "wxbutils.h"
41 #include <wx/panel.h>
42 #include <wx/choice.h>
43 #include <wx/stattext.h>
44 #include <wx/textctrl.h>
45
46 #include <wx/dynarray.h>
47
48 enum wxbConfigType {
49    text,
50    modifiableText,
51    choice
52 };
53
54 class wxbConfigParam {
55    public:
56       /* Create a new config parameter */
57       wxbConfigParam(wxString title, wxWindowID id, wxbConfigType type, wxString value);
58       wxbConfigParam(wxString title, wxWindowID id, wxbConfigType type, int n, wxString values[]);
59      ~wxbConfigParam();
60
61      void AddControl(wxWindow* parent, wxSizer* sizer);
62
63      wxString GetValue();
64      void SetValue(wxString str);
65
66      int GetIndex();
67      void SetIndex(int ind);
68
69      void Clear();
70      void Add(wxString value);
71
72      wxString GetTitle();
73
74    private:
75       wxString value;
76       wxString* values;
77       int nvalues;
78
79       wxString title;
80
81       wxWindowID id;
82
83       wxbConfigType type;
84
85       wxChoice* choicectrl;
86       wxTextCtrl* textctrl;
87       wxStaticText* statictext;
88 };
89
90 WX_DECLARE_OBJARRAY(wxbConfigParam, wxbConfig);
91
92 class wxbConfigPanel : public wxPanel {
93 public:
94    /* Creates a new config panel, config must be allocated with new */
95         wxbConfigPanel(wxWindow* parent, wxbConfig* config, wxString title, wxWindowID ok, wxWindowID cancel, wxWindowID apply = -1);
96         ~wxbConfigPanel();
97
98    void SetRowString(const wxChar* title, wxString value);
99    wxString GetRowString(const wxChar* title);
100    int GetRowSelection(const wxChar* title);
101    void SetRowSelection(const wxChar* title, int ind);
102
103    void ClearRowChoices(const wxChar* title);
104    void AddRowChoice(const wxChar* title, wxString value);
105
106    /* If enable is true, enables apply button, and disables ok button */
107    void EnableApply(bool enable = true);
108
109 private:
110    /* Keep the last index accessed, for optimization */
111    unsigned int last;
112
113    wxbConfig* config;
114    wxButton* cfgOk;
115    wxButton* cfgCancel;
116    wxButton* cfgApply;
117
118    int FindRow(const wxChar* title);
119 };
120
121 #endif