]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/cocoa/textctrl.mm
expose find window method
[wxWidgets.git] / src / cocoa / textctrl.mm
... / ...
CommitLineData
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
28IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
29BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
30END_EVENT_TABLE()
31WX_IMPLEMENT_COCOA_OWNER(wxTextCtrl,NSTextField,NSControl,NSView)
32
33bool 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
62wxTextCtrl::~wxTextCtrl()
63{
64 DisassociateNSTextField(GetNSTextField());
65}
66
67void wxTextCtrl::Cocoa_didChangeText(void)
68{
69}
70
71void wxTextCtrl::AppendText(wxString const&)
72{
73}
74
75void wxTextCtrl::SetEditable(bool)
76{
77}
78
79void wxTextCtrl::MarkDirty()
80{
81}
82
83void wxTextCtrl::DiscardEdits()
84{
85}
86
87void wxTextCtrl::SetSelection(long, long)
88{
89}
90
91void wxTextCtrl::ShowPosition(long)
92{
93}
94
95void wxTextCtrl::SetInsertionPoint(long)
96{
97}
98
99void wxTextCtrl::SetInsertionPointEnd()
100{
101}
102
103void wxTextCtrl::Cut()
104{
105}
106
107void wxTextCtrl::Copy()
108{
109}
110
111void wxTextCtrl::Redo()
112{
113}
114
115void wxTextCtrl::Undo()
116{
117}
118
119void wxTextCtrl::Clear()
120{
121}
122
123void wxTextCtrl::Paste()
124{
125}
126
127void wxTextCtrl::Remove(long, long)
128{
129}
130
131void wxTextCtrl::Replace(long, long, wxString const&)
132{
133}
134
135void wxTextCtrl::SetValue(wxString const& value)
136{
137 wxAutoNSAutoreleasePool pool;
138 [GetNSTextField() setStringValue: wxNSStringWithWxString(value)];
139}
140
141void wxTextCtrl::WriteText(wxString const&)
142{
143}
144
145bool wxTextCtrl::IsEditable() const
146{
147 return true;
148}
149
150bool wxTextCtrl::IsModified() const
151{
152 return false;
153}
154
155wxString wxTextCtrl::GetLineText(long) const
156{
157 return wxEmptyString;
158}
159
160void wxTextCtrl::GetSelection(long*, long*) const
161{
162}
163
164bool wxTextCtrl::PositionToXY(long, long*, long*) const
165{
166 return false;
167}
168
169long wxTextCtrl::XYToPosition(long, long) const
170{
171 return 0;
172}
173
174int wxTextCtrl::GetLineLength(long) const
175{
176 return 0;
177}
178
179long wxTextCtrl::GetLastPosition() const
180{
181 return 0;
182}
183
184int wxTextCtrl::GetNumberOfLines() const
185{
186 return 0;
187}
188
189long wxTextCtrl::GetInsertionPoint() const
190{
191 return 0;
192}
193
194bool wxTextCtrl::CanRedo() const
195{
196 return false;
197}
198
199bool wxTextCtrl::CanUndo() const
200{
201 return false;
202}
203
204wxString wxTextCtrl::GetValue() const
205{
206 wxAutoNSAutoreleasePool pool;
207 return wxStringWithNSString([GetNSTextField() stringValue]);
208}
209
210wxSize 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