diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-06-16 14:19:09 +0000 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-06-18 20:27:49 +0200 |
commit | 4a478227f5af8322164ecce66fd056e9bf2eac89 (patch) | |
tree | 718e3049e6a8e6d8c2c14c329d48832d78c1cdd8 /vcl/qt5 | |
parent | 17c91a53d25c0b82524e04a0c108f8e0abc76685 (diff) |
VCL cleanup WidgetDrawInterface
I don't understand why WidgetDrawInterface, which is basically a
copy of the SalGraphics native controls interface, duplicated it,
instead of cleaning things up.
The whole commit message of commit 8fcfa3853a81, which added this
code, is just: "custom widgets: Custom Widget Themes". That's it.
So this patch does, what the original one skipped: replacing the
SalGraphics interface with the WidgetDrawInterface. One result is
the addition of handleDamage to SalGraphics to correctly handle
the damage done by a custom widget theme to the underlying
SalGraphics implementation.
Change-Id: I5fda1a64b28e6560fb3c62e02b6dcda827f698e2
Reviewed-on: https://gerrit.libreoffice.org/74118
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/qt5')
-rw-r--r-- | vcl/qt5/Qt5Graphics.cxx | 25 | ||||
-rw-r--r-- | vcl/qt5/Qt5Graphics_Controls.cxx | 4 | ||||
-rw-r--r-- | vcl/qt5/Qt5SvpGraphics.cxx | 51 |
3 files changed, 40 insertions, 40 deletions
diff --git a/vcl/qt5/Qt5Graphics.cxx b/vcl/qt5/Qt5Graphics.cxx index fbf7ae05bf6b..5192f0b42416 100644 --- a/vcl/qt5/Qt5Graphics.cxx +++ b/vcl/qt5/Qt5Graphics.cxx @@ -21,6 +21,7 @@ #include <Qt5Font.hxx> #include <Qt5Frame.hxx> +#include <Qt5Graphics_Controls.hxx> #include <Qt5Painter.hxx> #include <QtGui/QImage> @@ -39,6 +40,8 @@ Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame, QImage *pQImage ) , m_aTextColor( 0x00, 0x00, 0x00 ) { ResetClipRegion(); + if (!Qt5Data::noNativeControls()) + m_pWidgetDraw.reset(new Qt5Graphics_Controls()); } Qt5Graphics::~Qt5Graphics() @@ -110,20 +113,16 @@ SystemFontData Qt5Graphics::GetSysFontData(int /*nFallbacklevel*/) const #endif -bool Qt5Graphics::drawNativeControl(ControlType nType, ControlPart nPart, - const tools::Rectangle& rControlRegion, ControlState nState, - const ImplControlValue& aValue, const OUString& aCaption) +void Qt5Graphics::handleDamage(const tools::Rectangle& rDamagedRegion) { - 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()); - aPainter.update(toQRect(rControlRegion)); - } - return bHandled; + assert(m_pWidgetDraw); + assert(dynamic_cast<Qt5Graphics_Controls*>(m_pWidgetDraw.get())); + assert(!rDamagedRegion.IsEmpty()); + + QImage* pImage = static_cast<Qt5Graphics_Controls*>(m_pWidgetDraw.get())->getImage(); + Qt5Painter aPainter(*this); + aPainter.drawImage(QPoint(rDamagedRegion.getX(), rDamagedRegion.getY()), *pImage); + aPainter.update(toQRect(rDamagedRegion)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/Qt5Graphics_Controls.cxx b/vcl/qt5/Qt5Graphics_Controls.cxx index 4cc108f55043..6cefef623a73 100644 --- a/vcl/qt5/Qt5Graphics_Controls.cxx +++ b/vcl/qt5/Qt5Graphics_Controls.cxx @@ -67,7 +67,7 @@ static QStyle::State vclStateValue2StateFlag(ControlState nControlState, Qt5Graphics_Controls::Qt5Graphics_Controls() { initStyles(); } -bool Qt5Graphics_Controls::IsNativeControlSupported(ControlType type, ControlPart part) +bool Qt5Graphics_Controls::isNativeControlSupported(ControlType type, ControlPart part) { switch (type) { @@ -170,7 +170,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part, ControlState nControlState, const ImplControlValue& value, const OUString&) { - bool nativeSupport = IsNativeControlSupported(type, part); + bool nativeSupport = isNativeControlSupported(type, part); if (!nativeSupport) { assert(!nativeSupport && "drawNativeControl called without native support!"); diff --git a/vcl/qt5/Qt5SvpGraphics.cxx b/vcl/qt5/Qt5SvpGraphics.cxx index 1e6ae94be070..4edf55d55644 100644 --- a/vcl/qt5/Qt5SvpGraphics.cxx +++ b/vcl/qt5/Qt5SvpGraphics.cxx @@ -13,7 +13,9 @@ #include <config_cairo_canvas.h> +#include <Qt5Data.hxx> #include <Qt5Frame.hxx> +#include <Qt5Graphics_Controls.hxx> #include <Qt5SvpGraphics.hxx> #include <Qt5SvpSurface.hxx> #include <Qt5Tools.hxx> @@ -26,6 +28,8 @@ Qt5SvpGraphics::Qt5SvpGraphics(Qt5Frame* pFrame) : SvpSalGraphics() , m_pFrame(pFrame) { + if (!Qt5Data::noNativeControls()) + m_pWidgetDraw.reset(new Qt5Graphics_Controls()); } Qt5SvpGraphics::~Qt5SvpGraphics() {} @@ -57,35 +61,32 @@ cairo::SurfaceSharedPtr Qt5SvpGraphics::CreateSurface(const OutputDevice& /*rRef #endif -static void QImage2BitmapBuffer(QImage* pImg, BitmapBuffer* pBuf) +static void QImage2BitmapBuffer(QImage& rImg, BitmapBuffer& rBuf) { - if (pImg->width() != 0 && pImg->height() != 0) - { - pBuf->mnWidth = pImg->width(); - pBuf->mnHeight = pImg->height(); - pBuf->mnBitCount = getFormatBits(pImg->format()); - pBuf->mpBits = pImg->bits(); - pBuf->mnScanlineSize = pImg->bytesPerLine(); - } + assert(rImg.width()); + assert(rImg.height()); + + rBuf.mnWidth = rImg.width(); + rBuf.mnHeight = rImg.height(); + rBuf.mnBitCount = getFormatBits(rImg.format()); + rBuf.mpBits = rImg.bits(); + rBuf.mnScanlineSize = rImg.bytesPerLine(); } -bool Qt5SvpGraphics::drawNativeControl(ControlType nType, ControlPart nPart, - const tools::Rectangle& rControlRegion, ControlState nState, - const ImplControlValue& aValue, const OUString& aCaption) +void Qt5SvpGraphics::handleDamage(const tools::Rectangle& rDamagedRegion) { - bool bHandled - = m_aControl.drawNativeControl(nType, nPart, rControlRegion, nState, aValue, aCaption); - if (bHandled) - { - QImage* pImage = &m_aControl.getImage(); - BitmapBuffer* pBuffer = new BitmapBuffer; - QImage2BitmapBuffer(pImage, pBuffer); - SalTwoRect aTR(0, 0, pImage->width(), pImage->height(), rControlRegion.getX(), - rControlRegion.getY(), rControlRegion.GetWidth(), - rControlRegion.GetHeight()); - drawBitmap(aTR, pBuffer, CAIRO_OPERATOR_OVER); - } - return bHandled; + assert(m_pWidgetDraw); + assert(dynamic_cast<Qt5Graphics_Controls*>(m_pWidgetDraw.get())); + assert(!rDamagedRegion.IsEmpty()); + + QImage* pImage = static_cast<Qt5Graphics_Controls*>(m_pWidgetDraw.get())->getImage(); + assert(pImage); + BitmapBuffer* pBuffer = new BitmapBuffer; + + QImage2BitmapBuffer(*pImage, *pBuffer); + SalTwoRect aTR(0, 0, pImage->width(), pImage->height(), rDamagedRegion.getX(), + rDamagedRegion.getY(), rDamagedRegion.GetWidth(), rDamagedRegion.GetHeight()); + drawBitmap(aTR, pBuffer, CAIRO_OPERATOR_OVER); } void Qt5SvpGraphics::GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) |