LCOV - code coverage report
Current view: top level - vcl/source/control - button.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 962 2109 45.6 %
Date: 2012-08-25 Functions: 101 177 57.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 758 3062 24.8 %

           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                 :            : 
      30                 :            : #include <tools/debug.hxx>
      31                 :            : #include <tools/poly.hxx>
      32                 :            : #include <tools/rc.h>
      33                 :            : 
      34                 :            : #include <vcl/image.hxx>
      35                 :            : #include <vcl/bitmap.hxx>
      36                 :            : #include <vcl/bitmapex.hxx>
      37                 :            : #include <vcl/decoview.hxx>
      38                 :            : #include <vcl/event.hxx>
      39                 :            : #include <vcl/svapp.hxx>
      40                 :            : #include <vcl/dialog.hxx>
      41                 :            : #include <vcl/fixed.hxx>
      42                 :            : #include <vcl/button.hxx>
      43                 :            : #include <vcl/salnativewidgets.hxx>
      44                 :            : #include <vcl/edit.hxx>
      45                 :            : 
      46                 :            : #include <svids.hrc>
      47                 :            : #include <svdata.hxx>
      48                 :            : #include <window.h>
      49                 :            : #include <controldata.hxx>
      50                 :            : 
      51                 :            : // =======================================================================
      52                 :            : 
      53                 :            : #define PUSHBUTTON_VIEW_STYLE       (WB_3DLOOK |                        \
      54                 :            :                                      WB_LEFT | WB_CENTER | WB_RIGHT |   \
      55                 :            :                                      WB_TOP | WB_VCENTER | WB_BOTTOM |  \
      56                 :            :                                      WB_WORDBREAK | WB_NOLABEL |        \
      57                 :            :                                      WB_DEFBUTTON | WB_NOLIGHTBORDER |  \
      58                 :            :                                      WB_RECTSTYLE | WB_SMALLSTYLE |     \
      59                 :            :                                      WB_TOGGLE )
      60                 :            : #define RADIOBUTTON_VIEW_STYLE      (WB_3DLOOK |                        \
      61                 :            :                                      WB_LEFT | WB_CENTER | WB_RIGHT |   \
      62                 :            :                                      WB_TOP | WB_VCENTER | WB_BOTTOM |  \
      63                 :            :                                      WB_WORDBREAK | WB_NOLABEL)
      64                 :            : #define CHECKBOX_VIEW_STYLE         (WB_3DLOOK |                        \
      65                 :            :                                      WB_LEFT | WB_CENTER | WB_RIGHT |   \
      66                 :            :                                      WB_TOP | WB_VCENTER | WB_BOTTOM |  \
      67                 :            :                                      WB_WORDBREAK | WB_NOLABEL)
      68                 :            : 
      69                 :            : // =======================================================================
      70                 :            : 
      71                 :            : class ImplCommonButtonData
      72                 :            : {
      73                 :            : public:
      74                 :            :     Rectangle       maFocusRect;
      75                 :            :     long            mnSeparatorX;
      76                 :            :     sal_uInt16          mnButtonState;
      77                 :            :     sal_Bool            mbSmallSymbol;
      78                 :            : 
      79                 :            :     Image           maImage;
      80                 :            :     ImageAlign      meImageAlign;
      81                 :            :     SymbolAlign     meSymbolAlign;
      82                 :            : 
      83                 :            : public:
      84                 :            :                     ImplCommonButtonData();
      85                 :            :                    ~ImplCommonButtonData();
      86                 :            : };
      87                 :            : 
      88                 :            : // -----------------------------------------------------------------------
      89                 :      13767 : ImplCommonButtonData::ImplCommonButtonData() : maFocusRect(), mnSeparatorX(0), mnButtonState(0),
      90                 :      13767 : mbSmallSymbol(sal_False), maImage(), meImageAlign(IMAGEALIGN_TOP), meSymbolAlign(SYMBOLALIGN_LEFT)
      91                 :            : {
      92                 :      13767 : }
      93                 :            : 
      94                 :            : // -----------------------------------------------------------------------
      95                 :      13294 : ImplCommonButtonData::~ImplCommonButtonData()
      96                 :            : {
      97                 :      13294 : }
      98                 :            : 
      99                 :            : // =======================================================================
     100                 :            : 
     101                 :      13767 : Button::Button( WindowType nType ) :
     102         [ +  - ]:      13767 :     Control( nType )
     103                 :            : {
     104 [ +  - ][ +  - ]:      13767 :     mpButtonData = new ImplCommonButtonData;
     105                 :      13767 : }
     106                 :            : 
     107                 :            : // -----------------------------------------------------------------------
     108                 :            : 
     109                 :      13294 : Button::~Button()
     110                 :            : {
     111 [ +  - ][ +  - ]:      13294 :     delete mpButtonData;
     112         [ -  + ]:      13294 : }
     113                 :            : 
     114                 :            : // -----------------------------------------------------------------------
     115                 :            : 
     116                 :         64 : void Button::Click()
     117                 :            : {
     118                 :         64 :     ImplCallEventListenersAndHandler( VCLEVENT_BUTTON_CLICK, maClickHdl, this );
     119                 :         64 : }
     120                 :            : 
     121                 :            : // -----------------------------------------------------------------------
     122                 :            : 
     123                 :       1850 : XubString Button::GetStandardText( StandardButtonType eButton )
     124                 :            : {
     125                 :            :     static struct
     126                 :            :     {
     127                 :            :         sal_uInt32 nResId;
     128                 :            :         const char* pDefText;
     129                 :            :     } aResIdAry[BUTTON_COUNT] =
     130                 :            :     {
     131                 :            :         { SV_BUTTONTEXT_OK, "~OK" },
     132                 :            :         { SV_BUTTONTEXT_CANCEL, "~Cancel" },
     133                 :            :         { SV_BUTTONTEXT_YES, "~Yes" },
     134                 :            :         { SV_BUTTONTEXT_NO, "~No" },
     135                 :            :         { SV_BUTTONTEXT_RETRY, "~Retry" },
     136                 :            :         { SV_BUTTONTEXT_HELP, "~Help" },
     137                 :            :         { SV_BUTTONTEXT_CLOSE, "~Close" },
     138                 :            :         { SV_BUTTONTEXT_MORE, "~More" },
     139                 :            :         { SV_BUTTONTEXT_IGNORE, "~Ignore" },
     140                 :            :         { SV_BUTTONTEXT_ABORT, "~Abort" },
     141                 :            :         { SV_BUTTONTEXT_LESS, "~Less" }
     142                 :            :     };
     143                 :            : 
     144                 :       1850 :     String aText;
     145         [ +  - ]:       1850 :     ResMgr* pResMgr = ImplGetResMgr();
     146         [ +  - ]:       1850 :     if( pResMgr )
     147                 :            :     {
     148                 :       1850 :         sal_uInt32 nResId = aResIdAry[(sal_uInt16)eButton].nResId;
     149 [ +  - ][ +  - ]:       1850 :         aText = ResId(nResId, *pResMgr).toString();
     150                 :            : 
     151                 :            :         // Windows (apparently) has some magic auto-accelerator evil around
     152                 :            :         // ok / cancel so add this only for Unix
     153                 :            : #ifdef UNX
     154 [ +  + ][ +  + ]:       1850 :         if( nResId == SV_BUTTONTEXT_OK || nResId == SV_BUTTONTEXT_CANCEL )
     155 [ +  - ][ +  - ]:        370 :             aText.Insert( rtl::OUString("~"), 0 );
                 [ +  - ]
     156                 :            : #endif
     157                 :            :     }
     158                 :            :     else
     159                 :            :     {
     160                 :          0 :         rtl::OString aT( aResIdAry[(sal_uInt16)eButton].pDefText );
     161 [ #  # ][ #  # ]:          0 :         aText = rtl::OStringToOUString(aT, RTL_TEXTENCODING_ASCII_US);
     162                 :            :     }
     163                 :       1850 :     return aText;
     164                 :            : }
     165                 :            : 
     166                 :            : // -----------------------------------------------------------------------
     167                 :            : 
     168                 :          0 : XubString Button::GetStandardHelpText( StandardButtonType /* eButton */ )
     169                 :            : {
     170                 :          0 :     XubString aHelpText;
     171                 :          0 :     return aHelpText;
     172                 :            : }
     173                 :            : // -----------------------------------------------------------------------
     174                 :       1503 : sal_Bool Button::SetModeImage( const Image& rImage )
     175                 :            : {
     176         [ +  + ]:       1503 :     if ( rImage != mpButtonData->maImage )
     177                 :            :     {
     178                 :        840 :         mpButtonData->maImage = rImage;
     179                 :            : 
     180                 :        840 :         StateChanged( STATE_CHANGE_DATA );
     181                 :            :     }
     182                 :       1503 :     return sal_True;
     183                 :            : }
     184                 :            : 
     185                 :            : // -----------------------------------------------------------------------
     186                 :          0 : const Image Button::GetModeImage( ) const
     187                 :            : {
     188                 :          0 :     return mpButtonData->maImage;
     189                 :            : }
     190                 :            : 
     191                 :            : // -----------------------------------------------------------------------
     192                 :      12661 : sal_Bool Button::HasImage() const
     193                 :            : {
     194                 :      12661 :     return !!(mpButtonData->maImage);
     195                 :            : }
     196                 :            : 
     197                 :            : // -----------------------------------------------------------------------
     198                 :        216 : void Button::SetImageAlign( ImageAlign eAlign )
     199                 :            : {
     200         [ +  + ]:        216 :     if ( mpButtonData->meImageAlign != eAlign )
     201                 :            :     {
     202                 :         98 :         mpButtonData->meImageAlign = eAlign;
     203                 :         98 :         StateChanged( STATE_CHANGE_DATA );
     204                 :            :     }
     205                 :        216 : }
     206                 :            : 
     207                 :            : // -----------------------------------------------------------------------
     208                 :          0 : ImageAlign Button::GetImageAlign() const
     209                 :            : {
     210                 :          0 :     return mpButtonData->meImageAlign;
     211                 :            : }
     212                 :            : 
     213                 :            : // -----------------------------------------------------------------------
     214                 :            : 
     215                 :          0 : void Button::SetFocusRect( const Rectangle& rFocusRect )
     216                 :            : {
     217                 :          0 :     ImplSetFocusRect( rFocusRect );
     218                 :          0 : }
     219                 :            : 
     220                 :            : // -----------------------------------------------------------------------
     221                 :            : 
     222                 :          0 : long Button::ImplGetSeparatorX() const
     223                 :            : {
     224                 :          0 :     return mpButtonData->mnSeparatorX;
     225                 :            : }
     226                 :            : 
     227                 :          2 : void Button::ImplSetSeparatorX( long nX )
     228                 :            : {
     229                 :          2 :     mpButtonData->mnSeparatorX = nX;
     230                 :          2 : }
     231                 :            : 
     232                 :            : // -----------------------------------------------------------------------
     233                 :            : 
     234                 :        494 : sal_uInt16 Button::ImplGetTextStyle( XubString& rText, WinBits nWinStyle,
     235                 :            :                                  sal_uLong nDrawFlags )
     236                 :            : {
     237                 :        494 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     238                 :        494 :     sal_uInt16 nTextStyle = FixedText::ImplGetTextStyle( nWinStyle & ~WB_DEFBUTTON );
     239                 :            : 
     240         [ -  + ]:        494 :     if ( nDrawFlags & WINDOW_DRAW_NOMNEMONIC )
     241                 :            :     {
     242         [ #  # ]:          0 :         if ( nTextStyle & TEXT_DRAW_MNEMONIC )
     243                 :            :         {
     244         [ #  # ]:          0 :             rText = GetNonMnemonicString( rText );
     245                 :          0 :             nTextStyle &= ~TEXT_DRAW_MNEMONIC;
     246                 :            :         }
     247                 :            :     }
     248                 :            : 
     249         [ +  - ]:        494 :     if ( !(nDrawFlags & WINDOW_DRAW_NODISABLE) )
     250                 :            :     {
     251         [ +  + ]:        494 :         if ( !IsEnabled() )
     252                 :        233 :             nTextStyle |= TEXT_DRAW_DISABLE;
     253                 :            :     }
     254                 :            : 
     255   [ +  -  +  + ]:        988 :     if ( (nDrawFlags & WINDOW_DRAW_MONO) ||
                 [ +  + ]
     256                 :        494 :          (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
     257                 :        196 :         nTextStyle |= TEXT_DRAW_MONO;
     258                 :            : 
     259                 :        494 :     return nTextStyle;
     260                 :            : }
     261                 :            : 
     262                 :            : // -----------------------------------------------------------------------
     263                 :            : 
     264                 :      12548 : void Button::ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos,
     265                 :            :                                    Size& rSize, sal_Bool bLayout,
     266                 :            :                                    sal_uLong nImageSep, sal_uLong nDrawFlags,
     267                 :            :                                    sal_uInt16 nTextStyle, Rectangle *pSymbolRect,
     268                 :            :                                    bool bAddImageSep )
     269                 :            : {
     270         [ +  - ]:      12548 :     XubString   aText( GetText() );
     271 [ +  - ][ +  + ]:      12548 :     sal_Bool        bDrawImage = HasImage() && ! ( ImplGetButtonState() & BUTTON_DRAW_NOIMAGE );
                 [ +  - ]
     272 [ +  + ][ +  - ]:      12548 :     sal_Bool        bDrawText  = aText.Len() && ! ( ImplGetButtonState() & BUTTON_DRAW_NOTEXT );
     273         [ +  + ]:      12548 :     sal_Bool        bHasSymbol = pSymbolRect ? sal_True : sal_False;
     274                 :            : 
     275                 :            :     // No text and no image => nothing to do => return
     276 [ +  + ][ +  + ]:      12548 :     if ( !bDrawImage && !bDrawText && !bHasSymbol )
                 [ +  + ]
     277                 :            :         return;
     278                 :            : 
     279         [ +  - ]:      11683 :     WinBits         nWinStyle = GetStyle();
     280         [ +  - ]:      11683 :     Rectangle       aOutRect( rPos, rSize );
     281         [ -  + ]:      11683 :     MetricVector   *pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
     282         [ -  + ]:      11683 :     String         *pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL;
     283                 :      11683 :     ImageAlign      eImageAlign = mpButtonData->meImageAlign;
     284         [ +  - ]:      11683 :     Size            aImageSize = mpButtonData->maImage.GetSizePixel();
     285                 :            : 
     286 [ -  + ][ #  # ]:      11683 :     if ( ( nDrawFlags & WINDOW_DRAW_NOMNEMONIC ) &&
     287                 :            :          ( nTextStyle & TEXT_DRAW_MNEMONIC ) )
     288                 :            :     {
     289 [ #  # ][ #  # ]:          0 :         aText = GetNonMnemonicString( aText );
                 [ #  # ]
     290                 :          0 :         nTextStyle &= ~TEXT_DRAW_MNEMONIC;
     291                 :            :     }
     292                 :            : 
     293         [ +  - ]:      11683 :     aImageSize.Width()  = CalcZoom( aImageSize.Width() );
     294         [ +  - ]:      11683 :     aImageSize.Height() = CalcZoom( aImageSize.Height() );
     295                 :            : 
     296                 :            :     // Drawing text or symbol only is simple, use style and output rectangle
     297 [ +  + ][ +  - ]:      11683 :     if ( bHasSymbol && !bDrawImage && !bDrawText )
                 [ +  - ]
     298                 :            :     {
     299                 :      10285 :         *pSymbolRect = aOutRect;
     300                 :            :         return;
     301                 :            :     }
     302 [ +  + ][ +  + ]:       1398 :     else if ( bDrawText && !bDrawImage && !bHasSymbol )
                 [ +  - ]
     303                 :            :     {
     304         [ +  - ]:        529 :         DrawControlText( *pDev, aOutRect, aText, nTextStyle, pVector, pDisplayText );
     305                 :            : 
     306         [ +  - ]:        529 :         ImplSetFocusRect( aOutRect );
     307         [ +  - ]:        529 :         rSize = aOutRect.GetSize();
     308                 :        529 :         rPos = aOutRect.TopLeft();
     309                 :            : 
     310                 :            :         return;
     311                 :            :     }
     312                 :            : 
     313                 :            :     // check for HC mode ( image only! )
     314                 :        869 :     Image    *pImage    = &(mpButtonData->maImage);
     315                 :            : 
     316                 :        869 :     Size aTextSize;
     317                 :        869 :     Size aSymbolSize;
     318                 :        869 :     Size aMax;
     319                 :        869 :     Point aImagePos = rPos;
     320                 :        869 :     Point aTextPos = rPos;
     321         [ +  - ]:        869 :     Rectangle aUnion = Rectangle( aImagePos, aImageSize );
     322         [ +  - ]:        869 :     Rectangle aSymbol;
     323                 :        869 :     long nSymbolHeight = 0;
     324                 :            : 
     325 [ +  + ][ -  + ]:        869 :     if ( bDrawText || bHasSymbol )
     326                 :            :     {
     327                 :            :         // Get the size of the text output area ( the symbol will be drawn in
     328                 :            :         // this area as well, so the symbol rectangle will be calculated here, too )
     329                 :            : 
     330         [ +  - ]:         16 :         Rectangle   aRect = Rectangle( Point(), rSize );
     331                 :         16 :         Size        aTSSize;
     332                 :            : 
     333         [ -  + ]:         16 :         if ( bHasSymbol )
     334                 :            :         {
     335         [ #  # ]:          0 :             if ( bDrawText )
     336                 :            :             {
     337         [ #  # ]:          0 :                 nSymbolHeight = pDev->GetTextHeight();
     338         [ #  # ]:          0 :                 if ( mpButtonData->mbSmallSymbol )
     339                 :          0 :                     nSymbolHeight = nSymbolHeight * 3 / 4;
     340                 :            : 
     341         [ #  # ]:          0 :                 aSymbol = Rectangle( Point(), Size( nSymbolHeight, nSymbolHeight ) );
     342         [ #  # ]:          0 :                 ImplCalcSymbolRect( aSymbol );
     343                 :          0 :                 aRect.Left() += 3 * nSymbolHeight / 2;
     344                 :          0 :                 aTSSize.Width() = 3 * nSymbolHeight / 2;
     345                 :            :             }
     346                 :            :             else
     347                 :            :             {
     348         [ #  # ]:          0 :                 aSymbol = Rectangle( Point(), rSize );
     349         [ #  # ]:          0 :                 ImplCalcSymbolRect( aSymbol );
     350         [ #  # ]:          0 :                 aTSSize.Width() = aSymbol.GetWidth();
     351                 :            :             }
     352         [ #  # ]:          0 :             aTSSize.Height() = aSymbol.GetHeight();
     353         [ #  # ]:          0 :             aSymbolSize = aSymbol.GetSize();
     354                 :            :         }
     355                 :            : 
     356         [ +  - ]:         16 :         if ( bDrawText )
     357                 :            :         {
     358 [ +  - ][ -  + ]:         16 :             if ( ( eImageAlign == IMAGEALIGN_LEFT_TOP     ) ||
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     359                 :            :                  ( eImageAlign == IMAGEALIGN_LEFT         ) ||
     360                 :            :                  ( eImageAlign == IMAGEALIGN_LEFT_BOTTOM  ) ||
     361                 :            :                  ( eImageAlign == IMAGEALIGN_RIGHT_TOP    ) ||
     362                 :            :                  ( eImageAlign == IMAGEALIGN_RIGHT        ) ||
     363                 :            :                  ( eImageAlign == IMAGEALIGN_RIGHT_BOTTOM ) )
     364                 :            :             {
     365                 :         16 :                 aRect.Right() -= ( aImageSize.Width() + nImageSep );
     366                 :            :             }
     367 [ #  # ][ #  # ]:          0 :             else if ( ( eImageAlign == IMAGEALIGN_TOP_LEFT     ) ||
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     368                 :            :                       ( eImageAlign == IMAGEALIGN_TOP          ) ||
     369                 :            :                       ( eImageAlign == IMAGEALIGN_TOP_RIGHT    ) ||
     370                 :            :                       ( eImageAlign == IMAGEALIGN_BOTTOM_LEFT  ) ||
     371                 :            :                       ( eImageAlign == IMAGEALIGN_BOTTOM       ) ||
     372                 :            :                       ( eImageAlign == IMAGEALIGN_BOTTOM_RIGHT ) )
     373                 :            :             {
     374                 :          0 :                 aRect.Bottom() -= ( aImageSize.Height() + nImageSep );
     375                 :            :             }
     376                 :            : 
     377         [ +  - ]:         16 :             aRect = pDev->GetTextRect( aRect, aText, nTextStyle );
     378         [ +  - ]:         16 :             aTextSize = aRect.GetSize();
     379                 :            : 
     380                 :         16 :             aTSSize.Width()  += aTextSize.Width();
     381                 :            : 
     382         [ +  - ]:         16 :             if ( aTSSize.Height() < aTextSize.Height() )
     383                 :         16 :                 aTSSize.Height() = aTextSize.Height();
     384                 :            : 
     385 [ +  - ][ +  - ]:         16 :             if( bAddImageSep && bDrawImage )
     386                 :            :             {
     387                 :         16 :                 long nDiff = (aImageSize.Height() - aTextSize.Height()) / 3;
     388         [ +  - ]:         16 :                 if( nDiff > 0 )
     389                 :         16 :                     nImageSep += nDiff;
     390                 :            :             }
     391                 :            :         }
     392                 :            : 
     393         [ +  - ]:         16 :         aMax.Width()  = aTSSize.Width()  > aImageSize.Width()  ? aTSSize.Width()  : aImageSize.Width();
     394         [ -  + ]:         16 :         aMax.Height() = aTSSize.Height() > aImageSize.Height() ? aTSSize.Height() : aImageSize.Height();
     395                 :            : 
     396                 :            :         // Now calculate the output area for the image and the text acording to the image align flags
     397                 :            : 
     398 [ -  + ][ #  # ]:         16 :         if ( ( eImageAlign == IMAGEALIGN_LEFT ) ||
     399                 :            :              ( eImageAlign == IMAGEALIGN_RIGHT ) )
     400                 :            :         {
     401                 :         16 :             aImagePos.Y() = rPos.Y() + ( aMax.Height() - aImageSize.Height() ) / 2;
     402                 :         16 :             aTextPos.Y()  = rPos.Y() + ( aMax.Height() - aTSSize.Height() ) / 2;
     403                 :            :         }
     404 [ #  # ][ #  # ]:          0 :         else if ( ( eImageAlign == IMAGEALIGN_LEFT_BOTTOM ) ||
     405                 :            :                   ( eImageAlign == IMAGEALIGN_RIGHT_BOTTOM ) )
     406                 :            :         {
     407                 :          0 :             aImagePos.Y() = rPos.Y() + aMax.Height() - aImageSize.Height();
     408                 :          0 :             aTextPos.Y()  = rPos.Y() + aMax.Height() - aTSSize.Height();
     409                 :            :         }
     410 [ #  # ][ #  # ]:          0 :         else if ( ( eImageAlign == IMAGEALIGN_TOP ) ||
     411                 :            :                   ( eImageAlign == IMAGEALIGN_BOTTOM ) )
     412                 :            :         {
     413                 :          0 :             aImagePos.X() = rPos.X() + ( aMax.Width() - aImageSize.Width() ) / 2;
     414                 :          0 :             aTextPos.X()  = rPos.X() + ( aMax.Width() - aTSSize.Width() ) / 2;
     415                 :            :         }
     416 [ #  # ][ #  # ]:          0 :         else if ( ( eImageAlign == IMAGEALIGN_TOP_RIGHT ) ||
     417                 :            :                   ( eImageAlign == IMAGEALIGN_BOTTOM_RIGHT ) )
     418                 :            :         {
     419                 :          0 :             aImagePos.X() = rPos.X() + aMax.Width() - aImageSize.Width();
     420                 :          0 :             aTextPos.X()  = rPos.X() + aMax.Width() - aTSSize.Width();
     421                 :            :         }
     422                 :            : 
     423 [ +  - ][ -  + ]:         16 :         if ( ( eImageAlign == IMAGEALIGN_LEFT_TOP ) ||
                 [ #  # ]
     424                 :            :              ( eImageAlign == IMAGEALIGN_LEFT ) ||
     425                 :            :              ( eImageAlign == IMAGEALIGN_LEFT_BOTTOM ) )
     426                 :            :         {
     427                 :         16 :             aTextPos.X() = rPos.X() + aImageSize.Width() + nImageSep;
     428                 :            :         }
     429 [ #  # ][ #  # ]:          0 :         else if ( ( eImageAlign == IMAGEALIGN_RIGHT_TOP ) ||
                 [ #  # ]
     430                 :            :                   ( eImageAlign == IMAGEALIGN_RIGHT ) ||
     431                 :            :                   ( eImageAlign == IMAGEALIGN_RIGHT_BOTTOM ) )
     432                 :            :         {
     433                 :          0 :             aImagePos.X() = rPos.X() + aTSSize.Width() + nImageSep;
     434                 :            :         }
     435 [ #  # ][ #  # ]:          0 :         else if ( ( eImageAlign == IMAGEALIGN_TOP_LEFT ) ||
                 [ #  # ]
     436                 :            :                   ( eImageAlign == IMAGEALIGN_TOP ) ||
     437                 :            :                   ( eImageAlign == IMAGEALIGN_TOP_RIGHT ) )
     438                 :            :         {
     439                 :          0 :             aTextPos.Y() = rPos.Y() + aImageSize.Height() + nImageSep;
     440                 :            :         }
     441 [ #  # ][ #  # ]:          0 :         else if ( ( eImageAlign == IMAGEALIGN_BOTTOM_LEFT ) ||
                 [ #  # ]
     442                 :            :                   ( eImageAlign == IMAGEALIGN_BOTTOM ) ||
     443                 :            :                   ( eImageAlign == IMAGEALIGN_BOTTOM_RIGHT ) )
     444                 :            :         {
     445                 :          0 :             aImagePos.Y() = rPos.Y() + aTSSize.Height() + nImageSep;
     446                 :            :         }
     447         [ #  # ]:          0 :         else if ( eImageAlign == IMAGEALIGN_CENTER )
     448                 :            :         {
     449                 :          0 :             aImagePos.X() = rPos.X() + ( aMax.Width()  - aImageSize.Width() ) / 2;
     450                 :          0 :             aImagePos.Y() = rPos.Y() + ( aMax.Height() - aImageSize.Height() ) / 2;
     451                 :          0 :             aTextPos.X()  = rPos.X() + ( aMax.Width()  - aTSSize.Width() ) / 2;
     452                 :          0 :             aTextPos.Y()  = rPos.Y() + ( aMax.Height() - aTSSize.Height() ) / 2;
     453                 :            :         }
     454         [ +  - ]:         16 :         aUnion = Rectangle( aImagePos, aImageSize );
     455 [ +  - ][ +  - ]:         16 :         aUnion.Union( Rectangle( aTextPos, aTSSize ) );
     456                 :            :     }
     457                 :            : 
     458                 :            :     // Now place the combination of text and image in the output area of the button
     459                 :            :     // according to the window style (WinBits)
     460                 :        869 :     long nXOffset = 0;
     461                 :        869 :     long nYOffset = 0;
     462                 :            : 
     463         [ +  + ]:        869 :     if ( nWinStyle & WB_CENTER )
     464                 :            :     {
     465         [ +  - ]:        853 :         nXOffset = ( rSize.Width() - aUnion.GetWidth() ) / 2;
     466                 :            :     }
     467         [ -  + ]:         16 :     else if ( nWinStyle & WB_RIGHT )
     468                 :            :     {
     469         [ #  # ]:          0 :         nXOffset = rSize.Width() - aUnion.GetWidth();
     470                 :            :     }
     471                 :            : 
     472         [ +  - ]:        869 :     if ( nWinStyle & WB_VCENTER )
     473                 :            :     {
     474         [ +  - ]:        869 :         nYOffset = ( rSize.Height() - aUnion.GetHeight() ) / 2;
     475                 :            :     }
     476         [ #  # ]:          0 :     else if ( nWinStyle & WB_BOTTOM )
     477                 :            :     {
     478         [ #  # ]:          0 :         nYOffset = rSize.Height() - aUnion.GetHeight();
     479                 :            :     }
     480                 :            : 
     481                 :            :     // the top left corner should always be visible, so we don't allow negative offsets
     482         [ +  + ]:        869 :     if ( nXOffset < 0 ) nXOffset = 0;
     483         [ +  + ]:        869 :     if ( nYOffset < 0 ) nYOffset = 0;
     484                 :            : 
     485                 :        869 :     aImagePos.X() += nXOffset;
     486                 :        869 :     aImagePos.Y() += nYOffset;
     487                 :        869 :     aTextPos.X() += nXOffset;
     488                 :        869 :     aTextPos.Y() += nYOffset;
     489                 :            : 
     490                 :            :     // set rPos and rSize to the union
     491         [ +  - ]:        869 :     rSize = aUnion.GetSize();
     492                 :        869 :     rPos.X() += nXOffset;
     493                 :        869 :     rPos.Y() += nYOffset;
     494                 :            : 
     495         [ -  + ]:        869 :     if ( bHasSymbol )
     496                 :            :     {
     497         [ #  # ]:          0 :         if ( mpButtonData->meSymbolAlign == SYMBOLALIGN_RIGHT )
     498                 :            :         {
     499                 :          0 :             Point aRightPos = Point( aTextPos.X() + aTextSize.Width() + aSymbolSize.Width()/2, aTextPos.Y() );
     500         [ #  # ]:          0 :             *pSymbolRect = Rectangle( aRightPos, aSymbolSize );
     501                 :            :         }
     502                 :            :         else
     503                 :            :         {
     504         [ #  # ]:          0 :             *pSymbolRect = Rectangle( aTextPos, aSymbolSize );
     505                 :          0 :             aTextPos.X() += ( 3 * nSymbolHeight / 2 );
     506                 :            :         }
     507         [ #  # ]:          0 :         if ( mpButtonData->mbSmallSymbol )
     508                 :            :         {
     509         [ #  # ]:          0 :             nYOffset = (aUnion.GetHeight() - aSymbolSize.Height())/2;
     510                 :          0 :             pSymbolRect->setY( aTextPos.Y() + nYOffset );
     511                 :            :         }
     512                 :            :     }
     513                 :            : 
     514                 :        869 :     sal_uInt16 nStyle = 0;
     515                 :            : 
     516 [ +  - ][ +  + ]:       1738 :     if ( ! ( nDrawFlags & WINDOW_DRAW_NODISABLE ) &&
                 [ +  + ]
     517         [ +  - ]:        869 :          ! IsEnabled() )
     518                 :          9 :         nStyle |= IMAGE_DRAW_DISABLE;
     519                 :            : 
     520 [ +  - ][ -  + ]:        869 :     if ( IsZoom() )
     521         [ #  # ]:          0 :         pDev->DrawImage( aImagePos, aImageSize, *pImage, nStyle );
     522                 :            :     else
     523         [ +  - ]:        869 :         pDev->DrawImage( aImagePos, *pImage, nStyle );
     524                 :            : 
     525         [ +  + ]:        869 :     if ( bDrawText )
     526                 :            :     {
     527 [ +  - ][ +  - ]:         16 :         ImplSetFocusRect( Rectangle( aTextPos, aTextSize ) );
     528 [ +  - ][ +  - ]:         16 :         pDev->DrawText( Rectangle( aTextPos, aTextSize ), aText, nTextStyle, pVector, pDisplayText );
     529                 :            :     }
     530                 :            :     else
     531                 :            :     {
     532 [ +  - ][ +  - ]:        869 :         ImplSetFocusRect( Rectangle( aImagePos, aImageSize ) );
     533 [ +  - ][ +  + ]:      12548 :     }
     534                 :            : }
     535                 :            : 
     536                 :            : // -----------------------------------------------------------------------
     537                 :       1499 : void Button::ImplSetFocusRect( const Rectangle &rFocusRect )
     538                 :            : {
     539                 :       1499 :     Rectangle aFocusRect = rFocusRect;
     540         [ +  - ]:       1499 :     Rectangle aOutputRect = Rectangle( Point(), GetOutputSizePixel() );
     541                 :            : 
     542 [ +  - ][ +  - ]:       1499 :     if ( ! aFocusRect.IsEmpty() )
     543                 :            :     {
     544                 :       1499 :         aFocusRect.Left()--;
     545                 :       1499 :         aFocusRect.Top()--;
     546                 :       1499 :         aFocusRect.Right()++;
     547                 :       1499 :         aFocusRect.Bottom()++;
     548                 :            :     }
     549                 :            : 
     550         [ +  + ]:       1499 :     if ( aFocusRect.Left()   < aOutputRect.Left()   ) aFocusRect.Left()   = aOutputRect.Left();
     551         [ +  + ]:       1499 :     if ( aFocusRect.Top()    < aOutputRect.Top()    ) aFocusRect.Top()    = aOutputRect.Top();
     552         [ +  + ]:       1499 :     if ( aFocusRect.Right()  > aOutputRect.Right()  ) aFocusRect.Right()  = aOutputRect.Right();
     553         [ +  + ]:       1499 :     if ( aFocusRect.Bottom() > aOutputRect.Bottom() ) aFocusRect.Bottom() = aOutputRect.Bottom();
     554                 :            : 
     555                 :       1499 :     mpButtonData->maFocusRect = aFocusRect;
     556                 :       1499 : }
     557                 :            : 
     558                 :            : // -----------------------------------------------------------------------
     559                 :         18 : const Rectangle& Button::ImplGetFocusRect() const
     560                 :            : {
     561                 :         18 :     return mpButtonData->maFocusRect;
     562                 :            : }
     563                 :            : 
     564                 :            : // -----------------------------------------------------------------------
     565                 :      20249 : sal_uInt16& Button::ImplGetButtonState()
     566                 :            : {
     567                 :      20249 :     return mpButtonData->mnButtonState;
     568                 :            : }
     569                 :            : 
     570                 :            : // -----------------------------------------------------------------------
     571                 :         78 : sal_uInt16 Button::ImplGetButtonState() const
     572                 :            : {
     573                 :         78 :     return mpButtonData->mnButtonState;
     574                 :            : }
     575                 :            : 
     576                 :            : // -----------------------------------------------------------------------
     577                 :          0 : void Button::ImplSetSymbolAlign( SymbolAlign eAlign )
     578                 :            : {
     579         [ #  # ]:          0 :     if ( mpButtonData->meSymbolAlign != eAlign )
     580                 :            :     {
     581                 :          0 :         mpButtonData->meSymbolAlign = eAlign;
     582                 :          0 :         StateChanged( STATE_CHANGE_DATA );
     583                 :            :     }
     584                 :          0 : }
     585                 :            : 
     586                 :            : // -----------------------------------------------------------------------
     587                 :          0 : void Button::ImplSetSmallSymbol( sal_Bool bSmall )
     588                 :            : {
     589                 :          0 :     mpButtonData->mbSmallSymbol = bSmall;
     590                 :          0 : }
     591                 :            : 
     592                 :            : // -----------------------------------------------------------------------
     593                 :          0 : void Button::EnableImageDisplay( sal_Bool bEnable )
     594                 :            : {
     595         [ #  # ]:          0 :     if( bEnable )
     596                 :          0 :         mpButtonData->mnButtonState &= ~BUTTON_DRAW_NOIMAGE;
     597                 :            :     else
     598                 :          0 :         mpButtonData->mnButtonState |= BUTTON_DRAW_NOIMAGE;
     599                 :          0 : }
     600                 :            : 
     601                 :            : // -----------------------------------------------------------------------
     602                 :          0 : void Button::EnableTextDisplay( sal_Bool bEnable )
     603                 :            : {
     604         [ #  # ]:          0 :     if( bEnable )
     605                 :          0 :         mpButtonData->mnButtonState &= ~BUTTON_DRAW_NOTEXT;
     606                 :            :     else
     607                 :          0 :         mpButtonData->mnButtonState |= BUTTON_DRAW_NOTEXT;
     608                 :          0 : }
     609                 :            : 
     610                 :          0 : bool Button::IsSmallSymbol () const
     611                 :            : {
     612                 :          0 :     return mpButtonData->mbSmallSymbol;
     613                 :            : }
     614                 :            : 
     615                 :            : // =======================================================================
     616                 :            : 
     617                 :      13557 : void PushButton::ImplInitPushButtonData()
     618                 :            : {
     619                 :      13557 :     mpWindowImpl->mbPushButton    = sal_True;
     620                 :            : 
     621                 :      13557 :     meSymbol        = SYMBOL_NOSYMBOL;
     622                 :      13557 :     meState         = STATE_NOCHECK;
     623                 :      13557 :     meSaveValue     = STATE_NOCHECK;
     624                 :      13557 :     mnDDStyle       = 0;
     625                 :      13557 :     mbPressed       = sal_False;
     626                 :      13557 :     mbInUserDraw    = sal_False;
     627                 :      13557 : }
     628                 :            : 
     629                 :            : // -----------------------------------------------------------------------
     630                 :            : 
     631                 :      13557 : void PushButton::ImplInit( Window* pParent, WinBits nStyle )
     632                 :            : {
     633                 :      13557 :     nStyle = ImplInitStyle( pParent->GetWindow( WINDOW_LASTCHILD ), nStyle );
     634                 :      13557 :     Button::ImplInit( pParent, nStyle, NULL );
     635                 :            : 
     636         [ +  + ]:      13557 :     if ( nStyle & WB_NOLIGHTBORDER )
     637                 :       5658 :         ImplGetButtonState() |= BUTTON_DRAW_NOLIGHTBORDER;
     638                 :            : 
     639                 :      13557 :     ImplInitSettings( sal_True, sal_True, sal_True );
     640                 :      13557 : }
     641                 :            : 
     642                 :            : // -----------------------------------------------------------------------
     643                 :            : 
     644                 :      19534 : WinBits PushButton::ImplInitStyle( const Window* pPrevWindow, WinBits nStyle )
     645                 :            : {
     646         [ +  - ]:      19534 :     if ( !(nStyle & WB_NOTABSTOP) )
     647                 :      19534 :         nStyle |= WB_TABSTOP;
     648                 :            : 
     649                 :            :     // if no alignment is given, default to "vertically centered". This is because since
     650                 :            :     // #i26046#, we respect the vertical alignment flags (previously we didn't completely),
     651                 :            :     // but we of course want to look as before when no vertical alignment is specified
     652         [ +  + ]:      19534 :     if ( ( nStyle & ( WB_TOP | WB_VCENTER | WB_BOTTOM ) ) == 0 )
     653                 :      13591 :         nStyle |= WB_VCENTER;
     654                 :            : 
     655 [ +  - ][ +  +  :      53880 :     if ( !(nStyle & WB_NOGROUP) &&
          +  +  +  -  +  
                -  +  - ]
                 [ +  + ]
     656                 :            :          (!pPrevWindow ||
     657                 :      16172 :           ((pPrevWindow->GetType() != WINDOW_PUSHBUTTON  ) &&
     658                 :       6058 :            (pPrevWindow->GetType() != WINDOW_OKBUTTON    ) &&
     659                 :       6058 :            (pPrevWindow->GetType() != WINDOW_CANCELBUTTON) &&
     660                 :       6058 :            (pPrevWindow->GetType() != WINDOW_HELPBUTTON  )) ) )
     661                 :       9420 :         nStyle |= WB_GROUP;
     662                 :      19534 :     return nStyle;
     663                 :            : }
     664                 :            : 
     665                 :            : // -----------------------------------------------------------------
     666                 :            : 
     667                 :      14396 : const Font& PushButton::GetCanonicalFont( const StyleSettings& _rStyle ) const
     668                 :            : {
     669                 :      14396 :     return _rStyle.GetPushButtonFont();
     670                 :            : }
     671                 :            : 
     672                 :            : // -----------------------------------------------------------------
     673                 :      14367 : const Color& PushButton::GetCanonicalTextColor( const StyleSettings& _rStyle ) const
     674                 :            : {
     675                 :      14367 :     return _rStyle.GetButtonTextColor();
     676                 :            : }
     677                 :            : 
     678                 :            : // -----------------------------------------------------------------------
     679                 :            : 
     680                 :      14373 : void PushButton::ImplInitSettings( sal_Bool bFont,
     681                 :            :                                    sal_Bool bForeground, sal_Bool bBackground )
     682                 :            : {
     683                 :      14373 :     Button::ImplInitSettings( bFont, bForeground );
     684                 :            : 
     685         [ +  + ]:      14373 :     if ( bBackground )
     686                 :            :     {
     687                 :      14328 :         SetBackground();
     688                 :            :         // #i38498#: do not check for GetParent()->IsChildTransparentModeEnabled()
     689                 :            :         // otherwise the formcontrol button will be overdrawn due to PARENTCLIPMODE_NOCLIP
     690                 :            :         // for radio and checkbox this is ok as they shoud appear transparent in documents
     691         [ +  + ]:      28656 :         if ( IsNativeControlSupported( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL ) ||
           [ +  -  +  + ]
     692                 :      14328 :              (GetStyle() & WB_FLATBUTTON) != 0 )
     693                 :            :         {
     694                 :         16 :             EnableChildTransparentMode( sal_True );
     695                 :         16 :             SetParentClipMode( PARENTCLIPMODE_NOCLIP );
     696                 :         16 :             SetPaintTransparent( sal_True );
     697                 :         16 :             mpWindowImpl->mbUseNativeFocus = (GetStyle() & WB_FLATBUTTON)
     698                 :            :                 ? false
     699         [ -  + ]:         16 :                 : ImplGetSVData()->maNWFData.mbNoFocusRects;
     700                 :            :         }
     701                 :            :         else
     702                 :            :         {
     703                 :      14312 :             EnableChildTransparentMode( sal_False );
     704                 :      14312 :             SetParentClipMode( 0 );
     705                 :      14312 :             SetPaintTransparent( sal_False );
     706                 :            :         }
     707                 :            :     }
     708                 :      14373 : }
     709                 :            : 
     710                 :            : // -----------------------------------------------------------------------
     711                 :            : 
     712                 :      12038 : void PushButton::ImplDrawPushButtonFrame( Window* pDev,
     713                 :            :                                           Rectangle& rRect, sal_uInt16 nStyle )
     714                 :            : {
     715 [ +  - ][ +  + ]:      12038 :     if ( !(pDev->GetStyle() & (WB_RECTSTYLE | WB_SMALLSTYLE)) )
     716                 :            :     {
     717         [ +  - ]:         78 :         StyleSettings aStyleSettings = pDev->GetSettings().GetStyleSettings();
     718 [ +  - ][ +  + ]:         78 :         if ( pDev->IsControlBackground() )
     719 [ +  - ][ +  - ]:         78 :             aStyleSettings.Set3DColors( pDev->GetControlBackground() );
                 [ +  - ]
     720                 :            :     }
     721                 :            : 
     722                 :      12038 :     DecorationView aDecoView( pDev );
     723 [ +  + ][ +  - ]:      12038 :     if ( pDev->IsControlBackground() )
     724                 :            :     {
     725         [ +  - ]:          2 :         AllSettings     aSettings = pDev->GetSettings();
     726         [ +  - ]:          2 :         AllSettings     aOldSettings = aSettings;
     727         [ +  - ]:          2 :         StyleSettings   aStyleSettings = aSettings.GetStyleSettings();
     728 [ +  - ][ +  - ]:          2 :         aStyleSettings.Set3DColors( pDev->GetControlBackground() );
     729         [ +  - ]:          2 :         aSettings.SetStyleSettings( aStyleSettings );
     730         [ +  - ]:          2 :         pDev->OutputDevice::SetSettings( aSettings );
     731         [ +  - ]:          2 :         rRect = aDecoView.DrawButton( rRect, nStyle );
     732 [ +  - ][ +  - ]:          2 :         pDev->OutputDevice::SetSettings( aOldSettings );
         [ +  - ][ +  - ]
     733                 :            :     }
     734                 :            :     else
     735         [ +  - ]:      12036 :         rRect = aDecoView.DrawButton( rRect, nStyle );
     736                 :      12038 : }
     737                 :            : 
     738                 :            : // -----------------------------------------------------------------------
     739                 :            : 
     740                 :          0 : sal_Bool PushButton::ImplHitTestPushButton( Window* pDev,
     741                 :            :                                         const Point& rPos )
     742                 :            : {
     743                 :          0 :     Point       aTempPoint;
     744         [ #  # ]:          0 :     Rectangle   aTestRect( aTempPoint, pDev->GetOutputSizePixel() );
     745                 :            : 
     746         [ #  # ]:          0 :     return aTestRect.IsInside( rPos );
     747                 :            : }
     748                 :            : 
     749                 :            : // -----------------------------------------------------------------------
     750                 :            : 
     751                 :      12054 : sal_uInt16 PushButton::ImplGetTextStyle( sal_uLong nDrawFlags ) const
     752                 :            : {
     753                 :      12054 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     754                 :            : 
     755                 :      12054 :     sal_uInt16 nTextStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_MULTILINE | TEXT_DRAW_ENDELLIPSIS;
     756                 :            : 
     757 [ -  + ][ -  + ]:      12054 :     if ( ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO ) ||
                 [ +  - ]
     758                 :            :          ( nDrawFlags & WINDOW_DRAW_MONO ) )
     759                 :          0 :         nTextStyle |= TEXT_DRAW_MONO;
     760                 :            : 
     761         [ -  + ]:      12054 :     if ( GetStyle() & WB_WORDBREAK )
     762                 :          0 :         nTextStyle |= TEXT_DRAW_WORDBREAK;
     763         [ -  + ]:      12054 :     if ( GetStyle() & WB_NOLABEL )
     764                 :          0 :         nTextStyle &= ~TEXT_DRAW_MNEMONIC;
     765                 :            : 
     766         [ +  + ]:      12054 :     if ( GetStyle() & WB_LEFT )
     767                 :         16 :         nTextStyle |= TEXT_DRAW_LEFT;
     768         [ -  + ]:      12038 :     else if ( GetStyle() & WB_RIGHT )
     769                 :          0 :         nTextStyle |= TEXT_DRAW_RIGHT;
     770                 :            :     else
     771                 :      12038 :         nTextStyle |= TEXT_DRAW_CENTER;
     772                 :            : 
     773         [ -  + ]:      12054 :     if ( GetStyle() & WB_TOP )
     774                 :          0 :         nTextStyle |= TEXT_DRAW_TOP;
     775         [ -  + ]:      12054 :     else if ( GetStyle() & WB_BOTTOM )
     776                 :          0 :         nTextStyle |= TEXT_DRAW_BOTTOM;
     777                 :            :     else
     778                 :      12054 :         nTextStyle |= TEXT_DRAW_VCENTER;
     779                 :            : 
     780 [ +  - ][ +  + ]:      12054 :     if ( ! ( (nDrawFlags & WINDOW_DRAW_NODISABLE) || IsEnabled() ) )
                 [ +  + ]
     781                 :       1993 :         nTextStyle |= TEXT_DRAW_DISABLE;
     782                 :            : 
     783                 :      12054 :     return nTextStyle;
     784                 :            : }
     785                 :            : 
     786                 :            : // -----------------------------------------------------------------------
     787                 :            : 
     788                 :          0 : static void ImplDrawBtnDropDownArrow( OutputDevice* pDev,
     789                 :            :                                       long nX, long nY,
     790                 :            :                                       Color& rColor, sal_Bool bBlack )
     791                 :            : {
     792                 :          0 :     Color aOldLineColor = pDev->GetLineColor();
     793                 :          0 :     Color aOldFillColor = pDev->GetFillColor();
     794                 :            : 
     795         [ #  # ]:          0 :     pDev->SetLineColor();
     796         [ #  # ]:          0 :     if ( bBlack )
     797         [ #  # ]:          0 :         pDev->SetFillColor( Color( COL_BLACK ) );
     798                 :            :     else
     799         [ #  # ]:          0 :         pDev->SetFillColor( rColor );
     800 [ #  # ][ #  # ]:          0 :     pDev->DrawRect( Rectangle( nX+0, nY+0, nX+6, nY+0 ) );
     801 [ #  # ][ #  # ]:          0 :     pDev->DrawRect( Rectangle( nX+1, nY+1, nX+5, nY+1 ) );
     802 [ #  # ][ #  # ]:          0 :     pDev->DrawRect( Rectangle( nX+2, nY+2, nX+4, nY+2 ) );
     803 [ #  # ][ #  # ]:          0 :     pDev->DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
     804         [ #  # ]:          0 :     if ( bBlack )
     805                 :            :     {
     806         [ #  # ]:          0 :         pDev->SetFillColor( rColor );
     807 [ #  # ][ #  # ]:          0 :         pDev->DrawRect( Rectangle( nX+2, nY+1, nX+4, nY+1 ) );
     808 [ #  # ][ #  # ]:          0 :         pDev->DrawRect( Rectangle( nX+3, nY+2, nX+3, nY+2 ) );
     809                 :            :     }
     810         [ #  # ]:          0 :     pDev->SetLineColor( aOldLineColor );
     811         [ #  # ]:          0 :     pDev->SetFillColor( aOldFillColor );
     812                 :          0 : }
     813                 :            : 
     814                 :            : // -----------------------------------------------------------------------
     815                 :            : 
     816                 :      12054 : void PushButton::ImplDrawPushButtonContent( OutputDevice* pDev, sal_uLong nDrawFlags,
     817                 :            :                                             const Rectangle& rRect,
     818                 :            :                                             bool bLayout,
     819                 :            :                                             bool bMenuBtnSep
     820                 :            :                                             )
     821                 :            : {
     822                 :      12054 :     const StyleSettings&    rStyleSettings = GetSettings().GetStyleSettings();
     823                 :      12054 :     Rectangle               aInRect = rRect;
     824                 :      12054 :     Color                   aColor;
     825         [ +  - ]:      12054 :     XubString               aText = PushButton::GetText(); // PushButton:: wegen MoreButton
     826         [ +  - ]:      12054 :     sal_uInt16                  nTextStyle = ImplGetTextStyle( nDrawFlags );
     827                 :            :     sal_uInt16                  nStyle;
     828                 :            : 
     829 [ +  - ][ -  + ]:      12054 :     if( aInRect.nRight < aInRect.nLeft || aInRect.nBottom < aInRect.nTop )
     830                 :          0 :         aInRect.SetEmpty();
     831                 :            : 
     832         [ +  - ]:      12054 :     pDev->Push( PUSH_CLIPREGION );
     833         [ +  - ]:      12054 :     pDev->IntersectClipRegion( aInRect );
     834                 :            : 
     835         [ -  + ]:      12054 :     if ( nDrawFlags & WINDOW_DRAW_MONO )
     836                 :          0 :         aColor = Color( COL_BLACK );
     837 [ +  - ][ +  + ]:      12054 :     else if ( IsControlForeground() )
     838         [ +  - ]:          2 :         aColor = GetControlForeground();
     839         [ -  + ]:      12052 :     else if( nDrawFlags & WINDOW_DRAW_ROLLOVER )
     840                 :          0 :         aColor = rStyleSettings.GetButtonRolloverTextColor();
     841                 :            :     else
     842                 :      12052 :         aColor = rStyleSettings.GetButtonTextColor();
     843                 :            : 
     844         [ +  - ]:      12054 :     pDev->SetTextColor( aColor );
     845                 :            : 
     846 [ +  - ][ +  + ]:      12054 :     if ( IsEnabled() || (nDrawFlags & WINDOW_DRAW_NODISABLE) )
         [ -  + ][ +  + ]
     847                 :      10061 :         nStyle = 0;
     848                 :            :     else
     849                 :       1993 :         nStyle = SYMBOL_DRAW_DISABLE;
     850                 :            : 
     851         [ +  - ]:      12054 :     Size aSize = rRect.GetSize();
     852                 :      12054 :     Point aPos = rRect.TopLeft();
     853                 :            : 
     854         [ +  - ]:      12054 :     sal_uLong nImageSep = 1 + (pDev->GetTextHeight()-10)/2;
     855         [ -  + ]:      12054 :     if( nImageSep < 1 )
     856                 :          0 :         nImageSep = 1;
     857         [ +  + ]:      12054 :     if ( mnDDStyle == PUSHBUTTON_DROPDOWN_MENUBUTTON )
     858                 :            :     {
     859                 :          2 :         long nSeparatorX = 0;
     860                 :          2 :         Rectangle aSymbolRect = aInRect;
     861 [ +  - ][ +  - ]:          2 :         if ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
                 [ +  - ]
     862                 :            :         {
     863                 :            :             // calculate symbol size
     864         [ +  - ]:          2 :             long nSymbolSize    = pDev->GetTextHeight() / 2 + 1;
     865                 :            : 
     866                 :          2 :             nSeparatorX = aInRect.Right() - 2*nSymbolSize;
     867                 :          2 :             aSize.Width() -= 2*nSymbolSize;
     868                 :            : 
     869                 :            :             // center symbol rectangle in the separated area
     870                 :          2 :             aSymbolRect.Right() -= nSymbolSize/2;
     871                 :          2 :             aSymbolRect.Left()  = aSymbolRect.Right() - nSymbolSize;
     872                 :            : 
     873                 :            :             ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, nImageSep,
     874         [ +  - ]:          2 :                                   nDrawFlags, nTextStyle, NULL, true );
     875                 :            :         }
     876                 :            :         else
     877         [ #  # ]:          0 :             ImplCalcSymbolRect( aSymbolRect );
     878                 :            : 
     879         [ +  - ]:          2 :         if( ! bLayout )
     880                 :            :         {
     881 [ +  - ][ +  - ]:          2 :             long nDistance = (aSymbolRect.GetHeight() > 10) ? 2 : 1;
     882                 :          2 :             DecorationView aDecoView( pDev );
     883 [ #  # ][ -  + ]:          2 :             if( bMenuBtnSep && nSeparatorX > 0 )
     884                 :            :             {
     885                 :          0 :                 Point aStartPt( nSeparatorX, aSymbolRect.Top()+nDistance );
     886                 :          0 :                 Point aEndPt( nSeparatorX, aSymbolRect.Bottom()-nDistance );
     887         [ #  # ]:          0 :                 aDecoView.DrawSeparator( aStartPt, aEndPt );
     888                 :            :             }
     889                 :          2 :             ImplSetSeparatorX( nSeparatorX );
     890                 :            : 
     891         [ +  - ]:          2 :             aDecoView.DrawSymbol( aSymbolRect, SYMBOL_SPIN_DOWN, aColor, nStyle );
     892                 :            :         }
     893                 :            : 
     894                 :            :     }
     895                 :            :     else
     896                 :            :     {
     897         [ +  - ]:      12052 :         Rectangle aSymbolRect;
     898                 :            :         // FIXME: (GetStyle() & WB_FLATBUTTON) != 0 is preliminary
     899                 :            :         // in the next major this should be replaced by "true"
     900                 :            :         ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, nImageSep, nDrawFlags,
     901 [ +  + ][ +  - ]:      12052 :                               nTextStyle, IsSymbol() ? &aSymbolRect : NULL, true );
     902                 :            : 
     903 [ +  + ][ +  - ]:      12052 :         if ( IsSymbol() && ! bLayout )
                 [ +  + ]
     904                 :            :         {
     905                 :      10285 :             DecorationView aDecoView( pDev );
     906         [ +  - ]:      10285 :             aDecoView.DrawSymbol( aSymbolRect, meSymbol, aColor, nStyle );
     907                 :            :         }
     908                 :            : 
     909 [ -  + ][ #  # ]:      12052 :         if ( mnDDStyle == PUSHBUTTON_DROPDOWN_TOOLBOX && !bLayout )
     910                 :            :         {
     911                 :          0 :             sal_Bool    bBlack = sal_False;
     912                 :          0 :             Color   aArrowColor( COL_BLACK );
     913                 :            : 
     914         [ #  # ]:          0 :             if ( !(nDrawFlags & WINDOW_DRAW_MONO) )
     915                 :            :             {
     916 [ #  # ][ #  # ]:          0 :                 if ( !IsEnabled() )
     917                 :          0 :                     aArrowColor = rStyleSettings.GetShadowColor();
     918                 :            :                 else
     919                 :            :                 {
     920                 :          0 :                     aArrowColor = Color( COL_LIGHTGREEN );
     921                 :          0 :                     bBlack = sal_True;
     922                 :            :                 }
     923                 :            :             }
     924                 :            : 
     925                 :          0 :             ImplDrawBtnDropDownArrow( pDev, aInRect.Right()-6, aInRect.Top()+1,
     926         [ #  # ]:      12052 :                                       aArrowColor, bBlack );
     927                 :            :         }
     928                 :            :     }
     929                 :            : 
     930         [ +  - ]:      12054 :     UserDrawEvent aUDEvt( this, aInRect, 0 );
     931         [ +  - ]:      12054 :     UserDraw( aUDEvt );
     932                 :            : 
     933 [ +  - ][ +  - ]:      12054 :     pDev->Pop();  // restore clipregion
     934                 :      12054 : }
     935                 :            : 
     936                 :            : // -----------------------------------------------------------------------
     937                 :            : 
     938                 :      12054 : void PushButton::UserDraw( const UserDrawEvent& )
     939                 :            : {
     940                 :      12054 : }
     941                 :            : 
     942                 :            : // -----------------------------------------------------------------------
     943                 :            : 
     944                 :      12054 : void PushButton::ImplDrawPushButton( bool bLayout )
     945                 :            : {
     946         [ +  - ]:      12054 :     if( !bLayout )
     947         [ +  - ]:      12054 :         HideFocus();
     948                 :            : 
     949                 :      12054 :     sal_uInt16                  nButtonStyle = ImplGetButtonState();
     950                 :      12054 :     Point                   aPoint;
     951                 :      12054 :     Size                    aOutSz( GetOutputSizePixel() );
     952         [ +  - ]:      12054 :     Rectangle               aRect( aPoint, aOutSz );
     953                 :      12054 :     Rectangle               aInRect = aRect;
     954         [ +  - ]:      12054 :     Rectangle               aTextRect;
     955                 :      12054 :     sal_Bool                    bNativeOK = sal_False;
     956                 :            : 
     957                 :            :     // adjust style if button should be rendered 'pressed'
     958         [ +  + ]:      12054 :     if ( mbPressed )
     959                 :          4 :         nButtonStyle |= BUTTON_DRAW_PRESSED;
     960                 :            : 
     961                 :            :     // TODO: move this to Window class or make it a member !!!
     962                 :      12054 :     ControlType aCtrlType = 0;
     963 [ +  - ][ +  - ]:      12054 :     switch( GetParent()->GetType() )
              [ +  +  + ]
     964                 :            :     {
     965                 :            :         case WINDOW_LISTBOX:
     966                 :            :         case WINDOW_MULTILISTBOX:
     967                 :            :         case WINDOW_TREELISTBOX:
     968                 :       1093 :             aCtrlType = CTRL_LISTBOX;
     969                 :       1093 :             break;
     970                 :            : 
     971                 :            :         case WINDOW_COMBOBOX:
     972                 :            :         case WINDOW_PATTERNBOX:
     973                 :            :         case WINDOW_NUMERICBOX:
     974                 :            :         case WINDOW_METRICBOX:
     975                 :            :         case WINDOW_CURRENCYBOX:
     976                 :            :         case WINDOW_DATEBOX:
     977                 :            :         case WINDOW_TIMEBOX:
     978                 :            :         case WINDOW_LONGCURRENCYBOX:
     979                 :       3966 :             aCtrlType = CTRL_COMBOBOX;
     980                 :       3966 :             break;
     981                 :            :         default:
     982                 :       6995 :             break;
     983                 :            :     }
     984                 :            : 
     985 [ +  + ][ +  + ]:      12054 :     sal_Bool bDropDown = ( IsSymbol() && (GetSymbol()==SYMBOL_SPIN_DOWN) && !GetText().Len() );
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
                 [ #  # ]
     986                 :            : 
     987 [ +  + ][ +  + ]:      12054 :     if( bDropDown && (aCtrlType == CTRL_COMBOBOX || aCtrlType == CTRL_LISTBOX ) )
                 [ +  + ]
     988                 :            :     {
     989 [ +  - ][ +  - ]:       5059 :         if( GetParent()->IsNativeControlSupported( aCtrlType, PART_ENTIRE_CONTROL) )
                 [ -  + ]
     990                 :            :         {
     991                 :            :             // skip painting if the button was already drawn by the theme
     992         [ #  # ]:          0 :             if( aCtrlType == CTRL_COMBOBOX )
     993                 :            :             {
     994         [ #  # ]:          0 :                 Edit* pEdit = static_cast<Edit*>(GetParent());
     995 [ #  # ][ #  # ]:          0 :                 if( pEdit->ImplUseNativeBorder( pEdit->GetStyle() ) )
                 [ #  # ]
     996                 :          0 :                     bNativeOK = sal_True;
     997                 :            :             }
     998 [ #  # ][ #  # ]:          0 :             else if( GetParent()->IsNativeControlSupported( aCtrlType, HAS_BACKGROUND_TEXTURE) )
                 [ #  # ]
     999                 :            :             {
    1000                 :          0 :                 bNativeOK = sal_True;
    1001                 :            :             }
    1002 [ #  # ][ #  # ]:          0 :             if( !bNativeOK && GetParent()->IsNativeControlSupported( aCtrlType, PART_BUTTON_DOWN ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1003                 :            :             {
    1004                 :            :                 // let the theme draw it, note we then need support
    1005                 :            :                 // for CTRL_LISTBOX/PART_BUTTON_DOWN and CTRL_COMBOBOX/PART_BUTTON_DOWN
    1006                 :            : 
    1007                 :          0 :                 ImplControlValue    aControlValue;
    1008                 :          0 :                 ControlState        nState = 0;
    1009                 :            : 
    1010         [ #  # ]:          0 :                 if ( mbPressed )                        nState |= CTRL_STATE_PRESSED;
    1011         [ #  # ]:          0 :                 if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )   nState |= CTRL_STATE_PRESSED;
    1012 [ #  # ][ #  # ]:          0 :                 if ( HasFocus() )                       nState |= CTRL_STATE_FOCUSED;
    1013         [ #  # ]:          0 :                 if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT )   nState |= CTRL_STATE_DEFAULT;
    1014 [ #  # ][ #  # ]:          0 :                 if ( Window::IsEnabled() )              nState |= CTRL_STATE_ENABLED;
    1015                 :            : 
    1016 [ #  # ][ #  # ]:          0 :                 if ( IsMouseOver() && aInRect.IsInside( GetPointerPosPixel() ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1017                 :          0 :                     nState |= CTRL_STATE_ROLLOVER;
    1018                 :            : 
    1019                 :            :                 bNativeOK = DrawNativeControl( aCtrlType, PART_BUTTON_DOWN, aInRect, nState,
    1020 [ #  # ][ #  # ]:          0 :                                                 aControlValue, rtl::OUString() );
    1021                 :            :             }
    1022                 :            :         }
    1023                 :            :     }
    1024                 :            : 
    1025         [ +  - ]:      12054 :     if( bNativeOK )
    1026                 :      12054 :         return;
    1027                 :            : 
    1028 [ +  - ][ -  + ]:      12054 :     bool bRollOver = (IsMouseOver() && aInRect.IsInside( GetPointerPosPixel() ));
         [ #  # ][ #  # ]
         [ #  # ][ -  + ]
                 [ #  # ]
    1029                 :      12054 :     bool bDrawMenuSep = true;
    1030 [ +  - ][ +  + ]:      12054 :     if( (GetStyle() & WB_FLATBUTTON) )
    1031                 :            :     {
    1032 [ +  - ][ +  - ]:         16 :         if( ! bRollOver && ! HasFocus() )
         [ +  + ][ +  + ]
    1033                 :         14 :             bDrawMenuSep = false;
    1034                 :            :     }
    1035 [ +  - ][ -  + ]:      12054 :     if ( (bNativeOK=IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL)) == sal_True )
    1036                 :            :     {
    1037         [ #  # ]:          0 :         PushButtonValue aControlValue;
    1038                 :          0 :         Rectangle        aCtrlRegion( aInRect );
    1039                 :          0 :         ControlState     nState = 0;
    1040                 :            : 
    1041 [ #  # ][ #  # ]:          0 :         if ( mbPressed || IsChecked() )                   nState |= CTRL_STATE_PRESSED;
         [ #  # ][ #  # ]
    1042         [ #  # ]:          0 :         if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED ) nState |= CTRL_STATE_PRESSED;
    1043 [ #  # ][ #  # ]:          0 :         if ( HasFocus() )                       nState |= CTRL_STATE_FOCUSED;
    1044         [ #  # ]:          0 :         if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT )   nState |= CTRL_STATE_DEFAULT;
    1045 [ #  # ][ #  # ]:          0 :         if ( Window::IsEnabled() )              nState |= CTRL_STATE_ENABLED;
    1046                 :            : 
    1047         [ #  # ]:          0 :         if ( bRollOver )
    1048                 :          0 :             nState |= CTRL_STATE_ROLLOVER;
    1049                 :            : 
    1050 [ #  # ][ #  # ]:          0 :         if( GetStyle() & WB_BEVELBUTTON )
    1051                 :          0 :             aControlValue.mbBevelButton = true;
    1052                 :            : 
    1053                 :            :         // draw frame into invisible window to have aInRect modified correctly
    1054                 :            :         // but do not shift the inner rect for pressed buttons (ie remove BUTTON_DRAW_PRESSED)
    1055                 :            :         // this assumes the theme has enough visual cues to signalize the button was pressed
    1056                 :            :         //Window aWin( this );
    1057                 :            :         //ImplDrawPushButtonFrame( &aWin, aInRect, nButtonStyle & ~BUTTON_DRAW_PRESSED );
    1058                 :            : 
    1059                 :            :         // looks better this way as symbols were displaced slightly using the above approach
    1060                 :          0 :         aInRect.Top()+=4;
    1061                 :          0 :         aInRect.Bottom()-=4;
    1062                 :          0 :         aInRect.Left()+=4;
    1063                 :          0 :         aInRect.Right()-=4;
    1064                 :            : 
    1065                 :            :         // prepare single line hint (needed on mac to decide between normal push button and
    1066                 :            :         // rectangular bevel button look)
    1067 [ #  # ][ #  # ]:          0 :         Size aFontSize( Application::GetSettings().GetStyleSettings().GetPushButtonFont().GetSize() );
    1068 [ #  # ][ #  # ]:          0 :         aFontSize = LogicToPixel( aFontSize, MapMode( MAP_POINT ) );
                 [ #  # ]
    1069 [ #  # ][ #  # ]:          0 :         Size aInRectSize( LogicToPixel( Size( aInRect.GetWidth(), aInRect.GetHeight() ) ) );
                 [ #  # ]
    1070                 :          0 :         aControlValue.mbSingleLine = (aInRectSize.Height() < 2 * aFontSize.Height() );
    1071                 :            : 
    1072 [ #  # ][ #  # ]:          0 :         if( ((nState & CTRL_STATE_ROLLOVER)) || ! (GetStyle() & WB_FLATBUTTON) )
         [ #  # ][ #  # ]
    1073                 :            :         {
    1074                 :            :             bNativeOK = DrawNativeControl( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
    1075         [ #  # ]:          0 :                             aControlValue, rtl::OUString()/*PushButton::GetText()*/ );
    1076                 :            :         }
    1077                 :            :         else
    1078                 :            :         {
    1079                 :          0 :             bNativeOK = true;
    1080                 :            :         }
    1081                 :            : 
    1082                 :            :         // draw content using the same aInRect as non-native VCL would do
    1083                 :            :         ImplDrawPushButtonContent( this,
    1084                 :            :                                    (nState&CTRL_STATE_ROLLOVER) ? WINDOW_DRAW_ROLLOVER : 0,
    1085 [ #  # ][ #  # ]:          0 :                                    aInRect, bLayout, bDrawMenuSep );
    1086                 :            : 
    1087 [ #  # ][ #  # ]:          0 :         if ( HasFocus() )
    1088 [ #  # ][ #  # ]:          0 :             ShowFocus( ImplGetFocusRect() );
    1089                 :            :     }
    1090                 :            : 
    1091         [ +  - ]:      12054 :     if ( bNativeOK == sal_False )
    1092                 :            :     {
    1093                 :            :         // draw PushButtonFrame, aInRect has content size afterwards
    1094 [ +  - ][ +  + ]:      12054 :         if( (GetStyle() & WB_FLATBUTTON) )
    1095                 :            :         {
    1096                 :         16 :             Rectangle aTempRect( aInRect );
    1097 [ +  - ][ -  + ]:         16 :             if( ! bLayout && bRollOver )
    1098         [ #  # ]:          0 :                 ImplDrawPushButtonFrame( this, aTempRect, nButtonStyle );
    1099                 :         16 :             aInRect.Left()   += 2;
    1100                 :         16 :             aInRect.Top()    += 2;
    1101                 :         16 :             aInRect.Right()  -= 2;
    1102                 :         16 :             aInRect.Bottom() -= 2;
    1103                 :            :         }
    1104                 :            :         else
    1105                 :            :         {
    1106         [ +  - ]:      12038 :             if( ! bLayout )
    1107         [ +  - ]:      12038 :                 ImplDrawPushButtonFrame( this, aInRect, nButtonStyle );
    1108                 :            :         }
    1109                 :            : 
    1110                 :            :         // draw content
    1111         [ +  - ]:      12054 :         ImplDrawPushButtonContent( this, 0, aInRect, bLayout, bDrawMenuSep );
    1112                 :            : 
    1113 [ +  - ][ +  - ]:      12054 :         if( ! bLayout && HasFocus() )
         [ +  + ][ +  + ]
    1114                 :            :         {
    1115         [ +  - ]:      12054 :             ShowFocus( ImplGetFocusRect() );
    1116                 :            :         }
    1117                 :            :     }
    1118                 :            : }
    1119                 :            : 
    1120                 :            : // -----------------------------------------------------------------------
    1121                 :            : 
    1122                 :         12 : void PushButton::ImplSetDefButton( sal_Bool bSet )
    1123                 :            : {
    1124         [ +  - ]:         12 :     Size aSize( GetSizePixel() );
    1125         [ +  - ]:         12 :     Point aPos( GetPosPixel() );
    1126                 :         12 :     int dLeft(0), dRight(0), dTop(0), dBottom(0);
    1127                 :         12 :     sal_Bool bSetPos = sal_False;
    1128                 :            : 
    1129 [ +  - ][ -  + ]:         12 :     if ( (IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL)) == sal_True )
    1130                 :            :     {
    1131 [ #  # ][ #  # ]:          0 :         Rectangle aBound, aCont;
    1132         [ #  # ]:          0 :         Rectangle aCtrlRect( 0, 0, 80, 20 ); // use a constant size to avoid accumulating
    1133                 :            :                                              // will not work if the theme has dynamic adornment sizes
    1134                 :          0 :         ImplControlValue aControlValue;
    1135                 :          0 :         Rectangle        aCtrlRegion( aCtrlRect );
    1136                 :          0 :         ControlState     nState = CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED;
    1137                 :            : 
    1138                 :            :         // get native size of a 'default' button
    1139                 :            :         // and adjust the VCL button if more space for adornment is required
    1140         [ #  # ]:          0 :         if( GetNativeControlRegion( CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion,
    1141                 :            :                                 nState, aControlValue, rtl::OUString(),
    1142         [ #  # ]:          0 :                                 aBound, aCont ) )
    1143                 :            :         {
    1144                 :          0 :             dLeft = aCont.Left() - aBound.Left();
    1145                 :          0 :             dTop = aCont.Top() - aBound.Top();
    1146                 :          0 :             dRight = aBound.Right() - aCont.Right();
    1147                 :          0 :             dBottom = aBound.Bottom() - aCont.Bottom();
    1148 [ #  # ][ #  # ]:          0 :             bSetPos = dLeft || dTop || dRight || dBottom;
         [ #  # ][ #  # ]
    1149         [ #  # ]:          0 :         }
    1150                 :            :     }
    1151                 :            : 
    1152         [ +  + ]:         12 :     if ( bSet )
    1153                 :            :     {
    1154 [ +  - ][ -  + ]:          6 :         if( !(ImplGetButtonState() & BUTTON_DRAW_DEFAULT) && bSetPos )
                 [ -  + ]
    1155                 :            :         {
    1156                 :            :             // adjust pos/size when toggling from non-default to default
    1157                 :          0 :             aPos.Move(-dLeft, -dTop);
    1158                 :          0 :             aSize.Width() += dLeft + dRight;
    1159                 :          0 :             aSize.Height() += dTop + dBottom;
    1160                 :            :         }
    1161                 :          6 :         ImplGetButtonState() |= BUTTON_DRAW_DEFAULT;
    1162                 :            :     }
    1163                 :            :     else
    1164                 :            :     {
    1165 [ +  - ][ -  + ]:          6 :         if( (ImplGetButtonState() & BUTTON_DRAW_DEFAULT) && bSetPos )
                 [ -  + ]
    1166                 :            :         {
    1167                 :            :             // adjust pos/size when toggling from default to non-default
    1168                 :          0 :             aPos.Move(dLeft, dTop);
    1169                 :          0 :             aSize.Width() -= dLeft + dRight;
    1170                 :          0 :             aSize.Height() -= dTop + dBottom;
    1171                 :            :         }
    1172                 :          6 :         ImplGetButtonState() &= ~BUTTON_DRAW_DEFAULT;
    1173                 :            :     }
    1174         [ -  + ]:         12 :     if( bSetPos )
    1175         [ #  # ]:          0 :         SetPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height(), WINDOW_POSSIZE_ALL );
    1176                 :            : 
    1177         [ +  - ]:         12 :     Invalidate();
    1178                 :         12 : }
    1179                 :            : 
    1180                 :            : // -----------------------------------------------------------------------
    1181                 :            : 
    1182                 :         78 : sal_Bool PushButton::ImplIsDefButton() const
    1183                 :            : {
    1184                 :         78 :     return (ImplGetButtonState() & BUTTON_DRAW_DEFAULT) != 0;
    1185                 :            : }
    1186                 :            : 
    1187                 :            : // -----------------------------------------------------------------------
    1188                 :            : 
    1189                 :         32 : PushButton::PushButton( WindowType nType ) :
    1190         [ +  - ]:         32 :     Button( nType )
    1191                 :            : {
    1192                 :         32 :     ImplInitPushButtonData();
    1193                 :         32 : }
    1194                 :            : 
    1195                 :            : // -----------------------------------------------------------------------
    1196                 :            : 
    1197                 :       9571 : PushButton::PushButton( Window* pParent, WinBits nStyle ) :
    1198         [ +  - ]:       9571 :     Button( WINDOW_PUSHBUTTON )
    1199                 :            : {
    1200                 :       9571 :     ImplInitPushButtonData();
    1201         [ +  - ]:       9571 :     ImplInit( pParent, nStyle );
    1202                 :       9571 : }
    1203                 :            : 
    1204                 :            : // -----------------------------------------------------------------------
    1205                 :            : 
    1206                 :       3954 : PushButton::PushButton( Window* pParent, const ResId& rResId ) :
    1207         [ +  - ]:       3954 :     Button( WINDOW_PUSHBUTTON )
    1208                 :            : {
    1209                 :       3954 :     ImplInitPushButtonData();
    1210                 :       3954 :     rResId.SetRT( RSC_PUSHBUTTON );
    1211         [ +  - ]:       3954 :     WinBits nStyle = ImplInitRes( rResId );
    1212         [ +  - ]:       3954 :     ImplInit( pParent, nStyle );
    1213         [ +  - ]:       3954 :     ImplLoadRes( rResId );
    1214                 :            : 
    1215         [ -  + ]:       3954 :     if ( !(nStyle & WB_HIDE) )
    1216         [ #  # ]:          0 :         Show();
    1217                 :       3954 : }
    1218                 :            : 
    1219                 :            : // -----------------------------------------------------------------------
    1220                 :            : 
    1221                 :      13084 : PushButton::~PushButton()
    1222                 :            : {
    1223         [ -  + ]:      13136 : }
    1224                 :            : 
    1225                 :            : // -----------------------------------------------------------------------
    1226                 :            : 
    1227                 :          0 : void PushButton::MouseButtonDown( const MouseEvent& rMEvt )
    1228                 :            : {
    1229   [ #  #  #  # ]:          0 :     if ( rMEvt.IsLeft() &&
                 [ #  # ]
    1230                 :          0 :          ImplHitTestPushButton( this, rMEvt.GetPosPixel() ) )
    1231                 :            :     {
    1232                 :          0 :         sal_uInt16 nTrackFlags = 0;
    1233                 :            : 
    1234   [ #  #  #  # ]:          0 :         if ( ( GetStyle() & WB_REPEAT ) &&
                 [ #  # ]
    1235                 :          0 :              ! ( GetStyle() & WB_TOGGLE ) )
    1236                 :          0 :             nTrackFlags |= STARTTRACK_BUTTONREPEAT;
    1237                 :            : 
    1238                 :          0 :         ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
    1239                 :          0 :         ImplDrawPushButton();
    1240                 :          0 :         StartTracking( nTrackFlags );
    1241                 :            : 
    1242         [ #  # ]:          0 :         if ( nTrackFlags & STARTTRACK_BUTTONREPEAT )
    1243                 :          0 :             Click();
    1244                 :            :     }
    1245                 :          0 : }
    1246                 :            : 
    1247                 :            : // -----------------------------------------------------------------------
    1248                 :            : 
    1249                 :          0 : void PushButton::Tracking( const TrackingEvent& rTEvt )
    1250                 :            : {
    1251         [ #  # ]:          0 :     if ( rTEvt.IsTrackingEnded() )
    1252                 :            :     {
    1253         [ #  # ]:          0 :         if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
    1254                 :            :         {
    1255 [ #  # ][ #  # ]:          0 :             if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
                 [ #  # ]
    1256                 :          0 :                 GrabFocus();
    1257                 :            : 
    1258         [ #  # ]:          0 :             if ( GetStyle() & WB_TOGGLE )
    1259                 :            :             {
    1260                 :            :                 // Don't toggle, when aborted
    1261         [ #  # ]:          0 :                 if ( !rTEvt.IsTrackingCanceled() )
    1262                 :            :                 {
    1263         [ #  # ]:          0 :                     if ( IsChecked() )
    1264                 :            :                     {
    1265                 :          0 :                         Check( sal_False );
    1266                 :          0 :                         ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    1267                 :            :                     }
    1268                 :            :                     else
    1269                 :          0 :                         Check( sal_True );
    1270                 :            :                 }
    1271                 :            :             }
    1272                 :            :             else
    1273                 :          0 :                 ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    1274                 :            : 
    1275                 :          0 :             ImplDrawPushButton();
    1276                 :            : 
    1277                 :            :             // do not call Click handler if aborted
    1278         [ #  # ]:          0 :             if ( !rTEvt.IsTrackingCanceled() )
    1279                 :            :             {
    1280         [ #  # ]:          0 :                 if ( ! ( ( GetStyle() & WB_REPEAT ) &&
    1281 [ #  # ][ #  # ]:          0 :                          ! ( GetStyle() & WB_TOGGLE ) ) )
    1282                 :          0 :                     Click();
    1283                 :            :             }
    1284                 :            :         }
    1285                 :            :     }
    1286                 :            :     else
    1287                 :            :     {
    1288         [ #  # ]:          0 :         if ( ImplHitTestPushButton( this, rTEvt.GetMouseEvent().GetPosPixel() ) )
    1289                 :            :         {
    1290         [ #  # ]:          0 :             if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
    1291                 :            :             {
    1292         [ #  # ]:          0 :                 if ( rTEvt.IsTrackingRepeat() && (GetStyle() & WB_REPEAT) &&
           [ #  #  #  # ]
                 [ #  # ]
    1293                 :          0 :                      ! ( GetStyle() & WB_TOGGLE ) )
    1294                 :          0 :                     Click();
    1295                 :            :             }
    1296                 :            :             else
    1297                 :            :             {
    1298                 :          0 :                 ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
    1299                 :          0 :                 ImplDrawPushButton();
    1300                 :            :             }
    1301                 :            :         }
    1302                 :            :         else
    1303                 :            :         {
    1304         [ #  # ]:          0 :             if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
    1305                 :            :             {
    1306                 :          0 :                 ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    1307                 :          0 :                 ImplDrawPushButton();
    1308                 :            :             }
    1309                 :            :         }
    1310                 :            :     }
    1311                 :          0 : }
    1312                 :            : 
    1313                 :            : // -----------------------------------------------------------------------
    1314                 :            : 
    1315                 :          0 : void PushButton::KeyInput( const KeyEvent& rKEvt )
    1316                 :            : {
    1317                 :          0 :     KeyCode aKeyCode = rKEvt.GetKeyCode();
    1318                 :            : 
    1319 [ #  # ][ #  #  :          0 :     if ( !aKeyCode.GetModifier() &&
             #  #  #  # ]
    1320                 :          0 :          ((aKeyCode.GetCode() == KEY_RETURN) || (aKeyCode.GetCode() == KEY_SPACE)) )
    1321                 :            :     {
    1322         [ #  # ]:          0 :         if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
    1323                 :            :         {
    1324                 :          0 :             ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
    1325         [ #  # ]:          0 :             ImplDrawPushButton();
    1326                 :            :         }
    1327                 :            : 
    1328 [ #  # ][ #  # ]:          0 :         if ( ( GetStyle() & WB_REPEAT ) &&
         [ #  # ][ #  # ]
    1329         [ #  # ]:          0 :              ! ( GetStyle() & WB_TOGGLE ) )
    1330         [ #  # ]:          0 :             Click();
    1331                 :            :     }
    1332 [ #  # ][ #  # ]:          0 :     else if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) && (aKeyCode.GetCode() == KEY_ESCAPE) )
                 [ #  # ]
    1333                 :            :     {
    1334                 :          0 :         ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    1335         [ #  # ]:          0 :         ImplDrawPushButton();
    1336                 :            :     }
    1337                 :            :     else
    1338         [ #  # ]:          0 :         Button::KeyInput( rKEvt );
    1339                 :          0 : }
    1340                 :            : 
    1341                 :            : // -----------------------------------------------------------------------
    1342                 :            : 
    1343                 :          0 : void PushButton::KeyUp( const KeyEvent& rKEvt )
    1344                 :            : {
    1345                 :          0 :     KeyCode aKeyCode = rKEvt.GetKeyCode();
    1346                 :            : 
    1347 [ #  # ][ #  #  :          0 :     if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) &&
             #  #  #  # ]
    1348                 :          0 :          ((aKeyCode.GetCode() == KEY_RETURN) || (aKeyCode.GetCode() == KEY_SPACE)) )
    1349                 :            :     {
    1350 [ #  # ][ #  # ]:          0 :         if ( GetStyle() & WB_TOGGLE )
    1351                 :            :         {
    1352 [ #  # ][ #  # ]:          0 :             if ( IsChecked() )
    1353                 :            :             {
    1354         [ #  # ]:          0 :                 Check( sal_False );
    1355                 :          0 :                 ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    1356                 :            :             }
    1357                 :            :             else
    1358         [ #  # ]:          0 :                 Check( sal_True );
    1359                 :            : 
    1360         [ #  # ]:          0 :             Toggle();
    1361                 :            :         }
    1362                 :            :         else
    1363                 :          0 :             ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    1364                 :            : 
    1365         [ #  # ]:          0 :         ImplDrawPushButton();
    1366                 :            : 
    1367 [ #  # ][ #  # ]:          0 :         if ( !( ( GetStyle() & WB_REPEAT )  &&
    1368 [ #  # ][ #  # ]:          0 :                 ! ( GetStyle() & WB_TOGGLE ) ) )
                 [ #  # ]
    1369         [ #  # ]:          0 :             Click();
    1370                 :            :     }
    1371                 :            :     else
    1372         [ #  # ]:          0 :         Button::KeyUp( rKEvt );
    1373                 :          0 : }
    1374                 :            : 
    1375                 :            : // -----------------------------------------------------------------------
    1376                 :            : 
    1377                 :          0 : void PushButton::FillLayoutData() const
    1378                 :            : {
    1379         [ #  # ]:          0 :     mpControlData->mpLayoutData = new vcl::ControlLayoutData();
    1380                 :          0 :     const_cast<PushButton*>(this)->ImplDrawPushButton( true );
    1381                 :          0 : }
    1382                 :            : 
    1383                 :            : // -----------------------------------------------------------------------
    1384                 :            : 
    1385                 :      12054 : void PushButton::Paint( const Rectangle& )
    1386                 :            : {
    1387                 :      12054 :     ImplDrawPushButton();
    1388                 :      12054 : }
    1389                 :            : 
    1390                 :            : // -----------------------------------------------------------------------
    1391                 :            : 
    1392                 :          0 : void PushButton::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
    1393                 :            :                        sal_uLong nFlags )
    1394                 :            : {
    1395         [ #  # ]:          0 :     Point       aPos  = pDev->LogicToPixel( rPos );
    1396         [ #  # ]:          0 :     Size        aSize = pDev->LogicToPixel( rSize );
    1397         [ #  # ]:          0 :     Rectangle   aRect( aPos, aSize );
    1398         [ #  # ]:          0 :     Rectangle   aTextRect;
    1399         [ #  # ]:          0 :     Font        aFont = GetDrawPixelFont( pDev );
    1400                 :            : 
    1401         [ #  # ]:          0 :     pDev->Push();
    1402         [ #  # ]:          0 :     pDev->SetMapMode();
    1403         [ #  # ]:          0 :     pDev->SetFont( aFont );
    1404         [ #  # ]:          0 :     if ( nFlags & WINDOW_DRAW_MONO )
    1405                 :            :     {
    1406         [ #  # ]:          0 :         pDev->SetTextColor( Color( COL_BLACK ) );
    1407                 :            :     }
    1408                 :            :     else
    1409                 :            :     {
    1410         [ #  # ]:          0 :         pDev->SetTextColor( GetTextColor() );
    1411                 :            : 
    1412                 :            :         // DecoView uses the FaceColor...
    1413         [ #  # ]:          0 :         AllSettings aSettings = pDev->GetSettings();
    1414         [ #  # ]:          0 :         StyleSettings aStyleSettings = aSettings.GetStyleSettings();
    1415 [ #  # ][ #  # ]:          0 :         if ( IsControlBackground() )
    1416 [ #  # ][ #  # ]:          0 :             aStyleSettings.SetFaceColor( GetControlBackground() );
    1417                 :            :         else
    1418         [ #  # ]:          0 :             aStyleSettings.SetFaceColor( GetSettings().GetStyleSettings().GetFaceColor() );
    1419         [ #  # ]:          0 :         aSettings.SetStyleSettings( aStyleSettings );
    1420 [ #  # ][ #  # ]:          0 :         pDev->OutputDevice::SetSettings( aSettings );
                 [ #  # ]
    1421                 :            :     }
    1422         [ #  # ]:          0 :     pDev->SetTextFillColor();
    1423                 :            : 
    1424                 :          0 :     DecorationView aDecoView( pDev );
    1425                 :          0 :     sal_uInt16 nButtonStyle = 0;
    1426         [ #  # ]:          0 :     if ( nFlags & WINDOW_DRAW_MONO )
    1427                 :          0 :         nButtonStyle |= BUTTON_DRAW_MONO;
    1428 [ #  # ][ #  # ]:          0 :     if ( IsChecked() )
    1429                 :          0 :         nButtonStyle |= BUTTON_DRAW_CHECKED;
    1430         [ #  # ]:          0 :     aRect = aDecoView.DrawButton( aRect, nButtonStyle );
    1431                 :            : 
    1432         [ #  # ]:          0 :     ImplDrawPushButtonContent( pDev, nFlags, aRect, false, true );
    1433 [ #  # ][ #  # ]:          0 :     pDev->Pop();
    1434                 :          0 : }
    1435                 :            : 
    1436                 :            : // -----------------------------------------------------------------------
    1437                 :            : 
    1438                 :      19039 : void PushButton::Resize()
    1439                 :            : {
    1440                 :      19039 :     Control::Resize();
    1441                 :      19039 :     Invalidate();
    1442                 :      19039 : }
    1443                 :            : 
    1444                 :            : // -----------------------------------------------------------------------
    1445                 :            : 
    1446                 :         10 : void PushButton::GetFocus()
    1447                 :            : {
    1448                 :         10 :     ShowFocus( ImplGetFocusRect() );
    1449         [ +  - ]:         10 :     SetInputContext( InputContext( GetFont() ) );
    1450                 :         10 :     Button::GetFocus();
    1451                 :         10 : }
    1452                 :            : 
    1453                 :            : // -----------------------------------------------------------------------
    1454                 :            : 
    1455                 :          8 : void PushButton::LoseFocus()
    1456                 :            : {
    1457                 :          8 :     EndSelection();
    1458                 :          8 :     HideFocus();
    1459                 :          8 :     Button::LoseFocus();
    1460                 :          8 : }
    1461                 :            : 
    1462                 :            : // -----------------------------------------------------------------------
    1463                 :            : 
    1464                 :      45586 : void PushButton::StateChanged( StateChangedType nType )
    1465                 :            : {
    1466                 :      45586 :     Button::StateChanged( nType );
    1467                 :            : 
    1468 [ +  + ][ +  - ]:      45586 :     if ( (nType == STATE_CHANGE_ENABLE) ||
         [ +  + ][ +  - ]
         [ -  + ][ +  + ]
    1469                 :            :          (nType == STATE_CHANGE_TEXT) ||
    1470                 :            :          (nType == STATE_CHANGE_IMAGE) ||
    1471                 :            :          (nType == STATE_CHANGE_DATA) ||
    1472                 :            :          (nType == STATE_CHANGE_STATE) ||
    1473                 :            :          (nType == STATE_CHANGE_UPDATEMODE) )
    1474                 :            :     {
    1475 [ +  + ][ +  - ]:      19018 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ +  + ]
    1476                 :       1441 :             Invalidate();
    1477                 :            :     }
    1478         [ +  + ]:      28009 :     else if ( nType == STATE_CHANGE_STYLE )
    1479                 :            :     {
    1480                 :       5977 :         SetStyle( ImplInitStyle( GetWindow( WINDOW_PREV ), GetStyle() ) );
    1481                 :            : 
    1482                 :       5977 :         bool bIsDefButton = ( GetStyle() & WB_DEFBUTTON ) != 0;
    1483                 :       5977 :         bool bWasDefButton = ( GetPrevStyle() & WB_DEFBUTTON ) != 0;
    1484         [ -  + ]:       5977 :         if ( bIsDefButton != bWasDefButton )
    1485                 :          0 :             ImplSetDefButton( bIsDefButton );
    1486                 :            : 
    1487 [ +  + ][ +  - ]:       5977 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ +  + ]
    1488                 :            :         {
    1489         [ -  + ]:        128 :             if ( (GetPrevStyle() & PUSHBUTTON_VIEW_STYLE) !=
    1490                 :         64 :                  (GetStyle() & PUSHBUTTON_VIEW_STYLE) )
    1491                 :          0 :                 Invalidate();
    1492                 :            :         }
    1493                 :            :     }
    1494 [ +  + ][ +  + ]:      22032 :     else if ( (nType == STATE_CHANGE_ZOOM) ||
    1495                 :            :               (nType == STATE_CHANGE_CONTROLFONT) )
    1496                 :            :     {
    1497                 :         43 :         ImplInitSettings( sal_True, sal_False, sal_False );
    1498                 :         43 :         Invalidate();
    1499                 :            :     }
    1500         [ +  + ]:      21989 :     else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
    1501                 :            :     {
    1502                 :          2 :         ImplInitSettings( sal_False, sal_True, sal_False );
    1503                 :          2 :         Invalidate();
    1504                 :            :     }
    1505         [ +  + ]:      21987 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
    1506                 :            :     {
    1507                 :          2 :         ImplInitSettings( sal_False, sal_False, sal_True );
    1508                 :          2 :         Invalidate();
    1509                 :            :     }
    1510                 :      45586 : }
    1511                 :            : 
    1512                 :            : // -----------------------------------------------------------------------
    1513                 :            : 
    1514                 :       1029 : void PushButton::DataChanged( const DataChangedEvent& rDCEvt )
    1515                 :            : {
    1516                 :       1029 :     Button::DataChanged( rDCEvt );
    1517                 :            : 
    1518 [ +  + ][ +  -  :       4116 :     if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
          +  -  +  -  +  
                      + ]
    1519                 :       1029 :          (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
    1520                 :       1029 :          ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
    1521                 :       1029 :           (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
    1522                 :            :     {
    1523                 :        769 :         ImplInitSettings( sal_True, sal_True, sal_True );
    1524                 :        769 :         Invalidate();
    1525                 :            :     }
    1526                 :       1029 : }
    1527                 :            : 
    1528                 :            : // -----------------------------------------------------------------------
    1529                 :            : 
    1530                 :         18 : long PushButton::PreNotify( NotifyEvent& rNEvt )
    1531                 :            : {
    1532                 :         18 :     long nDone = 0;
    1533                 :         18 :     const MouseEvent* pMouseEvt = NULL;
    1534                 :            : 
    1535 [ -  + ][ #  # ]:         18 :     if( (rNEvt.GetType() == EVENT_MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != NULL )
                 [ -  + ]
    1536                 :            :     {
    1537 [ #  # ][ #  # ]:          0 :         if( pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow() )
                 [ #  # ]
    1538                 :            :         {
    1539                 :            :             // trigger redraw as mouse over state has changed
    1540                 :            : 
    1541                 :            :             // TODO: move this to Window class or make it a member !!!
    1542                 :          0 :             ControlType aCtrlType = 0;
    1543      [ #  #  # ]:          0 :             switch( GetParent()->GetType() )
    1544                 :            :             {
    1545                 :            :                 case WINDOW_LISTBOX:
    1546                 :            :                 case WINDOW_MULTILISTBOX:
    1547                 :            :                 case WINDOW_TREELISTBOX:
    1548                 :          0 :                     aCtrlType = CTRL_LISTBOX;
    1549                 :          0 :                     break;
    1550                 :            : 
    1551                 :            :                 case WINDOW_COMBOBOX:
    1552                 :            :                 case WINDOW_PATTERNBOX:
    1553                 :            :                 case WINDOW_NUMERICBOX:
    1554                 :            :                 case WINDOW_METRICBOX:
    1555                 :            :                 case WINDOW_CURRENCYBOX:
    1556                 :            :                 case WINDOW_DATEBOX:
    1557                 :            :                 case WINDOW_TIMEBOX:
    1558                 :            :                 case WINDOW_LONGCURRENCYBOX:
    1559                 :          0 :                     aCtrlType = CTRL_COMBOBOX;
    1560                 :          0 :                     break;
    1561                 :            :                 default:
    1562                 :          0 :                     break;
    1563                 :            :             }
    1564                 :            : 
    1565 [ #  # ][ #  # ]:          0 :             sal_Bool bDropDown = ( IsSymbol() && (GetSymbol()==SYMBOL_SPIN_DOWN) && !GetText().Len() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1566                 :            : 
    1567         [ #  # ]:          0 :             if( bDropDown && GetParent()->IsNativeControlSupported( aCtrlType, PART_ENTIRE_CONTROL) &&
           [ #  #  #  # ]
                 [ #  # ]
    1568                 :          0 :                    !GetParent()->IsNativeControlSupported( aCtrlType, PART_BUTTON_DOWN) )
    1569                 :            :             {
    1570                 :          0 :                 Window *pBorder = GetParent()->GetWindow( WINDOW_BORDER );
    1571         [ #  # ]:          0 :                 if(aCtrlType == CTRL_COMBOBOX)
    1572                 :            :                 {
    1573                 :            :                     // only paint the button part to avoid flickering of the combobox text
    1574                 :          0 :                     Point aPt;
    1575         [ #  # ]:          0 :                     Rectangle aClipRect( aPt, GetOutputSizePixel() );
    1576 [ #  # ][ #  # ]:          0 :                     aClipRect.SetPos(pBorder->ScreenToOutputPixel(OutputToScreenPixel(aClipRect.TopLeft())));
    1577         [ #  # ]:          0 :                     pBorder->Invalidate( aClipRect );
    1578                 :            :                 }
    1579                 :            :                 else
    1580                 :            :                 {
    1581                 :          0 :                     pBorder->Invalidate( INVALIDATE_NOERASE );
    1582                 :          0 :                     pBorder->Update();
    1583                 :            :                 }
    1584                 :            :             }
    1585   [ #  #  #  # ]:          0 :             else if( (GetStyle() & WB_FLATBUTTON) ||
                 [ #  # ]
    1586                 :          0 :                      IsNativeControlSupported(CTRL_PUSHBUTTON, PART_ENTIRE_CONTROL) )
    1587                 :            :             {
    1588                 :          0 :                 Invalidate();
    1589                 :            :             }
    1590                 :            :         }
    1591                 :            :     }
    1592                 :            : 
    1593         [ +  - ]:         18 :     return nDone ? nDone : Button::PreNotify(rNEvt);
    1594                 :            : }
    1595                 :            : 
    1596                 :            : // -----------------------------------------------------------------------
    1597                 :            : 
    1598                 :          0 : void PushButton::Toggle()
    1599                 :            : {
    1600                 :          0 :     ImplCallEventListenersAndHandler( VCLEVENT_PUSHBUTTON_TOGGLE, maToggleHdl, this );
    1601                 :          0 : }
    1602                 :            : 
    1603                 :            : // -----------------------------------------------------------------------
    1604                 :            : 
    1605                 :      24779 : void PushButton::SetSymbol( SymbolType eSymbol )
    1606                 :            : {
    1607         [ +  + ]:      24779 :     if ( meSymbol != eSymbol )
    1608                 :            :     {
    1609                 :      12117 :         meSymbol = eSymbol;
    1610                 :      12117 :         StateChanged( STATE_CHANGE_DATA );
    1611                 :            :     }
    1612                 :      24779 : }
    1613                 :            : 
    1614                 :            : // -----------------------------------------------------------------------
    1615                 :          0 : void PushButton::SetSymbolAlign( SymbolAlign eAlign )
    1616                 :            : {
    1617                 :          0 :     ImplSetSymbolAlign( eAlign );
    1618                 :          0 : }
    1619                 :            : 
    1620                 :            : // -----------------------------------------------------------------------
    1621                 :            : 
    1622                 :          0 : void PushButton::SetDropDown( sal_uInt16 nStyle )
    1623                 :            : {
    1624         [ #  # ]:          0 :     if ( mnDDStyle != nStyle )
    1625                 :            :     {
    1626                 :          0 :         mnDDStyle = nStyle;
    1627                 :          0 :         StateChanged( STATE_CHANGE_DATA );
    1628                 :            :     }
    1629                 :          0 : }
    1630                 :            : 
    1631                 :            : // -----------------------------------------------------------------------
    1632                 :            : 
    1633                 :         52 : void PushButton::SetState( TriState eState )
    1634                 :            : {
    1635         [ -  + ]:         52 :     if ( meState != eState )
    1636                 :            :     {
    1637                 :          0 :         meState = eState;
    1638         [ #  # ]:          0 :         if ( meState == STATE_NOCHECK )
    1639                 :          0 :             ImplGetButtonState() &= ~(BUTTON_DRAW_CHECKED | BUTTON_DRAW_DONTKNOW);
    1640         [ #  # ]:          0 :         else if ( meState == STATE_CHECK )
    1641                 :            :         {
    1642                 :          0 :             ImplGetButtonState() &= ~BUTTON_DRAW_DONTKNOW;
    1643                 :          0 :             ImplGetButtonState() |= BUTTON_DRAW_CHECKED;
    1644                 :            :         }
    1645                 :            :         else // STATE_DONTKNOW
    1646                 :            :         {
    1647                 :          0 :             ImplGetButtonState() &= ~BUTTON_DRAW_CHECKED;
    1648                 :          0 :             ImplGetButtonState() |= BUTTON_DRAW_DONTKNOW;
    1649                 :            :         }
    1650                 :            : 
    1651                 :          0 :         StateChanged( STATE_CHANGE_STATE );
    1652                 :          0 :         Toggle();
    1653                 :            :     }
    1654                 :         52 : }
    1655                 :            : 
    1656                 :            : // -----------------------------------------------------------------------
    1657                 :            : 
    1658                 :         12 : void PushButton::SetPressed( sal_Bool bPressed )
    1659                 :            : {
    1660         [ +  - ]:         12 :     if ( mbPressed != bPressed )
    1661                 :            :     {
    1662                 :         12 :         mbPressed = bPressed;
    1663                 :         12 :         StateChanged( STATE_CHANGE_DATA );
    1664                 :            :     }
    1665                 :         12 : }
    1666                 :            : 
    1667                 :            : // -----------------------------------------------------------------------
    1668                 :            : 
    1669                 :          8 : void PushButton::EndSelection()
    1670                 :            : {
    1671                 :          8 :     EndTracking( ENDTRACK_CANCEL );
    1672         [ -  + ]:          8 :     if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
    1673                 :            :     {
    1674                 :          0 :         ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    1675         [ #  # ]:          0 :         if ( !mbPressed )
    1676                 :          0 :             ImplDrawPushButton();
    1677                 :            :     }
    1678                 :          8 : }
    1679                 :            : 
    1680                 :            : // -----------------------------------------------------------------------
    1681                 :            : 
    1682                 :         12 : Size PushButton::CalcMinimumSize( long nMaxWidth ) const
    1683                 :            : {
    1684                 :         12 :     Size aSize;
    1685                 :            : 
    1686         [ -  + ]:         12 :     if ( IsSymbol() )
    1687                 :            :     {
    1688 [ #  # ][ #  # ]:          0 :         if ( IsSmallSymbol ())
    1689                 :          0 :             aSize = Size( 16, 12 );
    1690                 :            :         else
    1691                 :          0 :             aSize = Size( 26, 24 );
    1692         [ #  # ]:          0 :         if( mnDDStyle == PUSHBUTTON_DROPDOWN_MENUBUTTON )
    1693                 :          0 :             aSize.Width() += 4;
    1694                 :            :     }
    1695 [ +  - ][ -  + ]:         12 :     else if ( IsImage() && ! (ImplGetButtonState() & BUTTON_DRAW_NOIMAGE) )
         [ #  # ][ -  + ]
    1696 [ #  # ][ #  # ]:          0 :         aSize = GetModeImage().GetSizePixel();
                 [ #  # ]
    1697 [ +  - ][ -  + ]:         12 :     if ( PushButton::GetText().Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
         [ #  # ][ +  - ]
                 [ +  - ]
           [ -  +  #  # ]
    1698                 :            :     {
    1699                 :          0 :         sal_uLong nDrawFlags = 0;
    1700                 :            :         Size textSize = GetTextRect( Rectangle( Point(), Size( nMaxWidth ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
    1701 [ #  # ][ #  # ]:          0 :                                      PushButton::GetText(), ImplGetTextStyle( nDrawFlags ) ).GetSize();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1702                 :          0 :        aSize.Width() += int( textSize.Width () * 1.15 );
    1703         [ #  # ]:          0 :        aSize.Height() = std::max( aSize.Height(), long( textSize.Height() * 1.15 ) );
    1704                 :            :     }
    1705                 :            : 
    1706                 :            :     // cf. ImplDrawPushButton ...
    1707 [ +  - ][ +  - ]:         12 :     if( (GetStyle() & WB_SMALLSTYLE) == 0 )
    1708                 :            :     {
    1709                 :         12 :         aSize.Width() += 8;
    1710                 :         12 :         aSize.Height() += 8;
    1711                 :            :     }
    1712                 :            : 
    1713         [ +  - ]:         12 :     return CalcWindowSize( aSize );
    1714                 :            : }
    1715                 :            : 
    1716                 :          0 : Size PushButton::GetOptimalSize(WindowSizeType eType) const
    1717                 :            : {
    1718         [ #  # ]:          0 :     switch (eType) {
    1719                 :            :     case WINDOWSIZE_MINIMUM: {
    1720                 :          0 :         return CalcMinimumSize();
    1721                 :            :     }
    1722                 :            :     default:
    1723                 :          0 :         return Button::GetOptimalSize( eType );
    1724                 :            :     }
    1725                 :            : }
    1726                 :            : 
    1727                 :            : // =======================================================================
    1728                 :            : 
    1729                 :          0 : void OKButton::ImplInit( Window* pParent, WinBits nStyle )
    1730                 :            : {
    1731                 :          0 :     PushButton::ImplInit( pParent, nStyle );
    1732                 :            : 
    1733         [ #  # ]:          0 :     SetText( Button::GetStandardText( BUTTON_OK ) );
    1734         [ #  # ]:          0 :     SetHelpText( Button::GetStandardHelpText( BUTTON_OK ) );
    1735                 :          0 : }
    1736                 :            : 
    1737                 :            : // -----------------------------------------------------------------------
    1738                 :            : 
    1739                 :          0 : OKButton::OKButton( Window* pParent, WinBits nStyle ) :
    1740                 :          0 :     PushButton( WINDOW_OKBUTTON )
    1741                 :            : {
    1742         [ #  # ]:          0 :     ImplInit( pParent, nStyle );
    1743                 :          0 : }
    1744                 :            : 
    1745                 :            : // -----------------------------------------------------------------------
    1746                 :            : 
    1747                 :          0 : OKButton::OKButton( Window* pParent, const ResId& rResId ) :
    1748                 :          0 :     PushButton( WINDOW_OKBUTTON )
    1749                 :            : {
    1750                 :          0 :     rResId.SetRT( RSC_OKBUTTON );
    1751         [ #  # ]:          0 :     WinBits nStyle = ImplInitRes( rResId );
    1752         [ #  # ]:          0 :     ImplInit( pParent, nStyle );
    1753         [ #  # ]:          0 :     ImplLoadRes( rResId );
    1754                 :            : 
    1755         [ #  # ]:          0 :     if ( !(nStyle & WB_HIDE) )
    1756         [ #  # ]:          0 :         Show();
    1757                 :          0 : }
    1758                 :            : 
    1759                 :            : // -----------------------------------------------------------------------
    1760                 :            : 
    1761                 :          0 : void OKButton::Click()
    1762                 :            : {
    1763                 :            :     SAL_WARN_IF(!GetClickHdl(), "vcl", "No handler installed for OKButton");
    1764                 :            :     // close parent if no link set
    1765         [ #  # ]:          0 :     if ( !GetClickHdl() )
    1766                 :            :     {
    1767                 :          0 :         Window* pParent = GetParent();
    1768         [ #  # ]:          0 :         if ( pParent->IsSystemWindow() )
    1769                 :            :         {
    1770         [ #  # ]:          0 :             if ( pParent->IsDialog() )
    1771                 :            :             {
    1772         [ #  # ]:          0 :                 if ( ((Dialog*)pParent)->IsInExecute() )
    1773                 :          0 :                     ((Dialog*)pParent)->EndDialog( sal_True );
    1774                 :            :                 // prevent recursive calls
    1775         [ #  # ]:          0 :                 else if ( !((Dialog*)pParent)->IsInClose() )
    1776                 :            :                 {
    1777         [ #  # ]:          0 :                     if ( pParent->GetStyle() & WB_CLOSEABLE )
    1778                 :          0 :                         ((Dialog*)pParent)->Close();
    1779                 :            :                 }
    1780                 :            :             }
    1781                 :            :             else
    1782                 :            :             {
    1783         [ #  # ]:          0 :                 if ( pParent->GetStyle() & WB_CLOSEABLE )
    1784                 :          0 :                     ((SystemWindow*)pParent)->Close();
    1785                 :            :             }
    1786                 :            :         }
    1787                 :            :     }
    1788                 :            :     else
    1789                 :            :     {
    1790                 :          0 :         PushButton::Click();
    1791                 :            :     }
    1792                 :          0 : }
    1793                 :            : 
    1794                 :            : // =======================================================================
    1795                 :            : 
    1796                 :          0 : void CancelButton::ImplInit( Window* pParent, WinBits nStyle )
    1797                 :            : {
    1798                 :          0 :     PushButton::ImplInit( pParent, nStyle );
    1799                 :            : 
    1800         [ #  # ]:          0 :     SetText( Button::GetStandardText( BUTTON_CANCEL ) );
    1801         [ #  # ]:          0 :     SetHelpText( Button::GetStandardHelpText( BUTTON_CANCEL ) );
    1802                 :          0 : }
    1803                 :            : 
    1804                 :            : // -----------------------------------------------------------------------
    1805                 :            : 
    1806                 :          0 : CancelButton::CancelButton( Window* pParent, WinBits nStyle ) :
    1807                 :          0 :     PushButton( WINDOW_CANCELBUTTON )
    1808                 :            : {
    1809         [ #  # ]:          0 :     ImplInit( pParent, nStyle );
    1810                 :          0 : }
    1811                 :            : 
    1812                 :            : // -----------------------------------------------------------------------
    1813                 :            : 
    1814                 :          0 : CancelButton::CancelButton( Window* pParent, const ResId& rResId ) :
    1815                 :          0 :     PushButton( WINDOW_CANCELBUTTON )
    1816                 :            : {
    1817                 :          0 :     rResId.SetRT( RSC_CANCELBUTTON );
    1818         [ #  # ]:          0 :     WinBits nStyle = ImplInitRes( rResId );
    1819         [ #  # ]:          0 :     ImplInit( pParent, nStyle );
    1820         [ #  # ]:          0 :     ImplLoadRes( rResId );
    1821                 :            : 
    1822         [ #  # ]:          0 :     if ( !(nStyle & WB_HIDE) )
    1823         [ #  # ]:          0 :         Show();
    1824                 :          0 : }
    1825                 :            : 
    1826                 :            : // -----------------------------------------------------------------------
    1827                 :            : 
    1828                 :          0 : void CancelButton::Click()
    1829                 :            : {
    1830                 :            :     SAL_WARN_IF(!GetClickHdl(), "vcl", "No handler installed for CancelButton");
    1831                 :            :     // close parent if link not set
    1832         [ #  # ]:          0 :     if ( !GetClickHdl() )
    1833                 :            :     {
    1834                 :          0 :         Window* pParent = GetParent();
    1835         [ #  # ]:          0 :         if ( pParent->IsSystemWindow() )
    1836                 :            :         {
    1837         [ #  # ]:          0 :             if ( pParent->IsDialog() )
    1838                 :            :             {
    1839         [ #  # ]:          0 :                 if ( ((Dialog*)pParent)->IsInExecute() )
    1840                 :          0 :                     ((Dialog*)pParent)->EndDialog( sal_False );
    1841                 :            :                 // prevent recursive calls
    1842         [ #  # ]:          0 :                 else if ( !((Dialog*)pParent)->IsInClose() )
    1843                 :            :                 {
    1844         [ #  # ]:          0 :                     if ( pParent->GetStyle() & WB_CLOSEABLE )
    1845                 :          0 :                         ((Dialog*)pParent)->Close();
    1846                 :            :                 }
    1847                 :            :             }
    1848                 :            :             else
    1849                 :            :             {
    1850         [ #  # ]:          0 :                 if ( pParent->GetStyle() & WB_CLOSEABLE )
    1851                 :          0 :                     ((SystemWindow*)pParent)->Close();
    1852                 :            :             }
    1853                 :            :         }
    1854                 :            :     }
    1855                 :            :     else
    1856                 :            :     {
    1857                 :          0 :         PushButton::Click();
    1858                 :            :     }
    1859                 :          0 : }
    1860                 :            : 
    1861                 :            : // =======================================================================
    1862                 :            : 
    1863                 :          0 : void HelpButton::ImplInit( Window* pParent, WinBits nStyle )
    1864                 :            : {
    1865                 :          0 :     PushButton::ImplInit( pParent, nStyle | WB_NOPOINTERFOCUS );
    1866                 :            : 
    1867         [ #  # ]:          0 :     SetText( Button::GetStandardText( BUTTON_HELP ) );
    1868         [ #  # ]:          0 :     SetHelpText( Button::GetStandardHelpText( BUTTON_HELP ) );
    1869                 :          0 : }
    1870                 :            : 
    1871                 :            : // -----------------------------------------------------------------------
    1872                 :            : 
    1873                 :          0 : HelpButton::HelpButton( Window* pParent, WinBits nStyle ) :
    1874                 :          0 :     PushButton( WINDOW_HELPBUTTON )
    1875                 :            : {
    1876         [ #  # ]:          0 :     ImplInit( pParent, nStyle );
    1877                 :          0 : }
    1878                 :            : 
    1879                 :            : // -----------------------------------------------------------------------
    1880                 :            : 
    1881                 :          0 : HelpButton::HelpButton( Window* pParent, const ResId& rResId ) :
    1882                 :          0 :     PushButton( WINDOW_HELPBUTTON )
    1883                 :            : {
    1884                 :          0 :     rResId.SetRT( RSC_HELPBUTTON );
    1885         [ #  # ]:          0 :     WinBits nStyle = ImplInitRes( rResId );
    1886         [ #  # ]:          0 :     ImplInit( pParent, nStyle );
    1887         [ #  # ]:          0 :     ImplLoadRes( rResId );
    1888                 :            : 
    1889         [ #  # ]:          0 :     if ( !(nStyle & WB_HIDE) )
    1890         [ #  # ]:          0 :         Show();
    1891                 :          0 : }
    1892                 :            : 
    1893                 :            : // -----------------------------------------------------------------------
    1894                 :            : 
    1895                 :          0 : void HelpButton::Click()
    1896                 :            : {
    1897                 :            :     SAL_WARN_IF(!GetClickHdl(), "vcl", "No handler installed for HelpButton");
    1898                 :            :     // trigger help if no link set
    1899         [ #  # ]:          0 :     if ( !GetClickHdl() )
    1900                 :            :     {
    1901         [ #  # ]:          0 :         Window* pFocusWin = Application::GetFocusWindow();
    1902         [ #  # ]:          0 :         if ( !pFocusWin )
    1903                 :          0 :             pFocusWin = this;
    1904                 :            : 
    1905 [ #  # ][ #  # ]:          0 :         HelpEvent aEvt( pFocusWin->GetPointerPosPixel(), HELPMODE_CONTEXT );
    1906         [ #  # ]:          0 :         pFocusWin->RequestHelp( aEvt );
    1907                 :            :     }
    1908                 :          0 :     PushButton::Click();
    1909                 :          0 : }
    1910                 :            : 
    1911                 :            : // =======================================================================
    1912                 :            : 
    1913                 :         34 : void RadioButton::ImplInitRadioButtonData()
    1914                 :            : {
    1915                 :         34 :     mbChecked       = sal_False;
    1916                 :         34 :     mbSaveValue     = sal_False;
    1917                 :         34 :     mbRadioCheck    = sal_True;
    1918                 :         34 :     mbStateChanged  = sal_False;
    1919                 :         34 : }
    1920                 :            : 
    1921                 :            : // -----------------------------------------------------------------------
    1922                 :            : 
    1923                 :         34 : void RadioButton::ImplInit( Window* pParent, WinBits nStyle )
    1924                 :            : {
    1925                 :         34 :     nStyle = ImplInitStyle( pParent->GetWindow( WINDOW_LASTCHILD ), nStyle );
    1926                 :         34 :     Button::ImplInit( pParent, nStyle, NULL );
    1927                 :            : 
    1928                 :         34 :     ImplInitSettings( sal_True, sal_True, sal_True );
    1929                 :         34 : }
    1930                 :            : 
    1931                 :            : // -----------------------------------------------------------------------
    1932                 :            : 
    1933                 :         44 : WinBits RadioButton::ImplInitStyle( const Window* pPrevWindow, WinBits nStyle )
    1934                 :            : {
    1935         [ +  - ]:         74 :     if ( !(nStyle & WB_NOGROUP) &&
           [ +  +  +  - ]
                 [ +  - ]
    1936                 :         30 :          (!pPrevWindow || (pPrevWindow->GetType() != WINDOW_RADIOBUTTON)) )
    1937                 :         44 :         nStyle |= WB_GROUP;
    1938         [ +  - ]:         44 :     if ( !(nStyle & WB_NOTABSTOP) )
    1939                 :            :     {
    1940         [ -  + ]:         44 :         if ( IsChecked() )
    1941                 :          0 :             nStyle |= WB_TABSTOP;
    1942                 :            :         else
    1943                 :         44 :             nStyle &= ~WB_TABSTOP;
    1944                 :            :     }
    1945                 :         44 :     return nStyle;
    1946                 :            : }
    1947                 :            : 
    1948                 :            : // -----------------------------------------------------------------
    1949                 :            : 
    1950                 :        700 : const Font& RadioButton::GetCanonicalFont( const StyleSettings& _rStyle ) const
    1951                 :            : {
    1952                 :        700 :     return _rStyle.GetRadioCheckFont();
    1953                 :            : }
    1954                 :            : 
    1955                 :            : // -----------------------------------------------------------------
    1956                 :        505 : const Color& RadioButton::GetCanonicalTextColor( const StyleSettings& _rStyle ) const
    1957                 :            : {
    1958                 :        505 :     return _rStyle.GetRadioCheckTextColor();
    1959                 :            : }
    1960                 :            : 
    1961                 :            : // -----------------------------------------------------------------------
    1962                 :            : 
    1963                 :        505 : void RadioButton::ImplInitSettings( sal_Bool bFont,
    1964                 :            :                                     sal_Bool bForeground, sal_Bool bBackground )
    1965                 :            : {
    1966                 :        505 :     Button::ImplInitSettings( bFont, bForeground );
    1967                 :            : 
    1968         [ +  + ]:        505 :     if ( bBackground )
    1969                 :            :     {
    1970                 :        360 :         Window* pParent = GetParent();
    1971 [ +  - ][ +  -  :        720 :         if ( !IsControlBackground() &&
             -  +  #  # ]
    1972                 :        360 :             (pParent->IsChildTransparentModeEnabled() || IsNativeControlSupported( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL ) ) )
    1973                 :            :         {
    1974                 :        360 :             EnableChildTransparentMode( sal_True );
    1975                 :        360 :             SetParentClipMode( PARENTCLIPMODE_NOCLIP );
    1976                 :        360 :             SetPaintTransparent( sal_True );
    1977                 :        360 :             SetBackground();
    1978         [ -  + ]:        360 :             if( IsNativeControlSupported( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL ) )
    1979                 :          0 :                 mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects;
    1980                 :            :         }
    1981                 :            :         else
    1982                 :            :         {
    1983                 :          0 :             EnableChildTransparentMode( sal_False );
    1984                 :          0 :             SetParentClipMode( 0 );
    1985                 :          0 :             SetPaintTransparent( sal_False );
    1986                 :            : 
    1987         [ #  # ]:          0 :             if ( IsControlBackground() )
    1988 [ #  # ][ #  # ]:          0 :                 SetBackground( GetControlBackground() );
                 [ #  # ]
    1989                 :            :             else
    1990                 :          0 :                 SetBackground( pParent->GetBackground() );
    1991                 :            :         }
    1992                 :            :     }
    1993                 :        505 : }
    1994                 :            : 
    1995                 :          0 : void RadioButton::DrawRadioButtonState( )
    1996                 :            : {
    1997                 :          0 :     ImplDrawRadioButtonState( );
    1998                 :          0 : }
    1999                 :            : 
    2000                 :            : // -----------------------------------------------------------------------
    2001                 :            : 
    2002                 :          0 : void RadioButton::ImplInvalidateOrDrawRadioButtonState()
    2003                 :            : {
    2004         [ #  # ]:          0 :     if( ImplGetSVData()->maNWFData.mbCheckBoxNeedsErase )
    2005                 :            :     {
    2006         [ #  # ]:          0 :         if ( IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL) )
    2007                 :            :         {
    2008                 :          0 :             Invalidate();
    2009                 :          0 :             Update();
    2010                 :          0 :             return;
    2011                 :            :         }
    2012                 :            :     }
    2013                 :          0 :     ImplDrawRadioButtonState();
    2014                 :            : }
    2015                 :            : 
    2016                 :        252 : void RadioButton::ImplDrawRadioButtonState()
    2017                 :            : {
    2018                 :        252 :     sal_Bool   bNativeOK = sal_False;
    2019                 :            : 
    2020                 :            :     // no native drawing for image radio buttons
    2021 [ +  - ][ -  + ]:        252 :     if ( !maImage && (bNativeOK=IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL)) == sal_True )
                 [ -  + ]
    2022                 :            :     {
    2023         [ #  # ]:          0 :         ImplControlValue            aControlValue( mbChecked ? BUTTONVALUE_ON : BUTTONVALUE_OFF );
    2024 [ #  # ][ #  # ]:          0 :         Rectangle                   aCtrlRect( maStateRect.TopLeft(), maStateRect.GetSize() );
    2025                 :          0 :         ControlState                nState = 0;
    2026                 :            : 
    2027         [ #  # ]:          0 :         if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )   nState |= CTRL_STATE_PRESSED;
    2028 [ #  # ][ #  # ]:          0 :         if ( HasFocus() )                       nState |= CTRL_STATE_FOCUSED;
    2029         [ #  # ]:          0 :         if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT )   nState |= CTRL_STATE_DEFAULT;
    2030 [ #  # ][ #  # ]:          0 :         if ( IsEnabled() )                      nState |= CTRL_STATE_ENABLED;
    2031                 :            : 
    2032 [ #  # ][ #  # ]:          0 :         if ( IsMouseOver() && maMouseRect.IsInside( GetPointerPosPixel() ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    2033                 :          0 :             nState |= CTRL_STATE_ROLLOVER;
    2034                 :            : 
    2035                 :            :         bNativeOK = DrawNativeControl( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRect, nState,
    2036 [ #  # ][ #  # ]:          0 :                     aControlValue,rtl::OUString() );
    2037                 :            : 
    2038                 :            :     }
    2039                 :            : 
    2040         [ +  - ]:        252 : if ( bNativeOK == sal_False )
    2041                 :            : {
    2042                 :            :     // kein Image-RadioButton
    2043         [ +  - ]:        252 :     if ( !maImage )
    2044                 :            :     {
    2045                 :        252 :         sal_uInt16 nStyle = ImplGetButtonState();
    2046 [ +  + ][ +  - ]:        252 :         if ( !IsEnabled() )
    2047                 :         61 :             nStyle |= BUTTON_DRAW_DISABLED;
    2048         [ +  + ]:        252 :         if ( mbChecked )
    2049                 :        203 :             nStyle |= BUTTON_DRAW_CHECKED;
    2050         [ +  - ]:        252 :         Image aImage = GetRadioImage( GetSettings(), nStyle );
    2051 [ +  - ][ -  + ]:        252 :         if ( IsZoom() )
    2052 [ #  # ][ #  # ]:          0 :             DrawImage( maStateRect.TopLeft(), maStateRect.GetSize(), aImage );
    2053                 :            :         else
    2054 [ +  - ][ +  - ]:        252 :             DrawImage( maStateRect.TopLeft(), aImage );
    2055                 :            :     }
    2056                 :            :     else
    2057                 :            :     {
    2058         [ #  # ]:          0 :         HideFocus();
    2059                 :            : 
    2060                 :          0 :         DecorationView          aDecoView( this );
    2061                 :          0 :         const StyleSettings&    rStyleSettings = GetSettings().GetStyleSettings();
    2062                 :          0 :         Rectangle               aImageRect  = maStateRect;
    2063         [ #  # ]:          0 :         Size                    aImageSize  = maImage.GetSizePixel();
    2064         [ #  # ]:          0 :         sal_Bool                    bEnabled    = IsEnabled();
    2065                 :          0 :         sal_uInt16 nButtonStyle = FRAME_DRAW_DOUBLEIN;
    2066                 :            : 
    2067         [ #  # ]:          0 :         aImageSize.Width()  = CalcZoom( aImageSize.Width() );
    2068         [ #  # ]:          0 :         aImageSize.Height() = CalcZoom( aImageSize.Height() );
    2069                 :            : 
    2070                 :            :         // display border and selection status
    2071         [ #  # ]:          0 :         aImageRect = aDecoView.DrawFrame( aImageRect, nButtonStyle );
    2072 [ #  # ][ #  # ]:          0 :         if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) || !bEnabled )
                 [ #  # ]
    2073         [ #  # ]:          0 :             SetFillColor( rStyleSettings.GetFaceColor() );
    2074                 :            :         else
    2075         [ #  # ]:          0 :             SetFillColor( rStyleSettings.GetFieldColor() );
    2076         [ #  # ]:          0 :         SetLineColor();
    2077         [ #  # ]:          0 :         DrawRect( aImageRect );
    2078                 :            : 
    2079                 :            :         // display image
    2080                 :          0 :         nButtonStyle = 0;
    2081         [ #  # ]:          0 :         if ( !bEnabled )
    2082                 :          0 :             nButtonStyle |= IMAGE_DRAW_DISABLE;
    2083                 :            : 
    2084                 :          0 :         Image *pImage = &maImage;
    2085                 :            : 
    2086                 :          0 :         Point aImagePos( aImageRect.TopLeft() );
    2087         [ #  # ]:          0 :         aImagePos.X() += (aImageRect.GetWidth()-aImageSize.Width())/2;
    2088         [ #  # ]:          0 :         aImagePos.Y() += (aImageRect.GetHeight()-aImageSize.Height())/2;
    2089 [ #  # ][ #  # ]:          0 :         if ( IsZoom() )
    2090         [ #  # ]:          0 :             DrawImage( aImagePos, aImageSize, *pImage, nButtonStyle );
    2091                 :            :         else
    2092         [ #  # ]:          0 :             DrawImage( aImagePos, *pImage, nButtonStyle );
    2093                 :            : 
    2094                 :          0 :         aImageRect.Left()++;
    2095                 :          0 :         aImageRect.Top()++;
    2096                 :          0 :         aImageRect.Right()--;
    2097                 :          0 :         aImageRect.Bottom()--;
    2098                 :            : 
    2099         [ #  # ]:          0 :         ImplSetFocusRect( aImageRect );
    2100                 :            : 
    2101         [ #  # ]:          0 :         if ( mbChecked )
    2102                 :            :         {
    2103         [ #  # ]:          0 :             SetLineColor( rStyleSettings.GetHighlightColor() );
    2104         [ #  # ]:          0 :             SetFillColor();
    2105 [ #  # ][ #  # ]:          0 :             if ( (aImageSize.Width() >= 20) || (aImageSize.Height() >= 20) )
                 [ #  # ]
    2106                 :            :             {
    2107                 :          0 :                 aImageRect.Left()++;
    2108                 :          0 :                 aImageRect.Top()++;
    2109                 :          0 :                 aImageRect.Right()--;
    2110                 :          0 :                 aImageRect.Bottom()--;
    2111                 :            :             }
    2112         [ #  # ]:          0 :             DrawRect( aImageRect );
    2113                 :          0 :             aImageRect.Left()++;
    2114                 :          0 :             aImageRect.Top()++;
    2115                 :          0 :             aImageRect.Right()--;
    2116                 :          0 :             aImageRect.Bottom()--;
    2117         [ #  # ]:          0 :             DrawRect( aImageRect );
    2118                 :            :         }
    2119                 :            : 
    2120 [ #  # ][ #  # ]:          0 :         if ( HasFocus() )
    2121         [ #  # ]:          0 :             ShowFocus( ImplGetFocusRect() );
    2122                 :            :     }
    2123                 :            : }
    2124                 :        252 : }
    2125                 :            : 
    2126                 :            : // -----------------------------------------------------------------------
    2127                 :            : 
    2128                 :        252 : void RadioButton::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
    2129                 :            :                             const Point& rPos, const Size& rSize,
    2130                 :            :                             const Size& rImageSize, Rectangle& rStateRect,
    2131                 :            :                             Rectangle& rMouseRect, bool bLayout )
    2132                 :            : {
    2133         [ +  - ]:        252 :     WinBits                 nWinStyle = GetStyle();
    2134         [ +  - ]:        252 :     XubString               aText( GetText() );
    2135         [ +  - ]:        252 :     Rectangle               aRect( rPos, rSize );
    2136         [ -  + ]:        252 :     MetricVector*           pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
    2137         [ -  + ]:        252 :     String*                 pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL;
    2138                 :            : 
    2139         [ +  - ]:        252 :     pDev->Push( PUSH_CLIPREGION );
    2140 [ +  - ][ +  - ]:        252 :     pDev->IntersectClipRegion( Rectangle( rPos, rSize ) );
    2141                 :            : 
    2142                 :            :     // no image radio button
    2143         [ +  - ]:        252 :     if ( !maImage )
    2144                 :            :     {
    2145 [ +  + ][ -  + ]:        309 :         if ( ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) ) ||
           [ -  +  #  # ]
                 [ +  + ]
    2146         [ +  - ]:         57 :              ( HasImage() &&  ! (ImplGetButtonState() & BUTTON_DRAW_NOIMAGE) ) )
    2147                 :            :         {
    2148         [ +  - ]:        195 :             sal_uInt16 nTextStyle = Button::ImplGetTextStyle( aText, nWinStyle, nDrawFlags );
    2149                 :            : 
    2150 [ +  - ][ +  - ]:        195 :             const long nImageSep = GetDrawPixel( pDev, ImplGetImageToTextDistance() );
    2151                 :        195 :             Size aSize( rSize );
    2152                 :        195 :             Point aPos( rPos );
    2153                 :        195 :             aPos.X() += rImageSize.Width() + nImageSep;
    2154                 :        195 :             aSize.Width() -= rImageSize.Width() + nImageSep;
    2155                 :            : 
    2156                 :            :             // if the text rect height is smaller than the height of the image
    2157                 :            :             // then for single lines the default should be centered text
    2158 [ +  + ][ +  + ]:        390 :             if( (nWinStyle & (WB_TOP|WB_VCENTER|WB_BOTTOM)) == 0 &&
           [ +  -  +  - ]
    2159                 :        195 :                 (rImageSize.Height() > rSize.Height() || ! (nWinStyle & WB_WORDBREAK)  ) )
    2160                 :            :             {
    2161                 :         74 :                 nTextStyle &= ~(TEXT_DRAW_TOP|TEXT_DRAW_BOTTOM);
    2162                 :         74 :                 nTextStyle |= TEXT_DRAW_VCENTER;
    2163                 :         74 :                 aSize.Height() = rImageSize.Height();
    2164                 :            :             }
    2165                 :            : 
    2166                 :            :             ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, 1,
    2167         [ +  - ]:        195 :                                   nDrawFlags, nTextStyle, NULL );
    2168                 :            : 
    2169         [ +  - ]:        195 :             rMouseRect          = Rectangle( aPos, aSize );
    2170                 :        195 :             rMouseRect.Left()   = rPos.X();
    2171                 :            : 
    2172                 :        195 :             rStateRect.Left()   = rPos.X();
    2173                 :        195 :             rStateRect.Top()    = rMouseRect.Top();
    2174                 :            : 
    2175         [ +  + ]:        195 :             if ( aSize.Height() > rImageSize.Height() )
    2176                 :        170 :                 rStateRect.Top() += ( aSize.Height() - rImageSize.Height() ) / 2;
    2177                 :            :             else
    2178                 :            :             {
    2179                 :         25 :                 rStateRect.Top() -= ( rImageSize.Height() - aSize.Height() ) / 2;
    2180         [ +  + ]:         25 :                 if( rStateRect.Top() < 0 )
    2181                 :          1 :                     rStateRect.Top() = 0;
    2182                 :            :             }
    2183                 :            : 
    2184                 :        195 :             rStateRect.Right()  = rStateRect.Left() + rImageSize.Width()-1;
    2185                 :        195 :             rStateRect.Bottom() = rStateRect.Top() + rImageSize.Height()-1;
    2186                 :            : 
    2187         [ +  + ]:        195 :             if ( rStateRect.Bottom() > rMouseRect.Bottom() )
    2188                 :        195 :                 rMouseRect.Bottom() = rStateRect.Bottom();
    2189                 :            :         }
    2190                 :            :         else
    2191                 :            :         {
    2192 [ -  + ][ #  # ]:         57 :             if ( mbLegacyNoTextAlign && ( nWinStyle & WB_CENTER ) )
    2193                 :          0 :                 rStateRect.Left() = rPos.X()+((rSize.Width()-rImageSize.Width())/2);
    2194 [ -  + ][ #  # ]:         57 :             else if ( mbLegacyNoTextAlign && ( nWinStyle & WB_RIGHT ) )
    2195                 :          0 :                 rStateRect.Left() = rPos.X()+rSize.Width()-rImageSize.Width(); //-1;
    2196                 :            :             else
    2197                 :         57 :                 rStateRect.Left() = rPos.X(); //+1;
    2198         [ -  + ]:         57 :             if ( nWinStyle & WB_VCENTER )
    2199                 :          0 :                 rStateRect.Top() = rPos.Y()+((rSize.Height()-rImageSize.Height())/2);
    2200         [ -  + ]:         57 :             else if ( nWinStyle & WB_BOTTOM )
    2201                 :          0 :                 rStateRect.Top() = rPos.Y()+rSize.Height()-rImageSize.Height(); //-1;
    2202                 :            :             else
    2203                 :         57 :                 rStateRect.Top() = rPos.Y(); //+1;
    2204                 :         57 :             rStateRect.Right()  = rStateRect.Left()+rImageSize.Width()-1;
    2205                 :         57 :             rStateRect.Bottom() = rStateRect.Top()+rImageSize.Height()-1;
    2206                 :         57 :             rMouseRect          = rStateRect;
    2207                 :            : 
    2208         [ +  - ]:         57 :             ImplSetFocusRect( rStateRect );
    2209                 :            : 
    2210                 :            : /*  and above -1 because CalcSize() does not include focus-rectangle since images would be even
    2211                 :            :     positioned higher in writer
    2212                 :            :             rFocusRect          = rStateRect;
    2213                 :            :             rFocusRect.Left()--;
    2214                 :            :             rFocusRect.Top()--;
    2215                 :            :             rFocusRect.Right()++;
    2216                 :            :             rFocusRect.Bottom()++;
    2217                 :            : */
    2218                 :            :         }
    2219                 :            :     }
    2220                 :            :     else
    2221                 :            :     {
    2222                 :          0 :         sal_Bool        bTopImage   = (nWinStyle & WB_TOP) != 0;
    2223         [ #  # ]:          0 :         Size        aImageSize  = maImage.GetSizePixel();
    2224         [ #  # ]:          0 :         Rectangle   aImageRect( rPos, rSize );
    2225         [ #  # ]:          0 :         long        nTextHeight = pDev->GetTextHeight();
    2226         [ #  # ]:          0 :         long        nTextWidth  = pDev->GetCtrlTextWidth( aText );
    2227                 :            : 
    2228                 :            :         // calculate position and sizes
    2229 [ #  # ][ #  # ]:          0 :         if ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
                 [ #  # ]
    2230                 :            :         {
    2231                 :          0 :             Size aTmpSize( (aImageSize.Width()+8), (aImageSize.Height()+8) );
    2232         [ #  # ]:          0 :             if ( bTopImage )
    2233                 :            :             {
    2234                 :          0 :                 aImageRect.Left() = (rSize.Width()-aTmpSize.Width())/2;
    2235                 :          0 :                 aImageRect.Top()  = (rSize.Height()-(aTmpSize.Height()+nTextHeight+6))/2;
    2236                 :            :             }
    2237                 :            :             else
    2238                 :          0 :                 aImageRect.Top()  = (rSize.Height()-aTmpSize.Height())/2;
    2239                 :            : 
    2240                 :          0 :             aImageRect.Right()  = aImageRect.Left()+aTmpSize.Width();
    2241                 :          0 :             aImageRect.Bottom() = aImageRect.Top()+aTmpSize.Height();
    2242                 :            : 
    2243                 :            :             // display text
    2244                 :          0 :             Point aTxtPos = rPos;
    2245         [ #  # ]:          0 :             if ( bTopImage )
    2246                 :            :             {
    2247                 :          0 :                 aTxtPos.X() += (rSize.Width()-nTextWidth)/2;
    2248                 :          0 :                 aTxtPos.Y() += aImageRect.Bottom()+6;
    2249                 :            :             }
    2250                 :            :             else
    2251                 :            :             {
    2252                 :          0 :                 aTxtPos.X() += aImageRect.Right()+8;
    2253                 :          0 :                 aTxtPos.Y() += (rSize.Height()-nTextHeight)/2;
    2254                 :            :             }
    2255         [ #  # ]:          0 :             pDev->DrawCtrlText( aTxtPos, aText, 0, STRING_LEN, TEXT_DRAW_MNEMONIC, pVector, pDisplayText );
    2256                 :            :         }
    2257                 :            : 
    2258                 :          0 :         rMouseRect = aImageRect;
    2259                 :          0 :         rStateRect = aImageRect;
    2260                 :            :     }
    2261                 :            : 
    2262 [ +  - ][ +  - ]:        252 :     pDev->Pop();
    2263                 :        252 : }
    2264                 :            : 
    2265                 :            : // -----------------------------------------------------------------------
    2266                 :            : 
    2267                 :        252 : void RadioButton::ImplDrawRadioButton( bool bLayout )
    2268                 :            : {
    2269         [ +  - ]:        252 :     if( !bLayout )
    2270         [ +  - ]:        252 :         HideFocus();
    2271                 :            : 
    2272                 :        252 :     Size aImageSize;
    2273         [ +  - ]:        252 :     if ( !maImage )
    2274         [ +  - ]:        252 :         aImageSize = ImplGetRadioImageSize();
    2275                 :            :     else
    2276         [ #  # ]:          0 :         aImageSize  = maImage.GetSizePixel();
    2277         [ +  - ]:        252 :     aImageSize.Width()  = CalcZoom( aImageSize.Width() );
    2278         [ +  - ]:        252 :     aImageSize.Height() = CalcZoom( aImageSize.Height() );
    2279                 :            : 
    2280                 :            :     // Draw control text
    2281                 :        252 :     ImplDraw( this, 0, Point(), GetOutputSizePixel(),
    2282         [ +  - ]:        252 :               aImageSize, maStateRect, maMouseRect, bLayout );
    2283                 :            : 
    2284 [ -  + ][ #  # ]:        252 :     if( !bLayout || (IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL)==sal_True) )
         [ #  # ][ +  - ]
    2285                 :            :     {
    2286 [ +  - ][ +  - ]:        252 :         if ( !maImage && HasFocus() )
         [ -  + ][ -  + ]
    2287         [ #  # ]:          0 :             ShowFocus( ImplGetFocusRect() );
    2288                 :            : 
    2289         [ +  - ]:        252 :         ImplDrawRadioButtonState();
    2290                 :            :     }
    2291                 :        252 : }
    2292                 :            : 
    2293                 :            : // -----------------------------------------------------------------------
    2294                 :            : 
    2295                 :          0 : void RadioButton::GetRadioButtonGroup( std::vector< RadioButton* >& io_rGroup, bool bIncludeThis ) const
    2296                 :            : {
    2297                 :            :     // empty the list
    2298                 :          0 :     io_rGroup.clear();
    2299                 :            : 
    2300                 :            :     // go back to first in group;
    2301                 :          0 :     Window* pFirst = const_cast<RadioButton*>(this);
    2302         [ #  # ]:          0 :     while( ( pFirst->GetStyle() & WB_GROUP ) == 0 )
    2303                 :            :     {
    2304                 :          0 :         Window* pWindow = pFirst->GetWindow( WINDOW_PREV );
    2305         [ #  # ]:          0 :         if( pWindow )
    2306                 :          0 :             pFirst = pWindow;
    2307                 :            :         else
    2308                 :          0 :             break;
    2309                 :            :     }
    2310                 :            :     // insert radiobuttons up to next group
    2311         [ #  # ]:          0 :     do
           [ #  #  #  # ]
    2312                 :            :     {
    2313         [ #  # ]:          0 :         if( pFirst->GetType() == WINDOW_RADIOBUTTON )
    2314                 :            :         {
    2315 [ #  # ][ #  # ]:          0 :             if( pFirst != this || bIncludeThis )
    2316         [ #  # ]:          0 :                 io_rGroup.push_back( static_cast<RadioButton*>(pFirst) );
    2317                 :            :         }
    2318                 :          0 :         pFirst = pFirst->GetWindow( WINDOW_NEXT );
    2319                 :          0 :     } while( pFirst && ( ( pFirst->GetStyle() & WB_GROUP ) == 0 ) );
    2320                 :          0 : }
    2321                 :            : 
    2322                 :            : // -----------------------------------------------------------------------
    2323                 :            : 
    2324                 :          6 : void RadioButton::ImplUncheckAllOther()
    2325                 :            : {
    2326                 :          6 :     mpWindowImpl->mnStyle |= WB_TABSTOP;
    2327                 :            : 
    2328                 :            :     // iterate over radio button group and checked buttons
    2329                 :            :     Window* pWindow;
    2330                 :            :     WinBits nStyle;
    2331         [ -  + ]:          6 :     if ( !(GetStyle() & WB_GROUP) )
    2332                 :            :     {
    2333                 :          0 :         pWindow = GetWindow( WINDOW_PREV );
    2334         [ #  # ]:          0 :         while ( pWindow )
    2335                 :            :         {
    2336                 :          0 :             nStyle = pWindow->GetStyle();
    2337                 :            : 
    2338         [ #  # ]:          0 :             if ( pWindow->GetType() == WINDOW_RADIOBUTTON )
    2339                 :            :             {
    2340         [ #  # ]:          0 :                 if ( ((RadioButton*)pWindow)->IsChecked() )
    2341                 :            :                 {
    2342         [ #  # ]:          0 :                     ImplDelData aDelData;
    2343         [ #  # ]:          0 :                     pWindow->ImplAddDel( &aDelData );
    2344         [ #  # ]:          0 :                     ((RadioButton*)pWindow)->SetState( sal_False );
    2345         [ #  # ]:          0 :                     if ( aDelData.IsDead() )
    2346                 :            :                         return;
    2347 [ #  # ][ #  # ]:          0 :                     pWindow->ImplRemoveDel( &aDelData );
                 [ #  # ]
    2348                 :            :                 }
    2349                 :            :                 // not inside if clause to always remove wrongly set WB_TABSTOPS
    2350                 :          0 :                 pWindow->mpWindowImpl->mnStyle &= ~WB_TABSTOP;
    2351                 :            :             }
    2352                 :            : 
    2353         [ #  # ]:          0 :             if ( nStyle & WB_GROUP )
    2354                 :          0 :                 break;
    2355                 :            : 
    2356                 :          0 :             pWindow = pWindow->GetWindow( WINDOW_PREV );
    2357                 :            :         }
    2358                 :            :     }
    2359                 :            : 
    2360                 :          6 :     pWindow = GetWindow( WINDOW_NEXT );
    2361         [ +  + ]:         12 :     while ( pWindow )
    2362                 :            :     {
    2363                 :          6 :         nStyle = pWindow->GetStyle();
    2364                 :            : 
    2365         [ +  + ]:          6 :         if ( nStyle & WB_GROUP )
    2366                 :          2 :             break;
    2367                 :            : 
    2368         [ -  + ]:          4 :         if ( pWindow->GetType() == WINDOW_RADIOBUTTON )
    2369                 :            :         {
    2370         [ #  # ]:          0 :             if ( ((RadioButton*)pWindow)->IsChecked() )
    2371                 :            :             {
    2372         [ #  # ]:          0 :                 ImplDelData aDelData;
    2373         [ #  # ]:          0 :                 pWindow->ImplAddDel( &aDelData );
    2374         [ #  # ]:          0 :                 ((RadioButton*)pWindow)->SetState( sal_False );
    2375         [ #  # ]:          0 :                 if ( aDelData.IsDead() )
    2376                 :            :                     return;
    2377 [ #  # ][ #  # ]:          0 :                 pWindow->ImplRemoveDel( &aDelData );
                 [ #  # ]
    2378                 :            :             }
    2379                 :            : 
    2380                 :            :             // not inside if clause to always remove wrongly set WB_TABSTOPS
    2381                 :          0 :             pWindow->mpWindowImpl->mnStyle &= ~WB_TABSTOP;
    2382                 :            :         }
    2383                 :            : 
    2384                 :          4 :         pWindow = pWindow->GetWindow( WINDOW_NEXT );
    2385                 :            :     }
    2386                 :            : }
    2387                 :            : 
    2388                 :            : // -----------------------------------------------------------------------
    2389                 :            : 
    2390                 :          0 : void RadioButton::ImplCallClick( sal_Bool bGrabFocus, sal_uInt16 nFocusFlags )
    2391                 :            : {
    2392                 :          0 :     mbStateChanged = !mbChecked;
    2393                 :          0 :     mbChecked = sal_True;
    2394                 :          0 :     mpWindowImpl->mnStyle |= WB_TABSTOP;
    2395         [ #  # ]:          0 :     ImplInvalidateOrDrawRadioButtonState();
    2396         [ #  # ]:          0 :     ImplDelData aDelData;
    2397         [ #  # ]:          0 :     ImplAddDel( &aDelData );
    2398         [ #  # ]:          0 :     if ( mbRadioCheck )
    2399         [ #  # ]:          0 :         ImplUncheckAllOther();
    2400         [ #  # ]:          0 :     if ( aDelData.IsDead() )
    2401                 :            :         return;
    2402         [ #  # ]:          0 :     if ( bGrabFocus )
    2403         [ #  # ]:          0 :         ImplGrabFocus( nFocusFlags );
    2404         [ #  # ]:          0 :     if ( aDelData.IsDead() )
    2405                 :            :         return;
    2406         [ #  # ]:          0 :     if ( mbStateChanged )
    2407         [ #  # ]:          0 :         Toggle();
    2408         [ #  # ]:          0 :     if ( aDelData.IsDead() )
    2409                 :            :         return;
    2410         [ #  # ]:          0 :     Click();
    2411         [ #  # ]:          0 :     if ( aDelData.IsDead() )
    2412                 :            :         return;
    2413         [ #  # ]:          0 :     ImplRemoveDel( &aDelData );
    2414 [ #  # ][ #  # ]:          0 :     mbStateChanged = sal_False;
    2415                 :            : }
    2416                 :            : 
    2417                 :            : // -----------------------------------------------------------------------
    2418                 :            : 
    2419                 :         34 : RadioButton::RadioButton( Window* pParent, WinBits nStyle ) :
    2420 [ +  - ][ +  - ]:         34 :     Button( WINDOW_RADIOBUTTON ), mbLegacyNoTextAlign( false )
         [ +  - ][ +  - ]
    2421                 :            : {
    2422                 :         34 :     ImplInitRadioButtonData();
    2423         [ +  - ]:         34 :     ImplInit( pParent, nStyle );
    2424                 :         34 : }
    2425                 :            : 
    2426                 :            : // -----------------------------------------------------------------------
    2427                 :            : 
    2428                 :          0 : RadioButton::RadioButton( Window* pParent, const ResId& rResId ) :
    2429 [ #  # ][ #  # ]:          0 :     Button( WINDOW_RADIOBUTTON ), mbLegacyNoTextAlign( false )
         [ #  # ][ #  # ]
    2430                 :            : {
    2431                 :          0 :     ImplInitRadioButtonData();
    2432                 :          0 :     rResId.SetRT( RSC_RADIOBUTTON );
    2433         [ #  # ]:          0 :     WinBits nStyle = ImplInitRes( rResId );
    2434         [ #  # ]:          0 :     ImplInit( pParent, nStyle );
    2435         [ #  # ]:          0 :     ImplLoadRes( rResId );
    2436                 :            : 
    2437         [ #  # ]:          0 :     if ( !(nStyle & WB_HIDE) )
    2438         [ #  # ]:          0 :         Show();
    2439                 :          0 : }
    2440                 :            : 
    2441                 :            : // -----------------------------------------------------------------------
    2442                 :            : 
    2443                 :          0 : void RadioButton::ImplLoadRes( const ResId& rResId )
    2444                 :            : {
    2445                 :          0 :     Button::ImplLoadRes( rResId );
    2446                 :            : 
    2447                 :            :     //anderer Wert als Default ?
    2448                 :          0 :     sal_uInt16 nChecked = ReadShortRes();
    2449         [ #  # ]:          0 :     if ( nChecked )
    2450                 :          0 :         SetState( sal_True );
    2451                 :          0 : }
    2452                 :            : 
    2453                 :            : // -----------------------------------------------------------------------
    2454                 :            : 
    2455         [ +  - ]:         34 : RadioButton::~RadioButton()
    2456                 :            : {
    2457         [ -  + ]:         68 : }
    2458                 :            : 
    2459                 :            : // -----------------------------------------------------------------------
    2460                 :            : 
    2461                 :          0 : void RadioButton::MouseButtonDown( const MouseEvent& rMEvt )
    2462                 :            : {
    2463 [ #  # ][ #  # ]:          0 :     if ( rMEvt.IsLeft() && maMouseRect.IsInside( rMEvt.GetPosPixel() ) )
                 [ #  # ]
    2464                 :            :     {
    2465                 :          0 :         ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
    2466                 :          0 :         ImplInvalidateOrDrawRadioButtonState();
    2467                 :          0 :         StartTracking();
    2468                 :          0 :         return;
    2469                 :            :     }
    2470                 :            : 
    2471                 :          0 :     Button::MouseButtonDown( rMEvt );
    2472                 :            : }
    2473                 :            : 
    2474                 :            : // -----------------------------------------------------------------------
    2475                 :            : 
    2476                 :          0 : void RadioButton::Tracking( const TrackingEvent& rTEvt )
    2477                 :            : {
    2478         [ #  # ]:          0 :     if ( rTEvt.IsTrackingEnded() )
    2479                 :            :     {
    2480         [ #  # ]:          0 :         if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
    2481                 :            :         {
    2482 [ #  # ][ #  # ]:          0 :             if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
                 [ #  # ]
    2483                 :          0 :                 GrabFocus();
    2484                 :            : 
    2485                 :          0 :             ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    2486                 :            : 
    2487                 :            :             // do not call click handler if aborted
    2488         [ #  # ]:          0 :             if ( !rTEvt.IsTrackingCanceled() )
    2489                 :          0 :                 ImplCallClick();
    2490                 :            :             else
    2491                 :          0 :                 ImplInvalidateOrDrawRadioButtonState();
    2492                 :            :         }
    2493                 :            :     }
    2494                 :            :     else
    2495                 :            :     {
    2496         [ #  # ]:          0 :         if ( maMouseRect.IsInside( rTEvt.GetMouseEvent().GetPosPixel() ) )
    2497                 :            :         {
    2498         [ #  # ]:          0 :             if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
    2499                 :            :             {
    2500                 :          0 :                 ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
    2501                 :          0 :                 ImplInvalidateOrDrawRadioButtonState();
    2502                 :            :             }
    2503                 :            :         }
    2504                 :            :         else
    2505                 :            :         {
    2506         [ #  # ]:          0 :             if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
    2507                 :            :             {
    2508                 :          0 :                 ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    2509                 :          0 :                 ImplInvalidateOrDrawRadioButtonState();
    2510                 :            :             }
    2511                 :            :         }
    2512                 :            :     }
    2513                 :          0 : }
    2514                 :            : 
    2515                 :            : // -----------------------------------------------------------------------
    2516                 :            : 
    2517                 :          0 : void RadioButton::KeyInput( const KeyEvent& rKEvt )
    2518                 :            : {
    2519                 :          0 :     KeyCode aKeyCode = rKEvt.GetKeyCode();
    2520                 :            : 
    2521 [ #  # ][ #  # ]:          0 :     if ( !aKeyCode.GetModifier() && (aKeyCode.GetCode() == KEY_SPACE) )
                 [ #  # ]
    2522                 :            :     {
    2523         [ #  # ]:          0 :         if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
    2524                 :            :         {
    2525                 :          0 :             ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
    2526         [ #  # ]:          0 :             ImplInvalidateOrDrawRadioButtonState();
    2527                 :            :         }
    2528                 :            :     }
    2529 [ #  # ][ #  # ]:          0 :     else if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) && (aKeyCode.GetCode() == KEY_ESCAPE) )
                 [ #  # ]
    2530                 :            :     {
    2531                 :          0 :         ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    2532         [ #  # ]:          0 :         ImplInvalidateOrDrawRadioButtonState();
    2533                 :            :     }
    2534                 :            :     else
    2535         [ #  # ]:          0 :         Button::KeyInput( rKEvt );
    2536                 :          0 : }
    2537                 :            : 
    2538                 :            : // -----------------------------------------------------------------------
    2539                 :            : 
    2540                 :          0 : void RadioButton::KeyUp( const KeyEvent& rKEvt )
    2541                 :            : {
    2542                 :          0 :     KeyCode aKeyCode = rKEvt.GetKeyCode();
    2543                 :            : 
    2544 [ #  # ][ #  # ]:          0 :     if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) && (aKeyCode.GetCode() == KEY_SPACE) )
                 [ #  # ]
    2545                 :            :     {
    2546                 :          0 :         ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    2547         [ #  # ]:          0 :         ImplCallClick();
    2548                 :            :     }
    2549                 :            :     else
    2550         [ #  # ]:          0 :         Button::KeyUp( rKEvt );
    2551                 :          0 : }
    2552                 :            : 
    2553                 :            : // -----------------------------------------------------------------------
    2554                 :            : 
    2555                 :          0 : void RadioButton::FillLayoutData() const
    2556                 :            : {
    2557         [ #  # ]:          0 :     mpControlData->mpLayoutData = new vcl::ControlLayoutData();
    2558                 :          0 :     const_cast<RadioButton*>(this)->ImplDrawRadioButton( true );
    2559                 :          0 : }
    2560                 :            : 
    2561                 :            : // -----------------------------------------------------------------------
    2562                 :            : 
    2563                 :        252 : void RadioButton::Paint( const Rectangle& )
    2564                 :            : {
    2565                 :        252 :     ImplDrawRadioButton();
    2566                 :        252 : }
    2567                 :            : 
    2568                 :            : // -----------------------------------------------------------------------
    2569                 :            : 
    2570                 :          0 : void RadioButton::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
    2571                 :            :                         sal_uLong nFlags )
    2572                 :            : {
    2573         [ #  # ]:          0 :     if ( !maImage )
    2574                 :            :     {
    2575         [ #  # ]:          0 :         MapMode     aResMapMode( MAP_100TH_MM );
    2576         [ #  # ]:          0 :         Point       aPos  = pDev->LogicToPixel( rPos );
    2577         [ #  # ]:          0 :         Size        aSize = pDev->LogicToPixel( rSize );
    2578         [ #  # ]:          0 :         Size        aImageSize = pDev->LogicToPixel( Size( 300, 300 ), aResMapMode );
    2579         [ #  # ]:          0 :         Size        aBrd1Size = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode );
    2580         [ #  # ]:          0 :         Size        aBrd2Size = pDev->LogicToPixel( Size( 60, 60 ), aResMapMode );
    2581         [ #  # ]:          0 :         Font        aFont = GetDrawPixelFont( pDev );
    2582         [ #  # ]:          0 :         Rectangle   aStateRect;
    2583         [ #  # ]:          0 :         Rectangle   aMouseRect;
    2584         [ #  # ]:          0 :         Rectangle   aFocusRect;
    2585                 :            : 
    2586         [ #  # ]:          0 :         aImageSize.Width()  = CalcZoom( aImageSize.Width() );
    2587         [ #  # ]:          0 :         aImageSize.Height() = CalcZoom( aImageSize.Height() );
    2588         [ #  # ]:          0 :         aBrd1Size.Width()   = CalcZoom( aBrd1Size.Width() );
    2589         [ #  # ]:          0 :         aBrd1Size.Height()  = CalcZoom( aBrd1Size.Height() );
    2590         [ #  # ]:          0 :         aBrd2Size.Width()   = CalcZoom( aBrd2Size.Width() );
    2591         [ #  # ]:          0 :         aBrd2Size.Height()  = CalcZoom( aBrd2Size.Height() );
    2592                 :            : 
    2593         [ #  # ]:          0 :         if ( !aBrd1Size.Width() )
    2594                 :          0 :             aBrd1Size.Width() = 1;
    2595         [ #  # ]:          0 :         if ( !aBrd1Size.Height() )
    2596                 :          0 :             aBrd1Size.Height() = 1;
    2597         [ #  # ]:          0 :         if ( !aBrd2Size.Width() )
    2598                 :          0 :             aBrd2Size.Width() = 1;
    2599         [ #  # ]:          0 :         if ( !aBrd2Size.Height() )
    2600                 :          0 :             aBrd2Size.Height() = 1;
    2601                 :            : 
    2602         [ #  # ]:          0 :         pDev->Push();
    2603         [ #  # ]:          0 :         pDev->SetMapMode();
    2604         [ #  # ]:          0 :         pDev->SetFont( aFont );
    2605         [ #  # ]:          0 :         if ( nFlags & WINDOW_DRAW_MONO )
    2606         [ #  # ]:          0 :             pDev->SetTextColor( Color( COL_BLACK ) );
    2607                 :            :         else
    2608         [ #  # ]:          0 :             pDev->SetTextColor( GetTextColor() );
    2609         [ #  # ]:          0 :         pDev->SetTextFillColor();
    2610                 :            : 
    2611                 :            :         ImplDraw( pDev, nFlags, aPos, aSize,
    2612         [ #  # ]:          0 :                   aImageSize, aStateRect, aMouseRect );
    2613                 :            : 
    2614         [ #  # ]:          0 :         Point   aCenterPos = aStateRect.Center();
    2615                 :          0 :         long    nRadX = aImageSize.Width()/2;
    2616                 :          0 :         long    nRadY = aImageSize.Height()/2;
    2617                 :            : 
    2618         [ #  # ]:          0 :         pDev->SetLineColor();
    2619         [ #  # ]:          0 :         pDev->SetFillColor( Color( COL_BLACK ) );
    2620 [ #  # ][ #  # ]:          0 :         pDev->DrawPolygon( Polygon( aCenterPos, nRadX, nRadY ) );
                 [ #  # ]
    2621                 :          0 :         nRadX -= aBrd1Size.Width();
    2622                 :          0 :         nRadY -= aBrd1Size.Height();
    2623         [ #  # ]:          0 :         pDev->SetFillColor( Color( COL_WHITE ) );
    2624 [ #  # ][ #  # ]:          0 :         pDev->DrawPolygon( Polygon( aCenterPos, nRadX, nRadY ) );
                 [ #  # ]
    2625         [ #  # ]:          0 :         if ( mbChecked )
    2626                 :            :         {
    2627                 :          0 :             nRadX -= aBrd1Size.Width();
    2628                 :          0 :             nRadY -= aBrd1Size.Height();
    2629         [ #  # ]:          0 :             if ( !nRadX )
    2630                 :          0 :                 nRadX = 1;
    2631         [ #  # ]:          0 :             if ( !nRadY )
    2632                 :          0 :                 nRadY = 1;
    2633         [ #  # ]:          0 :             pDev->SetFillColor( Color( COL_BLACK ) );
    2634 [ #  # ][ #  # ]:          0 :             pDev->DrawPolygon( Polygon( aCenterPos, nRadX, nRadY ) );
                 [ #  # ]
    2635                 :            :         }
    2636                 :            : 
    2637 [ #  # ][ #  # ]:          0 :         pDev->Pop();
                 [ #  # ]
    2638                 :            :     }
    2639                 :            :     else
    2640                 :            :     {
    2641                 :            :         OSL_FAIL( "RadioButton::Draw() - not implemented for RadioButton with Image" );
    2642                 :            :     }
    2643                 :          0 : }
    2644                 :            : 
    2645                 :            : // -----------------------------------------------------------------------
    2646                 :            : 
    2647                 :         38 : void RadioButton::Resize()
    2648                 :            : {
    2649                 :         38 :     Control::Resize();
    2650                 :         38 :     Invalidate();
    2651                 :         38 : }
    2652                 :            : 
    2653                 :            : // -----------------------------------------------------------------------
    2654                 :            : 
    2655                 :          0 : void RadioButton::GetFocus()
    2656                 :            : {
    2657                 :          0 :     ShowFocus( ImplGetFocusRect() );
    2658         [ #  # ]:          0 :     SetInputContext( InputContext( GetFont() ) );
    2659                 :          0 :     Button::GetFocus();
    2660                 :          0 : }
    2661                 :            : 
    2662                 :            : // -----------------------------------------------------------------------
    2663                 :            : 
    2664                 :          0 : void RadioButton::LoseFocus()
    2665                 :            : {
    2666         [ #  # ]:          0 :     if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
    2667                 :            :     {
    2668                 :          0 :         ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    2669                 :          0 :         ImplInvalidateOrDrawRadioButtonState();
    2670                 :            :     }
    2671                 :            : 
    2672                 :          0 :     HideFocus();
    2673                 :          0 :     Button::LoseFocus();
    2674                 :          0 : }
    2675                 :            : 
    2676                 :            : // -----------------------------------------------------------------------
    2677                 :            : 
    2678                 :        875 : void RadioButton::StateChanged( StateChangedType nType )
    2679                 :            : {
    2680                 :        875 :     Button::StateChanged( nType );
    2681                 :            : 
    2682         [ +  + ]:        875 :     if ( nType == STATE_CHANGE_STATE )
    2683                 :            :     {
    2684 [ -  + ][ #  # ]:         26 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ -  + ]
    2685                 :          0 :             Invalidate( maStateRect );
    2686                 :            :     }
    2687 [ +  + ][ +  + ]:        849 :     else if ( (nType == STATE_CHANGE_ENABLE) ||
         [ +  - ][ +  + ]
                 [ -  + ]
    2688                 :            :               (nType == STATE_CHANGE_TEXT) ||
    2689                 :            :               (nType == STATE_CHANGE_IMAGE) ||
    2690                 :            :               (nType == STATE_CHANGE_DATA) ||
    2691                 :            :               (nType == STATE_CHANGE_UPDATEMODE) )
    2692                 :            :     {
    2693         [ +  - ]:        188 :         if ( IsUpdateMode() )
    2694                 :         94 :             Invalidate();
    2695                 :            :     }
    2696         [ +  + ]:        755 :     else if ( nType == STATE_CHANGE_STYLE )
    2697                 :            :     {
    2698                 :         10 :         SetStyle( ImplInitStyle( GetWindow( WINDOW_PREV ), GetStyle() ) );
    2699                 :            : 
    2700         [ +  - ]:         20 :         if ( (GetPrevStyle() & RADIOBUTTON_VIEW_STYLE) !=
    2701                 :         10 :              (GetStyle() & RADIOBUTTON_VIEW_STYLE) )
    2702                 :            :         {
    2703         [ +  - ]:         10 :             if ( IsUpdateMode() )
    2704                 :         10 :                 Invalidate();
    2705                 :            :         }
    2706                 :            :     }
    2707 [ +  - ][ +  + ]:        745 :     else if ( (nType == STATE_CHANGE_ZOOM) ||
    2708                 :            :               (nType == STATE_CHANGE_CONTROLFONT) )
    2709                 :            :     {
    2710                 :        145 :         ImplInitSettings( sal_True, sal_False, sal_False );
    2711                 :        145 :         Invalidate();
    2712                 :            :     }
    2713         [ -  + ]:        600 :     else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
    2714                 :            :     {
    2715                 :          0 :         ImplInitSettings( sal_False, sal_True, sal_False );
    2716                 :          0 :         Invalidate();
    2717                 :            :     }
    2718         [ -  + ]:        600 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
    2719                 :            :     {
    2720                 :          0 :         ImplInitSettings( sal_False, sal_False, sal_True );
    2721                 :          0 :         Invalidate();
    2722                 :            :     }
    2723                 :        875 : }
    2724                 :            : 
    2725                 :            : // -----------------------------------------------------------------------
    2726                 :            : 
    2727                 :        326 : void RadioButton::DataChanged( const DataChangedEvent& rDCEvt )
    2728                 :            : {
    2729                 :        326 :     Button::DataChanged( rDCEvt );
    2730                 :            : 
    2731 [ +  - ][ +  -  :       1304 :     if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
          +  -  +  -  +  
                      - ]
    2732                 :        326 :          (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
    2733                 :        326 :          ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
    2734                 :        326 :           (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
    2735                 :            :     {
    2736                 :        326 :         ImplInitSettings( sal_True, sal_True, sal_True );
    2737                 :        326 :         Invalidate();
    2738                 :            :     }
    2739                 :        326 : }
    2740                 :            : 
    2741                 :            : // -----------------------------------------------------------------------
    2742                 :            : 
    2743                 :          0 : long RadioButton::PreNotify( NotifyEvent& rNEvt )
    2744                 :            : {
    2745                 :          0 :     long nDone = 0;
    2746                 :          0 :     const MouseEvent* pMouseEvt = NULL;
    2747                 :            : 
    2748 [ #  # ][ #  # ]:          0 :     if( (rNEvt.GetType() == EVENT_MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != NULL )
                 [ #  # ]
    2749                 :            :     {
    2750 [ #  # ][ #  # ]:          0 :         if( !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
         [ #  # ][ #  # ]
    2751                 :            :         {
    2752                 :            :             // trigger redraw if mouse over state has changed
    2753         [ #  # ]:          0 :             if( IsNativeControlSupported(CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL) )
    2754                 :            :             {
    2755 [ #  # ][ #  # ]:          0 :                 if( ( maMouseRect.IsInside( GetPointerPosPixel()) &&
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    2756 [ #  # ][ #  # ]:          0 :                      !maMouseRect.IsInside( GetLastPointerPosPixel()) ) ||
         [ #  # ][ #  # ]
    2757 [ #  # ][ #  # ]:          0 :                     ( maMouseRect.IsInside( GetLastPointerPosPixel()) &&
         [ #  # ][ #  # ]
    2758 [ #  # ][ #  # ]:          0 :                      !maMouseRect.IsInside( GetPointerPosPixel()) ) ||
         [ #  # ][ #  # ]
    2759                 :          0 :                      pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow() )
    2760                 :            :                 {
    2761                 :          0 :                     Invalidate( maStateRect );
    2762                 :            :                 }
    2763                 :            :             }
    2764                 :            :         }
    2765                 :            :     }
    2766                 :            : 
    2767         [ #  # ]:          0 :     return nDone ? nDone : Button::PreNotify(rNEvt);
    2768                 :            : }
    2769                 :            : 
    2770                 :            : // -----------------------------------------------------------------------
    2771                 :            : 
    2772                 :         26 : void RadioButton::Toggle()
    2773                 :            : {
    2774                 :         26 :     ImplCallEventListenersAndHandler( VCLEVENT_RADIOBUTTON_TOGGLE, maToggleHdl, this );
    2775                 :         26 : }
    2776                 :            : 
    2777                 :            : // -----------------------------------------------------------------------
    2778                 :            : 
    2779                 :          0 : sal_Bool RadioButton::SetModeRadioImage( const Image& rImage )
    2780                 :            : {
    2781         [ #  # ]:          0 :     if ( rImage != maImage )
    2782                 :            :     {
    2783                 :          0 :         maImage = rImage;
    2784                 :          0 :         StateChanged( STATE_CHANGE_DATA );
    2785                 :            :     }
    2786                 :          0 :     return sal_True;
    2787                 :            : }
    2788                 :            : 
    2789                 :            : // -----------------------------------------------------------------------
    2790                 :            : 
    2791                 :          0 : const Image& RadioButton::GetModeRadioImage( ) const
    2792                 :            : {
    2793                 :          0 :     return maImage;
    2794                 :            : }
    2795                 :            : 
    2796                 :            : // -----------------------------------------------------------------------
    2797                 :            : 
    2798                 :         34 : void RadioButton::SetState( sal_Bool bCheck )
    2799                 :            : {
    2800                 :            :     // TabStop-Flag richtig mitfuehren
    2801         [ +  + ]:         34 :     if ( bCheck )
    2802                 :         20 :         mpWindowImpl->mnStyle |= WB_TABSTOP;
    2803                 :            :     else
    2804                 :         14 :         mpWindowImpl->mnStyle &= ~WB_TABSTOP;
    2805                 :            : 
    2806         [ +  + ]:         34 :     if ( mbChecked != bCheck )
    2807                 :            :     {
    2808                 :         20 :         mbChecked = bCheck;
    2809                 :         20 :         StateChanged( STATE_CHANGE_STATE );
    2810                 :         20 :         Toggle();
    2811                 :            :     }
    2812                 :         34 : }
    2813                 :            : 
    2814                 :            : // -----------------------------------------------------------------------
    2815                 :            : 
    2816                 :         28 : void RadioButton::Check( sal_Bool bCheck )
    2817                 :            : {
    2818                 :            :     // TabStop-Flag richtig mitfuehren
    2819         [ +  - ]:         28 :     if ( bCheck )
    2820                 :         28 :         mpWindowImpl->mnStyle |= WB_TABSTOP;
    2821                 :            :     else
    2822                 :          0 :         mpWindowImpl->mnStyle &= ~WB_TABSTOP;
    2823                 :            : 
    2824         [ +  + ]:         28 :     if ( mbChecked != bCheck )
    2825                 :            :     {
    2826                 :          6 :         mbChecked = bCheck;
    2827         [ +  - ]:          6 :         ImplDelData aDelData;
    2828         [ +  - ]:          6 :         ImplAddDel( &aDelData );
    2829         [ +  - ]:          6 :         StateChanged( STATE_CHANGE_STATE );
    2830         [ -  + ]:          6 :         if ( aDelData.IsDead() )
    2831                 :            :             return;
    2832 [ +  - ][ +  - ]:          6 :         if ( bCheck && mbRadioCheck )
    2833         [ +  - ]:          6 :             ImplUncheckAllOther();
    2834         [ -  + ]:          6 :         if ( aDelData.IsDead() )
    2835                 :            :             return;
    2836         [ +  - ]:          6 :         Toggle();
    2837 [ +  - ][ +  - ]:         28 :         ImplRemoveDel( &aDelData );
                 [ +  - ]
    2838                 :            :     }
    2839                 :            : }
    2840                 :            : 
    2841                 :            : // -----------------------------------------------------------------------
    2842                 :            : 
    2843                 :        195 : long RadioButton::ImplGetImageToTextDistance() const
    2844                 :            : {
    2845                 :            :     // 4 pixels, but take zoom into account, so the text doesn't "jump" relative to surrounding elements,
    2846                 :            :     // which might have been aligned with the text of the check box
    2847                 :        195 :     return CalcZoom( 4 );
    2848                 :            : }
    2849                 :            : 
    2850                 :            : // -----------------------------------------------------------------------
    2851                 :            : 
    2852                 :        264 : Size RadioButton::ImplGetRadioImageSize() const
    2853                 :            : {
    2854                 :        264 :     Size aSize;
    2855                 :            :     // why are IsNativeControlSupported and GetNativeControlRegion not const ?
    2856                 :        264 :     RadioButton* pThis = const_cast<RadioButton*>(this);
    2857                 :        264 :     bool bDefaultSize = true;
    2858         [ -  + ]:        264 :     if( pThis->IsNativeControlSupported( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL ) )
    2859                 :            :     {
    2860                 :          0 :         ImplControlValue aControlValue;
    2861                 :            :         // #i45896# workaround gcc3.3 temporary problem
    2862 [ #  # ][ #  # ]:          0 :         Rectangle        aCtrlRegion( Point( 0, 0 ), GetSizePixel() );
    2863                 :          0 :         ControlState     nState = CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED;
    2864 [ #  # ][ #  # ]:          0 :         Rectangle aBoundingRgn, aContentRgn;
    2865                 :            : 
    2866                 :            :         // get native size of a radio button
    2867         [ #  # ]:          0 :         if( pThis->GetNativeControlRegion( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion,
    2868                 :            :                                            nState, aControlValue, rtl::OUString(),
    2869         [ #  # ]:          0 :                                            aBoundingRgn, aContentRgn ) )
    2870                 :            :         {
    2871         [ #  # ]:          0 :             aSize = aContentRgn.GetSize();
    2872                 :          0 :             bDefaultSize = false;
    2873         [ #  # ]:          0 :         }
    2874                 :            :     }
    2875         [ +  - ]:        264 :     if( bDefaultSize )
    2876         [ +  - ]:        264 :         aSize = GetRadioImage( GetSettings(), 0 ).GetSizePixel();
    2877                 :        264 :     return aSize;
    2878                 :            : }
    2879                 :            : 
    2880                 :         40 : static void LoadThemedImageList (const StyleSettings &rStyleSettings,
    2881                 :            :                                  ImageList *pList, const ResId &rResId,
    2882                 :            :                                  sal_uInt16 nImages)
    2883                 :            : {
    2884         [ +  + ]:        280 :     Color aColorAry1[6];
    2885         [ +  + ]:        280 :     Color aColorAry2[6];
    2886                 :         40 :     aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 );
    2887                 :         40 :     aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 );
    2888                 :         40 :     aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF );
    2889                 :         40 :     aColorAry1[3] = Color( 0x80, 0x80, 0x80 );
    2890                 :         40 :     aColorAry1[4] = Color( 0x00, 0x00, 0x00 );
    2891                 :         40 :     aColorAry1[5] = Color( 0x00, 0xFF, 0x00 );
    2892                 :         40 :     aColorAry2[0] = rStyleSettings.GetFaceColor();
    2893                 :         40 :     aColorAry2[1] = rStyleSettings.GetWindowColor();
    2894                 :         40 :     aColorAry2[2] = rStyleSettings.GetLightColor();
    2895                 :         40 :     aColorAry2[3] = rStyleSettings.GetShadowColor();
    2896                 :         40 :     aColorAry2[4] = rStyleSettings.GetDarkShadowColor();
    2897                 :         40 :     aColorAry2[5] = rStyleSettings.GetWindowTextColor();
    2898                 :            : 
    2899                 :         40 :     Color aMaskColor(0x00, 0x00, 0xFF );
    2900                 :            :         DBG_ASSERT( sizeof(aColorAry1) == sizeof(aColorAry2), "aColorAry1 must match aColorAry2" );
    2901                 :            :     // FIXME: do we want the mask for the checkbox ?
    2902                 :            :     pList->InsertFromHorizontalBitmap (rResId, nImages, &aMaskColor,
    2903         [ +  - ]:         40 :         aColorAry1, aColorAry2, sizeof(aColorAry1) / sizeof(Color));
    2904                 :         40 : }
    2905                 :            : 
    2906                 :        516 : Image RadioButton::GetRadioImage( const AllSettings& rSettings, sal_uInt16 nFlags )
    2907                 :            : {
    2908                 :        516 :     ImplSVData*             pSVData = ImplGetSVData();
    2909                 :        516 :     const StyleSettings&    rStyleSettings = rSettings.GetStyleSettings();
    2910                 :        516 :     sal_uInt16              nStyle = 0;
    2911                 :            : 
    2912         [ +  + ]:        516 :     if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
    2913                 :        334 :         nStyle = STYLE_RADIOBUTTON_MONO;
    2914                 :            : 
    2915 [ +  + ][ +  +  :       2016 :     if ( !pSVData->maCtrlData.mpRadioImgList ||
          +  -  +  -  -  
              + ][ +  + ]
    2916                 :            :          (pSVData->maCtrlData.mnRadioStyle != nStyle) ||
    2917                 :        500 :          (pSVData->maCtrlData.mnLastRadioFColor != rStyleSettings.GetFaceColor().GetColor()) ||
    2918                 :        500 :          (pSVData->maCtrlData.mnLastRadioWColor != rStyleSettings.GetWindowColor().GetColor()) ||
    2919                 :        500 :          (pSVData->maCtrlData.mnLastRadioLColor != rStyleSettings.GetLightColor().GetColor()) )
    2920                 :            :     {
    2921         [ +  + ]:         16 :         if ( pSVData->maCtrlData.mpRadioImgList )
    2922         [ +  - ]:         12 :             delete pSVData->maCtrlData.mpRadioImgList;
    2923                 :            : 
    2924                 :         16 :         pSVData->maCtrlData.mnLastRadioFColor = rStyleSettings.GetFaceColor().GetColor();
    2925                 :         16 :         pSVData->maCtrlData.mnLastRadioWColor = rStyleSettings.GetWindowColor().GetColor();
    2926                 :         16 :         pSVData->maCtrlData.mnLastRadioLColor = rStyleSettings.GetLightColor().GetColor();
    2927                 :            : 
    2928                 :         16 :         ResMgr* pResMgr = ImplGetResMgr();
    2929         [ +  - ]:         16 :         pSVData->maCtrlData.mpRadioImgList = new ImageList();
    2930         [ +  - ]:         16 :         if( pResMgr )
    2931                 :            :             LoadThemedImageList( rStyleSettings,
    2932                 :            :                  pSVData->maCtrlData.mpRadioImgList,
    2933                 :            :                  ResId( SV_RESID_BITMAP_RADIO+nStyle, *pResMgr ), 6
    2934         [ +  - ]:         16 :             );
    2935                 :         16 :         pSVData->maCtrlData.mnRadioStyle = nStyle;
    2936                 :            :     }
    2937                 :            : 
    2938                 :            :     sal_uInt16 nId;
    2939         [ +  + ]:        516 :     if ( nFlags & BUTTON_DRAW_DISABLED )
    2940                 :            :     {
    2941         [ +  - ]:         61 :         if ( nFlags & BUTTON_DRAW_CHECKED )
    2942                 :         61 :             nId = 6;
    2943                 :            :         else
    2944                 :          0 :             nId = 5;
    2945                 :            :     }
    2946         [ -  + ]:        455 :     else if ( nFlags & BUTTON_DRAW_PRESSED )
    2947                 :            :     {
    2948         [ #  # ]:          0 :         if ( nFlags & BUTTON_DRAW_CHECKED )
    2949                 :          0 :             nId = 4;
    2950                 :            :         else
    2951                 :          0 :             nId = 3;
    2952                 :            :     }
    2953                 :            :     else
    2954                 :            :     {
    2955         [ +  + ]:        455 :         if ( nFlags & BUTTON_DRAW_CHECKED )
    2956                 :        142 :             nId = 2;
    2957                 :            :         else
    2958                 :        313 :             nId = 1;
    2959                 :            :     }
    2960                 :        516 :     return pSVData->maCtrlData.mpRadioImgList->GetImage( nId );
    2961                 :            : }
    2962                 :            : 
    2963                 :            : // -----------------------------------------------------------------------
    2964                 :            : 
    2965                 :          0 : void RadioButton::ImplSetMinimumNWFSize()
    2966                 :            : {
    2967         [ #  # ]:          0 :     Push( PUSH_MAPMODE );
    2968 [ #  # ][ #  # ]:          0 :     SetMapMode( MAP_PIXEL );
                 [ #  # ]
    2969                 :            : 
    2970                 :          0 :     ImplControlValue aControlValue;
    2971         [ #  # ]:          0 :     Size aCurSize( GetSizePixel() );
    2972         [ #  # ]:          0 :     Rectangle aCtrlRegion( Point( 0, 0 ), aCurSize );
    2973 [ #  # ][ #  # ]:          0 :     Rectangle aBoundingRgn, aContentRgn;
    2974                 :            : 
    2975                 :            :     // get native size of a radiobutton
    2976         [ #  # ]:          0 :     if( GetNativeControlRegion( CTRL_RADIOBUTTON, PART_ENTIRE_CONTROL, aCtrlRegion,
    2977                 :            :                                 CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED, aControlValue, rtl::OUString(),
    2978         [ #  # ]:          0 :                                 aBoundingRgn, aContentRgn ) )
    2979                 :            :     {
    2980         [ #  # ]:          0 :         Size aSize = aContentRgn.GetSize();
    2981                 :            : 
    2982         [ #  # ]:          0 :         if( aSize.Height() > aCurSize.Height() )
    2983                 :            :         {
    2984                 :          0 :             aCurSize.Height() = aSize.Height();
    2985         [ #  # ]:          0 :             SetSizePixel( aCurSize );
    2986                 :            :         }
    2987                 :            :     }
    2988                 :            : 
    2989 [ #  # ][ #  # ]:          0 :     Pop();
    2990                 :          0 : }
    2991                 :            : 
    2992                 :            : // -----------------------------------------------------------------------
    2993                 :            : 
    2994                 :         12 : Size RadioButton::CalcMinimumSize( long nMaxWidth ) const
    2995                 :            : {
    2996                 :         12 :     Size aSize;
    2997         [ +  - ]:         12 :     if ( !maImage )
    2998         [ +  - ]:         12 :         aSize = ImplGetRadioImageSize();
    2999                 :            :     else
    3000         [ #  # ]:          0 :         aSize = maImage.GetSizePixel();
    3001                 :            : 
    3002                 :         12 :     nMaxWidth -= aSize.Width();
    3003                 :            : 
    3004         [ +  - ]:         12 :     XubString aText = GetText();
    3005 [ -  + ][ #  # ]:         12 :     if ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
                 [ -  + ]
    3006                 :            :     {
    3007                 :            :         // subtract what will be added later
    3008                 :          0 :         nMaxWidth-=2;
    3009         [ #  # ]:          0 :         nMaxWidth -= ImplGetImageToTextDistance();
    3010                 :            : 
    3011                 :            :         Size aTextSize = GetTextRect( Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
    3012 [ #  # ][ #  # ]:          0 :                                       aText, FixedText::ImplGetTextStyle( GetStyle() ) ).GetSize();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3013                 :          0 :         aSize.Width()+=2;   // for focus rect
    3014         [ #  # ]:          0 :         aSize.Width() += ImplGetImageToTextDistance();
    3015                 :          0 :         aSize.Width() += aTextSize.Width();
    3016         [ #  # ]:          0 :         if ( aSize.Height() < aTextSize.Height() )
    3017                 :          0 :             aSize.Height() = aTextSize.Height();
    3018                 :            :     }
    3019                 :            : //  else if ( !maImage )
    3020                 :            : //  {
    3021                 :            : /* da ansonsten im Writer die Control zu weit oben haengen
    3022                 :            :         aSize.Width() += 2;
    3023                 :            :         aSize.Height() += 2;
    3024                 :            : */
    3025                 :            : //  }
    3026                 :            : 
    3027 [ +  - ][ +  - ]:         12 :     return CalcWindowSize( aSize );
    3028                 :            : }
    3029                 :            : 
    3030                 :            : // -----------------------------------------------------------------------
    3031                 :            : 
    3032                 :          0 : Size RadioButton::GetOptimalSize(WindowSizeType eType) const
    3033                 :            : {
    3034         [ #  # ]:          0 :     switch (eType) {
    3035                 :            :     case WINDOWSIZE_MINIMUM:
    3036                 :          0 :         return CalcMinimumSize();
    3037                 :            :     default:
    3038                 :          0 :         return Button::GetOptimalSize( eType );
    3039                 :            :     }
    3040                 :            : }
    3041                 :            : 
    3042                 :            : // =======================================================================
    3043                 :            : 
    3044                 :        176 : void CheckBox::ImplInitCheckBoxData()
    3045                 :            : {
    3046                 :        176 :     meState         = STATE_NOCHECK;
    3047                 :        176 :     meSaveValue     = STATE_NOCHECK;
    3048                 :        176 :     mbTriState      = sal_False;
    3049                 :        176 : }
    3050                 :            : 
    3051                 :            : // -----------------------------------------------------------------------
    3052                 :            : 
    3053                 :        176 : void CheckBox::ImplInit( Window* pParent, WinBits nStyle )
    3054                 :            : {
    3055                 :        176 :     nStyle = ImplInitStyle( pParent->GetWindow( WINDOW_LASTCHILD ), nStyle );
    3056                 :        176 :     Button::ImplInit( pParent, nStyle, NULL );
    3057                 :            : 
    3058                 :        176 :     ImplInitSettings( sal_True, sal_True, sal_True );
    3059                 :        176 : }
    3060                 :            : 
    3061                 :            : // -----------------------------------------------------------------------
    3062                 :            : 
    3063                 :        254 : WinBits CheckBox::ImplInitStyle( const Window* pPrevWindow, WinBits nStyle )
    3064                 :            : {
    3065         [ +  - ]:        254 :     if ( !(nStyle & WB_NOTABSTOP) )
    3066                 :        254 :         nStyle |= WB_TABSTOP;
    3067         [ +  - ]:        356 :     if ( !(nStyle & WB_NOGROUP) &&
           [ +  +  +  + ]
                 [ +  + ]
    3068                 :        102 :          (!pPrevWindow || (pPrevWindow->GetType() != WINDOW_CHECKBOX)) )
    3069                 :        169 :         nStyle |= WB_GROUP;
    3070                 :        254 :     return nStyle;
    3071                 :            : }
    3072                 :            : 
    3073                 :            : // -----------------------------------------------------------------
    3074                 :            : 
    3075                 :        878 : const Font& CheckBox::GetCanonicalFont( const StyleSettings& _rStyle ) const
    3076                 :            : {
    3077                 :        878 :     return _rStyle.GetRadioCheckFont();
    3078                 :            : }
    3079                 :            : 
    3080                 :            : // -----------------------------------------------------------------
    3081                 :        699 : const Color& CheckBox::GetCanonicalTextColor( const StyleSettings& _rStyle ) const
    3082                 :            : {
    3083                 :        699 :     return _rStyle.GetRadioCheckTextColor();
    3084                 :            : }
    3085                 :            : 
    3086                 :            : // -----------------------------------------------------------------------
    3087                 :            : 
    3088                 :        699 : void CheckBox::ImplInitSettings( sal_Bool bFont,
    3089                 :            :                                  sal_Bool bForeground, sal_Bool bBackground )
    3090                 :            : {
    3091                 :        699 :     Button::ImplInitSettings( bFont, bForeground );
    3092                 :            : 
    3093         [ +  + ]:        699 :     if ( bBackground )
    3094                 :            :     {
    3095                 :        554 :         Window* pParent = GetParent();
    3096 [ +  + ][ +  -  :       1210 :         if ( !IsControlBackground() &&
             +  +  -  + ]
    3097                 :        656 :             (pParent->IsChildTransparentModeEnabled() || IsNativeControlSupported( CTRL_CHECKBOX, PART_ENTIRE_CONTROL ) ) )
    3098                 :            :         {
    3099                 :        452 :             EnableChildTransparentMode( sal_True );
    3100                 :        452 :             SetParentClipMode( PARENTCLIPMODE_NOCLIP );
    3101                 :        452 :             SetPaintTransparent( sal_True );
    3102                 :        452 :             SetBackground();
    3103         [ -  + ]:        452 :             if( IsNativeControlSupported( CTRL_CHECKBOX, PART_ENTIRE_CONTROL ) )
    3104                 :          0 :                 ImplGetWindowImpl()->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects;
    3105                 :            :         }
    3106                 :            :         else
    3107                 :            :         {
    3108                 :        102 :             EnableChildTransparentMode( sal_False );
    3109                 :        102 :             SetParentClipMode( 0 );
    3110                 :        102 :             SetPaintTransparent( sal_False );
    3111                 :            : 
    3112         [ -  + ]:        102 :             if ( IsControlBackground() )
    3113 [ #  # ][ #  # ]:          0 :                 SetBackground( GetControlBackground() );
                 [ #  # ]
    3114                 :            :             else
    3115                 :        102 :                 SetBackground( pParent->GetBackground() );
    3116                 :            :         }
    3117                 :            :     }
    3118                 :        699 : }
    3119                 :            : 
    3120                 :            : // -----------------------------------------------------------------------
    3121                 :            : 
    3122                 :        102 : void CheckBox::ImplLoadRes( const ResId& rResId )
    3123                 :            : {
    3124                 :        102 :     Button::ImplLoadRes( rResId );
    3125                 :            : 
    3126         [ +  - ]:        102 :     if ( rResId.GetRT() != RSC_TRISTATEBOX )
    3127                 :            :     {
    3128                 :        102 :         sal_uInt16 nChecked = ReadShortRes();
    3129                 :            :         //anderer Wert als Default ?
    3130         [ -  + ]:        102 :         if( nChecked )
    3131                 :          0 :             Check( sal_True );
    3132                 :            :     }
    3133                 :        102 : }
    3134                 :            : 
    3135                 :            : // -----------------------------------------------------------------------
    3136                 :            : 
    3137                 :          0 : void CheckBox::ImplInvalidateOrDrawCheckBoxState()
    3138                 :            : {
    3139         [ #  # ]:          0 :     if( ImplGetSVData()->maNWFData.mbCheckBoxNeedsErase )
    3140                 :            :     {
    3141         [ #  # ]:          0 :         if ( IsNativeControlSupported(CTRL_CHECKBOX, PART_ENTIRE_CONTROL) )
    3142                 :            :         {
    3143                 :          0 :             Invalidate();
    3144                 :          0 :             Update();
    3145                 :          0 :             return;
    3146                 :            :         }
    3147                 :            :     }
    3148                 :          0 :     ImplDrawCheckBoxState();
    3149                 :            : }
    3150                 :            : 
    3151                 :        343 : void CheckBox::ImplDrawCheckBoxState()
    3152                 :            : {
    3153                 :        343 :     bool    bNativeOK = sal_True;
    3154                 :            : 
    3155         [ -  + ]:        343 :     if ( (bNativeOK=IsNativeControlSupported(CTRL_CHECKBOX, PART_ENTIRE_CONTROL)) == sal_True )
    3156                 :            :     {
    3157         [ #  # ]:          0 :         ImplControlValue    aControlValue( meState == STATE_CHECK ? BUTTONVALUE_ON : BUTTONVALUE_OFF );
    3158                 :          0 :         Rectangle           aCtrlRegion( maStateRect );
    3159                 :          0 :         ControlState        nState = 0;
    3160                 :            : 
    3161 [ #  # ][ #  # ]:          0 :         if ( HasFocus() )                       nState |= CTRL_STATE_FOCUSED;
    3162         [ #  # ]:          0 :         if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT )   nState |= CTRL_STATE_DEFAULT;
    3163         [ #  # ]:          0 :         if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )   nState |= CTRL_STATE_PRESSED;
    3164 [ #  # ][ #  # ]:          0 :         if ( IsEnabled() )                      nState |= CTRL_STATE_ENABLED;
    3165                 :            : 
    3166         [ #  # ]:          0 :         if ( meState == STATE_CHECK )
    3167                 :          0 :             aControlValue.setTristateVal( BUTTONVALUE_ON );
    3168         [ #  # ]:          0 :         else if ( meState == STATE_DONTKNOW )
    3169                 :          0 :             aControlValue.setTristateVal( BUTTONVALUE_MIXED );
    3170                 :            : 
    3171 [ #  # ][ #  # ]:          0 :         if ( IsMouseOver() && maMouseRect.IsInside( GetPointerPosPixel() ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    3172                 :          0 :             nState |= CTRL_STATE_ROLLOVER;
    3173                 :            : 
    3174                 :            :         bNativeOK = DrawNativeControl( CTRL_CHECKBOX, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
    3175 [ #  # ][ #  # ]:          0 :                                  aControlValue, rtl::OUString() );
    3176                 :            :     }
    3177                 :            : 
    3178         [ +  - ]:        343 :     if ( bNativeOK == sal_False )
    3179                 :            :     {
    3180                 :        343 :         sal_uInt16 nStyle = ImplGetButtonState();
    3181 [ +  + ][ +  - ]:        343 :         if ( !IsEnabled() )
    3182                 :        176 :             nStyle |= BUTTON_DRAW_DISABLED;
    3183         [ +  + ]:        343 :         if ( meState == STATE_DONTKNOW )
    3184                 :         68 :             nStyle |= BUTTON_DRAW_DONTKNOW;
    3185         [ +  + ]:        275 :         else if ( meState == STATE_CHECK )
    3186                 :         53 :             nStyle |= BUTTON_DRAW_CHECKED;
    3187         [ +  - ]:        343 :         Image aImage = GetCheckImage( GetSettings(), nStyle );
    3188 [ +  - ][ -  + ]:        343 :         if ( IsZoom() )
    3189 [ #  # ][ #  # ]:          0 :             DrawImage( maStateRect.TopLeft(), maStateRect.GetSize(), aImage );
    3190                 :            :         else
    3191 [ +  - ][ +  - ]:        343 :             DrawImage( maStateRect.TopLeft(), aImage );
    3192                 :            :     }
    3193                 :        343 : }
    3194                 :            : 
    3195                 :            : // -----------------------------------------------------------------------
    3196                 :            : 
    3197                 :        343 : void CheckBox::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
    3198                 :            :                          const Point& rPos, const Size& rSize,
    3199                 :            :                          const Size& rImageSize, Rectangle& rStateRect,
    3200                 :            :                          Rectangle& rMouseRect, bool bLayout )
    3201                 :            : {
    3202         [ +  - ]:        343 :     WinBits                 nWinStyle = GetStyle();
    3203         [ +  - ]:        343 :     XubString               aText( GetText() );
    3204                 :            : 
    3205         [ +  - ]:        343 :     pDev->Push( PUSH_CLIPREGION | PUSH_LINECOLOR );
    3206 [ +  - ][ +  - ]:        343 :     pDev->IntersectClipRegion( Rectangle( rPos, rSize ) );
    3207                 :            : 
    3208                 :        343 :     long nLineY = rPos.Y() + (rSize.Height()-1)/2;
    3209         [ -  + ]:        387 :     if ( ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) ) ||
           [ -  +  #  # ]
         [ +  + ][ +  + ]
    3210         [ +  - ]:         44 :          ( HasImage() && !  (ImplGetButtonState() & BUTTON_DRAW_NOIMAGE) ) )
    3211                 :            :     {
    3212         [ +  - ]:        299 :         sal_uInt16 nTextStyle = Button::ImplGetTextStyle( aText, nWinStyle, nDrawFlags );
    3213                 :            : 
    3214 [ +  - ][ +  - ]:        299 :         const long nImageSep = GetDrawPixel( pDev, ImplGetImageToTextDistance() );
    3215                 :        299 :         Size aSize( rSize );
    3216                 :        299 :         Point aPos( rPos );
    3217                 :        299 :         aPos.X() += rImageSize.Width() + nImageSep;
    3218                 :        299 :         aSize.Width() -= rImageSize.Width() + nImageSep;
    3219                 :            : 
    3220                 :            :         // if the text rect height is smaller than the height of the image
    3221                 :            :         // then for single lines the default should be centered text
    3222 [ +  + ][ +  + ]:        598 :         if( (nWinStyle & (WB_TOP|WB_VCENTER|WB_BOTTOM)) == 0 &&
           [ +  -  +  - ]
    3223                 :        299 :             (rImageSize.Height() > rSize.Height() || ! (nWinStyle & WB_WORDBREAK) ) )
    3224                 :            :         {
    3225                 :        185 :             nTextStyle &= ~(TEXT_DRAW_TOP|TEXT_DRAW_BOTTOM);
    3226                 :        185 :             nTextStyle |= TEXT_DRAW_VCENTER;
    3227                 :        185 :             aSize.Height() = rImageSize.Height();
    3228                 :            :         }
    3229                 :            : 
    3230                 :            :         ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, 1,
    3231         [ +  - ]:        299 :                               nDrawFlags, nTextStyle, NULL );
    3232                 :        299 :         nLineY = aPos.Y() + aSize.Height()/2;
    3233                 :            : 
    3234         [ +  - ]:        299 :         rMouseRect          = Rectangle( aPos, aSize );
    3235                 :        299 :         rMouseRect.Left()   = rPos.X();
    3236                 :        299 :         rStateRect.Left()   = rPos.X();
    3237                 :        299 :         rStateRect.Top()    = rMouseRect.Top();
    3238                 :            : 
    3239         [ +  + ]:        299 :         if ( aSize.Height() > rImageSize.Height() )
    3240                 :        165 :             rStateRect.Top() += ( aSize.Height() - rImageSize.Height() ) / 2;
    3241                 :            :         else
    3242                 :            :         {
    3243                 :        134 :             rStateRect.Top() -= ( rImageSize.Height() - aSize.Height() ) / 2;
    3244         [ +  + ]:        134 :             if( rStateRect.Top() < 0 )
    3245                 :          1 :                 rStateRect.Top() = 0;
    3246                 :            :         }
    3247                 :            : 
    3248                 :        299 :         rStateRect.Right()  = rStateRect.Left()+rImageSize.Width()-1;
    3249                 :        299 :         rStateRect.Bottom() = rStateRect.Top()+rImageSize.Height()-1;
    3250         [ +  + ]:        299 :         if ( rStateRect.Bottom() > rMouseRect.Bottom() )
    3251                 :        299 :             rMouseRect.Bottom() = rStateRect.Bottom();
    3252                 :            :     }
    3253                 :            :     else
    3254                 :            :     {
    3255 [ -  + ][ #  # ]:         44 :         if ( mbLegacyNoTextAlign && ( nWinStyle & WB_CENTER ) )
    3256                 :          0 :             rStateRect.Left() = rPos.X()+((rSize.Width()-rImageSize.Width())/2);
    3257 [ -  + ][ #  # ]:         44 :         else if ( mbLegacyNoTextAlign && ( nWinStyle & WB_RIGHT ) )
    3258                 :          0 :             rStateRect.Left() = rPos.X()+rSize.Width()-rImageSize.Width();
    3259                 :            :         else
    3260                 :         44 :             rStateRect.Left() = rPos.X();
    3261         [ -  + ]:         44 :         if ( nWinStyle & WB_VCENTER )
    3262                 :          0 :             rStateRect.Top() = rPos.Y()+((rSize.Height()-rImageSize.Height())/2);
    3263         [ -  + ]:         44 :         else if ( nWinStyle & WB_BOTTOM )
    3264                 :          0 :             rStateRect.Top() = rPos.Y()+rSize.Height()-rImageSize.Height();
    3265                 :            :         else
    3266                 :         44 :             rStateRect.Top() = rPos.Y();
    3267                 :         44 :         rStateRect.Right()  = rStateRect.Left()+rImageSize.Width()-1;
    3268                 :         44 :         rStateRect.Bottom() = rStateRect.Top()+rImageSize.Height()-1;
    3269                 :            :         // provide space for focusrect
    3270                 :            :         // note: this assumes that the control's size was adjusted
    3271                 :            :         // accordingly in Get/LoseFocus, so the onscreen position won't change
    3272 [ -  + ][ +  - ]:         44 :         if( HasFocus() )
    3273         [ #  # ]:          0 :             rStateRect.Move( 1, 1 );
    3274                 :         44 :         rMouseRect          = rStateRect;
    3275                 :            : 
    3276         [ +  - ]:         44 :         ImplSetFocusRect( rStateRect );
    3277                 :            :     }
    3278                 :            : 
    3279                 :        343 :     const int nLineSpace = 4;
    3280         [ +  - ]:        343 :     if( (GetStyle() & WB_CBLINESTYLE) != 0 &&
           [ -  +  #  # ]
                 [ -  + ]
    3281                 :          0 :         rMouseRect.Right()-1-nLineSpace < rPos.X()+rSize.Width() )
    3282                 :            :     {
    3283                 :          0 :         const StyleSettings&    rStyleSettings = GetSettings().GetStyleSettings();
    3284         [ #  # ]:          0 :         if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
    3285         [ #  # ]:          0 :             SetLineColor( Color( COL_BLACK ) );
    3286                 :            :         else
    3287         [ #  # ]:          0 :             SetLineColor( rStyleSettings.GetShadowColor() );
    3288                 :          0 :         long nLineX = rMouseRect.Right()+nLineSpace;
    3289         [ #  # ]:          0 :         DrawLine( Point( nLineX, nLineY ), Point( rPos.X() + rSize.Width()-1, nLineY ) );
    3290         [ #  # ]:          0 :         if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
    3291                 :            :         {
    3292         [ #  # ]:          0 :             SetLineColor( rStyleSettings.GetLightColor() );
    3293         [ #  # ]:          0 :             DrawLine( Point( nLineX, nLineY+1 ), Point( rPos.X() + rSize.Width()-1, nLineY+1 ) );
    3294                 :            :         }
    3295                 :            :     }
    3296                 :            : 
    3297 [ +  - ][ +  - ]:        343 :     pDev->Pop();
    3298                 :        343 : }
    3299                 :            : 
    3300                 :            : // -----------------------------------------------------------------------
    3301                 :            : 
    3302                 :        343 : void CheckBox::ImplDrawCheckBox( bool bLayout )
    3303                 :            : {
    3304         [ +  - ]:        343 :     Size aImageSize = ImplGetCheckImageSize();
    3305         [ +  - ]:        343 :     aImageSize.Width()  = CalcZoom( aImageSize.Width() );
    3306         [ +  - ]:        343 :     aImageSize.Height() = CalcZoom( aImageSize.Height() );
    3307                 :            : 
    3308         [ +  - ]:        343 :     if( !bLayout )
    3309         [ +  - ]:        343 :         HideFocus();
    3310                 :            : 
    3311                 :        343 :     ImplDraw( this, 0, Point(), GetOutputSizePixel(), aImageSize,
    3312         [ +  - ]:        343 :               maStateRect, maMouseRect, bLayout );
    3313                 :            : 
    3314         [ +  - ]:        343 :     if( !bLayout )
    3315                 :            :     {
    3316         [ +  - ]:        343 :         ImplDrawCheckBoxState();
    3317 [ +  - ][ -  + ]:        343 :         if ( HasFocus() )
    3318         [ #  # ]:          0 :             ShowFocus( ImplGetFocusRect() );
    3319                 :            :     }
    3320                 :        343 : }
    3321                 :            : 
    3322                 :            : // -----------------------------------------------------------------------
    3323                 :            : 
    3324                 :          0 : void CheckBox::ImplCheck()
    3325                 :            : {
    3326                 :            :     TriState eNewState;
    3327         [ #  # ]:          0 :     if ( meState == STATE_NOCHECK )
    3328                 :          0 :         eNewState = STATE_CHECK;
    3329         [ #  # ]:          0 :     else if ( !mbTriState )
    3330                 :          0 :         eNewState = STATE_NOCHECK;
    3331         [ #  # ]:          0 :     else if ( meState == STATE_CHECK )
    3332                 :          0 :         eNewState = STATE_DONTKNOW;
    3333                 :            :     else
    3334                 :          0 :         eNewState = STATE_NOCHECK;
    3335                 :          0 :     meState = eNewState;
    3336                 :            : 
    3337         [ #  # ]:          0 :     ImplDelData aDelData;
    3338         [ #  # ]:          0 :     ImplAddDel( &aDelData );
    3339 [ #  # ][ #  # ]:          0 :     if( (GetStyle() & WB_EARLYTOGGLE) )
    3340         [ #  # ]:          0 :         Toggle();
    3341         [ #  # ]:          0 :     ImplInvalidateOrDrawCheckBoxState();
    3342 [ #  # ][ #  # ]:          0 :     if( ! (GetStyle() & WB_EARLYTOGGLE) )
    3343         [ #  # ]:          0 :         Toggle();
    3344         [ #  # ]:          0 :     if ( aDelData.IsDead() )
    3345                 :          0 :         return;
    3346         [ #  # ]:          0 :     ImplRemoveDel( &aDelData );
    3347 [ #  # ][ #  # ]:          0 :     Click();
                 [ #  # ]
    3348                 :            : }
    3349                 :            : 
    3350                 :            : // -----------------------------------------------------------------------
    3351                 :            : 
    3352                 :         74 : CheckBox::CheckBox( Window* pParent, WinBits nStyle ) :
    3353 [ +  - ][ +  - ]:         74 :     Button( WINDOW_CHECKBOX ), mbLegacyNoTextAlign( false )
                 [ +  - ]
    3354                 :            : {
    3355                 :         74 :     ImplInitCheckBoxData();
    3356         [ +  - ]:         74 :     ImplInit( pParent, nStyle );
    3357                 :         74 : }
    3358                 :            : 
    3359                 :            : // -----------------------------------------------------------------------
    3360                 :            : 
    3361                 :        102 : CheckBox::CheckBox( Window* pParent, const ResId& rResId ) :
    3362 [ +  - ][ +  - ]:        102 :     Button( WINDOW_CHECKBOX ), mbLegacyNoTextAlign( false )
                 [ +  - ]
    3363                 :            : {
    3364                 :        102 :     ImplInitCheckBoxData();
    3365                 :        102 :     rResId.SetRT( RSC_CHECKBOX );
    3366         [ +  - ]:        102 :     WinBits nStyle = ImplInitRes( rResId );
    3367         [ +  - ]:        102 :     ImplInit( pParent, nStyle );
    3368         [ +  - ]:        102 :     ImplLoadRes( rResId );
    3369                 :            : 
    3370         [ +  - ]:        102 :     if ( !(nStyle & WB_HIDE) )
    3371         [ +  - ]:        102 :         Show();
    3372                 :        102 : }
    3373                 :            : 
    3374                 :            : // -----------------------------------------------------------------------
    3375                 :            : 
    3376                 :          0 : void CheckBox::MouseButtonDown( const MouseEvent& rMEvt )
    3377                 :            : {
    3378 [ #  # ][ #  # ]:          0 :     if ( rMEvt.IsLeft() && maMouseRect.IsInside( rMEvt.GetPosPixel() ) )
                 [ #  # ]
    3379                 :            :     {
    3380                 :          0 :         ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
    3381                 :          0 :         ImplInvalidateOrDrawCheckBoxState();
    3382                 :          0 :         StartTracking();
    3383                 :          0 :         return;
    3384                 :            :     }
    3385                 :            : 
    3386                 :          0 :     Button::MouseButtonDown( rMEvt );
    3387                 :            : }
    3388                 :            : 
    3389                 :            : // -----------------------------------------------------------------------
    3390                 :            : 
    3391                 :          0 : void CheckBox::Tracking( const TrackingEvent& rTEvt )
    3392                 :            : {
    3393         [ #  # ]:          0 :     if ( rTEvt.IsTrackingEnded() )
    3394                 :            :     {
    3395         [ #  # ]:          0 :         if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
    3396                 :            :         {
    3397 [ #  # ][ #  # ]:          0 :             if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
                 [ #  # ]
    3398                 :          0 :                 GrabFocus();
    3399                 :            : 
    3400                 :          0 :             ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    3401                 :            : 
    3402                 :            :             // do not call click handler if aborted
    3403         [ #  # ]:          0 :             if ( !rTEvt.IsTrackingCanceled() )
    3404                 :          0 :                 ImplCheck();
    3405                 :            :             else
    3406                 :          0 :                 ImplInvalidateOrDrawCheckBoxState();
    3407                 :            :         }
    3408                 :            :     }
    3409                 :            :     else
    3410                 :            :     {
    3411         [ #  # ]:          0 :         if ( maMouseRect.IsInside( rTEvt.GetMouseEvent().GetPosPixel() ) )
    3412                 :            :         {
    3413         [ #  # ]:          0 :             if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
    3414                 :            :             {
    3415                 :          0 :                 ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
    3416                 :          0 :                 ImplInvalidateOrDrawCheckBoxState();
    3417                 :            :             }
    3418                 :            :         }
    3419                 :            :         else
    3420                 :            :         {
    3421         [ #  # ]:          0 :             if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
    3422                 :            :             {
    3423                 :          0 :                 ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    3424                 :          0 :                 ImplInvalidateOrDrawCheckBoxState();
    3425                 :            :             }
    3426                 :            :         }
    3427                 :            :     }
    3428                 :          0 : }
    3429                 :            : 
    3430                 :            : // -----------------------------------------------------------------------
    3431                 :            : 
    3432                 :          0 : void CheckBox::KeyInput( const KeyEvent& rKEvt )
    3433                 :            : {
    3434                 :          0 :     KeyCode aKeyCode = rKEvt.GetKeyCode();
    3435                 :            : 
    3436 [ #  # ][ #  # ]:          0 :     if ( !aKeyCode.GetModifier() && (aKeyCode.GetCode() == KEY_SPACE) )
                 [ #  # ]
    3437                 :            :     {
    3438         [ #  # ]:          0 :         if ( !(ImplGetButtonState() & BUTTON_DRAW_PRESSED) )
    3439                 :            :         {
    3440                 :          0 :             ImplGetButtonState() |= BUTTON_DRAW_PRESSED;
    3441         [ #  # ]:          0 :             ImplInvalidateOrDrawCheckBoxState();
    3442                 :            :         }
    3443                 :            :     }
    3444 [ #  # ][ #  # ]:          0 :     else if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) && (aKeyCode.GetCode() == KEY_ESCAPE) )
                 [ #  # ]
    3445                 :            :     {
    3446                 :          0 :         ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    3447         [ #  # ]:          0 :         ImplInvalidateOrDrawCheckBoxState();
    3448                 :            :     }
    3449                 :            :     else
    3450         [ #  # ]:          0 :         Button::KeyInput( rKEvt );
    3451                 :          0 : }
    3452                 :            : 
    3453                 :            : // -----------------------------------------------------------------------
    3454                 :            : 
    3455                 :          0 : void CheckBox::KeyUp( const KeyEvent& rKEvt )
    3456                 :            : {
    3457                 :          0 :     KeyCode aKeyCode = rKEvt.GetKeyCode();
    3458                 :            : 
    3459 [ #  # ][ #  # ]:          0 :     if ( (ImplGetButtonState() & BUTTON_DRAW_PRESSED) && (aKeyCode.GetCode() == KEY_SPACE) )
                 [ #  # ]
    3460                 :            :     {
    3461                 :          0 :         ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    3462         [ #  # ]:          0 :         ImplCheck();
    3463                 :            :     }
    3464                 :            :     else
    3465         [ #  # ]:          0 :         Button::KeyUp( rKEvt );
    3466                 :          0 : }
    3467                 :            : 
    3468                 :            : // -----------------------------------------------------------------------
    3469                 :            : 
    3470                 :          0 : void CheckBox::FillLayoutData() const
    3471                 :            : {
    3472         [ #  # ]:          0 :     mpControlData->mpLayoutData = new vcl::ControlLayoutData();
    3473                 :          0 :     const_cast<CheckBox*>(this)->ImplDrawCheckBox( true );
    3474                 :          0 : }
    3475                 :            : 
    3476                 :            : // -----------------------------------------------------------------------
    3477                 :            : 
    3478                 :        343 : void CheckBox::Paint( const Rectangle& )
    3479                 :            : {
    3480                 :        343 :     ImplDrawCheckBox();
    3481                 :        343 : }
    3482                 :            : 
    3483                 :            : // -----------------------------------------------------------------------
    3484                 :            : 
    3485                 :          0 : void CheckBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
    3486                 :            :                      sal_uLong nFlags )
    3487                 :            : {
    3488         [ #  # ]:          0 :     MapMode     aResMapMode( MAP_100TH_MM );
    3489         [ #  # ]:          0 :     Point       aPos  = pDev->LogicToPixel( rPos );
    3490         [ #  # ]:          0 :     Size        aSize = pDev->LogicToPixel( rSize );
    3491         [ #  # ]:          0 :     Size        aImageSize = pDev->LogicToPixel( Size( 300, 300 ), aResMapMode );
    3492         [ #  # ]:          0 :     Size        aBrd1Size = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode );
    3493         [ #  # ]:          0 :     Size        aBrd2Size = pDev->LogicToPixel( Size( 30, 30 ), aResMapMode );
    3494         [ #  # ]:          0 :     long        nCheckWidth = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode ).Width();
    3495         [ #  # ]:          0 :     Font        aFont = GetDrawPixelFont( pDev );
    3496         [ #  # ]:          0 :     Rectangle   aStateRect;
    3497         [ #  # ]:          0 :     Rectangle   aMouseRect;
    3498                 :            : 
    3499         [ #  # ]:          0 :     aImageSize.Width()  = CalcZoom( aImageSize.Width() );
    3500         [ #  # ]:          0 :     aImageSize.Height() = CalcZoom( aImageSize.Height() );
    3501         [ #  # ]:          0 :     aBrd1Size.Width()   = CalcZoom( aBrd1Size.Width() );
    3502         [ #  # ]:          0 :     aBrd1Size.Height()  = CalcZoom( aBrd1Size.Height() );
    3503         [ #  # ]:          0 :     aBrd2Size.Width()   = CalcZoom( aBrd2Size.Width() );
    3504         [ #  # ]:          0 :     aBrd2Size.Height()  = CalcZoom( aBrd2Size.Height() );
    3505                 :            : 
    3506         [ #  # ]:          0 :     if ( !aBrd1Size.Width() )
    3507                 :          0 :         aBrd1Size.Width() = 1;
    3508         [ #  # ]:          0 :     if ( !aBrd1Size.Height() )
    3509                 :          0 :         aBrd1Size.Height() = 1;
    3510         [ #  # ]:          0 :     if ( !aBrd2Size.Width() )
    3511                 :          0 :         aBrd2Size.Width() = 1;
    3512         [ #  # ]:          0 :     if ( !aBrd2Size.Height() )
    3513                 :          0 :         aBrd2Size.Height() = 1;
    3514         [ #  # ]:          0 :     if ( !nCheckWidth )
    3515                 :          0 :         nCheckWidth = 1;
    3516                 :            : 
    3517         [ #  # ]:          0 :     pDev->Push();
    3518         [ #  # ]:          0 :     pDev->SetMapMode();
    3519         [ #  # ]:          0 :     pDev->SetFont( aFont );
    3520         [ #  # ]:          0 :     if ( nFlags & WINDOW_DRAW_MONO )
    3521         [ #  # ]:          0 :         pDev->SetTextColor( Color( COL_BLACK ) );
    3522                 :            :     else
    3523         [ #  # ]:          0 :         pDev->SetTextColor( GetTextColor() );
    3524         [ #  # ]:          0 :     pDev->SetTextFillColor();
    3525                 :            : 
    3526                 :            :     ImplDraw( pDev, nFlags, aPos, aSize,
    3527         [ #  # ]:          0 :               aImageSize, aStateRect, aMouseRect, false );
    3528                 :            : 
    3529         [ #  # ]:          0 :     pDev->SetLineColor();
    3530         [ #  # ]:          0 :     pDev->SetFillColor( Color( COL_BLACK ) );
    3531         [ #  # ]:          0 :     pDev->DrawRect( aStateRect );
    3532                 :          0 :     aStateRect.Left()   += aBrd1Size.Width();
    3533                 :          0 :     aStateRect.Top()    += aBrd1Size.Height();
    3534                 :          0 :     aStateRect.Right()  -= aBrd1Size.Width();
    3535                 :          0 :     aStateRect.Bottom() -= aBrd1Size.Height();
    3536         [ #  # ]:          0 :     if ( meState == STATE_DONTKNOW )
    3537         [ #  # ]:          0 :         pDev->SetFillColor( Color( COL_LIGHTGRAY ) );
    3538                 :            :     else
    3539         [ #  # ]:          0 :         pDev->SetFillColor( Color( COL_WHITE ) );
    3540         [ #  # ]:          0 :     pDev->DrawRect( aStateRect );
    3541                 :            : 
    3542         [ #  # ]:          0 :     if ( meState == STATE_CHECK )
    3543                 :            :     {
    3544                 :          0 :         aStateRect.Left()   += aBrd2Size.Width();
    3545                 :          0 :         aStateRect.Top()    += aBrd2Size.Height();
    3546                 :          0 :         aStateRect.Right()  -= aBrd2Size.Width();
    3547                 :          0 :         aStateRect.Bottom() -= aBrd2Size.Height();
    3548                 :          0 :         Point   aPos11( aStateRect.TopLeft() );
    3549         [ #  # ]:          0 :         Point   aPos12( aStateRect.BottomRight() );
    3550         [ #  # ]:          0 :         Point   aPos21( aStateRect.TopRight() );
    3551         [ #  # ]:          0 :         Point   aPos22( aStateRect.BottomLeft() );
    3552                 :          0 :         Point   aTempPos11( aPos11 );
    3553                 :          0 :         Point   aTempPos12( aPos12 );
    3554                 :          0 :         Point   aTempPos21( aPos21 );
    3555                 :          0 :         Point   aTempPos22( aPos22 );
    3556         [ #  # ]:          0 :         pDev->SetLineColor( Color( COL_BLACK ) );
    3557                 :          0 :         long nDX = 0;
    3558         [ #  # ]:          0 :         for ( long i = 0; i < nCheckWidth; i++ )
    3559                 :            :         {
    3560         [ #  # ]:          0 :             if ( !(i % 2) )
    3561                 :            :             {
    3562                 :          0 :                 aTempPos11.X() = aPos11.X()+nDX;
    3563                 :          0 :                 aTempPos12.X() = aPos12.X()+nDX;
    3564                 :          0 :                 aTempPos21.X() = aPos21.X()+nDX;
    3565                 :          0 :                 aTempPos22.X() = aPos22.X()+nDX;
    3566                 :            :             }
    3567                 :            :             else
    3568                 :            :             {
    3569                 :          0 :                 nDX++;
    3570                 :          0 :                 aTempPos11.X() = aPos11.X()-nDX;
    3571                 :          0 :                 aTempPos12.X() = aPos12.X()-nDX;
    3572                 :          0 :                 aTempPos21.X() = aPos21.X()-nDX;
    3573                 :          0 :                 aTempPos22.X() = aPos22.X()-nDX;
    3574                 :            :             }
    3575         [ #  # ]:          0 :             pDev->DrawLine( aTempPos11, aTempPos12 );
    3576         [ #  # ]:          0 :             pDev->DrawLine( aTempPos21, aTempPos22 );
    3577                 :            :         }
    3578                 :            :     }
    3579                 :            : 
    3580 [ #  # ][ #  # ]:          0 :     pDev->Pop();
                 [ #  # ]
    3581                 :          0 : }
    3582                 :            : 
    3583                 :            : // -----------------------------------------------------------------------
    3584                 :            : 
    3585                 :        382 : void CheckBox::Resize()
    3586                 :            : {
    3587                 :        382 :     Control::Resize();
    3588                 :        382 :     Invalidate();
    3589                 :        382 : }
    3590                 :            : 
    3591                 :            : // -----------------------------------------------------------------------
    3592                 :            : 
    3593                 :          0 : void CheckBox::GetFocus()
    3594                 :            : {
    3595 [ #  # ][ #  # ]:          0 :     if ( !GetText().Len() || (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    3596                 :            :     {
    3597                 :            :         // increase button size to have space for focus rect
    3598                 :            :         // checkboxes without text will draw focusrect around the check
    3599                 :            :         // See CheckBox::ImplDraw()
    3600         [ #  # ]:          0 :         Point aPos( GetPosPixel() );
    3601         [ #  # ]:          0 :         Size aSize( GetSizePixel() );
    3602                 :          0 :         aPos.Move(-1,-1);
    3603                 :          0 :         aSize.Height() += 2;
    3604                 :          0 :         aSize.Width() += 2;
    3605         [ #  # ]:          0 :         SetPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height(), WINDOW_POSSIZE_ALL );
    3606         [ #  # ]:          0 :         ImplDrawCheckBox();
    3607                 :            :     }
    3608                 :            :     else
    3609                 :          0 :         ShowFocus( ImplGetFocusRect() );
    3610                 :            : 
    3611         [ #  # ]:          0 :     SetInputContext( InputContext( GetFont() ) );
    3612                 :          0 :     Button::GetFocus();
    3613                 :          0 : }
    3614                 :            : 
    3615                 :            : // -----------------------------------------------------------------------
    3616                 :            : 
    3617                 :          0 : void CheckBox::LoseFocus()
    3618                 :            : {
    3619         [ #  # ]:          0 :     if ( ImplGetButtonState() & BUTTON_DRAW_PRESSED )
    3620                 :            :     {
    3621                 :          0 :         ImplGetButtonState() &= ~BUTTON_DRAW_PRESSED;
    3622                 :          0 :         ImplInvalidateOrDrawCheckBoxState();
    3623                 :            :     }
    3624                 :            : 
    3625                 :          0 :     HideFocus();
    3626                 :          0 :     Button::LoseFocus();
    3627                 :            : 
    3628 [ #  # ][ #  # ]:          0 :     if ( !GetText().Len() || (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    3629                 :            :     {
    3630                 :            :         // decrease button size again (see GetFocus())
    3631                 :            :         // checkboxes without text will draw focusrect around the check
    3632         [ #  # ]:          0 :         Point aPos( GetPosPixel() );
    3633         [ #  # ]:          0 :         Size aSize( GetSizePixel() );
    3634                 :          0 :         aPos.Move(1,1);
    3635                 :          0 :         aSize.Height() -= 2;
    3636                 :          0 :         aSize.Width() -= 2;
    3637         [ #  # ]:          0 :         SetPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height(), WINDOW_POSSIZE_ALL );
    3638         [ #  # ]:          0 :         ImplDrawCheckBox();
    3639                 :            :     }
    3640                 :          0 : }
    3641                 :            : 
    3642                 :            : // -----------------------------------------------------------------------
    3643                 :            : 
    3644                 :       1407 : void CheckBox::StateChanged( StateChangedType nType )
    3645                 :            : {
    3646                 :       1407 :     Button::StateChanged( nType );
    3647                 :            : 
    3648         [ +  + ]:       1407 :     if ( nType == STATE_CHANGE_STATE )
    3649                 :            :     {
    3650 [ +  + ][ +  - ]:         52 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ +  + ]
    3651                 :         24 :             Invalidate( maStateRect );
    3652                 :            :     }
    3653 [ +  + ][ +  + ]:       1355 :     else if ( (nType == STATE_CHANGE_ENABLE) ||
         [ +  - ][ +  + ]
                 [ -  + ]
    3654                 :            :               (nType == STATE_CHANGE_TEXT) ||
    3655                 :            :               (nType == STATE_CHANGE_IMAGE) ||
    3656                 :            :               (nType == STATE_CHANGE_DATA) ||
    3657                 :            :               (nType == STATE_CHANGE_UPDATEMODE) )
    3658                 :            :     {
    3659         [ +  - ]:        692 :         if ( IsUpdateMode() )
    3660                 :        346 :             Invalidate();
    3661                 :            :     }
    3662         [ +  + ]:       1009 :     else if ( nType == STATE_CHANGE_STYLE )
    3663                 :            :     {
    3664                 :         78 :         SetStyle( ImplInitStyle( GetWindow( WINDOW_PREV ), GetStyle() ) );
    3665                 :            : 
    3666         [ +  + ]:        156 :         if ( (GetPrevStyle() & CHECKBOX_VIEW_STYLE) !=
    3667                 :         78 :              (GetStyle() & CHECKBOX_VIEW_STYLE) )
    3668                 :            :         {
    3669         [ +  - ]:         10 :             if ( IsUpdateMode() )
    3670                 :         10 :                 Invalidate();
    3671                 :            :         }
    3672                 :            :     }
    3673 [ +  - ][ +  + ]:        931 :     else if ( (nType == STATE_CHANGE_ZOOM) ||
    3674                 :            :               (nType == STATE_CHANGE_CONTROLFONT) )
    3675                 :            :     {
    3676                 :        145 :         ImplInitSettings( sal_True, sal_False, sal_False );
    3677                 :        145 :         Invalidate();
    3678                 :            :     }
    3679         [ -  + ]:        786 :     else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
    3680                 :            :     {
    3681                 :          0 :         ImplInitSettings( sal_False, sal_True, sal_False );
    3682                 :          0 :         Invalidate();
    3683                 :            :     }
    3684         [ -  + ]:        786 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
    3685                 :            :     {
    3686                 :          0 :         ImplInitSettings( sal_False, sal_False, sal_True );
    3687                 :          0 :         Invalidate();
    3688                 :            :     }
    3689                 :       1407 : }
    3690                 :            : 
    3691                 :            : // -----------------------------------------------------------------------
    3692                 :            : 
    3693                 :        378 : void CheckBox::DataChanged( const DataChangedEvent& rDCEvt )
    3694                 :            : {
    3695                 :        378 :     Button::DataChanged( rDCEvt );
    3696                 :            : 
    3697 [ +  - ][ +  -  :       1512 :     if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
          +  -  +  -  +  
                      - ]
    3698                 :        378 :          (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
    3699                 :        378 :          ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
    3700                 :        378 :           (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
    3701                 :            :     {
    3702                 :        378 :         ImplInitSettings( sal_True, sal_True, sal_True );
    3703                 :        378 :         Invalidate();
    3704                 :            :     }
    3705                 :        378 : }
    3706                 :            : 
    3707                 :            : // -----------------------------------------------------------------------
    3708                 :            : 
    3709                 :          0 : long CheckBox::PreNotify( NotifyEvent& rNEvt )
    3710                 :            : {
    3711                 :          0 :     long nDone = 0;
    3712                 :          0 :     const MouseEvent* pMouseEvt = NULL;
    3713                 :            : 
    3714 [ #  # ][ #  # ]:          0 :     if( (rNEvt.GetType() == EVENT_MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != NULL )
                 [ #  # ]
    3715                 :            :     {
    3716 [ #  # ][ #  # ]:          0 :         if( !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
         [ #  # ][ #  # ]
    3717                 :            :         {
    3718                 :            :             // trigger redraw if mouse over state has changed
    3719         [ #  # ]:          0 :             if( IsNativeControlSupported(CTRL_CHECKBOX, PART_ENTIRE_CONTROL) )
    3720                 :            :             {
    3721 [ #  # ][ #  # ]:          0 :                 if( ( maMouseRect.IsInside( GetPointerPosPixel()) &&
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    3722 [ #  # ][ #  # ]:          0 :                      !maMouseRect.IsInside( GetLastPointerPosPixel()) ) ||
         [ #  # ][ #  # ]
    3723 [ #  # ][ #  # ]:          0 :                     ( maMouseRect.IsInside( GetLastPointerPosPixel()) &&
         [ #  # ][ #  # ]
    3724 [ #  # ][ #  # ]:          0 :                      !maMouseRect.IsInside( GetPointerPosPixel()) ) ||
         [ #  # ][ #  # ]
    3725                 :          0 :                     pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow() )
    3726                 :            :                 {
    3727                 :          0 :                     Invalidate( maStateRect );
    3728                 :            :                 }
    3729                 :            :             }
    3730                 :            :         }
    3731                 :            :     }
    3732                 :            : 
    3733         [ #  # ]:          0 :     return nDone ? nDone : Button::PreNotify(rNEvt);
    3734                 :            : }
    3735                 :            : 
    3736                 :            : // -----------------------------------------------------------------------
    3737                 :            : 
    3738                 :        114 : void CheckBox::Toggle()
    3739                 :            : {
    3740                 :        114 :     ImplCallEventListenersAndHandler( VCLEVENT_CHECKBOX_TOGGLE, maToggleHdl, this );
    3741                 :        114 : }
    3742                 :            : 
    3743                 :            : // -----------------------------------------------------------------------
    3744                 :            : 
    3745                 :        164 : void CheckBox::SetState( TriState eState )
    3746                 :            : {
    3747 [ +  + ][ +  + ]:        164 :     if ( !mbTriState && (eState == STATE_DONTKNOW) )
    3748                 :          8 :         eState = STATE_NOCHECK;
    3749                 :            : 
    3750         [ +  + ]:        164 :     if ( meState != eState )
    3751                 :            :     {
    3752                 :         52 :         meState = eState;
    3753                 :         52 :         StateChanged( STATE_CHANGE_STATE );
    3754                 :         52 :         Toggle();
    3755                 :            :     }
    3756                 :        164 : }
    3757                 :            : 
    3758                 :            : // -----------------------------------------------------------------------
    3759                 :            : 
    3760                 :         92 : void CheckBox::EnableTriState( sal_Bool bTriState )
    3761                 :            : {
    3762         [ +  + ]:         92 :     if ( mbTriState != bTriState )
    3763                 :            :     {
    3764                 :         70 :         mbTriState = bTriState;
    3765                 :            : 
    3766 [ +  + ][ -  + ]:         70 :         if ( !bTriState && (meState == STATE_DONTKNOW) )
    3767                 :          0 :             SetState( STATE_NOCHECK );
    3768                 :            :     }
    3769                 :         92 : }
    3770                 :            : 
    3771                 :            : // -----------------------------------------------------------------------
    3772                 :            : 
    3773                 :        299 : long CheckBox::ImplGetImageToTextDistance() const
    3774                 :            : {
    3775                 :            :     // 4 pixels, but take zoom into account, so the text doesn't "jump" relative to surrounding elements,
    3776                 :            :     // which might have been aligned with the text of the check box
    3777                 :        299 :     return CalcZoom( 4 );
    3778                 :            : }
    3779                 :            : 
    3780                 :            : // -----------------------------------------------------------------------
    3781                 :            : 
    3782                 :        355 : Size CheckBox::ImplGetCheckImageSize() const
    3783                 :            : {
    3784                 :        355 :     Size aSize;
    3785                 :            :     // why are IsNativeControlSupported and GetNativeControlRegion not const ?
    3786                 :        355 :     CheckBox* pThis = const_cast<CheckBox*>(this);
    3787                 :        355 :     bool bDefaultSize = true;
    3788         [ -  + ]:        355 :     if( pThis->IsNativeControlSupported( CTRL_CHECKBOX, PART_ENTIRE_CONTROL ) )
    3789                 :            :     {
    3790                 :          0 :         ImplControlValue aControlValue;
    3791                 :            :         // #i45896# workaround gcc3.3 temporary problem
    3792 [ #  # ][ #  # ]:          0 :         Rectangle        aCtrlRegion( Point( 0, 0 ), GetSizePixel() );
    3793                 :          0 :         ControlState     nState = CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED;
    3794 [ #  # ][ #  # ]:          0 :         Rectangle aBoundingRgn, aContentRgn;
    3795                 :            : 
    3796                 :            :         // get native size of a check box
    3797         [ #  # ]:          0 :         if( pThis->GetNativeControlRegion( CTRL_CHECKBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
    3798                 :            :                                            nState, aControlValue, rtl::OUString(),
    3799         [ #  # ]:          0 :                                            aBoundingRgn, aContentRgn ) )
    3800                 :            :         {
    3801         [ #  # ]:          0 :             aSize = aContentRgn.GetSize();
    3802                 :          0 :             bDefaultSize = false;
    3803         [ #  # ]:          0 :         }
    3804                 :            :     }
    3805         [ +  - ]:        355 :     if( bDefaultSize )
    3806         [ +  - ]:        355 :         aSize = GetCheckImage( GetSettings(), 0 ).GetSizePixel();
    3807                 :        355 :     return aSize;
    3808                 :            : }
    3809                 :            : 
    3810                 :        698 : Image CheckBox::GetCheckImage( const AllSettings& rSettings, sal_uInt16 nFlags )
    3811                 :            : {
    3812                 :        698 :     ImplSVData*             pSVData = ImplGetSVData();
    3813                 :        698 :     const StyleSettings&    rStyleSettings = rSettings.GetStyleSettings();
    3814                 :        698 :     sal_uInt16              nStyle = 0;
    3815                 :            : 
    3816         [ +  + ]:        698 :     if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
    3817                 :        284 :         nStyle = STYLE_CHECKBOX_MONO;
    3818                 :            : 
    3819 [ +  + ][ +  +  :       2720 :     if ( !pSVData->maCtrlData.mpCheckImgList ||
          +  -  +  -  -  
              + ][ +  + ]
    3820                 :            :          (pSVData->maCtrlData.mnCheckStyle != nStyle) ||
    3821                 :        674 :          (pSVData->maCtrlData.mnLastCheckFColor != rStyleSettings.GetFaceColor().GetColor()) ||
    3822                 :        674 :          (pSVData->maCtrlData.mnLastCheckWColor != rStyleSettings.GetWindowColor().GetColor()) ||
    3823                 :        674 :          (pSVData->maCtrlData.mnLastCheckLColor != rStyleSettings.GetLightColor().GetColor()) )
    3824                 :            :     {
    3825         [ +  + ]:         24 :         if ( pSVData->maCtrlData.mpCheckImgList )
    3826         [ +  - ]:         12 :             delete pSVData->maCtrlData.mpCheckImgList;
    3827                 :            : 
    3828                 :         24 :         pSVData->maCtrlData.mnLastCheckFColor = rStyleSettings.GetFaceColor().GetColor();
    3829                 :         24 :         pSVData->maCtrlData.mnLastCheckWColor = rStyleSettings.GetWindowColor().GetColor();
    3830                 :         24 :         pSVData->maCtrlData.mnLastCheckLColor = rStyleSettings.GetLightColor().GetColor();
    3831                 :            : 
    3832                 :         24 :         ResMgr* pResMgr = ImplGetResMgr();
    3833         [ +  - ]:         24 :         pSVData->maCtrlData.mpCheckImgList = new ImageList();
    3834         [ +  - ]:         24 :         if( pResMgr )
    3835                 :            :         LoadThemedImageList( rStyleSettings,
    3836                 :            :                  pSVData->maCtrlData.mpCheckImgList,
    3837         [ +  - ]:         24 :                  ResId( SV_RESID_BITMAP_CHECK+nStyle, *pResMgr ), 9 );
    3838                 :         24 :         pSVData->maCtrlData.mnCheckStyle = nStyle;
    3839                 :            :     }
    3840                 :            : 
    3841                 :            :     sal_uInt16 nId;
    3842         [ +  + ]:        698 :     if ( nFlags & BUTTON_DRAW_DISABLED )
    3843                 :            :     {
    3844         [ +  + ]:        176 :         if ( nFlags & BUTTON_DRAW_DONTKNOW )
    3845                 :          4 :             nId = 9;
    3846         [ +  + ]:        172 :         else if ( nFlags & BUTTON_DRAW_CHECKED )
    3847                 :         43 :             nId = 6;
    3848                 :            :         else
    3849                 :        129 :             nId = 5;
    3850                 :            :     }
    3851         [ -  + ]:        522 :     else if ( nFlags & BUTTON_DRAW_PRESSED )
    3852                 :            :     {
    3853         [ #  # ]:          0 :         if ( nFlags & BUTTON_DRAW_DONTKNOW )
    3854                 :          0 :             nId = 8;
    3855         [ #  # ]:          0 :         else if ( nFlags & BUTTON_DRAW_CHECKED )
    3856                 :          0 :             nId = 4;
    3857                 :            :         else
    3858                 :          0 :             nId = 3;
    3859                 :            :     }
    3860                 :            :     else
    3861                 :            :     {
    3862         [ +  + ]:        522 :         if ( nFlags & BUTTON_DRAW_DONTKNOW )
    3863                 :         64 :             nId = 7;
    3864         [ +  + ]:        458 :         else if ( nFlags & BUTTON_DRAW_CHECKED )
    3865                 :         10 :             nId = 2;
    3866                 :            :         else
    3867                 :        448 :             nId = 1;
    3868                 :            :     }
    3869                 :        698 :     return pSVData->maCtrlData.mpCheckImgList->GetImage( nId );
    3870                 :            : }
    3871                 :            : 
    3872                 :            : // -----------------------------------------------------------------------
    3873                 :            : 
    3874                 :          0 : void CheckBox::ImplSetMinimumNWFSize()
    3875                 :            : {
    3876         [ #  # ]:          0 :     Push( PUSH_MAPMODE );
    3877 [ #  # ][ #  # ]:          0 :     SetMapMode( MAP_PIXEL );
                 [ #  # ]
    3878                 :            : 
    3879                 :          0 :     ImplControlValue aControlValue;
    3880         [ #  # ]:          0 :     Size aCurSize( GetSizePixel() );
    3881         [ #  # ]:          0 :     Rectangle aCtrlRegion( Point( 0, 0 ), aCurSize );
    3882 [ #  # ][ #  # ]:          0 :     Rectangle aBoundingRgn, aContentRgn;
    3883                 :            : 
    3884                 :            :     // get native size of a radiobutton
    3885         [ #  # ]:          0 :     if( GetNativeControlRegion( CTRL_CHECKBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
    3886                 :            :                                 CTRL_STATE_DEFAULT|CTRL_STATE_ENABLED, aControlValue, rtl::OUString(),
    3887         [ #  # ]:          0 :                                 aBoundingRgn, aContentRgn ) )
    3888                 :            :     {
    3889         [ #  # ]:          0 :         Size aSize = aContentRgn.GetSize();
    3890                 :            : 
    3891         [ #  # ]:          0 :         if( aSize.Height() > aCurSize.Height() )
    3892                 :            :         {
    3893                 :          0 :             aCurSize.Height() = aSize.Height();
    3894         [ #  # ]:          0 :             SetSizePixel( aCurSize );
    3895                 :            :         }
    3896                 :            :     }
    3897                 :            : 
    3898 [ #  # ][ #  # ]:          0 :     Pop();
    3899                 :          0 : }
    3900                 :            : 
    3901                 :            : // -----------------------------------------------------------------------
    3902                 :            : 
    3903                 :         12 : Size CheckBox::CalcMinimumSize( long nMaxWidth ) const
    3904                 :            : {
    3905         [ +  - ]:         12 :     Size aSize = ImplGetCheckImageSize();
    3906                 :         12 :     nMaxWidth -= aSize.Width();
    3907                 :            : 
    3908         [ +  - ]:         12 :     XubString aText = GetText();
    3909 [ -  + ][ #  # ]:         12 :     if ( aText.Len() && ! (ImplGetButtonState() & BUTTON_DRAW_NOTEXT) )
                 [ -  + ]
    3910                 :            :     {
    3911                 :            :         // subtract what will be added later
    3912                 :          0 :         nMaxWidth-=2;
    3913         [ #  # ]:          0 :         nMaxWidth -= ImplGetImageToTextDistance();
    3914                 :            : 
    3915                 :            :         Size aTextSize = GetTextRect( Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
    3916 [ #  # ][ #  # ]:          0 :                                       aText, FixedText::ImplGetTextStyle( GetStyle() ) ).GetSize();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3917                 :          0 :         aSize.Width()+=2;    // for focus rect
    3918         [ #  # ]:          0 :         aSize.Width() += ImplGetImageToTextDistance();
    3919                 :          0 :         aSize.Width() += aTextSize.Width();
    3920         [ #  # ]:          0 :         if ( aSize.Height() < aTextSize.Height() )
    3921                 :          0 :             aSize.Height() = aTextSize.Height();
    3922                 :            :     }
    3923                 :            :     else
    3924                 :            :     {
    3925                 :            :         // is this still correct ? since the checkbox now
    3926                 :            :         // shows a focus rect it should be 2 pixels wider and longer
    3927                 :            : /* da ansonsten im Writer die Control zu weit oben haengen
    3928                 :            :         aSize.Width() += 2;
    3929                 :            :         aSize.Height() += 2;
    3930                 :            : */
    3931                 :            :     }
    3932                 :            : 
    3933 [ +  - ][ +  - ]:         12 :     return CalcWindowSize( aSize );
    3934                 :            : }
    3935                 :            : 
    3936                 :            : // -----------------------------------------------------------------------
    3937                 :            : 
    3938                 :          0 : Size CheckBox::GetOptimalSize(WindowSizeType eType) const
    3939                 :            : {
    3940         [ #  # ]:          0 :     switch (eType) {
    3941                 :            :     case WINDOWSIZE_MINIMUM:
    3942                 :          0 :         return CalcMinimumSize();
    3943                 :            :     default:
    3944                 :          0 :         return Button::GetOptimalSize( eType );
    3945                 :            :     }
    3946                 :            : }
    3947                 :            : 
    3948                 :            : // =======================================================================
    3949                 :            : 
    3950                 :        443 : ImageButton::ImageButton( Window* pParent, WinBits nStyle ) :
    3951                 :        443 :     PushButton( pParent, nStyle )
    3952                 :            : {
    3953         [ +  - ]:        443 :     ImplInitStyle();
    3954                 :        443 : }
    3955                 :            : 
    3956                 :            : // -----------------------------------------------------------------------
    3957                 :            : 
    3958                 :       3954 : ImageButton::ImageButton( Window* pParent, const ResId& rResId ) :
    3959                 :       3954 :     PushButton( pParent, rResId.SetRT( RSC_IMAGEBUTTON ) )
    3960                 :            : {
    3961         [ +  - ]:       3954 :     sal_uLong nObjMask = ReadLongRes();
    3962                 :            : 
    3963         [ -  + ]:       3954 :     if ( RSC_IMAGEBUTTON_IMAGE & nObjMask )
    3964                 :            :     {
    3965 [ #  # ][ #  # ]:          0 :         SetModeImage( Image( ResId( (RSHEADER_TYPE*)GetClassRes(), *rResId.GetResMgr() ) ) );
         [ #  # ][ #  # ]
    3966 [ #  # ][ #  # ]:          0 :         IncrementRes( GetObjSizeRes( (RSHEADER_TYPE*)GetClassRes() ) );
                 [ #  # ]
    3967                 :            :     }
    3968                 :            : 
    3969         [ +  + ]:       3954 :     if ( RSC_IMAGEBUTTON_SYMBOL & nObjMask )
    3970 [ +  - ][ +  - ]:       2636 :         SetSymbol( (SymbolType)ReadLongRes() );
    3971                 :            : 
    3972         [ -  + ]:       3954 :     if ( RSC_IMAGEBUTTON_STATE & nObjMask )
    3973 [ #  # ][ #  # ]:          0 :         SetState( (TriState)ReadLongRes() );
    3974                 :            : 
    3975         [ +  - ]:       3954 :     ImplInitStyle();
    3976                 :       3954 : }
    3977                 :            : 
    3978                 :            : // -----------------------------------------------------------------------
    3979                 :            : 
    3980                 :       4132 : ImageButton::~ImageButton()
    3981                 :            : {
    3982         [ -  + ]:       4132 : }
    3983                 :            : 
    3984                 :            : // -----------------------------------------------------------------------
    3985                 :       4397 : void ImageButton::ImplInitStyle()
    3986                 :            : {
    3987                 :       4397 :     WinBits nStyle = GetStyle();
    3988                 :            : 
    3989         [ +  + ]:       4397 :     if ( ! ( nStyle & ( WB_RIGHT | WB_LEFT ) ) )
    3990                 :       4383 :         nStyle |= WB_CENTER;
    3991                 :            : 
    3992         [ +  - ]:       4397 :     if ( ! ( nStyle & ( WB_TOP | WB_BOTTOM ) ) )
    3993                 :       4397 :         nStyle |= WB_VCENTER;
    3994                 :            : 
    3995                 :       4397 :     SetStyle( nStyle );
    3996                 :       4397 : }
    3997                 :            : 
    3998                 :            : // =======================================================================
    3999                 :            : 
    4000                 :          0 : ImageRadioButton::ImageRadioButton( Window* pParent, WinBits nStyle ) :
    4001                 :          0 :     RadioButton( pParent, nStyle )
    4002                 :            : {
    4003                 :          0 : }
    4004                 :            : 
    4005                 :            : // -----------------------------------------------------------------------
    4006                 :            : 
    4007                 :          0 : ImageRadioButton::ImageRadioButton( Window* pParent, const ResId& rResId ) :
    4008                 :          0 :     RadioButton( pParent, rResId.SetRT( RSC_IMAGERADIOBUTTON ) )
    4009                 :            : {
    4010         [ #  # ]:          0 :     sal_uLong nObjMask = ReadLongRes();
    4011                 :            : 
    4012         [ #  # ]:          0 :     if ( RSC_IMAGERADIOBUTTON_IMAGE & nObjMask )
    4013                 :            :     {
    4014 [ #  # ][ #  # ]:          0 :         SetModeRadioImage( Image( ResId( (RSHEADER_TYPE*)GetClassRes(), *rResId.GetResMgr() ) ) );
         [ #  # ][ #  # ]
    4015 [ #  # ][ #  # ]:          0 :         IncrementRes( GetObjSizeRes( (RSHEADER_TYPE*)GetClassRes() ) );
                 [ #  # ]
    4016                 :            :     }
    4017                 :          0 : }
    4018                 :            : 
    4019                 :            : // -----------------------------------------------------------------------
    4020                 :            : 
    4021                 :          0 : ImageRadioButton::~ImageRadioButton()
    4022                 :            : {
    4023         [ #  # ]:          0 : }
    4024                 :            : 
    4025                 :            : // =======================================================================
    4026                 :            : 
    4027                 :         40 : TriStateBox::TriStateBox( Window* pParent, WinBits nStyle ) :
    4028                 :         40 :     CheckBox( pParent, nStyle )
    4029                 :            : {
    4030         [ +  - ]:         40 :     EnableTriState( sal_True );
    4031                 :         40 : }
    4032                 :            : 
    4033                 :            : // -----------------------------------------------------------------------
    4034                 :            : 
    4035                 :          0 : TriStateBox::TriStateBox( Window* pParent, const ResId& rResId ) :
    4036                 :          0 :     CheckBox( pParent, rResId.SetRT( RSC_TRISTATEBOX ) )
    4037                 :            : {
    4038         [ #  # ]:          0 :     EnableTriState( sal_True );
    4039                 :            : 
    4040         [ #  # ]:          0 :     sal_uLong  nTriState        = ReadLongRes();
    4041         [ #  # ]:          0 :     sal_uInt16 bDisableTriState = ReadShortRes();
    4042                 :            :     //anderer Wert als Default ?
    4043         [ #  # ]:          0 :     if ( (TriState)nTriState != STATE_NOCHECK )
    4044         [ #  # ]:          0 :         SetState( (TriState)nTriState );
    4045         [ #  # ]:          0 :     if ( bDisableTriState )
    4046         [ #  # ]:          0 :         EnableTriState( sal_False );
    4047                 :          0 : }
    4048                 :            : 
    4049                 :            : // -----------------------------------------------------------------------
    4050                 :            : 
    4051                 :         40 : TriStateBox::~TriStateBox()
    4052                 :            : {
    4053         [ -  + ]:         80 : }
    4054                 :            : 
    4055                 :            : // =======================================================================
    4056                 :            : 
    4057                 :          0 : DisclosureButton::DisclosureButton( Window* pParent, const ResId& rResId ) :
    4058                 :          0 :     CheckBox( pParent, rResId.SetRT( RSC_CHECKBOX ) )
    4059                 :            : {
    4060                 :          0 : }
    4061                 :            : 
    4062                 :            : // -----------------------------------------------------------------------
    4063                 :            : 
    4064                 :          0 : void DisclosureButton::ImplDrawCheckBoxState()
    4065                 :            : {
    4066                 :            :     /* HACK: DisclosureButton is currently assuming, that the disclosure sign
    4067                 :            :        will fit into the rectangle occupied by a normal checkbox on all themes.
    4068                 :            :        If this does not hold true for some theme, ImplGetCheckImageSize
    4069                 :            :        would have to be overloaded for DisclosureButton; also GetNativeControlRegion
    4070                 :            :        for CTRL_LISTNODE would have to be implemented and taken into account
    4071                 :            :     */
    4072                 :            : 
    4073                 :          0 :     Rectangle aStateRect( GetStateRect() );
    4074                 :            : 
    4075         [ #  # ]:          0 :     ImplControlValue    aControlValue( GetState() == STATE_CHECK ? BUTTONVALUE_ON : BUTTONVALUE_OFF );
    4076                 :          0 :     Rectangle           aCtrlRegion( aStateRect );
    4077                 :          0 :     ControlState        nState = 0;
    4078                 :            : 
    4079 [ #  # ][ #  # ]:          0 :     if ( HasFocus() )                       nState |= CTRL_STATE_FOCUSED;
    4080         [ #  # ]:          0 :     if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT )   nState |= CTRL_STATE_DEFAULT;
    4081 [ #  # ][ #  # ]:          0 :     if ( Window::IsEnabled() )              nState |= CTRL_STATE_ENABLED;
    4082 [ #  # ][ #  # ]:          0 :     if ( IsMouseOver() && GetMouseRect().IsInside( GetPointerPosPixel() ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    4083                 :          0 :         nState |= CTRL_STATE_ROLLOVER;
    4084                 :            : 
    4085         [ #  # ]:          0 :     if( ! DrawNativeControl( CTRL_LISTNODE, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
    4086         [ #  # ]:          0 :                            aControlValue, rtl::OUString() ) )
    4087                 :            :     {
    4088         [ #  # ]:          0 :         ImplSVCtrlData& rCtrlData( ImplGetSVData()->maCtrlData );
    4089         [ #  # ]:          0 :         if( ! rCtrlData.mpDisclosurePlus )
    4090 [ #  # ][ #  # ]:          0 :             rCtrlData.mpDisclosurePlus = new Image( BitmapEx( VclResId( SV_DISCLOSURE_PLUS ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    4091         [ #  # ]:          0 :         if( ! rCtrlData.mpDisclosureMinus )
    4092 [ #  # ][ #  # ]:          0 :             rCtrlData.mpDisclosureMinus = new Image( BitmapEx( VclResId( SV_DISCLOSURE_MINUS ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    4093                 :            : 
    4094                 :          0 :         Image* pImg = NULL;
    4095 [ #  # ][ #  # ]:          0 :         pImg = IsChecked() ? rCtrlData.mpDisclosureMinus : rCtrlData.mpDisclosurePlus;
    4096                 :            : 
    4097                 :            :         DBG_ASSERT( pImg, "no disclosure image" );
    4098         [ #  # ]:          0 :         if( ! pImg )
    4099                 :          0 :             return;
    4100                 :            : 
    4101                 :          0 :         sal_uInt16 nStyle = 0;
    4102 [ #  # ][ #  # ]:          0 :         if( ! IsEnabled() )
    4103                 :          0 :             nStyle |= IMAGE_DRAW_DISABLE;
    4104                 :            : 
    4105         [ #  # ]:          0 :         Size aSize( aStateRect.GetSize() );
    4106         [ #  # ]:          0 :         Size aImgSize( pImg->GetSizePixel() );
    4107                 :          0 :         Point aOff( (aSize.Width() - aImgSize.Width())/2,
    4108                 :          0 :                     (aSize.Height() - aImgSize.Height())/2 );
    4109                 :          0 :         aOff += aStateRect.TopLeft();
    4110         [ #  # ]:          0 :         DrawImage( aOff, *pImg, nStyle );
    4111 [ #  # ][ #  # ]:          0 :     }
    4112                 :            : }
    4113                 :            : 
    4114                 :            : // -----------------------------------------------------------------------
    4115                 :            : 
    4116                 :          0 : void DisclosureButton::KeyInput( const KeyEvent& rKEvt )
    4117                 :            : {
    4118                 :          0 :     KeyCode aKeyCode = rKEvt.GetKeyCode();
    4119                 :            : 
    4120 [ #  # ][ #  #  :          0 :     if( !aKeyCode.GetModifier()  &&
             #  #  #  # ]
    4121                 :          0 :         ( ( aKeyCode.GetCode() == KEY_ADD ) ||
    4122                 :          0 :           ( aKeyCode.GetCode() == KEY_SUBTRACT ) )
    4123                 :            :         )
    4124                 :            :     {
    4125         [ #  # ]:          0 :         Check( aKeyCode.GetCode() == KEY_ADD );
    4126                 :            :     }
    4127                 :            :     else
    4128         [ #  # ]:          0 :         Button::KeyInput( rKEvt );
    4129                 :          0 : }
    4130                 :            : 
    4131                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10