1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/radiobox.h
3 // Purpose: wxRadioBox declaration
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_UNIV_RADIOBOX_H_
12 #define _WX_UNIV_RADIOBOX_H_
14 class WXDLLIMPEXP_FWD_CORE wxRadioButton
;
16 #include "wx/statbox.h"
17 #include "wx/dynarray.h"
19 WX_DEFINE_EXPORTED_ARRAY_PTR(wxRadioButton
*, wxArrayRadioButtons
);
21 // ----------------------------------------------------------------------------
22 // wxRadioBox: a box full of radio buttons
23 // ----------------------------------------------------------------------------
25 class WXDLLIMPEXP_CORE wxRadioBox
: public wxStaticBox
,
29 // wxRadioBox construction
30 wxRadioBox() { Init(); }
32 wxRadioBox(wxWindow
*parent
,
34 const wxString
& title
,
35 const wxPoint
& pos
= wxDefaultPosition
,
36 const wxSize
& size
= wxDefaultSize
,
37 int n
= 0, const wxString
*choices
= NULL
,
39 long style
= wxRA_SPECIFY_COLS
,
40 const wxValidator
& val
= wxDefaultValidator
,
41 const wxString
& name
= wxRadioBoxNameStr
)
45 (void)Create(parent
, id
, title
, pos
, size
, n
, choices
,
46 majorDim
, style
, val
, name
);
48 wxRadioBox(wxWindow
*parent
,
50 const wxString
& title
,
53 const wxArrayString
& choices
,
55 long style
= wxRA_SPECIFY_COLS
,
56 const wxValidator
& val
= wxDefaultValidator
,
57 const wxString
& name
= wxRadioBoxNameStr
);
59 bool Create(wxWindow
*parent
,
61 const wxString
& title
,
62 const wxPoint
& pos
= wxDefaultPosition
,
63 const wxSize
& size
= wxDefaultSize
,
64 int n
= 0, const wxString
*choices
= NULL
,
66 long style
= wxRA_SPECIFY_COLS
,
67 const wxValidator
& val
= wxDefaultValidator
,
68 const wxString
& name
= wxRadioBoxNameStr
);
69 bool Create(wxWindow
*parent
,
71 const wxString
& title
,
74 const wxArrayString
& choices
,
76 long style
= wxRA_SPECIFY_COLS
,
77 const wxValidator
& val
= wxDefaultValidator
,
78 const wxString
& name
= wxRadioBoxNameStr
);
80 virtual ~wxRadioBox();
82 // implement wxRadioBox interface
83 virtual void SetSelection(int n
);
84 virtual int GetSelection() const;
86 virtual unsigned int GetCount() const
87 { return (unsigned int)m_buttons
.GetCount(); }
89 virtual wxString
GetString(unsigned int n
) const;
90 virtual void SetString(unsigned int n
, const wxString
& label
);
92 virtual bool Enable(unsigned int n
, bool enable
= true);
93 virtual bool Show(unsigned int n
, bool show
= true);
95 virtual bool IsItemEnabled(unsigned int n
) const;
96 virtual bool IsItemShown(unsigned 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 always returning false from wxStaticBox, override
105 // it to behave normally
106 virtual bool AcceptsFocus() const { return wxControl::AcceptsFocus(); }
109 virtual void DoSetToolTip( wxToolTip
*tip
);
110 #endif // wxUSE_TOOLTIPS
112 // wxUniversal-only methods
114 // another Append() version
115 void Append(int n
, const wxString
*choices
);
117 // implementation only: called by wxRadioHookHandler
118 void OnRadioButton(wxEvent
& event
);
119 bool OnKeyDown(wxKeyEvent
& event
);
122 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
124 // override the base class methods dealing with window positioning/sizing
125 // as we must move/size the buttons as well
126 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
127 virtual wxSize
DoGetBestClientSize() const;
129 // generate a radiobutton click event for the current item
130 void SendRadioEvent();
132 // common part of all ctors
135 // calculate the max size of all buttons
136 wxSize
GetMaxButtonSize() const;
138 // the currently selected radio button or -1
142 wxArrayRadioButtons m_buttons
;
144 // the event handler which is used to translate radiobutton events into
146 wxEvtHandler
*m_evtRadioHook
;
149 DECLARE_DYNAMIC_CLASS(wxRadioBox
)
152 #endif // _WX_UNIV_RADIOBOX_H_