]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/radiobox.h
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "radiobox.h"
19 #include "wx/statbox.h"
21 class WXDLLEXPORT wxSubwindows
;
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
27 class WXDLLEXPORT wxRadioBox
: public wxStaticBox
, public wxRadioBoxBase
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_HORIZONTAL
,
40 const wxValidator
& val
= wxDefaultValidator
,
41 const wxString
& name
= wxRadioBoxNameStr
)
45 (void)Create(parent
, id
, title
, pos
, size
, n
, choices
, majorDim
,
49 wxRadioBox(wxWindow
*parent
,
51 const wxString
& title
,
54 const wxArrayString
& choices
,
56 long style
= wxRA_HORIZONTAL
,
57 const wxValidator
& val
= wxDefaultValidator
,
58 const wxString
& name
= wxRadioBoxNameStr
)
62 (void)Create(parent
, id
, title
, pos
, size
, choices
, majorDim
,
68 bool Create(wxWindow
*parent
,
70 const wxString
& title
,
71 const wxPoint
& pos
= wxDefaultPosition
,
72 const wxSize
& size
= wxDefaultSize
,
73 int n
= 0, const wxString choices
[] = NULL
,
75 long style
= wxRA_HORIZONTAL
,
76 const wxValidator
& val
= wxDefaultValidator
,
77 const wxString
& name
= wxRadioBoxNameStr
);
78 bool Create(wxWindow
*parent
,
80 const wxString
& title
,
83 const wxArrayString
& choices
,
85 long style
= wxRA_HORIZONTAL
,
86 const wxValidator
& val
= wxDefaultValidator
,
87 const wxString
& name
= wxRadioBoxNameStr
);
89 // implement the radiobox interface
90 virtual void SetSelection(int n
);
91 virtual int GetSelection() const { return m_selectedButton
; }
92 virtual int GetCount() const;
93 virtual wxString
GetString(int n
) const;
94 virtual void SetString(int n
, const wxString
& label
);
95 virtual bool Enable(int n
, bool enable
= true);
96 virtual bool Show(int n
, bool show
= true);
97 virtual int GetColumnCount() const { return GetNumHor(); }
98 virtual int GetRowCount() const { return GetNumVer(); }
100 // override some base class methods
101 virtual bool Show(bool show
= true);
102 virtual bool Enable(bool enable
= true);
103 virtual void SetFocus();
104 virtual bool SetFont(const wxFont
& font
);
105 virtual bool ContainsHWND(WXHWND hWnd
) const;
107 // we inherit a version returning false from wxStaticBox, override it again
108 virtual bool AcceptsFocus() const { return true; }
110 void SetLabelFont(const wxFont
& WXUNUSED(font
)) {}
111 void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
114 // implementation only from now on
115 // -------------------------------
117 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
118 void Command(wxCommandEvent
& event
);
120 void SendNotificationEvent();
122 // get the number of buttons per column/row
123 int GetNumVer() const;
124 int GetNumHor() const;
127 // common part of all ctors
130 // we can't compute our best size before the items are added to the control
131 virtual void SetInitialBestSize(const wxSize
& WXUNUSED(size
)) { }
133 // subclass one radio button
134 void SubclassRadioButton(WXHWND hWndBtn
);
136 // get the max size of radio buttons
137 wxSize
GetMaxButtonSize() const;
139 // get the total size occupied by the radio box buttons
140 wxSize
GetTotalButtonSize(const wxSize
& sizeBtn
) const;
142 virtual void DoSetSize(int x
, int y
,
143 int width
, int height
,
144 int sizeFlags
= wxSIZE_AUTO
);
145 virtual wxSize
DoGetBestSize() const;
148 // the buttons we contain
149 wxSubwindows
*m_radioButtons
;
151 // array of widths and heights of the buttons, may be wxDefaultCoord if the
152 // corresponding quantity should be computed
156 // the number of elements in major dimension (i.e. number of columns if
157 // wxRA_SPECIFY_COLS or the number of rows if wxRA_SPECIFY_ROWS)
160 // currently selected button or wxNOT_FOUND if none
161 int m_selectedButton
;
164 DECLARE_DYNAMIC_CLASS(wxRadioBox
)
165 DECLARE_NO_COPY_CLASS(wxRadioBox
)