]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/combobox.h
Patch to use high printer resolution instead of Cairo's 72dpi
[wxWidgets.git] / include / wx / cocoa / combobox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/combobox.h
3 // Purpose: wxComboBox class
4 // Author: Ryan Norton
5 // Modified by:
6 // Created: 2005/02/16
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __WX_COCOA_COMBOBOX_H__
13 #define __WX_COCOA_COMBOBOX_H__
14
15 //Begin NSComboBox.h
16
17 #include "wx/hashmap.h"
18 #include "wx/cocoa/ObjcAssociate.h"
19
20 DECLARE_WXCOCOA_OBJC_CLASS(NSComboBox);
21
22 WX_DECLARE_OBJC_HASHMAP(NSComboBox);
23 class wxCocoaNSComboBox
24 {
25 WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSComboBox)
26 public:
27 void AssociateNSComboBox(WX_NSComboBox cocoaNSComboBox);
28 void DisassociateNSComboBox(WX_NSComboBox cocoaNSComboBox);
29
30 virtual void doWxEvent(int nEvent) = 0;
31 virtual ~wxCocoaNSComboBox() { }
32 };
33
34 //begin combobox.h
35
36 #include "wx/dynarray.h"
37
38 // ========================================================================
39 // wxComboBox
40 // ========================================================================
41 class WXDLLEXPORT wxComboBox : public wxTextCtrl, public wxComboBoxBase, protected wxCocoaNSComboBox
42 {
43 DECLARE_DYNAMIC_CLASS(wxComboBox)
44 DECLARE_EVENT_TABLE()
45 WX_DECLARE_COCOA_OWNER(NSComboBox,NSTextField,NSView)
46 // ------------------------------------------------------------------------
47 // initialization
48 // ------------------------------------------------------------------------
49 public:
50 wxComboBox() { }
51 wxComboBox(wxWindow *parent, wxWindowID winid,
52 const wxString& value = wxEmptyString,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize,
55 int n = 0, const wxString choices[] = NULL,
56 long style = 0,
57 const wxValidator& validator = wxDefaultValidator,
58 const wxString& name = wxComboBoxNameStr)
59 {
60 Create(parent, winid, value, pos, size, n, choices, style, validator, name);
61 }
62 wxComboBox(wxWindow *parent, wxWindowID winid,
63 const wxString& value,
64 const wxPoint& pos,
65 const wxSize& size,
66 const wxArrayString& choices,
67 long style = 0,
68 const wxValidator& validator = wxDefaultValidator,
69 const wxString& name = wxComboBoxNameStr)
70 {
71 Create(parent, winid, value, pos, size, choices, style,
72 validator, name);
73 }
74
75 bool Create(wxWindow *parent, wxWindowID winid,
76 const wxString& value = wxEmptyString,
77 const wxPoint& pos = wxDefaultPosition,
78 const wxSize& size = wxDefaultSize,
79 int n = 0, const wxString choices[] = NULL,
80 long style = 0,
81 const wxValidator& validator = wxDefaultValidator,
82 const wxString& name = wxComboBoxNameStr);
83 bool Create(wxWindow *parent, wxWindowID winid,
84 const wxString& value,
85 const wxPoint& pos,
86 const wxSize& size,
87 const wxArrayString& choices,
88 long style = 0,
89 const wxValidator& validator = wxDefaultValidator,
90 const wxString& name = wxComboBoxNameStr);
91 virtual ~wxComboBox();
92
93 // ------------------------------------------------------------------------
94 // Cocoa callbacks
95 // ------------------------------------------------------------------------
96 protected:
97 wxArrayPtrVoid m_Datas;
98 virtual void doWxEvent(int nEvent);
99
100 // ------------------------------------------------------------------------
101 // Implementation
102 // ------------------------------------------------------------------------
103 public:
104 // FIXME: Quit deriving from wxTextCtrl
105 void Clear() // HACK
106 { wxComboBoxBase::Clear(); }
107
108 // wxCombobox methods
109 virtual void SetSelection(int pos);
110 // Overlapping methods
111 virtual wxString GetStringSelection();
112 // wxItemContainer
113 virtual void DoClear();
114 virtual void DoDeleteOneItem(unsigned int n);
115 virtual unsigned int GetCount() const;
116 virtual wxString GetString(unsigned int) const;
117 virtual void SetString(unsigned int pos, const wxString&);
118 virtual int FindString(const wxString& s, bool bCase = false) const;
119 virtual int GetSelection() const;
120 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
121 unsigned int pos,
122 void **clientData, wxClientDataType type);
123 virtual void DoSetItemClientData(unsigned int, void*);
124 virtual void* DoGetItemClientData(unsigned int) const;
125 virtual bool IsSorted() const { return HasFlag(wxCB_SORT); }
126 // wxComboBoxBase pure virtuals
127 virtual wxString GetValue() const
128 { return wxTextCtrl::GetValue(); }
129 virtual void SetValue(const wxString& value)
130 { return wxTextCtrl::SetValue(value); }
131 virtual void Cut() { wxTextCtrl::Cut(); }
132 virtual void Copy() { wxTextCtrl::Copy(); }
133 virtual void Paste() { wxTextCtrl::Paste(); }
134 virtual void SetInsertionPoint(long pos)
135 { wxTextCtrl::SetInsertionPoint(pos); }
136 virtual void SetInsertionPointEnd()
137 { wxTextCtrl::SetInsertionPointEnd(); }
138 virtual long GetInsertionPoint() const
139 { return wxTextCtrl::GetInsertionPoint(); }
140 virtual wxTextPos GetLastPosition() const
141 { return wxTextCtrl::GetLastPosition(); }
142 virtual void Replace(long from, long to, const wxString& value)
143 { wxTextCtrl::Replace(from,to,value); }
144 virtual void SetSelection(long from, long to)
145 { wxTextCtrl::SetSelection(from,to); }
146 virtual void SetEditable(bool editable)
147 { wxTextCtrl::SetEditable(editable); }
148 virtual bool IsEditable() const
149 { return !HasFlag(wxCB_READONLY); }
150 virtual void Undo()
151 { wxTextCtrl::Undo(); }
152 virtual void Redo()
153 { wxTextCtrl::Redo(); }
154 virtual void SelectAll()
155 { wxTextCtrl::SelectAll(); }
156 virtual bool CanCopy() const
157 { return wxTextCtrl::CanCopy(); }
158 virtual bool CanCut() const
159 { return wxTextCtrl::CanCut(); }
160 virtual bool CanPaste() const
161 { return wxTextCtrl::CanPaste(); }
162 virtual bool CanUndo() const
163 { return wxTextCtrl::CanUndo(); }
164 virtual bool CanRedo() const
165 { return wxTextCtrl::CanRedo(); }
166 };
167
168 #endif // __WX_COCOA_COMBOBOX_H__