diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-10-11 13:59:41 +0200 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-10-11 13:59:41 +0200 |
commit | 7fcbcc4b70c1e905e6cdd08ab79ea8ebd0720a5b (patch) | |
tree | 4fbe5377aeff23233492e0d2e68845bba7ded7c6 /vcl/source/control/imgctrl.cxx | |
parent | 9c18a3edd46fcff26b0fb3f2c583f3200c283154 (diff) |
dba34b: during #i112779#: don't hold an extra BitmapEx in ImageControl, use base classes Image instead
Diffstat (limited to 'vcl/source/control/imgctrl.cxx')
-rw-r--r-- | vcl/source/control/imgctrl.cxx | 177 |
1 files changed, 65 insertions, 112 deletions
diff --git a/vcl/source/control/imgctrl.cxx b/vcl/source/control/imgctrl.cxx index d0ed042db354..a379fbfdcec2 100644 --- a/vcl/source/control/imgctrl.cxx +++ b/vcl/source/control/imgctrl.cxx @@ -95,17 +95,24 @@ namespace // ----------------------------------------------------------------------- -void ImageControl::UserDraw( const UserDrawEvent& rUDEvt ) +void ImageControl::ImplDraw( OutputDevice& rDev, ULONG nDrawFlags, const Point& rPos, const Size& rSize ) const { USHORT nStyle = 0; - BitmapEx* pBitmap = &maBmp; - if( !!maBmpHC ) + if ( !(nDrawFlags & WINDOW_DRAW_NODISABLE) ) { - if( GetSettings().GetStyleSettings().GetHighContrastMode() ) - pBitmap = &maBmpHC; + if ( !IsEnabled() ) + nStyle |= IMAGE_DRAW_DISABLE; } - if ( !*pBitmap ) + const Image& rImage( GetModeImage( BMP_COLOR_NORMAL ) ); + const Image& rImageHC( GetModeImage( BMP_COLOR_HIGHCONTRAST ) ); + + const Image* pImage = &GetImage(); + if ( !!rImageHC && GetSettings().GetStyleSettings().GetHighContrastMode() ) + pImage = &rImageHC; + + const Rectangle aDrawRect( rPos, rSize ); + if ( !*pImage ) { String sText( GetText() ); if ( !sText.Len() ) @@ -113,131 +120,56 @@ void ImageControl::UserDraw( const UserDrawEvent& rUDEvt ) WinBits nWinStyle = GetStyle(); USHORT nTextStyle = FixedText::ImplGetTextStyle( nWinStyle ); - if ( !IsEnabled() ) - nTextStyle |= TEXT_DRAW_DISABLE; + if ( !(nDrawFlags & WINDOW_DRAW_NODISABLE) ) + if ( !IsEnabled() ) + nTextStyle |= TEXT_DRAW_DISABLE; - DrawText( rUDEvt.GetRect(), sText, nTextStyle ); + rDev.DrawText( aDrawRect, sText, nTextStyle ); return; } - const Rectangle& rPaintRect = rUDEvt.GetRect(); - const Size& rBitmapSize = maBmp.GetSizePixel(); + const Size& rBitmapSize = pImage->GetSizePixel(); - if( nStyle & IMAGE_DRAW_COLORTRANSFORM ) + switch ( mnScaleMode ) { - // only images support IMAGE_DRAW_COLORTRANSFORM - Image aImage( *pBitmap ); - if ( !!aImage ) - { - switch ( mnScaleMode ) - { - case ImageScaleMode::None: - { - rUDEvt.GetDevice()->DrawImage( - lcl_centerWithin( rPaintRect, rBitmapSize ), aImage, nStyle ); - } - break; - - case ImageScaleMode::Isotropic: - { - const Size aPaintSize = lcl_calcPaintSize( rPaintRect, rBitmapSize ); - rUDEvt.GetDevice()->DrawImage( - lcl_centerWithin( rPaintRect, aPaintSize ), - aPaintSize, - aImage, nStyle ); - } - break; - - case ImageScaleMode::Anisotropic: - { - rUDEvt.GetDevice()->DrawImage( - rPaintRect.TopLeft(), - rPaintRect.GetSize(), - aImage, nStyle ); - } - break; - - default: - OSL_ENSURE( false, "ImageControl::UserDraw: unhandled scale mode!" ); - break; - - } // switch ( mnScaleMode ) - } - } - else + case ImageScaleMode::None: { - switch ( mnScaleMode ) - { - case ImageScaleMode::None: - { - pBitmap->Draw( rUDEvt.GetDevice(), lcl_centerWithin( rPaintRect, rBitmapSize ) ); - } - break; - - case ImageScaleMode::Isotropic: - { - const Size aPaintSize = lcl_calcPaintSize( rPaintRect, rBitmapSize ); - pBitmap->Draw( rUDEvt.GetDevice(), - lcl_centerWithin( rPaintRect, aPaintSize ), - aPaintSize ); - } - break; - - case ImageScaleMode::Anisotropic: - { - pBitmap->Draw( rUDEvt.GetDevice(), - rPaintRect.TopLeft(), - rPaintRect.GetSize() ); - } - break; - - default: - OSL_ENSURE( false, "ImageControl::UserDraw: unhandled scale mode!" ); - break; - - } // switch ( mnScaleMode ) + rDev.DrawImage( lcl_centerWithin( aDrawRect, rBitmapSize ), *pImage, nStyle ); } -} - -// ----------------------------------------------------------------------- - -void ImageControl::SetBitmap( const BitmapEx& rBmp ) -{ - maBmp = rBmp; - StateChanged( STATE_CHANGE_DATA ); -} + break; -// ----------------------------------------------------------------------- + case ImageScaleMode::Isotropic: + { + const Size aPaintSize = lcl_calcPaintSize( aDrawRect, rBitmapSize ); + rDev.DrawImage( + lcl_centerWithin( aDrawRect, aPaintSize ), + aPaintSize, + *pImage, nStyle ); + } + break; -BOOL ImageControl::SetModeBitmap( const BitmapEx& rBitmap, BmpColorMode eMode ) -{ - if( eMode == BMP_COLOR_NORMAL ) - SetBitmap( rBitmap ); - else if( eMode == BMP_COLOR_HIGHCONTRAST ) + case ImageScaleMode::Anisotropic: { - maBmpHC = rBitmap; - StateChanged( STATE_CHANGE_DATA ); + rDev.DrawImage( + aDrawRect.TopLeft(), + aDrawRect.GetSize(), + *pImage, nStyle ); } - else - return FALSE; - return TRUE; -} + break; -// ----------------------------------------------------------------------- + default: + OSL_ENSURE( false, "ImageControl::ImplDraw: unhandled scale mode!" ); + break; -const BitmapEx& ImageControl::GetModeBitmap( BmpColorMode eMode ) const -{ - if( eMode == BMP_COLOR_HIGHCONTRAST ) - return maBmpHC; - else - return maBmp; + } // switch ( mnScaleMode ) } // ----------------------------------------------------------------------- -void ImageControl::Paint( const Rectangle& rRect ) +void ImageControl::Paint( const Rectangle& /*rRect*/ ) { - FixedImage::Paint( rRect ); + ImplDraw( *this, 0, Point(), GetOutputSizePixel() ); + if( HasFocus() ) { Window *pWin = GetWindow( WINDOW_BORDER ); @@ -261,6 +193,27 @@ void ImageControl::Paint( const Rectangle& rRect ) } // ----------------------------------------------------------------------- +void ImageControl::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, ULONG nFlags ) +{ + const Point aPos = pDev->LogicToPixel( rPos ); + const Size aSize = pDev->LogicToPixel( rSize ); + Rectangle aRect( aPos, aSize ); + + pDev->Push(); + pDev->SetMapMode(); + + // Border + if ( !(nFlags & WINDOW_DRAW_NOBORDER) && (GetStyle() & WB_BORDER) ) + { + ImplDrawFrame( pDev, aRect ); + } + pDev->IntersectClipRegion( aRect ); + ImplDraw( *pDev, nFlags, aRect.TopLeft(), aRect.GetSize() ); + + pDev->Pop(); +} + +// ----------------------------------------------------------------------- void ImageControl::GetFocus() { |