From 49d52abb4ed19fb11a4f573908ac03ac7eb2bb24 Mon Sep 17 00:00:00 2001 From: Andreas Falkenhahn Date: Thu, 22 Oct 2015 00:06:45 +0200 Subject: [PATCH] Add wxTE_{RIGHT,CENTER} support for multiline wxTextCtrl in wxOSX Just use -[NSTextView setAlignment]. Closes #13702. (cherry picked from commit d45ba8ce62541bb046776766afb9ca55c9d0bb1f) --- docs/changes.txt | 1 + include/wx/osx/cocoa/private/textimpl.h | 2 +- src/osx/cocoa/textctrl.mm | 13 +++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index d5addb04c7..6ffb25ce1c 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -662,6 +662,7 @@ wxOSX: - Fix custom paper support (tijsv). - Return false from wxSound::Create()/IsOk() if the file doesn't exist. - Fix scrolling behaviour of wxSearchCtrl (John Roberts). +- Add wxTE_{RIGHT,CENTER} support for multiline wxTextCtrl (Andreas Falkenhahn). 3.0.2: (released 2014-10-06) diff --git a/include/wx/osx/cocoa/private/textimpl.h b/include/wx/osx/cocoa/private/textimpl.h index 47d2565119..93d7695272 100644 --- a/include/wx/osx/cocoa/private/textimpl.h +++ b/include/wx/osx/cocoa/private/textimpl.h @@ -62,7 +62,7 @@ private: class wxNSTextViewControl : public wxWidgetCocoaImpl, public wxTextWidgetImpl { public: - wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w ); + wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w, long style ); virtual ~wxNSTextViewControl(); virtual wxString GetStringValue() const ; diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index b414ea0e3a..358eda7954 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -561,7 +561,7 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; // wxNSTextViewControl -wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w ) +wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w, long style ) : wxWidgetCocoaImpl(wxPeer, w), wxTextWidgetImpl(wxPeer) { @@ -581,6 +581,15 @@ wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w ) [tv setHorizontallyResizable:NO]; [tv setAutoresizingMask:NSViewWidthSizable]; + if ( style & wxTE_RIGHT) + { + [tv setAlignment:NSRightTextAlignment]; + } + else if ( style & wxTE_CENTRE) + { + [tv setAlignment:NSCenterTextAlignment]; + } + if ( !wxPeer->HasFlag(wxTE_RICH | wxTE_RICH2) ) { [tv setRichText:NO]; @@ -1055,7 +1064,7 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer, { wxNSTextScrollView* v = nil; v = [[wxNSTextScrollView alloc] initWithFrame:r]; - c = new wxNSTextViewControl( wxpeer, v ); + c = new wxNSTextViewControl( wxpeer, v, style ); c->SetNeedsFocusRect( true ); } else