LCOV - code coverage report
Current view: top level - svtools/source/contnr - svlbitm.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 258 0.0 %
Date: 2014-04-14 Functions: 0 59 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 <svtools/treelistbox.hxx>
      21             : #include <svtools/svlbitm.hxx>
      22             : #include "svtools/treelistentry.hxx"
      23             : #include "svtools/viewdataentry.hxx"
      24             : #include <vcl/svapp.hxx>
      25             : #include <vcl/button.hxx>
      26             : #include <vcl/decoview.hxx>
      27             : #include <vcl/salnativewidgets.hxx>
      28             : 
      29             : struct SvLBoxButtonData_Impl
      30             : {
      31             :     SvTreeListEntry*    pEntry;
      32             :     bool                bDefaultImages;
      33             :     bool                bShowRadioButton;
      34             : 
      35           0 :     SvLBoxButtonData_Impl() : pEntry( NULL ), bDefaultImages( false ), bShowRadioButton( false ) {}
      36             : };
      37             : 
      38             : 
      39             : 
      40           0 : void SvLBoxButtonData::InitData( bool bImagesFromDefault, bool _bRadioBtn, const Control* pCtrl )
      41             : {
      42           0 :     nWidth = nHeight = 0;
      43             : 
      44           0 :     pImpl = new SvLBoxButtonData_Impl;
      45             : 
      46           0 :     bDataOk = false;
      47           0 :     eState = SV_BUTTON_UNCHECKED;
      48           0 :     pImpl->bDefaultImages = bImagesFromDefault;
      49           0 :     pImpl->bShowRadioButton = ( _bRadioBtn != false );
      50             : 
      51           0 :     if ( bImagesFromDefault )
      52           0 :         SetDefaultImages( pCtrl );
      53           0 : }
      54             : 
      55           0 : SvLBoxButtonData::SvLBoxButtonData( const Control* pControlForSettings )
      56             : {
      57           0 :     InitData( true, false, pControlForSettings );
      58           0 : }
      59             : 
      60           0 : SvLBoxButtonData::SvLBoxButtonData( const Control* pControlForSettings, bool _bRadioBtn )
      61             : {
      62           0 :     InitData( true, _bRadioBtn, pControlForSettings );
      63           0 : }
      64             : 
      65           0 : SvLBoxButtonData::~SvLBoxButtonData()
      66             : {
      67             : 
      68           0 :     delete pImpl;
      69             : #ifdef DBG_UTIL
      70             :     pImpl = NULL;
      71             : #endif
      72           0 : }
      73             : 
      74           0 : void SvLBoxButtonData::CallLink()
      75             : {
      76           0 :     aLink.Call( this );
      77           0 : }
      78             : 
      79           0 : sal_uInt16 SvLBoxButtonData::GetIndex( sal_uInt16 nItemState )
      80             : {
      81           0 :     nItemState &= 0x000F;
      82             :     sal_uInt16 nIdx;
      83           0 :     switch( nItemState )
      84             :     {
      85             :         case SV_ITEMSTATE_UNCHECKED:
      86           0 :                 nIdx = SV_BMP_UNCHECKED; break;
      87             :         case SV_ITEMSTATE_CHECKED:
      88           0 :                 nIdx = SV_BMP_CHECKED; break;
      89             :         case SV_ITEMSTATE_TRISTATE:
      90           0 :                 nIdx = SV_BMP_TRISTATE; break;
      91             :         case SV_ITEMSTATE_UNCHECKED | SV_ITEMSTATE_HILIGHTED:
      92           0 :                 nIdx = SV_BMP_HIUNCHECKED; break;
      93             :         case SV_ITEMSTATE_CHECKED | SV_ITEMSTATE_HILIGHTED:
      94           0 :                 nIdx = SV_BMP_HICHECKED; break;
      95             :         case SV_ITEMSTATE_TRISTATE | SV_ITEMSTATE_HILIGHTED:
      96           0 :                 nIdx = SV_BMP_HITRISTATE; break;
      97             :         default:
      98           0 :                 nIdx = SV_BMP_UNCHECKED;
      99             :     }
     100           0 :     return nIdx;
     101             : }
     102             : 
     103           0 : void SvLBoxButtonData::SetWidthAndHeight()
     104             : {
     105           0 :     Size aSize = aBmps[0].GetSizePixel();
     106           0 :     nWidth = aSize.Width();
     107           0 :     nHeight = aSize.Height();
     108           0 :     bDataOk = true;
     109           0 : }
     110             : 
     111             : 
     112           0 : void SvLBoxButtonData::StoreButtonState( SvTreeListEntry* pActEntry, sal_uInt16 nItemFlags )
     113             : {
     114           0 :     pImpl->pEntry = pActEntry;
     115           0 :     eState = ConvertToButtonState( nItemFlags );
     116           0 : }
     117             : 
     118           0 : SvButtonState SvLBoxButtonData::ConvertToButtonState( sal_uInt16 nItemFlags ) const
     119             : {
     120             :     nItemFlags &= (SV_ITEMSTATE_UNCHECKED |
     121             :                    SV_ITEMSTATE_CHECKED |
     122           0 :                    SV_ITEMSTATE_TRISTATE);
     123           0 :     switch( nItemFlags )
     124             :     {
     125             :         case SV_ITEMSTATE_UNCHECKED:
     126           0 :             return SV_BUTTON_UNCHECKED;
     127             : 
     128             :         case SV_ITEMSTATE_CHECKED:
     129           0 :             return SV_BUTTON_CHECKED;
     130             : 
     131             :         case SV_ITEMSTATE_TRISTATE:
     132           0 :             return SV_BUTTON_TRISTATE;
     133             :         default:
     134           0 :             return SV_BUTTON_UNCHECKED;
     135             :     }
     136             : }
     137             : 
     138           0 : SvTreeListEntry* SvLBoxButtonData::GetActEntry() const
     139             : {
     140             :     DBG_ASSERT( pImpl, "-SvLBoxButtonData::GetActEntry(): don't use me that way!" );
     141           0 :     return pImpl->pEntry;
     142             : }
     143             : 
     144           0 : void SvLBoxButtonData::SetDefaultImages( const Control* pCtrl )
     145             : {
     146           0 :     const AllSettings& rSettings = pCtrl? pCtrl->GetSettings() : Application::GetSettings();
     147             : 
     148           0 :     if ( pImpl->bShowRadioButton )
     149             :     {
     150           0 :         aBmps[ SV_BMP_UNCHECKED ]   = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DEFAULT );
     151           0 :         aBmps[ SV_BMP_CHECKED ]     = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_CHECKED );
     152           0 :         aBmps[ SV_BMP_HICHECKED ]   = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_CHECKED | BUTTON_DRAW_PRESSED );
     153           0 :         aBmps[ SV_BMP_HIUNCHECKED ] = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DEFAULT | BUTTON_DRAW_PRESSED );
     154           0 :         aBmps[ SV_BMP_TRISTATE ]    = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DONTKNOW );
     155           0 :         aBmps[ SV_BMP_HITRISTATE ]  = RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DONTKNOW | BUTTON_DRAW_PRESSED );
     156             :     }
     157             :     else
     158             :     {
     159           0 :         aBmps[ SV_BMP_UNCHECKED ]   = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DEFAULT );
     160           0 :         aBmps[ SV_BMP_CHECKED ]     = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_CHECKED );
     161           0 :         aBmps[ SV_BMP_HICHECKED ]   = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_CHECKED | BUTTON_DRAW_PRESSED );
     162           0 :         aBmps[ SV_BMP_HIUNCHECKED ] = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DEFAULT | BUTTON_DRAW_PRESSED );
     163           0 :         aBmps[ SV_BMP_TRISTATE ]    = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DONTKNOW );
     164           0 :         aBmps[ SV_BMP_HITRISTATE ]  = CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DONTKNOW | BUTTON_DRAW_PRESSED );
     165             :     }
     166           0 : }
     167             : 
     168           0 : bool SvLBoxButtonData::HasDefaultImages( void ) const
     169             : {
     170           0 :     return pImpl->bDefaultImages;
     171             : }
     172             : 
     173           0 : bool SvLBoxButtonData::IsRadio() {
     174           0 :     return pImpl->bShowRadioButton;
     175             : }
     176             : 
     177             : // ***************************************************************
     178             : // class SvLBoxString
     179             : // ***************************************************************
     180             : 
     181             : 
     182           0 : SvLBoxString::SvLBoxString(SvTreeListEntry* pEntry, sal_uInt16 nFlags, const OUString& rStr)
     183           0 :     : SvLBoxItem(pEntry, nFlags)
     184             : {
     185           0 :     SetText(rStr);
     186           0 : }
     187             : 
     188           0 : SvLBoxString::SvLBoxString() : SvLBoxItem()
     189             : {
     190           0 : }
     191             : 
     192           0 : SvLBoxString::~SvLBoxString()
     193             : {
     194           0 : }
     195             : 
     196           0 : sal_uInt16 SvLBoxString::GetType() const
     197             : {
     198           0 :     return SV_ITEM_ID_LBOXSTRING;
     199             : }
     200             : 
     201           0 : void SvLBoxString::Paint(
     202             :     const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/,
     203             :     const SvTreeListEntry* pEntry)
     204             : {
     205           0 :     if (pEntry)
     206             :     {
     207           0 :         sal_uInt16 nStyle = rDev.IsEnabled() ? 0 : TEXT_DRAW_DISABLE;
     208           0 :         if ( rDev.IsEntryMnemonicsEnabled() )
     209           0 :             nStyle |= TEXT_DRAW_MNEMONIC;
     210           0 :         rDev.DrawText(Rectangle(rPos, GetSize(&rDev, pEntry)), maText, nStyle);
     211             :     }
     212             :     else
     213           0 :         rDev.DrawText(rPos, maText);
     214             : 
     215           0 : }
     216             : 
     217           0 : SvLBoxItem* SvLBoxString::Create() const
     218             : {
     219           0 :     return new SvLBoxString;
     220             : }
     221             : 
     222           0 : void SvLBoxString::Clone( SvLBoxItem* pSource )
     223             : {
     224           0 :     maText = ((SvLBoxString*)pSource)->maText;
     225           0 : }
     226             : 
     227           0 : void SvLBoxString::InitViewData(
     228             :     SvTreeListBox* pView, SvTreeListEntry* pEntry, SvViewDataItem* pViewData)
     229             : {
     230           0 :     if( !pViewData )
     231           0 :         pViewData = pView->GetViewDataItem( pEntry, this );
     232             : 
     233             :     // fdo#72125: GetTextWidth() can get very expensive; let's just count
     234             :     // an approximate width using a cached value when we have many entries
     235             :     long nTextWidth;
     236           0 :     if (pView->GetEntryCount() > 100)
     237             :     {
     238             :         static SvTreeListBox *pPreviousView = NULL;
     239             :         static float fApproximateCharWidth = 0.0;
     240           0 :         if (pPreviousView != pView)
     241             :         {
     242           0 :             pPreviousView = pView;
     243           0 :             fApproximateCharWidth = pView->approximate_char_width();
     244             :         }
     245           0 :         nTextWidth = maText.getLength() * fApproximateCharWidth;
     246             :     }
     247             :     else
     248           0 :         nTextWidth = pView->GetTextWidth(maText);
     249             : 
     250           0 :     pViewData->maSize = Size(nTextWidth, pView->GetTextHeight());
     251           0 : }
     252             : 
     253             : // ***************************************************************
     254             : // class SvLBoxBmp
     255             : // ***************************************************************
     256             : 
     257             : 
     258           0 : SvLBoxBmp::SvLBoxBmp() : SvLBoxItem()
     259             : {
     260           0 : }
     261             : 
     262           0 : SvLBoxBmp::~SvLBoxBmp()
     263             : {
     264           0 : }
     265             : 
     266           0 : sal_uInt16 SvLBoxBmp::GetType() const
     267             : {
     268           0 :     return SV_ITEM_ID_LBOXBMP;
     269             : }
     270             : 
     271           0 : void SvLBoxBmp::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry,
     272             :     SvViewDataItem* pViewData)
     273             : {
     274           0 :     if( !pViewData )
     275           0 :         pViewData = pView->GetViewDataItem( pEntry, this );
     276           0 :     pViewData->maSize = aBmp.GetSizePixel();
     277           0 : }
     278             : 
     279           0 : void SvLBoxBmp::Paint(
     280             :     const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/,
     281             :     const SvTreeListEntry* /*pEntry*/)
     282             : {
     283           0 :     sal_uInt16 nStyle = rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE;
     284           0 :     rDev.DrawImage( rPos, aBmp ,nStyle);
     285           0 : }
     286             : 
     287           0 : SvLBoxItem* SvLBoxBmp::Create() const
     288             : {
     289           0 :     return new SvLBoxBmp;
     290             : }
     291             : 
     292           0 : void SvLBoxBmp::Clone( SvLBoxItem* pSource )
     293             : {
     294           0 :     aBmp = ((SvLBoxBmp*)pSource)->aBmp;
     295           0 : }
     296             : 
     297             : // ***************************************************************
     298             : // class SvLBoxButton
     299             : // ***************************************************************
     300             : 
     301             : 
     302           0 : SvLBoxButton::SvLBoxButton( SvTreeListEntry* pEntry, SvLBoxButtonKind eTheKind,
     303             :                             sal_uInt16 nFlags, SvLBoxButtonData* pBData )
     304             :     : SvLBoxItem( pEntry, nFlags )
     305             :     , isVis(true)
     306             :     , pData(pBData)
     307             :     , eKind(eTheKind)
     308             :     , nItemFlags(0)
     309           0 :     , nBaseOffs(0)
     310             : {
     311           0 :     SetStateUnchecked();
     312           0 : }
     313             : 
     314           0 : SvLBoxButton::SvLBoxButton()
     315             :     : SvLBoxItem()
     316             :     , isVis(false)
     317             :     , pData(0)
     318             :     , eKind(SvLBoxButtonKind_enabledCheckbox)
     319             :     , nItemFlags(0)
     320           0 :     , nBaseOffs(0)
     321             : {
     322           0 :     SetStateUnchecked();
     323           0 : }
     324             : 
     325           0 : SvLBoxButton::~SvLBoxButton()
     326             : {
     327           0 : }
     328             : 
     329           0 : sal_uInt16 SvLBoxButton::GetType() const
     330             : {
     331           0 :     return SV_ITEM_ID_LBOXBUTTON;
     332             : }
     333             : 
     334           0 : bool SvLBoxButton::ClickHdl( SvTreeListBox*, SvTreeListEntry* pEntry )
     335             : {
     336           0 :     if ( CheckModification() )
     337             :     {
     338           0 :         if ( IsStateChecked() )
     339           0 :             SetStateUnchecked();
     340             :         else
     341           0 :             SetStateChecked();
     342           0 :         pData->StoreButtonState( pEntry, nItemFlags );
     343           0 :         pData->CallLink();
     344             :     }
     345           0 :     return false;
     346             : }
     347             : 
     348           0 : void SvLBoxButton::Paint(
     349             :     const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/,
     350             :     const SvTreeListEntry* /*pEntry*/)
     351             : {
     352           0 :     sal_uInt16 nIndex = eKind == SvLBoxButtonKind_staticImage
     353           0 :         ? SV_BMP_STATICIMAGE : pData->GetIndex( nItemFlags );
     354           0 :     sal_uInt16 nStyle = eKind != SvLBoxButtonKind_disabledCheckbox &&
     355           0 :         rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE;
     356             : 
     357             :     //Native drawing
     358           0 :     bool bNativeOK = false;
     359           0 :     ControlType eCtrlType = (pData->IsRadio())? CTRL_RADIOBUTTON : CTRL_CHECKBOX;
     360           0 :     if ( nIndex != SV_BMP_STATICIMAGE && rDev.IsNativeControlSupported( eCtrlType, PART_ENTIRE_CONTROL) )
     361             : 
     362             :     {
     363           0 :         Size aSize(pData->Width(), pData->Height());
     364           0 :         ImplAdjustBoxSize( aSize, eCtrlType, &rDev );
     365           0 :         ImplControlValue    aControlValue;
     366           0 :         Rectangle           aCtrlRegion( rPos, aSize );
     367           0 :         ControlState        nState = 0;
     368             : 
     369             :         //states CTRL_STATE_DEFAULT, CTRL_STATE_PRESSED and CTRL_STATE_ROLLOVER are not implemented
     370           0 :         if ( IsStateHilighted() )                   nState |= CTRL_STATE_FOCUSED;
     371           0 :         if ( nStyle != IMAGE_DRAW_DISABLE )         nState |= CTRL_STATE_ENABLED;
     372             : 
     373           0 :         if ( IsStateChecked() )
     374           0 :             aControlValue.setTristateVal( BUTTONVALUE_ON );
     375           0 :         else if ( IsStateUnchecked() )
     376           0 :             aControlValue.setTristateVal( BUTTONVALUE_OFF );
     377           0 :         else if ( IsStateTristate() )
     378           0 :             aControlValue.setTristateVal( BUTTONVALUE_MIXED );
     379             : 
     380           0 :         if( isVis)
     381             :             bNativeOK = rDev.DrawNativeControl( eCtrlType, PART_ENTIRE_CONTROL,
     382           0 :                                 aCtrlRegion, nState, aControlValue, OUString() );
     383             :     }
     384             : 
     385           0 :     if( !bNativeOK && isVis )
     386           0 :         rDev.DrawImage( rPos, pData->aBmps[nIndex + nBaseOffs] ,nStyle);
     387           0 : }
     388             : 
     389           0 : SvLBoxItem* SvLBoxButton::Create() const
     390             : {
     391           0 :     return new SvLBoxButton;
     392             : }
     393             : 
     394           0 : void SvLBoxButton::Clone( SvLBoxItem* pSource )
     395             : {
     396           0 :     pData = ((SvLBoxButton*)pSource)->pData;
     397           0 : }
     398             : 
     399           0 : void SvLBoxButton::ImplAdjustBoxSize( Size& io_rSize, ControlType i_eType, Window* i_pParent )
     400             : {
     401           0 :     if ( i_pParent->IsNativeControlSupported( i_eType, PART_ENTIRE_CONTROL) )
     402             :     {
     403           0 :         ImplControlValue    aControlValue;
     404           0 :         Rectangle           aCtrlRegion( Point( 0, 0 ), io_rSize );
     405           0 :         ControlState        nState = CTRL_STATE_ENABLED;
     406             : 
     407           0 :         aControlValue.setTristateVal( BUTTONVALUE_ON );
     408             : 
     409           0 :         Rectangle aNativeBounds, aNativeContent;
     410             :         bool bNativeOK = i_pParent->GetNativeControlRegion( i_eType,
     411             :                                                             PART_ENTIRE_CONTROL,
     412             :                                                             aCtrlRegion,
     413             :                                                             nState,
     414             :                                                             aControlValue,
     415             :                                                             OUString(),
     416             :                                                             aNativeBounds,
     417           0 :                                                             aNativeContent );
     418           0 :         if( bNativeOK )
     419             :         {
     420           0 :             Size aContentSize( aNativeContent.GetSize() );
     421             :             // leave a little space around the box image (looks better)
     422           0 :             if( aContentSize.Height() + 2 > io_rSize.Height() )
     423           0 :                 io_rSize.Height() = aContentSize.Height() + 2;
     424           0 :             if( aContentSize.Width() + 2 > io_rSize.Width() )
     425           0 :                 io_rSize.Width() = aContentSize.Width() + 2;
     426           0 :         }
     427             :     }
     428           0 : }
     429             : 
     430           0 : void SvLBoxButton::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry,
     431             :     SvViewDataItem* pViewData )
     432             : {
     433           0 :     if( !pViewData )
     434           0 :         pViewData = pView->GetViewDataItem( pEntry, this );
     435           0 :     Size aSize( pData->Width(), pData->Height() );
     436             : 
     437           0 :     ControlType eCtrlType = (pData->IsRadio())? CTRL_RADIOBUTTON : CTRL_CHECKBOX;
     438           0 :     if ( eKind != SvLBoxButtonKind_staticImage && pView )
     439           0 :         ImplAdjustBoxSize( aSize, eCtrlType, pView );
     440           0 :     pViewData->maSize = aSize;
     441           0 : }
     442             : 
     443           0 : bool SvLBoxButton::CheckModification() const
     444             : {
     445           0 :     return eKind == SvLBoxButtonKind_enabledCheckbox;
     446             : }
     447             : 
     448           0 : void SvLBoxButton::SetStateInvisible()
     449             : {
     450           0 :     isVis = false;
     451           0 : }
     452             : 
     453             : // ***************************************************************
     454             : // class SvLBoxContextBmp
     455             : // ***************************************************************
     456             : 
     457           0 : struct SvLBoxContextBmp_Impl
     458             : {
     459             :     Image       m_aImage1;
     460             :     Image       m_aImage2;
     461             : 
     462             :     bool        m_bExpanded;
     463             : };
     464             : 
     465             : // ***************************************************************
     466             : 
     467           0 : SvLBoxContextBmp::SvLBoxContextBmp(
     468             :     SvTreeListEntry* pEntry, sal_uInt16 nItemFlags, Image aBmp1, Image aBmp2,
     469             :     bool bExpanded)
     470             :     :SvLBoxItem( pEntry, nItemFlags )
     471           0 :     ,m_pImpl( new SvLBoxContextBmp_Impl )
     472             : {
     473             : 
     474           0 :     m_pImpl->m_bExpanded = bExpanded;
     475           0 :     SetModeImages( aBmp1, aBmp2 );
     476           0 : }
     477             : 
     478           0 : SvLBoxContextBmp::SvLBoxContextBmp()
     479             :     :SvLBoxItem( )
     480           0 :     ,m_pImpl( new SvLBoxContextBmp_Impl )
     481             : {
     482           0 :     m_pImpl->m_bExpanded = false;
     483           0 : }
     484             : 
     485           0 : SvLBoxContextBmp::~SvLBoxContextBmp()
     486             : {
     487           0 :     delete m_pImpl;
     488           0 : }
     489             : 
     490           0 : sal_uInt16 SvLBoxContextBmp::GetType() const
     491             : {
     492           0 :     return SV_ITEM_ID_LBOXCONTEXTBMP;
     493             : }
     494             : 
     495           0 : bool SvLBoxContextBmp::SetModeImages( const Image& _rBitmap1, const Image& _rBitmap2 )
     496             : {
     497           0 :     bool bSuccess = true;
     498           0 :     m_pImpl->m_aImage1 = _rBitmap1;
     499           0 :     m_pImpl->m_aImage2 = _rBitmap2;
     500           0 :     return bSuccess;
     501             : }
     502             : 
     503           0 : Image& SvLBoxContextBmp::implGetImageStore( bool _bFirst )
     504             : {
     505             : 
     506             :     // OJ: #i27071# wrong mode so we just return the normal images
     507           0 :     return _bFirst ? m_pImpl->m_aImage1 : m_pImpl->m_aImage2;
     508             : }
     509             : 
     510           0 : void SvLBoxContextBmp::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry,
     511             :     SvViewDataItem* pViewData)
     512             : {
     513           0 :     if( !pViewData )
     514           0 :         pViewData = pView->GetViewDataItem( pEntry, this );
     515           0 :     pViewData->maSize = m_pImpl->m_aImage1.GetSizePixel();
     516           0 : }
     517             : 
     518           0 : void SvLBoxContextBmp::Paint(
     519             :     const Point& _rPos, SvTreeListBox& _rDev,
     520             :     const SvViewDataEntry* pView, const SvTreeListEntry* pEntry)
     521             : {
     522             : 
     523             :     // get the image.
     524           0 :     const Image& rImage = implGetImageStore(pView->IsExpanded() != m_pImpl->m_bExpanded);
     525             : 
     526           0 :     bool _bSemiTransparent = pEntry && ( 0 != ( SV_ENTRYFLAG_SEMITRANSPARENT  & pEntry->GetFlags( ) ) );
     527             :     // draw
     528           0 :     sal_uInt16 nStyle = _rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE;
     529           0 :     if ( _bSemiTransparent )
     530           0 :         nStyle |= IMAGE_DRAW_SEMITRANSPARENT;
     531           0 :     _rDev.DrawImage( _rPos, rImage, nStyle);
     532           0 : }
     533             : 
     534           0 : SvLBoxItem* SvLBoxContextBmp::Create() const
     535             : {
     536           0 :     return new SvLBoxContextBmp;
     537             : }
     538             : 
     539           0 : void SvLBoxContextBmp::Clone( SvLBoxItem* pSource )
     540             : {
     541           0 :     m_pImpl->m_aImage1 = static_cast< SvLBoxContextBmp* >( pSource )->m_pImpl->m_aImage1;
     542           0 :     m_pImpl->m_aImage2 = static_cast< SvLBoxContextBmp* >( pSource )->m_pImpl->m_aImage2;
     543           0 :     m_pImpl->m_bExpanded = static_cast<SvLBoxContextBmp*>(pSource)->m_pImpl->m_bExpanded;
     544           0 : }
     545             : 
     546           0 : long SvLBoxButtonData::Width()
     547             : {
     548           0 :     if ( !bDataOk )
     549           0 :         SetWidthAndHeight();
     550           0 :     return nWidth;
     551             : }
     552             : 
     553           0 : long SvLBoxButtonData::Height()
     554             : {
     555           0 :     if ( !bDataOk )
     556           0 :         SetWidthAndHeight();
     557           0 :     return nHeight;
     558             : }
     559             : 
     560             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10