Make wxStaticText alignment work with wxGTK2.

Alignment was silently ignored in wxStaticText with GTK+ 2 since 2.12 or so,
make it work even at the price of using a non-default ellipsize mode as this
seems to be the only way to have it at all.

Closes #12539.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78478 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2015-02-11 21:16:11 +00:00
parent 67f2950cb1
commit 4ae21c7f1a

View File

@@ -55,11 +55,35 @@ bool wxStaticText::Create(wxWindow *parent,
GtkJustification justify;
if ( style & wxALIGN_CENTER_HORIZONTAL )
justify = GTK_JUSTIFY_CENTER;
{
#ifndef __WXGTK3__
// This looks like a bug in GTK+ and seems to be fixed in GTK+3, but
// using non-default justification with default ellipsize mode doesn't
// work: the justification is just ignored. In practice, alignment is
// more important, so turn on ellipsize mode even if it was not
// specified to make it work if necessary.
if ( !(style & wxST_ELLIPSIZE_MASK) )
style |= wxST_ELLIPSIZE_MIDDLE;
#endif // GTK+ 2
justify = GTK_JUSTIFY_CENTER;
}
else if ( style & wxALIGN_RIGHT )
justify = GTK_JUSTIFY_RIGHT;
else
justify = GTK_JUSTIFY_LEFT;
{
#ifndef __WXGTK3__
// As above, we need to use a non-default ellipsize mode for the
// alignment to have any effect.
if ( !(style & wxST_ELLIPSIZE_MASK) )
style |= wxST_ELLIPSIZE_START;
#endif // GTK+ 2
justify = GTK_JUSTIFY_RIGHT;
}
else // must be wxALIGN_LEFT which is 0
{
// No need to play games with wxST_ELLIPSIZE_XXX.
justify = GTK_JUSTIFY_LEFT;
}
if (GetLayoutDirection() == wxLayout_RightToLeft)
{