1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/radiobox.h
3 // Purpose: wxRadioBox declaration
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_RADIOBOX_H_
13 #define _WX_UNIV_RADIOBOX_H_
15 class WXDLLEXPORT wxRadioButton
;
17 #include "wx/statbox.h"
18 #include "wx/dynarray.h"
20 WX_DEFINE_EXPORTED_ARRAY_PTR(wxRadioButton
*, wxArrayRadioButtons
);
22 // ----------------------------------------------------------------------------
23 // wxRadioBox: a box full of radio buttons
24 // ----------------------------------------------------------------------------
26 class WXDLLEXPORT wxRadioBox
: public wxStaticBox
,
30 // wxRadioBox construction
31 wxRadioBox() { Init(); }
33 wxRadioBox(wxWindow
*parent
,
35 const wxString
& title
,
36 const wxPoint
& pos
= wxDefaultPosition
,
37 const wxSize
& size
= wxDefaultSize
,
38 int n
= 0, const wxString
*choices
= NULL
,
40 long style
= wxRA_SPECIFY_COLS
,
41 const wxValidator
& val
= wxDefaultValidator
,
42 const wxString
& name
= wxRadioBoxNameStr
)
46 (void)Create(parent
, id
, title
, pos
, size
, n
, choices
,
47 majorDim
, style
, val
, name
);
49 wxRadioBox(wxWindow
*parent
,
51 const wxString
& title
,
54 const wxArrayString
& choices
,
56 long style
= wxRA_SPECIFY_COLS
,
57 const wxValidator
& val
= wxDefaultValidator
,
58 const wxString
& name
= wxRadioBoxNameStr
);
60 bool Create(wxWindow
*parent
,
62 const wxString
& title
,
63 const wxPoint
& pos
= wxDefaultPosition
,
64 const wxSize
& size
= wxDefaultSize
,
65 int n
= 0, const wxString
*choices
= NULL
,
67 long style
= wxRA_SPECIFY_COLS
,
68 const wxValidator
& val
= wxDefaultValidator
,
69 const wxString
& name
= wxRadioBoxNameStr
);
70 bool Create(wxWindow
*parent
,
72 const wxString
& title
,
75 const wxArrayString
& choices
,
77 long style
= wxRA_SPECIFY_COLS
,
78 const wxValidator
& val
= wxDefaultValidator
,
79 const wxString
& name
= wxRadioBoxNameStr
);
81 virtual ~wxRadioBox();
83 // implement wxRadioBox interface
84 virtual void SetSelection(int n
);
85 virtual int GetSelection() const;
87 virtual int GetCount() const { return (int) m_buttons
.GetCount(); }
89 virtual wxString
GetString(int n
) const;
90 virtual void SetString(int n
, const wxString
& label
);
92 virtual bool Enable(int n
, bool enable
= true);
93 virtual bool Show(int n
, bool show
= true);
95 virtual bool IsItemEnabled(int n
) const;
96 virtual bool IsItemShown(int n
) const;
98 // we also override the wxControl methods to avoid virtual function hiding
99 virtual bool Enable(bool enable
= true);
100 virtual bool Show(bool show
= true);
101 virtual wxString
GetLabel() const;
102 virtual void SetLabel(const wxString
& label
);
104 // we inherit a version returning false from wxStaticBox, override it again
105 virtual bool AcceptsFocus() const { return true; }
108 virtual void DoSetToolTip( wxToolTip
*tip
);
109 #endif // wxUSE_TOOLTIPS
111 // wxUniversal-only methods
113 // another Append() version
114 void Append(int n
, const wxString
*choices
);
116 // implementation only: called by wxRadioHookHandler
117 void OnRadioButton(wxEvent
& event
);
118 bool OnKeyDown(wxKeyEvent
& event
);
121 // override the base class methods dealing with window positioning/sizing
122 // as we must move/size the buttons as well
123 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
124 virtual wxSize
DoGetBestClientSize() const;
126 // generate a radiobutton click event for the current item
127 void SendRadioEvent();
129 // common part of all ctors
132 // calculate the max size of all buttons
133 wxSize
GetMaxButtonSize() const;
135 // the currently selected radio button or -1
139 wxArrayRadioButtons m_buttons
;
141 // the event handler which is used to translate radiobutton events into
143 wxEvtHandler
*m_evtRadioHook
;
146 DECLARE_DYNAMIC_CLASS(wxRadioBox
)
149 #endif // _WX_UNIV_RADIOBOX_H_