]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/cocoa/textctrl.mm
moved AppendAppName() from MSW to common code; modified it to not double the trailing...
[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: wxWidgets licence
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#import <AppKit/NSCell.h>
26
27#include <math.h>
28
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{
42 wxAutoNSAutoreleasePool pool;
43 if(!CreateControl(parent,winid,pos,size,style,validator,name))
44 return false;
45 m_cocoaNSView = NULL;
46 SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]);
47 [m_cocoaNSView release];
48 [GetNSTextField() setStringValue:wxNSStringWithWxString(value)];
49
50 [GetNSControl() sizeToFit];
51 NSRect currentFrame = [m_cocoaNSView frame];
52 if(currentFrame.size.width < 70)
53 {
54 currentFrame.size.width = 70;
55 [m_cocoaNSView setFrame:currentFrame];
56 }
57 if(m_parent)
58 m_parent->CocoaAddChild(this);
59 SetInitialFrameRect(pos,size);
60 return true;
61}
62
63wxTextCtrl::~wxTextCtrl()
64{
65 DisassociateNSTextField(GetNSTextField());
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
80void wxTextCtrl::MarkDirty()
81{
82}
83
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
136void wxTextCtrl::SetValue(wxString const& value)
137{
138 wxAutoNSAutoreleasePool pool;
139 [GetNSTextField() setStringValue: wxNSStringWithWxString(value)];
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
180long wxTextCtrl::GetLastPosition() const
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{
207 wxAutoNSAutoreleasePool pool;
208 return wxStringWithNSString([GetNSTextField() stringValue]);
209}
210
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