1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/radiobox.h
3 // Purpose: wxRadioBox class
4 // Author: David Elliott
7 // Copyright: (c) 2003 David Elliott
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __WX_COCOA_RADIOBOX_H__
12 #define __WX_COCOA_RADIOBOX_H__
14 // #include "wx/cocoa/NSButton.h"
15 DECLARE_WXCOCOA_OBJC_CLASS(NSMatrix
);
17 // ========================================================================
19 // ========================================================================
20 class WXDLLIMPEXP_CORE wxRadioBox
: public wxControl
, public wxRadioBoxBase
// , protected wxCocoaNSButton
22 DECLARE_DYNAMIC_CLASS(wxRadioBox
)
24 // NOTE: We explicitly skip NSControl because our primary cocoa view is
25 // the NSBox but we want to receive action messages from the NSMatrix.
26 WX_DECLARE_COCOA_OWNER(NSBox
,NSView
,NSView
)
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
32 wxRadioBox(wxWindow
*parent
, wxWindowID winid
,
33 const wxString
& title
,
34 const wxPoint
& pos
= wxDefaultPosition
,
35 const wxSize
& size
= wxDefaultSize
,
36 int n
= 0, const wxString choices
[] = NULL
,
38 long style
= 0, const wxValidator
& validator
= wxDefaultValidator
,
39 const wxString
& name
= wxRadioBoxNameStr
)
41 Create(parent
, winid
, title
, pos
, size
, n
, choices
, majorDim
, style
, validator
, name
);
43 wxRadioBox(wxWindow
*parent
, wxWindowID winid
,
44 const wxString
& title
,
47 const wxArrayString
& choices
,
49 long style
= 0, const wxValidator
& validator
= wxDefaultValidator
,
50 const wxString
& name
= wxRadioBoxNameStr
)
52 Create(parent
, winid
, title
, pos
, size
, choices
, majorDim
, style
, validator
, name
);
55 bool Create(wxWindow
*parent
, wxWindowID winid
,
56 const wxString
& title
,
57 const wxPoint
& pos
= wxDefaultPosition
,
58 const wxSize
& size
= wxDefaultSize
,
59 int n
= 0, const wxString choices
[] = NULL
,
62 const wxValidator
& validator
= wxDefaultValidator
,
63 const wxString
& name
= wxRadioBoxNameStr
);
64 bool Create(wxWindow
*parent
, wxWindowID winid
,
65 const wxString
& title
,
68 const wxArrayString
& choices
,
71 const wxValidator
& validator
= wxDefaultValidator
,
72 const wxString
& name
= wxRadioBoxNameStr
);
73 virtual ~wxRadioBox();
76 virtual bool Enable(unsigned int n
, bool enable
= true);
77 virtual bool IsItemEnabled(unsigned int WXUNUSED(n
)) const
84 virtual bool Show(unsigned int n
, bool show
= true);
85 virtual bool IsItemShown(unsigned int WXUNUSED(n
)) const
91 // ------------------------------------------------------------------------
93 // ------------------------------------------------------------------------
95 // Radio boxes cannot be enabled/disabled
96 virtual void CocoaSetEnabled(bool WXUNUSED(enable
)) { }
97 virtual void CocoaTarget_action(void);
98 // ------------------------------------------------------------------------
100 // ------------------------------------------------------------------------
104 virtual void SetSelection(int n
);
105 virtual int GetSelection() const;
107 virtual unsigned int GetCount() const;
108 virtual wxString
GetString(unsigned int n
) const;
109 virtual void SetString(unsigned int n
, const wxString
& label
);
110 // change the individual radio button state
112 // We don't want the typical wxCocoaNSBox behaviour because our real
113 // implementation is by using an NSMatrix as the NSBox's contentView.
114 WX_NSMatrix
GetNSMatrix() const;
115 void AssociateNSBox(WX_NSBox theBox
);
116 void DisassociateNSBox(WX_NSBox theBox
);
118 virtual wxSize
DoGetBestSize() const;
120 int GetRowForIndex(int n
) const
122 if(m_windowStyle
& wxRA_SPECIFY_COLS
)
123 return n
/ GetMajorDim();
125 return n
% GetMajorDim();
128 int GetColumnForIndex(int n
) const
130 if(m_windowStyle
& wxRA_SPECIFY_COLS
)
131 return n
% GetMajorDim();
133 return n
/ GetMajorDim();
137 #endif // __WX_COCOA_RADIOBOX_H__