1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/radiobox.h
3 // Purpose: wxRadioBox class
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_RADIOBOX_H_
12 #define _WX_RADIOBOX_H_
14 #include "wx/statbox.h"
16 class WXDLLIMPEXP_FWD_CORE wxSubwindows
;
18 // ----------------------------------------------------------------------------
20 // ----------------------------------------------------------------------------
22 class WXDLLIMPEXP_CORE wxRadioBox
: public wxStaticBox
, public wxRadioBoxBase
25 wxRadioBox() { Init(); }
27 wxRadioBox(wxWindow
*parent
,
29 const wxString
& title
,
30 const wxPoint
& pos
= wxDefaultPosition
,
31 const wxSize
& size
= wxDefaultSize
,
32 int n
= 0, const wxString choices
[] = NULL
,
34 long style
= wxRA_SPECIFY_COLS
,
35 const wxValidator
& val
= wxDefaultValidator
,
36 const wxString
& name
= wxRadioBoxNameStr
)
40 (void)Create(parent
, id
, title
, pos
, size
, n
, choices
, majorDim
,
44 wxRadioBox(wxWindow
*parent
,
46 const wxString
& title
,
49 const wxArrayString
& choices
,
51 long style
= wxRA_SPECIFY_COLS
,
52 const wxValidator
& val
= wxDefaultValidator
,
53 const wxString
& name
= wxRadioBoxNameStr
)
57 (void)Create(parent
, id
, title
, pos
, size
, choices
, majorDim
,
61 virtual ~wxRadioBox();
63 bool Create(wxWindow
*parent
,
65 const wxString
& title
,
66 const wxPoint
& pos
= wxDefaultPosition
,
67 const wxSize
& size
= wxDefaultSize
,
68 int n
= 0, const wxString choices
[] = NULL
,
70 long style
= wxRA_SPECIFY_COLS
,
71 const wxValidator
& val
= wxDefaultValidator
,
72 const wxString
& name
= wxRadioBoxNameStr
);
73 bool Create(wxWindow
*parent
,
75 const wxString
& title
,
78 const wxArrayString
& choices
,
80 long style
= wxRA_SPECIFY_COLS
,
81 const wxValidator
& val
= wxDefaultValidator
,
82 const wxString
& name
= wxRadioBoxNameStr
);
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;
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;
104 virtual bool HasToolTips() const;
105 #endif // wxUSE_TOOLTIPS
107 // override virtual function with a platform-independent implementation
108 virtual wxString
GetHelpTextAtPoint(const wxPoint
& pt
, wxHelpEvent::Origin origin
) const
110 return wxRadioBoxBase::DoGetHelpTextAtPoint( this, pt
, origin
);
114 virtual bool Reparent(wxWindowBase
*newParent
);
116 // returns true if the platform should explicitly apply a theme border
117 virtual bool CanApplyThemeBorder() const { return false; }
119 void SetLabelFont(const wxFont
& WXUNUSED(font
)) {}
120 void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
123 // implementation only from now on
124 // -------------------------------
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
);
130 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
131 void Command(wxCommandEvent
& event
);
133 void SendNotificationEvent();
136 // common part of all ctors
139 // subclass one radio button
140 void SubclassRadioButton(WXHWND hWndBtn
);
142 // get the max size of radio buttons
143 wxSize
GetMaxButtonSize() const;
145 // get the total size occupied by the radio box buttons
146 wxSize
GetTotalButtonSize(const wxSize
& sizeBtn
) const;
148 // Adjust all the buttons to the new window size.
149 void PositionAllButtons(int x
, int y
, int width
, int height
);
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;
158 virtual void DoSetItemToolTip(unsigned int n
, wxToolTip
* tooltip
);
162 virtual WXHRGN
MSWGetRegionWithoutChildren();
163 #endif // __WXWINCE__
165 // resolve ambiguity in base classes
166 virtual wxBorder
GetDefaultBorder() const { return wxRadioBoxBase::GetDefaultBorder(); }
168 // the buttons we contain
169 wxSubwindows
*m_radioButtons
;
171 // and the special dummy button used only as a tab group boundary
173 wxWindowIDRef m_dummyId
;
175 // array of widths and heights of the buttons, may be wxDefaultCoord if the
176 // corresponding quantity should be computed
180 // currently selected button or wxNOT_FOUND if none
181 int m_selectedButton
;
184 DECLARE_DYNAMIC_CLASS(wxRadioBox
)
185 wxDECLARE_NO_COPY_CLASS(wxRadioBox
);