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