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