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