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