mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 12:36:15 +02:00
Qt5: fixed TWinControl.PaintTo(). issue #36883
git-svn-id: trunk@62902 -
This commit is contained in:
parent
046a3365f5
commit
e25e50dcd3
@ -389,31 +389,18 @@ class procedure TQtWSWinControl.PaintTo(const AWinControl: TWinControl;
|
|||||||
var
|
var
|
||||||
Context: TQtDeviceContext absolute ADC;
|
Context: TQtDeviceContext absolute ADC;
|
||||||
Widget: TQtWidget;
|
Widget: TQtWidget;
|
||||||
Window: TQtMainWindow;
|
|
||||||
DCSize: TSize;
|
DCSize: TSize;
|
||||||
APoint: TQtPoint;
|
APoint: TQtPoint;
|
||||||
ARect, GRect: TRect;
|
ARect: TRect;
|
||||||
OffsetY: Integer;
|
Pixmap: QPixmapH;
|
||||||
Pixmap, NewHandle: QPixmapH;
|
ASourceRegion: QRegionH;
|
||||||
AWidgetID: PtrUInt;
|
AFlags: Integer;
|
||||||
AWindow: QWindowH;
|
|
||||||
AScreen: QScreenH;
|
|
||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(AWincontrol, 'PaintTo') or (ADC = 0) then
|
if not WSCheckHandleAllocated(AWincontrol, 'PaintTo') or (ADC = 0) then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
Widget := TQtWidget(AWinControl.Handle);
|
Widget := TQtWidget(AWinControl.Handle);
|
||||||
ARect := Widget.getFrameGeometry;
|
ARect := Widget.getFrameGeometry;
|
||||||
GRect := Widget.getGeometry;
|
|
||||||
|
|
||||||
// calculate OffsetY only in case when we are form
|
|
||||||
if (AWinControl.FCompStyle = csForm) and Assigned(TCustomForm(AWinControl).Menu) then
|
|
||||||
begin
|
|
||||||
Window := TQtMainWindow(TCustomForm(AWinControl).Handle);
|
|
||||||
if Window.MenuBar.getVisible then
|
|
||||||
OffsetY := Window.MenuBar.getHeight;
|
|
||||||
end else
|
|
||||||
OffsetY := 0;
|
|
||||||
|
|
||||||
with DCSize, ARect do
|
with DCSize, ARect do
|
||||||
begin
|
begin
|
||||||
@ -422,29 +409,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
Pixmap := QPixmap_create(PSize(@DCSize));
|
Pixmap := QPixmap_create(PSize(@DCSize));
|
||||||
try
|
try
|
||||||
OffsetRect(GRect, -ARect.Left, -ARect.Top);
|
APoint := QtPoint(0, 0);
|
||||||
|
ASourceRegion := QRegion_Create(0, 0, DCSize.cx, DCSize.cy);
|
||||||
|
AFlags := QWidgetDrawChildren;
|
||||||
|
if (Widget is TQtMainWindow) then
|
||||||
|
AFlags := AFlags or QWidgetDrawWindowBackground;
|
||||||
|
QWidget_render(Widget.Widget, QPaintDeviceH(Pixmap), @APoint, ASourceRegion, AFlags);
|
||||||
|
QRegion_destroy(ASourceRegion);
|
||||||
|
|
||||||
AWidgetID := QWidget_winId(Widget.Widget);
|
APoint := QtPoint(X, Y);
|
||||||
AWindow := QWidget_windowHandle(Widget.Widget);
|
|
||||||
if AWindow <> nil then
|
|
||||||
AScreen := QWindow_screen(AWindow)
|
|
||||||
else
|
|
||||||
AScreen := QGuiApplication_primaryScreen();
|
|
||||||
|
|
||||||
QScreen_grabWindow(AScreen, Pixmap, AWidgetID, 0, 0);
|
|
||||||
|
|
||||||
// apply offset if we have main menu
|
|
||||||
APoint := QtPoint(X, Y + OffsetY);
|
|
||||||
ARect := Rect(0, 0, QPixmap_width(Pixmap), QPixmap_height(Pixmap));
|
ARect := Rect(0, 0, QPixmap_width(Pixmap), QPixmap_height(Pixmap));
|
||||||
// also scale pixmap by height of menu, so it's catched in our image.
|
Context.drawPixmap(@APoint, Pixmap, @ARect);
|
||||||
if OffsetY <> 0 then
|
|
||||||
begin
|
|
||||||
NewHandle := QPixmap_create();
|
|
||||||
QPixmap_scaled(Pixmap, NewHandle, QPixmap_width(Pixmap), QPixmap_height(Pixmap) - OffsetY);
|
|
||||||
Context.drawPixmap(@APoint, NewHandle, @ARect);
|
|
||||||
QPixmap_destroy(NewHandle);
|
|
||||||
end else
|
|
||||||
Context.drawPixmap(@APoint, Pixmap, @ARect);
|
|
||||||
finally
|
finally
|
||||||
QPixmap_destroy(Pixmap);
|
QPixmap_destroy(Pixmap);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user