]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/radiobox.h
Removed a method using wxColour from non-GUI benchmark code.
[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 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_RADIOBOX_H_
12 #define _WX_RADIOBOX_H_
13
14 #include "wx/statbox.h"
15
16 class WXDLLIMPEXP_FWD_CORE wxSubwindows;
17
18 // ----------------------------------------------------------------------------
19 // wxRadioBox
20 // ----------------------------------------------------------------------------
21
22 class WXDLLIMPEXP_CORE wxRadioBox : public wxStaticBox, public wxRadioBoxBase
23 {
24 public:
25 wxRadioBox() { Init(); }
26
27 wxRadioBox(wxWindow *parent,
28 wxWindowID id,
29 const wxString& title,
30 const wxPoint& pos = wxDefaultPosition,
31 const wxSize& size = wxDefaultSize,
32 int n = 0, const wxString choices[] = NULL,
33 int majorDim = 0,
34 long style = wxRA_SPECIFY_COLS,
35 const wxValidator& val = wxDefaultValidator,
36 const wxString& name = wxRadioBoxNameStr)
37 {
38 Init();
39
40 (void)Create(parent, id, title, pos, size, n, choices, majorDim,
41 style, val, name);
42 }
43
44 wxRadioBox(wxWindow *parent,
45 wxWindowID id,
46 const wxString& title,
47 const wxPoint& pos,
48 const wxSize& size,
49 const wxArrayString& choices,
50 int majorDim = 0,
51 long style = wxRA_SPECIFY_COLS,
52 const wxValidator& val = wxDefaultValidator,
53 const wxString& name = wxRadioBoxNameStr)
54 {
55 Init();
56
57 (void)Create(parent, id, title, pos, size, choices, majorDim,
58 style, val, name);
59 }
60
61 virtual ~wxRadioBox();
62
63 bool Create(wxWindow *parent,
64 wxWindowID id,
65 const wxString& title,
66 const wxPoint& pos = wxDefaultPosition,
67 const wxSize& size = wxDefaultSize,
68 int n = 0, const wxString choices[] = NULL,
69 int majorDim = 0,
70 long style = wxRA_SPECIFY_COLS,
71 const wxValidator& val = wxDefaultValidator,
72 const wxString& name = wxRadioBoxNameStr);
73 bool Create(wxWindow *parent,
74 wxWindowID id,
75 const wxString& title,
76 const wxPoint& pos,
77 const wxSize& size,
78 const wxArrayString& choices,
79 int majorDim = 0,
80 long style = wxRA_SPECIFY_COLS,
81 const wxValidator& val = wxDefaultValidator,
82 const wxString& name = wxRadioBoxNameStr);
83
84 // implement the radiobox interface
85 virtual void SetSelection(int n);
86 virtual int GetSelection() const { return m_selectedButton; }
87 virtual unsigned int GetCount() const;
88 virtual wxString GetString(unsigned int n) const;
89 virtual void SetString(unsigned int n, const wxString& label);
90 virtual bool Enable(unsigned int n, bool enable = true);
91 virtual bool Show(unsigned int n, bool show = true);
92 virtual bool IsItemEnabled(unsigned int n) const;
93 virtual bool IsItemShown(unsigned int n) const;
94 virtual int GetItemFromPoint(const wxPoint& pt) const;
95
96 // override some base class methods
97 virtual bool Show(bool show = true);
98 virtual bool Enable(bool enable = true);
99 virtual bool CanBeFocused() const;
100 virtual void SetFocus();
101 virtual bool SetFont(const wxFont& font);
102 virtual bool ContainsHWND(WXHWND hWnd) const;
103 #if wxUSE_TOOLTIPS
104 virtual bool HasToolTips() const;
105 #endif // wxUSE_TOOLTIPS
106 #if wxUSE_HELP
107 // override virtual function with a platform-independent implementation
108 virtual wxString GetHelpTextAtPoint(const wxPoint & pt, wxHelpEvent::Origin origin) const
109 {
110 return wxRadioBoxBase::DoGetHelpTextAtPoint( this, pt, origin );
111 }
112 #endif // wxUSE_HELP
113
114 virtual bool Reparent(wxWindowBase *newParent);
115
116 // returns true if the platform should explicitly apply a theme border
117 virtual bool CanApplyThemeBorder() const { return false; }
118
119 void SetLabelFont(const wxFont& WXUNUSED(font)) {}
120 void SetButtonFont(const wxFont& font) { SetFont(font); }
121
122
123 // implementation only from now on
124 // -------------------------------
125
126 // This function can be used to check if the given radio button HWND
127 // belongs to one of our radio boxes. If it doesn't, NULL is returned.
128 static wxRadioBox *GetFromRadioButtonHWND(WXHWND hwnd);
129
130 virtual bool MSWCommand(WXUINT param, WXWORD id);
131 void Command(wxCommandEvent& event);
132
133 void SendNotificationEvent();
134
135 protected:
136 // common part of all ctors
137 void Init();
138
139 // subclass one radio button
140 void SubclassRadioButton(WXHWND hWndBtn);
141
142 // get the max size of radio buttons
143 wxSize GetMaxButtonSize() const;
144
145 // get the total size occupied by the radio box buttons
146 wxSize GetTotalButtonSize(const wxSize& sizeBtn) const;
147
148 // Adjust all the buttons to the new window size.
149 void PositionAllButtons(int x, int y, int width, int height);
150
151 virtual void DoSetSize(int x, int y,
152 int width, int height,
153 int sizeFlags = wxSIZE_AUTO);
154 virtual void DoMoveWindow(int x, int y, int width, int height);
155 virtual wxSize DoGetBestSize() const;
156
157 #if wxUSE_TOOLTIPS
158 virtual void DoSetItemToolTip(unsigned int n, wxToolTip * tooltip);
159 #endif
160
161 #ifndef __WXWINCE__
162 virtual WXHRGN MSWGetRegionWithoutChildren();
163 #endif // __WXWINCE__
164
165 // resolve ambiguity in base classes
166 virtual wxBorder GetDefaultBorder() const { return wxRadioBoxBase::GetDefaultBorder(); }
167
168 // the buttons we contain
169 wxSubwindows *m_radioButtons;
170
171 // and the special dummy button used only as a tab group boundary
172 WXHWND m_dummyHwnd;
173 wxWindowIDRef m_dummyId;
174
175 // array of widths and heights of the buttons, may be wxDefaultCoord if the
176 // corresponding quantity should be computed
177 int *m_radioWidth;
178 int *m_radioHeight;
179
180 // currently selected button or wxNOT_FOUND if none
181 int m_selectedButton;
182
183 private:
184 DECLARE_DYNAMIC_CLASS(wxRadioBox)
185 wxDECLARE_NO_COPY_CLASS(wxRadioBox);
186 };
187
188 #endif
189 // _WX_RADIOBOX_H_