Cocoa/TabControl: #40050 Merge branch 'cocoa/tabcontrol', scrolling is supported when TabPosition:=tpBottom

This commit is contained in:
rich2014 2023-09-12 21:41:43 +08:00
parent 748351eb53
commit 71e85eb4d5
2 changed files with 26 additions and 8 deletions

View File

@ -67,6 +67,7 @@ type
class function alloc: id; override;
procedure dealloc; override;
procedure setFrame(aframe: NSRect); override;
procedure setTabViewType(newValue: NSTabViewType); override;
// lcl
function lclIsEnabled: Boolean; override;
procedure lclSetEnabled(AEnabled: Boolean); override;
@ -191,8 +192,15 @@ var
begin
if not assigned(abtn) then Exit;
if isPrev then org:=NSMakePoint(arrow_hofs, arrow_vofs)
else org:=NSMakePoint(dst.frame.size.width - abtn.frame.size.width - arrow_hofs , arrow_vofs);
if dst.tabViewType = NSTopTabsBezelBorder then
org.y := arrow_vofs
else
org.y := dst.frame.size.height - abtn.frame.size.height - arrow_vofs;
if isPrev then
org.x := arrow_hofs
else
org.x := dst.frame.size.width - abtn.frame.size.width - arrow_hofs;
abtn.setFrameOrigin(org);
end;
@ -208,10 +216,6 @@ begin
aview.prevarr.setAction( ObjCSelector('extTabPrevButtonClick:'));
aview.nextarr.setTarget(aview);
aview.nextarr.setAction( ObjCSelector('extTabNextButtonClick:'));
PlaceButton(true, aview.prevarr, aview);
PlaceButton(false, aview.nextarr, aview);
end;
// only missing ViewItems inserted, RemoveAllTabs() is no longer needed,
@ -260,6 +264,9 @@ begin
ShowPrev := false;
ShowNext := false;
// ReviseTabs() supports tpTop and tpBottom only
if (aview.tabViewType=NSLeftTabsBezelBorder) or (aview.tabViewType=NSRightTabsBezelBorder) then exit;
if aview.fulltabs.count=0 then exit;
// AttachAllTabs() has been modified to not remove the selectedTabViewItem first,
@ -330,17 +337,23 @@ var
begin
ReviseTabs(aview, showPrev, showNExt);
if Assigned(aview.prevarr) then
begin
PlaceButton(true, aview.prevarr, aview);
{$ifdef BOOLFIX}
aview.prevarr.setHidden_(Ord(not showPrev));
{$else}
aview.prevarr.setHidden(not showPrev);
{$endif}
end;
if Assigned(aview.nextarr) then
begin
PlaceButton(false, aview.nextarr, aview);
{$ifdef BOOLFIX}
aview.nextarr.setHidden_(Ord(not showNext));
{$else}
aview.nextarr.setHidden(not showNext);
{$endif}
end;
end;
function IndexOfTab(ahost: TCocoaTabControl; atab: NSTabViewItem): Integer;
@ -440,6 +453,12 @@ begin
UpdateTabAndArrowVisibility(self);
end;
procedure TCocoaTabControl.setTabViewType(newValue: NSTabViewType);
begin
Inherited;
UpdateTabAndArrowVisibility(self);
end;
procedure TCocoaTabControl.extselectTabViewItemAtIndex(index: NSInteger);
var
idx : integer;

View File

@ -911,12 +911,11 @@ end;
class procedure TCocoaWSCustomTabControl.SetTabPosition(const ATabControl: TCustomTabControl; const ATabPosition: TTabPosition);
var
lTabControl: TCocoaTabControl = nil;
lOldTabStyle, lTabStyle: NSTabViewType;
lTabStyle: NSTabViewType;
begin
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
lTabControl := TCocoaTabControl(ATabControl.Handle);
lOldTabStyle := lTabControl.tabViewType();
lTabStyle := LCLTabPosToNSTabStyle(ATabControl.ShowTabs, ATabControl.BorderWidth, ATabPosition);
lTabControl.setTabViewType(lTabStyle);
end;