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 | |
parent | 9c18a3edd46fcff26b0fb3f2c583f3200c283154 (diff) |
dba34b: during #i112779#: don't hold an extra BitmapEx in ImageControl, use base classes Image instead
-rw-r--r-- | svtools/source/uno/unoiface.cxx | 2 | ||||
-rw-r--r-- | toolkit/inc/toolkit/awt/vclxwindows.hxx | 2 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindows.cxx | 6 | ||||
-rw-r--r-- | vcl/inc/vcl/imgctrl.hxx | 11 | ||||
-rw-r--r-- | vcl/source/control/imgctrl.cxx | 177 | ||||
-rw-r--r-- | vcl/source/control/throbber.cxx | 4 |
6 files changed, 75 insertions, 127 deletions
diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx index 2d22d9cedb33..18ab6f804d0c 100644 --- a/svtools/source/uno/unoiface.cxx +++ b/svtools/source/uno/unoiface.cxx @@ -1652,7 +1652,7 @@ void SVTXRoadmap::ImplSetNewImage() { OSL_PRECOND( GetWindow(), "SVTXRoadmap::ImplSetNewImage: window is required to be not-NULL!" ); ::svt::ORoadmap* pButton = static_cast< ::svt::ORoadmap* >( GetWindow() ); - pButton->SetRoadmapBitmap( GetBitmap() ); + pButton->SetRoadmapBitmap( GetImage().GetBitmapEx() ); } void SVTXRoadmap::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) diff --git a/toolkit/inc/toolkit/awt/vclxwindows.hxx b/toolkit/inc/toolkit/awt/vclxwindows.hxx index fb110cb74391..0e597779342e 100644 --- a/toolkit/inc/toolkit/awt/vclxwindows.hxx +++ b/toolkit/inc/toolkit/awt/vclxwindows.hxx @@ -121,7 +121,7 @@ private: Image maImage; protected: - BitmapEx GetBitmap() const { return maImage.GetBitmapEx(); } + const Image& GetImage() const { return maImage; } protected: // ::com::sun::star::awt::XWindow diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index db34c840f8eb..c69e7c550d90 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -219,7 +219,7 @@ void VCLXGraphicControl::ImplSetNewImage() { OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" ); Button* pButton = static_cast< Button* >( GetWindow() ); - pButton->SetModeBitmap( GetBitmap() ); + pButton->SetModeImage( GetImage() ); } void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, short Flags ) throw(::com::sun::star::uno::RuntimeException) @@ -660,14 +660,14 @@ void VCLXImageControl::ImplSetNewImage() { OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" ); ImageControl* pControl = static_cast< ImageControl* >( GetWindow() ); - pControl->SetBitmap( GetBitmap() ); + pControl->SetImage( GetImage() ); } ::com::sun::star::awt::Size VCLXImageControl::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); - Size aSz = GetBitmap().GetSizePixel(); + Size aSz = GetImage().GetSizePixel(); aSz = ImplCalcWindowSize( aSz ); return AWTSize(aSz); diff --git a/vcl/inc/vcl/imgctrl.hxx b/vcl/inc/vcl/imgctrl.hxx index 83bd300379d6..156b955e95aa 100644 --- a/vcl/inc/vcl/imgctrl.hxx +++ b/vcl/inc/vcl/imgctrl.hxx @@ -40,8 +40,6 @@ class VCL_DLLPUBLIC ImageControl : public FixedImage { private: - BitmapEx maBmp; - BitmapEx maBmpHC; ::sal_Int16 mnScaleMode; public: @@ -53,16 +51,13 @@ public: ::sal_Int16 GetScaleMode() const { return mnScaleMode; } virtual void Resize(); - virtual void UserDraw( const UserDrawEvent& rUDEvt ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, ULONG nFlags ); virtual void Paint( const Rectangle& rRect ); virtual void GetFocus(); virtual void LoseFocus(); - void SetBitmap( const BitmapEx& rBmp ); - using OutputDevice::GetBitmap; - const BitmapEx& GetBitmap() const { return maBmp; } - BOOL SetModeBitmap( const BitmapEx& rBitmap, BmpColorMode eMode = BMP_COLOR_NORMAL ); - const BitmapEx& GetModeBitmap( BmpColorMode eMode = BMP_COLOR_NORMAL ) const; +protected: + void ImplDraw( OutputDevice& rDev, ULONG nDrawFlags, const Point& rPos, const Size& rSize ) const; }; #endif // _SV_IMGCTRL_HXX 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() { diff --git a/vcl/source/control/throbber.cxx b/vcl/source/control/throbber.cxx index eab39b735b4d..37115814cab9 100644 --- a/vcl/source/control/throbber.cxx +++ b/vcl/source/control/throbber.cxx @@ -202,7 +202,7 @@ void Throbber::setImageList( ::std::vector< Image > const& i_images ) mnStepCount = maImageList.size(); const Image aInitialImage( mnStepCount ? maImageList[ 0 ] : Image() ); - SetBitmap( aInitialImage.GetBitmapEx() ); + SetImage( aInitialImage ); } //-------------------------------------------------------------------- @@ -277,7 +277,7 @@ IMPL_LINK( Throbber, TimeOutHdl, void*, EMPTYARG ) } } - SetBitmap( maImageList[ mnCurStep ].GetBitmapEx() ); + SetImage( maImageList[ mnCurStep ] ); return 0; } |