1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/textctrl.mm
4 // Author: Stefan Csomor
5 // Modified by: Ryan Norton (MLTE GetLineLength and GetLineText)
7 // RCS-ID: $Id: textctrl.cpp 54820 2008-07-29 20:04:11Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/textctrl.h"
23 #include "wx/button.h"
25 #include "wx/settings.h"
26 #include "wx/msgdlg.h"
27 #include "wx/toplevel.h"
31 #include <sys/types.h>
37 #if wxUSE_STD_IOSTREAM
45 #include "wx/filefn.h"
46 #include "wx/sysopt.h"
47 #include "wx/thread.h"
49 #include "wx/osx/private.h"
50 #include "wx/osx/cocoa/private/textimpl.h"
52 @implementation wxNSTextField
54 - (void)setImplementation: (wxWidgetImpl *) theImplementation
56 impl = theImplementation;
59 - (wxWidgetImpl*) implementation
69 // use our common calls
70 - (void) setTitle:(NSString *) title
72 [self setStringValue: title];
77 wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w)
81 wxNSTextFieldControl::~wxNSTextFieldControl()
85 wxString wxNSTextFieldControl::GetStringValue() const
87 wxCFStringRef cf( (CFStringRef) [[(wxNSTextField*) m_osxView stringValue] retain] );
88 return cf.AsString(m_wxPeer->GetFont().GetEncoding());
90 void wxNSTextFieldControl::SetStringValue( const wxString &str)
92 [(wxNSTextField*) m_osxView setStringValue: wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
94 void wxNSTextFieldControl::Copy()
98 void wxNSTextFieldControl::Cut()
102 void wxNSTextFieldControl::Paste()
106 bool wxNSTextFieldControl::CanPaste() const
111 void wxNSTextFieldControl::SetEditable(bool editable)
115 void wxNSTextFieldControl::GetSelection( long* from, long* to) const
119 void wxNSTextFieldControl::SetSelection( long from , long to )
123 void wxNSTextFieldControl::WriteText(const wxString& str)
125 // temp hack to get logging working early
126 wxString former = GetStringValue();
127 SetStringValue( former + str );
130 wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
139 NSView* sv = (wxpeer->GetParent()->GetHandle() );
141 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
142 wxNSTextField* v = [[wxNSTextField alloc] initWithFrame:r];
146 //[v setEditable:NO];
147 //[v setDrawsBackground:NO];
149 wxWidgetCocoaImpl* c = new wxNSTextFieldControl( wxpeer, v );
150 [v setImplementation:c];
155 #endif // wxUSE_TEXTCTRL