1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/radiobox.h
3 // Purpose: wxRadioBox class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_RADIOBOX_H_
13 #define _WX_RADIOBOX_H_
15 #include "wx/statbox.h"
17 class WXDLLIMPEXP_FWD_CORE wxSubwindows
;
19 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
23 class WXDLLIMPEXP_CORE wxRadioBox
: public wxStaticBox
, public wxRadioBoxBase
26 wxRadioBox() { Init(); }
28 wxRadioBox(wxWindow
*parent
,
30 const wxString
& title
,
31 const wxPoint
& pos
= wxDefaultPosition
,
32 const wxSize
& size
= wxDefaultSize
,
33 int n
= 0, const wxString choices
[] = NULL
,
35 long style
= wxRA_SPECIFY_COLS
,
36 const wxValidator
& val
= wxDefaultValidator
,
37 const wxString
& name
= wxRadioBoxNameStr
)
41 (void)Create(parent
, id
, title
, pos
, size
, n
, choices
, majorDim
,
45 wxRadioBox(wxWindow
*parent
,
47 const wxString
& title
,
50 const wxArrayString
& choices
,
52 long style
= wxRA_SPECIFY_COLS
,
53 const wxValidator
& val
= wxDefaultValidator
,
54 const wxString
& name
= wxRadioBoxNameStr
)
58 (void)Create(parent
, id
, title
, pos
, size
, choices
, majorDim
,
62 virtual ~wxRadioBox();
64 bool Create(wxWindow
*parent
,
66 const wxString
& title
,
67 const wxPoint
& pos
= wxDefaultPosition
,
68 const wxSize
& size
= wxDefaultSize
,
69 int n
= 0, const wxString choices
[] = NULL
,
71 long style
= wxRA_SPECIFY_COLS
,
72 const wxValidator
& val
= wxDefaultValidator
,
73 const wxString
& name
= wxRadioBoxNameStr
);
74 bool Create(wxWindow
*parent
,
76 const wxString
& title
,
79 const wxArrayString
& choices
,
81 long style
= wxRA_SPECIFY_COLS
,
82 const wxValidator
& val
= wxDefaultValidator
,
83 const wxString
& name
= wxRadioBoxNameStr
);
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;
97 // override some base class methods
98 virtual bool Show(bool show
= true);
99 virtual bool Enable(bool enable
= true);
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 // we inherit a version always returning false from wxStaticBox, override
117 // it to behave normally
118 virtual bool AcceptsFocus() const { return wxControl::AcceptsFocus(); }
120 // returns true if the platform should explicitly apply a theme border
121 virtual bool CanApplyThemeBorder() const { return false; }
123 void SetLabelFont(const wxFont
& WXUNUSED(font
)) {}
124 void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
127 // implementation only from now on
128 // -------------------------------
130 // This function can be used to check if the given radio button HWND
131 // belongs to one of our radio boxes. If it doesn't, NULL is returned.
132 static wxRadioBox
*GetFromRadioButtonHWND(WXHWND hwnd
);
134 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
135 void Command(wxCommandEvent
& event
);
137 void SendNotificationEvent();
140 // common part of all ctors
143 // subclass one radio button
144 void SubclassRadioButton(WXHWND hWndBtn
);
146 // get the max size of radio buttons
147 wxSize
GetMaxButtonSize() const;
149 // get the total size occupied by the radio box buttons
150 wxSize
GetTotalButtonSize(const wxSize
& sizeBtn
) const;
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;
159 virtual void DoSetItemToolTip(unsigned int n
, wxToolTip
* tooltip
);
163 virtual WXHRGN
MSWGetRegionWithoutChildren();
164 #endif // __WXWINCE__
167 // the buttons we contain
168 wxSubwindows
*m_radioButtons
;
170 // and the special dummy button used only as a tab group boundary
172 wxWindowIDRef m_dummyId
;
174 // array of widths and heights of the buttons, may be wxDefaultCoord if the
175 // corresponding quantity should be computed
179 // currently selected button or wxNOT_FOUND if none
180 int m_selectedButton
;
183 DECLARE_DYNAMIC_CLASS(wxRadioBox
)
184 wxDECLARE_NO_COPY_CLASS(wxRadioBox
);