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: radiobox.h 54930 2008-08-02 19:45:23Z VZ $ 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 wxChar) 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 GetColumnCount()49 unsigned int GetColumnCount() const { return m_numCols; } GetRowCount()50 unsigned int GetRowCount() const { return m_numRows; } 51 52 // return the next active (i.e. shown and not disabled) item above/below/to 53 // the left/right of the given one 54 int GetNextItem(int item, wxDirection dir, long style) const; 55 56 #if wxUSE_TOOLTIPS 57 // set the tooltip text for a radio item, empty string unsets any tooltip 58 void SetItemToolTip(unsigned int item, const wxString& text); 59 60 // get the individual items tooltip; returns NULL if none GetItemToolTip(unsigned int item)61 wxToolTip *GetItemToolTip(unsigned int item) const 62 { return m_itemsTooltips ? (*m_itemsTooltips)[item] : NULL; } 63 #endif // wxUSE_TOOLTIPS 64 65 #if wxUSE_HELP 66 // set helptext for a particular item, pass an empty string to erase it 67 void SetItemHelpText(unsigned int n, const wxString& helpText); 68 69 // retrieve helptext for a particular item, empty string means no help text 70 wxString GetItemHelpText(unsigned int n) const; 71 #else // wxUSE_HELP 72 // just silently ignore the help text, it's better than requiring using 73 // conditional compilation in all code using this function SetItemHelpText(unsigned int WXUNUSED (n),const wxString & WXUNUSED (helpText))74 void SetItemHelpText(unsigned int WXUNUSED(n), 75 const wxString& WXUNUSED(helpText)) 76 { 77 } 78 #endif // wxUSE_HELP 79 80 // returns the radio item at the given position or wxNOT_FOUND if none 81 // (currently implemented only under MSW and GTK) GetItemFromPoint(const wxPoint & WXUNUSED (pt))82 virtual int GetItemFromPoint(const wxPoint& WXUNUSED(pt)) const 83 { 84 return wxNOT_FOUND; 85 } 86 87 88 // deprecated functions 89 // -------------------- 90 91 #if WXWIN_COMPATIBILITY_2_4 92 wxDEPRECATED( int GetNumberOfRowsOrCols() const ); 93 wxDEPRECATED( void SetNumberOfRowsOrCols(int n) ); 94 #endif // WXWIN_COMPATIBILITY_2_4 95 96 protected: wxRadioBoxBase()97 wxRadioBoxBase() 98 { 99 m_numCols = 100 m_numRows = 101 m_majorDim = 0; 102 103 #if wxUSE_TOOLTIPS 104 m_itemsTooltips = NULL; 105 #endif // wxUSE_TOOLTIPS 106 } 107 108 // return the number of items in major direction (which depends on whether 109 // we have wxRA_SPECIFY_COLS or wxRA_SPECIFY_ROWS style) GetMajorDim()110 unsigned int GetMajorDim() const { return m_majorDim; } 111 112 // sets m_majorDim and also updates m_numCols/Rows 113 // 114 // the style parameter should be the style of the radiobox itself 115 void SetMajorDim(unsigned int majorDim, long style); 116 117 #if wxUSE_TOOLTIPS 118 // called from SetItemToolTip() to really set the tooltip for the specified 119 // item in the box (or, if tooltip is NULL, to remove any existing one). 120 // 121 // NB: this function should really be pure virtual but to avoid breaking 122 // the build of the ports for which it's not implemented yet we provide 123 // an empty stub in the base class for now 124 virtual void DoSetItemToolTip(unsigned int item, wxToolTip *tooltip); 125 126 // returns true if we have any item tooltips HasItemToolTips()127 bool HasItemToolTips() const { return m_itemsTooltips != NULL; } 128 #endif // wxUSE_TOOLTIPS 129 130 #if wxUSE_HELP 131 // Retrieve help text for an item: this is a helper for the implementation 132 // of wxWindow::GetHelpTextAtPoint() in the real radiobox class 133 wxString DoGetHelpTextAtPoint(const wxWindow *derived, 134 const wxPoint& pt, 135 wxHelpEvent::Origin origin) const; 136 #endif // wxUSE_HELP 137 138 private: 139 // the number of elements in major dimension (i.e. number of columns if 140 // wxRA_SPECIFY_COLS or the number of rows if wxRA_SPECIFY_ROWS) and also 141 // the number of rows/columns calculated from it 142 unsigned int m_majorDim, 143 m_numCols, 144 m_numRows; 145 146 #if wxUSE_TOOLTIPS 147 // array of tooltips for the individual items 148 // 149 // this array is initially NULL and initialized on first use 150 wxToolTipArray *m_itemsTooltips; 151 #endif 152 153 #if wxUSE_HELP 154 // help text associated with a particular item or empty string if none 155 wxArrayString m_itemsHelpTexts; 156 #endif // wxUSE_HELP 157 }; 158 159 #if defined(__WXUNIVERSAL__) 160 #include "wx/univ/radiobox.h" 161 #elif defined(__WXMSW__) 162 #include "wx/msw/radiobox.h" 163 #elif defined(__WXMOTIF__) 164 #include "wx/motif/radiobox.h" 165 #elif defined(__WXGTK20__) 166 #include "wx/gtk/radiobox.h" 167 #elif defined(__WXGTK__) 168 #include "wx/gtk1/radiobox.h" 169 #elif defined(__WXMAC__) 170 #include "wx/mac/radiobox.h" 171 #elif defined(__WXCOCOA__) 172 #include "wx/cocoa/radiobox.h" 173 #elif defined(__WXPM__) 174 #include "wx/os2/radiobox.h" 175 #elif defined(__WXPALMOS__) 176 #include "wx/palmos/radiobox.h" 177 #endif 178 179 #endif // wxUSE_RADIOBOX 180 181 #endif // _WX_RADIOBOX_H_BASE_ 182