mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 20:39:15 +02:00
carbon intf: implemented GetWindowSize, GetClientRect, critical sections
git-svn-id: trunk@9531 -
This commit is contained in:
parent
187e308562
commit
67968958f1
@ -107,7 +107,7 @@ begin
|
|||||||
|
|
||||||
// create LCL WidgetInfo
|
// create LCL WidgetInfo
|
||||||
Result:=HWnd(Control);
|
Result:=HWnd(Control);
|
||||||
Info := CreateWidgetInfo(Control, AWinControl);
|
Info := CreateWidgetInfo(Control, AWinControl, cwtControlRef);
|
||||||
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
||||||
|
|
||||||
// create the AGL context
|
// create the AGL context
|
||||||
|
@ -42,11 +42,14 @@ var
|
|||||||
WIDGETINFO_FOURCC: FourCharCode; // = 'WInf';
|
WIDGETINFO_FOURCC: FourCharCode; // = 'WInf';
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TCarbonWidgetType = (cwtWindowRef, cwtControlRef);
|
||||||
|
|
||||||
// Info needed by the API of a HWND (=Widget)
|
// Info needed by the API of a HWND (=Widget)
|
||||||
PWidgetInfo = ^TWidgetInfo;
|
PWidgetInfo = ^TWidgetInfo;
|
||||||
TWidgetInfo = record
|
TWidgetInfo = record
|
||||||
LCLObject: TObject; // the object which created this widget
|
LCLObject: TObject; // the object which created this widget
|
||||||
Widget: Pointer; // Reference to the Carbon window or control
|
Widget: Pointer; // Reference to the Carbon window or control
|
||||||
|
WidgetType: TCarbonWidgetType;
|
||||||
WSClass: TWSLCLComponentClass; // The Widgetsetclass for this info
|
WSClass: TWSLCLComponentClass; // The Widgetsetclass for this info
|
||||||
DataOwner: Boolean; // Set if the UserData should be freed when the info is freed
|
DataOwner: Boolean; // Set if the UserData should be freed when the info is freed
|
||||||
UserData: Pointer;
|
UserData: Pointer;
|
||||||
@ -64,4 +67,4 @@ initialization
|
|||||||
LAZARUS_FOURCC := MakeFourCC('Laz ');
|
LAZARUS_FOURCC := MakeFourCC('Laz ');
|
||||||
WIDGETINFO_FOURCC := MakeFourCC('WInf');
|
WIDGETINFO_FOURCC := MakeFourCC('WInf');
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -34,7 +34,8 @@ uses
|
|||||||
LCLProc, LCLClasses, Controls, LMessages, Forms, Avl_Tree, SysUtils,
|
LCLProc, LCLClasses, Controls, LMessages, Forms, Avl_Tree, SysUtils,
|
||||||
CarbonDef;
|
CarbonDef;
|
||||||
|
|
||||||
function CreateWidgetInfo(AWidget: Pointer; AObject: TLCLComponent): PWidgetInfo;
|
function CreateWidgetInfo(AWidget: Pointer; AObject: TLCLComponent;
|
||||||
|
TheType: TCarbonWidgetType): PWidgetInfo;
|
||||||
procedure FreeWidgetInfo(AInfo: PWidgetInfo);
|
procedure FreeWidgetInfo(AInfo: PWidgetInfo);
|
||||||
function GetWidgetInfo(AWidget: Pointer): PWidgetInfo;
|
function GetWidgetInfo(AWidget: Pointer): PWidgetInfo;
|
||||||
|
|
||||||
@ -52,13 +53,15 @@ function Dbgs(const ARect: FPCMacOSAll.Rect): string; overload;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
function CreateWidgetInfo(AWidget: Pointer; AObject: TLCLComponent): PWidgetInfo;
|
function CreateWidgetInfo(AWidget: Pointer; AObject: TLCLComponent;
|
||||||
|
TheType: TCarbonWidgetType): PWidgetInfo;
|
||||||
begin
|
begin
|
||||||
New(Result);
|
New(Result);
|
||||||
FillChar(Result^, SizeOf(Result^), 0);
|
FillChar(Result^, SizeOf(Result^), 0);
|
||||||
Result^.LCLObject := AObject;
|
Result^.LCLObject := AObject;
|
||||||
Result^.Widget := AWidget;
|
Result^.Widget := AWidget;
|
||||||
Result^.WSClass := AObject.WidgetSetClass;
|
Result^.WSClass := AObject.WidgetSetClass;
|
||||||
|
Result^.widgetType := TheType;
|
||||||
|
|
||||||
if IsValidControlHandle(AWidget)
|
if IsValidControlHandle(AWidget)
|
||||||
then begin
|
then begin
|
||||||
@ -247,4 +250,4 @@ finalization
|
|||||||
if UPPTree <> nil
|
if UPPTree <> nil
|
||||||
then FreeAndNil(UPPTree);
|
then FreeAndNil(UPPTree);
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -190,8 +190,12 @@ end;
|
|||||||
|
|
||||||
procedure TCarbonWidgetSet.DeleteCriticalSection(
|
procedure TCarbonWidgetSet.DeleteCriticalSection(
|
||||||
var CritSection: TCriticalSection);
|
var CritSection: TCriticalSection);
|
||||||
|
var
|
||||||
|
ACritSec: System.PRTLCriticalSection;
|
||||||
begin
|
begin
|
||||||
inherited DeleteCriticalSection(CritSection);
|
ACritSec:=System.PRTLCriticalSection(CritSection);
|
||||||
|
System.DoneCriticalsection(ACritSec^);
|
||||||
|
CritSection:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonWidgetSet.DeleteDC(hDC: HDC): Boolean;
|
function TCarbonWidgetSet.DeleteDC(hDC: HDC): Boolean;
|
||||||
@ -251,8 +255,11 @@ end;
|
|||||||
|
|
||||||
procedure TCarbonWidgetSet.EnterCriticalSection(
|
procedure TCarbonWidgetSet.EnterCriticalSection(
|
||||||
var CritSection: TCriticalSection);
|
var CritSection: TCriticalSection);
|
||||||
|
var
|
||||||
|
ACritSec: System.PRTLCriticalSection;
|
||||||
begin
|
begin
|
||||||
inherited EnterCriticalSection(CritSection);
|
ACritSec:=System.PRTLCriticalSection(CritSection);
|
||||||
|
System.EnterCriticalsection(ACritSec^);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonWidgetSet.ExcludeClipRect(dc: hdc; Left, Top, Right,
|
function TCarbonWidgetSet.ExcludeClipRect(dc: hdc; Left, Top, Right,
|
||||||
@ -585,8 +592,19 @@ end;
|
|||||||
|
|
||||||
function TCarbonWidgetSet.GetWindowSize(Handle: hwnd; var Width, Height: integer
|
function TCarbonWidgetSet.GetWindowSize(Handle: hwnd; var Width, Height: integer
|
||||||
): boolean;
|
): boolean;
|
||||||
|
var
|
||||||
|
AWndRect: FPCMacOSAll.Rect;
|
||||||
|
Info: PWidgetInfo;
|
||||||
begin
|
begin
|
||||||
Result:=inherited GetWindowSize(Handle, Width, Height);
|
Info:=GetWidgetInfo(Pointer(Handle));
|
||||||
|
if Info^.widgetType=cwtWindowRef then begin
|
||||||
|
Result := GetWindowBounds(WindowRef(Handle),kWindowStructureRgn, AWndRect) = 0;
|
||||||
|
end else begin
|
||||||
|
Result := GetControlBounds(ControlRef(Handle), AWndRect) <>nil;
|
||||||
|
end;
|
||||||
|
if not Result then Exit;
|
||||||
|
Width := AWndRect.right-AWndRect.left;
|
||||||
|
Height := AWndRect.bottom-AWndRect.top;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonWidgetSet.GradientFill(DC: HDC; Vertices: PTriVertex;
|
function TCarbonWidgetSet.GradientFill(DC: HDC; Vertices: PTriVertex;
|
||||||
@ -604,8 +622,11 @@ end;
|
|||||||
|
|
||||||
procedure TCarbonWidgetSet.InitializeCriticalSection(
|
procedure TCarbonWidgetSet.InitializeCriticalSection(
|
||||||
var CritSection: TCriticalSection);
|
var CritSection: TCriticalSection);
|
||||||
|
var
|
||||||
|
ACritSec: System.PRTLCriticalSection;
|
||||||
begin
|
begin
|
||||||
inherited InitializeCriticalSection(CritSection);
|
ACritSec:=System.PRTLCriticalSection(CritSection);
|
||||||
|
System.InitCriticalSection(ACritSec^);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonWidgetSet.IntersectClipRect(dc: hdc; Left, Top, Right,
|
function TCarbonWidgetSet.IntersectClipRect(dc: hdc; Left, Top, Right,
|
||||||
@ -628,8 +649,11 @@ end;
|
|||||||
|
|
||||||
procedure TCarbonWidgetSet.LeaveCriticalSection(
|
procedure TCarbonWidgetSet.LeaveCriticalSection(
|
||||||
var CritSection: TCriticalSection);
|
var CritSection: TCriticalSection);
|
||||||
|
var
|
||||||
|
ACritSec: System.PRTLCriticalSection;
|
||||||
begin
|
begin
|
||||||
inherited LeaveCriticalSection(CritSection);
|
ACritSec:=System.PRTLCriticalSection(CritSection);
|
||||||
|
System.LeaveCriticalsection(ACritSec^);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean;
|
function TCarbonWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean;
|
||||||
|
@ -95,7 +95,7 @@ begin
|
|||||||
if Result = 0 then Exit;
|
if Result = 0 then Exit;
|
||||||
|
|
||||||
// add the info (our data, like which TWinControl belong to this carbon widget)
|
// add the info (our data, like which TWinControl belong to this carbon widget)
|
||||||
Info := CreateWidgetInfo(Control, AWinControl);
|
Info := CreateWidgetInfo(Control, AWinControl, cwtControlRef);
|
||||||
|
|
||||||
// register events (e.g. mouse, focus, keyboard, size, ...)
|
// register events (e.g. mouse, focus, keyboard, size, ...)
|
||||||
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
||||||
|
@ -204,13 +204,26 @@ class function TCarbonWSWinControl.GetClientRect(const AWincontrol: TWinControl;
|
|||||||
var ARect: TRect): Boolean;
|
var ARect: TRect): Boolean;
|
||||||
var
|
var
|
||||||
AHiRect: HIRect;
|
AHiRect: HIRect;
|
||||||
|
AWndRect: FPCMacOSAll.Rect;
|
||||||
begin
|
begin
|
||||||
Result := HIViewGetBounds(HIViewRef(AWinControl.Handle), AHiRect) = 0;
|
if (AWinControl is TCustomForm)
|
||||||
if not Result then Exit;
|
and (AWinControl.Parent=nil) then begin
|
||||||
ARect.Top := 0;//AHiRect.Origin.y;
|
Result := GetWindowBounds(WindowRef(AWinControl.Handle),kWindowContentRgn, AWndRect) = 0;
|
||||||
ARect.Left := 0;//AHiRect.Origin.x;
|
if not Result then Exit;
|
||||||
ARect.Right := ARect.Left + Trunc(AHiRect.size.width);
|
ARect.Top := 0;//AHiRect.Origin.y;
|
||||||
ARect.Bottom := ARect.Top + Trunc(AHIRect.size.height);
|
ARect.Left := 0;//AHiRect.Origin.x;
|
||||||
|
ARect.Right := AWndRect.right-AWndRect.left;
|
||||||
|
ARect.Bottom := AWndRect.bottom-AWndRect.top;
|
||||||
|
//debugln(['TCarbonWSWinControl.GetClientRect ',dbgs(ARect)]);
|
||||||
|
end else begin
|
||||||
|
Result := HIViewGetBounds(HIViewRef(AWinControl.Handle), AHiRect) = 0;
|
||||||
|
if not Result then Exit;
|
||||||
|
ARect.Top := 0;//AHiRect.Origin.y;
|
||||||
|
ARect.Left := 0;//AHiRect.Origin.x;
|
||||||
|
ARect.Right := ARect.Left + Trunc(AHiRect.size.width);
|
||||||
|
ARect.Bottom := ARect.Top + Trunc(AHIRect.size.height);
|
||||||
|
//debugln(['TCarbonWSWinControl.GetClientRect ',dbgs(ARect)]);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCarbonWSCustomControl }
|
{ TCarbonWSCustomControl }
|
||||||
@ -239,7 +252,7 @@ begin
|
|||||||
CFRelease(Pointer(CFString));
|
CFRelease(Pointer(CFString));
|
||||||
if Result = 0 then Exit;
|
if Result = 0 then Exit;
|
||||||
|
|
||||||
Info := CreateWidgetInfo(Control, AWinControl);
|
Info := CreateWidgetInfo(Control, AWinControl, cwtControlRef);
|
||||||
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ begin
|
|||||||
SetWindowTitleWithCFString(Window, CFString);
|
SetWindowTitleWithCFString(Window, CFString);
|
||||||
CFRelease(Pointer(CFString));
|
CFRelease(Pointer(CFString));
|
||||||
|
|
||||||
Info := CreateWidgetInfo(Window, AWinControl);
|
Info := CreateWidgetInfo(Window, AWinControl, cwtWindowRef);
|
||||||
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
||||||
|
|
||||||
MinSize.width:=AWinControl.Constraints.EffectiveMinWidth;
|
MinSize.width:=AWinControl.Constraints.EffectiveMinWidth;
|
||||||
|
@ -256,7 +256,7 @@ begin
|
|||||||
SizeOf(Boolean), @SingleLine);
|
SizeOf(Boolean), @SingleLine);
|
||||||
|
|
||||||
|
|
||||||
Info := CreateWidgetInfo(Control, AWinControl);
|
Info := CreateWidgetInfo(Control, AWinControl, cwtControlRef);
|
||||||
Info^.UserData := IsPassword;
|
Info^.UserData := IsPassword;
|
||||||
Info^.DataOwner := True;
|
Info^.DataOwner := True;
|
||||||
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
||||||
@ -476,7 +476,7 @@ begin
|
|||||||
CFRelease(Pointer(CFString));
|
CFRelease(Pointer(CFString));
|
||||||
if Result = 0 then Exit;
|
if Result = 0 then Exit;
|
||||||
|
|
||||||
Info := CreateWidgetInfo(Control, AWinControl);
|
Info := CreateWidgetInfo(Control, AWinControl, cwtControlRef);
|
||||||
|
|
||||||
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
TCarbonPrivateHandleClass(WSPrivate).RegisterEvents(Info);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user