summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-09-20 00:06:52 +0200
committerJan Holesovsky <kendy@collabora.com>2018-11-08 09:14:36 +0100
commit241822e4ebba3bd7c6b8fc9cb1430eb939493d3c (patch)
treebcf0fea17abb63fc20c94affa66089667a88fdee /vcl
parent24e772ebe8dbc2cb1a25fade6a02270e96e2663f (diff)
custom widgets: setup style setting in the widget library
Some theme colors are set using the style settings, which are implemented by each backend to correspond to the system theme. For custom widgets these need to also be set by the library itself. This commit adds the ground work and sets some of the colors for windows backgrounds. Change-Id: Ia65b1605b2b7bef7f01ff1feff2e7470479e626a
Diffstat (limited to 'vcl')
-rw-r--r--vcl/headless/CustomWidgetDraw.cxx70
-rw-r--r--vcl/headless/svpframe.cxx17
-rw-r--r--vcl/headless/svpgdi.cxx7
-rw-r--r--vcl/inc/WidgetDrawInterface.hxx4
-rw-r--r--vcl/inc/WidgetThemeLibrary.hxx20
-rw-r--r--vcl/inc/headless/CustomWidgetDraw.hxx3
-rw-r--r--vcl/inc/headless/svpgdi.hxx2
-rw-r--r--vcl/inc/unx/gtk/gtkgdi.hxx4
-rw-r--r--vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx8
9 files changed, 133 insertions, 2 deletions
diff --git a/vcl/headless/CustomWidgetDraw.cxx b/vcl/headless/CustomWidgetDraw.cxx
index 5cf2ccf83f55..5698f0ac34d8 100644
--- a/vcl/headless/CustomWidgetDraw.cxx
+++ b/vcl/headless/CustomWidgetDraw.cxx
@@ -309,6 +309,76 @@ bool CustomWidgetDraw::getNativeControlRegion(
rNativeBoundingRegion, rNativeContentRegion);
}
+bool CustomWidgetDraw::updateSettings(AllSettings& rSettings)
+{
+ if (!s_pWidgetImplementation)
+ return false;
+
+ WidgetDrawStyle aStyle;
+
+ if (s_pWidgetImplementation->updateSettings(aStyle))
+ {
+ StyleSettings aStyleSet = rSettings.GetStyleSettings();
+
+ aStyleSet.SetFaceColor(aStyle.maFaceColor);
+ aStyleSet.SetCheckedColor(Color(0xCC, 0xCC, 0xCC));
+ aStyleSet.SetLightColor(aStyle.maLightColor);
+ aStyleSet.SetLightBorderColor(aStyle.maLightBorderColor);
+ aStyleSet.SetShadowColor(aStyle.maShadowColor);
+ aStyleSet.SetDarkShadowColor(aStyle.maDarkShadowColor);
+ aStyleSet.SetButtonTextColor(Color(COL_BLACK));
+ aStyleSet.SetButtonRolloverTextColor(Color(COL_BLACK));
+ aStyleSet.SetRadioCheckTextColor(Color(COL_BLACK));
+ aStyleSet.SetGroupTextColor(Color(COL_BLACK));
+ aStyleSet.SetLabelTextColor(Color(COL_BLACK));
+ aStyleSet.SetWindowColor(aStyle.maWindowColor);
+ aStyleSet.SetWindowTextColor(aStyle.maWindowTextColor);
+ aStyleSet.SetDialogColor(aStyle.maDialogColor);
+ aStyleSet.SetDialogTextColor(aStyle.maDialogTextColor);
+ aStyleSet.SetWorkspaceColor(Color(0xDF, 0xDF, 0xDE));
+ aStyleSet.SetMonoColor(Color(COL_BLACK));
+ aStyleSet.SetFieldColor(Color(COL_WHITE));
+ aStyleSet.SetFieldTextColor(Color(COL_BLACK));
+ aStyleSet.SetFieldRolloverTextColor(Color(COL_BLACK));
+ aStyleSet.SetActiveColor(Color(COL_BLUE));
+ aStyleSet.SetActiveTextColor(Color(COL_WHITE));
+ aStyleSet.SetActiveBorderColor(Color(COL_LIGHTGRAY));
+ aStyleSet.SetDeactiveColor(Color(COL_GRAY));
+ aStyleSet.SetDeactiveTextColor(Color(COL_LIGHTGRAY));
+ aStyleSet.SetDeactiveBorderColor(Color(COL_LIGHTGRAY));
+ aStyleSet.SetMenuColor(Color(COL_LIGHTGRAY));
+ aStyleSet.SetMenuBarColor(Color(COL_LIGHTGRAY));
+ aStyleSet.SetMenuBarRolloverColor(Color(COL_BLUE));
+ aStyleSet.SetMenuBorderColor(Color(COL_LIGHTGRAY));
+ aStyleSet.SetMenuTextColor(Color(COL_BLACK));
+ aStyleSet.SetMenuBarTextColor(Color(COL_BLACK));
+ aStyleSet.SetMenuBarRolloverTextColor(Color(COL_WHITE));
+ aStyleSet.SetMenuBarHighlightTextColor(Color(COL_WHITE));
+ aStyleSet.SetMenuHighlightColor(Color(COL_BLUE));
+ aStyleSet.SetMenuHighlightTextColor(Color(COL_WHITE));
+ aStyleSet.SetHighlightColor(aStyle.maHighlightColor);
+ aStyleSet.SetHighlightTextColor(aStyle.maHighlightTextColor);
+ aStyleSet.SetActiveTabColor(aStyle.maActiveTabColor);
+ aStyleSet.SetInactiveTabColor(aStyle.maInactiveTabColor);
+ aStyleSet.SetTabTextColor(Color(COL_BLACK));
+ aStyleSet.SetTabRolloverTextColor(Color(COL_BLACK));
+ aStyleSet.SetTabHighlightTextColor(Color(COL_BLACK));
+ aStyleSet.SetDisableColor(Color(COL_GRAY));
+ aStyleSet.SetHelpColor(Color(0xFF, 0xFF, 0xE0));
+ aStyleSet.SetHelpTextColor(Color(COL_BLACK));
+ aStyleSet.SetLinkColor(Color(COL_BLUE));
+ aStyleSet.SetVisitedLinkColor(Color(0x00, 0x00, 0xCC));
+ aStyleSet.SetToolTextColor(Color(COL_BLACK));
+ aStyleSet.SetFontColor(Color(COL_BLACK));
+
+ rSettings.SetStyleSettings(aStyleSet);
+
+ return true;
+ }
+
+ return false;
+}
+
} // end vcl namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx
index 25419302dc5f..835b77f39add 100644
--- a/vcl/headless/svpframe.cxx
+++ b/vcl/headless/svpframe.cxx
@@ -424,6 +424,23 @@ void SvpSalFrame::UpdateSettings( AllSettings& rSettings )
aStdFont.SetFontSize(Size(0, 12));
aStyleSettings.SetMenuFont(aStdFont);
+
+ SvpSalGraphics* pGraphics = m_aGraphics.back();
+ bool bFreeGraphics = false;
+ if (!pGraphics)
+ {
+ pGraphics = dynamic_cast<SvpSalGraphics*>(AcquireGraphics());
+ if (!pGraphics)
+ {
+ SAL_WARN("vcl.gtk3", "Could not get graphics - unable to update settings");
+ return;
+ }
+ bFreeGraphics = true;
+ }
+ pGraphics->updateSettings(rSettings);
+
+ if (bFreeGraphics)
+ ReleaseGraphics(pGraphics);
}
rSettings.SetStyleSettings( aStyleSettings );
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 6d533e08641b..3e409a3763bb 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1541,6 +1541,13 @@ bool SvpSalGraphics::getNativeControlRegion(ControlType eType, ControlPart ePart
return false;
}
+void SvpSalGraphics::updateSettings(AllSettings& rSettings)
+{
+ if (hasWidgetDraw())
+ {
+ m_pWidgetDraw->updateSettings(rSettings);
+ }
+}
namespace
{
diff --git a/vcl/inc/WidgetDrawInterface.hxx b/vcl/inc/WidgetDrawInterface.hxx
index ce6c5d43babe..4d1ecce7a3fe 100644
--- a/vcl/inc/WidgetDrawInterface.hxx
+++ b/vcl/inc/WidgetDrawInterface.hxx
@@ -12,6 +12,8 @@
#define INCLUDED_VCL_INC_WIDGETDRAWINTERFACE_HXX
#include <vcl/dllapi.h>
+#include <vcl/salnativewidgets.hxx>
+#include <vcl/settings.hxx>
namespace vcl
{
@@ -91,6 +93,8 @@ public:
tools::Rectangle& rNativeBoundingRegion,
tools::Rectangle& rNativeContentRegion)
= 0;
+
+ virtual bool updateSettings(AllSettings& rSettings) = 0;
};
}
diff --git a/vcl/inc/WidgetThemeLibrary.hxx b/vcl/inc/WidgetThemeLibrary.hxx
index 7d38112130c8..59692de60012 100644
--- a/vcl/inc/WidgetThemeLibrary.hxx
+++ b/vcl/inc/WidgetThemeLibrary.hxx
@@ -14,9 +14,27 @@
#include <cairo.h>
#include <vcl/dllapi.h>
#include <vcl/salnativewidgets.hxx>
+#include <tools/color.hxx>
namespace vcl
{
+struct WidgetDrawStyle
+{
+ Color maFaceColor;
+ Color maLightColor;
+ Color maLightBorderColor;
+ Color maShadowColor;
+ Color maDarkShadowColor;
+ Color maHighlightColor;
+ Color maHighlightTextColor;
+ Color maActiveTabColor;
+ Color maInactiveTabColor;
+ Color maWindowColor;
+ Color maWindowTextColor;
+ Color maDialogColor;
+ Color maDialogTextColor;
+};
+
struct ControlDrawParameters
{
ControlDrawParameters(cairo_t* i_pCairo, ControlPart i_ePart, ControlState i_eState)
@@ -76,6 +94,8 @@ public:
virtual bool drawListNet(ControlDrawParameters const& rParameters, long nWidth, long nHeight);
virtual bool drawListHeader(ControlDrawParameters const& rParameters, long nWidth,
long nHeight);
+
+ virtual bool updateSettings(WidgetDrawStyle& rSettings);
};
extern "C" vcl::WidgetThemeLibrary* CreateWidgetThemeLibrary();
diff --git a/vcl/inc/headless/CustomWidgetDraw.hxx b/vcl/inc/headless/CustomWidgetDraw.hxx
index ce749ac15b63..89082803abc3 100644
--- a/vcl/inc/headless/CustomWidgetDraw.hxx
+++ b/vcl/inc/headless/CustomWidgetDraw.hxx
@@ -16,6 +16,7 @@
#include <WidgetDrawInterface.hxx>
#include <WidgetThemeLibrary.hxx>
#include <headless/svpgdi.hxx>
+#include <vcl/settings.hxx>
#include <memory>
namespace vcl
@@ -45,6 +46,8 @@ public:
const ImplControlValue& aValue, const OUString& aCaption,
tools::Rectangle& rNativeBoundingRegion,
tools::Rectangle& rNativeContentRegion) override;
+
+ bool updateSettings(AllSettings& rSettings) override;
};
} // end vcl namespace
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 1cf6f1556d4e..0c834a0a158a 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -248,6 +248,8 @@ public:
tools::Rectangle& rNativeBoundingRegion,
tools::Rectangle& rNativeContentRegion) override;
+ virtual void updateSettings(AllSettings& rSettings);
+
#if ENABLE_CAIRO_CANVAS
virtual bool SupportsCairo() const override;
virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index fc896db7f913..99d656ee1eec 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -115,6 +115,9 @@ public:
const OUString& rCaption,
tools::Rectangle &rNativeBoundingRegion,
tools::Rectangle &rNativeContentRegion ) override;
+
+ virtual void updateSettings(AllSettings& rSettings) override;
+
#if ENABLE_CAIRO_CANVAS
virtual bool SupportsCairo() const override;
@@ -125,7 +128,6 @@ public:
void WidgetQueueDraw() const;
- void updateSettings( AllSettings& rSettings );
static void refreshFontconfig( GtkSettings *pSettings );
static void signalSettingsNotify( GObject*, GParamSpec *pSpec, gpointer );
diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
index 9259ee36c63b..95c9cf73df15 100644
--- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
@@ -2873,8 +2873,14 @@ static vcl::Font getFont(GtkStyleContext* pStyle, const css::lang::Locale& rLoca
return aFont;
}
-void GtkSalGraphics::updateSettings( AllSettings& rSettings )
+void GtkSalGraphics::updateSettings(AllSettings& rSettings)
{
+ if (m_pWidgetDraw)
+ {
+ m_pWidgetDraw->updateSettings(rSettings);
+ return;
+ }
+
GtkStyleContext* pStyle = gtk_widget_get_style_context( mpWindow );
GtkSettings* pSettings = gtk_widget_get_settings( mpWindow );
StyleSettings aStyleSet = rSettings.GetStyleSettings();