]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/radiobox.h
Fixed bug #1022383: 'several ComboBoxes appear selected'
[wxWidgets.git] / include / wx / msw / radiobox.h
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
1e6feb95 2// Name: wx/msw/radiobox.h
2bda0e17
KB
3// Purpose: wxRadioBox class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_RADIOBOX_H_
13#define _WX_RADIOBOX_H_
2bda0e17 14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c49245f8 16 #pragma interface "radiobox.h"
2bda0e17
KB
17#endif
18
bd0a76e2
VZ
19#include "wx/statbox.h"
20
21class WXDLLEXPORT wxSubwindows;
2bda0e17 22
1e6feb95
VZ
23// ----------------------------------------------------------------------------
24// wxRadioBox
25// ----------------------------------------------------------------------------
bfc6fde4 26
bd0a76e2 27class WXDLLEXPORT wxRadioBox : public wxStaticBox, public wxRadioBoxBase
1e6feb95 28{
2bda0e17 29public:
bd0a76e2 30 wxRadioBox() { Init(); }
2bda0e17 31
1e6feb95
VZ
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_HORIZONTAL,
40 const wxValidator& val = wxDefaultValidator,
6463b9f5
JS
41 const wxString& name = wxRadioBoxNameStr)
42 {
bd0a76e2
VZ
43 Init();
44
6463b9f5
JS
45 (void)Create(parent, id, title, pos, size, n, choices, majorDim,
46 style, val, name);
47 }
bd0a76e2 48
584ad2a3
MB
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_HORIZONTAL,
57 const wxValidator& val = wxDefaultValidator,
58 const wxString& name = wxRadioBoxNameStr)
59 {
bd0a76e2
VZ
60 Init();
61
584ad2a3
MB
62 (void)Create(parent, id, title, pos, size, choices, majorDim,
63 style, val, name);
64 }
bfc6fde4 65
bfc6fde4
VZ
66 ~wxRadioBox();
67
1e6feb95
VZ
68 bool Create(wxWindow *parent,
69 wxWindowID id,
70 const wxString& title,
71 const wxPoint& pos = wxDefaultPosition,
72 const wxSize& size = wxDefaultSize,
73 int n = 0, const wxString choices[] = NULL,
74 int majorDim = 0,
75 long style = wxRA_HORIZONTAL,
76 const wxValidator& val = wxDefaultValidator,
77 const wxString& name = wxRadioBoxNameStr);
584ad2a3
MB
78 bool Create(wxWindow *parent,
79 wxWindowID id,
80 const wxString& title,
81 const wxPoint& pos,
82 const wxSize& size,
83 const wxArrayString& choices,
84 int majorDim = 0,
85 long style = wxRA_HORIZONTAL,
86 const wxValidator& val = wxDefaultValidator,
87 const wxString& name = wxRadioBoxNameStr);
1e6feb95
VZ
88
89 // implement the radiobox interface
90 virtual void SetSelection(int n);
bd0a76e2 91 virtual int GetSelection() const { return m_selectedButton; }
1e6feb95
VZ
92 virtual int GetCount() const;
93 virtual wxString GetString(int n) const;
94 virtual void SetString(int n, const wxString& label);
1a87edf2 95 virtual bool Enable(int n, bool enable = true);
789f6795 96 virtual bool Show(int n, bool show = true);
bd0a76e2
VZ
97 virtual int GetColumnCount() const { return GetNumHor(); }
98 virtual int GetRowCount() const { return GetNumVer(); }
bfc6fde4 99
bd0a76e2 100 // override some base class methods
4d08943e 101 virtual bool Show(bool show = true);
4d08943e 102 virtual bool Enable(bool enable = true);
bd0a76e2
VZ
103 virtual void SetFocus();
104 virtual bool SetFont(const wxFont& font);
105 virtual bool ContainsHWND(WXHWND hWnd) const;
106
47e388ca
VZ
107 // we inherit a version returning false from wxStaticBox, override it again
108 virtual bool AcceptsFocus() const { return true; }
109
6fb99eb3 110 void SetLabelFont(const wxFont& WXUNUSED(font)) {}
bfc6fde4
VZ
111 void SetButtonFont(const wxFont& font) { SetFont(font); }
112
bfc6fde4 113
c49245f8
VZ
114 // implementation only from now on
115 // -------------------------------
116
1e6feb95 117 virtual bool MSWCommand(WXUINT param, WXWORD id);
bd0a76e2 118 void Command(wxCommandEvent& event);
1e6feb95 119
9a5ccab4 120 void SendNotificationEvent();
bfc6fde4 121
e373f51b 122 // get the number of buttons per column/row
c49245f8
VZ
123 int GetNumVer() const;
124 int GetNumHor() const;
125
2bda0e17 126protected:
bd0a76e2
VZ
127 // common part of all ctors
128 void Init();
129
7a5a5718
RD
130 // we can't compute our best size before the items are added to the control
131 virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) { }
132
3ca6a5f0 133 // subclass one radio button
e373f51b
VZ
134 void SubclassRadioButton(WXHWND hWndBtn);
135
3ca6a5f0
BP
136 // get the max size of radio buttons
137 wxSize GetMaxButtonSize() const;
138
139 // get the total size occupied by the radio box buttons
140 wxSize GetTotalButtonSize(const wxSize& sizeBtn) const;
141
bfc6fde4
VZ
142 virtual void DoSetSize(int x, int y,
143 int width, int height,
144 int sizeFlags = wxSIZE_AUTO);
3ca6a5f0 145 virtual wxSize DoGetBestSize() const;
1e6feb95 146
bd0a76e2
VZ
147
148 // the buttons we contain
149 wxSubwindows *m_radioButtons;
150
151 // array of widths and heights of the buttons, may be wxDefaultCoord if the
152 // corresponding quantity should be computed
153 int *m_radioWidth;
154 int *m_radioHeight;
155
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)
158 int m_majorDim;
159
160 // currently selected button or wxNOT_FOUND if none
161 int m_selectedButton;
162
1e6feb95
VZ
163private:
164 DECLARE_DYNAMIC_CLASS(wxRadioBox)
22f3361e 165 DECLARE_NO_COPY_CLASS(wxRadioBox)
2bda0e17
KB
166};
167
168#endif
bbcdf8bc 169 // _WX_RADIOBOX_H_