+void wxNSTextViewControl::SetStyle(long start,
+ long end,
+ const wxTextAttr& style)
+{
+ if ( !m_textView )
+ return;
+
+ if ( start == -1 && end == -1 )
+ {
+ NSMutableDictionary* const
+ attrs = [NSMutableDictionary dictionaryWithCapacity:3];
+ if ( style.HasFont() )
+ [attrs setValue:style.GetFont().OSXGetNSFont() forKey:NSFontAttributeName];
+ if ( style.HasBackgroundColour() )
+ [attrs setValue:style.GetBackgroundColour().OSXGetNSColor() forKey:NSBackgroundColorAttributeName];
+ if ( style.HasTextColour() )
+ [attrs setValue:style.GetTextColour().OSXGetNSColor() forKey:NSForegroundColorAttributeName];
+
+ [m_textView setTypingAttributes:attrs];
+ }
+ else // Set the attributes just for this range.
+ {
+ NSRange range = NSMakeRange(start, end-start);
+
+ NSTextStorage* storage = [m_textView textStorage];
+ if ( style.HasFont() )
+ [storage addAttribute:NSFontAttributeName value:style.GetFont().OSXGetNSFont() range:range];
+
+ if ( style.HasBackgroundColour() )
+ [storage addAttribute:NSBackgroundColorAttributeName value:style.GetBackgroundColour().OSXGetNSColor() range:range];
+
+ if ( style.HasTextColour() )
+ [storage addAttribute:NSForegroundColorAttributeName value:style.GetTextColour().OSXGetNSColor() range:range];
+ }
+}
+
+void wxNSTextViewControl::CheckSpelling(bool check)
+{
+ if (m_textView)
+ [m_textView setContinuousSpellCheckingEnabled: check];
+}
+
+wxSize wxNSTextViewControl::GetBestSize() const
+{
+ if (m_textView && [m_textView layoutManager])
+ {
+ NSRect rect = [[m_textView layoutManager] usedRectForTextContainer: [m_textView textContainer]];
+ return wxSize((int)(rect.size.width + [m_textView textContainerInset].width),
+ (int)(rect.size.height + [m_textView textContainerInset].height));
+ }
+ return wxSize(0,0);
+}
+
+// wxNSTextFieldControl
+
+wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *text, WXWidget w )
+ : wxWidgetCocoaImpl(text, w),
+ wxTextWidgetImpl(text)
+{
+ Init(w);
+}
+
+wxNSTextFieldControl::wxNSTextFieldControl(wxWindow *wxPeer,
+ wxTextEntry *entry,
+ WXWidget w)
+ : wxWidgetCocoaImpl(wxPeer, w),
+ wxTextWidgetImpl(entry)
+{
+ Init(w);
+}
+
+void wxNSTextFieldControl::Init(WXWidget w)
+{
+ NSTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>) *tf = (NSTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>)*) w;
+ m_textField = tf;
+ [m_textField setDelegate: tf];
+ m_selStart = m_selEnd = 0;
+ m_hasEditor = [w isKindOfClass:[NSTextField class]];
+}
+
+wxNSTextFieldControl::~wxNSTextFieldControl()
+{
+ if (m_textField)
+ [m_textField setDelegate: nil];
+}
+
+wxString wxNSTextFieldControl::GetStringValue() const
+{
+ return wxCFStringRef::AsString([m_textField stringValue], m_wxPeer->GetFont().GetEncoding());
+}
+
+void wxNSTextFieldControl::SetStringValue( const wxString &str)