LCOV - code coverage report
Current view: top level - sc/source/ui/view - tabsplit.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 72 86 83.7 %
Date: 2014-11-03 Functions: 7 9 77.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "tabsplit.hxx"
      21             : #include "viewdata.hxx"
      22             : #include "dbfunc.hxx"
      23             : 
      24             : #include <vcl/settings.hxx>
      25             : 
      26        1092 : ScTabSplitter::ScTabSplitter( vcl::Window* pParent, WinBits nWinStyle, ScViewData* pData ) :
      27             :     Splitter( pParent, nWinStyle ),
      28        1092 :     pViewData(pData)
      29             : {
      30        1092 :     SetFixed(false);
      31        1092 :     EnableRTL( false );
      32        1092 : }
      33             : 
      34        2184 : ScTabSplitter::~ScTabSplitter()
      35             : {
      36        2184 : }
      37             : 
      38           0 : void ScTabSplitter::MouseButtonDown( const MouseEvent& rMEvt )
      39             : {
      40           0 :     if (bFixed)
      41           0 :         Window::MouseButtonDown( rMEvt );
      42             :     else
      43           0 :         Splitter::MouseButtonDown( rMEvt );
      44           0 : }
      45             : 
      46           0 : void ScTabSplitter::Splitting( Point& rSplitPos )
      47             : {
      48           0 :     vcl::Window* pParent = GetParent();
      49           0 :     Point aScreenPos = pParent->OutputToNormalizedScreenPixel( rSplitPos );
      50           0 :     pViewData->GetView()->SnapSplitPos( aScreenPos );
      51           0 :     Point aNew = pParent->NormalizedScreenToOutputPixel( aScreenPos );
      52           0 :     if ( IsHorizontal() )
      53           0 :         rSplitPos.X() = aNew.X();
      54             :     else
      55           0 :         rSplitPos.Y() = aNew.Y();
      56           0 : }
      57             : 
      58        2796 : void ScTabSplitter::SetFixed(bool bSet)
      59             : {
      60        2796 :     bFixed = bSet;
      61        2796 :     if (bSet)
      62          14 :         SetPointer(POINTER_ARROW);
      63        2782 :     else if (IsHorizontal())
      64        1394 :         SetPointer(POINTER_HSPLIT);
      65             :     else
      66        1388 :         SetPointer(POINTER_VSPLIT);
      67        2796 : }
      68             : 
      69         624 : void ScTabSplitter::Paint( const Rectangle& rRect )
      70             : {
      71         624 :     const Color oldFillCol = GetFillColor();
      72         624 :     const Color oldLineCol = GetLineColor();
      73             : 
      74         624 :     if (IsHorizontal())
      75             :     {
      76         318 :         switch (pViewData->GetHSplitMode())
      77             :         {
      78             :             case SC_SPLIT_NONE:
      79             :             {
      80             :                 // Draw 3D border
      81         315 :                 SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
      82         315 :                 DrawLine(rRect.TopRight(), rRect.BottomRight());
      83         315 :                 DrawLine(rRect.BottomLeft(), rRect.BottomRight());
      84         315 :                 SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
      85         315 :                 DrawLine(rRect.TopLeft(), rRect.TopRight());
      86         315 :                 DrawLine(rRect.TopLeft(), rRect.BottomLeft());
      87             :                 // Fill internal rectangle
      88         315 :                 SetLineColor();
      89         315 :                 SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
      90         315 :                 DrawRect(Rectangle(rRect.Left()+1, rRect.Top()+1, rRect.Right()-1, rRect.Bottom()-1));
      91             :                 // Draw handle
      92         315 :                 SetLineColor(Color(COL_BLACK));
      93         315 :                 SetFillColor(Color(COL_BLACK));
      94         315 :                 const long xc = rRect.Right()+rRect.Left();
      95         315 :                 const long h4 = rRect.GetHeight()/4;
      96             :                 // First xc fraction is truncated, second one is rounded. This will draw a centered line
      97             :                 // in handlers with odd width and a centered rectangle in those with even width.
      98         315 :                 DrawRect(Rectangle(Point(xc/2, rRect.Top()+h4), Point((xc+1)/2, rRect.Bottom()-h4)));
      99         315 :                 break;
     100             :             }
     101             :             case SC_SPLIT_NORMAL:
     102           2 :                 SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
     103           2 :                 DrawLine(rRect.TopLeft(), rRect.BottomLeft());
     104           2 :                 SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
     105           2 :                 DrawLine(rRect.TopRight(), rRect.BottomRight());
     106           2 :                 SetLineColor();
     107           2 :                 SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
     108           2 :                 DrawRect(Rectangle(Point(rRect.Left()+1, rRect.Top()), Point(rRect.Right()-1, rRect.Bottom())));
     109           2 :                 break;
     110             :             case SC_SPLIT_FIX:
     111             :                 // Nothing to draw
     112           1 :                 break;
     113             :         }
     114             :     }
     115             :     else
     116             :     {
     117         306 :         switch (pViewData->GetVSplitMode())
     118             :         {
     119             :             case SC_SPLIT_NONE:
     120             :             {
     121             :                 // Draw 3D border
     122         301 :                 SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
     123         301 :                 DrawLine(rRect.TopRight(), rRect.BottomRight());
     124         301 :                 DrawLine(rRect.BottomLeft(), rRect.BottomRight());
     125         301 :                 SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
     126         301 :                 DrawLine(rRect.TopLeft(), rRect.TopRight());
     127         301 :                 DrawLine(rRect.TopLeft(), rRect.BottomLeft());
     128             :                 // Fill internal rectangle
     129         301 :                 SetLineColor();
     130         301 :                 SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
     131         301 :                 DrawRect(Rectangle(rRect.Left()+1, rRect.Top()+1, rRect.Right()-1, rRect.Bottom()-1));
     132             :                 // Draw handle
     133         301 :                 SetLineColor(Color(COL_BLACK));
     134         301 :                 SetFillColor(Color(COL_BLACK));
     135         301 :                 const long yc = rRect.Top()+rRect.Bottom();
     136         301 :                 const long w4 = rRect.GetWidth()/4;
     137             :                 // First yc fraction is truncated, second one is rounded. This will draw a centered line
     138             :                 // in handlers with odd height and a centered rectangle in those with even height.
     139         301 :                 DrawRect(Rectangle(Point(rRect.Left()+w4, yc/2), Point(rRect.Right()-w4, (yc+1)/2)));
     140         301 :                 break;
     141             :             }
     142             :             case SC_SPLIT_NORMAL:
     143           2 :                 SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
     144           2 :                 DrawLine(rRect.TopLeft(), rRect.TopRight());
     145           2 :                 SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
     146           2 :                 DrawLine(rRect.BottomLeft(), rRect.BottomRight());
     147           2 :                 SetLineColor();
     148           2 :                 SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
     149           2 :                 DrawRect(Rectangle(Point(rRect.Left(), rRect.Top()+1), Point(rRect.Right(), rRect.Bottom()-1)));
     150           2 :                 break;
     151             :             case SC_SPLIT_FIX:
     152             :                 // Nothing to draw
     153           3 :                 break;
     154             :         }
     155             :     }
     156             : 
     157         624 :     SetFillColor(oldFillCol);
     158         624 :     SetLineColor(oldLineCol);
     159         852 : }
     160             : 
     161             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10