]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/radiobox.h
[ 1945434 ] Changing method wxComboCtrlBase::DrawButton to virtual one
[wxWidgets.git] / include / wx / univ / radiobox.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/radiobox.h
3 // Purpose: wxRadioBox declaration
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 11.09.00
7 // RCS-ID: $Id$
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_UNIV_RADIOBOX_H_
13 #define _WX_UNIV_RADIOBOX_H_
14
15 class WXDLLIMPEXP_FWD_CORE wxRadioButton;
16
17 #include "wx/statbox.h"
18 #include "wx/dynarray.h"
19
20 WX_DEFINE_EXPORTED_ARRAY_PTR(wxRadioButton *, wxArrayRadioButtons);
21
22 // ----------------------------------------------------------------------------
23 // wxRadioBox: a box full of radio buttons
24 // ----------------------------------------------------------------------------
25
26 class WXDLLIMPEXP_CORE wxRadioBox : public wxStaticBox,
27 public wxRadioBoxBase
28 {
29 public:
30 // wxRadioBox construction
31 wxRadioBox() { Init(); }
32
33 wxRadioBox(wxWindow *parent,
34 wxWindowID id,
35 const wxString& title,
36 const wxPoint& pos = wxDefaultPosition,
37 const wxSize& size = wxDefaultSize,
38 int n = 0, const wxString *choices = NULL,
39 int majorDim = 0,
40 long style = wxRA_SPECIFY_COLS,
41 const wxValidator& val = wxDefaultValidator,
42 const wxString& name = wxRadioBoxNameStr)
43 {
44 Init();
45
46 (void)Create(parent, id, title, pos, size, n, choices,
47 majorDim, style, val, name);
48 }
49 wxRadioBox(wxWindow *parent,
50 wxWindowID id,
51 const wxString& title,
52 const wxPoint& pos,
53 const wxSize& size,
54 const wxArrayString& choices,
55 int majorDim = 0,
56 long style = wxRA_SPECIFY_COLS,
57 const wxValidator& val = wxDefaultValidator,
58 const wxString& name = wxRadioBoxNameStr);
59
60 bool Create(wxWindow *parent,
61 wxWindowID id,
62 const wxString& title,
63 const wxPoint& pos = wxDefaultPosition,
64 const wxSize& size = wxDefaultSize,
65 int n = 0, const wxString *choices = NULL,
66 int majorDim = 0,
67 long style = wxRA_SPECIFY_COLS,
68 const wxValidator& val = wxDefaultValidator,
69 const wxString& name = wxRadioBoxNameStr);
70 bool Create(wxWindow *parent,
71 wxWindowID id,
72 const wxString& title,
73 const wxPoint& pos,
74 const wxSize& size,
75 const wxArrayString& choices,
76 int majorDim = 0,
77 long style = wxRA_SPECIFY_COLS,
78 const wxValidator& val = wxDefaultValidator,
79 const wxString& name = wxRadioBoxNameStr);
80
81 virtual ~wxRadioBox();
82
83 // implement wxRadioBox interface
84 virtual void SetSelection(int n);
85 virtual int GetSelection() const;
86
87 virtual unsigned int GetCount() const
88 { return (unsigned int)m_buttons.GetCount(); }
89
90 virtual wxString GetString(unsigned int n) const;
91 virtual void SetString(unsigned int n, const wxString& label);
92
93 virtual bool Enable(unsigned int n, bool enable = true);
94 virtual bool Show(unsigned int n, bool show = true);
95
96 virtual bool IsItemEnabled(unsigned int n) const;
97 virtual bool IsItemShown(unsigned int n) const;
98
99 // we also override the wxControl methods to avoid virtual function hiding
100 virtual bool Enable(bool enable = true);
101 virtual bool Show(bool show = true);
102 virtual wxString GetLabel() const;
103 virtual void SetLabel(const wxString& label);
104
105 // we inherit a version always returning false from wxStaticBox, override
106 // it to behave normally
107 virtual bool AcceptsFocus() const { return wxControl::AcceptsFocus(); }
108
109 #if wxUSE_TOOLTIPS
110 virtual void DoSetToolTip( wxToolTip *tip );
111 #endif // wxUSE_TOOLTIPS
112
113 // wxUniversal-only methods
114
115 // another Append() version
116 void Append(int n, const wxString *choices);
117
118 // implementation only: called by wxRadioHookHandler
119 void OnRadioButton(wxEvent& event);
120 bool OnKeyDown(wxKeyEvent& event);
121
122 protected:
123 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
124
125 // override the base class methods dealing with window positioning/sizing
126 // as we must move/size the buttons as well
127 virtual void DoMoveWindow(int x, int y, int width, int height);
128 virtual wxSize DoGetBestClientSize() const;
129
130 // generate a radiobutton click event for the current item
131 void SendRadioEvent();
132
133 // common part of all ctors
134 void Init();
135
136 // calculate the max size of all buttons
137 wxSize GetMaxButtonSize() const;
138
139 // the currently selected radio button or -1
140 int m_selection;
141
142 // all radio buttons
143 wxArrayRadioButtons m_buttons;
144
145 // the event handler which is used to translate radiobutton events into
146 // radiobox one
147 wxEvtHandler *m_evtRadioHook;
148
149 private:
150 DECLARE_DYNAMIC_CLASS(wxRadioBox)
151 };
152
153 #endif // _WX_UNIV_RADIOBOX_H_