From 70d4b1f17f3b056273b9882b63f242e6aa4597cd Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Sun, 4 Nov 2018 11:01:00 -0500 Subject: LOK: custom widgets: reduce theme plugin API surface Change-Id: I89dcf5a102be19fd1bc314a89538a121522f4a43 --- vcl/headless/CustomWidgetDraw.cxx | 23 ++++++++-- vcl/headless/svpgdi.cxx | 1 + vcl/inc/WidgetThemeLibrary.hxx | 18 ++++---- vcl/inc/WidgetThemeLibraryTypes.hxx | 92 +------------------------------------ vcl/inc/headless/svpgdi.hxx | 1 - 5 files changed, 32 insertions(+), 103 deletions(-) (limited to 'vcl') diff --git a/vcl/headless/CustomWidgetDraw.cxx b/vcl/headless/CustomWidgetDraw.cxx index cadc41e85452..ca0af690a874 100644 --- a/vcl/headless/CustomWidgetDraw.cxx +++ b/vcl/headless/CustomWidgetDraw.cxx @@ -300,9 +300,26 @@ bool CustomWidgetDraw::getNativeControlRegion( ControlState eState, const ImplControlValue& /*aValue*/, const OUString& /*aCaption*/, tools::Rectangle& rNativeBoundingRegion, tools::Rectangle& rNativeContentRegion) { - return s_pWidgetImplementation - && s_pWidgetImplementation->getRegion(eType, ePart, eState, rBoundingControlRegion, - rNativeBoundingRegion, rNativeContentRegion); + // Translate to POD rectangle and back. + const rectangle_t aRegion + = { rBoundingControlRegion.getX(), rBoundingControlRegion.getY(), + rBoundingControlRegion.GetWidth(), rBoundingControlRegion.GetHeight() }; + if (s_pWidgetImplementation) + { + rectangle_t aNativeBoundingRegion; + rectangle_t aNativeContentRegion; + s_pWidgetImplementation->getRegion(eType, ePart, eState, aRegion, aNativeBoundingRegion, + aNativeContentRegion); + + rNativeBoundingRegion + = tools::Rectangle(aNativeBoundingRegion.x, aNativeBoundingRegion.y, + aNativeBoundingRegion.width, aNativeBoundingRegion.height); + rNativeContentRegion + = tools::Rectangle(aNativeBoundingRegion.x, aNativeBoundingRegion.y, + aNativeBoundingRegion.width, aNativeBoundingRegion.height); + } + + return false; } bool CustomWidgetDraw::updateSettings(AllSettings& rSettings) diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 3e409a3763bb..0fa655f96a92 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/vcl/inc/WidgetThemeLibrary.hxx b/vcl/inc/WidgetThemeLibrary.hxx index 9d916895d43b..84479af7bae5 100644 --- a/vcl/inc/WidgetThemeLibrary.hxx +++ b/vcl/inc/WidgetThemeLibrary.hxx @@ -11,11 +11,7 @@ #ifndef INCLUDED_VCL_INC_WIDGETTHEME_HXX #define INCLUDED_VCL_INC_WIDGETTHEME_HXX -/** - * This file expects cairo.h and the definition of - * the other types used here to be defined before - * including it. - */ +#include namespace vcl { @@ -76,6 +72,7 @@ struct WidgetDrawStyle struct ControlDrawParameters { + typedef struct _cairo cairo_t; ControlDrawParameters(cairo_t* i_pCairo, ControlPart i_ePart, ControlState i_eState) : nSize(sizeof(ControlDrawParameters)) , pCairo(i_pCairo) @@ -98,15 +95,20 @@ struct ControlDrawParameters typedef struct _WidgetThemeLibrary WidgetThemeLibrary; +typedef struct _rectangle +{ + long x, y; + long width, height; +} rectangle_t; + struct _WidgetThemeLibrary { uint32_t nSize; bool (*isNativeControlSupported)(ControlType eType, ControlPart ePart); bool (*getRegion)(ControlType eType, ControlPart ePart, ControlState eState, - const tools::Rectangle& rBoundingControlRegion, - tools::Rectangle& rNativeBoundingRegion, - tools::Rectangle& rNativeContentRegion); + const rectangle_t& rBoundingControlRegion, rectangle_t& rNativeBoundingRegion, + rectangle_t& rNativeContentRegion); bool (*drawPushButton)(ControlDrawParameters const& rParameters, long nWidth, long nHeight); bool (*drawRadiobutton)(ControlDrawParameters const& rParameters, long nWidth, long nHeight); diff --git a/vcl/inc/WidgetThemeLibraryTypes.hxx b/vcl/inc/WidgetThemeLibraryTypes.hxx index c8a492313356..af7ff9738471 100644 --- a/vcl/inc/WidgetThemeLibraryTypes.hxx +++ b/vcl/inc/WidgetThemeLibraryTypes.hxx @@ -12,7 +12,7 @@ #define INCLUDED_VCL_INC_WIDGETTHEMETYPES_HXX #include -#include +#include // Used for enum operator /** * These types are all based on the supported variants @@ -268,96 +268,6 @@ constexpr uint32_t RGB_COLORDATA(uint8_t r, uint8_t g, uint8_t b) { #define COL_YELLOW_HIGHLIGHT RGB_COLORDATA( 0xFF, 0xF2, 0x00 ) #define COL_WHITE RGB_COLORDATA( 0xFF, 0xFF, 0xFF ) -#ifndef SAL_DLLPUBLIC_EXPORT -# define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("default"))) -#endif - -namespace tools -{ - -#define RECT_EMPTY ((short)-32767) - -class SAL_DLLPUBLIC_EXPORT Rectangle -{ -public: - Rectangle(); - Rectangle( long nLeft, long nTop, - long nRight, long nBottom ); - - long Left() const { return nLeft; } - long Right() const { return nRight; } - long Top() const { return nTop; } - long Bottom() const { return nBottom; } - - long& Left() { return nLeft; } - long& Right() { return nRight; } - long& Top() { return nTop; } - long& Bottom() { return nBottom; } - - /// Returns the difference between right and left, assuming the range is inclusive. - inline long GetWidth() const; - /// Returns the difference between bottom and top, assuming the range is inclusive. - inline long GetHeight() const; - - long getX() const { return nLeft; } - long getY() const { return nTop; } - -private: - long nLeft; - long nTop; - long nRight; - long nBottom; -}; -} - -inline tools::Rectangle::Rectangle() -{ - nLeft = nTop = 0; - nRight = nBottom = RECT_EMPTY; -} - -inline tools::Rectangle::Rectangle( long _nLeft, long _nTop, - long _nRight, long _nBottom ) -{ - nLeft = _nLeft; - nTop = _nTop; - nRight = _nRight; - nBottom = _nBottom; -} - -inline long tools::Rectangle::GetWidth() const -{ - long n; - if ( nRight == RECT_EMPTY ) - n = 0; - else - { - n = nRight - nLeft; - if( n < 0 ) - n--; - else - n++; - } - - return n; -} - -inline long tools::Rectangle::GetHeight() const -{ - long n; - if ( nBottom == RECT_EMPTY ) - n = 0; - else - { - n = nBottom - nTop; - if ( n < 0 ) - n--; - else - n++; - } - - return n; -} #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 0c834a0a158a..dcd344350473 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -29,7 +29,6 @@ #include #include "svpcairotextrender.hxx" #include -#include #ifdef IOS #define SvpSalGraphics AquaSalGraphics -- cgit