]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/textctrl.mm
expose find window method
[wxWidgets.git] / src / cocoa / textctrl.mm
CommitLineData
fb896a32
DE
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
449c5673
DE
12#include "wx/wxprec.h"
13#ifndef WX_PRECOMP
14 #include "wx/app.h"
15 #include "wx/textctrl.h"
79e1f224 16 #include "wx/log.h"
449c5673 17#endif //WX_PRECOMP
fb896a32 18
7d27dcf9
DE
19#include "wx/cocoa/string.h"
20
7fc77f30
DE
21#include "wx/cocoa/autorelease.h"
22
fb896a32
DE
23#import <Foundation/NSString.h>
24#import <AppKit/NSTextField.h>
25
79e1f224
DE
26#include <math.h>
27
fb896a32
DE
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{
7fc77f30 41 wxAutoNSAutoreleasePool pool;
fb896a32
DE
42 if(!CreateControl(parent,winid,pos,size,style,validator,name))
43 return false;
44 m_cocoaNSView = NULL;
9ba1d264 45 SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]);
fb896a32 46 [m_cocoaNSView release];
b0c0a393
DE
47 [GetNSTextField() setStringValue:wxNSStringWithWxString(value)];
48
fb896a32 49 [GetNSControl() sizeToFit];
9ba1d264
DE
50 NSRect currentFrame = [m_cocoaNSView frame];
51 if(currentFrame.size.width < 70)
52 {
53 currentFrame.size.width = 70;
54 [m_cocoaNSView setFrame:currentFrame];
55 }
fb896a32
DE
56 if(m_parent)
57 m_parent->CocoaAddChild(this);
9ba1d264 58 SetInitialFrameRect(pos,size);
fb896a32
DE
59 return true;
60}
61
62wxTextCtrl::~wxTextCtrl()
63{
911e17c6 64 DisassociateNSTextField(GetNSTextField());
fb896a32
DE
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
3a9fa0d6
VZ
79void wxTextCtrl::MarkDirty()
80{
81}
82
fb896a32
DE
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
7d27dcf9 135void wxTextCtrl::SetValue(wxString const& value)
fb896a32 136{
7fc77f30 137 wxAutoNSAutoreleasePool pool;
7d27dcf9 138 [GetNSTextField() setStringValue: wxNSStringWithWxString(value)];
fb896a32
DE
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{
7fc77f30 206 wxAutoNSAutoreleasePool pool;
b0c0a393 207 return wxStringWithNSString([GetNSTextField() stringValue]);
fb896a32
DE
208}
209
79e1f224
DE
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