Cocoa: fix the size of Overlay Style Scroller in TCocoaWidgetSet.GetScrollBarSize()

This commit is contained in:
rich2014 2024-06-16 21:17:16 +08:00
parent 95b9ef2414
commit 1459f56c95

View File

@ -1601,24 +1601,35 @@ end;
function TCocoaWidgetSet.GetScrollBarSize(Handle: HWND; BarKind: Integer): integer; function TCocoaWidgetSet.GetScrollBarSize(Handle: HWND; BarKind: Integer): integer;
var var
sc : NSScrollView;
obj : NSObject; obj : NSObject;
scroller: NSScroller;
begin begin
obj := NSObject(Handle);
Result := 0; Result := 0;
if not Assigned(obj) then Exit;
if obj.isKindOfClass(NSScrollView) then obj:= NSObject(Handle);
begin if NOT Assigned(obj) then
if (BarKind = SB_Vert) and Assigned(NSScrollView(obj).verticalScroller) then Exit;
Result:=round(NSScrollView(obj).verticalScroller.frame.size.width)
else if (BarKind = SB_Horz) and Assigned(NSScrollView(obj).horizontalScroller) then if NOT obj.isKindOfClass(NSScrollView) then begin
Result:=round(NSScrollView(obj).verticalScroller.frame.size.height) Result:= GetSystemMetrics(SM_CXVSCROLL);
else Exit;
Result := GetSystemMetrics(SM_CXVSCROLL); end;
end
if BarKind = SB_VERT then
scroller:= NSScrollView(obj).verticalScroller
else else
Result := GetSystemMetrics(SM_CXVSCROLL); scroller:= NSScrollView(obj).horizontalScroller;
if NOT Assigned(scroller) then
Exit;
if scroller.scrollerStyle = NSScrollerStyleOverlay then
Exit;
if BarKind = SB_Vert then
Result:= Round(scroller.frame.size.width)
else
Result:= Round(scroller.frame.size.height);
end; end;
function TCocoaWidgetSet.GetScrollbarVisible(Handle: HWND; SBStyle: Integer): boolean; function TCocoaWidgetSet.GetScrollbarVisible(Handle: HWND; SBStyle: Integer): boolean;