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