]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/radiobox.h
Fix menu event handlers calling order.
[wxWidgets.git] / include / wx / cocoa / radiobox.h
CommitLineData
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
8228b893 7// RCS-ID: $Id$
da0634c1 8// Copyright: (c) 2003 David Elliott
1a87edf2 9// Licence: wxWindows licence
da0634c1
DE
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __WX_COCOA_RADIOBOX_H__
13#define __WX_COCOA_RADIOBOX_H__
14
15// #include "wx/cocoa/NSButton.h"
9ed97552 16DECLARE_WXCOCOA_OBJC_CLASS(NSMatrix);
da0634c1
DE
17
18// ========================================================================
19// wxRadioBox
20// ========================================================================
53a2db12 21class WXDLLIMPEXP_CORE wxRadioBox: public wxControl, public wxRadioBoxBase// , protected wxCocoaNSButton
da0634c1
DE
22{
23 DECLARE_DYNAMIC_CLASS(wxRadioBox)
24 DECLARE_EVENT_TABLE()
259502c6
DE
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.
9ed97552 27 WX_DECLARE_COCOA_OWNER(NSBox,NSView,NSView)
da0634c1
DE
28// ------------------------------------------------------------------------
29// initialization
30// ------------------------------------------------------------------------
31public:
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 }
584ad2a3
MB
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 }
da0634c1
DE
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);
584ad2a3
MB
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);
da0634c1
DE
74 virtual ~wxRadioBox();
75
7a952d4c
WS
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
da0634c1
DE
92// ------------------------------------------------------------------------
93// Cocoa callbacks
94// ------------------------------------------------------------------------
95protected:
2d80da5f
VZ
96 // Radio boxes cannot be enabled/disabled
97 virtual void CocoaSetEnabled(bool WXUNUSED(enable)) { }
259502c6 98 virtual void CocoaTarget_action(void);
da0634c1
DE
99// ------------------------------------------------------------------------
100// Implementation
101// ------------------------------------------------------------------------
102public:
103// Pure virtuals
104 // selection
105 virtual void SetSelection(int n);
106 virtual int GetSelection() const;
107 // string access
aa61d352
VZ
108 virtual unsigned int GetCount() const;
109 virtual wxString GetString(unsigned int n) const;
110 virtual void SetString(unsigned int n, const wxString& label);
da0634c1 111 // change the individual radio button state
9a165f54 112protected:
4c51a665 113 // We don't want the typical wxCocoaNSBox behaviour because our real
259502c6 114 // implementation is by using an NSMatrix as the NSBox's contentView.
9ed97552 115 WX_NSMatrix GetNSMatrix() const;
259502c6
DE
116 void AssociateNSBox(WX_NSBox theBox);
117 void DisassociateNSBox(WX_NSBox theBox);
118
9a165f54 119 virtual wxSize DoGetBestSize() const;
4c1a4c41
DE
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 }
da0634c1
DE
136};
137
138#endif // __WX_COCOA_RADIOBOX_H__