1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/textctrl.mm
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #include "wx/textctrl.h"
15 #include "wx/cocoa/string.h"
17 #import <Foundation/NSString.h>
18 #import <AppKit/NSTextField.h>
20 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
21 BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
23 WX_IMPLEMENT_COCOA_OWNER(wxTextCtrl,NSTextField,NSControl,NSView)
25 bool wxTextCtrl::Create(wxWindow *parent, wxWindowID winid,
26 const wxString& value,
30 const wxValidator& validator,
33 if(!CreateControl(parent,winid,pos,size,style,validator,name))
36 SetNSTextField([[NSTextField alloc] initWithFrame:NSMakeRect(0,0,30,30)]);
37 [m_cocoaNSView release];
38 [GetNSTextField() setStringValue:[NSString stringWithCString:value.c_str()]];
39 [GetNSControl() sizeToFit];
41 m_parent->CocoaAddChild(this);
45 wxTextCtrl::~wxTextCtrl()
47 DisassociateNSTextField(m_cocoaNSView);
50 void wxTextCtrl::Cocoa_didChangeText(void)
54 void wxTextCtrl::AppendText(wxString const&)
58 void wxTextCtrl::SetEditable(bool)
62 void wxTextCtrl::DiscardEdits()
66 void wxTextCtrl::SetSelection(long, long)
70 void wxTextCtrl::ShowPosition(long)
74 void wxTextCtrl::SetInsertionPoint(long)
78 void wxTextCtrl::SetInsertionPointEnd()
82 void wxTextCtrl::Cut()
86 void wxTextCtrl::Copy()
90 void wxTextCtrl::Redo()
94 void wxTextCtrl::Undo()
98 void wxTextCtrl::Clear()
102 void wxTextCtrl::Paste()
106 void wxTextCtrl::Remove(long, long)
110 void wxTextCtrl::Replace(long, long, wxString const&)
114 void wxTextCtrl::SetValue(wxString const& value)
116 [GetNSTextField() setStringValue: wxNSStringWithWxString(value)];
119 void wxTextCtrl::WriteText(wxString const&)
123 bool wxTextCtrl::IsEditable() const
128 bool wxTextCtrl::IsModified() const
133 wxString wxTextCtrl::GetLineText(long) const
135 return wxEmptyString;
138 void wxTextCtrl::GetSelection(long*, long*) const
142 bool wxTextCtrl::PositionToXY(long, long*, long*) const
147 long wxTextCtrl::XYToPosition(long, long) const
152 int wxTextCtrl::GetLineLength(long) const
157 long wxTextCtrl::GetLastPosition() const
162 int wxTextCtrl::GetNumberOfLines() const
167 long wxTextCtrl::GetInsertionPoint() const
172 bool wxTextCtrl::CanRedo() const
177 bool wxTextCtrl::CanUndo() const
182 wxString wxTextCtrl::GetValue() const
184 return wxString([[GetNSTextField() stringValue] lossyCString]);