LCOV - code coverage report
Current view: top level - sc/source/ui/view - tabsplit.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 51 58 87.9 %
Date: 2015-06-13 12:38:46 Functions: 7 8 87.5 %
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         696 : ScTabSplitter::ScTabSplitter( vcl::Window* pParent, WinBits nWinStyle, ScViewData* pData ) :
      27             :     Splitter(pParent, nWinStyle),
      28         696 :     pViewData(pData)
      29             : {
      30         696 :     SetFixed(false);
      31         696 :     EnableRTL(false);
      32         696 : }
      33             : 
      34        1380 : ScTabSplitter::~ScTabSplitter()
      35             : {
      36        1380 : }
      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        1986 : void ScTabSplitter::SetFixed(bool bSet)
      47             : {
      48        1986 :     bFixed = bSet;
      49        1986 :     if (bSet)
      50           7 :         SetPointer(PointerStyle::Arrow);
      51        1979 :     else if (IsHorizontal())
      52         991 :         SetPointer(PointerStyle::HSplit);
      53             :     else
      54         988 :         SetPointer(PointerStyle::VSplit);
      55        1986 : }
      56             : 
      57         387 : void ScTabSplitter::Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect )
      58             : {
      59         387 :     rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
      60         387 :     const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
      61             : 
      62         387 :     if (IsHorizontal())
      63             :     {
      64         202 :         switch (pViewData->GetHSplitMode())
      65             :         {
      66             :             case SC_SPLIT_NONE:
      67             :             {
      68         201 :                 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
      69         201 :                 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
      70         201 :                 rRenderContext.DrawRect(Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom()));
      71             : 
      72             :                 // Draw handle
      73         201 :                 rRenderContext.SetLineColor(Color(COL_BLACK));
      74         201 :                 rRenderContext.SetFillColor(Color(COL_BLACK));
      75         201 :                 const long xc = rRect.Right() + rRect.Left();
      76         201 :                 const long h4 = rRect.GetHeight() / 4;
      77             :                 // First xc fraction is truncated, second one is rounded. This will draw a centered line
      78             :                 // in handlers with odd width and a centered rectangle in those with even width.
      79         201 :                 rRenderContext.DrawRect(Rectangle(Point(xc / 2, rRect.Top() + h4),
      80         402 :                                                   Point((xc + 1) / 2, rRect.Bottom() - h4)));
      81         201 :                 break;
      82             :             }
      83             :             case SC_SPLIT_NORMAL:
      84           1 :                 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
      85           1 :                 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
      86           1 :                 rRenderContext.DrawRect(Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom()));
      87           1 :                 break;
      88             :             case SC_SPLIT_FIX:
      89             :                 // Nothing to draw
      90           0 :                 break;
      91             :         }
      92             :     }
      93             :     else
      94             :     {
      95         185 :         switch (pViewData->GetVSplitMode())
      96             :         {
      97             :             case SC_SPLIT_NONE:
      98             :             {
      99         183 :                 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
     100         183 :                 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
     101         183 :                 rRenderContext.DrawRect(Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom()));
     102             : 
     103             :                  // Draw handle
     104         183 :                 rRenderContext.SetLineColor(Color(COL_BLACK));
     105         183 :                 rRenderContext.SetFillColor(Color(COL_BLACK));
     106         183 :                 const long yc = rRect.Top() + rRect.Bottom();
     107         183 :                 const long w4 = rRect.GetWidth() / 4;
     108             :                 // First yc fraction is truncated, second one is rounded. This will draw a centered line
     109             :                 // in handlers with odd height and a centered rectangle in those with even height.
     110         183 :                 DrawRect(Rectangle(Point(rRect.Left() + w4, yc / 2),
     111         366 :                                    Point(rRect.Right() - w4, (yc + 1) / 2)));
     112         183 :                 break;
     113             :             }
     114             :             case SC_SPLIT_NORMAL:
     115           2 :                 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
     116           2 :                 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
     117           2 :                 rRenderContext.DrawRect(Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom()));
     118           2 :                 break;
     119             :             case SC_SPLIT_FIX:
     120             :                 // Nothing to draw
     121           0 :                 break;
     122             :         }
     123             :     }
     124             : 
     125         387 :     rRenderContext.Pop();
     126         543 : }
     127             : 
     128             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11