Implemented text wrapping for GTK (1.2 and 2.X).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33420 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2005-04-07 22:52:32 +00:00
parent 1dd815f363
commit a5040b80be
4 changed files with 50 additions and 22 deletions

View 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)

View 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)

View 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)

View 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)