mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 10:59:29 +02:00
Qt: pascalified mapToGlobal() and mapFromGlobal()
git-svn-id: trunk@34151 -
This commit is contained in:
parent
c7d4748e81
commit
f45d3703b2
@ -255,6 +255,8 @@ type
|
||||
function isFullScreen: Boolean;
|
||||
function IsWindow: Boolean;
|
||||
procedure lowerWidget; virtual;
|
||||
function MapToGlobal(APt: TPoint; const AWithScrollOffset: Boolean = False): TPoint; virtual;
|
||||
function MapFromGlobal(APt: TPoint; const AWithScrollOffset: Boolean = False): TPoint; virtual;
|
||||
procedure move(ANewLeft, ANewTop: Integer); virtual;
|
||||
procedure preferredSize(var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); virtual;
|
||||
procedure raiseWidget; virtual;
|
||||
@ -451,6 +453,8 @@ type
|
||||
public
|
||||
function CanAdjustClientRectOnResize: Boolean; override;
|
||||
function cornerWidget: TQtWidget;
|
||||
function MapToGlobal(APt: TPoint; const AWithScrollOffset: Boolean = False): TPoint; override;
|
||||
function MapFromGlobal(APt: TPoint; const AWithScrollOffset: Boolean = False): TPoint; override;
|
||||
function viewport: TQtViewPort;
|
||||
procedure preferredSize(var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;
|
||||
procedure setCornerWidget(AWidget: TQtWidget);
|
||||
@ -4006,6 +4010,24 @@ begin
|
||||
QWidget_lower(Widget);
|
||||
end;
|
||||
|
||||
function TQtWidget.MapToGlobal(APt: TPoint;
|
||||
const AWithScrollOffset: Boolean = False): TPoint;
|
||||
var
|
||||
Pt: TQtPoint;
|
||||
begin
|
||||
Pt := QtPoint(APt.X, APt.Y);
|
||||
QWidget_mapToGlobal(GetContainerWidget, @Result, @Pt);
|
||||
end;
|
||||
|
||||
function TQtWidget.MapFromGlobal(APt: TPoint;
|
||||
const AWithScrollOffset: Boolean = False): TPoint;
|
||||
var
|
||||
Pt: TQtPoint;
|
||||
begin
|
||||
Pt := QtPoint(APt.X, APt.Y);
|
||||
QWidget_mapFromGlobal(GetContainerWidget, @Result, @Pt);
|
||||
end;
|
||||
|
||||
procedure TQtWidget.move(ANewLeft, ANewTop: Integer);
|
||||
begin
|
||||
QWidget_move(Widget, ANewLeft, ANewTop);
|
||||
@ -13571,6 +13593,27 @@ begin
|
||||
Result := FCornerWidget;
|
||||
end;
|
||||
|
||||
function TQtCustomControl.MapToGlobal(APt: TPoint;
|
||||
const AWithScrollOffset: Boolean = False): TPoint;
|
||||
var
|
||||
Pt: TPoint;
|
||||
begin
|
||||
Result := inherited MapToGlobal(APt);
|
||||
if AWithScrollOffset and (ChildOfComplexWidget = ccwScrollingWinControl) then
|
||||
begin
|
||||
Pt := viewport.ScrolledOffset;
|
||||
dec(Result.X, Pt.X);
|
||||
dec(Result.Y, Pt.Y);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TQtCustomControl.MapFromGlobal(APt: TPoint;
|
||||
const AWithScrollOffset: Boolean = False): TPoint;
|
||||
begin
|
||||
//TODO: see what to do with ccwScrollingWinControl
|
||||
Result := inherited MapFromGlobal(APt);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: TQtCustomControl.setCornerWidget
|
||||
Params: TQtWidget
|
||||
|
@ -158,18 +158,7 @@ var
|
||||
begin
|
||||
Result := IsValidHandle(Handle);
|
||||
if Result then
|
||||
begin
|
||||
APoint := QtPoint(P.X, P.Y);
|
||||
|
||||
QWidget_mapToGlobal(TQtWidget(Handle).GetContainerWidget, @APoint, @APoint);
|
||||
if TQtWidget(Handle).ChildOfComplexWidget = ccwScrollingWinControl then
|
||||
begin
|
||||
Pt := TQtCustomControl(Handle).viewport.ScrolledOffset;
|
||||
dec(APoint.X, Pt.X);
|
||||
dec(APoint.Y, Pt.Y);
|
||||
end;
|
||||
P := Point(APoint.x, APoint.y);
|
||||
end;
|
||||
P := TQtWidget(Handle).MapToGlobal(P, True);
|
||||
end;
|
||||
|
||||
|
||||
@ -5168,9 +5157,7 @@ begin
|
||||
Result := 0;
|
||||
if IsValidHandle(Handle) then
|
||||
begin
|
||||
APoint := QtPoint(P.X, P.Y);
|
||||
QWidget_mapFromGlobal(TQtWidget(Handle).GetContainerWidget, @APoint, @APoint);
|
||||
P := Point(APoint.x, APoint.y);
|
||||
P := TQtWidget(Handle).MapFromGlobal(P);
|
||||
Result := 1;
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user