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

Generated by: LCOV version 1.10