Cocoa: unify Scroll related naming

This commit is contained in:
rich2014 2024-07-05 21:12:08 +08:00
parent 48c96f03fc
commit ca2bb30540
2 changed files with 88 additions and 88 deletions

View File

@ -43,7 +43,7 @@ type
// the corresponding LCL ScrollInfo, // the corresponding LCL ScrollInfo,
// which are needed when documentView.frame changes. // which are needed when documentView.frame changes.
lclHoriScrollInfo: TScrollInfo; lclHorzScrollInfo: TScrollInfo;
lclVertScrollInfo: TScrollInfo; lclVertScrollInfo: TScrollInfo;
docrect : NSRect; // have to remember old docrect : NSRect; // have to remember old
@ -227,9 +227,9 @@ type
private private
_manager: TCocoaScrollStyleManager; _manager: TCocoaScrollStyleManager;
_tapping: Integer; // two finger tapping, SB_VERT / SB_HORZ / SB_BOTH _tapping: Integer; // two finger tapping, SB_VERT / SB_HORZ / SB_BOTH
fdocumentView: NSView; _documentView: NSView;
fhscroll : TCocoaScrollBar; _horzScrollBar : TCocoaScrollBar;
fvscroll : TCocoaScrollBar; _vertScrollBar : TCocoaScrollBar;
public public
callback: ICommonCallback; callback: ICommonCallback;
function initWithFrame(frameRect: NSRect): id; override; function initWithFrame(frameRect: NSRect): id; override;
@ -629,15 +629,15 @@ end;
procedure TCocoaManualScrollView.dealloc; procedure TCocoaManualScrollView.dealloc;
begin begin
if Assigned(fhscroll) then begin if Assigned(_horzScrollBar) then begin
fhscroll.removeFromSuperview; _horzScrollBar.removeFromSuperview;
fhscroll.setManager( nil ); _horzScrollBar.setManager( nil );
fhscroll.release; _horzScrollBar.release;
end; end;
if Assigned(fvscroll) then begin if Assigned(_vertScrollBar) then begin
fvscroll.removeFromSuperview; _vertScrollBar.removeFromSuperview;
fvscroll.setManager( nil ); _vertScrollBar.setManager( nil );
fvscroll.release; _vertScrollBar.release;
end; end;
FreeAndNil( _manager ); FreeAndNil( _manager );
end; end;
@ -664,11 +664,11 @@ begin
else else
_manager:= TCocoaScrollStyleManagerOverlay.createForScrollView(self); _manager:= TCocoaScrollStyleManagerOverlay.createForScrollView(self);
if Assigned(self.fhscroll) then begin if Assigned(_horzScrollBar) then begin
self.fhscroll.setManager( _manager ); _horzScrollBar.setManager( _manager );
end; end;
if Assigned(self.fvscroll) then begin if Assigned(_vertScrollBar) then begin
self.fvscroll.setManager( _manager ); _vertScrollBar.setManager( _manager );
end; end;
oldManager.Free; oldManager.Free;
@ -679,21 +679,21 @@ var
horzAvailable: Boolean; horzAvailable: Boolean;
vertAvailabl: Boolean; vertAvailabl: Boolean;
begin begin
horzAvailable:= _manager.isAvailableScrollBar( self.fhscroll ); horzAvailable:= _manager.isAvailableScrollBar( _horzScrollBar );
vertAvailabl:= _manager.isAvailableScrollBar( self.fvscroll ); vertAvailabl:= _manager.isAvailableScrollBar( _vertScrollBar );
self.resetManager; self.resetManager;
_manager.availScrollBar( self.fhscroll, horzAvailable ); _manager.availScrollBar( _horzScrollBar, horzAvailable );
_manager.availScrollBar( self.fvscroll, vertAvailabl ); _manager.availScrollBar( _vertScrollBar, vertAvailabl );
if self.lclGetTarget is TWinControl then if self.lclGetTarget is TWinControl then
TWinControl(self.lclGetTarget).AdjustSize; TWinControl(self.lclGetTarget).AdjustSize;
_manager.updateLayout; _manager.updateLayout;
_manager.showScrollBar(self.fhscroll); _manager.showScrollBar(_horzScrollBar);
_manager.showScrollBar(self.fvscroll); _manager.showScrollBar(_vertScrollBar);
end; end;
function TCocoaManualScrollView.lclGetCallback: ICommonCallback; function TCocoaManualScrollView.lclGetCallback: ICommonCallback;
@ -708,14 +708,14 @@ end;
function TCocoaManualScrollView.lclContentView: NSView; function TCocoaManualScrollView.lclContentView: NSView;
begin begin
Result:=fdocumentView; Result:=_documentView;
end; end;
function TCocoaManualScrollView.lclClientFrame: TRect; function TCocoaManualScrollView.lclClientFrame: TRect;
begin begin
if Assigned(fdocumentView) then if Assigned(_documentView) then
begin begin
Result:=fdocumentView.lclClientFrame; Result:=_documentView.lclClientFrame;
end end
else Result:=inherited lclClientFrame; else Result:=inherited lclClientFrame;
end; end;
@ -744,25 +744,25 @@ procedure TCocoaManualScrollView.setDocumentView(AView: NSView);
var var
f : NSrect; f : NSrect;
begin begin
if fdocumentView=AView then Exit; if _documentView=AView then Exit;
if Assigned(fdocumentView) then if Assigned(_documentView) then
fdocumentView.removeFromSuperview; _documentView.removeFromSuperview;
fdocumentView:=AView; _documentView:=AView;
if Assigned(fdocumentView) then if Assigned(_documentView) then
begin begin
addSubview(fdocumentView); addSubview(_documentView);
f:=fdocumentView.frame; f:=_documentView.frame;
f.origin.x:=0; f.origin.x:=0;
f.origin.y:=0; f.origin.y:=0;
fdocumentView.setFrame(f); _documentView.setFrame(f);
fdocumentView.setAutoresizingMask(NSViewWidthSizable or NSViewHeightSizable); _documentView.setAutoresizingMask(NSViewWidthSizable or NSViewHeightSizable);
end; end;
end; end;
function TCocoaManualScrollView.documentView: NSView; function TCocoaManualScrollView.documentView: NSView;
begin begin
Result:=fdocumentView; Result:=_documentView;
end; end;
function TCocoaManualScrollView.isTapping(scroller: NSScroller): Boolean; function TCocoaManualScrollView.isTapping(scroller: NSScroller): Boolean;
@ -771,9 +771,9 @@ begin
Exit( False ); Exit( False );
if _tapping = SB_BOTH then if _tapping = SB_BOTH then
Exit( True ); Exit( True );
if (_tapping = SB_HORZ) and (scroller=self.fhscroll) then if (_tapping = SB_HORZ) and (scroller=_horzScrollBar) then
Exit( True ); Exit( True );
if (_tapping = SB_VERT) and (scroller=self.fvscroll) then if (_tapping = SB_VERT) and (scroller=_vertScrollBar) then
Exit( True ); Exit( True );
Result:= False; Result:= False;
end; end;
@ -783,27 +783,27 @@ begin
if _tapping < 0 then if _tapping < 0 then
Exit; Exit;
if scroller=self.fvscroll then begin if scroller=_vertScrollBar then begin
_tapping:= SB_VERT; _tapping:= SB_VERT;
_manager.tempHideScrollBar( fhscroll ); _manager.tempHideScrollBar( _horzScrollBar );
end else if scroller=self.fhscroll then begin end else if scroller=_horzScrollBar then begin
_tapping:= SB_HORZ; _tapping:= SB_HORZ;
_manager.tempHideScrollBar( fvscroll ); _manager.tempHideScrollBar( _vertScrollBar );
end; end;
end; end;
procedure TCocoaManualScrollView.delayShowScrollBars(); procedure TCocoaManualScrollView.delayShowScrollBars();
begin begin
_manager.showScrollBar( self.fhscroll, False ); _manager.showScrollBar( _horzScrollBar, False );
_manager.showScrollBar( self.fvscroll, False ); _manager.showScrollBar( _vertScrollBar, False );
end; end;
procedure TCocoaManualScrollView.showScrollBarsAndAutoHide( tapping:Integer ); procedure TCocoaManualScrollView.showScrollBarsAndAutoHide( tapping:Integer );
begin begin
if (tapping=SB_HORZ) or (tapping=SB_BOTH) then if (tapping=SB_HORZ) or (tapping=SB_BOTH) then
_manager.showScrollBar(self.fhscroll); _manager.showScrollBar(_horzScrollBar);
if (tapping=SB_VERT) or (tapping=SB_BOTH) then if (tapping=SB_VERT) or (tapping=SB_BOTH) then
_manager.showScrollBar(self.fvscroll); _manager.showScrollBar(_vertScrollBar);
end; end;
procedure TCocoaManualScrollView.touchesBeganWithEvent(event: NSEvent); procedure TCocoaManualScrollView.touchesBeganWithEvent(event: NSEvent);
@ -868,11 +868,11 @@ procedure TCocoaManualScrollView.setHasVerticalScroller(doshow: Boolean);
var var
available: Boolean; available: Boolean;
begin begin
available:= _manager.isAvailableScrollBar(fvscroll); available:= _manager.isAvailableScrollBar(_vertScrollBar);
if NOT Assigned(fvscroll) and doshow then if NOT Assigned(_vertScrollBar) and doshow then
fvscroll:= self.allocVerticalScroller( True ); _vertScrollBar:= self.allocVerticalScroller( True );
_manager.availScrollBar( fvscroll, doshow ); _manager.availScrollBar( _vertScrollBar, doshow );
if available <> _manager.isAvailableScrollBar(fvscroll) then if available <> _manager.isAvailableScrollBar(_vertScrollBar) then
_manager.updateLayout; _manager.updateLayout;
end; end;
@ -880,32 +880,32 @@ procedure TCocoaManualScrollView.setHasHorizontalScroller(doshow: Boolean);
var var
available: Boolean; available: Boolean;
begin begin
available:= _manager.isAvailableScrollBar(fhscroll); available:= _manager.isAvailableScrollBar(_horzScrollBar);
if NOT Assigned(fhscroll) and doshow then if NOT Assigned(_horzScrollBar) and doshow then
fhscroll:= self.allocHorizontalScroller( True ); _horzScrollBar:= self.allocHorizontalScroller( True );
_manager.availScrollBar( fhscroll, doshow ); _manager.availScrollBar( _horzScrollBar, doshow );
if available <> _manager.isAvailableScrollBar(fhscroll) then if available <> _manager.isAvailableScrollBar(_horzScrollBar) then
_manager.updateLayout; _manager.updateLayout;
end; end;
function TCocoaManualScrollView.hasVerticalScroller: Boolean; function TCocoaManualScrollView.hasVerticalScroller: Boolean;
begin begin
Result:= _manager.isAvailableScrollBar(fvscroll); Result:= _manager.isAvailableScrollBar(_vertScrollBar);
end; end;
function TCocoaManualScrollView.hasHorizontalScroller: Boolean; function TCocoaManualScrollView.hasHorizontalScroller: Boolean;
begin begin
Result:= _manager.isAvailableScrollBar(fhscroll); Result:= _manager.isAvailableScrollBar(_horzScrollBar);
end; end;
function TCocoaManualScrollView.horizontalScroller: NSScroller; function TCocoaManualScrollView.horizontalScroller: NSScroller;
begin begin
Result:=fhscroll; Result:=_horzScrollBar;
end; end;
function TCocoaManualScrollView.verticalScroller: NSScroller; function TCocoaManualScrollView.verticalScroller: NSScroller;
begin begin
Result:=fvscroll; Result:=_vertScrollBar;
end; end;
function TCocoaManualScrollView.allocHorizontalScroller(avisible: Boolean): TCocoaScrollBar; function TCocoaManualScrollView.allocHorizontalScroller(avisible: Boolean): TCocoaScrollBar;
@ -914,17 +914,17 @@ var
f : NSRect; f : NSRect;
w : CGFloat; w : CGFloat;
begin begin
if Assigned(fhscroll) then if Assigned(_horzScrollBar) then
Result := fhscroll Result := _horzScrollBar
else else
begin begin
f := frame; f := frame;
w := NSScroller.scrollerWidthForControlSize_scrollerStyle( w := NSScroller.scrollerWidthForControlSize_scrollerStyle(
fhscroll.controlSize, fhscroll.preferredScrollerStyle); _horzScrollBar.controlSize, _horzScrollBar.preferredScrollerStyle);
r := NSMakeRect(0, 0, Max(f.size.width,w+1), w); // width<height to create a horizontal scroller r := NSMakeRect(0, 0, Max(f.size.width,w+1), w); // width<height to create a horizontal scroller
fhscroll := allocScroller( self, r, avisible); _horzScrollBar := allocScroller( self, r, avisible);
fhscroll.setAutoresizingMask(NSViewWidthSizable); _horzScrollBar.setAutoresizingMask(NSViewWidthSizable);
Result := fhscroll; Result := _horzScrollBar;
_manager.updateLayout; _manager.updateLayout;
end; end;
end; end;
@ -935,20 +935,20 @@ var
f : NSRect; f : NSRect;
w : CGFloat; w : CGFloat;
begin begin
if Assigned(fvscroll) then if Assigned(_vertScrollBar) then
Result := fvscroll Result := _vertScrollBar
else else
begin begin
f := frame; f := frame;
w := NSScroller.scrollerWidthForControlSize_scrollerStyle( w := NSScroller.scrollerWidthForControlSize_scrollerStyle(
fvscroll.controlSize, fvscroll.preferredScrollerStyle); _vertScrollBar.controlSize, _vertScrollBar.preferredScrollerStyle);
r := NSMakeRect(0, 0, w, Max(f.size.height,w+1)); // height<width to create a vertical scroller r := NSMakeRect(0, 0, w, Max(f.size.height,w+1)); // height<width to create a vertical scroller
fvscroll := allocScroller( self, r, avisible); _vertScrollBar := allocScroller( self, r, avisible);
if self.isFlipped then if self.isFlipped then
fvscroll.setAutoresizingMask(NSViewHeightSizable or NSViewMaxXMargin) _vertScrollBar.setAutoresizingMask(NSViewHeightSizable or NSViewMaxXMargin)
else else
fvscroll.setAutoresizingMask(NSViewHeightSizable or NSViewMinXMargin); _vertScrollBar.setAutoresizingMask(NSViewHeightSizable or NSViewMinXMargin);
Result := fvscroll; Result := _vertScrollBar;
_manager.updateLayout; _manager.updateLayout;
end; end;
end; end;
@ -963,20 +963,20 @@ var
pt : NSPoint; pt : NSPoint;
begin begin
Result := false; Result := false;
if Assigned(host.fhscroll) and (not host.fhscroll.isHidden) then if Assigned(host._horzScrollBar) and (not host._horzScrollBar.isHidden) then
begin begin
pt := host.fhscroll.convertPoint_fromView(event.locationInWindow, nil); pt := host._horzScrollBar.convertPoint_fromView(event.locationInWindow, nil);
if NSPointInRect(pt, host.fhscroll.bounds) then if NSPointInRect(pt, host._horzScrollBar.bounds) then
begin begin
Result := true; Result := true;
Exit; Exit;
end; end;
end; end;
if Assigned(host.fvscroll) and (not host.fvscroll.isHidden) then if Assigned(host._vertScrollBar) and (not host._vertScrollBar.isHidden) then
begin begin
pt := host.fvscroll.convertPoint_fromView(event.locationInWindow, nil); pt := host._vertScrollBar.convertPoint_fromView(event.locationInWindow, nil);
if NSPointInRect(pt, host.fvscroll.bounds) then if NSPointInRect(pt, host._vertScrollBar.bounds) then
begin begin
Result := true; Result := true;
Exit; Exit;
@ -1024,7 +1024,7 @@ end;
procedure TCocoaScrollView.resetScrollData; procedure TCocoaScrollView.resetScrollData;
begin begin
docrect:=documentVisibleRect; docrect:=documentVisibleRect;
lclHoriScrollInfo.fMask:= 0; lclHorzScrollInfo.fMask:= 0;
lclVertScrollInfo.fMask:= 0; lclVertScrollInfo.fMask:= 0;
end; end;
@ -1103,7 +1103,7 @@ begin
end end
else else
begin begin
self.lclHoriScrollInfo:= scrollInfo; self.lclHorzScrollInfo:= scrollInfo;
newOrigin.x:= scrollInfo.nPos; newOrigin.x:= scrollInfo.nPos;
end; end;
self.contentView.setBoundsOrigin( newOrigin ); self.contentView.setBoundsOrigin( newOrigin );
@ -1142,8 +1142,8 @@ begin
documentView.setFrameSize(newDocSize); documentView.setFrameSize(newDocSize);
if lclHoriScrollInfo.fMask<>0 then if lclHorzScrollInfo.fMask<>0 then
applyScrollInfo(SB_Horz, lclHoriScrollInfo); applyScrollInfo(SB_Horz, lclHorzScrollInfo);
if lclVertScrollInfo.fMask<>0 then if lclVertScrollInfo.fMask<>0 then
applyScrollInfo(SB_Vert, lclVertScrollInfo); applyScrollInfo(SB_Vert, lclVertScrollInfo);
@ -1655,8 +1655,8 @@ begin
hScrollerFrame := docFrame; hScrollerFrame := docFrame;
vScrollerFrame := docFrame; vScrollerFrame := docFrame;
hScroller:= _scrollView.fhscroll; hScroller:= _scrollView._horzScrollBar;
vScroller:= _scrollView.fvscroll; vScroller:= _scrollView._vertScrollBar;
if self.isAvailableScrollBar(hScroller) then if self.isAvailableScrollBar(hScroller) then
begin begin
@ -2033,8 +2033,8 @@ begin
hScrollerFrame := docFrame; hScrollerFrame := docFrame;
vScrollerFrame := docFrame; vScrollerFrame := docFrame;
hScroller:= _scrollView.fhscroll; hScroller:= _scrollView._horzScrollBar;
vScroller:= _scrollView.fvscroll; vScroller:= _scrollView._vertScrollBar;
if Assigned(hScroller) then if Assigned(hScroller) then
begin begin

View File

@ -1859,8 +1859,8 @@ begin
if sc.lclVertScrollInfo.fMask<>0 then if sc.lclVertScrollInfo.fMask<>0 then
sc.applyScrollInfo(SB_Vert, sc.lclVertScrollInfo) sc.applyScrollInfo(SB_Vert, sc.lclVertScrollInfo)
end else begin end else begin
if sc.lclHoriScrollInfo.fMask<>0 then if sc.lclHorzScrollInfo.fMask<>0 then
sc.applyScrollInfo(SB_Horz, sc.lclHoriScrollInfo); sc.applyScrollInfo(SB_Horz, sc.lclHorzScrollInfo);
end; end;
end; end;