]>
Commit | Line | Data |
---|---|---|
1e6feb95 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/univ/radiobox.h | |
3 | // Purpose: wxRadioBox declaration | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 11.09.00 | |
7 | // RCS-ID: $Id$ | |
442b35b5 | 8 | // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) |
65571936 | 9 | // Licence: wxWindows licence |
1e6feb95 VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_UNIV_RADIOBOX_H_ | |
13 | #define _WX_UNIV_RADIOBOX_H_ | |
14 | ||
1e6feb95 VZ |
15 | class WXDLLEXPORT wxRadioButton; |
16 | ||
17 | #include "wx/statbox.h" | |
18 | #include "wx/dynarray.h" | |
19 | ||
d5d29b8a | 20 | WX_DEFINE_EXPORTED_ARRAY_PTR(wxRadioButton *, wxArrayRadioButtons); |
1e6feb95 VZ |
21 | |
22 | // ---------------------------------------------------------------------------- | |
23 | // wxRadioBox: a box full of radio buttons | |
24 | // ---------------------------------------------------------------------------- | |
25 | ||
26 | class WXDLLEXPORT wxRadioBox : public wxStaticBox, | |
27 | public wxRadioBoxBase | |
28 | { | |
29 | public: | |
30 | // wxRadioBox construction | |
6463b9f5 | 31 | wxRadioBox() { Init(); } |
1e6feb95 VZ |
32 | |
33 | wxRadioBox(wxWindow *parent, | |
34 | wxWindowID id, | |
35 | const wxString& title, | |
36 | const wxPoint& pos = wxDefaultPosition, | |
37 | const wxSize& size = wxDefaultSize, | |
38 | int n = 0, const wxString *choices = NULL, | |
39 | int majorDim = 0, | |
40 | long style = wxRA_SPECIFY_COLS, | |
41 | const wxValidator& val = wxDefaultValidator, | |
6463b9f5 JS |
42 | const wxString& name = wxRadioBoxNameStr) |
43 | { | |
44 | Init(); | |
45 | ||
46 | (void)Create(parent, id, title, pos, size, n, choices, | |
47 | majorDim, style, val, name); | |
48 | } | |
584ad2a3 MB |
49 | wxRadioBox(wxWindow *parent, |
50 | wxWindowID id, | |
51 | const wxString& title, | |
52 | const wxPoint& pos, | |
53 | const wxSize& size, | |
54 | const wxArrayString& choices, | |
55 | int majorDim = 0, | |
56 | long style = wxRA_SPECIFY_COLS, | |
57 | const wxValidator& val = wxDefaultValidator, | |
58 | const wxString& name = wxRadioBoxNameStr); | |
1e6feb95 VZ |
59 | |
60 | bool Create(wxWindow *parent, | |
61 | wxWindowID id, | |
62 | const wxString& title, | |
63 | const wxPoint& pos = wxDefaultPosition, | |
64 | const wxSize& size = wxDefaultSize, | |
65 | int n = 0, const wxString *choices = NULL, | |
66 | int majorDim = 0, | |
67 | long style = wxRA_SPECIFY_COLS, | |
68 | const wxValidator& val = wxDefaultValidator, | |
69 | const wxString& name = wxRadioBoxNameStr); | |
584ad2a3 MB |
70 | bool Create(wxWindow *parent, |
71 | wxWindowID id, | |
72 | const wxString& title, | |
73 | const wxPoint& pos, | |
74 | const wxSize& size, | |
75 | const wxArrayString& choices, | |
76 | int majorDim = 0, | |
77 | long style = wxRA_SPECIFY_COLS, | |
78 | const wxValidator& val = wxDefaultValidator, | |
79 | const wxString& name = wxRadioBoxNameStr); | |
1e6feb95 VZ |
80 | |
81 | virtual ~wxRadioBox(); | |
82 | ||
83 | // implement wxRadioBox interface | |
84 | virtual void SetSelection(int n); | |
85 | virtual int GetSelection() const; | |
86 | ||
58161def | 87 | virtual int GetCount() const { return (int) m_buttons.GetCount(); } |
1e6feb95 VZ |
88 | virtual int GetColumnCount() const { return m_numCols; } |
89 | virtual int GetRowCount() const { return m_numRows; } | |
90 | ||
91 | virtual wxString GetString(int n) const; | |
92 | virtual void SetString(int n, const wxString& label); | |
93 | ||
1a87edf2 | 94 | virtual bool Enable(int n, bool enable = true); |
fa50c0e3 | 95 | virtual bool Show(int n, bool show = true); |
1e6feb95 VZ |
96 | |
97 | // we also override the wxControl methods to avoid virtual function hiding | |
a290fa5a WS |
98 | virtual bool Enable(bool enable = true); |
99 | virtual bool Show(bool show = true); | |
1e6feb95 VZ |
100 | virtual wxString GetLabel() const; |
101 | virtual void SetLabel(const wxString& label); | |
102 | ||
44029ca4 VZ |
103 | // we inherit a version returning false from wxStaticBox, override it again |
104 | virtual bool AcceptsFocus() const { return true; } | |
105 | ||
d4e5272b JS |
106 | #if wxUSE_TOOLTIPS |
107 | virtual void DoSetToolTip( wxToolTip *tip ); | |
108 | #endif // wxUSE_TOOLTIPS | |
109 | ||
1e6feb95 VZ |
110 | // wxUniversal-only methods |
111 | ||
112 | // another Append() version | |
113 | void Append(int n, const wxString *choices); | |
114 | ||
115 | // implementation only: called by wxRadioHookHandler | |
116 | void OnRadioButton(wxEvent& event); | |
117 | bool OnKeyDown(wxKeyEvent& event); | |
118 | ||
119 | protected: | |
120 | // override the base class methods dealing with window positioning/sizing | |
121 | // as we must move/size the buttons as well | |
122 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
123 | virtual wxSize DoGetBestClientSize() const; | |
124 | ||
125 | // generate a radiobutton click event for the current item | |
126 | void SendRadioEvent(); | |
127 | ||
128 | // common part of all ctors | |
129 | void Init(); | |
130 | ||
1e6feb95 VZ |
131 | // sets m_majorDim and calculate m_numCols and m_numRows |
132 | void SetMajorDim(int majorDim); | |
133 | ||
134 | // calculate the max size of all buttons | |
135 | wxSize GetMaxButtonSize() const; | |
136 | ||
137 | // the currently selected radio button or -1 | |
138 | int m_selection; | |
139 | ||
140 | // the parameters defining the button layout: majorDim meaning depends on | |
141 | // the style and is the (max) number of columns if it includes | |
142 | // wxRA_SPECIFY_COLS and is the (max) number of rows if it includes | |
143 | // wxRA_SPECIFY_ROWS - the number of rows and columns is calculated from | |
144 | // it | |
145 | int m_majorDim, | |
146 | m_numCols, | |
147 | m_numRows; | |
148 | ||
149 | // all radio buttons | |
150 | wxArrayRadioButtons m_buttons; | |
151 | ||
152 | // the event handler which is used to translate radiobutton events into | |
153 | // radiobox one | |
154 | wxEvtHandler *m_evtRadioHook; | |
155 | ||
156 | private: | |
157 | DECLARE_DYNAMIC_CLASS(wxRadioBox) | |
158 | }; | |
159 | ||
160 | #endif // _WX_UNIV_RADIOBOX_H_ |