mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 10:39:09 +02:00
lcl-cocoa: Various fixes and improvements related to TPageControl, it can already show all tabs and the contents of the initially selected tab
git-svn-id: trunk@44774 -
This commit is contained in:
parent
103fe7fe69
commit
b50fcc983d
@ -1691,11 +1691,8 @@ begin
|
||||
p := nil;
|
||||
if (AParams.WndParent <> 0) then
|
||||
begin
|
||||
p := CocoaUtils.GetNSObjectView(NSObject(AParams.WndParent));
|
||||
if (NSObject(AParams.WndParent).isKindOfClass_(NSView)) then
|
||||
p := NSView(AParams.WndParent)
|
||||
else
|
||||
if (NSObject(AParams.WndParent).isKindOfClass_(NSWindow)) then
|
||||
p := NSWindow(AParams.WndParent).contentView;
|
||||
end;
|
||||
with AParams do
|
||||
if Assigned(p) then
|
||||
|
@ -223,8 +223,12 @@ function GetNSObjectView(obj: NSObject): NSView;
|
||||
begin
|
||||
Result := nil;
|
||||
if not Assigned(obj) then Exit;
|
||||
if obj.isKindOfClass_(NSView) then Result:=NSView(obj)
|
||||
else if obj.isKindOfClass_(NSWindow) then Result:=NSWindow(obj).contentView;
|
||||
if obj.isKindOfClass_(NSView) then
|
||||
Result:=NSView(obj)
|
||||
else if obj.isKindOfClass_(NSWindow) then
|
||||
Result:=NSWindow(obj).contentView
|
||||
else if obj.isKindOfClass_(NSTabViewItem) then
|
||||
Result := NSTabViewItem(obj).view;
|
||||
end;
|
||||
|
||||
function GetNSPoint(x, y: single): NSPoint;
|
||||
|
@ -927,7 +927,7 @@ begin
|
||||
|
||||
// Call on a window
|
||||
lView := NSView(Handle);
|
||||
if lView.isKindOfClass(objc_getClass('TCocoaWindowContent')) then
|
||||
if lView.isKindOfClass_(TCocoaWindowContent) then
|
||||
begin
|
||||
if TCocoaWindowContent(handle).isembedded then
|
||||
r := TCocoaWindowContent(handle).lclFrame
|
||||
|
@ -5,6 +5,8 @@ interface
|
||||
{$mode delphi}
|
||||
{$modeswitch objectivec1}
|
||||
|
||||
{.$DEFINE COCOA_DEBUG_TABCONTROL}
|
||||
|
||||
uses
|
||||
// RTL, FCL, LCL
|
||||
CocoaAll,
|
||||
@ -40,6 +42,7 @@ type
|
||||
published
|
||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
class procedure UpdateProperties(const ACustomPage: TCustomPage); override;
|
||||
class procedure SetProperties(const ACustomPage: TCustomPage; ACocoaControl: NSTabViewItem);
|
||||
end;
|
||||
|
||||
{ TCocoaWSCustomTabControl }
|
||||
@ -196,17 +199,43 @@ class function TCocoaWSCustomPage.CreateHandle(const AWinControl: TWinControl; c
|
||||
var
|
||||
lControl: TCocoaTabPage;
|
||||
begin
|
||||
{$IFDEF COCOA_DEBUG_TABCONTROL}
|
||||
WriteLn('[TCocoaWSCustomPage.CreateHandle]');
|
||||
{$ENDIF}
|
||||
lControl := TCocoaTabPage.alloc().init();
|
||||
Result := TLCLIntfHandle(lControl);
|
||||
if Result <> 0 then
|
||||
begin
|
||||
//lControl.callback := TLCLCommonCallback.Create(Result, ATarget);
|
||||
//lControl.callback := TLCLCommonCallback.Create(lControl, AWinControl);
|
||||
lControl.LCLPage := TCustomPage(AWinControl);
|
||||
SetProperties(TCustomPage(AWinControl), lControl);
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomPage.UpdateProperties(const ACustomPage: TCustomPage);
|
||||
var
|
||||
lTabPage: TCocoaTabPage;
|
||||
begin
|
||||
{$IFDEF COCOA_DEBUG_TABCONTROL}
|
||||
WriteLn('[TCocoaWSCustomTabControl.UpdateProperties] ACustomPage='+IntToStr(PtrInt(ACustomPage)));
|
||||
{$ENDIF}
|
||||
if not Assigned(ACustomPage) or not ACustomPage.HandleAllocated then Exit;
|
||||
lTabPage := TCocoaTabPage(ACustomPage.Handle);
|
||||
SetProperties(ACustomPage, lTabPage);
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomPage.SetProperties(
|
||||
const ACustomPage: TCustomPage; ACocoaControl: NSTabViewItem);
|
||||
var
|
||||
lHintStr: string;
|
||||
begin
|
||||
// title
|
||||
ACocoaControl.setLabel(NSStringUTF8(ACustomPage.Caption));
|
||||
|
||||
// hint
|
||||
if ACustomPage.ShowHint then lHintStr := ACustomPage.Hint
|
||||
else lHintStr := '';
|
||||
ACocoaControl.setToolTip(NSStringUTF8(lHintStr));
|
||||
end;
|
||||
|
||||
{ TCocoaWSCustomTabControl }
|
||||
@ -219,7 +248,7 @@ begin
|
||||
Result := TLCLIntfHandle(lControl);
|
||||
if Result <> 0 then
|
||||
begin
|
||||
//Result.callback := TLCLCommonCallback.Create(Result, ATarget);
|
||||
//lControl.callback := TLCLCommonCallback.Create(lControl, AWinControl);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -228,12 +257,19 @@ var
|
||||
lTabControl: TCocoaTabControl;
|
||||
lTabPage: TCocoaTabPage;
|
||||
begin
|
||||
{$IFDEF COCOA_DEBUG_TABCONTROL}
|
||||
WriteLn('[TCocoaWSCustomTabControl.AddPage] AChild='+IntToStr(PtrInt(AChild)));
|
||||
{$ENDIF}
|
||||
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
|
||||
lTabControl := TCocoaTabControl(ATabControl.Handle);
|
||||
AChild.HandleNeeded();
|
||||
if not Assigned(AChild) or not AChild.HandleAllocated then Exit;
|
||||
lTabPage := TCocoaTabPage(AChild.Handle);
|
||||
|
||||
lTabControl.insertTabViewItem_atIndex(lTabPage, AIndex);
|
||||
{$IFDEF COCOA_DEBUG_TABCONTROL}
|
||||
WriteLn('[TCocoaWSCustomTabControl.AddPage] END');
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomTabControl.MovePage(const ATabControl: TCustomTabControl; const AChild: TCustomPage; const NewIndex: integer);
|
||||
@ -243,6 +279,7 @@ var
|
||||
begin
|
||||
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
|
||||
lTabControl := TCocoaTabControl(ATabControl.Handle);
|
||||
AChild.HandleNeeded();
|
||||
if not Assigned(AChild) or not AChild.HandleAllocated then Exit;
|
||||
lTabPage := TCocoaTabPage(AChild.Handle);
|
||||
|
||||
@ -282,12 +319,18 @@ var
|
||||
lTabControl: TCocoaTabControl;
|
||||
lTabCount: NSInteger;
|
||||
begin
|
||||
//WriteLn('[TCocoaWSCustomTabControl.SetPageIndex]');
|
||||
{$IFDEF COCOA_DEBUG_TABCONTROL}
|
||||
WriteLn('[TCocoaWSCustomTabControl.SetPageIndex]');
|
||||
{$ENDIF}
|
||||
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
|
||||
lTabControl := TCocoaTabControl(ATabControl.Handle);
|
||||
//WriteLn(Format('[TCocoaWSCustomTabControl.SetPageIndex] lTabControl=%d', [PtrUInt(lTabControl)]));
|
||||
{$IFDEF COCOA_DEBUG_TABCONTROL}
|
||||
WriteLn(Format('[TCocoaWSCustomTabControl.SetPageIndex] lTabControl=%d', [PtrUInt(lTabControl)]));
|
||||
{$ENDIF}
|
||||
lTabCount := lTabControl.numberOfTabViewItems();
|
||||
//WriteLn(Format('[TCocoaWSCustomTabControl.SetPageIndex] lTabCount=%d', [lTabCount]));
|
||||
{$IFDEF COCOA_DEBUG_TABCONTROL}
|
||||
WriteLn(Format('[TCocoaWSCustomTabControl.SetPageIndex] lTabCount=%d', [lTabCount]));
|
||||
{$ENDIF}
|
||||
if (AIndex < 0) or (AIndex >= lTabCount) then Exit;
|
||||
|
||||
lTabControl.selectTabViewItemAtIndex(AIndex);
|
||||
|
@ -831,7 +831,7 @@ begin
|
||||
begin
|
||||
FIsEventRouting:=true;
|
||||
// debugln(Target.name+' -> '+targetControl.Name+'- is parent:'+dbgs(targetControl=Target.Parent)+' Point: '+dbgs(mp)+' Rect'+dbgs(rect));
|
||||
obj:=NSView(targetControl.Handle);
|
||||
obj := GetNSObjectView(NSObject(targetControl.Handle));
|
||||
callback:=obj.lclGetCallback;
|
||||
result:=callback.MouseMove(Event);
|
||||
FIsEventRouting:=false;
|
||||
@ -1046,13 +1046,8 @@ var
|
||||
View: NSView;
|
||||
begin
|
||||
Result := False;
|
||||
if Owner.isKindOfClass_(NSWindow) then
|
||||
View := NSwindow(Owner).contentView
|
||||
else
|
||||
if Owner.isKindOfClass_(NSView) then
|
||||
View := NSView(Owner)
|
||||
else
|
||||
Exit;
|
||||
View := CocoaUtils.GetNSObjectView(Owner);
|
||||
if View = nil then Exit;
|
||||
if not (csDesigning in Target.ComponentState) then
|
||||
begin
|
||||
ACursor := Screen.Cursor;
|
||||
|
@ -165,8 +165,7 @@ end;
|
||||
|
||||
function RegisterPageControl: Boolean; alias : 'WSRegisterPageControl';
|
||||
begin
|
||||
RegisterWSComponent(TCustomTabControl, TCocoaWSCustomTabControl);
|
||||
Result := True;
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function RegisterCustomListView: Boolean; alias : 'WSRegisterCustomListView';
|
||||
@ -338,7 +337,8 @@ end;
|
||||
|
||||
function RegisterCustomNotebook: Boolean; alias : 'WSRegisterCustomNotebook';
|
||||
begin
|
||||
Result := False;
|
||||
RegisterWSComponent(TCustomTabControl, TCocoaWSCustomTabControl);
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function RegisterShape: Boolean; alias : 'WSRegisterShape';
|
||||
|
Loading…
Reference in New Issue
Block a user