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