LCOV - code coverage report
Current view: top level - libreoffice/vcl/source/window - tabpage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 117 0.9 %
Date: 2012-12-27 Functions: 2 18 11.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             : 
      21             : #include <tools/rc.h>
      22             : 
      23             : #include <vcl/event.hxx>
      24             : #include <vcl/layout.hxx>
      25             : #include <vcl/svapp.hxx>
      26             : #include <vcl/tabpage.hxx>
      27             : #include <vcl/tabctrl.hxx>
      28             : #include <vcl/bitmapex.hxx>
      29             : 
      30             : #include <svdata.hxx>
      31             : 
      32             : #include <com/sun/star/accessibility/XAccessible.hpp>
      33             : 
      34             : // =======================================================================
      35             : 
      36           0 : void TabPage::ImplInit( Window* pParent, WinBits nStyle )
      37             : {
      38           0 :     if ( !(nStyle & WB_NODIALOGCONTROL) )
      39           0 :         nStyle |= WB_DIALOGCONTROL;
      40             : 
      41           0 :     Window::ImplInit( pParent, nStyle, NULL );
      42             : 
      43           0 :     ImplInitSettings();
      44             : 
      45             :     // if the tabpage is drawn (ie filled) by a native widget, make sure all contols will have transparent background
      46             :     // otherwise they will paint with a wrong background
      47           0 :     if( IsNativeControlSupported(CTRL_TAB_BODY, PART_ENTIRE_CONTROL) && GetParent() && (GetParent()->GetType() == WINDOW_TABCONTROL) )
      48           0 :         EnableChildTransparentMode( sal_True );
      49           0 : }
      50             : 
      51             : // -----------------------------------------------------------------------
      52             : 
      53           0 : void TabPage::ImplInitSettings()
      54             : {
      55           0 :     Window* pParent = GetParent();
      56           0 :     if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
      57             :     {
      58           0 :         EnableChildTransparentMode( sal_True );
      59           0 :         SetParentClipMode( PARENTCLIPMODE_NOCLIP );
      60           0 :         SetPaintTransparent( sal_True );
      61           0 :         SetBackground();
      62             :     }
      63             :     else
      64             :     {
      65           0 :         EnableChildTransparentMode( sal_False );
      66           0 :         SetParentClipMode( 0 );
      67           0 :         SetPaintTransparent( sal_False );
      68             : 
      69           0 :         if ( IsControlBackground() )
      70           0 :             SetBackground( GetControlBackground() );
      71             :         else
      72           0 :             SetBackground( pParent->GetBackground() );
      73             :     }
      74           0 : }
      75             : 
      76             : // -----------------------------------------------------------------------
      77             : 
      78           0 : TabPage::TabPage( Window* pParent, WinBits nStyle ) :
      79           0 :     Window( WINDOW_TABPAGE )
      80             : {
      81           0 :     ImplInit( pParent, nStyle );
      82           0 : }
      83             : 
      84             : // -----------------------------------------------------------------------
      85             : 
      86           0 : TabPage::TabPage( Window* pParent, const ResId& rResId ) :
      87           0 :     Window( WINDOW_TABPAGE )
      88             : {
      89           0 :     rResId.SetRT( RSC_TABPAGE );
      90           0 :     WinBits nStyle = ImplInitRes( rResId );
      91           0 :     ImplInit( pParent, nStyle );
      92           0 :     ImplLoadRes(rResId);
      93             : 
      94           0 :     if ( !(nStyle & WB_HIDE) )
      95           0 :         Show();
      96           0 : }
      97             : 
      98           0 : TabPage::TabPage(Window *pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription)
      99           0 :     : Window(WINDOW_TABPAGE)
     100             : {
     101           0 :     ImplInit(pParent, 0);
     102           0 :     m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID);
     103           0 : }
     104             : 
     105             : // -----------------------------------------------------------------------
     106             : 
     107           0 : void TabPage::StateChanged( StateChangedType nType )
     108             : {
     109           0 :     Window::StateChanged( nType );
     110             : 
     111           0 :     if ( nType == STATE_CHANGE_INITSHOW )
     112             :     {
     113           0 :         if ( GetSettings().GetStyleSettings().GetAutoMnemonic() )
     114           0 :             ImplWindowAutoMnemonic( this );
     115             :         // FIXME: no layouting, workaround some clipping issues
     116           0 :         ImplAdjustNWFSizes();
     117             :     }
     118           0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     119             :     {
     120           0 :         ImplInitSettings();
     121           0 :         Invalidate();
     122             :     }
     123           0 : }
     124             : 
     125             : // -----------------------------------------------------------------------
     126             : 
     127           0 : void TabPage::DataChanged( const DataChangedEvent& rDCEvt )
     128             : {
     129           0 :     Window::DataChanged( rDCEvt );
     130             : 
     131           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     132           0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     133             :     {
     134           0 :         ImplInitSettings();
     135           0 :         Invalidate();
     136             :     }
     137           0 : }
     138             : 
     139             : // -----------------------------------------------------------------------
     140             : 
     141           0 : void TabPage::Paint( const Rectangle& )
     142             : {
     143             :     // draw native tabpage only inside tabcontrols, standalone tabpages look ugly (due to bad dialog design)
     144           0 :     if( IsNativeControlSupported(CTRL_TAB_BODY, PART_ENTIRE_CONTROL) && GetParent() && (GetParent()->GetType() == WINDOW_TABCONTROL) )
     145             :     {
     146           0 :         const ImplControlValue aControlValue;
     147             : 
     148           0 :         ControlState nState = CTRL_STATE_ENABLED;
     149           0 :         int part = PART_ENTIRE_CONTROL;
     150           0 :         if ( !IsEnabled() )
     151           0 :             nState &= ~CTRL_STATE_ENABLED;
     152           0 :         if ( HasFocus() )
     153           0 :             nState |= CTRL_STATE_FOCUSED;
     154           0 :         Point aPoint;
     155             :         // pass the whole window region to NWF as the tab body might be a gradient or bitmap
     156             :         // that has to be scaled properly, clipping makes sure that we do not paint too much
     157           0 :         Rectangle aCtrlRegion( aPoint, GetOutputSizePixel() );
     158             :         DrawNativeControl( CTRL_TAB_BODY, part, aCtrlRegion, nState,
     159           0 :                 aControlValue, rtl::OUString() );
     160             :     }
     161           0 : }
     162             : 
     163             : // -----------------------------------------------------------------------
     164           0 : void TabPage::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong )
     165             : {
     166           0 :     Point aPos = pDev->LogicToPixel( rPos );
     167           0 :     Size aSize = pDev->LogicToPixel( rSize );
     168             : 
     169           0 :     Wallpaper aWallpaper = GetBackground();
     170           0 :     if ( !aWallpaper.IsBitmap() )
     171           0 :         ImplInitSettings();
     172             : 
     173           0 :     pDev->Push();
     174           0 :     pDev->SetMapMode();
     175           0 :     pDev->SetLineColor();
     176             : 
     177           0 :     if ( aWallpaper.IsBitmap() )
     178           0 :         pDev->DrawBitmapEx( aPos, aSize, aWallpaper.GetBitmap() );
     179             :     else
     180             :     {
     181           0 :         if( aWallpaper.GetColor() == COL_AUTO )
     182           0 :             pDev->SetFillColor( GetSettings().GetStyleSettings().GetDialogColor() );
     183             :         else
     184           0 :             pDev->SetFillColor( aWallpaper.GetColor() );
     185           0 :         pDev->DrawRect( Rectangle( aPos, aSize ) );
     186             :     }
     187             : 
     188           0 :     pDev->Pop();
     189           0 : }
     190             : 
     191             : // -----------------------------------------------------------------------
     192             : 
     193           0 : void TabPage::ActivatePage()
     194             : {
     195           0 : }
     196             : 
     197             : // -----------------------------------------------------------------------
     198             : 
     199           0 : void TabPage::DeactivatePage()
     200             : {
     201           0 : }
     202             : 
     203           0 : bool TabPage::isLayoutEnabled() const
     204             : {
     205             :     //Child is a container => we're layout enabled
     206           0 :     const Window *pChild = GetWindow(WINDOW_FIRSTCHILD);
     207           0 :     return pChild && isContainerWindow(*pChild) && !pChild->GetWindow(WINDOW_NEXT);
     208             : }
     209             : 
     210           0 : Size TabPage::GetOptimalSize(WindowSizeType eType) const
     211             : {
     212           0 :     if (eType == WINDOWSIZE_MAXIMUM)
     213           0 :         return Window::GetOptimalSize(eType);
     214           0 :     Size aSize;
     215           0 :     if (isLayoutEnabled())
     216           0 :         aSize = GetWindow(WINDOW_FIRSTCHILD)->GetOptimalSize(eType);
     217             :     else
     218           0 :         aSize = getLegacyBestSizeForChildren(*this);
     219           0 :     return Window::CalcWindowSize(aSize);
     220             : }
     221             : 
     222           0 : void TabPage::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation)
     223             : {
     224           0 :     Window::SetPosSizePixel(rAllocPos, rAllocation);
     225           0 :     if (isLayoutEnabled())
     226           0 :         VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), rAllocation);
     227           0 : }
     228             : 
     229           0 : void TabPage::SetSizePixel(const Size& rAllocation)
     230             : {
     231           0 :     Window::SetSizePixel(rAllocation);
     232           0 :     if (isLayoutEnabled())
     233           0 :         VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), rAllocation);
     234           0 : }
     235             : 
     236           0 : void TabPage::SetPosPixel(const Point& rAllocPos)
     237             : {
     238           0 :     Window::SetPosPixel(rAllocPos);
     239           0 :     if (isLayoutEnabled())
     240           0 :         VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), GetOutputSizePixel());
     241         108 : }
     242             : 
     243             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10