diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-11-04 11:01:00 -0500 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-11-09 18:42:36 +0100 |
commit | b5f97c9f5250907b689ad72cbeb292861aaf0c17 (patch) | |
tree | 2aa094aa6ba22116d451f08b2c25ba6b0bdb3107 /vcl | |
parent | 53961bc1bebe1159936f177b7e70eb8fadb36cff (diff) |
LOK: custom widgets: reduce theme plugin API surface
Change-Id: I89dcf5a102be19fd1bc314a89538a121522f4a43
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/headless/CustomWidgetDraw.cxx | 23 | ||||
-rw-r--r-- | vcl/headless/svpgdi.cxx | 1 | ||||
-rw-r--r-- | vcl/inc/WidgetThemeLibrary.hxx | 18 | ||||
-rw-r--r-- | vcl/inc/WidgetThemeLibraryTypes.hxx | 92 | ||||
-rw-r--r-- | vcl/inc/headless/svpgdi.hxx | 1 |
5 files changed, 32 insertions, 103 deletions
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 4af25f82478d..39f9176a8d64 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -24,6 +24,7 @@ #include <headless/svpbmp.hxx> #include <headless/svpframe.hxx> #include <headless/svpcairotextrender.hxx> +#include <headless/CustomWidgetDraw.hxx> #include <saldatabasic.hxx> #include <sal/log.hxx> 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 <cstdint> 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 <cstdint> -#include <type_traits> +#include <type_traits> // 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 21b1b0537c8e..8546387f8962 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -33,7 +33,6 @@ #include <sallayout.hxx> #include "svpcairotextrender.hxx" #include <impfontmetricdata.hxx> -#include <headless/CustomWidgetDraw.hxx> #include <cairo.h> |