LCOV - code coverage report
Current view: top level - libreoffice/vcl/source/window - dockingarea.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 45 108 41.7 %
Date: 2012-12-27 Functions: 12 14 85.7 %
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 <vcl/dockingarea.hxx>
      22             : #include <vcl/syswin.hxx>
      23             : #include <vcl/menu.hxx>
      24             : 
      25             : #include <svdata.hxx>
      26             : 
      27             : #include <map>
      28             : 
      29             : // =======================================================================
      30             : 
      31             : class DockingAreaWindow::ImplData
      32             : {
      33             : public:
      34             :     ImplData();
      35             :     ~ImplData();
      36             : 
      37             :     WindowAlign meAlign;
      38             : };
      39             : 
      40        1920 : DockingAreaWindow::ImplData::ImplData()
      41             : {
      42        1920 :     meAlign = WINDOWALIGN_TOP;
      43        1920 : }
      44             : 
      45         504 : DockingAreaWindow::ImplData::~ImplData()
      46             : {
      47         504 : }
      48             : 
      49             : // =======================================================================
      50             : 
      51        1920 : static void ImplInitBackground( DockingAreaWindow* pThis )
      52             : {
      53        1920 :     if( !pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
      54             :     {
      55        1920 :         Wallpaper aWallpaper;
      56        1920 :         aWallpaper.SetStyle( WALLPAPER_APPLICATIONGRADIENT );
      57        1920 :         pThis->SetBackground( aWallpaper );
      58             :     }
      59             :     else
      60           0 :         pThis->SetBackground( Wallpaper( pThis->GetSettings().GetStyleSettings().GetFaceColor() ) );
      61        1920 : }
      62             : 
      63        1920 : DockingAreaWindow::DockingAreaWindow( Window* pParent ) :
      64        1920 :     Window( WINDOW_DOCKINGAREA )
      65             : {
      66        1920 :     ImplInit( pParent, WB_CLIPCHILDREN|WB_3DLOOK, NULL );
      67             : 
      68        1920 :     mpImplData = new ImplData;
      69        1920 :     ImplInitBackground( this );
      70        1920 : }
      71             : 
      72        1512 : DockingAreaWindow::~DockingAreaWindow()
      73             : {
      74         504 :     delete mpImplData;
      75        1008 : }
      76             : 
      77             : // -----------------------------------------------------------------------
      78             : 
      79         736 : void DockingAreaWindow::DataChanged( const DataChangedEvent& rDCEvt )
      80             : {
      81         736 :     Window::DataChanged( rDCEvt );
      82             : 
      83         736 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
      84             :     {
      85           0 :         ImplInitBackground( this );
      86             :     }
      87         736 : }
      88             : 
      89             : // -----------------------------------------------------------------------
      90             : 
      91        2591 : static void ImplInvalidateMenubar( DockingAreaWindow* pThis )
      92             : {
      93             :     // due to a possible comon gradient covering menubar and top dockingarea
      94             :     // the menubar must be repainted if the top dockingarea changes size or visibility
      95        2591 :     if( ImplGetSVData()->maNWFData.mbMenuBarDockingAreaCommonBG &&
      96           0 :         (pThis->GetAlign() == WINDOWALIGN_TOP)
      97           0 :         && pThis->IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL )
      98           0 :         && pThis->IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL ) )
      99             :     {
     100           0 :         SystemWindow *pSysWin = pThis->GetSystemWindow();
     101           0 :         if( pSysWin && pSysWin->GetMenuBar() )
     102             :         {
     103           0 :             Window *pMenubarWin = pSysWin->GetMenuBar()->GetWindow();
     104           0 :             if( pMenubarWin )
     105           0 :                 pMenubarWin->Invalidate();
     106             :         }
     107             :     }
     108        2591 : }
     109             : 
     110        2368 : void DockingAreaWindow::StateChanged( StateChangedType nType )
     111             : {
     112        2368 :     Window::StateChanged( nType );
     113             : 
     114        2368 :     if ( nType == STATE_CHANGE_VISIBLE )
     115         744 :         ImplInvalidateMenubar( this );
     116        2368 : }
     117             : 
     118             : // -----------------------------------------------------------------------
     119             : 
     120           0 : sal_Bool DockingAreaWindow::IsHorizontal() const
     121             : {
     122           0 :     return ( mpImplData->meAlign == WINDOWALIGN_TOP || mpImplData->meAlign == WINDOWALIGN_BOTTOM );
     123             : }
     124             : 
     125        1920 : void DockingAreaWindow::SetAlign( WindowAlign eNewAlign )
     126             : {
     127        1920 :     if( eNewAlign != mpImplData->meAlign )
     128             :     {
     129        1440 :         mpImplData->meAlign = eNewAlign;
     130        1440 :         Invalidate();
     131             :     }
     132        1920 : }
     133             : 
     134           0 : WindowAlign DockingAreaWindow::GetAlign() const
     135             : {
     136           0 :     return mpImplData->meAlign;
     137             : }
     138             : 
     139             : // -----------------------------------------------------------------------
     140             : 
     141         435 : void DockingAreaWindow::Paint( const Rectangle& )
     142             : {
     143         435 :     EnableNativeWidget( sal_True ); // only required because the toolkit curently switches this flag off
     144         435 :     if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
     145             :     {
     146           0 :         ToolbarValue        aControlValue;
     147             : 
     148           0 :         if( GetAlign() == WINDOWALIGN_TOP && ImplGetSVData()->maNWFData.mbMenuBarDockingAreaCommonBG )
     149             :         {
     150             :             // give NWF a hint that this dockingarea is adjacent to the menubar
     151             :             // useful for special gradient effects that should cover both windows
     152           0 :             aControlValue.mbIsTopDockingArea = sal_True;
     153             :         }
     154           0 :         ControlState        nState = CTRL_STATE_ENABLED;
     155             : 
     156           0 :         if( !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB )
     157             :         {
     158             :             // draw a single toolbar background covering the whole docking area
     159           0 :             Point tmp;
     160           0 :             Rectangle aCtrlRegion( tmp, GetOutputSizePixel() );
     161             : 
     162           0 :             DrawNativeControl( CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
     163           0 :                                aCtrlRegion, nState, aControlValue, rtl::OUString() );
     164             : 
     165           0 :             if( !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames )
     166             :             {
     167             :                 // each toolbar gets a thin border to better recognize its borders on the homogeneous docking area
     168           0 :                 sal_uInt16 nChildren = GetChildCount();
     169           0 :                 for( sal_uInt16 n = 0; n < nChildren; n++ )
     170             :                 {
     171           0 :                     Window* pChild = GetChild( n );
     172           0 :                     if ( pChild->IsVisible() )
     173             :                     {
     174           0 :                         Point aPos = pChild->GetPosPixel();
     175           0 :                         Size aSize = pChild->GetSizePixel();
     176           0 :                         Rectangle aRect( aPos, aSize );
     177             : 
     178           0 :                         SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
     179           0 :                         DrawLine( aRect.TopLeft(), aRect.TopRight() );
     180           0 :                         DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
     181             : 
     182           0 :                         SetLineColor( GetSettings().GetStyleSettings().GetSeparatorColor() );
     183           0 :                         DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
     184           0 :                         DrawLine( aRect.TopRight(), aRect.BottomRight() );
     185             :                     }
     186             :                 }
     187             :             }
     188             :         }
     189             :         else
     190             :         {
     191             :             // create map to find toolbar lines
     192           0 :             Size aOutSz = GetOutputSizePixel();
     193           0 :             std::map< int, int > ranges;
     194           0 :             sal_uInt16 nChildren = GetChildCount();
     195           0 :             for( sal_uInt16 n = 0; n < nChildren; n++ )
     196             :             {
     197           0 :                 Window* pChild = GetChild( n );
     198           0 :                 Point aPos = pChild->GetPosPixel();
     199           0 :                 Size aSize = pChild->GetSizePixel();
     200           0 :                 if( IsHorizontal() )
     201           0 :                     ranges[ aPos.Y() ] = aSize.Height();
     202             :                 else
     203           0 :                     ranges[ aPos.X() ] = aSize.Width();
     204             :             }
     205             : 
     206             : 
     207             :             // draw multiple toolbar backgrounds, i.e., one for each toolbar line
     208           0 :             for( std::map<int,int>::const_iterator it = ranges.begin(); it != ranges.end(); ++it )
     209             :             {
     210           0 :                 Rectangle aTBRect;
     211           0 :                 if( IsHorizontal() )
     212             :                 {
     213           0 :                     aTBRect.Left()      = 0;
     214           0 :                     aTBRect.Right()     = aOutSz.Width() - 1;
     215           0 :                     aTBRect.Top()       = it->first;
     216           0 :                     aTBRect.Bottom()    = it->first + it->second - 1;
     217             :                 }
     218             :                 else
     219             :                 {
     220           0 :                     aTBRect.Left()      = it->first;
     221           0 :                     aTBRect.Right()     = it->first + it->second - 1;
     222           0 :                     aTBRect.Top()       = 0;
     223           0 :                     aTBRect.Bottom()    = aOutSz.Height() - 1;
     224             :                 }
     225           0 :                 DrawNativeControl( CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
     226           0 :                                    aTBRect, nState, aControlValue, rtl::OUString() );
     227           0 :             }
     228           0 :         }
     229             :     }
     230         435 : }
     231             : 
     232        1847 : void DockingAreaWindow::Resize()
     233             : {
     234        1847 :     ImplInvalidateMenubar( this );
     235        1847 :     if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
     236           0 :         Invalidate();
     237        1847 : }
     238             : 
     239             : // -----------------------------------------------------------------------
     240             : 
     241             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10