]> git.saurik.com Git - wxWidgets.git/commitdiff
Implemented text wrapping for GTK (1.2 and 2.X).
authorRobert Roebling <robert@roebling.de>
Thu, 7 Apr 2005 22:52:32 +0000 (22:52 +0000)
committerRobert Roebling <robert@roebling.de>
Thu, 7 Apr 2005 22:52:32 +0000 (22:52 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33420 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/stattext.h
include/wx/gtk1/stattext.h
src/gtk/stattext.cpp
src/gtk1/stattext.cpp

index 6686c96982fd80da969685882386aaf5925a2a6f..fc7098928b56a522155e125b8310abcb707da21e 100644 (file)
@@ -67,6 +67,10 @@ public:
     // --------------
 
 protected:
+    virtual void DoSetSize(int x, int y,
+                           int width, int height,
+                           int sizeFlags = wxSIZE_AUTO);
+                           
     virtual wxSize DoGetBestSize() const;
 
     DECLARE_DYNAMIC_CLASS(wxStaticText)
index 6686c96982fd80da969685882386aaf5925a2a6f..fc7098928b56a522155e125b8310abcb707da21e 100644 (file)
@@ -67,6 +67,10 @@ public:
     // --------------
 
 protected:
+    virtual void DoSetSize(int x, int y,
+                           int width, int height,
+                           int sizeFlags = wxSIZE_AUTO);
+                           
     virtual wxSize DoGetBestSize() const;
 
     DECLARE_DYNAMIC_CLASS(wxStaticText)
index 9b5aa5cb2f2faa946d2bfd0c65b38ed36a07e6d6..da7039c8edec6fee3a1d34a99d51ef44d039d535 100644 (file)
@@ -85,8 +85,10 @@ bool wxStaticText::Create(wxWindow *parent,
     static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
     gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
 
-    // do not move this call elsewhere
-    gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
+    if (size.x == -1)
+        gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
+    else
+        gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE );
 
     m_parent->DoAddChild( this );
 
@@ -168,24 +170,32 @@ bool wxStaticText::SetFont( const wxFont &font )
     return ret;
 }
 
+void wxStaticText::DoSetSize(int x, int y,
+                           int width, int height,
+                           int sizeFlags )
+{
+    wxControl::DoSetSize( x, y, width, height, sizeFlags );
+}
+
 wxSize wxStaticText::DoGetBestSize() const
 {
     // Do not return any arbitrary default value...
     wxASSERT_MSG( m_widget, wxT("wxStaticText::DoGetBestSize called before creation") );
 
-    // this invalidates the size request
-    gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE );
-    gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
-
+    int width = m_width;
+#ifndef __WXGTK20__
+    gtk_label_set_pattern( GTK_LABEL(m_widget), NULL );
+    if (width < 3) width = -1;
+#endif
+    gtk_widget_set_usize( m_widget, width, -1 );
+    
     GtkRequisition req;
-    req.width = 2;
-    req.height = 2;
+    req.width = -1;
+    req.height = -1;
     (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
         (m_widget, &req );
 
-    wxSize best(req.width, req.height);
-    CacheBestSize(best);
-    return best;
+    return wxSize (req.width, req.height);
 }
 
 bool wxStaticText::SetForegroundColour(const wxColour& colour)
index 9b5aa5cb2f2faa946d2bfd0c65b38ed36a07e6d6..da7039c8edec6fee3a1d34a99d51ef44d039d535 100644 (file)
@@ -85,8 +85,10 @@ bool wxStaticText::Create(wxWindow *parent,
     static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
     gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
 
-    // do not move this call elsewhere
-    gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
+    if (size.x == -1)
+        gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
+    else
+        gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE );
 
     m_parent->DoAddChild( this );
 
@@ -168,24 +170,32 @@ bool wxStaticText::SetFont( const wxFont &font )
     return ret;
 }
 
+void wxStaticText::DoSetSize(int x, int y,
+                           int width, int height,
+                           int sizeFlags )
+{
+    wxControl::DoSetSize( x, y, width, height, sizeFlags );
+}
+
 wxSize wxStaticText::DoGetBestSize() const
 {
     // Do not return any arbitrary default value...
     wxASSERT_MSG( m_widget, wxT("wxStaticText::DoGetBestSize called before creation") );
 
-    // this invalidates the size request
-    gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE );
-    gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
-
+    int width = m_width;
+#ifndef __WXGTK20__
+    gtk_label_set_pattern( GTK_LABEL(m_widget), NULL );
+    if (width < 3) width = -1;
+#endif
+    gtk_widget_set_usize( m_widget, width, -1 );
+    
     GtkRequisition req;
-    req.width = 2;
-    req.height = 2;
+    req.width = -1;
+    req.height = -1;
     (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
         (m_widget, &req );
 
-    wxSize best(req.width, req.height);
-    CacheBestSize(best);
-    return best;
+    return wxSize (req.width, req.height);
 }
 
 bool wxStaticText::SetForegroundColour(const wxColour& colour)