1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/radiobox.h
3 // Purpose: wxRadioBox class
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __WX_COCOA_RADIOBOX_H__
13 #define __WX_COCOA_RADIOBOX_H__
15 // #include "wx/cocoa/NSButton.h"
16 DECLARE_WXCOCOA_OBJC_CLASS(NSMatrix
);
18 // ========================================================================
20 // ========================================================================
21 class WXDLLIMPEXP_CORE wxRadioBox
: public wxControl
, public wxRadioBoxBase
// , protected wxCocoaNSButton
23 DECLARE_DYNAMIC_CLASS(wxRadioBox
)
25 // NOTE: We explicitly skip NSControl because our primary cocoa view is
26 // the NSBox but we want to receive action messages from the NSMatrix.
27 WX_DECLARE_COCOA_OWNER(NSBox
,NSView
,NSView
)
28 // ------------------------------------------------------------------------
30 // ------------------------------------------------------------------------
33 wxRadioBox(wxWindow
*parent
, wxWindowID winid
,
34 const wxString
& title
,
35 const wxPoint
& pos
= wxDefaultPosition
,
36 const wxSize
& size
= wxDefaultSize
,
37 int n
= 0, const wxString choices
[] = NULL
,
39 long style
= 0, const wxValidator
& validator
= wxDefaultValidator
,
40 const wxString
& name
= wxRadioBoxNameStr
)
42 Create(parent
, winid
, title
, pos
, size
, n
, choices
, majorDim
, style
, validator
, name
);
44 wxRadioBox(wxWindow
*parent
, wxWindowID winid
,
45 const wxString
& title
,
48 const wxArrayString
& choices
,
50 long style
= 0, const wxValidator
& validator
= wxDefaultValidator
,
51 const wxString
& name
= wxRadioBoxNameStr
)
53 Create(parent
, winid
, title
, pos
, size
, choices
, majorDim
, style
, validator
, name
);
56 bool Create(wxWindow
*parent
, wxWindowID winid
,
57 const wxString
& title
,
58 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxSize
& size
= wxDefaultSize
,
60 int n
= 0, const wxString choices
[] = NULL
,
63 const wxValidator
& validator
= wxDefaultValidator
,
64 const wxString
& name
= wxRadioBoxNameStr
);
65 bool Create(wxWindow
*parent
, wxWindowID winid
,
66 const wxString
& title
,
69 const wxArrayString
& choices
,
72 const wxValidator
& validator
= wxDefaultValidator
,
73 const wxString
& name
= wxRadioBoxNameStr
);
74 virtual ~wxRadioBox();
77 virtual bool Enable(unsigned int n
, bool enable
= true);
78 virtual bool IsItemEnabled(unsigned int WXUNUSED(n
)) const
85 virtual bool Show(unsigned int n
, bool show
= true);
86 virtual bool IsItemShown(unsigned int WXUNUSED(n
)) const
92 // ------------------------------------------------------------------------
94 // ------------------------------------------------------------------------
96 // Radio boxes cannot be enabled/disabled
97 virtual void CocoaSetEnabled(bool WXUNUSED(enable
)) { }
98 virtual void CocoaTarget_action(void);
99 // ------------------------------------------------------------------------
101 // ------------------------------------------------------------------------
105 virtual void SetSelection(int n
);
106 virtual int GetSelection() const;
108 virtual unsigned int GetCount() const;
109 virtual wxString
GetString(unsigned int n
) const;
110 virtual void SetString(unsigned int n
, const wxString
& label
);
111 // change the individual radio button state
113 // We don't want the typical wxCocoaNSBox behaviour because our real
114 // implementation is by using an NSMatrix as the NSBox's contentView.
115 WX_NSMatrix
GetNSMatrix() const;
116 void AssociateNSBox(WX_NSBox theBox
);
117 void DisassociateNSBox(WX_NSBox theBox
);
119 virtual wxSize
DoGetBestSize() const;
121 int GetRowForIndex(int n
) const
123 if(m_windowStyle
& wxRA_SPECIFY_COLS
)
124 return n
/ GetMajorDim();
126 return n
% GetMajorDim();
129 int GetColumnForIndex(int n
) const
131 if(m_windowStyle
& wxRA_SPECIFY_COLS
)
132 return n
% GetMajorDim();
134 return n
/ GetMajorDim();
138 #endif // __WX_COCOA_RADIOBOX_H__