LCOV - code coverage report
Current view: top level - libreoffice/vcl/source/control - fixed.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 49 611 8.0 %
Date: 2012-12-17 Functions: 9 74 12.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "tools/rc.h"
      22             : 
      23             : #include "vcl/decoview.hxx"
      24             : #include "vcl/dialog.hxx"
      25             : #include "vcl/event.hxx"
      26             : #include "vcl/fixed.hxx"
      27             : #include "vcl/svapp.hxx"
      28             : #include <comphelper/string.hxx>
      29             : #include "controldata.hxx"
      30             : #include "impimagetree.hxx"
      31             : #include "window.h"
      32             : 
      33             : // =======================================================================
      34             : 
      35             : #define FIXEDLINE_TEXT_BORDER    4
      36             : 
      37             : #define FIXEDTEXT_VIEW_STYLE    (WB_3DLOOK |                        \
      38             :                                  WB_LEFT | WB_CENTER | WB_RIGHT |   \
      39             :                                  WB_TOP | WB_VCENTER | WB_BOTTOM |  \
      40             :                                  WB_WORDBREAK | WB_NOLABEL |        \
      41             :                                  WB_INFO | WB_PATHELLIPSIS)
      42             : #define FIXEDLINE_VIEW_STYLE    (WB_3DLOOK | WB_NOLABEL)
      43             : #define FIXEDBITMAP_VIEW_STYLE  (WB_3DLOOK |                        \
      44             :                                  WB_LEFT | WB_CENTER | WB_RIGHT |   \
      45             :                                  WB_TOP | WB_VCENTER | WB_BOTTOM |  \
      46             :                                  WB_SCALE)
      47             : #define FIXEDIMAGE_VIEW_STYLE   (WB_3DLOOK |                        \
      48             :                                  WB_LEFT | WB_CENTER | WB_RIGHT |   \
      49             :                                  WB_TOP | WB_VCENTER | WB_BOTTOM |  \
      50             :                                  WB_SCALE)
      51             : 
      52             : // =======================================================================
      53             : 
      54           0 : static Point ImplCalcPos( WinBits nStyle, const Point& rPos,
      55             :                           const Size& rObjSize, const Size& rWinSize )
      56             : {
      57             :     long    nX;
      58             :     long    nY;
      59             : 
      60           0 :     if ( nStyle & WB_LEFT )
      61           0 :         nX = 0;
      62           0 :     else if ( nStyle & WB_RIGHT )
      63           0 :         nX = rWinSize.Width()-rObjSize.Width();
      64             :     else
      65           0 :         nX = (rWinSize.Width()-rObjSize.Width())/2;
      66             : 
      67           0 :     if ( nStyle & WB_TOP )
      68           0 :         nY = 0;
      69           0 :     else if ( nStyle & WB_BOTTOM )
      70           0 :         nY = rWinSize.Height()-rObjSize.Height();
      71             :     else
      72           0 :         nY = (rWinSize.Height()-rObjSize.Height())/2;
      73             : 
      74           0 :     if ( nStyle & WB_TOPLEFTVISIBLE )
      75             :     {
      76           0 :         if ( nX < 0 )
      77           0 :             nX = 0;
      78           0 :         if ( nY < 0 )
      79           0 :             nY = 0;
      80             :     }
      81             : 
      82           0 :     Point aPos( nX+rPos.X(), nY+rPos.Y() );
      83           0 :     return aPos;
      84             : }
      85             : 
      86             : // =======================================================================
      87             : 
      88           0 : void FixedText::ImplInit( Window* pParent, WinBits nStyle )
      89             : {
      90           0 :     nStyle = ImplInitStyle( nStyle );
      91           0 :     Control::ImplInit( pParent, nStyle, NULL );
      92           0 :     ImplInitSettings( sal_True, sal_True, sal_True );
      93           0 : }
      94             : 
      95             : // -----------------------------------------------------------------------
      96             : 
      97           0 : WinBits FixedText::ImplInitStyle( WinBits nStyle )
      98             : {
      99           0 :     if ( !(nStyle & WB_NOGROUP) )
     100           0 :         nStyle |= WB_GROUP;
     101           0 :     return nStyle;
     102             : }
     103             : 
     104             : // -----------------------------------------------------------------
     105             : 
     106           0 : const Font& FixedText::GetCanonicalFont( const StyleSettings& _rStyle ) const
     107             : {
     108           0 :     return ( GetStyle() & WB_INFO ) ? _rStyle.GetInfoFont() : _rStyle.GetLabelFont();
     109             : }
     110             : 
     111             : // -----------------------------------------------------------------
     112           0 : const Color& FixedText::GetCanonicalTextColor( const StyleSettings& _rStyle ) const
     113             : {
     114           0 :     return ( GetStyle() & WB_INFO ) ? _rStyle.GetInfoTextColor() : _rStyle.GetLabelTextColor();
     115             : }
     116             : 
     117             : // -----------------------------------------------------------------------
     118             : 
     119           0 : void FixedText::ImplInitSettings( sal_Bool bFont,
     120             :                                   sal_Bool bForeground, sal_Bool bBackground )
     121             : {
     122           0 :     Control::ImplInitSettings( bFont, bForeground );
     123             : 
     124           0 :     if ( bBackground )
     125             :     {
     126           0 :         Window* pParent = GetParent();
     127           0 :         if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
     128             :         {
     129           0 :             EnableChildTransparentMode( sal_True );
     130           0 :             SetParentClipMode( PARENTCLIPMODE_NOCLIP );
     131           0 :             SetPaintTransparent( sal_True );
     132           0 :             SetBackground();
     133             :         }
     134             :         else
     135             :         {
     136           0 :             EnableChildTransparentMode( sal_False );
     137           0 :             SetParentClipMode( 0 );
     138           0 :             SetPaintTransparent( sal_False );
     139             : 
     140           0 :             if ( IsControlBackground() )
     141           0 :                 SetBackground( GetControlBackground() );
     142             :             else
     143           0 :                 SetBackground( pParent->GetBackground() );
     144             :         }
     145             :     }
     146           0 : }
     147             : 
     148             : // -----------------------------------------------------------------------
     149             : 
     150           0 : FixedText::FixedText( Window* pParent, WinBits nStyle )
     151             :     : Control(WINDOW_FIXEDTEXT)
     152             :     , m_nMaxWidthChars(-1)
     153           0 :     , m_nMinWidthChars(-1)
     154             : {
     155           0 :     ImplInit( pParent, nStyle );
     156           0 : }
     157             : 
     158             : // -----------------------------------------------------------------------
     159             : 
     160           0 : FixedText::FixedText( Window* pParent, const ResId& rResId )
     161             :     : Control(WINDOW_FIXEDTEXT)
     162             :     , m_nMaxWidthChars(-1)
     163           0 :     , m_nMinWidthChars(-1)
     164             : {
     165           0 :     rResId.SetRT( RSC_TEXT );
     166           0 :     WinBits nStyle = ImplInitRes( rResId );
     167           0 :     ImplInit( pParent, nStyle );
     168           0 :     ImplLoadRes( rResId );
     169             : 
     170           0 :     if ( !(nStyle & WB_HIDE) )
     171           0 :         Show();
     172           0 : }
     173             : 
     174             : // -----------------------------------------------------------------------
     175             : 
     176           0 : FixedText::FixedText( Window* pParent, const ResId& rResId, bool bDisableAccessibleLabelForRelation )
     177             :     : Control( WINDOW_FIXEDTEXT )
     178             :     , m_nMaxWidthChars(-1)
     179           0 :     , m_nMinWidthChars(-1)
     180             : {
     181           0 :     rResId.SetRT( RSC_TEXT );
     182           0 :     WinBits nStyle = ImplInitRes( rResId );
     183           0 :     ImplInit( pParent, nStyle );
     184           0 :     ImplLoadRes( rResId );
     185           0 :     if ( bDisableAccessibleLabelForRelation )
     186           0 :         ImplGetWindowImpl()->mbDisableAccessibleLabelForRelation = sal_True;
     187             : 
     188           0 :     if ( !(nStyle & WB_HIDE) )
     189           0 :         Show();
     190           0 : }
     191             : 
     192             : // -----------------------------------------------------------------------
     193             : 
     194           0 : sal_uInt16 FixedText::ImplGetTextStyle( WinBits nWinStyle )
     195             : {
     196           0 :     sal_uInt16 nTextStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_ENDELLIPSIS;
     197             : 
     198           0 :     if( ! (nWinStyle & WB_NOMULTILINE) )
     199           0 :         nTextStyle |= TEXT_DRAW_MULTILINE;
     200             : 
     201           0 :     if ( nWinStyle & WB_RIGHT )
     202           0 :         nTextStyle |= TEXT_DRAW_RIGHT;
     203           0 :     else if ( nWinStyle & WB_CENTER )
     204           0 :         nTextStyle |= TEXT_DRAW_CENTER;
     205             :     else
     206           0 :         nTextStyle |= TEXT_DRAW_LEFT;
     207           0 :     if ( nWinStyle & WB_BOTTOM )
     208           0 :         nTextStyle |= TEXT_DRAW_BOTTOM;
     209           0 :     else if ( nWinStyle & WB_VCENTER )
     210           0 :         nTextStyle |= TEXT_DRAW_VCENTER;
     211             :     else
     212           0 :         nTextStyle |= TEXT_DRAW_TOP;
     213           0 :     if ( nWinStyle & WB_WORDBREAK )
     214             :     {
     215           0 :         nTextStyle |= TEXT_DRAW_WORDBREAK;
     216           0 :         if ( (nWinStyle & WB_HYPHENATION ) == WB_HYPHENATION )
     217           0 :             nTextStyle |= TEXT_DRAW_WORDBREAK_HYPHENATION;
     218             :     }
     219           0 :     if ( nWinStyle & WB_NOLABEL )
     220           0 :         nTextStyle &= ~TEXT_DRAW_MNEMONIC;
     221             : 
     222           0 :     return nTextStyle;
     223             : }
     224             : 
     225             : // -----------------------------------------------------------------------
     226             : 
     227           0 : void FixedText::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
     228             :                           const Point& rPos, const Size& rSize,
     229             :                           bool bFillLayout
     230             :                           ) const
     231             : {
     232           0 :     const StyleSettings&    rStyleSettings = GetSettings().GetStyleSettings();
     233           0 :     WinBits                 nWinStyle = GetStyle();
     234           0 :     rtl::OUString           aText( GetText() );
     235           0 :     sal_uInt16              nTextStyle = FixedText::ImplGetTextStyle( nWinStyle );
     236           0 :     Point                   aPos = rPos;
     237             : 
     238           0 :     if ( nWinStyle & WB_EXTRAOFFSET )
     239           0 :         aPos.X() += 2;
     240             : 
     241           0 :     if ( nWinStyle & WB_PATHELLIPSIS )
     242             :     {
     243           0 :         nTextStyle &= ~(TEXT_DRAW_ENDELLIPSIS | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK);
     244           0 :         nTextStyle |= TEXT_DRAW_PATHELLIPSIS;
     245             :     }
     246           0 :     if ( nDrawFlags & WINDOW_DRAW_NOMNEMONIC )
     247             :     {
     248           0 :         if ( nTextStyle & TEXT_DRAW_MNEMONIC )
     249             :         {
     250           0 :             aText = GetNonMnemonicString( aText );
     251           0 :             nTextStyle &= ~TEXT_DRAW_MNEMONIC;
     252             :         }
     253             :     }
     254           0 :     if ( !(nDrawFlags & WINDOW_DRAW_NODISABLE) )
     255             :     {
     256           0 :         if ( !IsEnabled() )
     257           0 :             nTextStyle |= TEXT_DRAW_DISABLE;
     258             :     }
     259           0 :     if ( (nDrawFlags & WINDOW_DRAW_MONO) ||
     260           0 :          (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
     261           0 :         nTextStyle |= TEXT_DRAW_MONO;
     262             : 
     263           0 :     if( bFillLayout )
     264           0 :         mpControlData->mpLayoutData->m_aDisplayText = String();
     265             : 
     266           0 :     Rectangle aRect( Rectangle( aPos, rSize ) );
     267             :     DrawControlText( *pDev, aRect, aText, nTextStyle,
     268             :         bFillLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL,
     269             :         bFillLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL
     270           0 :     );
     271           0 : }
     272             : 
     273             : // -----------------------------------------------------------------------
     274             : 
     275           0 : void FixedText::Paint( const Rectangle& )
     276             : {
     277           0 :     ImplDraw( this, 0, Point(), GetOutputSizePixel() );
     278           0 : }
     279             : 
     280             : // -----------------------------------------------------------------------
     281             : 
     282           0 : void FixedText::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
     283             :                       sal_uLong nFlags )
     284             : {
     285           0 :     ImplInitSettings( sal_True, sal_True, sal_True );
     286             : 
     287           0 :     Point       aPos  = pDev->LogicToPixel( rPos );
     288           0 :     Size        aSize = pDev->LogicToPixel( rSize );
     289           0 :     Font        aFont = GetDrawPixelFont( pDev );
     290             : 
     291           0 :     pDev->Push();
     292           0 :     pDev->SetMapMode();
     293           0 :     pDev->SetFont( aFont );
     294           0 :     if ( nFlags & WINDOW_DRAW_MONO )
     295           0 :         pDev->SetTextColor( Color( COL_BLACK ) );
     296             :     else
     297           0 :         pDev->SetTextColor( GetTextColor() );
     298           0 :     pDev->SetTextFillColor();
     299             : 
     300           0 :     sal_Bool bBorder = !(nFlags & WINDOW_DRAW_NOBORDER ) && (GetStyle() & WB_BORDER);
     301           0 :     sal_Bool bBackground = !(nFlags & WINDOW_DRAW_NOBACKGROUND) && IsControlBackground();
     302           0 :     if ( bBorder || bBackground )
     303             :     {
     304           0 :         Rectangle aRect( aPos, aSize );
     305           0 :         if ( bBorder )
     306             :         {
     307           0 :             ImplDrawFrame( pDev, aRect );
     308             :         }
     309           0 :         if ( bBackground )
     310             :         {
     311           0 :             pDev->SetFillColor( GetControlBackground() );
     312           0 :             pDev->DrawRect( aRect );
     313             :         }
     314             :     }
     315             : 
     316           0 :     ImplDraw( pDev, nFlags, aPos, aSize );
     317           0 :     pDev->Pop();
     318           0 : }
     319             : 
     320             : // -----------------------------------------------------------------------
     321             : 
     322           0 : void FixedText::Resize()
     323             : {
     324           0 :     Control::Resize();
     325           0 :     Invalidate();
     326           0 : }
     327             : 
     328             : // -----------------------------------------------------------------------
     329             : 
     330           0 : void FixedText::StateChanged( StateChangedType nType )
     331             : {
     332           0 :     Control::StateChanged( nType );
     333             : 
     334           0 :     if ( (nType == STATE_CHANGE_ENABLE) ||
     335             :          (nType == STATE_CHANGE_TEXT) ||
     336             :          (nType == STATE_CHANGE_UPDATEMODE) )
     337             :     {
     338           0 :         if ( IsReallyVisible() && IsUpdateMode() )
     339           0 :             Invalidate();
     340             :     }
     341           0 :     else if ( nType == STATE_CHANGE_STYLE )
     342             :     {
     343           0 :         SetStyle( ImplInitStyle( GetStyle() ) );
     344           0 :         if ( (GetPrevStyle() & FIXEDTEXT_VIEW_STYLE) !=
     345           0 :              (GetStyle() & FIXEDTEXT_VIEW_STYLE) )
     346             :         {
     347           0 :             ImplInitSettings( sal_True, sal_False, sal_False );
     348           0 :             Invalidate();
     349             :         }
     350             :     }
     351           0 :     else if ( (nType == STATE_CHANGE_ZOOM)  ||
     352             :               (nType == STATE_CHANGE_CONTROLFONT) )
     353             :     {
     354           0 :         ImplInitSettings( sal_True, sal_False, sal_False );
     355           0 :         Invalidate();
     356             :     }
     357           0 :     else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
     358             :     {
     359           0 :         ImplInitSettings( sal_False, sal_True, sal_False );
     360           0 :         Invalidate();
     361             :     }
     362           0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     363             :     {
     364           0 :         ImplInitSettings( sal_False, sal_False, sal_True );
     365           0 :         Invalidate();
     366             :     }
     367           0 : }
     368             : 
     369             : // -----------------------------------------------------------------------
     370             : 
     371           0 : void FixedText::DataChanged( const DataChangedEvent& rDCEvt )
     372             : {
     373           0 :     Control::DataChanged( rDCEvt );
     374             : 
     375           0 :     if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
     376           0 :          (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
     377           0 :          ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     378           0 :           (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
     379             :     {
     380           0 :         ImplInitSettings( sal_True, sal_True, sal_True );
     381           0 :         Invalidate();
     382             :     }
     383           0 : }
     384             : 
     385             : // -----------------------------------------------------------------------
     386             : 
     387           0 : Size FixedText::getTextDimensions(Control const *pControl, const OUString &rTxt, long nMaxWidth)
     388             : {
     389           0 :     sal_uInt16 nStyle = ImplGetTextStyle( pControl->GetStyle() );
     390           0 :     if ( !( pControl->GetStyle() & WB_NOLABEL ) )
     391           0 :         nStyle |= TEXT_DRAW_MNEMONIC;
     392             : 
     393             :     return pControl->GetTextRect(Rectangle( Point(), Size(nMaxWidth, 0x7fffffff)),
     394           0 :                                        rTxt, nStyle).GetSize();
     395             : }
     396             : 
     397             : 
     398           0 : Size FixedText::CalcMinimumTextSize( Control const *pControl, long nMaxWidth )
     399             : {
     400           0 :     Size aSize = getTextDimensions(pControl, pControl->GetText(), nMaxWidth);
     401             : 
     402           0 :     if ( pControl->GetStyle() & WB_EXTRAOFFSET )
     403           0 :         aSize.Width() += 2;
     404             : 
     405             :     // GetTextRect verkraftet keinen leeren String:
     406           0 :     if ( aSize.Width() < 0 )
     407           0 :         aSize.Width() = 0;
     408           0 :     if ( aSize.Height() <= 0 )
     409           0 :         aSize.Height() = pControl->GetTextHeight();
     410             : 
     411           0 :     return aSize;
     412             : }
     413             : 
     414           0 : Size FixedText::CalcMinimumSize( long nMaxWidth ) const
     415             : {
     416           0 :     return CalcWindowSize( CalcMinimumTextSize ( this, nMaxWidth ) );
     417             : }
     418             : // -----------------------------------------------------------------------
     419             : 
     420           0 : Size FixedText::GetOptimalSize(WindowSizeType eType) const
     421             : {
     422           0 :     switch (eType)
     423             :     {
     424             :         case WINDOWSIZE_MINIMUM:
     425             :         {
     426           0 :             sal_Int32 nMaxAvailWidth = 0x7fffffff;
     427           0 :             const OUString &rTxt = GetText();
     428           0 :             if (m_nMaxWidthChars != -1 && m_nMaxWidthChars < rTxt.getLength())
     429             :             {
     430             :                 nMaxAvailWidth = getTextDimensions(this,
     431           0 :                     rTxt.copy(0, m_nMaxWidthChars), 0x7fffffff).Width();
     432             :             }
     433           0 :             Size aRet = CalcMinimumSize(nMaxAvailWidth);
     434           0 :             if (m_nMinWidthChars != -1)
     435             :             {
     436           0 :                 OUStringBuffer aBuf;
     437           0 :                 comphelper::string::padToLength(aBuf, m_nMinWidthChars, 'x');
     438             :                 Size aMinAllowed = getTextDimensions(this,
     439           0 :                     aBuf.makeStringAndClear(), 0x7fffffff);
     440           0 :                 if (aMinAllowed.Width() > aRet.Width())
     441           0 :                     aRet = aMinAllowed;
     442             :             }
     443           0 :             return aRet;
     444             :         }
     445             :         default:
     446           0 :             return Control::GetOptimalSize( eType );
     447             :     }
     448             : }
     449             : 
     450             : // -----------------------------------------------------------------------
     451             : 
     452           0 : void FixedText::FillLayoutData() const
     453             : {
     454           0 :     mpControlData->mpLayoutData = new vcl::ControlLayoutData();
     455           0 :     ImplDraw( const_cast<FixedText*>(this), 0, Point(), GetOutputSizePixel(), true );
     456           0 : }
     457             : 
     458           0 : void FixedText::setMaxWidthChars(sal_Int32 nWidth)
     459             : {
     460           0 :     if (nWidth != m_nMaxWidthChars)
     461             :     {
     462           0 :         m_nMaxWidthChars = nWidth;
     463           0 :         queue_resize();
     464             :     }
     465           0 : }
     466             : 
     467           0 : void FixedText::setMinWidthChars(sal_Int32 nWidth)
     468             : {
     469           0 :     if (nWidth != m_nMinWidthChars)
     470             :     {
     471           0 :         m_nMinWidthChars = nWidth;
     472           0 :         queue_resize();
     473             :     }
     474           0 : }
     475             : 
     476           0 : bool FixedText::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
     477             : {
     478           0 :     if (rKey == "max-width-chars")
     479           0 :         setMaxWidthChars(rValue.toInt32());
     480           0 :     else if (rKey == "width-chars")
     481           0 :         setMinWidthChars(rValue.toInt32());
     482             :     else
     483           0 :         return Control::set_property(rKey, rValue);
     484           0 :     return true;
     485             : }
     486             : 
     487             : // =======================================================================
     488             : 
     489          36 : void FixedLine::ImplInit( Window* pParent, WinBits nStyle )
     490             : {
     491          36 :     nStyle = ImplInitStyle( nStyle );
     492          36 :     Control::ImplInit( pParent, nStyle, NULL );
     493          36 :     ImplInitSettings( sal_True, sal_True, sal_True );
     494          36 : }
     495             : 
     496             : // -----------------------------------------------------------------------
     497             : 
     498          36 : WinBits FixedLine::ImplInitStyle( WinBits nStyle )
     499             : {
     500          36 :     if ( !(nStyle & WB_NOGROUP) )
     501          36 :         nStyle |= WB_GROUP;
     502          36 :     return nStyle;
     503             : }
     504             : 
     505             : // -----------------------------------------------------------------
     506             : 
     507          36 : const Font& FixedLine::GetCanonicalFont( const StyleSettings& _rStyle ) const
     508             : {
     509          36 :     return _rStyle.GetGroupFont();
     510             : }
     511             : 
     512             : // -----------------------------------------------------------------
     513          36 : const Color& FixedLine::GetCanonicalTextColor( const StyleSettings& _rStyle ) const
     514             : {
     515          36 :     return _rStyle.GetGroupTextColor();
     516             : }
     517             : 
     518             : // -----------------------------------------------------------------------
     519             : 
     520          36 : void FixedLine::ImplInitSettings( sal_Bool bFont,
     521             :                                   sal_Bool bForeground, sal_Bool bBackground )
     522             : {
     523          36 :     Control::ImplInitSettings( bFont, bForeground );
     524             : 
     525          36 :     if ( bBackground )
     526             :     {
     527          36 :         Window* pParent = GetParent();
     528          36 :         if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
     529             :         {
     530          36 :             EnableChildTransparentMode( sal_True );
     531          36 :             SetParentClipMode( PARENTCLIPMODE_NOCLIP );
     532          36 :             SetPaintTransparent( sal_True );
     533          36 :             SetBackground();
     534             :         }
     535             :         else
     536             :         {
     537           0 :             EnableChildTransparentMode( sal_False );
     538           0 :             SetParentClipMode( 0 );
     539           0 :             SetPaintTransparent( sal_False );
     540             : 
     541           0 :             if ( IsControlBackground() )
     542           0 :                 SetBackground( GetControlBackground() );
     543             :             else
     544           0 :                 SetBackground( pParent->GetBackground() );
     545             :         }
     546             :     }
     547          36 : }
     548             : 
     549             : // -----------------------------------------------------------------------
     550             : 
     551           0 : void FixedLine::ImplDraw( bool bLayout )
     552             : {
     553           0 :     Size                    aOutSize = GetOutputSizePixel();
     554           0 :     String                  aText = GetText();
     555           0 :     WinBits                 nWinStyle = GetStyle();
     556           0 :     MetricVector*           pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
     557           0 :     String*                 pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL;
     558             : 
     559           0 :     DecorationView aDecoView( this );
     560           0 :     if ( !aText.Len() )
     561             :     {
     562           0 :         if( !pVector )
     563             :         {
     564           0 :             if ( nWinStyle & WB_VERT )
     565             :             {
     566           0 :                 long nX = (aOutSize.Width()-1)/2;
     567           0 :                 aDecoView.DrawSeparator( Point( nX, 0 ), Point( nX, aOutSize.Height()-1 ) );
     568             :             }
     569             :             else
     570             :             {
     571           0 :                 long nY = (aOutSize.Height()-1)/2;
     572           0 :                 aDecoView.DrawSeparator( Point( 0, nY ), Point( aOutSize.Width()-1, nY ), false );
     573             :             }
     574             :         }
     575             :     }
     576           0 :     else if( (nWinStyle & WB_VERT) )
     577             :     {
     578           0 :         long nWidth = GetTextWidth( aText );
     579           0 :         Push( PUSH_FONT );
     580           0 :         Font aFont( GetFont() );
     581           0 :         aFont.SetOrientation( 900 );
     582           0 :         SetFont( aFont );
     583           0 :         Point aStartPt( aOutSize.Width()/2, aOutSize.Height()-1 );
     584           0 :         if( (nWinStyle & WB_VCENTER) )
     585           0 :             aStartPt.Y() -= (aOutSize.Height() - nWidth)/2;
     586           0 :         Point aTextPt( aStartPt );
     587           0 :         aTextPt.X() -= GetTextHeight()/2;
     588           0 :         DrawText( aTextPt, aText, 0, STRING_LEN, pVector, pDisplayText );
     589           0 :         Pop();
     590           0 :         if( aOutSize.Height() - aStartPt.Y() > FIXEDLINE_TEXT_BORDER )
     591           0 :             aDecoView.DrawSeparator( Point( aStartPt.X(), aOutSize.Height()-1 ),
     592           0 :                                      Point( aStartPt.X(), aStartPt.Y() + FIXEDLINE_TEXT_BORDER ) );
     593           0 :         if( aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER > 0 )
     594           0 :             aDecoView.DrawSeparator( Point( aStartPt.X(), aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER ),
     595           0 :                                      Point( aStartPt.X(), 0 ) );
     596             :     }
     597             :     else
     598             :     {
     599           0 :         sal_uInt16      nStyle = TEXT_DRAW_MNEMONIC | TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS;
     600           0 :         Rectangle   aRect( 0, 0, aOutSize.Width(), aOutSize.Height() );
     601           0 :         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     602           0 :         if( (nWinStyle & WB_CENTER) )
     603           0 :             nStyle |= TEXT_DRAW_CENTER;
     604             : 
     605           0 :         if ( !IsEnabled() )
     606           0 :             nStyle |= TEXT_DRAW_DISABLE;
     607           0 :         if ( GetStyle() & WB_NOLABEL )
     608           0 :             nStyle &= ~TEXT_DRAW_MNEMONIC;
     609           0 :         if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO )
     610           0 :             nStyle |= TEXT_DRAW_MONO;
     611             : 
     612           0 :         DrawControlText( *this, aRect, aText, nStyle, pVector, pDisplayText );
     613             : 
     614           0 :         if( !pVector )
     615             :         {
     616           0 :             long nTop = aRect.Top() + ((aRect.GetHeight()-1)/2);
     617           0 :             aDecoView.DrawSeparator( Point( aRect.Right()+FIXEDLINE_TEXT_BORDER, nTop ), Point( aOutSize.Width()-1, nTop ), false );
     618           0 :             if( aRect.Left() > FIXEDLINE_TEXT_BORDER )
     619           0 :                 aDecoView.DrawSeparator( Point( 0, nTop ), Point( aRect.Left()-FIXEDLINE_TEXT_BORDER, nTop ), false );
     620             :         }
     621           0 :     }
     622           0 : }
     623             : 
     624             : // -----------------------------------------------------------------------
     625             : 
     626          36 : FixedLine::FixedLine( Window* pParent, WinBits nStyle ) :
     627          36 :     Control( WINDOW_FIXEDLINE )
     628             : {
     629          36 :     ImplInit( pParent, nStyle );
     630          36 :     SetSizePixel( Size( 2, 2 ) );
     631          36 : }
     632             : 
     633             : // -----------------------------------------------------------------------
     634             : 
     635           0 : FixedLine::FixedLine( Window* pParent, const ResId& rResId ) :
     636           0 :     Control( WINDOW_FIXEDLINE )
     637             : {
     638           0 :     rResId.SetRT( RSC_FIXEDLINE );
     639           0 :     WinBits nStyle = ImplInitRes( rResId );
     640           0 :     ImplInit( pParent, nStyle );
     641           0 :     ImplLoadRes( rResId );
     642             : 
     643           0 :     if ( !(nStyle & WB_HIDE) )
     644           0 :         Show();
     645           0 : }
     646             : 
     647             : // -----------------------------------------------------------------------
     648             : 
     649           0 : void  FixedLine::FillLayoutData() const
     650             : {
     651           0 :     mpControlData->mpLayoutData = new vcl::ControlLayoutData();
     652           0 :     const_cast<FixedLine*>(this)->ImplDraw( true );
     653           0 : }
     654             : 
     655             : 
     656             : // -----------------------------------------------------------------------
     657             : 
     658           0 : void FixedLine::Paint( const Rectangle& )
     659             : {
     660           0 :     ImplDraw();
     661           0 : }
     662             : 
     663             : // -----------------------------------------------------------------------
     664             : 
     665           0 : void FixedLine::Draw( OutputDevice*, const Point&, const Size&, sal_uLong )
     666             : {
     667           0 : }
     668             : 
     669             : // -----------------------------------------------------------------------
     670             : 
     671          72 : void FixedLine::Resize()
     672             : {
     673          72 :     Control::Resize();
     674          72 :     Invalidate();
     675          72 : }
     676             : 
     677             : // -----------------------------------------------------------------------
     678             : 
     679          88 : void FixedLine::StateChanged( StateChangedType nType )
     680             : {
     681          88 :     Control::StateChanged( nType );
     682             : 
     683          88 :     if ( (nType == STATE_CHANGE_ENABLE) ||
     684             :          (nType == STATE_CHANGE_TEXT) ||
     685             :          (nType == STATE_CHANGE_UPDATEMODE) )
     686             :     {
     687          24 :         if ( IsReallyVisible() && IsUpdateMode() )
     688          12 :             Invalidate();
     689             :     }
     690          76 :     else if ( nType == STATE_CHANGE_STYLE )
     691             :     {
     692           0 :         SetStyle( ImplInitStyle( GetStyle() ) );
     693           0 :         if ( (GetPrevStyle() & FIXEDLINE_VIEW_STYLE) !=
     694           0 :              (GetStyle() & FIXEDLINE_VIEW_STYLE) )
     695           0 :             Invalidate();
     696             :     }
     697          76 :     else if ( (nType == STATE_CHANGE_ZOOM)  ||
     698             :               (nType == STATE_CHANGE_STYLE) ||
     699             :               (nType == STATE_CHANGE_CONTROLFONT) )
     700             :     {
     701           0 :         ImplInitSettings( sal_True, sal_False, sal_False );
     702           0 :         Invalidate();
     703             :     }
     704          76 :     else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
     705             :     {
     706           0 :         ImplInitSettings( sal_False, sal_True, sal_False );
     707           0 :         Invalidate();
     708             :     }
     709          76 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     710             :     {
     711           0 :         ImplInitSettings( sal_False, sal_False, sal_True );
     712           0 :         Invalidate();
     713             :     }
     714          88 : }
     715             : 
     716             : // -----------------------------------------------------------------------
     717             : 
     718          24 : void FixedLine::DataChanged( const DataChangedEvent& rDCEvt )
     719             : {
     720          24 :     Control::DataChanged( rDCEvt );
     721             : 
     722          96 :     if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
     723          24 :          (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
     724          24 :          ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     725          24 :           (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
     726             :     {
     727           0 :         ImplInitSettings( sal_True, sal_True, sal_True );
     728           0 :         Invalidate();
     729             :     }
     730          24 : }
     731             : 
     732             : // -----------------------------------------------------------------------
     733             : 
     734           0 : Size FixedLine::GetOptimalSize(WindowSizeType eType) const
     735             : {
     736           0 :     switch (eType) {
     737             :     case WINDOWSIZE_MINIMUM:
     738           0 :         return CalcWindowSize( FixedText::CalcMinimumTextSize ( this, 0x7fffffff ) );
     739             :     default:
     740           0 :         return Control::GetOptimalSize( eType );
     741             :     }
     742             : }
     743             : 
     744             : // =======================================================================
     745             : 
     746           0 : void FixedBitmap::ImplInit( Window* pParent, WinBits nStyle )
     747             : {
     748           0 :     nStyle = ImplInitStyle( nStyle );
     749           0 :     Control::ImplInit( pParent, nStyle, NULL );
     750           0 :     ImplInitSettings();
     751           0 : }
     752             : 
     753             : // -----------------------------------------------------------------------
     754             : 
     755           0 : WinBits FixedBitmap::ImplInitStyle( WinBits nStyle )
     756             : {
     757           0 :     if ( !(nStyle & WB_NOGROUP) )
     758           0 :         nStyle |= WB_GROUP;
     759           0 :     return nStyle;
     760             : }
     761             : 
     762             : // -----------------------------------------------------------------------
     763             : 
     764           0 : void FixedBitmap::ImplInitSettings()
     765             : {
     766           0 :     Window* pParent = GetParent();
     767           0 :     if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
     768             :     {
     769           0 :         EnableChildTransparentMode( sal_True );
     770           0 :         SetParentClipMode( PARENTCLIPMODE_NOCLIP );
     771           0 :         SetPaintTransparent( sal_True );
     772           0 :         SetBackground();
     773             :     }
     774             :     else
     775             :     {
     776           0 :         EnableChildTransparentMode( sal_False );
     777           0 :         SetParentClipMode( 0 );
     778           0 :         SetPaintTransparent( sal_False );
     779             : 
     780           0 :         if ( IsControlBackground() )
     781           0 :             SetBackground( GetControlBackground() );
     782             :         else
     783           0 :             SetBackground( pParent->GetBackground() );
     784             :     }
     785           0 : }
     786             : 
     787             : // -----------------------------------------------------------------------
     788             : 
     789           0 : void FixedBitmap::ImplLoadRes( const ResId& rResId )
     790             : {
     791           0 :     Control::ImplLoadRes( rResId );
     792             : 
     793           0 :     sal_uLong nObjMask = ReadLongRes();
     794             : 
     795           0 :     if ( RSC_FIXEDBITMAP_BITMAP & nObjMask )
     796             :     {
     797           0 :         maBitmap = Bitmap( ResId( (RSHEADER_TYPE*)GetClassRes(), *rResId.GetResMgr() ) );
     798           0 :         IncrementRes( GetObjSizeRes( (RSHEADER_TYPE*)GetClassRes() ) );
     799             :     }
     800           0 : }
     801             : 
     802             : // -----------------------------------------------------------------------
     803             : 
     804           0 : FixedBitmap::FixedBitmap( Window* pParent, WinBits nStyle ) :
     805           0 :     Control( WINDOW_FIXEDBITMAP )
     806             : {
     807           0 :     ImplInit( pParent, nStyle );
     808           0 : }
     809             : 
     810             : // -----------------------------------------------------------------------
     811             : 
     812           0 : FixedBitmap::FixedBitmap( Window* pParent, const ResId& rResId ) :
     813           0 :     Control( WINDOW_FIXEDBITMAP )
     814             : {
     815           0 :     rResId.SetRT( RSC_FIXEDBITMAP );
     816           0 :     WinBits nStyle = ImplInitRes( rResId );
     817           0 :     ImplInit( pParent, nStyle );
     818           0 :     ImplLoadRes( rResId );
     819             : 
     820           0 :     if ( !(nStyle & WB_HIDE) )
     821           0 :         Show();
     822           0 : }
     823             : 
     824             : // -----------------------------------------------------------------------
     825             : 
     826           0 : FixedBitmap::~FixedBitmap()
     827             : {
     828           0 : }
     829             : 
     830             : // -----------------------------------------------------------------------
     831             : 
     832           0 : void FixedBitmap::ImplDraw( OutputDevice* pDev, sal_uLong /* nDrawFlags */,
     833             :                             const Point& rPos, const Size& rSize )
     834             : {
     835           0 :     sal_uInt16 nStyle = 0;
     836           0 :     Bitmap* pBitmap = &maBitmap;
     837           0 :     Color aCol;
     838             : 
     839           0 :     if( nStyle & IMAGE_DRAW_COLORTRANSFORM )
     840             :     {
     841             :         // only images support IMAGE_DRAW_COLORTRANSFORM
     842           0 :         Image aImage( maBitmap );
     843           0 :         if ( !(!aImage) )
     844             :         {
     845           0 :             if ( GetStyle() & WB_SCALE )
     846           0 :                 pDev->DrawImage( rPos, rSize, aImage, nStyle );
     847             :             else
     848             :             {
     849           0 :                 Point aPos = ImplCalcPos( GetStyle(), rPos, aImage.GetSizePixel(), rSize );
     850           0 :                 pDev->DrawImage( aPos, aImage, nStyle );
     851             :             }
     852           0 :         }
     853             :     }
     854             :     else
     855             :     {
     856             :         // Haben wir ueberhaupt eine Bitmap
     857           0 :         if ( !(!(*pBitmap)) )
     858             :         {
     859           0 :             if ( GetStyle() & WB_SCALE )
     860           0 :                 pDev->DrawBitmap( rPos, rSize, *pBitmap );
     861             :             else
     862             :             {
     863           0 :                 Point aPos = ImplCalcPos( GetStyle(), rPos, pBitmap->GetSizePixel(), rSize );
     864           0 :                 pDev->DrawBitmap( aPos, *pBitmap );
     865             :             }
     866             :         }
     867             :     }
     868           0 : }
     869             : 
     870             : // -----------------------------------------------------------------------
     871             : 
     872           0 : void FixedBitmap::Paint( const Rectangle& )
     873             : {
     874           0 :     ImplDraw( this, 0, Point(), GetOutputSizePixel() );
     875           0 : }
     876             : 
     877             : // -----------------------------------------------------------------------
     878             : 
     879           0 : void FixedBitmap::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
     880             :                         sal_uLong nFlags )
     881             : {
     882           0 :     Point       aPos  = pDev->LogicToPixel( rPos );
     883           0 :     Size        aSize = pDev->LogicToPixel( rSize );
     884           0 :     Rectangle   aRect( aPos, aSize );
     885             : 
     886           0 :     pDev->Push();
     887           0 :     pDev->SetMapMode();
     888             : 
     889             :     // Border
     890           0 :     if ( !(nFlags & WINDOW_DRAW_NOBORDER) && (GetStyle() & WB_BORDER) )
     891             :     {
     892           0 :         DecorationView aDecoView( pDev );
     893           0 :         aRect = aDecoView.DrawFrame( aRect, FRAME_DRAW_DOUBLEIN );
     894             :     }
     895           0 :     pDev->IntersectClipRegion( aRect );
     896           0 :     ImplDraw( pDev, nFlags, aRect.TopLeft(), aRect.GetSize() );
     897             : 
     898           0 :     pDev->Pop();
     899           0 : }
     900             : 
     901             : // -----------------------------------------------------------------------
     902             : 
     903           0 : void FixedBitmap::Resize()
     904             : {
     905           0 :     Control::Resize();
     906           0 :     Invalidate();
     907           0 : }
     908             : 
     909             : // -----------------------------------------------------------------------
     910             : 
     911           0 : void FixedBitmap::StateChanged( StateChangedType nType )
     912             : {
     913           0 :     Control::StateChanged( nType );
     914             : 
     915           0 :     if ( (nType == STATE_CHANGE_DATA) ||
     916             :          (nType == STATE_CHANGE_UPDATEMODE) )
     917             :     {
     918           0 :         if ( IsReallyVisible() && IsUpdateMode() )
     919           0 :             Invalidate();
     920             :     }
     921           0 :     else if ( nType == STATE_CHANGE_STYLE )
     922             :     {
     923           0 :         SetStyle( ImplInitStyle( GetStyle() ) );
     924           0 :         if ( (GetPrevStyle() & FIXEDBITMAP_VIEW_STYLE) !=
     925           0 :              (GetStyle() & FIXEDBITMAP_VIEW_STYLE) )
     926           0 :             Invalidate();
     927             :     }
     928           0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     929             :     {
     930           0 :         ImplInitSettings();
     931           0 :         Invalidate();
     932             :     }
     933           0 : }
     934             : 
     935             : // -----------------------------------------------------------------------
     936             : 
     937           0 : void FixedBitmap::DataChanged( const DataChangedEvent& rDCEvt )
     938             : {
     939           0 :     Control::DataChanged( rDCEvt );
     940             : 
     941           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     942           0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     943             :     {
     944           0 :         ImplInitSettings();
     945           0 :         Invalidate();
     946             :     }
     947           0 : }
     948             : 
     949             : // -----------------------------------------------------------------------
     950             : 
     951           0 : void FixedBitmap::SetBitmap( const Bitmap& rBitmap )
     952             : {
     953           0 :     maBitmap = rBitmap;
     954           0 :     StateChanged( STATE_CHANGE_DATA );
     955           0 :     queue_resize();
     956           0 : }
     957             : 
     958             : // =======================================================================
     959             : 
     960           0 : void FixedImage::ImplInit( Window* pParent, WinBits nStyle )
     961             : {
     962           0 :     nStyle = ImplInitStyle( nStyle );
     963           0 :     mbInUserDraw = sal_False;
     964           0 :     Control::ImplInit( pParent, nStyle, NULL );
     965           0 :     ImplInitSettings();
     966           0 : }
     967             : 
     968             : // -----------------------------------------------------------------------
     969             : 
     970           0 : WinBits FixedImage::ImplInitStyle( WinBits nStyle )
     971             : {
     972           0 :     if ( !(nStyle & WB_NOGROUP) )
     973           0 :         nStyle |= WB_GROUP;
     974           0 :     return nStyle;
     975             : }
     976             : 
     977             : // -----------------------------------------------------------------------
     978             : 
     979           0 : void FixedImage::ImplInitSettings()
     980             : {
     981           0 :     Window* pParent = GetParent();
     982           0 :     if ( pParent && pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
     983             :     {
     984           0 :         EnableChildTransparentMode( sal_True );
     985           0 :         SetParentClipMode( PARENTCLIPMODE_NOCLIP );
     986           0 :         SetPaintTransparent( sal_True );
     987           0 :         SetBackground();
     988             :     }
     989             :     else
     990             :     {
     991           0 :         EnableChildTransparentMode( sal_False );
     992           0 :         SetParentClipMode( 0 );
     993           0 :         SetPaintTransparent( sal_False );
     994             : 
     995           0 :         if ( IsControlBackground() )
     996           0 :             SetBackground( GetControlBackground() );
     997           0 :         else if ( pParent )
     998           0 :             SetBackground( pParent->GetBackground() );
     999             :     }
    1000           0 : }
    1001             : 
    1002             : // -----------------------------------------------------------------------
    1003             : 
    1004           0 : void FixedImage::ImplLoadRes( const ResId& rResId )
    1005             : {
    1006           0 :     Control::ImplLoadRes( rResId );
    1007             : 
    1008           0 :     sal_uLong nObjMask = ReadLongRes();
    1009             : 
    1010           0 :     if ( RSC_FIXEDIMAGE_IMAGE & nObjMask )
    1011             :     {
    1012           0 :         maImage = Image( ResId( (RSHEADER_TYPE*)GetClassRes(), *rResId.GetResMgr() ) );
    1013           0 :         IncrementRes( GetObjSizeRes( (RSHEADER_TYPE*)GetClassRes() ) );
    1014             :     }
    1015           0 : }
    1016             : 
    1017             : // -----------------------------------------------------------------------
    1018             : 
    1019           0 : FixedImage::FixedImage( Window* pParent, WinBits nStyle ) :
    1020           0 :     Control( WINDOW_FIXEDIMAGE )
    1021             : {
    1022           0 :     ImplInit( pParent, nStyle );
    1023           0 : }
    1024             : 
    1025             : // -----------------------------------------------------------------------
    1026             : 
    1027           0 : FixedImage::FixedImage( Window* pParent, const ResId& rResId ) :
    1028           0 :     Control( WINDOW_FIXEDIMAGE )
    1029             : {
    1030           0 :     rResId.SetRT( RSC_FIXEDIMAGE );
    1031           0 :     WinBits nStyle = ImplInitRes( rResId );
    1032           0 :     ImplInit( pParent, nStyle );
    1033           0 :     ImplLoadRes( rResId );
    1034             : 
    1035           0 :     if ( !(nStyle & WB_HIDE) )
    1036           0 :         Show();
    1037           0 : }
    1038             : 
    1039             : // -----------------------------------------------------------------------
    1040             : 
    1041           0 : FixedImage::~FixedImage()
    1042             : {
    1043           0 : }
    1044             : 
    1045             : // -----------------------------------------------------------------------
    1046             : 
    1047           0 : void FixedImage::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
    1048             :                            const Point& rPos, const Size& rSize )
    1049             : {
    1050           0 :     sal_uInt16 nStyle = 0;
    1051           0 :     if ( !(nDrawFlags & WINDOW_DRAW_NODISABLE) )
    1052             :     {
    1053           0 :         if ( !IsEnabled() )
    1054           0 :             nStyle |= IMAGE_DRAW_DISABLE;
    1055             :     }
    1056             : 
    1057           0 :     Image *pImage = &maImage;
    1058           0 :     Color aCol;
    1059             : 
    1060             :     // Haben wir ueberhaupt ein Image
    1061           0 :     if ( !(!(*pImage)) )
    1062             :     {
    1063           0 :         if ( GetStyle() & WB_SCALE )
    1064           0 :             pDev->DrawImage( rPos, rSize, *pImage, nStyle );
    1065             :         else
    1066             :         {
    1067           0 :             Point aPos = ImplCalcPos( GetStyle(), rPos, pImage->GetSizePixel(), rSize );
    1068           0 :             pDev->DrawImage( aPos, *pImage, nStyle );
    1069             :         }
    1070             :     }
    1071             : 
    1072           0 :     mbInUserDraw = sal_True;
    1073           0 :     UserDrawEvent aUDEvt( pDev, Rectangle( rPos, rSize ), 0, nStyle );
    1074           0 :     UserDraw( aUDEvt );
    1075           0 :     mbInUserDraw = sal_False;
    1076           0 : }
    1077             : 
    1078             : // -----------------------------------------------------------------------
    1079             : 
    1080           0 : void FixedImage::Paint( const Rectangle& )
    1081             : {
    1082           0 :     ImplDraw( this, 0, Point(), GetOutputSizePixel() );
    1083           0 : }
    1084             : 
    1085             : // -----------------------------------------------------------------------
    1086             : 
    1087           0 : Size FixedImage::GetOptimalSize( WindowSizeType ) const
    1088             : {
    1089           0 :     const Image* pImage = &maImage;
    1090           0 :     return pImage->GetSizePixel();
    1091             : }
    1092             : 
    1093             : // -----------------------------------------------------------------------
    1094             : 
    1095           0 : void FixedImage::UserDraw( const UserDrawEvent& )
    1096             : {
    1097           0 : }
    1098             : 
    1099             : // -----------------------------------------------------------------------
    1100             : 
    1101           0 : void FixedImage::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
    1102             :                        sal_uLong nFlags )
    1103             : {
    1104           0 :     Point       aPos  = pDev->LogicToPixel( rPos );
    1105           0 :     Size        aSize = pDev->LogicToPixel( rSize );
    1106           0 :     Rectangle   aRect( aPos, aSize );
    1107             : 
    1108           0 :     pDev->Push();
    1109           0 :     pDev->SetMapMode();
    1110             : 
    1111             :     // Border
    1112           0 :     if ( !(nFlags & WINDOW_DRAW_NOBORDER) && (GetStyle() & WB_BORDER) )
    1113             :     {
    1114           0 :         ImplDrawFrame( pDev, aRect );
    1115             :     }
    1116           0 :     pDev->IntersectClipRegion( aRect );
    1117           0 :     ImplDraw( pDev, nFlags, aRect.TopLeft(), aRect.GetSize() );
    1118             : 
    1119           0 :     pDev->Pop();
    1120           0 : }
    1121             : 
    1122             : // -----------------------------------------------------------------------
    1123             : 
    1124           0 : void FixedImage::Resize()
    1125             : {
    1126           0 :     Control::Resize();
    1127           0 :     Invalidate();
    1128           0 : }
    1129             : 
    1130             : // -----------------------------------------------------------------------
    1131             : 
    1132           0 : void FixedImage::StateChanged( StateChangedType nType )
    1133             : {
    1134           0 :     Control::StateChanged( nType );
    1135             : 
    1136           0 :     if ( (nType == STATE_CHANGE_ENABLE) ||
    1137             :          (nType == STATE_CHANGE_DATA) ||
    1138             :          (nType == STATE_CHANGE_UPDATEMODE) )
    1139             :     {
    1140           0 :         if ( IsReallyVisible() && IsUpdateMode() )
    1141           0 :             Invalidate();
    1142             :     }
    1143           0 :     else if ( nType == STATE_CHANGE_STYLE )
    1144             :     {
    1145           0 :         SetStyle( ImplInitStyle( GetStyle() ) );
    1146           0 :         if ( (GetPrevStyle() & FIXEDIMAGE_VIEW_STYLE) !=
    1147           0 :              (GetStyle() & FIXEDIMAGE_VIEW_STYLE) )
    1148           0 :             Invalidate();
    1149             :     }
    1150           0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
    1151             :     {
    1152           0 :         ImplInitSettings();
    1153           0 :         Invalidate();
    1154             :     }
    1155           0 : }
    1156             : 
    1157             : // -----------------------------------------------------------------------
    1158             : 
    1159           0 : void FixedImage::DataChanged( const DataChangedEvent& rDCEvt )
    1160             : {
    1161           0 :     Control::DataChanged( rDCEvt );
    1162             : 
    1163           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
    1164           0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
    1165             :     {
    1166           0 :         ImplInitSettings();
    1167           0 :         Invalidate();
    1168             :     }
    1169           0 : }
    1170             : 
    1171             : // -----------------------------------------------------------------------
    1172             : 
    1173           0 : void FixedImage::SetImage( const Image& rImage )
    1174             : {
    1175           0 :     if ( rImage != maImage )
    1176             :     {
    1177           0 :         maImage = rImage;
    1178           0 :         StateChanged( STATE_CHANGE_DATA );
    1179           0 :         queue_resize();
    1180             :     }
    1181           0 : }
    1182             : 
    1183             : // -----------------------------------------------------------------------
    1184             : 
    1185           0 : sal_Bool FixedImage::SetModeImage( const Image& rImage )
    1186             : {
    1187           0 :     SetImage( rImage );
    1188           0 :     return sal_True;
    1189             : }
    1190             : 
    1191             : // -----------------------------------------------------------------------
    1192             : 
    1193           0 : const Image& FixedImage::GetModeImage( ) const
    1194             : {
    1195           0 :     return maImage;
    1196             : }
    1197             : 
    1198           0 : bool FixedImage::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
    1199             : {
    1200           0 :     if (rKey == "pixbuf")
    1201             :     {
    1202           0 :         static ImplImageTreeSingletonRef aImageTree;
    1203             :         OUString sCurrentSymbolsStyle =
    1204           0 :             Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName();
    1205           0 :         const OUString sFileName(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
    1206           0 :         BitmapEx aBitmap;
    1207           0 :         bool bSuccess = aImageTree->loadImage(sFileName, sCurrentSymbolsStyle, aBitmap, true);
    1208             :         SAL_WARN_IF(!bSuccess, "vcl.layout", "Unable to load " << sFileName
    1209             :             << " from theme " << sCurrentSymbolsStyle);
    1210           0 :         SetImage(Image(aBitmap));
    1211             :     }
    1212             :     else
    1213           0 :         return Control::set_property(rKey, rValue);
    1214           0 :     return true;
    1215             : }
    1216             : 
    1217             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10