tdf#148168 set built-in gtk search box to search "document name" column
[LibreOffice.git] / vcl / qt5 / QtGraphics.cxx
blobd809556ce219d9654f93cf81e9d1e08de726a693
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <QtGraphics.hxx>
22 #include <QtData.hxx>
23 #include <QtFont.hxx>
24 #include <QtFrame.hxx>
25 #include <QtGraphics_Controls.hxx>
26 #include <QtPainter.hxx>
28 #include <QtGui/QImage>
29 #include <QtGui/QPainter>
30 #include <QtWidgets/QPushButton>
31 #include <QtWidgets/QWidget>
33 QtGraphics::QtGraphics( QtFrame *pFrame, QImage *pQImage )
34 : m_pFrame( pFrame )
35 , m_pTextStyle{ nullptr, }
36 , m_aTextColor( 0x00, 0x00, 0x00 )
38 m_pBackend = std::make_unique<QtGraphicsBackend>(m_pFrame, pQImage);
40 if (!initWidgetDrawBackends(false))
42 if (!QtData::noNativeControls())
43 m_pWidgetDraw.reset(new QtGraphics_Controls(*this));
45 if (m_pFrame)
46 setDevicePixelRatioF(m_pFrame->devicePixelRatioF());
49 QtGraphics::~QtGraphics() { ReleaseFonts(); }
51 void QtGraphics::ChangeQImage(QImage* pQImage)
53 m_pBackend->setQImage(pQImage);
54 m_pBackend->ResetClipRegion();
57 SalGraphicsImpl* QtGraphics::GetImpl() const { return m_pBackend.get(); }
59 SystemGraphicsData QtGraphics::GetGraphicsData() const { return SystemGraphicsData(); }
61 #if ENABLE_CAIRO_CANVAS
63 bool QtGraphics::SupportsCairo() const { return false; }
65 cairo::SurfaceSharedPtr
66 QtGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& /*rSurface*/) const
68 return nullptr;
71 cairo::SurfaceSharedPtr QtGraphics::CreateSurface(const OutputDevice& /*rRefDevice*/, int /*x*/,
72 int /*y*/, int /*width*/, int /*height*/) const
74 return nullptr;
77 cairo::SurfaceSharedPtr QtGraphics::CreateBitmapSurface(const OutputDevice& /*rRefDevice*/,
78 const BitmapSystemData& /*rData*/,
79 const Size& /*rSize*/) const
81 return nullptr;
84 css::uno::Any QtGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& /*rSurface*/,
85 const basegfx::B2ISize& /*rSize*/) const
87 return css::uno::Any();
90 #endif
92 void QtGraphics::handleDamage(const tools::Rectangle& rDamagedRegion)
94 assert(m_pWidgetDraw);
95 assert(dynamic_cast<QtGraphics_Controls*>(m_pWidgetDraw.get()));
96 assert(!rDamagedRegion.IsEmpty());
98 QImage* pImage = static_cast<QtGraphics_Controls*>(m_pWidgetDraw.get())->getImage();
99 QImage blit(*pImage);
100 blit.setDevicePixelRatio(1);
101 QtPainter aPainter(*m_pBackend);
102 aPainter.drawImage(QPoint(rDamagedRegion.Left(), rDamagedRegion.Top()), blit);
103 aPainter.update(toQRect(rDamagedRegion));
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */