LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - TabItem.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 46 0.0 %
Date: 2014-04-14 Functions: 0 7 0.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 ::com::sun::star;
      29             : using namespace ::com::sun::star::uno;
      30             : 
      31             : 
      32             : namespace sfx2 { namespace sidebar {
      33             : 
      34             : 
      35           0 : TabItem::TabItem (Window* pParentWindow)
      36             :     : ImageRadioButton(pParentWindow),
      37             :       mbIsLeftButtonDown(false),
      38           0 :       mePaintType(PT_Theme)
      39             : {
      40           0 :     SetStyle(GetStyle() | WB_TABSTOP | WB_DIALOGCONTROL | WB_NOPOINTERFOCUS);
      41           0 :     SetBackground(Theme::GetPaint(Theme::Paint_TabBarBackground).GetWallpaper());
      42             : #ifdef DEBUG
      43             :     SetText(OUString("TabItem"));
      44             : #endif
      45           0 : }
      46             : 
      47             : 
      48             : 
      49             : 
      50           0 : TabItem::~TabItem (void)
      51             : {
      52           0 : }
      53             : 
      54             : 
      55             : 
      56             : 
      57           0 : void TabItem::Paint (const Rectangle& rUpdateArea)
      58             : {
      59           0 :     switch(mePaintType)
      60             :     {
      61             :         case PT_Theme:
      62             :         default:
      63             :         {
      64           0 :             const bool bIsSelected (IsChecked());
      65           0 :             const bool bIsHighlighted (IsMouseOver() || HasFocus());
      66             :             DrawHelper::DrawRoundedRectangle(
      67             :                 *this,
      68           0 :                 Rectangle(Point(0,0), GetSizePixel()),
      69             :                 Theme::GetInteger(Theme::Int_ButtonCornerRadius),
      70           0 :                 bIsHighlighted||bIsSelected
      71             :                     ? Theme::GetColor(Theme::Color_TabItemBorder)
      72             :                     : Color(0xffffffff),
      73             :                 bIsHighlighted
      74             :                     ? Theme::GetPaint(Theme::Paint_TabItemBackgroundHighlight)
      75           0 :                     : Theme::GetPaint(Theme::Paint_TabItemBackgroundNormal));
      76             : 
      77           0 :             const Image aIcon(Button::GetModeImage());
      78           0 :             const Size aIconSize (aIcon.GetSizePixel());
      79             :             const Point aIconLocation(
      80           0 :                 (GetSizePixel().Width() - aIconSize.Width())/2,
      81           0 :                 (GetSizePixel().Height() - aIconSize.Height())/2);
      82             :             DrawImage(
      83             :                 aIconLocation,
      84             :                 aIcon,
      85           0 :                 IsEnabled() ? 0 : IMAGE_DRAW_DISABLE);
      86           0 :             break;
      87             :         }
      88             :         case PT_Native:
      89           0 :             Button::Paint(rUpdateArea);
      90           0 :             break;
      91             :     }
      92           0 : }
      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