]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbconfigpanel.h
kes wx-console crashes because of differences between Bacula and wxWidgets
[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-2006 Kern Sibbald
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    version 2 as amended with additional clauses defined in the
15    file LICENSE in the main source directory.
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    the file LICENSE for additional details.
21
22  */
23
24 #ifndef WXBCONFIGPANEL_H
25 #define WXBCONFIGPANEL_H
26
27 #include "wxbutils.h"
28 #include <wx/panel.h>
29 #include <wx/choice.h>
30 #include <wx/stattext.h>
31 #include <wx/textctrl.h>
32
33 #include <wx/dynarray.h>
34
35 enum wxbConfigType {
36    text,
37    modifiableText,
38    choice
39 };
40
41 class wxbConfigParam {
42    public:
43       /* Create a new config parameter */
44       wxbConfigParam(wxString title, wxWindowID id, wxbConfigType type, wxString value);
45       wxbConfigParam(wxString title, wxWindowID id, wxbConfigType type, int n, wxString values[]);
46      ~wxbConfigParam();
47
48      void AddControl(wxWindow* parent, wxSizer* sizer);
49
50      wxString GetValue();
51      void SetValue(wxString str);
52
53      int GetIndex();
54      void SetIndex(int ind);
55
56      void Clear();
57      void Add(wxString value);
58
59      wxString GetTitle();
60
61    private:
62       wxString value;
63       wxString* values;
64       int nvalues;
65
66       wxString title;
67
68       wxWindowID id;
69
70       wxbConfigType type;
71
72       wxChoice* choicectrl;
73       wxTextCtrl* textctrl;
74       wxStaticText* statictext;
75 };
76
77 WX_DECLARE_OBJARRAY(wxbConfigParam, wxbConfig);
78
79 class wxbConfigPanel : public wxPanel {
80 public:
81    /* Creates a new config panel, config must be allocated with new */
82         wxbConfigPanel(wxWindow* parent, wxbConfig* config, wxString title, wxWindowID ok, wxWindowID cancel, wxWindowID apply = -1);
83         ~wxbConfigPanel();
84
85    void SetRowString(const wxChar* title, wxString value);
86    wxString GetRowString(const wxChar* title);
87    int GetRowSelection(const wxChar* title);
88    void SetRowSelection(const wxChar* title, int ind);
89
90    void ClearRowChoices(const wxChar* title);
91    void AddRowChoice(const wxChar* title, wxString value);
92
93    /* If enable is true, enables apply button, and disables ok button */
94    void EnableApply(bool enable = true);
95
96 private:
97    /* Keep the last index accessed, for optimization */
98    unsigned int last;
99
100    wxbConfig* config;
101    wxButton* cfgOk;
102    wxButton* cfgCancel;
103    wxButton* cfgApply;
104
105    int FindRow(const wxChar* title);
106 };
107
108 #endif