cocoa: adding support for small and large change parameters of a scrollbar

git-svn-id: trunk@62541 -
This commit is contained in:
dmitry 2020-01-13 02:42:51 +00:00
parent 35bf787651
commit e7390143f5
2 changed files with 19 additions and 7 deletions

View File

@ -105,6 +105,8 @@ type
maxInt : Integer; maxInt : Integer;
pageInt : Integer; pageInt : Integer;
suppressLCLMouse: Boolean; suppressLCLMouse: Boolean;
largeInc: Integer;
smallInc: Integer;
procedure actionScrolling(sender: NSObject); message 'actionScrolling:'; procedure actionScrolling(sender: NSObject); message 'actionScrolling:';
function IsHorizontal: Boolean; message 'IsHorizontal'; function IsHorizontal: Boolean; message 'IsHorizontal';
@ -127,7 +129,6 @@ type
procedure mouseDragged(event: NSEvent); override; procedure mouseDragged(event: NSEvent); override;
procedure mouseMoved(event: NSEvent); override; procedure mouseMoved(event: NSEvent); override;
procedure scrollWheel(event: NSEvent); override; procedure scrollWheel(event: NSEvent); override;
end; end;
{ TCocoaManualScrollHost } { TCocoaManualScrollHost }
@ -175,19 +176,26 @@ end;
function AdjustScrollerPage(sc: TCocoaScrollBar; prt: NSScrollerPart): Boolean; function AdjustScrollerPage(sc: TCocoaScrollBar; prt: NSScrollerPart): Boolean;
var var
adj : Integer; adj : integer;
sz : Integer; sz : Integer;
dlt : double; dlt : double;
v : double; v : double;
begin begin
Result := isIncDecPagePart(prt); Result := false;
if not Result then Exit; case prt of
NSScrollerDecrementPage: adj := -sc.largeInc;
NSScrollerIncrementPage: adj := sc.largeInc;
NSScrollerDecrementLine: adj := -sc.smallInc;
NSScrollerIncrementLine: adj := sc.smallInc;
else
adj := 0;
end;
if adj = 0 then Exit;
sz := sc.maxInt - sc.minInt - sc.pageInt; sz := sc.maxInt - sc.minInt - sc.pageInt;
if sz = 0 then Exit; // do nothing! if sz = 0 then Exit; // do nothing!
if sc.pageInt = 0 then dlt := 1 / sz dlt := adj / sz;
else dlt := sc.pageInt / sz;
if prt = NSScrollerDecrementPage then dlt := -dlt;
v := sc.doubleValue; v := sc.doubleValue;
v := v + dlt; v := v + dlt;

View File

@ -1939,6 +1939,10 @@ begin
scr.minInt:=TCustomScrollBar(AWinControl).Min; scr.minInt:=TCustomScrollBar(AWinControl).Min;
scr.maxInt:=TCustomScrollBar(AWinControl).Max; scr.maxInt:=TCustomScrollBar(AWinControl).Max;
scr.pageInt:=TCustomScrollBar(AWinControl).PageSize; scr.pageInt:=TCustomScrollBar(AWinControl).PageSize;
scr.largeInc:=abs(TCustomScrollBar(AWinControl).LargeChange);
scr.smallInc:=abs(TCustomScrollBar(AWinControl).SmallChange);
if scr.largeInc=0 then scr.largeInc:=1;
if scr.smallInc=0 then scr.smallInc:=1;
Result:=TLCLIntfHandle(scr); Result:=TLCLIntfHandle(scr);