mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 19:02:31 +02:00
Qt5,Qt6: fixed designing on scrolled forms. issue #41517
(cherry picked from commit 9de7888945
)
Co-authored-by: zeljan1 <zeljko@holobit.hr>
This commit is contained in:
parent
991f69be70
commit
7e3817c7c0
@ -290,11 +290,15 @@ var
|
|||||||
QtDC: TQtDeviceContext absolute DC;
|
QtDC: TQtDeviceContext absolute DC;
|
||||||
X, Y: Integer;
|
X, Y: Integer;
|
||||||
W, H: Integer;
|
W, H: Integer;
|
||||||
|
P: TPoint;
|
||||||
begin
|
begin
|
||||||
if not IsValidDC(DC) then
|
if not IsValidDC(DC) then
|
||||||
exit;
|
exit;
|
||||||
QtDC.save;
|
QtDC.save;
|
||||||
try
|
try
|
||||||
|
P := Point(0, 0);
|
||||||
|
SetWindowOrgEx(DC, 0, 0, @P);
|
||||||
|
|
||||||
W := (R.Right - R.Left - 1) div DX;
|
W := (R.Right - R.Left - 1) div DX;
|
||||||
H := (R.Bottom - R.Top - 1) div DY;
|
H := (R.Bottom - R.Top - 1) div DY;
|
||||||
|
|
||||||
|
@ -20186,8 +20186,15 @@ begin
|
|||||||
Msg.PaintStruct^.hdc := FDesignContext;
|
Msg.PaintStruct^.hdc := FDesignContext;
|
||||||
|
|
||||||
P := getClientOffset;
|
P := getClientOffset;
|
||||||
|
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
inc(P.X, -ScrollArea.horizontalScrollBar.getValue);
|
||||||
|
inc(P.Y, -ScrollArea.verticalScrollBar.getValue);
|
||||||
|
{$ELSE}
|
||||||
inc(P.X, FScrollX);
|
inc(P.X, FScrollX);
|
||||||
inc(P.Y, FScrollY);
|
inc(P.Y, FScrollY);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
TQtDeviceContext(Msg.DC).translate(P.X, P.Y);
|
TQtDeviceContext(Msg.DC).translate(P.X, P.Y);
|
||||||
|
|
||||||
// send paint message
|
// send paint message
|
||||||
@ -20229,9 +20236,13 @@ var
|
|||||||
begin
|
begin
|
||||||
if FDesignControl = nil then
|
if FDesignControl = nil then
|
||||||
Exit;
|
Exit;
|
||||||
// FDesignControl must be same as form area,
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
// since we use QWidget, not QMainWindow in design time.
|
QWidget_contentsRect(ScrollArea.viewportWidget, @R);
|
||||||
|
R.Width := R.Width + ScrollArea.horizontalScrollBar.getMax;
|
||||||
|
R.Height := R.Height + ScrollArea.verticalScrollBar.getMax;
|
||||||
|
{$ELSE}
|
||||||
QWidget_contentsRect(Widget, @R);
|
QWidget_contentsRect(Widget, @R);
|
||||||
|
{$ENDIF}
|
||||||
with R do
|
with R do
|
||||||
begin
|
begin
|
||||||
QWidget_move(FDesignControl, Left, Top);
|
QWidget_move(FDesignControl, Left, Top);
|
||||||
@ -20381,9 +20392,7 @@ begin
|
|||||||
{$IFDEF QTSCROLLABLEFORMS}
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
else
|
else
|
||||||
if (aWidget is TQtWindowArea) then
|
if (aWidget is TQtWindowArea) then
|
||||||
begin
|
|
||||||
TQtWindowArea(aWidget).scroll(XStep, YStep);
|
TQtWindowArea(aWidget).scroll(XStep, YStep);
|
||||||
end;
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
@ -20469,7 +20478,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
QEventPaint: SlotDesignControlPaint(Sender, Event);
|
QEventPaint:
|
||||||
|
begin
|
||||||
|
SlotDesignControlPaint(Sender, Event);
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
QEventContextMenu: SlotContextMenu(Sender, Event);
|
QEventContextMenu: SlotContextMenu(Sender, Event);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
|
@ -2820,7 +2820,8 @@ function TQtWidgetSet.GetDCOriginRelativeToWindow(PaintDC: HDC;
|
|||||||
var
|
var
|
||||||
QtDC: TQtDeviceContext absolute PaintDC;
|
QtDC: TQtDeviceContext absolute PaintDC;
|
||||||
Matrix: QTransformH;
|
Matrix: QTransformH;
|
||||||
P: TPoint;
|
DCScreenOrigin, P: TPoint;
|
||||||
|
Pt1, Pt2: TQtPoint;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQtWinAPI}
|
{$ifdef VerboseQtWinAPI}
|
||||||
WriteLn('[WinAPI GetDCOriginRelativeToWindow] PaintDC ' + dbghex(PaintDC));
|
WriteLn('[WinAPI GetDCOriginRelativeToWindow] PaintDC ' + dbghex(PaintDC));
|
||||||
@ -2831,13 +2832,26 @@ begin
|
|||||||
Matrix := QPainter_transform(QtDC.Widget);
|
Matrix := QPainter_transform(QtDC.Widget);
|
||||||
OriginDiff := Point(0, 0);
|
OriginDiff := Point(0, 0);
|
||||||
P := Point(0, 0);
|
P := Point(0, 0);
|
||||||
|
DCScreenOrigin := Point(0, 0);
|
||||||
|
if (QtDC.Parent <> nil) then
|
||||||
|
begin
|
||||||
|
Pt2.X := 0;
|
||||||
|
Pt2.y := 0;
|
||||||
|
QWidget_mapToGlobal(QtDC.Parent, @Pt1, @Pt2);
|
||||||
|
DCScreenOrigin.X := Pt1.X;
|
||||||
|
DCScreenOrigin.Y := Pt1.Y;
|
||||||
|
end;
|
||||||
if WindowHandle <> 0 then
|
if WindowHandle <> 0 then
|
||||||
|
begin
|
||||||
P := TQtWidget(WindowHandle).getClientOffset;
|
P := TQtWidget(WindowHandle).getClientOffset;
|
||||||
|
P := TQtWidget(WindowHandle).MapToGlobal(P, False);
|
||||||
|
end;
|
||||||
if Matrix <> nil then
|
if Matrix <> nil then
|
||||||
begin
|
begin
|
||||||
OriginDiff.X := Round(QTransform_Dx(Matrix)) - P.X;
|
OriginDiff.X := DCScreenOrigin.X - P.X;
|
||||||
OriginDiff.Y := Round(QTransform_Dy(Matrix)) - P.Y;
|
OriginDiff.Y := DCScreenOrigin.Y - P.Y;
|
||||||
end;
|
end;
|
||||||
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
@ -290,11 +290,15 @@ var
|
|||||||
QtDC: TQtDeviceContext absolute DC;
|
QtDC: TQtDeviceContext absolute DC;
|
||||||
X, Y: Integer;
|
X, Y: Integer;
|
||||||
W, H: Integer;
|
W, H: Integer;
|
||||||
|
P: TPoint;
|
||||||
begin
|
begin
|
||||||
if not IsValidDC(DC) then
|
if not IsValidDC(DC) then
|
||||||
exit;
|
exit;
|
||||||
QtDC.save;
|
QtDC.save;
|
||||||
try
|
try
|
||||||
|
P := Point(0, 0);
|
||||||
|
SetWindowOrgEx(DC, 0, 0, @P);
|
||||||
|
|
||||||
W := (R.Right - R.Left - 1) div DX;
|
W := (R.Right - R.Left - 1) div DX;
|
||||||
H := (R.Bottom - R.Top - 1) div DY;
|
H := (R.Bottom - R.Top - 1) div DY;
|
||||||
|
|
||||||
|
@ -20107,8 +20107,15 @@ begin
|
|||||||
Msg.PaintStruct^.hdc := FDesignContext;
|
Msg.PaintStruct^.hdc := FDesignContext;
|
||||||
|
|
||||||
P := getClientOffset;
|
P := getClientOffset;
|
||||||
|
|
||||||
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
|
inc(P.X, -ScrollArea.horizontalScrollBar.getValue);
|
||||||
|
inc(P.Y, -ScrollArea.verticalScrollBar.getValue);
|
||||||
|
{$ELSE}
|
||||||
inc(P.X, FScrollX);
|
inc(P.X, FScrollX);
|
||||||
inc(P.Y, FScrollY);
|
inc(P.Y, FScrollY);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
TQtDeviceContext(Msg.DC).translate(P.X, P.Y);
|
TQtDeviceContext(Msg.DC).translate(P.X, P.Y);
|
||||||
|
|
||||||
// send paint message
|
// send paint message
|
||||||
@ -20150,9 +20157,13 @@ var
|
|||||||
begin
|
begin
|
||||||
if FDesignControl = nil then
|
if FDesignControl = nil then
|
||||||
Exit;
|
Exit;
|
||||||
// FDesignControl must be same as form area,
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
// since we use QWidget, not QMainWindow in design time.
|
QWidget_contentsRect(ScrollArea.viewportWidget, @R);
|
||||||
|
R.Width := R.Width + ScrollArea.horizontalScrollBar.getMax;
|
||||||
|
R.Height := R.Height + ScrollArea.verticalScrollBar.getMax;
|
||||||
|
{$ELSE}
|
||||||
QWidget_contentsRect(Widget, @R);
|
QWidget_contentsRect(Widget, @R);
|
||||||
|
{$ENDIF}
|
||||||
with R do
|
with R do
|
||||||
begin
|
begin
|
||||||
QWidget_move(FDesignControl, Left, Top);
|
QWidget_move(FDesignControl, Left, Top);
|
||||||
@ -20302,9 +20313,7 @@ begin
|
|||||||
{$IFDEF QTSCROLLABLEFORMS}
|
{$IFDEF QTSCROLLABLEFORMS}
|
||||||
else
|
else
|
||||||
if (aWidget is TQtWindowArea) then
|
if (aWidget is TQtWindowArea) then
|
||||||
begin
|
|
||||||
TQtWindowArea(aWidget).scroll(XStep, YStep);
|
TQtWindowArea(aWidget).scroll(XStep, YStep);
|
||||||
end;
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
@ -20390,7 +20399,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
QEventPaint: SlotDesignControlPaint(Sender, Event);
|
QEventPaint:
|
||||||
|
begin
|
||||||
|
SlotDesignControlPaint(Sender, Event);
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
QEventContextMenu: SlotContextMenu(Sender, Event);
|
QEventContextMenu: SlotContextMenu(Sender, Event);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
|
@ -2817,7 +2817,8 @@ function TQtWidgetSet.GetDCOriginRelativeToWindow(PaintDC: HDC;
|
|||||||
var
|
var
|
||||||
QtDC: TQtDeviceContext absolute PaintDC;
|
QtDC: TQtDeviceContext absolute PaintDC;
|
||||||
Matrix: QTransformH;
|
Matrix: QTransformH;
|
||||||
P: TPoint;
|
DCScreenOrigin, P: TPoint;
|
||||||
|
Pt1, Pt2: TQtPoint;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQtWinAPI}
|
{$ifdef VerboseQtWinAPI}
|
||||||
WriteLn('[WinAPI GetDCOriginRelativeToWindow] PaintDC ' + dbghex(PaintDC));
|
WriteLn('[WinAPI GetDCOriginRelativeToWindow] PaintDC ' + dbghex(PaintDC));
|
||||||
@ -2828,13 +2829,26 @@ begin
|
|||||||
Matrix := QPainter_transform(QtDC.Widget);
|
Matrix := QPainter_transform(QtDC.Widget);
|
||||||
OriginDiff := Point(0, 0);
|
OriginDiff := Point(0, 0);
|
||||||
P := Point(0, 0);
|
P := Point(0, 0);
|
||||||
|
DCScreenOrigin := Point(0, 0);
|
||||||
|
if (QtDC.Parent <> nil) then
|
||||||
|
begin
|
||||||
|
Pt2.X := 0;
|
||||||
|
Pt2.y := 0;
|
||||||
|
QWidget_mapToGlobal(QtDC.Parent, @Pt1, @Pt2);
|
||||||
|
DCScreenOrigin.X := Pt1.X;
|
||||||
|
DCScreenOrigin.Y := Pt1.Y;
|
||||||
|
end;
|
||||||
if WindowHandle <> 0 then
|
if WindowHandle <> 0 then
|
||||||
|
begin
|
||||||
P := TQtWidget(WindowHandle).getClientOffset;
|
P := TQtWidget(WindowHandle).getClientOffset;
|
||||||
|
P := TQtWidget(WindowHandle).MapToGlobal(P, False);
|
||||||
|
end;
|
||||||
if Matrix <> nil then
|
if Matrix <> nil then
|
||||||
begin
|
begin
|
||||||
OriginDiff.X := Round(QTransform_Dx(Matrix)) - P.X;
|
OriginDiff.X := DCScreenOrigin.X - P.X;
|
||||||
OriginDiff.Y := Round(QTransform_Dy(Matrix)) - P.Y;
|
OriginDiff.Y := DCScreenOrigin.Y - P.Y;
|
||||||
end;
|
end;
|
||||||
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user