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