]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbconfigpanel.h
Fix some trivial errors and implemented the restore of IRIX xattrs.
[bacula/bacula] / bacula / src / wx-console / wxbconfigpanel.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2004-2008 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version three of the GNU Affero General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU Affero General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /*
29  *
30  *   Config panel, used to specify parameters (for example clients, filesets... in restore)
31  *
32  *    Nicolas Boichat, April 2004
33  *
34  *    Version $Id$
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      int GetCount();
72
73      wxString GetTitle();
74
75    private:
76       wxString value;
77       wxString* values;
78       int nvalues;
79
80       wxString title;
81
82       wxWindowID id;
83
84       wxbConfigType type;
85
86       wxChoice* choicectrl;
87       wxTextCtrl* textctrl;
88       wxStaticText* statictext;
89 };
90
91 WX_DECLARE_OBJARRAY(wxbConfigParam, wxbConfig);
92
93 class wxbConfigPanel : public wxPanel {
94 public:
95    /* Creates a new config panel, config must be allocated with new */
96         wxbConfigPanel(wxWindow* parent, wxbConfig* config, wxString title, wxWindowID ok, wxWindowID cancel, wxWindowID apply = -1);
97         ~wxbConfigPanel();
98
99    void SetRowString(const wxChar* title, wxString value);
100    wxString GetRowString(const wxChar* title);
101    int GetRowSelection(const wxChar* title);
102    void SetRowSelection(const wxChar* title, int ind);
103
104    void ClearRowChoices(const wxChar* title);
105    void AddRowChoice(const wxChar* title, wxString value);
106    int GetRowCount(const wxChar* title);
107
108    /* If enable is true, enables apply button, and disables ok button */
109    void EnableApply(bool enable = true);
110
111 private:
112    /* Keep the last index accessed, for optimization */
113    unsigned int last;
114
115    wxbConfig* config;
116    wxButton* cfgOk;
117    wxButton* cfgCancel;
118    wxButton* cfgApply;
119
120    int FindRow(const wxChar* title);
121 };
122
123 #endif