]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbconfigpanel.h
This commit was manufactured by cvs2svn to create tag
[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    Copyright (C) 2004 Kern Sibbald and John Walker
11
12    This program is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public License
14    as published by the Free Software Foundation; either version 2
15    of the License, or (at your option) any later version.
16
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20    GNU General Public License for more details.
21
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifndef WXBCONFIGPANEL_H
28 #define WXBCONFIGPANEL_H
29
30 #include "wxbutils.h"
31 #include <wx/panel.h>
32 #include <wx/choice.h>
33 #include <wx/stattext.h>
34 #include <wx/textctrl.h>
35
36 #include <wx/dynarray.h>
37
38 enum wxbConfigType {
39    text,
40    modifiableText,
41    choice
42 };
43
44 class wxbConfigParam {
45    public:
46       /* Create a new config parameter */
47       wxbConfigParam(wxString title, wxWindowID id, wxbConfigType type, wxString value);
48       wxbConfigParam(wxString title, wxWindowID id, wxbConfigType type, int n, wxString values[]);
49      ~wxbConfigParam();
50
51      void AddControl(wxWindow* parent, wxSizer* sizer);
52
53      wxString GetValue();
54      void SetValue(wxString str);
55
56      int GetIndex();
57      void SetIndex(int ind);
58
59      void Clear();
60      void Add(wxString value);
61
62      wxString GetTitle();
63
64    private:
65       wxString value;
66       wxString* values;
67       int nvalues;
68
69       wxString title;
70
71       wxWindowID id;
72
73       wxbConfigType type;
74
75       wxChoice* choicectrl;
76       wxTextCtrl* textctrl;
77       wxStaticText* statictext;
78 };
79
80 WX_DECLARE_OBJARRAY(wxbConfigParam, wxbConfig);
81
82 class wxbConfigPanel : public wxPanel {
83 public:
84    /* Creates a new config panel, config must be allocated with new */
85         wxbConfigPanel(wxWindow* parent, wxbConfig* config, wxString title, wxWindowID ok, wxWindowID cancel, wxWindowID apply = -1);
86         ~wxbConfigPanel();
87
88    void SetRowString(const char* title, wxString value);
89    wxString GetRowString(const char* title);
90    int GetRowSelection(const char* title);
91    void SetRowSelection(const char* title, int ind);
92
93    void ClearRowChoices(const char* title);
94    void AddRowChoice(const char* title, wxString value);
95
96    /* If enable is true, enables apply button, and disables ok button */
97    void EnableApply(bool enable = true);
98
99 private:
100    /* Keep the last index accessed, for optimization */
101    unsigned int last;
102
103    wxbConfig* config;
104    wxButton* cfgOk;
105    wxButton* cfgCancel;
106    wxButton* cfgApply;
107
108    int FindRow(const char* title);
109 };
110
111 #endif