summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-03-08 08:49:10 +0100
committerTomaž Vajngerl <quikee@gmail.com>2019-03-08 09:47:20 +0100
commita2bf2ca1e3d398db0caa07fce4d135e6dc8b2f27 (patch)
tree8f1b64694bee143f6b60d55e774836aa254cd516 /vcl
parent1e21df65c89de18c26d4602e1b8744c49f9ae183 (diff)
make it possible to use FileDefinitionWidgetDraw in more backends
Change-Id: I8871eb49e11d8c72c469230967c3c979091a0f9b Reviewed-on: https://gerrit.libreoffice.org/68898 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/headless/svpgdi.cxx13
-rw-r--r--vcl/inc/salgdi.hxx22
-rw-r--r--vcl/quartz/salgdi.cxx4
-rw-r--r--vcl/source/gdi/salgdilayout.cxx61
-rw-r--r--vcl/source/outdev/nativecontrols.cxx2
-rw-r--r--vcl/unx/gtk/salnativewidgets-gtk.cxx2
6 files changed, 83 insertions, 21 deletions
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index a2b7e7933c22..08cb2bfec940 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -27,8 +27,6 @@
#include <headless/CustomWidgetDraw.hxx>
#include <saldatabasic.hxx>
-#include <FileDefinitionWidgetDraw.hxx>
-
#include <sal/log.hxx>
#include <tools/helpers.hxx>
#include <o3tl/safeint.hxx>
@@ -601,12 +599,11 @@ SvpSalGraphics::SvpSalGraphics()
, m_ePaintMode(PaintMode::Over)
, m_aTextRenderImpl(*this)
{
- bool bFileDefinitionsWidgetDraw = !!getenv("VCL_DRAW_WIDGETS_FROM_FILE");
-
- if (bFileDefinitionsWidgetDraw)
- m_pWidgetDraw.reset(new vcl::FileDefinitionWidgetDraw(*this));
- else if (comphelper::LibreOfficeKit::isActive())
- m_pWidgetDraw.reset(new vcl::CustomWidgetDraw(*this));
+ if (!initWidgetDrawBackends())
+ {
+ if (comphelper::LibreOfficeKit::isActive())
+ m_pWidgetDraw.reset(new vcl::CustomWidgetDraw(*this));
+ }
}
SvpSalGraphics::~SvpSalGraphics()
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index fdd93ce00813..d7b45f5fcf97 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -348,8 +348,7 @@ public:
* @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 );
+ bool IsSupported(ControlType eType, ControlPart ePart);
/**
@@ -443,6 +442,11 @@ public:
#endif // ENABLE_CAIRO_CANVAS
+private:
+ bool callGetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, ControlState nState, const ImplControlValue& aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion);
+ bool callDrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, ControlState nState, const ImplControlValue& aValue, const OUString& rCaption);
+ bool callHitTestNativeControl(ControlType eType, ControlPart nPart, const tools::Rectangle& rControlRegion, const Point& aPos, bool& rIsInside);
+
protected:
virtual bool setClipRegion( const vcl::Region& ) = 0;
@@ -537,6 +541,15 @@ protected:
sal_uInt32 nSize ) = 0;
/**
+ * 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);
+
+ /**
* Query if a position is inside the native widget part.
*
* Mainly used for scrollbars.
@@ -601,6 +614,7 @@ protected:
tools::Rectangle &rNativeBoundingRegion,
tools::Rectangle &rNativeContentRegion );
+
/** Blend the bitmap with the current buffer */
virtual bool blendBitmap(
const SalTwoRect&,
@@ -666,11 +680,13 @@ protected:
inline long GetDeviceWidth(const OutputDevice* pOutDev) const;
+ // native controls
+ bool initWidgetDrawBackends(bool bForce = false);
+
bool hasWidgetDraw()
{
return bool(m_pWidgetDraw);
}
-
std::unique_ptr<vcl::WidgetDrawInterface> m_pWidgetDraw;
};
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 379174690968..18eda87c2de7 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -30,6 +30,7 @@
#include <osl/process.h>
#include <rtl/bootstrap.h>
#include <rtl/strbuf.hxx>
+#include <comphelper/lok.hxx>
#include <vcl/metric.hxx>
#include <vcl/fontcharmap.hxx>
@@ -212,6 +213,9 @@ AquaSalGraphics::AquaSalGraphics()
for (int i = 0; i < MAX_FALLBACK; ++i)
mpTextStyle[i] = nullptr;
+
+ if (comphelper::LibreOfficeKit::isActive())
+ initWidgetDrawBackends(true);
}
AquaSalGraphics::~AquaSalGraphics()
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index d410ce51772c..22199c52a712 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -33,6 +33,7 @@
#include <basegfx/numeric/ftools.hxx> //for F_PI180
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <FileDefinitionWidgetDraw.hxx>
// The only common SalFrame method
@@ -62,6 +63,18 @@ SalGraphics::SalGraphics()
m_nLayout = SalLayoutFlags::BiDiRtl;
}
+bool SalGraphics::initWidgetDrawBackends(bool bForce)
+{
+ bool bFileDefinitionsWidgetDraw = !!getenv("VCL_DRAW_WIDGETS_FROM_FILE");
+
+ if (bFileDefinitionsWidgetDraw || bForce)
+ {
+ m_pWidgetDraw.reset(new vcl::FileDefinitionWidgetDraw(*this));
+ return true;
+ }
+ return false;
+}
+
SalGraphics::~SalGraphics()
{
}
@@ -745,6 +758,22 @@ bool SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, void* pP
return drawEPS( nX, nY, nWidth, nHeight, pPtr, nSize );
}
+bool SalGraphics::IsSupported(ControlType eType, ControlPart ePart)
+{
+ if (m_pWidgetDraw)
+ return m_pWidgetDraw->isNativeControlSupported(eType, ePart);
+ else
+ return IsNativeControlSupported(eType, ePart);
+}
+
+bool SalGraphics::callHitTestNativeControl(ControlType eType, ControlPart nPart, const tools::Rectangle& rControlRegion, const Point& aPos, bool& rIsInside)
+{
+ if (m_pWidgetDraw)
+ return m_pWidgetDraw->hitTestNativeControl(eType, nPart, rControlRegion, aPos, rIsInside);
+ else
+ return hitTestNativeControl(eType, nPart, rControlRegion, aPos, rIsInside);
+}
+
bool SalGraphics::HitTestNativeScrollbar( ControlPart nPart, const tools::Rectangle& rControlRegion,
const Point& aPos, bool& rIsInside, const OutputDevice *pOutDev )
{
@@ -754,10 +783,10 @@ bool SalGraphics::HitTestNativeScrollbar( ControlPart nPart, const tools::Rectan
tools::Rectangle rgn( rControlRegion );
pt.setX( mirror2( pt.X(), pOutDev ) );
mirror( rgn, pOutDev );
- return hitTestNativeControl( ControlType::Scrollbar, nPart, rgn, pt, rIsInside );
+ return callHitTestNativeControl( ControlType::Scrollbar, nPart, rgn, pt, rIsInside );
}
else
- return hitTestNativeControl( ControlType::Scrollbar, nPart, rControlRegion, aPos, rIsInside );
+ return callHitTestNativeControl( ControlType::Scrollbar, nPart, rControlRegion, aPos, rIsInside );
}
void SalGraphics::mirror( ImplControlValue& rVal, const OutputDevice* pOutDev ) const
@@ -796,9 +825,17 @@ void SalGraphics::mirror( ImplControlValue& rVal, const OutputDevice* pOutDev )
}
}
+bool SalGraphics::callDrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, ControlState nState, const ImplControlValue& aValue, const OUString& rCaption)
+{
+ if (m_pWidgetDraw)
+ return m_pWidgetDraw->drawNativeControl(nType, nPart, rControlRegion, nState, aValue, rCaption);
+ else
+ return drawNativeControl(nType, nPart, rControlRegion, nState, aValue, rCaption);
+}
+
bool SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion,
ControlState nState, const ImplControlValue& aValue,
- const OUString& aCaption, const OutputDevice *pOutDev )
+ const OUString& aCaption, const OutputDevice *pOutDev)
{
if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
{
@@ -807,11 +844,19 @@ bool SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const
mirror(rgn, pOutDev);
std::unique_ptr< ImplControlValue > mirrorValue( aValue.clone());
mirror( *mirrorValue, pOutDev );
- bool bRet = drawNativeControl( nType, nPart, rgn, nState, *mirrorValue, aCaption );
+ bool bRet = callDrawNativeControl(nType, nPart, rgn, nState, *mirrorValue, aCaption);
return bRet;
}
else
- return drawNativeControl( nType, nPart, rControlRegion, nState, aValue, aCaption );
+ return callDrawNativeControl(nType, nPart, rControlRegion, nState, aValue, aCaption);
+}
+
+bool SalGraphics::callGetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, ControlState nState, const ImplControlValue& aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion)
+{
+ if (m_pWidgetDraw)
+ return m_pWidgetDraw->getNativeControlRegion(nType, nPart, rControlRegion, nState, aValue, OUString(), rNativeBoundingRegion, rNativeContentRegion);
+ else
+ return getNativeControlRegion(nType, nPart, rControlRegion, nState, aValue, OUString(), rNativeBoundingRegion, rNativeContentRegion);
}
bool SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, ControlState nState,
@@ -824,8 +869,7 @@ bool SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart,
mirror( rgn, pOutDev );
std::unique_ptr< ImplControlValue > mirrorValue( aValue.clone());
mirror( *mirrorValue, pOutDev );
- if( getNativeControlRegion( nType, nPart, rgn, nState, *mirrorValue, OUString(),
- rNativeBoundingRegion, rNativeContentRegion ) )
+ if (callGetNativeControlRegion(nType, nPart, rgn, nState, *mirrorValue, rNativeBoundingRegion, rNativeContentRegion))
{
mirror( rNativeBoundingRegion, pOutDev, true );
mirror( rNativeContentRegion, pOutDev, true );
@@ -834,8 +878,7 @@ bool SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart,
return false;
}
else
- return getNativeControlRegion( nType, nPart, rControlRegion, nState, aValue, OUString(),
- rNativeBoundingRegion, rNativeContentRegion );
+ return callGetNativeControlRegion(nType, nPart, rControlRegion, nState, aValue, rNativeBoundingRegion, rNativeContentRegion);
}
bool SalGraphics::BlendBitmap( const SalTwoRect& rPosAry,
diff --git a/vcl/source/outdev/nativecontrols.cxx b/vcl/source/outdev/nativecontrols.cxx
index ef2295808a6d..af51d2c279d9 100644
--- a/vcl/source/outdev/nativecontrols.cxx
+++ b/vcl/source/outdev/nativecontrols.cxx
@@ -166,7 +166,7 @@ bool OutputDevice::IsNativeControlSupported( ControlType nType, ControlPart nPar
if ( !mpGraphics && !AcquireGraphics() )
return false;
- return mpGraphics->IsNativeControlSupported(nType, nPart);
+ return mpGraphics->IsSupported(nType, nPart);
}
bool OutputDevice::HitTestNativeScrollbar(
diff --git a/vcl/unx/gtk/salnativewidgets-gtk.cxx b/vcl/unx/gtk/salnativewidgets-gtk.cxx
index 1154e8923859..767a53410df9 100644
--- a/vcl/unx/gtk/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/salnativewidgets-gtk.cxx
@@ -70,6 +70,8 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow,
m_aClipRegion(true)
{
Init( pFrame, GDK_WINDOW_XID( widget_get_window( pWindow ) ), nXScreen );
+
+ initWidgetDrawBackends();
}
GtkSalGraphics::~GtkSalGraphics()