summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-11-01 23:04:12 -0400
committerJan Holesovsky <kendy@collabora.com>2018-11-09 18:42:34 +0100
commit25741af1d255128f27444daf3705afece685322d (patch)
treef8b340e475f130ed125abae67646efec0b2c56d3
parent7484f1691cbe9513dabf084effe8a0366b737a80 (diff)
LOK: custom themes: isolate LO internals headers from theme plugin
Change-Id: Ic189aecf092b9cffd800e410d2d6e88016c43052
-rw-r--r--solenv/clang-format/blacklist1
-rw-r--r--vcl/headless/CustomWidgetDraw.cxx3
-rw-r--r--vcl/inc/WidgetThemeLibrary.hxx15
-rw-r--r--vcl/inc/WidgetThemeLibraryTypes.hxx404
-rw-r--r--vcl/inc/headless/CustomWidgetDraw.hxx1
5 files changed, 416 insertions, 8 deletions
diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist
index eee7266b67b8..fe9aecae089e 100644
--- a/solenv/clang-format/blacklist
+++ b/solenv/clang-format/blacklist
@@ -17801,6 +17801,7 @@ vcl/inc/unx/x11_cursors/wsshow_curs.h
vcl/inc/unx/x11_cursors/wsshow_mask.h
vcl/inc/vcleventlisteners.hxx
vcl/inc/vclpluginapi.h
+vcl/inc/WidgetThemeLibraryTypes.hxx
vcl/inc/wall2.hxx
vcl/inc/win/DWriteTextRenderer.hxx
vcl/inc/win/ScopedHDC.hxx
diff --git a/vcl/headless/CustomWidgetDraw.cxx b/vcl/headless/CustomWidgetDraw.cxx
index 38d52dedcfa2..d7eb359311a8 100644
--- a/vcl/headless/CustomWidgetDraw.cxx
+++ b/vcl/headless/CustomWidgetDraw.cxx
@@ -8,14 +8,13 @@
*
*/
+#include <cairo.h>
#include <headless/CustomWidgetDraw.hxx>
-#include <vcl/salnativewidgets.hxx>
#include <sal/main.h>
#include <sal/config.h>
#include <rtl/bootstrap.hxx>
#include <tools/svlibrary.h>
#include <osl/module.hxx>
-#include <cairo.h>
#include <svdata.hxx>
namespace vcl
diff --git a/vcl/inc/WidgetThemeLibrary.hxx b/vcl/inc/WidgetThemeLibrary.hxx
index 59692de60012..8f08669254c6 100644
--- a/vcl/inc/WidgetThemeLibrary.hxx
+++ b/vcl/inc/WidgetThemeLibrary.hxx
@@ -11,10 +11,11 @@
#ifndef INCLUDED_VCL_INC_WIDGETTHEME_HXX
#define INCLUDED_VCL_INC_WIDGETTHEME_HXX
-#include <cairo.h>
-#include <vcl/dllapi.h>
-#include <vcl/salnativewidgets.hxx>
-#include <tools/color.hxx>
+/**
+ * This file expects cairo.h and the definition of
+ * the other types used here to be defined before
+ * including it.
+ */
namespace vcl
{
@@ -52,9 +53,13 @@ struct ControlDrawParameters
ControlState eState;
ButtonValue eButtonValue;
bool bIsStock;
- sal_Int64 nValue;
+ int64_t nValue;
};
+#ifndef SAL_DLLPUBLIC_RTTI
+#define SAL_DLLPUBLIC_RTTI
+#endif
+
class SAL_DLLPUBLIC_RTTI WidgetThemeLibrary
{
public:
diff --git a/vcl/inc/WidgetThemeLibraryTypes.hxx b/vcl/inc/WidgetThemeLibraryTypes.hxx
new file mode 100644
index 000000000000..a5a32109142d
--- /dev/null
+++ b/vcl/inc/WidgetThemeLibraryTypes.hxx
@@ -0,0 +1,404 @@
+/* -*- 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_WIDGETTHEMETYPES_HXX
+#define INCLUDED_VCL_INC_WIDGETTHEMETYPES_HXX
+
+#include <cstdint>
+#include <type_traits>
+
+/**
+ * These types are all based on the supported variants
+ * vcl/salnativewidgets.hxx and must be kept in-sync.
+ **/
+
+/* Control Types:
+ *
+ * Specify the overall, whole control
+ * type (as opposed to parts of the
+ * control if it were composite).
+ */
+
+enum class ControlType {
+// for use in general purpose ImplControlValue
+ Generic = 0,
+// Normal PushButton/Command Button
+ Pushbutton = 1,
+// Normal single radio button
+ Radiobutton = 2,
+// Normal single checkbox
+ Checkbox = 10,
+// Combobox, i.e. a ListBox
+// that allows data entry by user
+ Combobox = 20,
+// Control that allows text entry
+ Editbox = 30,
+// Control that allows text entry, but without the usual border
+// Has to be handled separately, because this one cannot handle
+// ControlPart::HasBackgroundTexture, which is drawn in the edit box'es
+// border window.
+ EditboxNoBorder = 31,
+// Control that allows text entry
+// ( some systems distinguish between single and multi line edit boxes )
+ MultilineEditbox = 32,
+// Control that pops up a menu,
+// but does NOT allow data entry
+ Listbox = 35,
+// An edit field together with two little
+// buttons on the side (aka spin field)
+ Spinbox = 40,
+// Two standalone spin buttons
+// without an edit field
+ SpinButtons = 45,
+// A single tab
+ TabItem = 50,
+// The border around a tab area,
+// but without the tabs themselves.
+// May have a gap at the top for
+// the active tab
+ TabPane = 55,
+// The background to the tab area
+ TabHeader = 56,
+// Background of a Tab Pane
+ TabBody = 57,
+// Normal scrollbar, including
+// all parts like slider, buttons
+ Scrollbar = 60,
+ Slider = 65,
+// A separator line
+ Fixedline = 80,
+// A toolbar control with buttons and a grip
+ Toolbar = 100,
+// The menubar
+ Menubar = 120,
+// popup menu
+ MenuPopup = 121,
+ Progress = 131,
+// Progress bar for the intro window
+// (aka splash screen), in case some
+// wants native progress bar in the
+// application but not for the splash
+// screen (used in desktop/)
+ IntroProgress = 132,
+// tool tips
+ Tooltip = 140,
+// to draw the implemented theme
+ WindowBackground = 150,
+//to draw border of frames natively
+ Frame = 160,
+// for nodes in listviews
+// used in svtools/source/contnr/svtreebx.cxx
+ ListNode = 170,
+// nets between elements of listviews
+// with nodes
+ ListNet = 171,
+// for list headers
+ ListHeader = 172,
+};
+
+
+/* Control Parts:
+ *
+ * Uniquely identify a part of a control,
+ * for example the slider of a scroll bar.
+ */
+
+enum class ControlPart
+{
+ NONE = 0,
+ Entire = 1,
+ ListboxWindow = 5, // the static listbox window containing the list
+ Button = 100,
+ ButtonUp = 101,
+ ButtonDown = 102, // Also for ComboBoxes/ListBoxes
+ ButtonLeft = 103,
+ ButtonRight = 104,
+ AllButtons = 105,
+ SeparatorHorz = 106,
+ SeparatorVert = 107,
+ TrackHorzLeft = 200,
+ TrackVertUpper = 201,
+ TrackHorzRight = 202,
+ TrackVertLower = 203,
+ TrackHorzArea = 204,
+ TrackVertArea = 205,
+ Arrow = 220,
+ ThumbHorz = 210, // Also used as toolbar grip
+ ThumbVert = 211, // Also used as toolbar grip
+ MenuItem = 250,
+ MenuItemCheckMark = 251,
+ MenuItemRadioMark = 252,
+ Separator = 253,
+ SubmenuArrow = 254,
+
+/* #i77549#
+ HACK: for scrollbars in case of thumb rect, page up and page down rect we
+ abuse the HitTestNativeScrollbar interface. All theming engines but aqua
+ are actually able to draw the thumb according to our internal representation.
+ However aqua draws a little outside. The canonical way would be to enhance the
+ HitTestNativeScrollbar passing a ScrollbarValue additionally so all necessary
+ information is available in the call.
+ .
+ However since there is only this one small exception we will deviate a little and
+ instead pass the respective rect as control region to allow for a small correction.
+
+ So all places using HitTestNativeScrollbar on ControlPart::ThumbHorz, ControlPart::ThumbVert,
+ ControlPart::TrackHorzLeft, ControlPart::TrackHorzRight, ControlPart::TrackVertUpper, ControlPart::TrackVertLower
+ do not use the control rectangle as region but the actuall part rectangle, making
+ only small deviations feasible.
+*/
+
+/** The edit field part of a control, e.g. of the combo box.
+
+ Currently used just for combo boxes and just for GetNativeControlRegion().
+ It is valid only if GetNativeControlRegion() supports ControlPart::ButtonDown as
+ well.
+*/
+ SubEdit = 300,
+
+// For controls that require the entire background
+// to be drawn first, and then other pieces over top.
+// (GTK+ scrollbars for example). Control region passed
+// in to draw this part is expected to be the entire
+// area of the control.
+// A control may respond to one or both.
+ DrawBackgroundHorz = 1000,
+ DrawBackgroundVert = 1001,
+
+// GTK+ also draws tabs right->left since there is a
+// hardcoded 2 pixel overlap between adjacent tabs
+ TabsDrawRtl = 3000,
+
+// For themes that do not want to have the focus
+// rectangle part drawn by VCL but take care of the
+// whole inner control part by themselves
+// eg, listboxes or comboboxes or spinbuttons
+ HasBackgroundTexture = 4000,
+
+// For scrollbars that have 3 buttons (most KDE themes)
+ HasThreeButtons = 5000,
+
+ BackgroundWindow = 6000,
+ BackgroundDialog = 6001,
+
+//to draw natively the border of frames
+ Border = 7000,
+
+//to draw natively the focus rects
+ Focus = 8000
+};
+
+/* Control State:
+ *
+ * Specify how a particular part of the control
+ * is to be drawn. Constants are bitwise OR-ed
+ * together to compose a final drawing state.
+ * A _disabled_ state is assumed by the drawing
+ * functions until an ENABLED or HIDDEN is passed
+ * in the ControlState.
+ */
+enum class ControlState {
+ NONE = 0,
+ ENABLED = 0x0001,
+ FOCUSED = 0x0002,
+ PRESSED = 0x0004,
+ ROLLOVER = 0x0008,
+ DEFAULT = 0x0020,
+ SELECTED = 0x0040,
+ DOUBLEBUFFERING = 0x4000, ///< Set when the control is painted using double-buffering via VirtualDevice.
+ CACHING_ALLOWED = 0x8000, ///< Set when the control is completely visible (i.e. not clipped).
+};
+
+inline bool operator& (const ControlState& lhs, const ControlState& rhs)
+{
+ return static_cast<std::underlying_type<ControlState>::type>(lhs)
+ & static_cast<std::underlying_type<ControlState>::type>(rhs);
+}
+
+/* ButtonValue:
+ *
+ * Identifies the tri-state value options
+ * that buttons allow
+ */
+
+enum class ButtonValue {
+ DontKnow,
+ On,
+ Off,
+ Mixed
+};
+
+// Color types
+typedef uint32_t ColorData;
+
+constexpr ColorData RGB_COLORDATA(uint8_t r, uint8_t g, uint8_t b) {
+ return uint32_t(b) | (uint32_t(g) << 8) | (uint32_t(r) << 16);
+}
+
+#define COLORDATA_RED( n ) ((uint8_t)((n)>>16))
+#define COLORDATA_GREEN( n ) ((uint8_t)(((uint16_t)(n)) >> 8))
+#define COLORDATA_BLUE( n ) ((uint8_t)(n))
+#define COLORDATA_RGB( n ) ((ColorData)((n) & 0x00FFFFFF))
+
+#define COL_BLACK RGB_COLORDATA( 0x00, 0x00, 0x00 )
+#define COL_BLUE RGB_COLORDATA( 0x00, 0x00, 0x80 )
+#define COL_GREEN RGB_COLORDATA( 0x00, 0x80, 0x00 )
+#define COL_CYAN RGB_COLORDATA( 0x00, 0x80, 0x80 )
+#define COL_RED RGB_COLORDATA( 0x80, 0x00, 0x00 )
+#define COL_RED_FONTCOLOR RGB_COLORDATA( 0xCE, 0x18, 0x1E )
+#define COL_MAGENTA RGB_COLORDATA( 0x80, 0x00, 0x80 )
+#define COL_BROWN RGB_COLORDATA( 0x80, 0x80, 0x00 )
+#define COL_GRAY RGB_COLORDATA( 0x80, 0x80, 0x80 )
+#define COL_GRAY3 RGB_COLORDATA( 0xCC, 0xCC, 0xCC )
+#define COL_GRAY7 RGB_COLORDATA( 0x66, 0x66, 0x66 )
+#define COL_LIGHTGRAY RGB_COLORDATA( 0xC0, 0xC0, 0xC0 )
+#define COL_LIGHTBLUE RGB_COLORDATA( 0x00, 0x00, 0xFF )
+#define COL_LIGHTGREEN RGB_COLORDATA( 0x00, 0xFF, 0x00 )
+#define COL_LIGHTCYAN RGB_COLORDATA( 0x00, 0xFF, 0xFF )
+#define COL_LIGHTRED RGB_COLORDATA( 0xFF, 0x00, 0x00 )
+#define COL_LIGHTMAGENTA RGB_COLORDATA( 0xFF, 0x00, 0xFF )
+#define COL_LIGHTGRAYBLUE RGB_COLORDATA( 0xE0, 0xE0, 0xFF )
+#define COL_YELLOW RGB_COLORDATA( 0xFF, 0xFF, 0x00 )
+#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
+
+class SAL_DLLPUBLIC_EXPORT Color final
+{
+ ColorData mnColor;
+
+public:
+ explicit Color(ColorData nColor = COL_BLACK)
+ : mnColor(nColor)
+ {}
+ Color(uint8_t nRed, uint8_t nGreen, uint8_t nBlue)
+ : mnColor(RGB_COLORDATA(nRed, nGreen, nBlue))
+ {}
+
+ bool operator<(const Color& b) const
+ {
+ return mnColor < b.GetColor();
+ }
+
+ void SetColor(ColorData nColor)
+ {
+ mnColor = nColor;
+ }
+ ColorData GetColor() const
+ {
+ return mnColor;
+ }
+ ColorData GetRGBColor() const
+ {
+ return COLORDATA_RGB(mnColor);
+ }
+
+ bool operator==(const Color& rColor) const
+ {
+ return mnColor == rColor.mnColor;
+ }
+ bool operator!=(const Color& rColor) const
+ {
+ return !(Color::operator==(rColor));
+ }
+};
+
+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/CustomWidgetDraw.hxx b/vcl/inc/headless/CustomWidgetDraw.hxx
index 89082803abc3..d0ddcea430bc 100644
--- a/vcl/inc/headless/CustomWidgetDraw.hxx
+++ b/vcl/inc/headless/CustomWidgetDraw.hxx
@@ -12,7 +12,6 @@
#define INCLUDED_VCL_INC_CUSTOMWIDGETDRAW_HXX
#include <vcl/dllapi.h>
-#include <vcl/salnativewidgets.hxx>
#include <WidgetDrawInterface.hxx>
#include <WidgetThemeLibrary.hxx>
#include <headless/svpgdi.hxx>