1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <Qt5Graphics.hxx>
22 #include <Qt5Font.hxx>
23 #include <Qt5Frame.hxx>
24 #include <Qt5Graphics_Controls.hxx>
25 #include <Qt5Painter.hxx>
27 #include <QtGui/QImage>
28 #include <QtGui/QPainter>
29 #include <QtWidgets/QPushButton>
30 #include <QtWidgets/QWidget>
32 Qt5Graphics::Qt5Graphics( Qt5Frame
*pFrame
, QImage
*pQImage
)
34 , m_pQImage( pQImage
)
35 , m_aLineColor( 0x00, 0x00, 0x00 )
36 , m_aFillColor( 0xFF, 0xFF, 0XFF )
37 , m_eCompositionMode( QPainter::CompositionMode_SourceOver
)
38 , m_pFontCollection( nullptr )
39 , m_pTextStyle
{ nullptr, }
40 , m_aTextColor( 0x00, 0x00, 0x00 )
43 if (!Qt5Data::noNativeControls())
44 m_pWidgetDraw
.reset(new Qt5Graphics_Controls());
47 Qt5Graphics::~Qt5Graphics() { ReleaseFonts(); }
49 void Qt5Graphics::ChangeQImage(QImage
* pQImage
)
55 SalGraphicsImpl
* Qt5Graphics::GetImpl() const { return nullptr; }
57 SystemGraphicsData
Qt5Graphics::GetGraphicsData() const { return SystemGraphicsData(); }
59 bool Qt5Graphics::supportsOperation(OutDevSupportType eType
) const
63 case OutDevSupportType::B2DDraw
:
64 case OutDevSupportType::TransparentRect
:
71 #if ENABLE_CAIRO_CANVAS
73 bool Qt5Graphics::SupportsCairo() const { return false; }
75 cairo::SurfaceSharedPtr
76 Qt5Graphics::CreateSurface(const cairo::CairoSurfaceSharedPtr
& /*rSurface*/) const
81 cairo::SurfaceSharedPtr
Qt5Graphics::CreateSurface(const OutputDevice
& /*rRefDevice*/, int /*x*/,
82 int /*y*/, int /*width*/, int /*height*/) const
87 cairo::SurfaceSharedPtr
Qt5Graphics::CreateBitmapSurface(const OutputDevice
& /*rRefDevice*/,
88 const BitmapSystemData
& /*rData*/,
89 const Size
& /*rSize*/) const
94 css::uno::Any
Qt5Graphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr
& /*rSurface*/,
95 const basegfx::B2ISize
& /*rSize*/) const
97 return css::uno::Any();
100 SystemFontData
Qt5Graphics::GetSysFontData(int /*nFallbacklevel*/) const
102 return SystemFontData();
107 void Qt5Graphics::handleDamage(const tools::Rectangle
& rDamagedRegion
)
109 assert(m_pWidgetDraw
);
110 assert(dynamic_cast<Qt5Graphics_Controls
*>(m_pWidgetDraw
.get()));
111 assert(!rDamagedRegion
.IsEmpty());
113 QImage
* pImage
= static_cast<Qt5Graphics_Controls
*>(m_pWidgetDraw
.get())->getImage();
114 Qt5Painter
aPainter(*this);
115 aPainter
.drawImage(QPoint(rDamagedRegion
.getX(), rDamagedRegion
.getY()), *pImage
);
116 aPainter
.update(toQRect(rDamagedRegion
));
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */