Kaydet (Commit) 192af752 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

Qt5 move native control handing from kde5

The native painting code in the kde5 backend is Qt based only.
To prevent multiple inheritance, it's moved into an extra class
and just leaves the backend specific QImage blitting in the
specific SalGraphics implementation.

Change-Id: I3d5f58f42a37966794541fe1214c1b9557376a98
Reviewed-on: https://gerrit.libreoffice.org/58652
Tested-by: Jenkins
Reviewed-by: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
üst b9a6760a
...@@ -27,18 +27,23 @@ ...@@ -27,18 +27,23 @@
#include <QtGui/QPainterPath> #include <QtGui/QPainterPath>
#include <QtGui/QRegion> #include <QtGui/QRegion>
#include <Qt5Graphics_Controls.hxx>
class PhysicalFontCollection;
class QImage;
class QPushButton;
class Qt5Font; class Qt5Font;
class Qt5FontFace; class Qt5FontFace;
class Qt5Frame; class Qt5Frame;
class Qt5Painter; class Qt5Painter;
class PhysicalFontCollection;
class QImage;
class Qt5Graphics : public SalGraphics class Qt5Graphics : public SalGraphics
{ {
friend class Qt5Bitmap; friend class Qt5Bitmap;
friend class Qt5Painter; friend class Qt5Painter;
Qt5Graphics_Controls m_aControl;
Qt5Frame* m_pFrame; Qt5Frame* m_pFrame;
QImage* m_pQImage; QImage* m_pQImage;
QRegion m_aClipRegion; QRegion m_aClipRegion;
...@@ -50,6 +55,9 @@ class Qt5Graphics : public SalGraphics ...@@ -50,6 +55,9 @@ class Qt5Graphics : public SalGraphics
PhysicalFontCollection* m_pFontCollection; PhysicalFontCollection* m_pFontCollection;
rtl::Reference<Qt5Font> m_pTextStyle[MAX_FALLBACK]; rtl::Reference<Qt5Font> m_pTextStyle[MAX_FALLBACK];
Color m_aTextColor; Color m_aTextColor;
std::unique_ptr<QPushButton> m_focusedButton;
std::unique_ptr<QImage> m_image;
QRect m_lastPopupRect;
Qt5Graphics(Qt5Frame* pFrame, QImage* pQImage); Qt5Graphics(Qt5Frame* pFrame, QImage* pQImage);
...@@ -206,4 +214,27 @@ public: ...@@ -206,4 +214,27 @@ public:
tools::Rectangle& rNativeContentRegion) override; tools::Rectangle& rNativeContentRegion) override;
}; };
inline bool Qt5Graphics::IsNativeControlSupported(ControlType nType, ControlPart nPart)
{
return m_aControl.IsNativeControlSupported(nType, nPart);
}
inline bool Qt5Graphics::hitTestNativeControl(ControlType nType, ControlPart nPart,
const tools::Rectangle& rControlRegion,
const Point& aPos, bool& rIsInside)
{
return m_aControl.hitTestNativeControl(nType, nPart, rControlRegion, aPos, rIsInside);
}
inline bool Qt5Graphics::getNativeControlRegion(ControlType nType, ControlPart nPart,
const tools::Rectangle& rControlRegion,
ControlState nState, const ImplControlValue& aValue,
const OUString& aCaption,
tools::Rectangle& rNativeBoundingRegion,
tools::Rectangle& rNativeContentRegion)
{
return m_aControl.getNativeControlRegion(nType, nPart, rControlRegion, nState, aValue, aCaption,
rNativeBoundingRegion, rNativeContentRegion);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <vclpluginapi.h>
#include <salgdi.hxx>
#include <memory>
#include <QtGui/QPainter>
#include <QtGui/QRegion>
class QImage;
class QPushButton;
// Native control support
class VCLPLUG_QT5_PUBLIC Qt5Graphics_Controls
{
std::unique_ptr<QPushButton> m_focusedButton;
std::unique_ptr<QImage> m_image;
QRect m_lastPopupRect;
void initStyles();
public:
Qt5Graphics_Controls();
QImage& getImage() { return *m_image; }
bool IsNativeControlSupported(ControlType nType, ControlPart nPart);
bool hitTestNativeControl(ControlType nType, ControlPart nPart,
const tools::Rectangle& rControlRegion, const Point& aPos,
bool& rIsInside);
bool drawNativeControl(ControlType nType, ControlPart nPart,
const tools::Rectangle& rControlRegion, ControlState nState,
const ImplControlValue& aValue, const OUString& aCaption);
bool getNativeControlRegion(ControlType nType, ControlPart nPart,
const tools::Rectangle& rControlRegion, ControlState nState,
const ImplControlValue& aValue, const OUString& aCaption,
tools::Rectangle& rNativeBoundingRegion,
tools::Rectangle& rNativeContentRegion);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <QtGui/QImage> #include <QtGui/QImage>
#include <QtGui/QPainter> #include <QtGui/QPainter>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QWidget> #include <QtWidgets/QWidget>
Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame, QImage *pQImage ) Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame, QImage *pQImage )
...@@ -109,4 +110,19 @@ SystemFontData Qt5Graphics::GetSysFontData(int /*nFallbacklevel*/) const ...@@ -109,4 +110,19 @@ SystemFontData Qt5Graphics::GetSysFontData(int /*nFallbacklevel*/) const
#endif #endif
bool Qt5Graphics::drawNativeControl(ControlType nType, ControlPart nPart,
const tools::Rectangle& rControlRegion, ControlState nState,
const ImplControlValue& aValue, const OUString& aCaption)
{
bool bHandled
= m_aControl.drawNativeControl(nType, nPart, rControlRegion, nState, aValue, aCaption);
if (bHandled)
{
Qt5Painter aPainter(*this);
aPainter.drawImage(QPoint(rControlRegion.getX(), rControlRegion.getY()),
m_aControl.getImage());
}
return bHandled;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
#include <rtl/string.hxx> #include <rtl/string.hxx>
#include <headless/svpgdi.hxx> #include <headless/svpgdi.hxx>
#include <Qt5Graphics_Controls.hxx>
#include <QtGui/QImage> #include <QtGui/QImage>
#include <QtWidgets/QPushButton> #include <QtWidgets/QPushButton>
class KDE5SalFrame;
/** /**
* Handles native graphics requests and performs the needed drawing operations. * Handles native graphics requests and performs the needed drawing operations.
*/ */
...@@ -48,13 +48,29 @@ public: ...@@ -48,13 +48,29 @@ public:
ControlState, const ImplControlValue&, const OUString&, ControlState, const ImplControlValue&, const OUString&,
tools::Rectangle&, tools::Rectangle&) override; tools::Rectangle&, tools::Rectangle&) override;
std::unique_ptr<QImage> m_image;
QRect lastPopupRect;
private: private:
void initStyles(); Qt5Graphics_Controls m_aControl;
std::unique_ptr<QPushButton> m_focusedButton;
}; };
inline bool KDE5SalGraphics::IsNativeControlSupported(ControlType nType, ControlPart nPart)
{
return m_aControl.IsNativeControlSupported(nType, nPart);
}
inline bool KDE5SalGraphics::hitTestNativeControl(ControlType nType, ControlPart nPart,
const tools::Rectangle& rControlRegion,
const Point& aPos, bool& rIsInside)
{
return m_aControl.hitTestNativeControl(nType, nPart, rControlRegion, aPos, rIsInside);
}
inline bool KDE5SalGraphics::getNativeControlRegion(
ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion,
ControlState nState, const ImplControlValue& aValue, const OUString& aCaption,
tools::Rectangle& rNativeBoundingRegion, tools::Rectangle& rNativeContentRegion)
{
return m_aControl.getNativeControlRegion(nType, nPart, rControlRegion, nState, aValue, aCaption,
rNativeBoundingRegion, rNativeContentRegion);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment