]> git.saurik.com Git - wxWidgets.git/blob - include/wx/radiobox.h
cleanup
[wxWidgets.git] / include / wx / radiobox.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/radiobox.h
3 // Purpose: wxRadioBox declaration
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 10.09.00
7 // RCS-ID: $Id$
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_RADIOBOX_H_BASE_
13 #define _WX_RADIOBOX_H_BASE_
14
15 #if wxUSE_RADIOBOX
16
17 #include "wx/ctrlsub.h"
18
19 #if wxUSE_TOOLTIPS
20
21 #include "wx/dynarray.h"
22
23 class WXDLLIMPEXP_FWD_CORE wxToolTip;
24
25 WX_DEFINE_EXPORTED_ARRAY_PTR(wxToolTip *, wxToolTipArray);
26
27 #endif // wxUSE_TOOLTIPS
28
29 extern WXDLLEXPORT_DATA(const char) wxRadioBoxNameStr[];
30
31 // ----------------------------------------------------------------------------
32 // wxRadioBoxBase is not a normal base class, but rather a mix-in because the
33 // real wxRadioBox derives from different classes on different platforms: for
34 // example, it is a wxStaticBox in wxUniv and wxMSW but not in other ports
35 // ----------------------------------------------------------------------------
36
37 class WXDLLEXPORT wxRadioBoxBase : public wxItemContainerImmutable
38 {
39 public:
40 virtual ~wxRadioBoxBase();
41
42 // change/query the individual radio button state
43 virtual bool Enable(unsigned int n, bool enable = true) = 0;
44 virtual bool Show(unsigned int n, bool show = true) = 0;
45 virtual bool IsItemEnabled(unsigned int n) const = 0;
46 virtual bool IsItemShown(unsigned int n) const = 0;
47
48 // return number of columns/rows in this radiobox
49 unsigned int GetColumnCount() const { return m_numCols; }
50 unsigned int GetRowCount() const { return m_numRows; }
51
52 // return the item above/below/to the left/right of the given one
53 int GetNextItem(int item, wxDirection dir, long style) const;
54
55 #if wxUSE_TOOLTIPS
56 // set the tooltip text for a radio item, empty string unsets any tooltip
57 void SetItemToolTip(unsigned int item, const wxString& text);
58
59 // get the individual items tooltip; returns NULL if none
60 wxToolTip *GetItemToolTip(unsigned int item) const
61 { return m_itemsTooltips ? (*m_itemsTooltips)[item] : NULL; }
62 #endif // wxUSE_TOOLTIPS
63
64 #if wxUSE_HELP
65 // set helptext for a particular item, pass an empty string to erase it
66 void SetItemHelpText(unsigned int n, const wxString& helpText);
67
68 // retrieve helptext for a particular item, empty string means no help text
69 wxString GetItemHelpText(unsigned int n) const;
70 #else // wxUSE_HELP
71 // just silently ignore the help text, it's better than requiring using
72 // conditional compilation in all code using this function
73 void SetItemHelpText(unsigned int WXUNUSED(n),
74 const wxString& WXUNUSED(helpText))
75 {
76 }
77 #endif // wxUSE_HELP
78
79 // returns the radio item at the given position or wxNOT_FOUND if none
80 // (currently implemented only under MSW and GTK)
81 virtual int GetItemFromPoint(const wxPoint& WXUNUSED(pt)) const
82 {
83 return wxNOT_FOUND;
84 }
85
86
87 protected:
88 wxRadioBoxBase()
89 {
90 m_numCols =
91 m_numRows =
92 m_majorDim = 0;
93
94 #if wxUSE_TOOLTIPS
95 m_itemsTooltips = NULL;
96 #endif // wxUSE_TOOLTIPS
97 }
98
99 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
100
101 // return the number of items in major direction (which depends on whether
102 // we have wxRA_SPECIFY_COLS or wxRA_SPECIFY_ROWS style)
103 unsigned int GetMajorDim() const { return m_majorDim; }
104
105 // sets m_majorDim and also updates m_numCols/Rows
106 //
107 // the style parameter should be the style of the radiobox itself
108 void SetMajorDim(unsigned int majorDim, long style);
109
110 #if wxUSE_TOOLTIPS
111 // called from SetItemToolTip() to really set the tooltip for the specified
112 // item in the box (or, if tooltip is NULL, to remove any existing one).
113 //
114 // NB: this function should really be pure virtual but to avoid breaking
115 // the build of the ports for which it's not implemented yet we provide
116 // an empty stub in the base class for now
117 virtual void DoSetItemToolTip(unsigned int item, wxToolTip *tooltip);
118
119 // returns true if we have any item tooltips
120 bool HasItemToolTips() const { return m_itemsTooltips != NULL; }
121 #endif // wxUSE_TOOLTIPS
122
123 #if wxUSE_HELP
124 // Retrieve help text for an item: this is a helper for the implementation
125 // of wxWindow::GetHelpTextAtPoint() in the real radiobox class
126 wxString DoGetHelpTextAtPoint(const wxWindow *derived,
127 const wxPoint& pt,
128 wxHelpEvent::Origin origin) const;
129 #endif // wxUSE_HELP
130
131 private:
132 // the number of elements in major dimension (i.e. number of columns if
133 // wxRA_SPECIFY_COLS or the number of rows if wxRA_SPECIFY_ROWS) and also
134 // the number of rows/columns calculated from it
135 unsigned int m_majorDim,
136 m_numCols,
137 m_numRows;
138
139 #if wxUSE_TOOLTIPS
140 // array of tooltips for the individual items
141 //
142 // this array is initially NULL and initialized on first use
143 wxToolTipArray *m_itemsTooltips;
144 #endif
145
146 #if wxUSE_HELP
147 // help text associated with a particular item or empty string if none
148 wxArrayString m_itemsHelpTexts;
149 #endif // wxUSE_HELP
150 };
151
152 #if defined(__WXUNIVERSAL__)
153 #include "wx/univ/radiobox.h"
154 #elif defined(__WXMSW__)
155 #include "wx/msw/radiobox.h"
156 #elif defined(__WXMOTIF__)
157 #include "wx/motif/radiobox.h"
158 #elif defined(__WXGTK20__)
159 #include "wx/gtk/radiobox.h"
160 #elif defined(__WXGTK__)
161 #include "wx/gtk1/radiobox.h"
162 #elif defined(__WXMAC__)
163 #include "wx/mac/radiobox.h"
164 #elif defined(__WXCOCOA__)
165 #include "wx/cocoa/radiobox.h"
166 #elif defined(__WXPM__)
167 #include "wx/os2/radiobox.h"
168 #elif defined(__WXPALMOS__)
169 #include "wx/palmos/radiobox.h"
170 #endif
171
172 #endif // wxUSE_RADIOBOX
173
174 #endif // _WX_RADIOBOX_H_BASE_