From 3e9a589e8082b390ab9d76739202e5d25a4d00d9 Mon Sep 17 00:00:00 2001 From: dmitry Date: Thu, 11 Jan 2018 05:28:36 +0000 Subject: [PATCH] cocoa: scrollwincontrol, keeping the actual scrollbox size, if a smaller scolling range is requested. #32998 git-svn-id: trunk@57048 - --- lcl/interfaces/cocoa/cocoawinapi.inc | 30 ++++++++++++++++++++++++---- lcl/interfaces/cocoa/cocoawsforms.pp | 1 + 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoawinapi.inc b/lcl/interfaces/cocoa/cocoawinapi.inc index 11bb52cde6..13768e846c 100644 --- a/lcl/interfaces/cocoa/cocoawinapi.inc +++ b/lcl/interfaces/cocoa/cocoawinapi.inc @@ -1764,6 +1764,9 @@ var obj : NSObject; sc : TCocoaScrollView; bar : TCocoaScrollBar; + f : NSSize; + sz : NSSize; + flg : NSUInteger; begin obj := HandleToNSObject(Handle); Result := 0; @@ -1773,10 +1776,29 @@ begin begin sc:=TCocoaScrollView(obj); if sc.isCustomRange and (ScrollInfo.fMask and SIF_RANGE>0) then begin - if SBStyle=SB_Horz then - sc.documentView.setFrameSize( NSMakeSize( ScrollInfo.nMax, sc.documentView.frame.size.height )) - else if SBStyle=SB_Vert then - sc.documentView.setFrameSize( NSMakeSize( sc.documentView.frame.size.width, ScrollInfo.nMax )); + f:=sc.frame.size; + sz:=sc.documentView.frame.size; + flg:=sc.documentView.autoresizingMask; + + if SBStyle=SB_Horz then begin + if ScrollInfo.nMax>f.width then begin + sz.width := ScrollInfo.nMax; + flg:=flg and not NSViewWidthSizable; + end else begin + sz.width := f.width; + flg:=flg or NSViewWidthSizable; + end; + end else if SBStyle=SB_Vert then begin + if ScrollInfo.nMax>f.height then begin + sz.height := ScrollInfo.nMax; + flg:=flg and not NSViewHeightSizable; + end else begin + sz.height := f.height; + flg:=flg or NSViewHeightSizable; + end; + end; + sc.documentView.setAutoresizingMask(flg); + sc.documentView.setFrameSize( sz ); end; NSScrollViewSetScrollInfo(NSScrollView(obj), SBStyle, ScrollInfo); diff --git a/lcl/interfaces/cocoa/cocoawsforms.pp b/lcl/interfaces/cocoa/cocoawsforms.pp index 0e38751619..38748f9b23 100644 --- a/lcl/interfaces/cocoa/cocoawsforms.pp +++ b/lcl/interfaces/cocoa/cocoawsforms.pp @@ -393,6 +393,7 @@ begin lcl := TLCLCustomControlCallback.Create(docview, AWinControl); docview.callback := lcl; + docview.setAutoresizingMask(NSViewWidthSizable or NSViewHeightSizable); scrollcon.callback := lcl; lcl.Frame:=scrollcon; scrollcon.setDocumentView(docview);