LCOV - code coverage report
Current view: top level - toolkit/source/awt - scrollabledialog.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 84 0.0 %
Date: 2014-04-14 Functions: 0 13 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 <toolkit/awt/scrollabledialog.hxx>
      21             : #include <vcl/group.hxx>
      22             : #include <vcl/settings.hxx>
      23             : 
      24             : namespace toolkit
      25             : {
      26             : 
      27             : // Using  WB_AUTOHSCROLL, WB_AUTOVSCROLL here sucks big time, there is a
      28             : // problem in the toolkit class where there are some clashing IDs
      29             : // ( ::com::sun::star::awt::VclWindowPeerAttribute::VSCROLL has the same value
      30             : // as ::com::sun::star::awt::WindowAttribute::NODECORATION and they are used
      31             : // in the same bitmap :-( WB_VSCROLL & WB_HSCROLL apparently are only for
      32             : // child classes ( whole thing is a mess if you ask me )
      33             : template< class T>
      34           0 : ScrollableWrapper<T>::ScrollableWrapper( Window* pParent, WinBits nStyle ) : T( pParent, nStyle & ~( WB_AUTOHSCROLL | WB_AUTOVSCROLL ) ), maHScrollBar( this, WB_HSCROLL | WB_DRAG), maVScrollBar( this, WB_VSCROLL | WB_DRAG ), mbHasHoriBar( false ), mbHasVertBar( false ), maScrollVis( None )
      35             : {
      36           0 :     Link aLink( LINK( this, ScrollableWrapper, ScrollBarHdl ) );
      37           0 :     maVScrollBar.SetScrollHdl( aLink );
      38           0 :     maHScrollBar.SetScrollHdl( aLink );
      39             : 
      40           0 :     ScrollBarVisibility aVis = None;
      41             : 
      42           0 :     if ( nStyle & ( WB_AUTOHSCROLL | WB_AUTOVSCROLL ) )
      43             :     {
      44           0 :         if ( nStyle & WB_AUTOHSCROLL )
      45           0 :             aVis = Hori;
      46           0 :         if ( nStyle &  WB_AUTOVSCROLL )
      47             :         {
      48           0 :             if ( aVis == Hori )
      49           0 :                 aVis = Both;
      50             :             else
      51           0 :                 aVis = Vert;
      52             :         }
      53             :     }
      54           0 :     setScrollVisibility( aVis );
      55           0 :     mnScrWidth = T::GetSettings().GetStyleSettings().GetScrollBarSize();
      56           0 : }
      57             : 
      58             : template< class T>
      59           0 : void ScrollableWrapper<T>::setScrollVisibility( ScrollBarVisibility rVisState )
      60             : {
      61           0 :     maScrollVis = rVisState;
      62           0 :     if (  maScrollVis == Hori || maScrollVis == Both )
      63             :     {
      64           0 :         mbHasHoriBar = true;
      65           0 :         maHScrollBar.Show();
      66             :     }
      67           0 :     if ( maScrollVis == Vert || maScrollVis == Both )
      68             :     {
      69           0 :         mbHasVertBar = true;
      70           0 :         maVScrollBar.Show();
      71             :     }
      72           0 :     if ( mbHasHoriBar || mbHasVertBar )
      73           0 :         this->SetStyle( T::GetStyle() | WB_CLIPCHILDREN | SCROLL_UPDATE );
      74           0 : }
      75             : 
      76             : template< class T>
      77           0 : ScrollableWrapper<T>::~ScrollableWrapper()
      78             : {
      79           0 : }
      80             : 
      81             : template< class T>
      82           0 : void ScrollableWrapper<T>::lcl_Scroll( long nX, long nY )
      83             : {
      84           0 :     long nXScroll = mnScrollPos.X() - nX;
      85           0 :     long nYScroll = mnScrollPos.Y() - nY;
      86           0 :     mnScrollPos = Point( nX, nY );
      87             : 
      88           0 :     Rectangle aScrollableArea( 0, 0, maScrollArea.Width(), maScrollArea.Height() );
      89           0 :     T::Scroll(nXScroll, nYScroll, aScrollableArea );
      90             :     // Manually scroll all children ( except the scrollbars )
      91           0 :     for ( int index = 0; index < T::GetChildCount(); ++index )
      92             :     {
      93           0 :         Window* pChild = T::GetChild( index );
      94           0 :         if ( pChild && pChild != &maVScrollBar && pChild != &maHScrollBar )
      95             :         {
      96           0 :             Point aPos = pChild->GetPosPixel();
      97           0 :             aPos += Point( nXScroll, nYScroll );
      98           0 :             pChild->SetPosPixel( aPos );
      99             :         }
     100             :     }
     101           0 : }
     102             : 
     103             : //Can't use IMPL_LINK with the template
     104             : //IMPL_LINK( ScrollableWrapper, ScrollBarHdl, ScrollBar*, pSB )
     105             : 
     106             : template< class T>
     107           0 : long ScrollableWrapper<T>::LinkStubScrollBarHdl( void* pThis, void* pCaller)
     108             : {
     109           0 :     return ((ScrollableWrapper<T>*)pThis )->ScrollBarHdl( (ScrollBar*)pCaller );
     110             : }
     111             : 
     112             : template< class T>
     113           0 : long ScrollableWrapper<T>::ScrollBarHdl( ScrollBar* pSB )
     114             : {
     115           0 :     sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos();
     116           0 :     if( pSB == &maVScrollBar )
     117           0 :         lcl_Scroll(mnScrollPos.X(), nPos );
     118           0 :     else if( pSB == &maHScrollBar )
     119           0 :         lcl_Scroll(nPos, mnScrollPos.Y() );
     120           0 :     return 1;
     121             : }
     122             : 
     123             : template< class T>
     124           0 : void ScrollableWrapper<T>::SetScrollTop( long nTop )
     125             : {
     126           0 :     Point aOld = mnScrollPos;
     127           0 :     lcl_Scroll( mnScrollPos.X() , mnScrollPos.Y() - nTop );
     128           0 :     maHScrollBar.SetThumbPos( 0 );
     129             :     // new pos is 0,0
     130           0 :     mnScrollPos = aOld;
     131           0 : }
     132             : template< class T>
     133           0 : void ScrollableWrapper<T>::SetScrollLeft( long nLeft )
     134             : {
     135           0 :     Point aOld = mnScrollPos;
     136           0 :     lcl_Scroll( mnScrollPos.X() - nLeft , mnScrollPos.Y() );
     137           0 :     maVScrollBar.SetThumbPos( 0 );
     138             :     // new pos is 0,0
     139           0 :     mnScrollPos = aOld;
     140           0 : }
     141             : template< class T>
     142           0 : void ScrollableWrapper<T>::SetScrollWidth( long nWidth )
     143             : {
     144           0 :     maScrollArea.Width() = nWidth;
     145           0 :     ResetScrollBars();
     146           0 : }
     147             : 
     148             : template< class T>
     149           0 : void ScrollableWrapper<T>::SetScrollHeight( long nHeight )
     150             : {
     151           0 :     maScrollArea.Height() = nHeight;
     152           0 :     ResetScrollBars();
     153           0 : }
     154             : 
     155             : template< class T>
     156           0 : void ScrollableWrapper<T>::Resize()
     157             : {
     158           0 :     ResetScrollBars();
     159           0 : }
     160             : 
     161             : template< class T>
     162           0 : void ScrollableWrapper<T>::ResetScrollBars()
     163             : {
     164           0 :     Size aOutSz = T::GetOutputSizePixel();
     165             : 
     166           0 :     Point aVPos( aOutSz.Width() - mnScrWidth, 0 );
     167           0 :     Point aHPos( 0, aOutSz.Height() - mnScrWidth );
     168             : 
     169           0 :     maVScrollBar.SetPosSizePixel( aVPos, Size( mnScrWidth,  T::GetSizePixel().Height() - mnScrWidth ) );
     170           0 :     maHScrollBar.SetPosSizePixel( aHPos, Size(  T::GetSizePixel().Width() - mnScrWidth, mnScrWidth ) );
     171             : 
     172           0 :     maHScrollBar.SetRangeMax( maScrollArea.Width() + mnScrWidth  );
     173           0 :     maHScrollBar.SetVisibleSize( T::GetSizePixel().Width() );
     174             : 
     175           0 :     maVScrollBar.SetRangeMax( maScrollArea.Height() + mnScrWidth );
     176           0 :     maVScrollBar.SetVisibleSize( T::GetSizePixel().Height() );
     177           0 : }
     178             : 
     179             : template class ScrollableWrapper< Dialog >;
     180             : #ifdef SCROLLABLEFRAME
     181             : template class ScrollableWrapper< GroupBox >;
     182             : #endif
     183             : 
     184             : } // toolkit
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10