LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - TabItem.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 19 44 43.2 %
Date: 2015-06-13 12:38:46 Functions: 2 5 40.0 %
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 "TabItem.hxx"
      21             : 
      22             : #include "DrawHelper.hxx"
      23             : #include "Paint.hxx"
      24             : #include <sfx2/sidebar/Tools.hxx>
      25             : 
      26             : #include <sfx2/sidebar/Theme.hxx>
      27             : 
      28             : using namespace css;
      29             : using namespace css::uno;
      30             : 
      31             : namespace sfx2 { namespace sidebar {
      32             : 
      33        3020 : TabItem::TabItem (vcl::Window* pParentWindow)
      34             :     : ImageRadioButton(pParentWindow),
      35             :       mbIsLeftButtonDown(false),
      36        3020 :       mePaintType(PT_Theme)
      37             : {
      38        3020 :     SetStyle(GetStyle() | WB_TABSTOP | WB_DIALOGCONTROL | WB_NOPOINTERFOCUS);
      39        3020 :     SetBackground(Theme::GetPaint(Theme::Paint_TabBarBackground).GetWallpaper());
      40             : #ifdef DEBUG
      41             :     SetText(OUString("TabItem"));
      42             : #endif
      43        3020 : }
      44             : 
      45        4603 : void TabItem::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rUpdateArea)
      46             : {
      47        4603 :     switch (mePaintType)
      48             :     {
      49             :         case PT_Theme:
      50             :         default:
      51             :         {
      52        4603 :             const bool bIsSelected (IsChecked());
      53        4603 :             const bool bIsHighlighted (IsMouseOver() || HasFocus());
      54             :             DrawHelper::DrawRoundedRectangle(
      55             :                 rRenderContext,
      56        4603 :                 Rectangle(Point(0,0), GetSizePixel()),
      57             :                 Theme::GetInteger(Theme::Int_ButtonCornerRadius),
      58        4603 :                 bIsHighlighted||bIsSelected
      59             :                     ? Theme::GetColor(Theme::Color_TabItemBorder)
      60             :                     : Color(0xffffffff),
      61             :                 bIsHighlighted
      62             :                     ? Theme::GetPaint(Theme::Paint_TabItemBackgroundHighlight)
      63       10142 :                     : Theme::GetPaint(Theme::Paint_TabItemBackgroundNormal));
      64             : 
      65        4603 :             const Image aIcon(Button::GetModeImage());
      66        4603 :             const Size aIconSize (aIcon.GetSizePixel());
      67        9206 :             const Point aIconLocation((GetSizePixel().Width() - aIconSize.Width()) / 2,
      68       13809 :                                       (GetSizePixel().Height() - aIconSize.Height()) / 2);
      69        4603 :             rRenderContext.DrawImage(aIconLocation, aIcon, IsEnabled() ? DrawImageFlags::NONE : DrawImageFlags::Disable);
      70        4603 :             break;
      71             :         }
      72             :         case PT_Native:
      73           0 :             Button::Paint(rRenderContext, rUpdateArea);
      74           0 :             break;
      75             :     }
      76        4603 : }
      77             : 
      78           0 : void TabItem::MouseMove(const MouseEvent& rEvent)
      79             : {
      80           0 :     if (rEvent.IsEnterWindow() || rEvent.IsLeaveWindow())
      81           0 :         Invalidate();
      82           0 :     ImageRadioButton::MouseMove(rEvent);
      83           0 : }
      84             : 
      85           0 : void TabItem::MouseButtonDown(const MouseEvent& rMouseEvent)
      86             : {
      87           0 :     if (rMouseEvent.IsLeft())
      88             :     {
      89           0 :         mbIsLeftButtonDown = true;
      90           0 :         CaptureMouse();
      91           0 :         Invalidate();
      92             :     }
      93           0 : }
      94             : 
      95           0 : void TabItem::MouseButtonUp(const MouseEvent& rMouseEvent)
      96             : {
      97           0 :     if (IsMouseCaptured())
      98           0 :         ReleaseMouse();
      99             : 
     100           0 :     if (rMouseEvent.IsLeft())
     101             :     {
     102           0 :         if (mbIsLeftButtonDown)
     103             :         {
     104           0 :             Check();
     105           0 :             Click();
     106           0 :             GetParent()->Invalidate();
     107             :         }
     108             :     }
     109           0 :     if (mbIsLeftButtonDown)
     110             :     {
     111           0 :         mbIsLeftButtonDown = false;
     112           0 :         Invalidate();
     113             :     }
     114           0 : }
     115             : 
     116             : } } // end of namespace sfx2::sidebar
     117             : 
     118             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11