diff options
author | Mathias Bauer <mba@openoffice.org> | 2011-02-03 15:53:56 +0100 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2011-02-03 15:53:56 +0100 |
commit | 2e913ff4d61087475ddf3d15455a652cb50c0549 (patch) | |
tree | 9fc661cdf6462f6d245cd92ac2a20c747e1f9cd9 /vcl | |
parent | fd66c3fb05c8aa2031e6f859f6cfaef0ee7bfa87 (diff) | |
parent | 99ff7a9fb521895d6ba18ca4ca92d7eb0c3524fd (diff) |
CWS gnumake3: resync to m99
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/vcl/fixed.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/vcl/imgctrl.hxx | 14 | ||||
-rw-r--r-- | vcl/inc/vcl/throbber.hxx | 103 | ||||
-rw-r--r-- | vcl/prj/d.lst | 1 | ||||
-rw-r--r-- | vcl/source/control/imgctrl.cxx | 192 | ||||
-rw-r--r-- | vcl/source/control/makefile.mk | 22 | ||||
-rw-r--r-- | vcl/source/control/throbber.cxx | 325 | ||||
-rw-r--r-- | vcl/source/src/makefile.mk | 3 | ||||
-rwxr-xr-x | vcl/source/src/throbber.src | 114 | ||||
-rw-r--r-- | vcl/workben/svpclient.cxx | 2 |
10 files changed, 641 insertions, 139 deletions
diff --git a/vcl/inc/vcl/fixed.hxx b/vcl/inc/vcl/fixed.hxx index 4460694420a0..4e068fc32731 100644 --- a/vcl/inc/vcl/fixed.hxx +++ b/vcl/inc/vcl/fixed.hxx @@ -167,10 +167,10 @@ private: SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); SAL_DLLPRIVATE void ImplInitSettings(); - SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, ULONG nDrawFlags, - const Point& rPos, const Size& rSize ); protected: + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, ULONG nDrawFlags, + const Point& rPos, const Size& rSize ); SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); public: diff --git a/vcl/inc/vcl/imgctrl.hxx b/vcl/inc/vcl/imgctrl.hxx index fa3b01463f34..25c1e395c837 100644 --- a/vcl/inc/vcl/imgctrl.hxx +++ b/vcl/inc/vcl/imgctrl.hxx @@ -40,28 +40,26 @@ class VCL_DLLPUBLIC ImageControl : public FixedImage { private: - BitmapEx maBmp; - BitmapEx maBmpHC; ::sal_Int16 mnScaleMode; public: ImageControl( Window* pParent, WinBits nStyle = 0 ); + ImageControl( Window* pParent, const ResId& rResId ); // set/get the scale mode. This is one of the css.awt.ImageScaleMode constants void SetScaleMode( const ::sal_Int16 _nMode ); ::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; +private: + using FixedImage::ImplDraw; }; #endif // _SV_IMGCTRL_HXX diff --git a/vcl/inc/vcl/throbber.hxx b/vcl/inc/vcl/throbber.hxx new file mode 100644 index 000000000000..f86a9944e28f --- /dev/null +++ b/vcl/inc/vcl/throbber.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VCL_THROBBER_HXX +#define VCL_THROBBER_HXX + +#include "vcl/dllapi.h" +#include "vcl/imgctrl.hxx" +#include "vcl/timer.hxx" + +#include <vos/mutex.hxx> + +#include <com/sun/star/graphic/XGraphic.hpp> + +#include <vector> + +class VCL_DLLPUBLIC Throbber : public ImageControl +{ +public: + enum ImageSet + { + /// no (default) images at all + IMAGES_NONE, + /// automatically decide between different image sets, depending on what fits best the actual size + IMAGES_AUTO, + /// default images, 16x16 pixels + IMAGES_16_PX, + /// default images, 32x32 pixels + IMAGES_32_PX, + /// default images, 64x64 pixels + IMAGES_64_PX, + }; + +public: + Throbber( Window* i_parentWindow, WinBits i_style, const ImageSet i_imageSet = IMAGES_AUTO ); + Throbber( Window* i_parentWindow, const ResId& i_resId, const ImageSet i_imageSet = IMAGES_AUTO ); + ~Throbber(); + + // Properties + void setStepTime( sal_Int32 nStepTime ) { mnStepTime = nStepTime; } + sal_Int32 getStepTime() const { return mnStepTime; } + + void setRepeat( sal_Bool bRepeat ) { mbRepeat = bRepeat; } + sal_Bool getRepeat() const { return mbRepeat; } + + // animation control + void start(); + void stop(); + bool isRunning() const; + + void setImageList( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > >& ImageList ); + void setImageList( ::std::vector< Image > const& i_images ); + + // default images + static ::std::vector< ::rtl::OUString > + getDefaultImageURLs( const ImageSet i_imageSet ); + +protected: + // Window overridables + virtual void Resize(); + +private: + SAL_DLLPRIVATE void initImages(); + +private: + ::std::vector< Image > maImageList; + + sal_Bool mbRepeat; + sal_Int32 mnStepTime; + sal_Int32 mnCurStep; + sal_Int32 mnStepCount; + AutoTimer maWaitTimer; + ImageSet meImageSet; + + DECL_LINK( TimeOutHdl, void* ); +}; + +#endif // VCL_THROBBER_HXX + diff --git a/vcl/prj/d.lst b/vcl/prj/d.lst index d99694fdd458..5a7dd7d9ef91 100644 --- a/vcl/prj/d.lst +++ b/vcl/prj/d.lst @@ -58,6 +58,7 @@ mkdir: %_DEST%\inc%_EXT%\vcl ..\inc\vcl\image.hxx %_DEST%\inc%_EXT%\vcl\image.hxx ..\inc\vcl\imagerepository.hxx %_DEST%\inc%_EXT%\vcl\imagerepository.hxx ..\inc\vcl\imgctrl.hxx %_DEST%\inc%_EXT%\vcl\imgctrl.hxx +..\inc\vcl\throbber.hxx %_DEST%\inc%_EXT%\vcl\throbber.hxx ..\inc\vcl\impdel.hxx %_DEST%\inc%_EXT%\vcl\impdel.hxx ..\inc\vcl\inputctx.hxx %_DEST%\inc%_EXT%\vcl\inputctx.hxx ..\inc\vcl\javachild.hxx %_DEST%\inc%_EXT%\vcl\javachild.hxx diff --git a/vcl/source/control/imgctrl.cxx b/vcl/source/control/imgctrl.cxx index 075a8b1b95e2..662efd407995 100644 --- a/vcl/source/control/imgctrl.cxx +++ b/vcl/source/control/imgctrl.cxx @@ -30,6 +30,7 @@ #include <vcl/event.hxx> #include <vcl/imgctrl.hxx> +#include <tools/rcid.h> #include <com/sun/star/awt/ImageScaleMode.hdl> @@ -37,10 +38,18 @@ namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; // ----------------------------------------------------------------------- -ImageControl::ImageControl( Window* pParent, WinBits nStyle ) : - FixedImage( pParent, nStyle ) +ImageControl::ImageControl( Window* pParent, WinBits nStyle ) + :FixedImage( pParent, nStyle ) + ,mnScaleMode( ImageScaleMode::Anisotropic ) +{ +} + +// ----------------------------------------------------------------------- + +ImageControl::ImageControl( Window* pParent, const ResId& rResId ) + :FixedImage( pParent, rResId ) + ,mnScaleMode( ImageScaleMode::Anisotropic ) { - mnScaleMode = ImageScaleMode::Anisotropic; } // ----------------------------------------------------------------------- @@ -86,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 = &rImage; + if ( !!rImageHC && GetSettings().GetStyleSettings().GetHighContrastMode() ) + pImage = &rImageHC; + + const Rectangle aDrawRect( rPos, rSize ); + if ( !*pImage ) { String sText( GetText() ); if ( !sText.Len() ) @@ -104,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 ); } -} + break; -// ----------------------------------------------------------------------- - -void ImageControl::SetBitmap( const BitmapEx& rBmp ) -{ - maBmp = rBmp; - StateChanged( STATE_CHANGE_DATA ); -} - -// ----------------------------------------------------------------------- + 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 ); @@ -252,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/makefile.mk b/vcl/source/control/makefile.mk index b1644e58ccd9..de2613b1084f 100644 --- a/vcl/source/control/makefile.mk +++ b/vcl/source/control/makefile.mk @@ -43,16 +43,21 @@ CDEFS+=-D_STD_NO_NAMESPACE -D_VOS_NO_NAMESPACE -D_UNO_NO_NAMESPACE # --- Files -------------------------------------------------------- -SLOFILES= $(SLO)$/button.obj \ +EXCEPTIONSFILES= \ + $(SLO)$/button.obj \ $(SLO)$/ctrl.obj \ - $(SLO)$/combobox.obj \ $(SLO)$/edit.obj \ - $(SLO)$/field.obj \ $(SLO)$/field2.obj \ + $(SLO)$/ilstbox.obj \ + $(SLO)$/tabctrl.obj \ + $(SLO)$/throbber.obj + +SLOFILES= $(EXCEPTIONSFILES) \ + $(SLO)$/combobox.obj \ + $(SLO)$/field.obj \ $(SLO)$/fixbrd.obj \ $(SLO)$/fixed.obj \ $(SLO)$/group.obj \ - $(SLO)$/ilstbox.obj \ $(SLO)$/imgctrl.obj \ $(SLO)$/longcurr.obj \ $(SLO)$/lstbox.obj \ @@ -62,19 +67,12 @@ SLOFILES= $(SLO)$/button.obj \ $(SLO)$/slider.obj \ $(SLO)$/spinfld.obj \ $(SLO)$/spinbtn.obj \ - $(SLO)$/tabctrl.obj \ $(SLO)$/quickselectionengine.obj -EXCEPTIONSFILES= \ - $(SLO)$/button.obj \ - $(SLO)$/ctrl.obj \ - $(SLO)$/edit.obj \ - $(SLO)$/field2.obj \ - $(SLO)$/ilstbox.obj \ - $(SLO)$/tabctrl.obj # --- Targets ------------------------------------------------------ .INCLUDE : target.mk .INCLUDE : $(PRJ)$/util$/target.pmk + diff --git a/vcl/source/control/throbber.cxx b/vcl/source/control/throbber.cxx new file mode 100644 index 000000000000..6ebd02cb5de1 --- /dev/null +++ b/vcl/source/control/throbber.cxx @@ -0,0 +1,325 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_vcl.hxx" + +#include "vcl/throbber.hxx" +#include "vcl/svapp.hxx" + +#include <com/sun/star/graphic/XGraphicProvider.hpp> +#include <com/sun/star/awt/ImageScaleMode.hpp> + +#include <comphelper/componentcontext.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <comphelper/processfactory.hxx> +#include <rtl/ustrbuf.hxx> +#include <tools/diagnose_ex.h> +#include <tools/urlobj.hxx> + +#include <limits> + +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::graphic::XGraphic; +using ::com::sun::star::graphic::XGraphicProvider; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::Exception; +namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; + +//---------------------------------------------------------------------------------------------------------------------- +Throbber::Throbber( Window* i_parentWindow, WinBits i_style, const ImageSet i_imageSet ) + :ImageControl( i_parentWindow, i_style ) + ,mbRepeat( sal_True ) + ,mnStepTime( 100 ) + ,mnCurStep( 0 ) + ,mnStepCount( 0 ) + ,meImageSet( i_imageSet ) +{ + maWaitTimer.SetTimeout( mnStepTime ); + maWaitTimer.SetTimeoutHdl( LINK( this, Throbber, TimeOutHdl ) ); + + SetScaleMode( ImageScaleMode::None ); + initImages(); +} + +//-------------------------------------------------------------------- +Throbber::Throbber( Window* i_parentWindow, const ResId& i_resId, const ImageSet i_imageSet ) + :ImageControl( i_parentWindow, i_resId ) + ,mbRepeat( sal_True ) + ,mnStepTime( 100 ) + ,mnCurStep( 0 ) + ,mnStepCount( 0 ) + ,meImageSet( i_imageSet ) +{ + maWaitTimer.SetTimeout( mnStepTime ); + maWaitTimer.SetTimeoutHdl( LINK( this, Throbber, TimeOutHdl ) ); + + SetScaleMode( ImageScaleMode::None ); + initImages(); +} + +//---------------------------------------------------------------------------------------------------------------------- +Throbber::~Throbber() +{ + maWaitTimer.Stop(); +} + +//---------------------------------------------------------------------------------------------------------------------- +namespace +{ + //.................................................................................................................. + ::rtl::OUString lcl_getHighContrastURL( ::rtl::OUString const& i_imageURL ) + { + INetURLObject aURL( i_imageURL ); + if ( aURL.GetProtocol() != INET_PROT_PRIV_SOFFICE ) + { + OSL_VERIFY( aURL.insertName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "hicontrast" ) ), false, 0 ) ); + return aURL.GetMainURL( INetURLObject::NO_DECODE ); + } + // the private: scheme is not considered to be hierarchical by INetURLObject, so manually insert the + // segment + const sal_Int32 separatorPos = i_imageURL.indexOf( '/' ); + ENSURE_OR_RETURN( separatorPos != -1, "lcl_getHighContrastURL: unsipported URL scheme - cannot automatically determine HC version!", i_imageURL ); + + ::rtl::OUStringBuffer composer; + composer.append( i_imageURL.copy( 0, separatorPos ) ); + composer.appendAscii( "/hicontrast" ); + composer.append( i_imageURL.copy( separatorPos ) ); + return composer.makeStringAndClear(); + } + + //.................................................................................................................. + ::std::vector< Image > lcl_loadImageSet( const Throbber::ImageSet i_imageSet, const bool i_isHiContrast ) + { + ::std::vector< Image > aImages; + ENSURE_OR_RETURN( i_imageSet != Throbber::IMAGES_NONE, "lcl_loadImageSet: illegal image set", aImages ); + + const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + const Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW ); + + ::std::vector< ::rtl::OUString > aImageURLs( Throbber::getDefaultImageURLs( i_imageSet ) ); + aImages.reserve( aImageURLs.size() ); + + ::comphelper::NamedValueCollection aMediaProperties; + for ( ::std::vector< ::rtl::OUString >::const_iterator imageURL = aImageURLs.begin(); + imageURL != aImageURLs.end(); + ++imageURL + ) + { + Reference< XGraphic > xGraphic; + if ( i_isHiContrast ) + { + aMediaProperties.put( "URL", lcl_getHighContrastURL( *imageURL ) ); + xGraphic.set( xGraphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY ); + } + if ( !xGraphic.is() ) + { + aMediaProperties.put( "URL", *imageURL ); + xGraphic.set( xGraphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY ); + } + aImages.push_back( Image( xGraphic ) ); + } + + return aImages; + } +} + +//---------------------------------------------------------------------------------------------------------------------- +void Throbber::Resize() +{ + ImageControl::Resize(); + + if ( meImageSet == IMAGES_AUTO ) + initImages(); +} + +//---------------------------------------------------------------------------------------------------------------------- +void Throbber::initImages() +{ + if ( meImageSet == IMAGES_NONE ) + return; + + try + { + ::std::vector< ::std::vector< Image > > aImageSets; + const bool isHiContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); + if ( meImageSet == IMAGES_AUTO ) + { + aImageSets.push_back( lcl_loadImageSet( IMAGES_16_PX, isHiContrast ) ); + aImageSets.push_back( lcl_loadImageSet( IMAGES_32_PX, isHiContrast ) ); + aImageSets.push_back( lcl_loadImageSet( IMAGES_64_PX, isHiContrast ) ); + } + else + { + aImageSets.push_back( lcl_loadImageSet( meImageSet, isHiContrast ) ); + } + + // find the best matching image set (size-wise) + const ::Size aWindowSizePixel = GetSizePixel(); + size_t nPreferredSet = 0; + if ( aImageSets.size() > 1 ) + { + long nMinimalDistance = ::std::numeric_limits< long >::max(); + for ( ::std::vector< ::std::vector< Image > >::const_iterator check = aImageSets.begin(); + check != aImageSets.end(); + ++check + ) + { + ENSURE_OR_CONTINUE( !check->empty(), "Throbber::initImages: illegal image!" ); + const Size aImageSize = (*check)[0].GetSizePixel(); + + if ( ( aImageSize.Width() > aWindowSizePixel.Width() ) + || ( aImageSize.Height() > aWindowSizePixel.Height() ) + ) + // do not use an image set which doesn't fit into the window + continue; + + const sal_Int64 distance = + ( aWindowSizePixel.Width() - aImageSize.Width() ) * ( aWindowSizePixel.Width() - aImageSize.Width() ) + + ( aWindowSizePixel.Height() - aImageSize.Height() ) * ( aWindowSizePixel.Height() - aImageSize.Height() ); + if ( distance < nMinimalDistance ) + { + nMinimalDistance = distance; + nPreferredSet = check - aImageSets.begin(); + } + } + } + + if ( nPreferredSet < aImageSets.size() ) + setImageList( aImageSets[nPreferredSet] ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//---------------------------------------------------------------------------------------------------------------------- +void Throbber::start() +{ + maWaitTimer.Start(); +} + +//---------------------------------------------------------------------------------------------------------------------- +void Throbber::stop() +{ + maWaitTimer.Stop(); +} + +//---------------------------------------------------------------------------------------------------------------------- +bool Throbber::isRunning() const +{ + return maWaitTimer.IsActive(); +} + +//---------------------------------------------------------------------------------------------------------------------- +void Throbber::setImageList( ::std::vector< Image > const& i_images ) +{ + maImageList = i_images; + + mnStepCount = maImageList.size(); + const Image aInitialImage( mnStepCount ? maImageList[ 0 ] : Image() ); + SetImage( aInitialImage ); +} + +//---------------------------------------------------------------------------------------------------------------------- +void Throbber::setImageList( const Sequence< Reference< XGraphic > >& rImageList ) +{ + ::std::vector< Image > aImages( rImageList.getLength() ); + ::std::copy( + rImageList.getConstArray(), + rImageList.getConstArray() + rImageList.getLength(), + aImages.begin() + ); + setImageList( aImages ); +} + +//---------------------------------------------------------------------------------------------------------------------- +::std::vector< ::rtl::OUString > Throbber::getDefaultImageURLs( const ImageSet i_imageSet ) +{ + ::std::vector< ::rtl::OUString > aImageURLs; + + sal_Char const* const pResolutions[] = { "16", "32", "64" }; + size_t const nImageCounts[] = { 6, 12, 12 }; + + size_t index = 0; + switch ( i_imageSet ) + { + case IMAGES_16_PX: index = 0; break; + case IMAGES_32_PX: index = 1; break; + case IMAGES_64_PX: index = 2; break; + case IMAGES_NONE: + case IMAGES_AUTO: + OSL_ENSURE( false, "Throbber::getDefaultImageURLs: illegal image set!" ); + return aImageURLs; + } + + aImageURLs.reserve( nImageCounts[index] ); + for ( size_t i=0; i<nImageCounts[index]; ++i ) + { + ::rtl::OUStringBuffer aURL; + aURL.appendAscii( "private:graphicrepository/shared/spinner-" ); + aURL.appendAscii( pResolutions[index] ); + aURL.appendAscii( "-" ); + if ( i < 9 ) + aURL.appendAscii( "0" ); + aURL.append ( sal_Int32( i + 1 ) ); + aURL.appendAscii( ".png" ); + + aImageURLs.push_back( aURL.makeStringAndClear() ); + } + + return aImageURLs; +} + +//---------------------------------------------------------------------------------------------------------------------- +IMPL_LINK( Throbber, TimeOutHdl, void*, EMPTYARG ) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if ( maImageList.empty() ) + return 0; + + if ( mnCurStep < mnStepCount - 1 ) + mnCurStep += 1; + else + { + if ( mbRepeat ) + { + // start over + mnCurStep = 0; + } + else + { + stop(); + } + } + + SetImage( maImageList[ mnCurStep ] ); + + return 0; +} diff --git a/vcl/source/src/makefile.mk b/vcl/source/src/makefile.mk index 40b7d4e75dfe..161d821573b9 100644 --- a/vcl/source/src/makefile.mk +++ b/vcl/source/src/makefile.mk @@ -44,7 +44,8 @@ SRC1FILES= images.src \ helptext.src \ units.src \ btntext.src \ - print.src + print.src \ + throbber.src \ RESLIB1NAME= $(RESTARGET) RESLIB1IMAGES= $(PRJ)$/source/src diff --git a/vcl/source/src/throbber.src b/vcl/source/src/throbber.src new file mode 100755 index 000000000000..d3c5ea44035c --- /dev/null +++ b/vcl/source/src/throbber.src @@ -0,0 +1,114 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// TODO: we need a mechanism to add images to images.zip, *without* +// referring them in resource files. The below resources are never loaded +// at runtime, instead, the images in images.zip are accessed via +// private:graphicrepository/* URLs. + +Resource 1000 +{ + Image 1 { ImageBitmap = Bitmap{ file = "shared/spinner-16-01.png"; }; }; + Image 2 { ImageBitmap = Bitmap{ file = "shared/spinner-16-02.png"; }; }; + Image 3 { ImageBitmap = Bitmap{ file = "shared/spinner-16-03.png"; }; }; + Image 4 { ImageBitmap = Bitmap{ file = "shared/spinner-16-04.png"; }; }; + Image 5 { ImageBitmap = Bitmap{ file = "shared/spinner-16-05.png"; }; }; + Image 6 { ImageBitmap = Bitmap{ file = "shared/spinner-16-06.png"; }; }; +}; + +Resource 1001 +{ + Image 1 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-16-01.png"; }; }; + Image 2 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-16-02.png"; }; }; + Image 3 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-16-03.png"; }; }; + Image 4 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-16-04.png"; }; }; + Image 5 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-16-05.png"; }; }; + Image 6 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-16-06.png"; }; }; +}; + +Resource 1002 +{ + Image 1 { ImageBitmap = Bitmap{ file = "shared/spinner-32-01.png"; }; }; + Image 2 { ImageBitmap = Bitmap{ file = "shared/spinner-32-02.png"; }; }; + Image 3 { ImageBitmap = Bitmap{ file = "shared/spinner-32-03.png"; }; }; + Image 4 { ImageBitmap = Bitmap{ file = "shared/spinner-32-04.png"; }; }; + Image 5 { ImageBitmap = Bitmap{ file = "shared/spinner-32-05.png"; }; }; + Image 6 { ImageBitmap = Bitmap{ file = "shared/spinner-32-06.png"; }; }; + Image 7 { ImageBitmap = Bitmap{ file = "shared/spinner-32-07.png"; }; }; + Image 8 { ImageBitmap = Bitmap{ file = "shared/spinner-32-08.png"; }; }; + Image 9 { ImageBitmap = Bitmap{ file = "shared/spinner-32-09.png"; }; }; + Image 10 { ImageBitmap = Bitmap{ file = "shared/spinner-32-10.png"; }; }; + Image 11 { ImageBitmap = Bitmap{ file = "shared/spinner-32-11.png"; }; }; + Image 12 { ImageBitmap = Bitmap{ file = "shared/spinner-32-12.png"; }; }; +}; + +Resource 1003 +{ + Image 1 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-32-01.png"; }; }; + Image 2 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-32-02.png"; }; }; + Image 3 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-32-03.png"; }; }; + Image 4 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-32-04.png"; }; }; + Image 5 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-32-05.png"; }; }; + Image 6 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-32-06.png"; }; }; + Image 7 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-32-07.png"; }; }; + Image 8 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-32-08.png"; }; }; + Image 9 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-32-09.png"; }; }; + Image 10 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-32-10.png"; }; }; + Image 11 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-32-11.png"; }; }; + Image 12 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-32-12.png"; }; }; +}; + +Resource 1004 +{ + Image 1 { ImageBitmap = Bitmap{ file = "shared/spinner-64-01.png"; }; }; + Image 2 { ImageBitmap = Bitmap{ file = "shared/spinner-64-02.png"; }; }; + Image 3 { ImageBitmap = Bitmap{ file = "shared/spinner-64-03.png"; }; }; + Image 4 { ImageBitmap = Bitmap{ file = "shared/spinner-64-04.png"; }; }; + Image 5 { ImageBitmap = Bitmap{ file = "shared/spinner-64-05.png"; }; }; + Image 6 { ImageBitmap = Bitmap{ file = "shared/spinner-64-06.png"; }; }; + Image 7 { ImageBitmap = Bitmap{ file = "shared/spinner-64-07.png"; }; }; + Image 8 { ImageBitmap = Bitmap{ file = "shared/spinner-64-08.png"; }; }; + Image 9 { ImageBitmap = Bitmap{ file = "shared/spinner-64-09.png"; }; }; + Image 10 { ImageBitmap = Bitmap{ file = "shared/spinner-64-10.png"; }; }; + Image 11 { ImageBitmap = Bitmap{ file = "shared/spinner-64-11.png"; }; }; + Image 12 { ImageBitmap = Bitmap{ file = "shared/spinner-64-12.png"; }; }; +}; + +Resource 1005 +{ + Image 1 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-64-01.png"; }; }; + Image 2 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-64-02.png"; }; }; + Image 3 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-64-03.png"; }; }; + Image 4 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-64-04.png"; }; }; + Image 5 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-64-05.png"; }; }; + Image 6 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-64-06.png"; }; }; + Image 7 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-64-07.png"; }; }; + Image 8 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-64-08.png"; }; }; + Image 9 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-64-09.png"; }; }; + Image 10 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-64-10.png"; }; }; + Image 11 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-64-11.png"; }; }; + Image 12 { ImageBitmap = Bitmap{ file = "hicontrast/shared/spinner-64-12.png"; }; }; +}; diff --git a/vcl/workben/svpclient.cxx b/vcl/workben/svpclient.cxx index 61ed22ca95e7..0746dbfc0379 100644 --- a/vcl/workben/svpclient.cxx +++ b/vcl/workben/svpclient.cxx @@ -291,7 +291,7 @@ IMPL_LINK( MyWin, SelectHdl, ListBox*, ) aFixedSize.Width() += 10; aFixedSize.Height() += 10; m_aImage.SetSizePixel( aFixedSize ); - m_aImage.SetBitmap( BitmapEx( aBitmap ) ); + m_aImage.SetImage( Image( BitmapEx( aBitmap ) ) ); } return 0; } |