cocoa: scrollwincontrol, keeping the actual scrollbox size, if a smaller scolling range is requested. #32998

git-svn-id: trunk@57048 -
This commit is contained in:
dmitry 2018-01-11 05:28:36 +00:00
parent db4dc7c254
commit 3e9a589e80
2 changed files with 27 additions and 4 deletions

View File

@ -1764,6 +1764,9 @@ var
obj : NSObject; obj : NSObject;
sc : TCocoaScrollView; sc : TCocoaScrollView;
bar : TCocoaScrollBar; bar : TCocoaScrollBar;
f : NSSize;
sz : NSSize;
flg : NSUInteger;
begin begin
obj := HandleToNSObject(Handle); obj := HandleToNSObject(Handle);
Result := 0; Result := 0;
@ -1773,10 +1776,29 @@ begin
begin begin
sc:=TCocoaScrollView(obj); sc:=TCocoaScrollView(obj);
if sc.isCustomRange and (ScrollInfo.fMask and SIF_RANGE>0) then begin if sc.isCustomRange and (ScrollInfo.fMask and SIF_RANGE>0) then begin
if SBStyle=SB_Horz then f:=sc.frame.size;
sc.documentView.setFrameSize( NSMakeSize( ScrollInfo.nMax, sc.documentView.frame.size.height )) sz:=sc.documentView.frame.size;
else if SBStyle=SB_Vert then flg:=sc.documentView.autoresizingMask;
sc.documentView.setFrameSize( NSMakeSize( sc.documentView.frame.size.width, ScrollInfo.nMax ));
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; end;
NSScrollViewSetScrollInfo(NSScrollView(obj), SBStyle, ScrollInfo); NSScrollViewSetScrollInfo(NSScrollView(obj), SBStyle, ScrollInfo);

View File

@ -393,6 +393,7 @@ begin
lcl := TLCLCustomControlCallback.Create(docview, AWinControl); lcl := TLCLCustomControlCallback.Create(docview, AWinControl);
docview.callback := lcl; docview.callback := lcl;
docview.setAutoresizingMask(NSViewWidthSizable or NSViewHeightSizable);
scrollcon.callback := lcl; scrollcon.callback := lcl;
lcl.Frame:=scrollcon; lcl.Frame:=scrollcon;
scrollcon.setDocumentView(docview); scrollcon.setDocumentView(docview);