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:
@@ -67,6 +67,10 @@ public:
|
|||||||
// --------------
|
// --------------
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void DoSetSize(int x, int y,
|
||||||
|
int width, int height,
|
||||||
|
int sizeFlags = wxSIZE_AUTO);
|
||||||
|
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxStaticText)
|
DECLARE_DYNAMIC_CLASS(wxStaticText)
|
||||||
|
@@ -67,6 +67,10 @@ public:
|
|||||||
// --------------
|
// --------------
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void DoSetSize(int x, int y,
|
||||||
|
int width, int height,
|
||||||
|
int sizeFlags = wxSIZE_AUTO);
|
||||||
|
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxStaticText)
|
DECLARE_DYNAMIC_CLASS(wxStaticText)
|
||||||
|
@@ -85,8 +85,10 @@ bool wxStaticText::Create(wxWindow *parent,
|
|||||||
static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
|
static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
|
||||||
gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
|
gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
|
||||||
|
|
||||||
// do not move this call elsewhere
|
if (size.x == -1)
|
||||||
gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
|
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 );
|
m_parent->DoAddChild( this );
|
||||||
|
|
||||||
@@ -168,24 +170,32 @@ bool wxStaticText::SetFont( const wxFont &font )
|
|||||||
return ret;
|
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
|
wxSize wxStaticText::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
// Do not return any arbitrary default value...
|
// Do not return any arbitrary default value...
|
||||||
wxASSERT_MSG( m_widget, wxT("wxStaticText::DoGetBestSize called before creation") );
|
wxASSERT_MSG( m_widget, wxT("wxStaticText::DoGetBestSize called before creation") );
|
||||||
|
|
||||||
// this invalidates the size request
|
int width = m_width;
|
||||||
gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE );
|
#ifndef __WXGTK20__
|
||||||
gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
|
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;
|
GtkRequisition req;
|
||||||
req.width = 2;
|
req.width = -1;
|
||||||
req.height = 2;
|
req.height = -1;
|
||||||
(* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
|
(* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
|
||||||
(m_widget, &req );
|
(m_widget, &req );
|
||||||
|
|
||||||
wxSize best(req.width, req.height);
|
return wxSize (req.width, req.height);
|
||||||
CacheBestSize(best);
|
|
||||||
return best;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxStaticText::SetForegroundColour(const wxColour& colour)
|
bool wxStaticText::SetForegroundColour(const wxColour& colour)
|
||||||
|
@@ -85,8 +85,10 @@ bool wxStaticText::Create(wxWindow *parent,
|
|||||||
static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
|
static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
|
||||||
gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
|
gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
|
||||||
|
|
||||||
// do not move this call elsewhere
|
if (size.x == -1)
|
||||||
gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
|
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 );
|
m_parent->DoAddChild( this );
|
||||||
|
|
||||||
@@ -168,24 +170,32 @@ bool wxStaticText::SetFont( const wxFont &font )
|
|||||||
return ret;
|
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
|
wxSize wxStaticText::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
// Do not return any arbitrary default value...
|
// Do not return any arbitrary default value...
|
||||||
wxASSERT_MSG( m_widget, wxT("wxStaticText::DoGetBestSize called before creation") );
|
wxASSERT_MSG( m_widget, wxT("wxStaticText::DoGetBestSize called before creation") );
|
||||||
|
|
||||||
// this invalidates the size request
|
int width = m_width;
|
||||||
gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE );
|
#ifndef __WXGTK20__
|
||||||
gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
|
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;
|
GtkRequisition req;
|
||||||
req.width = 2;
|
req.width = -1;
|
||||||
req.height = 2;
|
req.height = -1;
|
||||||
(* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
|
(* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
|
||||||
(m_widget, &req );
|
(m_widget, &req );
|
||||||
|
|
||||||
wxSize best(req.width, req.height);
|
return wxSize (req.width, req.height);
|
||||||
CacheBestSize(best);
|
|
||||||
return best;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxStaticText::SetForegroundColour(const wxColour& colour)
|
bool wxStaticText::SetForegroundColour(const wxColour& colour)
|
||||||
|
Reference in New Issue
Block a user