LCOV - code coverage report
Current view: top level - vcl/source/control - morebtn.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 68 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 11 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 <vcl/morebtn.hxx>
      21             : 
      22             : #include <tools/rc.h>
      23             : #include <vector>
      24             : 
      25             : typedef ::std::vector< VclPtr<vcl::Window> > ImplMoreWindowList;
      26             : 
      27           0 : struct ImplMoreButtonData
      28             : {
      29             :     ImplMoreWindowList *mpItemList;
      30             :     OUString            maMoreText;
      31             :     OUString            maLessText;
      32             : };
      33             : 
      34           0 : void MoreButton::ImplInit( vcl::Window* pParent, WinBits nStyle )
      35             : {
      36           0 :     mpMBData     = new ImplMoreButtonData;
      37           0 :     mnDelta      = 0;
      38           0 :     meUnit       = MAP_PIXEL;
      39           0 :     mbState      = false;
      40             : 
      41           0 :     mpMBData->mpItemList = NULL;
      42             : 
      43           0 :     PushButton::ImplInit( pParent, nStyle );
      44             : 
      45           0 :     mpMBData->maMoreText = Button::GetStandardText( StandardButtonType::More );
      46           0 :     mpMBData->maLessText = Button::GetStandardText( StandardButtonType::Less );
      47             : 
      48           0 :     ShowState();
      49             : 
      50           0 :     SetSymbolAlign(SymbolAlign::RIGHT);
      51           0 :     SetImageAlign(IMAGEALIGN_RIGHT); //Resoves: fdo#31849 ensure button remains vertically centered
      52           0 :     SetSmallSymbol(true);
      53             : 
      54           0 :     if ( ! ( nStyle & ( WB_RIGHT | WB_LEFT ) ) )
      55             :     {
      56           0 :         nStyle |= WB_CENTER;
      57           0 :         SetStyle( nStyle );
      58             :     }
      59           0 : }
      60             : 
      61           0 : void MoreButton::ShowState()
      62             : {
      63           0 :     if ( mbState )
      64             :     {
      65           0 :         SetSymbol( SymbolType::PAGEUP );
      66           0 :         SetText( mpMBData->maLessText );
      67             :     }
      68             :     else
      69             :     {
      70           0 :         SetSymbol( SymbolType::PAGEDOWN );
      71           0 :         SetText( mpMBData->maMoreText );
      72             :     }
      73           0 : }
      74             : 
      75           0 : MoreButton::MoreButton( vcl::Window* pParent, WinBits nStyle ) :
      76           0 :     PushButton( WINDOW_MOREBUTTON )
      77             : {
      78           0 :     ImplInit( pParent, nStyle );
      79           0 : }
      80             : 
      81           0 : MoreButton::~MoreButton()
      82             : {
      83           0 :     disposeOnce();
      84           0 : }
      85             : 
      86           0 : void MoreButton::dispose()
      87             : {
      88           0 :     delete mpMBData->mpItemList;
      89           0 :     delete mpMBData;
      90           0 :     PushButton::dispose();
      91           0 : }
      92             : 
      93           0 : void MoreButton::Click()
      94             : {
      95           0 :     vcl::Window*     pParent = GetParent();
      96           0 :     Size        aSize( pParent->GetSizePixel() );
      97           0 :     long        nDeltaPixel = LogicToPixel( Size( 0, mnDelta ), meUnit ).Height();
      98             : 
      99             :     // Change status
     100           0 :     mbState = !mbState;
     101           0 :     ShowState();
     102             : 
     103             :     // Update the windows according to the status
     104           0 :     if ( mbState )
     105             :     {
     106             :         // Show window
     107           0 :         if ( mpMBData->mpItemList ) {
     108           0 :             for ( size_t i = 0, n = mpMBData->mpItemList->size(); i < n; ++i ) {
     109           0 :                 (*mpMBData->mpItemList)[ i ]->Show();
     110             :             }
     111             :         }
     112             : 
     113             :         // Adapt dialogbox
     114           0 :         Point aPos( pParent->GetPosPixel() );
     115           0 :         Rectangle aDeskRect( pParent->ImplGetFrameWindow()->GetDesktopRectPixel() );
     116             : 
     117           0 :         aSize.Height() += nDeltaPixel;
     118           0 :         if ( (aPos.Y()+aSize.Height()) > aDeskRect.Bottom() )
     119             :         {
     120           0 :             aPos.Y() = aDeskRect.Bottom()-aSize.Height();
     121             : 
     122           0 :             if ( aPos.Y() < aDeskRect.Top() )
     123           0 :                 aPos.Y() = aDeskRect.Top();
     124             : 
     125           0 :             pParent->SetPosSizePixel( aPos, aSize );
     126             :         }
     127             :         else
     128           0 :             pParent->SetSizePixel( aSize );
     129             :     }
     130             :     else
     131             :     {
     132             :         // Adapt Dialogbox
     133           0 :         aSize.Height() -= nDeltaPixel;
     134           0 :         pParent->SetSizePixel( aSize );
     135             : 
     136             :         // Hide window(s) again
     137           0 :         if ( mpMBData->mpItemList ) {
     138           0 :             for ( size_t i = 0, n = mpMBData->mpItemList->size(); i < n; ++i ) {
     139           0 :                 (*mpMBData->mpItemList)[ i ]->Hide();
     140             :             }
     141             :         }
     142             :     }
     143             :     // Call Click handler here, so that we can initialize the Controls
     144           0 :     PushButton::Click();
     145           0 : }
     146             : 
     147           0 : void MoreButton::SetText( const OUString& rText )
     148             : {
     149           0 :     PushButton::SetText( rText );
     150           0 : }
     151             : 
     152           0 : OUString MoreButton::GetText() const
     153             : {
     154           0 :     return PushButton::GetText();
     155             : }
     156             : 
     157             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11