]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/radiobox.h
Added MSWPositionForWxMenu() method which is used to translate wxWindows
[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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "univradiobox.h"
17 #endif
18
19 class WXDLLEXPORT wxRadioButton;
20
21 #include "wx/statbox.h"
22 #include "wx/dynarray.h"
23
24 WX_DEFINE_EXPORTED_ARRAY_PTR(wxRadioButton *, wxArrayRadioButtons);
25
26 // ----------------------------------------------------------------------------
27 // wxRadioBox: a box full of radio buttons
28 // ----------------------------------------------------------------------------
29
30 class WXDLLEXPORT wxRadioBox : public wxStaticBox,
31 public wxRadioBoxBase
32 {
33 public:
34 // wxRadioBox construction
35 wxRadioBox();
36
37 wxRadioBox(wxWindow *parent,
38 wxWindowID id,
39 const wxString& title,
40 const wxPoint& pos = wxDefaultPosition,
41 const wxSize& size = wxDefaultSize,
42 int n = 0, const wxString *choices = NULL,
43 int majorDim = 0,
44 long style = wxRA_SPECIFY_COLS,
45 const wxValidator& val = wxDefaultValidator,
46 const wxString& name = wxRadioBoxNameStr);
47
48 bool Create(wxWindow *parent,
49 wxWindowID id,
50 const wxString& title,
51 const wxPoint& pos = wxDefaultPosition,
52 const wxSize& size = wxDefaultSize,
53 int n = 0, const wxString *choices = NULL,
54 int majorDim = 0,
55 long style = wxRA_SPECIFY_COLS,
56 const wxValidator& val = wxDefaultValidator,
57 const wxString& name = wxRadioBoxNameStr);
58
59 virtual ~wxRadioBox();
60
61 // implement wxRadioBox interface
62 virtual void SetSelection(int n);
63 virtual int GetSelection() const;
64
65 virtual int GetCount() const { return m_buttons.GetCount(); }
66 virtual int GetColumnCount() const { return m_numCols; }
67 virtual int GetRowCount() const { return m_numRows; }
68
69 virtual wxString GetString(int n) const;
70 virtual void SetString(int n, const wxString& label);
71
72 virtual void Enable(int n, bool enable = TRUE);
73 virtual void Show(int n, bool show = TRUE);
74
75 // we also override the wxControl methods to avoid virtual function hiding
76 virtual bool Enable(bool enable = TRUE);
77 virtual bool Show(bool show = TRUE);
78 virtual wxString GetLabel() const;
79 virtual void SetLabel(const wxString& label);
80
81 #if wxUSE_TOOLTIPS
82 virtual void DoSetToolTip( wxToolTip *tip );
83 #endif // wxUSE_TOOLTIPS
84
85 // wxUniversal-only methods
86
87 // another Append() version
88 void Append(int n, const wxString *choices);
89
90 // implementation only: called by wxRadioHookHandler
91 void OnRadioButton(wxEvent& event);
92 bool OnKeyDown(wxKeyEvent& event);
93
94 protected:
95 // override the base class methods dealing with window positioning/sizing
96 // as we must move/size the buttons as well
97 virtual void DoMoveWindow(int x, int y, int width, int height);
98 virtual wxSize DoGetBestClientSize() const;
99
100 // generate a radiobutton click event for the current item
101 void SendRadioEvent();
102
103 // common part of all ctors
104 void Init();
105
106 // check that the index is valid
107 bool IsValid(int n) const { return n >= 0 && n < GetCount(); }
108
109 // sets m_majorDim and calculate m_numCols and m_numRows
110 void SetMajorDim(int majorDim);
111
112 // calculate the max size of all buttons
113 wxSize GetMaxButtonSize() const;
114
115 // the currently selected radio button or -1
116 int m_selection;
117
118 // the parameters defining the button layout: majorDim meaning depends on
119 // the style and is the (max) number of columns if it includes
120 // wxRA_SPECIFY_COLS and is the (max) number of rows if it includes
121 // wxRA_SPECIFY_ROWS - the number of rows and columns is calculated from
122 // it
123 int m_majorDim,
124 m_numCols,
125 m_numRows;
126
127 // all radio buttons
128 wxArrayRadioButtons m_buttons;
129
130 // the event handler which is used to translate radiobutton events into
131 // radiobox one
132 wxEvtHandler *m_evtRadioHook;
133
134 private:
135 DECLARE_DYNAMIC_CLASS(wxRadioBox)
136 };
137
138 #endif // _WX_UNIV_RADIOBOX_H_