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