mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 22:19:12 +02:00
MG: fixed get widget position for inherited gdkwindows
git-svn-id: trunk@804 -
This commit is contained in:
parent
a5013f860e
commit
9279e80775
@ -790,30 +790,59 @@ begin
|
|||||||
Result := TObject(gtk_object_get_data(Widget, 'LCLHiddenClass'));
|
Result := TObject(gtk_object_get_data(Widget, 'LCLHiddenClass'));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{-------------------------------------------------------------------------------
|
||||||
|
GetWidgetScreenPos
|
||||||
|
|
||||||
|
Returns the absolute left top position of a widget on the screen.
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
function GetWidgetOrigin(TheWidget: PGtkWidget): TPoint;
|
||||||
|
var
|
||||||
|
TheWindow: PGdkWindow;
|
||||||
|
begin
|
||||||
|
TheWindow:=TheWidget^.Window;
|
||||||
|
gdk_window_get_origin(TheWindow,@Result.X,@Result.Y);
|
||||||
|
// check if the gdkwindow is the clientwindow of the parent
|
||||||
|
if gtk_widget_get_parent_window(TheWidget)=TheWindow then begin
|
||||||
|
// the widget is using its parent window
|
||||||
|
// -> adjust the coordinates
|
||||||
|
inc(Result.X,TheWidget^.Allocation.X);
|
||||||
|
inc(Result.Y,TheWidget^.Allocation.Y);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{-------------------------------------------------------------------------------
|
||||||
|
GetWidgetClientScreenPos
|
||||||
|
|
||||||
|
Returns the absolute left top position of a widget's client area
|
||||||
|
on the screen.
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
function GetWidgetClientOrigin(TheWidget: PGtkWidget): TPoint;
|
||||||
|
var
|
||||||
|
ClientWidget: PGtkWidget;
|
||||||
|
begin
|
||||||
|
ClientWidget:=GetFixedWidget(TheWidget);
|
||||||
|
if ClientWidget<>nil then begin
|
||||||
|
gdk_window_get_origin(ClientWidget^.Window,@Result.X,@Result.Y);
|
||||||
|
end else begin
|
||||||
|
Result:=GetWidgetOrigin(TheWidget);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
{-------------------------------------------------------------------------------
|
||||||
TranslateGdkPointToClientArea
|
TranslateGdkPointToClientArea
|
||||||
|
|
||||||
Translates SourcePos relative to SourceWindow to a coordinate relative to the
|
Translates SourcePos relative to SourceWindow to a coordinate relative to the
|
||||||
client area of the DestinationWidget.
|
client area of the LCL WinControl.
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
function TranslateGdkPointToClientArea(SourceWindow: PGdkWindow;
|
function TranslateGdkPointToClientArea(SourceWindow: PGdkWindow;
|
||||||
SourcePos: TPoint;
|
SourcePos: TPoint; DestinationWidget: PGtkWidget): TPoint;
|
||||||
DestinationWidget: PGtkWidget): TPoint;
|
|
||||||
var
|
var
|
||||||
SrcWindowOrigin: TPoint;
|
SrcWindowOrigin: TPoint;
|
||||||
ClientWidget: PGtkWidget;
|
|
||||||
ClientAreaWindow: PGdkWindow;
|
|
||||||
ClientAreaWindowOrigin: TPoint;
|
ClientAreaWindowOrigin: TPoint;
|
||||||
Src2ClientAreaVector: TPoint;
|
Src2ClientAreaVector: TPoint;
|
||||||
begin
|
begin
|
||||||
gdk_window_get_origin(SourceWindow,@SrcWindowOrigin.X,@SrcWindowOrigin.Y);
|
gdk_window_get_origin(SourceWindow,@SrcWindowOrigin.X,@SrcWindowOrigin.Y);
|
||||||
ClientWidget:=GetFixedWidget(DestinationWidget);
|
ClientAreaWindowOrigin:=GetWidgetClientOrigin(DestinationWidget);
|
||||||
if ClientWidget<>nil then
|
|
||||||
ClientAreaWindow:=ClientWidget^.Window
|
|
||||||
else
|
|
||||||
ClientAreaWindow:=DestinationWidget^.Window;
|
|
||||||
gdk_window_get_origin(ClientAreaWindow,
|
|
||||||
@ClientAreaWindowOrigin.X,@ClientAreaWindowOrigin.Y);
|
|
||||||
Src2ClientAreaVector.X:=ClientAreaWindowOrigin.X-SrcWindowOrigin.X;
|
Src2ClientAreaVector.X:=ClientAreaWindowOrigin.X-SrcWindowOrigin.X;
|
||||||
Src2ClientAreaVector.Y:=ClientAreaWindowOrigin.Y-SrcWindowOrigin.Y;
|
Src2ClientAreaVector.Y:=ClientAreaWindowOrigin.Y-SrcWindowOrigin.Y;
|
||||||
Result.X:=SourcePos.X-Src2ClientAreaVector.X;
|
Result.X:=SourcePos.X-Src2ClientAreaVector.X;
|
||||||
@ -1637,6 +1666,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.54 2002/07/23 07:40:52 lazarus
|
||||||
|
MG: fixed get widget position for inherited gdkwindows
|
||||||
|
|
||||||
Revision 1.53 2002/07/20 13:47:04 lazarus
|
Revision 1.53 2002/07/20 13:47:04 lazarus
|
||||||
MG: fixed eventmask for realized windows
|
MG: fixed eventmask for realized windows
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user