]>
Commit | Line | Data |
---|---|---|
da0634c1 DE |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/cocoa/radiobox.h | |
3 | // Purpose: wxRadioBox class | |
4 | // Author: David Elliott | |
5 | // Modified by: | |
6 | // Created: 2003/03/18 | |
da0634c1 | 7 | // Copyright: (c) 2003 David Elliott |
1a87edf2 | 8 | // Licence: wxWindows licence |
da0634c1 DE |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef __WX_COCOA_RADIOBOX_H__ | |
12 | #define __WX_COCOA_RADIOBOX_H__ | |
13 | ||
14 | // #include "wx/cocoa/NSButton.h" | |
9ed97552 | 15 | DECLARE_WXCOCOA_OBJC_CLASS(NSMatrix); |
da0634c1 DE |
16 | |
17 | // ======================================================================== | |
18 | // wxRadioBox | |
19 | // ======================================================================== | |
53a2db12 | 20 | class WXDLLIMPEXP_CORE wxRadioBox: public wxControl, public wxRadioBoxBase// , protected wxCocoaNSButton |
da0634c1 DE |
21 | { |
22 | DECLARE_DYNAMIC_CLASS(wxRadioBox) | |
23 | DECLARE_EVENT_TABLE() | |
259502c6 DE |
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. | |
9ed97552 | 26 | WX_DECLARE_COCOA_OWNER(NSBox,NSView,NSView) |
da0634c1 DE |
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 | } | |
584ad2a3 MB |
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 | } | |
da0634c1 DE |
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); | |
584ad2a3 MB |
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); | |
da0634c1 DE |
73 | virtual ~wxRadioBox(); |
74 | ||
7a952d4c WS |
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 | ||
da0634c1 DE |
91 | // ------------------------------------------------------------------------ |
92 | // Cocoa callbacks | |
93 | // ------------------------------------------------------------------------ | |
94 | protected: | |
2d80da5f VZ |
95 | // Radio boxes cannot be enabled/disabled |
96 | virtual void CocoaSetEnabled(bool WXUNUSED(enable)) { } | |
259502c6 | 97 | virtual void CocoaTarget_action(void); |
da0634c1 DE |
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 | |
aa61d352 VZ |
107 | virtual unsigned int GetCount() const; |
108 | virtual wxString GetString(unsigned int n) const; | |
109 | virtual void SetString(unsigned int n, const wxString& label); | |
da0634c1 | 110 | // change the individual radio button state |
9a165f54 | 111 | protected: |
4c51a665 | 112 | // We don't want the typical wxCocoaNSBox behaviour because our real |
259502c6 | 113 | // implementation is by using an NSMatrix as the NSBox's contentView. |
9ed97552 | 114 | WX_NSMatrix GetNSMatrix() const; |
259502c6 DE |
115 | void AssociateNSBox(WX_NSBox theBox); |
116 | void DisassociateNSBox(WX_NSBox theBox); | |
117 | ||
9a165f54 | 118 | virtual wxSize DoGetBestSize() const; |
4c1a4c41 DE |
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 | } | |
da0634c1 DE |
135 | }; |
136 | ||
137 | #endif // __WX_COCOA_RADIOBOX_H__ |