]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/radiobox.h
Add wxActivateEvent::GetActivationReason().
[wxWidgets.git] / include / wx / cocoa / radiobox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/radiobox.h
3 // Purpose: wxRadioBox class
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/03/18
7 // Copyright: (c) 2003 David Elliott
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef __WX_COCOA_RADIOBOX_H__
12 #define __WX_COCOA_RADIOBOX_H__
13
14 // #include "wx/cocoa/NSButton.h"
15 DECLARE_WXCOCOA_OBJC_CLASS(NSMatrix);
16
17 // ========================================================================
18 // wxRadioBox
19 // ========================================================================
20 class WXDLLIMPEXP_CORE wxRadioBox: public wxControl, public wxRadioBoxBase// , protected wxCocoaNSButton
21 {
22 DECLARE_DYNAMIC_CLASS(wxRadioBox)
23 DECLARE_EVENT_TABLE()
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 // ------------------------------------------------------------------------
28 // initialization
29 // ------------------------------------------------------------------------
30 public:
31 wxRadioBox() { }
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,
37 int majorDim = 0,
38 long style = 0, const wxValidator& validator = wxDefaultValidator,
39 const wxString& name = wxRadioBoxNameStr)
40 {
41 Create(parent, winid, title, pos, size, n, choices, majorDim, style, validator, name);
42 }
43 wxRadioBox(wxWindow *parent, wxWindowID winid,
44 const wxString& title,
45 const wxPoint& pos,
46 const wxSize& size,
47 const wxArrayString& choices,
48 int majorDim = 0,
49 long style = 0, const wxValidator& validator = wxDefaultValidator,
50 const wxString& name = wxRadioBoxNameStr)
51 {
52 Create(parent, winid, title, pos, size, choices, majorDim, style, validator, name);
53 }
54
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,
60 int majorDim = 0,
61 long style = 0,
62 const wxValidator& validator = wxDefaultValidator,
63 const wxString& name = wxRadioBoxNameStr);
64 bool Create(wxWindow *parent, wxWindowID winid,
65 const wxString& title,
66 const wxPoint& pos,
67 const wxSize& size,
68 const wxArrayString& choices,
69 int majorDim = 0,
70 long style = 0,
71 const wxValidator& validator = wxDefaultValidator,
72 const wxString& name = wxRadioBoxNameStr);
73 virtual ~wxRadioBox();
74
75 // Enabling
76 virtual bool Enable(unsigned int n, bool enable = true);
77 virtual bool IsItemEnabled(unsigned int WXUNUSED(n)) const
78 {
79 /* TODO */
80 return true;
81 }
82
83 // Showing
84 virtual bool Show(unsigned int n, bool show = true);
85 virtual bool IsItemShown(unsigned int WXUNUSED(n)) const
86 {
87 /* TODO */
88 return true;
89 }
90
91 // ------------------------------------------------------------------------
92 // Cocoa callbacks
93 // ------------------------------------------------------------------------
94 protected:
95 // Radio boxes cannot be enabled/disabled
96 virtual void CocoaSetEnabled(bool WXUNUSED(enable)) { }
97 virtual void CocoaTarget_action(void);
98 // ------------------------------------------------------------------------
99 // Implementation
100 // ------------------------------------------------------------------------
101 public:
102 // Pure virtuals
103 // selection
104 virtual void SetSelection(int n);
105 virtual int GetSelection() const;
106 // string access
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
111 protected:
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);
117
118 virtual wxSize DoGetBestSize() const;
119
120 int GetRowForIndex(int n) const
121 {
122 if(m_windowStyle & wxRA_SPECIFY_COLS)
123 return n / GetMajorDim();
124 else
125 return n % GetMajorDim();
126 }
127
128 int GetColumnForIndex(int n) const
129 {
130 if(m_windowStyle & wxRA_SPECIFY_COLS)
131 return n % GetMajorDim();
132 else
133 return n / GetMajorDim();
134 }
135 };
136
137 #endif // __WX_COCOA_RADIOBOX_H__