LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - TabItem.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 21 46 45.7 %
Date: 2014-04-11 Functions: 4 7 57.1 %
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 ::com::sun::star;
      29             : using namespace ::com::sun::star::uno;
      30             : 
      31             : 
      32             : namespace sfx2 { namespace sidebar {
      33             : 
      34             : 
      35          77 : TabItem::TabItem (Window* pParentWindow)
      36             :     : ImageRadioButton(pParentWindow),
      37             :       mbIsLeftButtonDown(false),
      38          77 :       mePaintType(PT_Theme)
      39             : {
      40          77 :     SetStyle(GetStyle() | WB_TABSTOP | WB_DIALOGCONTROL | WB_NOPOINTERFOCUS);
      41          77 :     SetBackground(Theme::GetPaint(Theme::Paint_TabBarBackground).GetWallpaper());
      42             : #ifdef DEBUG
      43             :     SetText(OUString("TabItem"));
      44             : #endif
      45          77 : }
      46             : 
      47             : 
      48             : 
      49             : 
      50         154 : TabItem::~TabItem (void)
      51             : {
      52         154 : }
      53             : 
      54             : 
      55             : 
      56             : 
      57         112 : void TabItem::Paint (const Rectangle& rUpdateArea)
      58             : {
      59         112 :     switch(mePaintType)
      60             :     {
      61             :         case PT_Theme:
      62             :         default:
      63             :         {
      64         112 :             const bool bIsSelected (IsChecked());
      65         112 :             const bool bIsHighlighted (IsMouseOver() || HasFocus());
      66             :             DrawHelper::DrawRoundedRectangle(
      67             :                 *this,
      68         112 :                 Rectangle(Point(0,0), GetSizePixel()),
      69             :                 Theme::GetInteger(Theme::Int_ButtonCornerRadius),
      70         112 :                 bIsHighlighted||bIsSelected
      71             :                     ? Theme::GetColor(Theme::Color_TabItemBorder)
      72             :                     : Color(0xffffffff),
      73             :                 bIsHighlighted
      74             :                     ? Theme::GetPaint(Theme::Paint_TabItemBackgroundHighlight)
      75         240 :                     : Theme::GetPaint(Theme::Paint_TabItemBackgroundNormal));
      76             : 
      77         112 :             const Image aIcon(Button::GetModeImage());
      78         112 :             const Size aIconSize (aIcon.GetSizePixel());
      79             :             const Point aIconLocation(
      80         224 :                 (GetSizePixel().Width() - aIconSize.Width())/2,
      81         336 :                 (GetSizePixel().Height() - aIconSize.Height())/2);
      82             :             DrawImage(
      83             :                 aIconLocation,
      84             :                 aIcon,
      85         112 :                 IsEnabled() ? 0 : IMAGE_DRAW_DISABLE);
      86         112 :             break;
      87             :         }
      88             :         case PT_Native:
      89           0 :             Button::Paint(rUpdateArea);
      90           0 :             break;
      91             :     }
      92         112 : }
      93             : 
      94             : 
      95             : 
      96             : 
      97           0 : void TabItem::MouseMove (const MouseEvent& rEvent)
      98             : {
      99           0 :     if (rEvent.IsEnterWindow() || rEvent.IsLeaveWindow())
     100           0 :         Invalidate();
     101           0 :     ImageRadioButton::MouseMove(rEvent);
     102           0 : }
     103             : 
     104             : 
     105             : 
     106             : 
     107           0 : void TabItem::MouseButtonDown (const MouseEvent& rMouseEvent)
     108             : {
     109           0 :     if (rMouseEvent.IsLeft())
     110             :     {
     111           0 :         mbIsLeftButtonDown = true;
     112           0 :         CaptureMouse();
     113           0 :         Invalidate();
     114             :     }
     115           0 : }
     116             : 
     117             : 
     118             : 
     119             : 
     120           0 : void TabItem::MouseButtonUp (const MouseEvent& rMouseEvent)
     121             : {
     122           0 :     if (IsMouseCaptured())
     123           0 :         ReleaseMouse();
     124             : 
     125           0 :     if (rMouseEvent.IsLeft())
     126             :     {
     127           0 :         if (mbIsLeftButtonDown)
     128             :         {
     129           0 :             Check();
     130           0 :             Click();
     131           0 :             GetParent()->Invalidate();
     132             :         }
     133             :     }
     134           0 :     if (mbIsLeftButtonDown)
     135             :     {
     136           0 :         mbIsLeftButtonDown = false;
     137           0 :         Invalidate();
     138             :     }
     139           0 : }
     140             : 
     141             : 
     142             : 
     143             : } } // end of namespace sfx2::sidebar
     144             : 
     145             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10