LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/slidesorter/view - SlsToolTip.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 57 0.0 %
Date: 2012-12-27 Functions: 0 8 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             : 
      21             : #include "view/SlsToolTip.hxx"
      22             : #include "view/SlideSorterView.hxx"
      23             : #include "view/SlsLayouter.hxx"
      24             : #include "view/SlsTheme.hxx"
      25             : #include "sdpage.hxx"
      26             : #include "sdresid.hxx"
      27             : #include "glob.hrc"
      28             : #include <vcl/help.hxx>
      29             : 
      30             : using ::rtl::OUString;
      31             : 
      32             : namespace sd { namespace slidesorter { namespace view {
      33             : 
      34           0 : ToolTip::ToolTip (SlideSorter& rSlideSorter)
      35             :     : mrSlideSorter(rSlideSorter),
      36             :       msDefaultHelpText(),
      37             :       msCurrentHelpText(),
      38             :       mnHelpWindowHandle(0),
      39           0 :       maTimer()
      40             : {
      41           0 :     maTimer.SetTimeout(Theme_ToolTipDelay);
      42           0 :     maTimer.SetTimeoutHdl(LINK(this, ToolTip, DelayTrigger));
      43           0 : }
      44             : 
      45             : 
      46             : 
      47             : 
      48           0 : ToolTip::~ToolTip (void)
      49             : {
      50           0 :     maTimer.Stop();
      51           0 :     Hide();
      52           0 : }
      53             : 
      54             : 
      55             : 
      56             : 
      57           0 : void ToolTip::SetPage (const model::SharedPageDescriptor& rpDescriptor)
      58             : {
      59           0 :     if (mpDescriptor != rpDescriptor)
      60             :     {
      61           0 :         maTimer.Stop();
      62           0 :         Hide();
      63             : 
      64           0 :         mpDescriptor = rpDescriptor;
      65             : 
      66           0 :         if (mpDescriptor)
      67             :         {
      68           0 :             SdPage* pPage = mpDescriptor->GetPage();
      69           0 :             OUString sHelpText;
      70           0 :             if (pPage != NULL)
      71           0 :                 sHelpText = pPage->GetName();
      72             :             else
      73             :             {
      74             :                 OSL_ASSERT(mpDescriptor->GetPage() != NULL);
      75             :             }
      76           0 :             if (sHelpText.isEmpty())
      77             :             {
      78           0 :                 sHelpText = String(SdResId(STR_PAGE));
      79           0 :                 sHelpText += String::CreateFromInt32(mpDescriptor->GetPageIndex()+1);
      80             :             }
      81             : 
      82           0 :             msDefaultHelpText = sHelpText;
      83           0 :             msCurrentHelpText = sHelpText;
      84           0 :             Show(false);
      85             :         }
      86             :         else
      87             :         {
      88           0 :             msDefaultHelpText = OUString();
      89           0 :             msCurrentHelpText = OUString();
      90             :         }
      91             :     }
      92           0 : }
      93             : 
      94             : 
      95             : 
      96           0 : void ToolTip::Show (const bool bNoDelay)
      97             : {
      98           0 :     if (bNoDelay)
      99           0 :         DoShow();
     100             :     else
     101           0 :         maTimer.Start();
     102           0 : }
     103             : 
     104             : 
     105             : 
     106             : 
     107           0 : void ToolTip::DoShow (void)
     108             : {
     109           0 :     if (maTimer.IsActive())
     110             :     {
     111             :         // The delay timer is active.  Wait for it to trigger the showing of
     112             :         // the tool tip.
     113             :         return;
     114             :     }
     115             : 
     116           0 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     117           0 :     if (!msCurrentHelpText.isEmpty() && pWindow)
     118             :     {
     119             :         Rectangle aBox (
     120           0 :             mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetBoundingBox(
     121             :                 mpDescriptor,
     122             :                 PageObjectLayouter::Preview,
     123           0 :                 PageObjectLayouter::WindowCoordinateSystem));
     124             : 
     125             :         // Do not show the help text when the (lower edge of the ) preview
     126             :         // is not visible.  The tool tip itself may still be outside the
     127             :         // window.
     128           0 :         if (aBox.Bottom() >= pWindow->GetSizePixel().Height())
     129             :             return;
     130             : 
     131           0 :         ::Window* pParent (pWindow.get());
     132           0 :         while (pParent!=NULL && pParent->GetParent()!=NULL)
     133           0 :             pParent = pParent->GetParent();
     134           0 :         const Point aOffset (pWindow->GetWindowExtentsRelative(pParent).TopLeft());
     135             : 
     136             :         // We do not know how high the tool tip will be but want its top
     137             :         // edge not its bottom to be at a specific position (a little below
     138             :         // the preview).  Therefore we use a little trick and place the tool
     139             :         // tip at the top of a rectangle that is placed below the preview.
     140           0 :         aBox.Move(aOffset.X(), aOffset.Y() + aBox.GetHeight() + 3);
     141             :         mnHelpWindowHandle = Help::ShowTip(
     142           0 :             pWindow.get(),
     143             :             aBox,
     144             :             msCurrentHelpText,
     145           0 :             QUICKHELP_CENTER | QUICKHELP_TOP);
     146           0 :     }
     147             : }
     148             : 
     149             : 
     150             : 
     151             : 
     152           0 : bool ToolTip::Hide (void)
     153             : {
     154           0 :     if (mnHelpWindowHandle>0)
     155             :     {
     156           0 :         Help::HideTip(mnHelpWindowHandle);
     157           0 :         mnHelpWindowHandle = 0;
     158           0 :         return true;
     159             :     }
     160             :     else
     161           0 :         return false;
     162             : }
     163             : 
     164             : 
     165             : 
     166             : 
     167           0 : IMPL_LINK_NOARG(ToolTip, DelayTrigger)
     168             : {
     169           0 :     DoShow();
     170             : 
     171           0 :     return 0;
     172             : }
     173             : 
     174             : } } } // end of namespace ::sd::slidesorter::view
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10