]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/radiobox.h
def96487c80f6982eebc54e82a48f80d0c90fc38
[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 WXDLLIMPEXP_FWD_CORE wxSubwindows;
18
19 // ----------------------------------------------------------------------------
20 // wxRadioBox
21 // ----------------------------------------------------------------------------
22
23 class WXDLLIMPEXP_CORE 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_SPECIFY_COLS,
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_SPECIFY_COLS,
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 virtual ~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_SPECIFY_COLS,
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_SPECIFY_COLS,
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 unsigned int GetCount() const;
89 virtual wxString GetString(unsigned int n) const;
90 virtual void SetString(unsigned int n, const wxString& label);
91 virtual bool Enable(unsigned int n, bool enable = true);
92 virtual bool Show(unsigned int n, bool show = true);
93 virtual bool IsItemEnabled(unsigned int n) const;
94 virtual bool IsItemShown(unsigned int n) const;
95 virtual int GetItemFromPoint(const wxPoint& pt) const;
96
97 // override some base class methods
98 virtual bool Show(bool show = true);
99 virtual bool Enable(bool enable = true);
100 virtual bool CanBeFocused() const;
101 virtual void SetFocus();
102 virtual bool SetFont(const wxFont& font);
103 virtual bool ContainsHWND(WXHWND hWnd) const;
104 #if wxUSE_TOOLTIPS
105 virtual bool HasToolTips() const;
106 #endif // wxUSE_TOOLTIPS
107 #if wxUSE_HELP
108 // override virtual function with a platform-independent implementation
109 virtual wxString GetHelpTextAtPoint(const wxPoint & pt, wxHelpEvent::Origin origin) const
110 {
111 return wxRadioBoxBase::DoGetHelpTextAtPoint( this, pt, origin );
112 }
113 #endif // wxUSE_HELP
114
115 virtual bool Reparent(wxWindowBase *newParent);
116
117 // returns true if the platform should explicitly apply a theme border
118 virtual bool CanApplyThemeBorder() const { return false; }
119
120 void SetLabelFont(const wxFont& WXUNUSED(font)) {}
121 void SetButtonFont(const wxFont& font) { SetFont(font); }
122
123
124 // implementation only from now on
125 // -------------------------------
126
127 // This function can be used to check if the given radio button HWND
128 // belongs to one of our radio boxes. If it doesn't, NULL is returned.
129 static wxRadioBox *GetFromRadioButtonHWND(WXHWND hwnd);
130
131 virtual bool MSWCommand(WXUINT param, WXWORD id);
132 void Command(wxCommandEvent& event);
133
134 void SendNotificationEvent();
135
136 protected:
137 // common part of all ctors
138 void Init();
139
140 // subclass one radio button
141 void SubclassRadioButton(WXHWND hWndBtn);
142
143 // get the max size of radio buttons
144 wxSize GetMaxButtonSize() const;
145
146 // get the total size occupied by the radio box buttons
147 wxSize GetTotalButtonSize(const wxSize& sizeBtn) const;
148
149 // Adjust all the buttons to the new window size.
150 void PositionAllButtons(int x, int y, int width, int height);
151
152 virtual void DoSetSize(int x, int y,
153 int width, int height,
154 int sizeFlags = wxSIZE_AUTO);
155 virtual void DoMoveWindow(int x, int y, int width, int height);
156 virtual wxSize DoGetBestSize() const;
157
158 #if wxUSE_TOOLTIPS
159 virtual void DoSetItemToolTip(unsigned int n, wxToolTip * tooltip);
160 #endif
161
162 #ifndef __WXWINCE__
163 virtual WXHRGN MSWGetRegionWithoutChildren();
164 #endif // __WXWINCE__
165
166 // resolve ambiguity in base classes
167 virtual wxBorder GetDefaultBorder() const { return wxRadioBoxBase::GetDefaultBorder(); }
168
169 // the buttons we contain
170 wxSubwindows *m_radioButtons;
171
172 // and the special dummy button used only as a tab group boundary
173 WXHWND m_dummyHwnd;
174 wxWindowIDRef m_dummyId;
175
176 // array of widths and heights of the buttons, may be wxDefaultCoord if the
177 // corresponding quantity should be computed
178 int *m_radioWidth;
179 int *m_radioHeight;
180
181 // currently selected button or wxNOT_FOUND if none
182 int m_selectedButton;
183
184 private:
185 DECLARE_DYNAMIC_CLASS(wxRadioBox)
186 wxDECLARE_NO_COPY_CLASS(wxRadioBox);
187 };
188
189 #endif
190 // _WX_RADIOBOX_H_