]>
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) |
371a5b4e | 9 | // Licence: wxWindows licence |
1e6feb95 VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_UNIV_RADIOBOX_H_ | |
13 | #define _WX_UNIV_RADIOBOX_H_ | |
14 | ||
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
a3870b2f | 16 | #pragma interface "univradiobox.h" |
1e6feb95 VZ |
17 | #endif |
18 | ||
19 | class WXDLLEXPORT wxRadioButton; | |
20 | ||
21 | #include "wx/statbox.h" | |
22 | #include "wx/dynarray.h" | |
23 | ||
d5d29b8a | 24 | WX_DEFINE_EXPORTED_ARRAY_PTR(wxRadioButton *, wxArrayRadioButtons); |
1e6feb95 VZ |
25 | |
26 | // ---------------------------------------------------------------------------- | |
27 | // wxRadioBox: a box full of radio buttons | |
28 | // ---------------------------------------------------------------------------- | |
29 | ||
30 | class WXDLLEXPORT wxRadioBox : public wxStaticBox, | |
31 | public wxRadioBoxBase | |
32 | { | |
33 | public: | |
34 | // wxRadioBox construction | |
35 | wxRadioBox() { Init(); } | |
36 | ||
37 | wxRadioBox(wxWindow *parent, | |
38 | wxWindowID id, | |
39 | const wxString& title, | |
40 | const wxPoint& pos = wxDefaultPosition, | |
41 | const wxSize& size = wxDefaultSize, | |
42 | int n = 0, const wxString *choices = NULL, | |
43 | int majorDim = 0, | |
44 | long style = wxRA_SPECIFY_COLS, | |
45 | const wxValidator& val = wxDefaultValidator, | |
46 | const wxString& name = wxRadioBoxNameStr) | |
47 | { | |
48 | Init(); | |
49 | ||
50 | (void)Create(parent, id, title, pos, size, n, choices, | |
51 | majorDim, style, val, name); | |
52 | } | |
53 | ||
54 | bool Create(wxWindow *parent, | |
55 | wxWindowID id, | |
56 | const wxString& title, | |
57 | const wxPoint& pos = wxDefaultPosition, | |
58 | const wxSize& size = wxDefaultSize, | |
59 | int n = 0, const wxString *choices = NULL, | |
60 | int majorDim = 0, | |
61 | long style = wxRA_SPECIFY_COLS, | |
62 | const wxValidator& val = wxDefaultValidator, | |
63 | const wxString& name = wxRadioBoxNameStr); | |
64 | ||
65 | virtual ~wxRadioBox(); | |
66 | ||
67 | // implement wxRadioBox interface | |
68 | virtual void SetSelection(int n); | |
69 | virtual int GetSelection() const; | |
70 | ||
71 | virtual int GetCount() const { return m_buttons.GetCount(); } | |
72 | virtual int GetColumnCount() const { return m_numCols; } | |
73 | virtual int GetRowCount() const { return m_numRows; } | |
74 | ||
75 | virtual wxString GetString(int n) const; | |
76 | virtual void SetString(int n, const wxString& label); | |
77 | ||
78 | virtual void Enable(int n, bool enable = TRUE); | |
79 | virtual void Show(int n, bool show = TRUE); | |
80 | ||
81 | // we also override the wxControl methods to avoid virtual function hiding | |
82 | virtual bool Enable(bool enable = TRUE); | |
83 | virtual bool Show(bool show = TRUE); | |
84 | virtual wxString GetLabel() const; | |
85 | virtual void SetLabel(const wxString& label); | |
86 | ||
d4e5272b JS |
87 | #if wxUSE_TOOLTIPS |
88 | virtual void DoSetToolTip( wxToolTip *tip ); | |
89 | #endif // wxUSE_TOOLTIPS | |
90 | ||
1e6feb95 VZ |
91 | // wxUniversal-only methods |
92 | ||
93 | // another Append() version | |
94 | void Append(int n, const wxString *choices); | |
95 | ||
96 | // implementation only: called by wxRadioHookHandler | |
97 | void OnRadioButton(wxEvent& event); | |
98 | bool OnKeyDown(wxKeyEvent& event); | |
99 | ||
100 | protected: | |
101 | // override the base class methods dealing with window positioning/sizing | |
102 | // as we must move/size the buttons as well | |
103 | virtual void DoMoveWindow(int x, int y, int width, int height); | |
104 | virtual wxSize DoGetBestClientSize() const; | |
105 | ||
106 | // generate a radiobutton click event for the current item | |
107 | void SendRadioEvent(); | |
108 | ||
109 | // common part of all ctors | |
110 | void Init(); | |
111 | ||
112 | // check that the index is valid | |
113 | bool IsValid(int n) const { return n >= 0 && n < GetCount(); } | |
114 | ||
115 | // sets m_majorDim and calculate m_numCols and m_numRows | |
116 | void SetMajorDim(int majorDim); | |
117 | ||
118 | // calculate the max size of all buttons | |
119 | wxSize GetMaxButtonSize() const; | |
120 | ||
121 | // the currently selected radio button or -1 | |
122 | int m_selection; | |
123 | ||
124 | // the parameters defining the button layout: majorDim meaning depends on | |
125 | // the style and is the (max) number of columns if it includes | |
126 | // wxRA_SPECIFY_COLS and is the (max) number of rows if it includes | |
127 | // wxRA_SPECIFY_ROWS - the number of rows and columns is calculated from | |
128 | // it | |
129 | int m_majorDim, | |
130 | m_numCols, | |
131 | m_numRows; | |
132 | ||
133 | // all radio buttons | |
134 | wxArrayRadioButtons m_buttons; | |
135 | ||
136 | // the event handler which is used to translate radiobutton events into | |
137 | // radiobox one | |
138 | wxEvtHandler *m_evtRadioHook; | |
139 | ||
140 | private: | |
141 | DECLARE_DYNAMIC_CLASS(wxRadioBox) | |
142 | }; | |
143 | ||
144 | #endif // _WX_UNIV_RADIOBOX_H_ |