]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/textctrl.mm
return the index of the inserted/appended item
[wxWidgets.git] / src / cocoa / textctrl.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/textctrl.mm
3 // Purpose: wxTextCtrl
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/03/16
7 // RCS-ID: $Id:
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/app.h"
13 #include "wx/textctrl.h"
14
15 #include "wx/cocoa/string.h"
16
17 #include "wx/cocoa/autorelease.h"
18
19 #import <Foundation/NSString.h>
20 #import <AppKit/NSTextField.h>
21
22 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
23 BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
24 END_EVENT_TABLE()
25 WX_IMPLEMENT_COCOA_OWNER(wxTextCtrl,NSTextField,NSControl,NSView)
26
27 bool wxTextCtrl::Create(wxWindow *parent, wxWindowID winid,
28 const wxString& value,
29 const wxPoint& pos,
30 const wxSize& size,
31 long style,
32 const wxValidator& validator,
33 const wxString& name)
34 {
35 wxAutoNSAutoreleasePool pool;
36 if(!CreateControl(parent,winid,pos,size,style,validator,name))
37 return false;
38 m_cocoaNSView = NULL;
39 SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]);
40 [m_cocoaNSView release];
41 [GetNSTextField() setStringValue:[NSString stringWithCString:value.c_str()]];
42 [GetNSControl() sizeToFit];
43 NSRect currentFrame = [m_cocoaNSView frame];
44 if(currentFrame.size.width < 70)
45 {
46 currentFrame.size.width = 70;
47 [m_cocoaNSView setFrame:currentFrame];
48 }
49 if(m_parent)
50 m_parent->CocoaAddChild(this);
51 SetInitialFrameRect(pos,size);
52 return true;
53 }
54
55 wxTextCtrl::~wxTextCtrl()
56 {
57 DisassociateNSTextField(m_cocoaNSView);
58 }
59
60 void wxTextCtrl::Cocoa_didChangeText(void)
61 {
62 }
63
64 void wxTextCtrl::AppendText(wxString const&)
65 {
66 }
67
68 void wxTextCtrl::SetEditable(bool)
69 {
70 }
71
72 void wxTextCtrl::DiscardEdits()
73 {
74 }
75
76 void wxTextCtrl::SetSelection(long, long)
77 {
78 }
79
80 void wxTextCtrl::ShowPosition(long)
81 {
82 }
83
84 void wxTextCtrl::SetInsertionPoint(long)
85 {
86 }
87
88 void wxTextCtrl::SetInsertionPointEnd()
89 {
90 }
91
92 void wxTextCtrl::Cut()
93 {
94 }
95
96 void wxTextCtrl::Copy()
97 {
98 }
99
100 void wxTextCtrl::Redo()
101 {
102 }
103
104 void wxTextCtrl::Undo()
105 {
106 }
107
108 void wxTextCtrl::Clear()
109 {
110 }
111
112 void wxTextCtrl::Paste()
113 {
114 }
115
116 void wxTextCtrl::Remove(long, long)
117 {
118 }
119
120 void wxTextCtrl::Replace(long, long, wxString const&)
121 {
122 }
123
124 void wxTextCtrl::SetValue(wxString const& value)
125 {
126 wxAutoNSAutoreleasePool pool;
127 [GetNSTextField() setStringValue: wxNSStringWithWxString(value)];
128 }
129
130 void wxTextCtrl::WriteText(wxString const&)
131 {
132 }
133
134 bool wxTextCtrl::IsEditable() const
135 {
136 return true;
137 }
138
139 bool wxTextCtrl::IsModified() const
140 {
141 return false;
142 }
143
144 wxString wxTextCtrl::GetLineText(long) const
145 {
146 return wxEmptyString;
147 }
148
149 void wxTextCtrl::GetSelection(long*, long*) const
150 {
151 }
152
153 bool wxTextCtrl::PositionToXY(long, long*, long*) const
154 {
155 return false;
156 }
157
158 long wxTextCtrl::XYToPosition(long, long) const
159 {
160 return 0;
161 }
162
163 int wxTextCtrl::GetLineLength(long) const
164 {
165 return 0;
166 }
167
168 long wxTextCtrl::GetLastPosition() const
169 {
170 return 0;
171 }
172
173 int wxTextCtrl::GetNumberOfLines() const
174 {
175 return 0;
176 }
177
178 long wxTextCtrl::GetInsertionPoint() const
179 {
180 return 0;
181 }
182
183 bool wxTextCtrl::CanRedo() const
184 {
185 return false;
186 }
187
188 bool wxTextCtrl::CanUndo() const
189 {
190 return false;
191 }
192
193 wxString wxTextCtrl::GetValue() const
194 {
195 wxAutoNSAutoreleasePool pool;
196 return wxString([[GetNSTextField() stringValue] lossyCString]);
197 }
198