]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/textctrl_osx.cpp
Override some methods in wxF(F)ileStream to resolve ambiguities.
[wxWidgets.git] / src / osx / textctrl_osx.cpp
index 1ff3094dbc4d7c49ecec37b518bc5d5c23097642..573fd4c6ae5973d05a15800230c4a1332fa8ebd4 100644 (file)
@@ -190,7 +190,8 @@ bool wxTextCtrl::SetFont( const wxFont& font )
 
 bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
 {
-    GetTextPeer()->SetStyle( start , end , style ) ;
+    if (GetTextPeer())
+        GetTextPeer()->SetStyle( start , end , style ) ;
 
     return true ;
 }
@@ -337,6 +338,13 @@ bool wxTextCtrl::AcceptsFocus() const
 
 wxSize wxTextCtrl::DoGetBestSize() const
 {
+    if (GetTextPeer())
+    {
+        wxSize size = GetTextPeer()->GetBestSize();
+        if (size.x > 0 && size.y > 0)
+            return size;
+    }
+    
     int wText, hText;
 
     // these are the numbers from the HIG:
@@ -373,6 +381,11 @@ wxSize wxTextCtrl::DoGetBestSize() const
     return wxSize(wText, hText);
 }
 
+bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
+{
+    return GetTextPeer()->GetStyle(position, style);
+}
+
 // ----------------------------------------------------------------------------
 // Undo/redo
 // ----------------------------------------------------------------------------
@@ -707,8 +720,7 @@ void wxTextCtrl::OnContextMenu(wxContextMenuEvent& event)
         m_privateContextMenu->Append(wxID_SELECTALL, _("Select &All"));
     }
 
-    if (m_privateContextMenu != NULL)
-        PopupMenu(m_privateContextMenu);
+    PopupMenu(m_privateContextMenu);
 #endif
 }
 
@@ -724,6 +736,12 @@ bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
 // implementation base class
 // ----------------------------------------------------------------------------
 
+bool wxTextWidgetImpl::GetStyle(long WXUNUSED(position),
+                                wxTextAttr& WXUNUSED(style))
+{
+    return false;
+}
+
 void wxTextWidgetImpl::SetStyle(long WXUNUSED(start),
                                 long WXUNUSED(end),
                                 const wxTextAttr& WXUNUSED(style))
@@ -809,13 +827,16 @@ void wxTextWidgetImpl::ShowPosition( long WXUNUSED(pos) )
 
 int wxTextWidgetImpl::GetNumberOfLines() const
 {
-    ItemCount lines = 0 ;
     wxString content = GetStringValue() ;
-    lines = 1;
+    ItemCount lines = 1;
 
     for (size_t i = 0; i < content.length() ; i++)
     {
+#if wxOSX_USE_COCOA
+        if (content[i] == '\n')
+#else
         if (content[i] == '\r')
+#endif
             lines++;
     }