From efe9236b16a9facc1dced24244a27816093d80c7 Mon Sep 17 00:00:00 2001 From: Chris Lemin Date: Tue, 2 Jul 2019 09:51:04 +0100 Subject: [PATCH] Add support for alignment flags to wxStaticText in wxQt Ensure static text fields use the alignment specified by WX on creation. This is the second commit doing this, the first one was reverted because it accidentally included unrelated changes, sorry for the trouble. See https://github.com/wxWidgets/wxWidgets/pull/1381 --- src/qt/stattext.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/qt/stattext.cpp b/src/qt/stattext.cpp index 2eb50b5f18..f6d2bcde63 100644 --- a/src/qt/stattext.cpp +++ b/src/qt/stattext.cpp @@ -55,6 +55,15 @@ bool wxStaticText::Create(wxWindow *parent, m_qtLabel->setBuddy( m_qtLabel ); m_qtLabel->setTextInteractionFlags( Qt::NoTextInteraction ); + // Translate the WX horizontal alignment flags to Qt alignment flags + // (notice that wxALIGN_LEFT is default and has the value of 0). + if ( style & wxALIGN_CENTER_HORIZONTAL ) + m_qtLabel->setAlignment(Qt::AlignHCenter); + else if ((style & wxALIGN_MASK) == wxALIGN_RIGHT) + m_qtLabel->setAlignment(Qt::AlignRight); + else + m_qtLabel->setAlignment(Qt::AlignLeft); + return QtCreateControl( parent, id, pos, size, style, wxDefaultValidator, name ); }