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 CocoaRemoveFromParent();
51 void wxTextCtrl::Cocoa_didChangeText(void)
55 void wxTextCtrl::AppendText(wxString const&)
59 void wxTextCtrl::SetEditable(bool)
63 void wxTextCtrl::DiscardEdits()
67 void wxTextCtrl::SetSelection(long, long)
71 void wxTextCtrl::ShowPosition(long)
75 void wxTextCtrl::SetInsertionPoint(long)
79 void wxTextCtrl::SetInsertionPointEnd()
83 void wxTextCtrl::Cut()
87 void wxTextCtrl::Copy()
91 void wxTextCtrl::Redo()
95 void wxTextCtrl::Undo()
99 void wxTextCtrl::Clear()
103 void wxTextCtrl::Paste()
107 void wxTextCtrl::Remove(long, long)
111 void wxTextCtrl::Replace(long, long, wxString const&)
115 void wxTextCtrl::SetValue(wxString const& value)
117 [GetNSTextField() setStringValue: wxNSStringWithWxString(value)];
120 void wxTextCtrl::WriteText(wxString const&)
124 bool wxTextCtrl::IsEditable() const
129 bool wxTextCtrl::IsModified() const
134 wxString wxTextCtrl::GetLineText(long) const
136 return wxEmptyString;
139 void wxTextCtrl::GetSelection(long*, long*) const
143 bool wxTextCtrl::PositionToXY(long, long*, long*) const
148 long wxTextCtrl::XYToPosition(long, long) const
153 int wxTextCtrl::GetLineLength(long) const
158 long wxTextCtrl::GetLastPosition() const
163 int wxTextCtrl::GetNumberOfLines() const
168 long wxTextCtrl::GetInsertionPoint() const
173 bool wxTextCtrl::CanRedo() const
178 bool wxTextCtrl::CanUndo() const
183 wxString wxTextCtrl::GetValue() const
185 return wxString([[GetNSTextField() stringValue] lossyCString]);