LCOV - code coverage report
Current view: top level - svtools/source/contnr - svlbitm.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 49 242 20.2 %
Date: 2012-08-25 Functions: 16 56 28.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 24 225 10.7 %

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

Generated by: LCOV version 1.10