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

Generated by: LCOV version 1.10