Consistent wxWindow::Enable with wxRadioBox::Enable for control and its items. wxRadi...
[wxWidgets.git] / include / wx / palmos / radiobox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/radiobox.h
3 // Purpose: wxRadioBox class
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by: Wlodzimierz ABX Skiba - native wxRadioBox implementation
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_RADIOBOX_H_
13 #define _WX_RADIOBOX_H_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "radiobox.h"
17 #endif
18
19 class WXDLLEXPORT wxBitmap;
20 class WXDLLEXPORT wxRadioButton;
21
22 // ----------------------------------------------------------------------------
23 // wxRadioBox
24 // ----------------------------------------------------------------------------
25
26 class WXDLLEXPORT wxRadioBox : public wxControl, public wxRadioBoxBase
27 {
28 public:
29 wxRadioBox():m_radios(wxKEY_INTEGER,32)
30 {
31 Init();
32 }
33
34 wxRadioBox(wxWindow *parent,
35 wxWindowID id,
36 const wxString& title,
37 const wxPoint& pos = wxDefaultPosition,
38 const wxSize& size = wxDefaultSize,
39 int n = 0, const wxString choices[] = NULL,
40 int majorDim = 0,
41 long style = wxRA_SPECIFY_COLS,
42 const wxValidator& val = wxDefaultValidator,
43 const wxString& name = wxRadioBoxNameStr)
44 :m_radios(wxKEY_INTEGER,n+1)
45 {
46 Init();
47 (void)Create(parent, id, title, pos, size, n, choices, majorDim,
48 style, val, name);
49 }
50
51 wxRadioBox(wxWindow *parent,
52 wxWindowID id,
53 const wxString& title,
54 const wxPoint& pos,
55 const wxSize& size,
56 const wxArrayString& choices,
57 int majorDim = 0,
58 long style = wxRA_SPECIFY_COLS,
59 const wxValidator& val = wxDefaultValidator,
60 const wxString& name = wxRadioBoxNameStr)
61 :m_radios(wxKEY_INTEGER,choices.GetCount()+1)
62 {
63 Init();
64 (void)Create(parent, id, title, pos, size, choices, majorDim,
65 style, val, name);
66 }
67
68 ~wxRadioBox();
69
70 bool Create(wxWindow *parent,
71 wxWindowID id,
72 const wxString& title,
73 const wxPoint& pos = wxDefaultPosition,
74 const wxSize& size = wxDefaultSize,
75 int n = 0, const wxString choices[] = NULL,
76 int majorDim = 0,
77 long style = wxRA_SPECIFY_COLS,
78 const wxValidator& val = wxDefaultValidator,
79 const wxString& name = wxRadioBoxNameStr);
80
81 bool Create(wxWindow *parent,
82 wxWindowID id,
83 const wxString& title,
84 const wxPoint& pos,
85 const wxSize& size,
86 const wxArrayString& choices,
87 int majorDim = 0,
88 long style = wxRA_SPECIFY_COLS,
89 const wxValidator& val = wxDefaultValidator,
90 const wxString& name = wxRadioBoxNameStr);
91
92 // implement the radiobox interface
93 virtual void SetSelection(int n);
94 virtual int GetSelection() const;
95 virtual int GetCount() const;
96 virtual wxString GetString(int n) const;
97 virtual void SetString(int n, const wxString& label);
98 virtual bool Enable(int n, bool enable = true);
99 virtual void Show(int n, bool show = true);
100 virtual int GetColumnCount() const;
101 virtual int GetRowCount() const;
102
103 virtual void DoGetPosition( int *x, int *y ) const;
104 virtual void DoGetSize( int *width, int *height ) const;
105 virtual void DoMoveWindow(int x, int y, int width, int height);
106
107 virtual wxPoint GetClientAreaOrigin() const;
108
109 virtual bool Show(bool show = true);
110 void SetFocus();
111 virtual bool Enable(bool enable = true);
112 void SetLabelFont(const wxFont& WXUNUSED(font)) {};
113 void SetButtonFont(const wxFont& font) { SetFont(font); }
114
115 void Command(wxCommandEvent& event);
116
117 int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; }
118 void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; }
119
120 // implementation only from now on
121 // -------------------------------
122
123 virtual bool SetFont(const wxFont& font);
124
125 void SendNotificationEvent();
126
127 // get the number of buttons per column/row
128 int GetNumVer() const;
129 int GetNumHor() const;
130
131 virtual void ApplyParentThemeBackground(const wxColour& bg)
132 { SetBackgroundColour(bg); }
133
134 protected:
135 // we can't compute our best size before the items are added to the control
136 virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) { }
137
138 // get the max size of radio buttons
139 wxSize GetMaxButtonSize() const;
140
141 // get the total size occupied by the radio box buttons
142 wxSize GetTotalButtonSize(const wxSize& sizeBtn) const;
143
144 int m_majorDim;
145 int * m_radioWidth; // for bitmaps
146 int * m_radioHeight;
147
148 int m_noItems;
149 int m_noRowsOrCols;
150 int m_selectedButton;
151
152 virtual wxSize DoGetBestSize() const;
153
154 private:
155
156 void Init();
157 wxRadioButton *GetRadioButton(int i);
158
159 wxPoint m_pos;
160 wxSize m_size;
161 wxHashTable m_radios;
162
163 DECLARE_DYNAMIC_CLASS(wxRadioBox)
164 DECLARE_NO_COPY_CLASS(wxRadioBox)
165 };
166
167 #endif
168 // _WX_RADIOBOX_H_