From 25ef6ea63ac2d329b510e921d013f6382b280673 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sun, 29 Jul 2012 16:00:22 +0200 Subject: [PATCH] Really draw Calc tab-splitters Change-Id: I952729487eb5d1195bbdf53c2e981685cd0c7b62 Reviewed-on: https://gerrit.libreoffice.org/350 Reviewed-by: Eike Rathke Tested-by: Eike Rathke --- sc/source/ui/inc/tabsplit.hxx | 8 +-- sc/source/ui/inc/tabview.hxx | 1 - sc/source/ui/view/tabsplit.cxx | 92 +++++++++++++++++++++++++++++++++- sc/source/ui/view/tabview.cxx | 1 + 4 files changed, 96 insertions(+), 6 deletions(-) diff --git a/sc/source/ui/inc/tabsplit.hxx b/sc/source/ui/inc/tabsplit.hxx index cdfa148d8f36..616bd0b18c40 100644 --- a/sc/source/ui/inc/tabsplit.hxx +++ b/sc/source/ui/inc/tabsplit.hxx @@ -28,14 +28,13 @@ class ScViewData; class ScTabSplitter : public Splitter { private: - ScViewData* pViewData; - sal_Bool bFixed; + const ScViewData *const pViewData; + bool bFixed; protected: virtual void MouseMove( const MouseEvent& rMEvt ); virtual void MouseButtonUp( const MouseEvent& rMEvt ); virtual void MouseButtonDown( const MouseEvent& rMEvt ); - virtual void Splitting( Point& rSplitPos ); public: @@ -43,7 +42,8 @@ public: ScViewData* pData ); ~ScTabSplitter(); - void SetFixed(sal_Bool bSet); + void SetFixed(bool bSet); + virtual void Paint( const Rectangle& rPaintRect ); }; diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index 6d7548126479..4d2a540966af 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -63,7 +63,6 @@ namespace chart2 { namespace data { struct HighlightedRange; }}}}} -#define SPLIT_HANDLE_SIZE 3 #define SC_FORCEMODE_NONE 0xff // --------------------------------------------------------------------------- diff --git a/sc/source/ui/view/tabsplit.cxx b/sc/source/ui/view/tabsplit.cxx index 05d0405f63c2..5c5f2ffcc1be 100644 --- a/sc/source/ui/view/tabsplit.cxx +++ b/sc/source/ui/view/tabsplit.cxx @@ -82,7 +82,7 @@ void ScTabSplitter::Splitting( Point& rSplitPos ) } -void ScTabSplitter::SetFixed(sal_Bool bSet) +void ScTabSplitter::SetFixed(bool bSet) { bFixed = bSet; if (bSet) @@ -93,6 +93,96 @@ void ScTabSplitter::SetFixed(sal_Bool bSet) SetPointer(POINTER_VSPLIT); } +void ScTabSplitter::Paint( const Rectangle& rRect ) +{ + const Color oldFillCol = GetFillColor(); + const Color oldLineCol = GetLineColor(); + if (IsHorizontal()) + { + switch (pViewData->GetHSplitMode()) + { + case SC_SPLIT_NONE: + { + // Draw 3D border + SetLineColor(GetSettings().GetStyleSettings().GetShadowColor()); + DrawLine(rRect.TopRight(), rRect.BottomRight()); + DrawLine(rRect.BottomLeft(), rRect.BottomRight()); + SetLineColor(GetSettings().GetStyleSettings().GetLightColor()); + DrawLine(rRect.TopLeft(), rRect.TopRight()); + DrawLine(rRect.TopLeft(), rRect.BottomLeft()); + // Fill internal rectangle + SetLineColor(); + SetFillColor(GetSettings().GetStyleSettings().GetFaceColor()); + DrawRect(Rectangle(rRect.Left()+1, rRect.Top()+1, rRect.Right()-1, rRect.Bottom()-1)); + // Draw handle + SetLineColor(Color(COL_BLACK)); + SetFillColor(Color(COL_BLACK)); + const long xc = rRect.Right()+rRect.Left(); + const long h4 = rRect.GetHeight()/4; + // First xc fraction is truncated, second one is rounded. This will draw a centered line + // in handlers with odd width and a centered rectangle in those with even width. + DrawRect(Rectangle(Point(xc/2, rRect.Top()+h4), Point((xc+1)/2, rRect.Bottom()-h4))); + break; + } + case SC_SPLIT_NORMAL: + SetLineColor(GetSettings().GetStyleSettings().GetLightColor()); + DrawLine(rRect.TopLeft(), rRect.BottomLeft()); + SetLineColor(GetSettings().GetStyleSettings().GetShadowColor()); + DrawLine(rRect.TopRight(), rRect.BottomRight()); + SetLineColor(); + SetFillColor(GetSettings().GetStyleSettings().GetFaceColor()); + DrawRect(Rectangle(Point(rRect.Left()+1, rRect.Top()), Point(rRect.Right()-1, rRect.Bottom()))); + break; + case SC_SPLIT_FIX: + // Nothing to draw + break; + } + } + else + { + switch (pViewData->GetVSplitMode()) + { + case SC_SPLIT_NONE: + { + // Draw 3D border + SetLineColor(GetSettings().GetStyleSettings().GetShadowColor()); + DrawLine(rRect.TopRight(), rRect.BottomRight()); + DrawLine(rRect.BottomLeft(), rRect.BottomRight()); + SetLineColor(GetSettings().GetStyleSettings().GetLightColor()); + DrawLine(rRect.TopLeft(), rRect.TopRight()); + DrawLine(rRect.TopLeft(), rRect.BottomLeft()); + // Fill internal rectangle + SetLineColor(); + SetFillColor(GetSettings().GetStyleSettings().GetFaceColor()); + DrawRect(Rectangle(rRect.Left()+1, rRect.Top()+1, rRect.Right()-1, rRect.Bottom()-1)); + // Draw handle + SetLineColor(Color(COL_BLACK)); + SetFillColor(Color(COL_BLACK)); + const long yc = rRect.Top()+rRect.Bottom(); + const long w4 = rRect.GetWidth()/4; + // First yc fraction is truncated, second one is rounded. This will draw a centered line + // in handlers with odd height and a centered rectangle in those with even height. + DrawRect(Rectangle(Point(rRect.Left()+w4, yc/2), Point(rRect.Right()-w4, (yc+1)/2))); + break; + } + case SC_SPLIT_NORMAL: + SetLineColor(GetSettings().GetStyleSettings().GetLightColor()); + DrawLine(rRect.TopLeft(), rRect.TopRight()); + SetLineColor(GetSettings().GetStyleSettings().GetShadowColor()); + DrawLine(rRect.BottomLeft(), rRect.BottomRight()); + SetLineColor(); + SetFillColor(GetSettings().GetStyleSettings().GetFaceColor()); + DrawRect(Rectangle(Point(rRect.Left(), rRect.Top()+1), Point(rRect.Right(), rRect.Bottom()-1))); + break; + case SC_SPLIT_FIX: + // Nothing to draw + break; + } + } + + SetFillColor(oldFillCol); + SetLineColor(oldLineCol); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 97701fbc2666..4322cc9111cf 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -91,6 +91,7 @@ #include #define SPLIT_MARGIN 30 +#define SPLIT_HANDLE_SIZE 5 #define SC_ICONSIZE 36 #define SC_SCROLLBAR_MIN 30