mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-18 14:59:15 +02:00
cocoa: Fixes the display of controls in tabs
git-svn-id: trunk@44864 -
This commit is contained in:
parent
580048e97c
commit
594e1f2069
@ -17,6 +17,7 @@ unit CocoaPrivate;
|
|||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
{$modeswitch objectivec1}
|
{$modeswitch objectivec1}
|
||||||
{$interfaces corba}
|
{$interfaces corba}
|
||||||
|
{.$DEFINE COCOA_DEBUG_SETBOUNDS}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ uses
|
|||||||
// Libs
|
// Libs
|
||||||
MacOSAll, CocoaAll, CocoaUtils, CocoaGDIObjects,
|
MacOSAll, CocoaAll, CocoaUtils, CocoaGDIObjects,
|
||||||
// LCL
|
// LCL
|
||||||
|
LMessages, LCLMessageGlue,
|
||||||
LCLType, LCLProc, Controls, ComCtrls;
|
LCLType, LCLProc, Controls, ComCtrls;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -530,12 +532,22 @@ type
|
|||||||
LCLPage: TCustomPage;
|
LCLPage: TCustomPage;
|
||||||
function lclGetCallback: ICommonCallback; override;
|
function lclGetCallback: ICommonCallback; override;
|
||||||
procedure lclClearCallback; override;
|
procedure lclClearCallback; override;
|
||||||
|
function lclFrame: TRect; override;
|
||||||
|
function lclClientFrame: TRect; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCocoaTabControl = objcclass(NSTabView)
|
{ TCocoaTabControl }
|
||||||
|
|
||||||
|
TCocoaTabControl = objcclass(NSTabView, NSTabViewDelegateProtocol)
|
||||||
|
LCLPageControl: TCustomTabControl;
|
||||||
callback: ICommonCallback;
|
callback: ICommonCallback;
|
||||||
function lclGetCallback: ICommonCallback; override;
|
function lclGetCallback: ICommonCallback; override;
|
||||||
procedure lclClearCallback; override;
|
procedure lclClearCallback; override;
|
||||||
|
// NSTabViewDelegateProtocol
|
||||||
|
function tabView_shouldSelectTabViewItem(tabView: NSTabView; tabViewItem: NSTabViewItem): Boolean; message 'tabView:shouldSelectTabViewItem:';
|
||||||
|
procedure tabView_willSelectTabViewItem(tabView: NSTabView; tabViewItem: NSTabViewItem); message 'tabView:willSelectTabViewItem:';
|
||||||
|
procedure tabView_didSelectTabViewItem(tabView: NSTabView; tabViewItem: NSTabViewItem); message 'tabView:didSelectTabViewItem:';
|
||||||
|
procedure tabViewDidChangeNumberOfTabViewItems(TabView: NSTabView); message 'tabViewDidChangeNumberOfTabViewItems:';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCocoaTabPageView = objcclass(NSView)
|
TCocoaTabPageView = objcclass(NSView)
|
||||||
@ -1752,10 +1764,11 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
pstr := '';
|
pstr := '';
|
||||||
WriteLn(Format('[LCLViewExtension.lclInitWithCreateParams] Class=%s Caption=%s ParentClass=%s ParentClassView=%s rect=%d %d %d %d',
|
WriteLn(Format('[LCLViewExtension.lclInitWithCreateParams] Class=%s Caption=%s ParentClass=%s ParentClassView=%s rect=%d %d %d %d Visible=%d',
|
||||||
[NSStringToString(Self.className), AParams.Caption,
|
[NSStringToString(Self.className), AParams.Caption,
|
||||||
NSStringToString(NSObject(AParams.WndParent).className), pstr,
|
NSStringToString(NSObject(AParams.WndParent).className), pstr,
|
||||||
Round(ns.Origin.x), Round(ns.Origin.y), Round(ns.size.width), Round(ns.size.height)]));
|
Round(ns.Origin.x), Round(ns.Origin.y), Round(ns.size.width), Round(ns.size.height),
|
||||||
|
AParams.Style and WS_VISIBLE]));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
Result := initWithFrame(ns);
|
Result := initWithFrame(ns);
|
||||||
@ -1777,6 +1790,10 @@ end;
|
|||||||
procedure LCLViewExtension.lclSetVisible(AVisible: Boolean);
|
procedure LCLViewExtension.lclSetVisible(AVisible: Boolean);
|
||||||
begin
|
begin
|
||||||
setHidden(not AVisible);
|
setHidden(not AVisible);
|
||||||
|
{$IFDEF COCOA_DEBUG_SETBOUNDS}
|
||||||
|
WriteLn(Format('LCLViewExtension.lclSetVisible: %s AVisible=%d',
|
||||||
|
[NSStringToString(Self.ClassName), Integer(AVisible)]));
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LCLViewExtension.lclIsPainting: Boolean;
|
function LCLViewExtension.lclIsPainting: Boolean;
|
||||||
@ -1864,7 +1881,9 @@ var
|
|||||||
begin
|
begin
|
||||||
svHeight := GetNSViewSuperViewHeight(Self);
|
svHeight := GetNSViewSuperViewHeight(Self);
|
||||||
if Assigned(superview) then
|
if Assigned(superview) then
|
||||||
|
begin
|
||||||
LCLToNSRect(r, svHeight, ns)
|
LCLToNSRect(r, svHeight, ns)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
ns := RectToNSRect(r);
|
ns := RectToNSRect(r);
|
||||||
{$IFDEF COCOA_DEBUG_SETBOUNDS}
|
{$IFDEF COCOA_DEBUG_SETBOUNDS}
|
||||||
@ -2189,6 +2208,20 @@ begin
|
|||||||
callback := nil;
|
callback := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCocoaTabPage.lclFrame: TRect;
|
||||||
|
var
|
||||||
|
svh: CGFloat;
|
||||||
|
begin
|
||||||
|
svh := tabView.frame.size.height;
|
||||||
|
NSToLCLRect(tabView.contentRect, svh, Result);
|
||||||
|
//WriteLn('[TCocoaTabPage.lclFrame] '+dbgs(Result)+' '+NSStringToString(Self.label_));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCocoaTabPage.lclClientFrame: TRect;
|
||||||
|
begin
|
||||||
|
Result := lclFrame();
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCocoaTabControl }
|
{ TCocoaTabControl }
|
||||||
|
|
||||||
function TCocoaTabControl.lclGetCallback: ICommonCallback;
|
function TCocoaTabControl.lclGetCallback: ICommonCallback;
|
||||||
@ -2201,6 +2234,58 @@ begin
|
|||||||
callback := nil;
|
callback := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCocoaTabControl.tabView_shouldSelectTabViewItem(tabView: NSTabView;
|
||||||
|
tabViewItem: NSTabViewItem): Boolean;
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaTabControl.tabView_willSelectTabViewItem(tabView: NSTabView;
|
||||||
|
tabViewItem: NSTabViewItem);
|
||||||
|
var
|
||||||
|
Msg: TLMNotify;
|
||||||
|
Hdr: TNmHdr;
|
||||||
|
begin
|
||||||
|
if LCLPageControl = nil then Exit;
|
||||||
|
|
||||||
|
FillChar(Msg, SizeOf(Msg), 0);
|
||||||
|
Msg.Msg := LM_NOTIFY;
|
||||||
|
FillChar(Hdr, SizeOf(Hdr), 0);
|
||||||
|
|
||||||
|
Hdr.hwndFrom := HWND(tabview);
|
||||||
|
Hdr.Code := TCN_SELCHANGING;
|
||||||
|
Hdr.idFrom := PtrUInt(tabview.indexOfTabViewItem(tabViewItem));
|
||||||
|
Msg.NMHdr := @Hdr;
|
||||||
|
Msg.Result := 0;
|
||||||
|
LCLMessageGlue.DeliverMessage(LCLPageControl, Msg);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaTabControl.tabView_didSelectTabViewItem(tabView: NSTabView;
|
||||||
|
tabViewItem: NSTabViewItem);
|
||||||
|
var
|
||||||
|
Msg: TLMNotify;
|
||||||
|
Hdr: TNmHdr;
|
||||||
|
begin
|
||||||
|
if LCLPageControl = nil then Exit;
|
||||||
|
|
||||||
|
FillChar(Msg, SizeOf(Msg), 0);
|
||||||
|
Msg.Msg := LM_NOTIFY;
|
||||||
|
FillChar(Hdr, SizeOf(Hdr), 0);
|
||||||
|
|
||||||
|
Hdr.hwndFrom := HWND(tabview);
|
||||||
|
Hdr.Code := TCN_SELCHANGE;
|
||||||
|
Hdr.idFrom := PtrUInt(tabview.indexOfTabViewItem(tabViewItem));
|
||||||
|
Msg.NMHdr := @Hdr;
|
||||||
|
Msg.Result := 0;
|
||||||
|
LCLMessageGlue.DeliverMessage(LCLPageControl, Msg);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaTabControl.tabViewDidChangeNumberOfTabViewItems(
|
||||||
|
TabView: NSTabView);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCocoaTableListView }
|
{ TCocoaTableListView }
|
||||||
|
|
||||||
function TCocoaTableListView.lclIsHandle: Boolean;
|
function TCocoaTableListView.lclIsHandle: Boolean;
|
||||||
|
@ -249,6 +249,8 @@ begin
|
|||||||
if Result <> 0 then
|
if Result <> 0 then
|
||||||
begin
|
begin
|
||||||
lControl.callback := TLCLCommonCallback.Create(lControl, AWinControl);
|
lControl.callback := TLCLCommonCallback.Create(lControl, AWinControl);
|
||||||
|
lControl.LCLPageControl := TCustomTabControl(AWinControl);
|
||||||
|
lControl.setDelegate(lControl);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ unit CocoaWSCommon;
|
|||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
{$modeswitch objectivec1}
|
{$modeswitch objectivec1}
|
||||||
|
{.$DEFINE COCOA_DEBUG_SETBOUNDS}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
@ -1269,14 +1270,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TCocoaWSWinControl.ShowHide(const AWinControl: TWinControl);
|
class procedure TCocoaWSWinControl.ShowHide(const AWinControl: TWinControl);
|
||||||
var pool: NSAutoreleasePool; // called outside apploop on startup - therefore has to be enframed by pool
|
var
|
||||||
|
pool: NSAutoreleasePool; // called outside apploop on startup - therefore has to be enframed by pool
|
||||||
begin
|
begin
|
||||||
|
//WriteLn(Format('[TCocoaWSWinControl.ShowHide] AWinControl=%s %s', [AWinControl.Name, AWinControl.ClassName]));
|
||||||
if AWinControl.HandleAllocated then
|
if AWinControl.HandleAllocated then
|
||||||
begin
|
begin
|
||||||
pool := NSAutoreleasePool.alloc.init;
|
pool := NSAutoreleasePool.alloc.init;
|
||||||
NSObject(AWinControl.Handle).lclSetVisible(AWinControl.HandleObjectShouldBeVisible);
|
NSObject(AWinControl.Handle).lclSetVisible(AWinControl.HandleObjectShouldBeVisible);
|
||||||
pool.release;
|
pool.release;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TCocoaWSWinControl.Invalidate(const AWinControl: TWinControl);
|
class procedure TCocoaWSWinControl.Invalidate(const AWinControl: TWinControl);
|
||||||
|
Loading…
Reference in New Issue
Block a user