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

Generated by: LCOV version 1.10