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: wxWidgets licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_RADIOBOX_H_
13 #define _WX_UNIV_RADIOBOX_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "univradiobox.h"
19 class WXDLLEXPORT wxRadioButton
;
21 #include "wx/statbox.h"
22 #include "wx/dynarray.h"
24 WX_DEFINE_EXPORTED_ARRAY_PTR(wxRadioButton
*, wxArrayRadioButtons
);
26 // ----------------------------------------------------------------------------
27 // wxRadioBox: a box full of radio buttons
28 // ----------------------------------------------------------------------------
30 class WXDLLEXPORT wxRadioBox
: public wxStaticBox
,
34 // wxRadioBox construction
35 wxRadioBox() { Init(); }
37 wxRadioBox(wxWindow
*parent
,
39 const wxString
& title
,
40 const wxPoint
& pos
= wxDefaultPosition
,
41 const wxSize
& size
= wxDefaultSize
,
42 int n
= 0, const wxString
*choices
= NULL
,
44 long style
= wxRA_SPECIFY_COLS
,
45 const wxValidator
& val
= wxDefaultValidator
,
46 const wxString
& name
= wxRadioBoxNameStr
)
50 (void)Create(parent
, id
, title
, pos
, size
, n
, choices
,
51 majorDim
, style
, val
, name
);
53 wxRadioBox(wxWindow
*parent
,
55 const wxString
& title
,
58 const wxArrayString
& choices
,
60 long style
= wxRA_SPECIFY_COLS
,
61 const wxValidator
& val
= wxDefaultValidator
,
62 const wxString
& name
= wxRadioBoxNameStr
);
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 virtual ~wxRadioBox();
87 // implement wxRadioBox interface
88 virtual void SetSelection(int n
);
89 virtual int GetSelection() const;
91 virtual int GetCount() const { return m_buttons
.GetCount(); }
92 virtual int GetColumnCount() const { return m_numCols
; }
93 virtual int GetRowCount() const { return m_numRows
; }
95 virtual wxString
GetString(int n
) const;
96 virtual void SetString(int n
, const wxString
& label
);
98 virtual void Enable(int n
, bool enable
= TRUE
);
99 virtual void Show(int n
, bool show
= TRUE
);
101 // we also override the wxControl methods to avoid virtual function hiding
102 virtual bool Enable(bool enable
= TRUE
);
103 virtual bool Show(bool show
= TRUE
);
104 virtual wxString
GetLabel() const;
105 virtual void SetLabel(const wxString
& label
);
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 // check that the index is valid
133 bool IsValid(int n
) const { return n
>= 0 && n
< GetCount(); }
135 // sets m_majorDim and calculate m_numCols and m_numRows
136 void SetMajorDim(int majorDim
);
138 // calculate the max size of all buttons
139 wxSize
GetMaxButtonSize() const;
141 // the currently selected radio button or -1
144 // the parameters defining the button layout: majorDim meaning depends on
145 // the style and is the (max) number of columns if it includes
146 // wxRA_SPECIFY_COLS and is the (max) number of rows if it includes
147 // wxRA_SPECIFY_ROWS - the number of rows and columns is calculated from
154 wxArrayRadioButtons m_buttons
;
156 // the event handler which is used to translate radiobutton events into
158 wxEvtHandler
*m_evtRadioHook
;
161 DECLARE_DYNAMIC_CLASS(wxRadioBox
)
164 #endif // _WX_UNIV_RADIOBOX_H_