Fix setting alignment for wxOSX wxTextCtrl with wxTE_DONTWRAP
Don't make the controls with wxTE_DONTWRAP (a.k.a. wxHSCROLL) style "infinitely" wide, but just "very" wide to allow alignment still work in it. See #17529.
This commit is contained in:
committed by
Vadim Zeitlin
parent
dcb1229f41
commit
d5c008da03
@@ -166,6 +166,7 @@ wxOSX:
|
|||||||
- Add OSXEnableAutomaticQuoteSubstitution(), OSXEnableAutomaticDashSubstitution()
|
- Add OSXEnableAutomaticQuoteSubstitution(), OSXEnableAutomaticDashSubstitution()
|
||||||
and OSXDisableAllSmartSubstitutions() to control wxTextCtrl smart behavior.
|
and OSXDisableAllSmartSubstitutions() to control wxTextCtrl smart behavior.
|
||||||
- Don't allow interacting with disabled wxSlider (Andreas Falkenhahn).
|
- Don't allow interacting with disabled wxSlider (Andreas Falkenhahn).
|
||||||
|
- Fix setting alignment in wxTextCtrl with wxTE_DONTWRAP (Andreas Falkenhahn).
|
||||||
|
|
||||||
Unix:
|
Unix:
|
||||||
|
|
||||||
|
@@ -598,6 +598,13 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
|
|||||||
|
|
||||||
// wxNSTextViewControl
|
// wxNSTextViewControl
|
||||||
|
|
||||||
|
// Official Apple docs suggest to use FLT_MAX when embedding an NSTextView
|
||||||
|
// object inside an NSScrollView, see here:
|
||||||
|
// https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/TextUILayer/Tasks/TextInScrollView.html
|
||||||
|
// However, when using FLT_MAX, "setAlignment" doesn't work any more; using
|
||||||
|
// 1000000 instead of FLT_MAX fixes this
|
||||||
|
#define MAX_WIDTH 1000000
|
||||||
|
|
||||||
wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w, long style )
|
wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w, long style )
|
||||||
: wxWidgetCocoaImpl(wxPeer, w),
|
: wxWidgetCocoaImpl(wxPeer, w),
|
||||||
wxTextWidgetImpl(wxPeer)
|
wxTextWidgetImpl(wxPeer)
|
||||||
@@ -612,7 +619,7 @@ wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w, long s
|
|||||||
NSSize contentSize = [m_scrollView contentSize];
|
NSSize contentSize = [m_scrollView contentSize];
|
||||||
NSRect viewFrame = NSMakeRect(
|
NSRect viewFrame = NSMakeRect(
|
||||||
0, 0,
|
0, 0,
|
||||||
hasHScroll ? FLT_MAX : contentSize.width, contentSize.height
|
hasHScroll ? MAX_WIDTH : contentSize.width, contentSize.height
|
||||||
);
|
);
|
||||||
|
|
||||||
wxNSTextView* const tv = [[wxNSTextView alloc] initWithFrame: viewFrame];
|
wxNSTextView* const tv = [[wxNSTextView alloc] initWithFrame: viewFrame];
|
||||||
@@ -623,7 +630,7 @@ wxNSTextViewControl::wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w, long s
|
|||||||
|
|
||||||
if ( hasHScroll )
|
if ( hasHScroll )
|
||||||
{
|
{
|
||||||
[[tv textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)];
|
[[tv textContainer] setContainerSize:NSMakeSize(MAX_WIDTH, MAX_WIDTH)];
|
||||||
[[tv textContainer] setWidthTracksTextView:NO];
|
[[tv textContainer] setWidthTracksTextView:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user