]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/radiobox.h
added wxRadioBox::IsItemEnabled/Shown() (for MSW only for now, other platforms to...
[wxWidgets.git] / include / wx / msw / radiobox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/radiobox.h
3 // Purpose: wxRadioBox class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_RADIOBOX_H_
13 #define _WX_RADIOBOX_H_
14
15 #include "wx/statbox.h"
16
17 class WXDLLEXPORT wxSubwindows;
18
19 // ----------------------------------------------------------------------------
20 // wxRadioBox
21 // ----------------------------------------------------------------------------
22
23 class WXDLLEXPORT wxRadioBox : public wxStaticBox, public wxRadioBoxBase
24 {
25 public:
26 wxRadioBox() { Init(); }
27
28 wxRadioBox(wxWindow *parent,
29 wxWindowID id,
30 const wxString& title,
31 const wxPoint& pos = wxDefaultPosition,
32 const wxSize& size = wxDefaultSize,
33 int n = 0, const wxString choices[] = NULL,
34 int majorDim = 0,
35 long style = wxRA_HORIZONTAL,
36 const wxValidator& val = wxDefaultValidator,
37 const wxString& name = wxRadioBoxNameStr)
38 {
39 Init();
40
41 (void)Create(parent, id, title, pos, size, n, choices, majorDim,
42 style, val, name);
43 }
44
45 wxRadioBox(wxWindow *parent,
46 wxWindowID id,
47 const wxString& title,
48 const wxPoint& pos,
49 const wxSize& size,
50 const wxArrayString& choices,
51 int majorDim = 0,
52 long style = wxRA_HORIZONTAL,
53 const wxValidator& val = wxDefaultValidator,
54 const wxString& name = wxRadioBoxNameStr)
55 {
56 Init();
57
58 (void)Create(parent, id, title, pos, size, choices, majorDim,
59 style, val, name);
60 }
61
62 ~wxRadioBox();
63
64 bool Create(wxWindow *parent,
65 wxWindowID id,
66 const wxString& title,
67 const wxPoint& pos = wxDefaultPosition,
68 const wxSize& size = wxDefaultSize,
69 int n = 0, const wxString choices[] = NULL,
70 int majorDim = 0,
71 long style = wxRA_HORIZONTAL,
72 const wxValidator& val = wxDefaultValidator,
73 const wxString& name = wxRadioBoxNameStr);
74 bool Create(wxWindow *parent,
75 wxWindowID id,
76 const wxString& title,
77 const wxPoint& pos,
78 const wxSize& size,
79 const wxArrayString& choices,
80 int majorDim = 0,
81 long style = wxRA_HORIZONTAL,
82 const wxValidator& val = wxDefaultValidator,
83 const wxString& name = wxRadioBoxNameStr);
84
85 // implement the radiobox interface
86 virtual void SetSelection(int n);
87 virtual int GetSelection() const { return m_selectedButton; }
88 virtual int GetCount() const;
89 virtual wxString GetString(int n) const;
90 virtual void SetString(int n, const wxString& label);
91 virtual bool Enable(int n, bool enable = true);
92 virtual bool Show(int n, bool show = true);
93 virtual bool IsItemEnabled(int n) const;
94 virtual bool IsItemShown(int n) const;
95 virtual int GetColumnCount() const { return GetNumHor(); }
96 virtual int GetRowCount() const { return GetNumVer(); }
97
98 // override some base class methods
99 virtual bool Show(bool show = true);
100 virtual bool Enable(bool enable = true);
101 virtual void SetFocus();
102 virtual bool SetFont(const wxFont& font);
103 virtual bool ContainsHWND(WXHWND hWnd) const;
104
105 // we inherit a version returning false from wxStaticBox, override it again
106 virtual bool AcceptsFocus() const { return true; }
107
108 void SetLabelFont(const wxFont& WXUNUSED(font)) {}
109 void SetButtonFont(const wxFont& font) { SetFont(font); }
110
111
112 // implementation only from now on
113 // -------------------------------
114
115 virtual bool MSWCommand(WXUINT param, WXWORD id);
116 void Command(wxCommandEvent& event);
117
118 void SendNotificationEvent();
119
120 // get the number of buttons per column/row
121 int GetNumVer() const;
122 int GetNumHor() const;
123
124 protected:
125 // common part of all ctors
126 void Init();
127
128 // we can't compute our best size before the items are added to the control
129 virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) { }
130
131 // subclass one radio button
132 void SubclassRadioButton(WXHWND hWndBtn);
133
134 // get the max size of radio buttons
135 wxSize GetMaxButtonSize() const;
136
137 // get the total size occupied by the radio box buttons
138 wxSize GetTotalButtonSize(const wxSize& sizeBtn) const;
139
140 virtual void DoSetSize(int x, int y,
141 int width, int height,
142 int sizeFlags = wxSIZE_AUTO);
143 virtual wxSize DoGetBestSize() const;
144
145 #ifndef __WXWINCE__
146 virtual WXHRGN MSWGetRegionWithoutChildren();
147 virtual WXLRESULT MSWWindowProc(WXUINT nMsg,
148 WXWPARAM wParam,
149 WXLPARAM lParam);
150 #endif // __WXWINCE__
151
152
153 // the buttons we contain
154 wxSubwindows *m_radioButtons;
155
156 // array of widths and heights of the buttons, may be wxDefaultCoord if the
157 // corresponding quantity should be computed
158 int *m_radioWidth;
159 int *m_radioHeight;
160
161 // the number of elements in major dimension (i.e. number of columns if
162 // wxRA_SPECIFY_COLS or the number of rows if wxRA_SPECIFY_ROWS)
163 int m_majorDim;
164
165 // currently selected button or wxNOT_FOUND if none
166 int m_selectedButton;
167
168 private:
169 DECLARE_DYNAMIC_CLASS(wxRadioBox)
170 DECLARE_NO_COPY_CLASS(wxRadioBox)
171 };
172
173 #endif
174 // _WX_RADIOBOX_H_