diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-07-25 15:41:14 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-11-09 18:42:23 +0100 |
commit | 8fcfa3853a81106db2ea1f16341d30ae9055be95 (patch) | |
tree | bec28547f652250f5f0283b71afa36eb4422bd01 /vcl/inc | |
parent | 4e6b448b998e3589baa2de46fb2135f1162695ed (diff) |
custom widgets: Custom Widget Themes
Change-Id: I7ec57d18fe99f906aeb6dbb40d0d30c2ac8b51c4
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/WidgetDrawInterface.hxx | 99 | ||||
-rw-r--r-- | vcl/inc/WidgetThemeLibrary.hxx | 35 | ||||
-rw-r--r-- | vcl/inc/headless/CustomWidgetDraw.hxx | 54 | ||||
-rw-r--r-- | vcl/inc/salgdi.hxx | 8 |
4 files changed, 196 insertions, 0 deletions
diff --git a/vcl/inc/WidgetDrawInterface.hxx b/vcl/inc/WidgetDrawInterface.hxx new file mode 100644 index 000000000000..ce6c5d43babe --- /dev/null +++ b/vcl/inc/WidgetDrawInterface.hxx @@ -0,0 +1,99 @@ +/* -*- 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/. + * + */ + +#ifndef INCLUDED_VCL_INC_WIDGETDRAWINTERFACE_HXX +#define INCLUDED_VCL_INC_WIDGETDRAWINTERFACE_HXX + +#include <vcl/dllapi.h> + +namespace vcl +{ +class VCL_PLUGIN_PUBLIC WidgetDrawInterface +{ +public: + virtual ~WidgetDrawInterface() {} + + /** + * Query the platform layer for native control support. + * + * @param [in] eType The widget type. + * @param [in] ePart The part of the widget. + * @return true if the platform supports native drawing of the widget type defined by part. + */ + virtual bool isNativeControlSupported(ControlType eType, ControlPart ePart) = 0; + + /** + * Query if a position is inside the native widget part. + * + * Mainly used for scrollbars. + * + * @param [in] eType The widget type. + * @param [in] ePart The part of the widget. + * @param [in] rBoundingControlRegion The bounding Rectangle of + the complete control in VCL frame coordinates. + * @param [in] aPos The position to check the hit. + * @param [out] rIsInside true, if \a aPos was inside the native widget. + * @return true, if the query was successful. + */ + virtual bool hitTestNativeControl(ControlType eType, ControlPart ePart, + const tools::Rectangle& rBoundingControlRegion, + const Point& aPos, bool& rIsInside) + = 0; + + /** + * Draw the requested control. + * + * @param [in] eType The widget type. + * @param [in] ePart The part of the widget. + * @param [in] rBoundingControlRegion The bounding rectangle of + * the complete control in VCL frame coordinates. + * @param [in] eState The general state of the control (enabled, focused, etc.). + * @param [in] aValue Addition control specific information. + * @param [in] aCaption A caption or title string (like button text etc.). + * @return true, if the control could be drawn. + */ + virtual bool drawNativeControl(ControlType eType, ControlPart ePart, + const tools::Rectangle& rBoundingControlRegion, + ControlState eState, const ImplControlValue& aValue, + const OUString& aCaptions) + = 0; + + /** + * Get the native control regions for the control part. + * + * If the return value is true, \a rNativeBoundingRegion contains + * the true bounding region covered by the control including any + * adornment, while \a rNativeContentRegion contains the area + * within the control that can be safely drawn into without drawing over + * the borders of the control. + * + * @param [in] eType Type of the widget. + * @param [in] ePart Specification of the widget's part if it consists of more than one. + * @param [in] rBoundingControlRegion The bounding region of the control in VCL frame coordinates. + * @param [in] eState The general state of the control (enabled, focused, etc.). + * @param [in] aValue Addition control specific information. + * @param [in] aCaption A caption or title string (like button text etc.). + * @param [out] rNativeBoundingRegion The region covered by the control including any adornment. + * @param [out] rNativeContentRegion The region within the control that can be safely drawn into. + * @return true, if the regions are filled. + */ + virtual bool getNativeControlRegion(ControlType eType, ControlPart ePart, + const tools::Rectangle& rBoundingControlRegion, + ControlState eState, const ImplControlValue& aValue, + const OUString& aCaption, + tools::Rectangle& rNativeBoundingRegion, + tools::Rectangle& rNativeContentRegion) + = 0; +}; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/WidgetThemeLibrary.hxx b/vcl/inc/WidgetThemeLibrary.hxx new file mode 100644 index 000000000000..18afbc9c50fa --- /dev/null +++ b/vcl/inc/WidgetThemeLibrary.hxx @@ -0,0 +1,35 @@ +/* -*- 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/. + * + */ + +#ifndef INCLUDED_VCL_INC_WIDGETTHEME_HXX +#define INCLUDED_VCL_INC_WIDGETTHEME_HXX + +#include <cairo.h> +#include <vcl/dllapi.h> + +namespace vcl +{ +class SAL_DLLPUBLIC_RTTI WidgetThemeLibrary +{ +public: + WidgetThemeLibrary(); + virtual ~WidgetThemeLibrary(); + + virtual bool drawPushButtonFocus(cairo_t* pCairo, long nX, long nY, long nWidth, long nHeight); + virtual bool drawPushButton(cairo_t* pCairo, long nX, long nY, long nWidth, long nHeight); +}; + +extern "C" vcl::WidgetThemeLibrary* CreateWidgetThemeLibrary(); + +} // end vcl namespace + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/headless/CustomWidgetDraw.hxx b/vcl/inc/headless/CustomWidgetDraw.hxx new file mode 100644 index 000000000000..ce749ac15b63 --- /dev/null +++ b/vcl/inc/headless/CustomWidgetDraw.hxx @@ -0,0 +1,54 @@ +/* -*- 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/. + * + */ + +#ifndef INCLUDED_VCL_INC_CUSTOMWIDGETDRAW_HXX +#define INCLUDED_VCL_INC_CUSTOMWIDGETDRAW_HXX + +#include <vcl/dllapi.h> +#include <vcl/salnativewidgets.hxx> +#include <WidgetDrawInterface.hxx> +#include <WidgetThemeLibrary.hxx> +#include <headless/svpgdi.hxx> +#include <memory> + +namespace vcl +{ +class VCL_DLLPUBLIC CustomWidgetDraw : public vcl::WidgetDrawInterface +{ +private: + static WidgetThemeLibrary* s_pWidgetImplementation; + SvpSalGraphics& m_rGraphics; + +public: + CustomWidgetDraw(SvpSalGraphics& rGraphics); + virtual ~CustomWidgetDraw(); + + bool isNativeControlSupported(ControlType eType, ControlPart ePart) override; + + bool hitTestNativeControl(ControlType eType, ControlPart ePart, + const tools::Rectangle& rBoundingControlRegion, const Point& aPos, + bool& rIsInside) override; + + bool drawNativeControl(ControlType eType, ControlPart ePart, + const tools::Rectangle& rBoundingControlRegion, ControlState eState, + const ImplControlValue& aValue, const OUString& aCaptions) override; + + bool getNativeControlRegion(ControlType eType, ControlPart ePart, + const tools::Rectangle& rBoundingControlRegion, ControlState eState, + const ImplControlValue& aValue, const OUString& aCaption, + tools::Rectangle& rNativeBoundingRegion, + tools::Rectangle& rNativeContentRegion) override; +}; + +} // end vcl namespace + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index e2d6a62278eb..f8a643d7f662 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -26,6 +26,7 @@ #include "salgdiimpl.hxx" #include "sallayout.hxx" #include <basegfx/matrix/b2dhommatrix.hxx> +#include <WidgetDrawInterface.hxx> #include <config_cairo_canvas.h> @@ -663,6 +664,13 @@ protected: bool m_bAntiAliasB2DDraw : 1; inline long GetDeviceWidth(const OutputDevice* pOutDev) const; + + bool hasWidgetDraw() + { + return bool(m_pWidgetDraw); + } + + std::unique_ptr<vcl::WidgetDrawInterface> m_pWidgetDraw; }; #endif // INCLUDED_VCL_INC_SALGDI_HXX |