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