LCOV - code coverage report
Current view: top level - svtools/source/contnr - svlbitm.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 52 260 20.0 %
Date: 2014-11-03 Functions: 18 61 29.5 %
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           0 : void SvLBoxButtonData::InitData( bool bImagesFromDefault, bool _bRadioBtn, const Control* pCtrl )
      39             : {
      40           0 :     nWidth = nHeight = 0;
      41             : 
      42           0 :     aBmps.resize((int)SvBmp::STATICIMAGE+1);
      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;
      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 : SvBmp SvLBoxButtonData::GetIndex( sal_uInt16 nItemState )
      80             : {
      81           0 :     nItemState &= 0x000F;
      82             :     SvBmp nIdx;
      83           0 :     switch( nItemState )
      84             :     {
      85             :         case SV_ITEMSTATE_UNCHECKED:
      86           0 :                 nIdx = SvBmp::UNCHECKED; break;
      87             :         case SV_ITEMSTATE_CHECKED:
      88           0 :                 nIdx = SvBmp::CHECKED; break;
      89             :         case SV_ITEMSTATE_TRISTATE:
      90           0 :                 nIdx = SvBmp::TRISTATE; break;
      91             :         case SV_ITEMSTATE_UNCHECKED | SV_ITEMSTATE_HILIGHTED:
      92           0 :                 nIdx = SvBmp::HIUNCHECKED; break;
      93             :         case SV_ITEMSTATE_CHECKED | SV_ITEMSTATE_HILIGHTED:
      94           0 :                 nIdx = SvBmp::HICHECKED; break;
      95             :         case SV_ITEMSTATE_TRISTATE | SV_ITEMSTATE_HILIGHTED:
      96           0 :                 nIdx = SvBmp::HITRISTATE; break;
      97             :         default:
      98           0 :                 nIdx = SvBmp::UNCHECKED;
      99             :     }
     100           0 :     return nIdx;
     101             : }
     102             : 
     103           0 : void SvLBoxButtonData::SetWidthAndHeight()
     104             : {
     105           0 :     Size aSize = aBmps[(int)SvBmp::UNCHECKED].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             :     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 :         SetImage(SvBmp::UNCHECKED,   RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DEFAULT ) );
     151           0 :         SetImage(SvBmp::CHECKED,     RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_CHECKED ) );
     152           0 :         SetImage(SvBmp::HICHECKED,   RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_CHECKED | BUTTON_DRAW_PRESSED ) );
     153           0 :         SetImage(SvBmp::HIUNCHECKED, RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DEFAULT | BUTTON_DRAW_PRESSED ) );
     154           0 :         SetImage(SvBmp::TRISTATE,    RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DONTKNOW ) );
     155           0 :         SetImage(SvBmp::HITRISTATE,  RadioButton::GetRadioImage( rSettings, BUTTON_DRAW_DONTKNOW | BUTTON_DRAW_PRESSED ) );
     156             :     }
     157             :     else
     158             :     {
     159           0 :         SetImage(SvBmp::UNCHECKED,   CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DEFAULT ) );
     160           0 :         SetImage(SvBmp::CHECKED,     CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_CHECKED ) );
     161           0 :         SetImage(SvBmp::HICHECKED,   CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_CHECKED | BUTTON_DRAW_PRESSED ) );
     162           0 :         SetImage(SvBmp::HIUNCHECKED, CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DEFAULT | BUTTON_DRAW_PRESSED ) );
     163           0 :         SetImage(SvBmp::TRISTATE,    CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DONTKNOW ) );
     164           0 :         SetImage(SvBmp::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        2900 : SvLBoxString::SvLBoxString(SvTreeListEntry* pEntry, sal_uInt16 nFlags, const OUString& rStr)
     183        2900 :     : SvLBoxItem(pEntry, nFlags)
     184             : {
     185        2900 :     SetText(rStr);
     186        2900 : }
     187             : 
     188           0 : SvLBoxString::SvLBoxString() : SvLBoxItem()
     189             : {
     190           0 : }
     191             : 
     192        4352 : SvLBoxString::~SvLBoxString()
     193             : {
     194        4352 : }
     195             : 
     196        1767 : sal_uInt16 SvLBoxString::GetType() const
     197             : {
     198        1767 :     return SV_ITEM_ID_LBOXSTRING;
     199             : }
     200             : 
     201        1767 : void SvLBoxString::Paint(
     202             :     const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/,
     203             :     const SvTreeListEntry* pEntry)
     204             : {
     205        1767 :     if (pEntry)
     206             :     {
     207        1767 :         sal_uInt16 nStyle = rDev.IsEnabled() ? 0 : TEXT_DRAW_DISABLE;
     208        1767 :         if ( rDev.IsEntryMnemonicsEnabled() )
     209           0 :             nStyle |= TEXT_DRAW_MNEMONIC;
     210        1767 :         rDev.DrawText(Rectangle(rPos, GetSize(&rDev, pEntry)), maText, nStyle);
     211             :     }
     212             :     else
     213           0 :         rDev.DrawText(rPos, maText);
     214             : 
     215        1767 : }
     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 = static_cast<SvLBoxString*>(pSource)->maText;
     225           0 : }
     226             : 
     227        1528 : void SvLBoxString::InitViewData(
     228             :     SvTreeListBox* pView, SvTreeListEntry* pEntry, SvViewDataItem* pViewData)
     229             : {
     230        1528 :     if( !pViewData )
     231          78 :         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        1528 :     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        1528 :         nTextWidth = pView->GetTextWidth(maText);
     249             : 
     250        1528 :     pViewData->maSize = Size(nTextWidth, pView->GetTextHeight());
     251        1528 : }
     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 = static_cast<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           0 :     , nItemFlags(0)
     309             : {
     310           0 :     SetStateUnchecked();
     311           0 : }
     312             : 
     313           0 : SvLBoxButton::SvLBoxButton()
     314             :     : SvLBoxItem()
     315             :     , isVis(false)
     316             :     , pData(0)
     317             :     , eKind(SvLBoxButtonKind_enabledCheckbox)
     318           0 :     , nItemFlags(0)
     319             : {
     320           0 :     SetStateUnchecked();
     321           0 : }
     322             : 
     323           0 : SvLBoxButton::~SvLBoxButton()
     324             : {
     325           0 : }
     326             : 
     327           0 : sal_uInt16 SvLBoxButton::GetType() const
     328             : {
     329           0 :     return SV_ITEM_ID_LBOXBUTTON;
     330             : }
     331             : 
     332           0 : bool SvLBoxButton::ClickHdl( SvTreeListBox*, SvTreeListEntry* pEntry )
     333             : {
     334           0 :     if ( CheckModification() )
     335             :     {
     336           0 :         if ( IsStateChecked() )
     337           0 :             SetStateUnchecked();
     338             :         else
     339           0 :             SetStateChecked();
     340           0 :         pData->StoreButtonState( pEntry, nItemFlags );
     341           0 :         pData->CallLink();
     342             :     }
     343           0 :     return false;
     344             : }
     345             : 
     346           0 : void SvLBoxButton::Paint(
     347             :     const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/,
     348             :     const SvTreeListEntry* /*pEntry*/)
     349             : {
     350           0 :     SvBmp nIndex = eKind == SvLBoxButtonKind_staticImage
     351           0 :         ? SvBmp::STATICIMAGE : pData->GetIndex( nItemFlags );
     352           0 :     sal_uInt16 nStyle = eKind != SvLBoxButtonKind_disabledCheckbox &&
     353           0 :         rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE;
     354             : 
     355             :     //Native drawing
     356           0 :     bool bNativeOK = false;
     357           0 :     ControlType eCtrlType = (pData->IsRadio())? CTRL_RADIOBUTTON : CTRL_CHECKBOX;
     358           0 :     if ( nIndex != SvBmp::STATICIMAGE && rDev.IsNativeControlSupported( eCtrlType, PART_ENTIRE_CONTROL) )
     359             : 
     360             :     {
     361           0 :         Size aSize(pData->Width(), pData->Height());
     362           0 :         ImplAdjustBoxSize( aSize, eCtrlType, &rDev );
     363           0 :         ImplControlValue    aControlValue;
     364           0 :         Rectangle           aCtrlRegion( rPos, aSize );
     365           0 :         ControlState        nState = 0;
     366             : 
     367             :         //states CTRL_STATE_DEFAULT, CTRL_STATE_PRESSED and CTRL_STATE_ROLLOVER are not implemented
     368           0 :         if ( IsStateHilighted() )                   nState |= CTRL_STATE_FOCUSED;
     369           0 :         if ( nStyle != IMAGE_DRAW_DISABLE )         nState |= CTRL_STATE_ENABLED;
     370             : 
     371           0 :         if ( IsStateChecked() )
     372           0 :             aControlValue.setTristateVal( BUTTONVALUE_ON );
     373           0 :         else if ( IsStateUnchecked() )
     374           0 :             aControlValue.setTristateVal( BUTTONVALUE_OFF );
     375           0 :         else if ( IsStateTristate() )
     376           0 :             aControlValue.setTristateVal( BUTTONVALUE_MIXED );
     377             : 
     378           0 :         if( isVis)
     379             :             bNativeOK = rDev.DrawNativeControl( eCtrlType, PART_ENTIRE_CONTROL,
     380           0 :                                 aCtrlRegion, nState, aControlValue, OUString() );
     381             :     }
     382             : 
     383           0 :     if( !bNativeOK && isVis )
     384           0 :         rDev.DrawImage( rPos, pData->GetImage(nIndex), nStyle);
     385           0 : }
     386             : 
     387           0 : SvLBoxItem* SvLBoxButton::Create() const
     388             : {
     389           0 :     return new SvLBoxButton;
     390             : }
     391             : 
     392           0 : void SvLBoxButton::Clone( SvLBoxItem* pSource )
     393             : {
     394           0 :     pData = static_cast<SvLBoxButton*>(pSource)->pData;
     395           0 : }
     396             : 
     397           0 : void SvLBoxButton::ImplAdjustBoxSize( Size& io_rSize, ControlType i_eType, vcl::Window* i_pParent )
     398             : {
     399           0 :     if ( i_pParent->IsNativeControlSupported( i_eType, PART_ENTIRE_CONTROL) )
     400             :     {
     401           0 :         ImplControlValue    aControlValue;
     402           0 :         Rectangle           aCtrlRegion( Point( 0, 0 ), io_rSize );
     403           0 :         ControlState        nState = CTRL_STATE_ENABLED;
     404             : 
     405           0 :         aControlValue.setTristateVal( BUTTONVALUE_ON );
     406             : 
     407           0 :         Rectangle aNativeBounds, aNativeContent;
     408             :         bool bNativeOK = i_pParent->GetNativeControlRegion( i_eType,
     409             :                                                             PART_ENTIRE_CONTROL,
     410             :                                                             aCtrlRegion,
     411             :                                                             nState,
     412             :                                                             aControlValue,
     413             :                                                             OUString(),
     414             :                                                             aNativeBounds,
     415           0 :                                                             aNativeContent );
     416           0 :         if( bNativeOK )
     417             :         {
     418           0 :             Size aContentSize( aNativeContent.GetSize() );
     419             :             // leave a little space around the box image (looks better)
     420           0 :             if( aContentSize.Height() + 2 > io_rSize.Height() )
     421           0 :                 io_rSize.Height() = aContentSize.Height() + 2;
     422           0 :             if( aContentSize.Width() + 2 > io_rSize.Width() )
     423           0 :                 io_rSize.Width() = aContentSize.Width() + 2;
     424           0 :         }
     425             :     }
     426           0 : }
     427             : 
     428           0 : void SvLBoxButton::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry,
     429             :     SvViewDataItem* pViewData )
     430             : {
     431           0 :     if( !pViewData )
     432           0 :         pViewData = pView->GetViewDataItem( pEntry, this );
     433           0 :     Size aSize( pData->Width(), pData->Height() );
     434             : 
     435           0 :     ControlType eCtrlType = (pData->IsRadio())? CTRL_RADIOBUTTON : CTRL_CHECKBOX;
     436           0 :     if ( eKind != SvLBoxButtonKind_staticImage && pView )
     437           0 :         ImplAdjustBoxSize( aSize, eCtrlType, pView );
     438           0 :     pViewData->maSize = aSize;
     439           0 : }
     440             : 
     441           0 : bool SvLBoxButton::CheckModification() const
     442             : {
     443           0 :     return eKind == SvLBoxButtonKind_enabledCheckbox;
     444             : }
     445             : 
     446           0 : void SvLBoxButton::SetStateInvisible()
     447             : {
     448           0 :     isVis = false;
     449           0 : }
     450             : 
     451             : // ***************************************************************
     452             : // class SvLBoxContextBmp
     453             : // ***************************************************************
     454             : 
     455        2900 : struct SvLBoxContextBmp_Impl
     456             : {
     457             :     Image       m_aImage1;
     458             :     Image       m_aImage2;
     459             : 
     460             :     bool        m_bExpanded;
     461             : };
     462             : 
     463             : // ***************************************************************
     464             : 
     465        1450 : SvLBoxContextBmp::SvLBoxContextBmp(
     466             :     SvTreeListEntry* pEntry, sal_uInt16 nItemFlags, Image aBmp1, Image aBmp2,
     467             :     bool bExpanded)
     468             :     :SvLBoxItem( pEntry, nItemFlags )
     469        1450 :     ,m_pImpl( new SvLBoxContextBmp_Impl )
     470             : {
     471             : 
     472        1450 :     m_pImpl->m_bExpanded = bExpanded;
     473        1450 :     SetModeImages( aBmp1, aBmp2 );
     474        1450 : }
     475             : 
     476           0 : SvLBoxContextBmp::SvLBoxContextBmp()
     477             :     :SvLBoxItem( )
     478           0 :     ,m_pImpl( new SvLBoxContextBmp_Impl )
     479             : {
     480           0 :     m_pImpl->m_bExpanded = false;
     481           0 : }
     482             : 
     483        4350 : SvLBoxContextBmp::~SvLBoxContextBmp()
     484             : {
     485        1450 :     delete m_pImpl;
     486        2900 : }
     487             : 
     488        7972 : sal_uInt16 SvLBoxContextBmp::GetType() const
     489             : {
     490        7972 :     return SV_ITEM_ID_LBOXCONTEXTBMP;
     491             : }
     492             : 
     493        1450 : bool SvLBoxContextBmp::SetModeImages( const Image& _rBitmap1, const Image& _rBitmap2 )
     494             : {
     495        1450 :     bool bSuccess = true;
     496        1450 :     m_pImpl->m_aImage1 = _rBitmap1;
     497        1450 :     m_pImpl->m_aImage2 = _rBitmap2;
     498        1450 :     return bSuccess;
     499             : }
     500             : 
     501        7587 : Image& SvLBoxContextBmp::implGetImageStore( bool _bFirst )
     502             : {
     503             : 
     504             :     // OJ: #i27071# wrong mode so we just return the normal images
     505        7587 :     return _bFirst ? m_pImpl->m_aImage1 : m_pImpl->m_aImage2;
     506             : }
     507             : 
     508        1528 : void SvLBoxContextBmp::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry,
     509             :     SvViewDataItem* pViewData)
     510             : {
     511        1528 :     if( !pViewData )
     512          78 :         pViewData = pView->GetViewDataItem( pEntry, this );
     513        1528 :     pViewData->maSize = m_pImpl->m_aImage1.GetSizePixel();
     514        1528 : }
     515             : 
     516        1783 : void SvLBoxContextBmp::Paint(
     517             :     const Point& _rPos, SvTreeListBox& _rDev,
     518             :     const SvViewDataEntry* pView, const SvTreeListEntry* pEntry)
     519             : {
     520             : 
     521             :     // get the image.
     522        1783 :     const Image& rImage = implGetImageStore(pView->IsExpanded() != m_pImpl->m_bExpanded);
     523             : 
     524        1783 :     bool _bSemiTransparent = pEntry && ( 0 != ( SV_ENTRYFLAG_SEMITRANSPARENT  & pEntry->GetFlags( ) ) );
     525             :     // draw
     526        1783 :     sal_uInt16 nStyle = _rDev.IsEnabled() ? 0 : IMAGE_DRAW_DISABLE;
     527        1783 :     if ( _bSemiTransparent )
     528           0 :         nStyle |= IMAGE_DRAW_SEMITRANSPARENT;
     529        1783 :     _rDev.DrawImage( _rPos, rImage, nStyle);
     530        1783 : }
     531             : 
     532           0 : SvLBoxItem* SvLBoxContextBmp::Create() const
     533             : {
     534           0 :     return new SvLBoxContextBmp;
     535             : }
     536             : 
     537           0 : void SvLBoxContextBmp::Clone( SvLBoxItem* pSource )
     538             : {
     539           0 :     m_pImpl->m_aImage1 = static_cast< SvLBoxContextBmp* >( pSource )->m_pImpl->m_aImage1;
     540           0 :     m_pImpl->m_aImage2 = static_cast< SvLBoxContextBmp* >( pSource )->m_pImpl->m_aImage2;
     541           0 :     m_pImpl->m_bExpanded = static_cast<SvLBoxContextBmp*>(pSource)->m_pImpl->m_bExpanded;
     542           0 : }
     543             : 
     544           0 : long SvLBoxButtonData::Width()
     545             : {
     546           0 :     if ( !bDataOk )
     547           0 :         SetWidthAndHeight();
     548           0 :     return nWidth;
     549             : }
     550             : 
     551           0 : long SvLBoxButtonData::Height()
     552             : {
     553           0 :     if ( !bDataOk )
     554           0 :         SetWidthAndHeight();
     555           0 :     return nHeight;
     556        1227 : }
     557             : 
     558             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10