summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toolkit/inc/toolkit/awt/xsimpleanimation.hxx4
-rw-r--r--toolkit/inc/toolkit/awt/xthrobber.hxx5
-rw-r--r--toolkit/inc/toolkit/helper/throbberimpl.hxx89
-rwxr-xr-xtoolkit/source/awt/animatedimagespeer.cxx49
-rw-r--r--toolkit/source/awt/vclxtoolkit.cxx14
-rw-r--r--toolkit/source/awt/xsimpleanimation.cxx85
-rw-r--r--toolkit/source/awt/xthrobber.cxx28
-rw-r--r--toolkit/source/helper/makefile.mk1
-rw-r--r--toolkit/source/helper/throbberimpl.cxx149
-rw-r--r--vcl/inc/vcl/imgctrl.hxx1
-rw-r--r--vcl/inc/vcl/throbber.hxx103
-rw-r--r--vcl/prj/d.lst1
-rw-r--r--vcl/source/control/imgctrl.cxx15
-rw-r--r--vcl/source/control/makefile.mk22
-rw-r--r--vcl/source/control/throbber.cxx283
15 files changed, 523 insertions, 326 deletions
diff --git a/toolkit/inc/toolkit/awt/xsimpleanimation.hxx b/toolkit/inc/toolkit/awt/xsimpleanimation.hxx
index 673c7eaddf61..9e6043b7d9ef 100644
--- a/toolkit/inc/toolkit/awt/xsimpleanimation.hxx
+++ b/toolkit/inc/toolkit/awt/xsimpleanimation.hxx
@@ -38,7 +38,6 @@
//........................................................................
namespace toolkit
{
- class Throbber_Impl;
//........................................................................
//====================================================================
@@ -50,9 +49,6 @@ namespace toolkit
class XSimpleAnimation : public XSimpleAnimation_Base
{
- private:
- ::boost::scoped_ptr< Throbber_Impl > mpThrobber;
-
public:
XSimpleAnimation();
diff --git a/toolkit/inc/toolkit/awt/xthrobber.hxx b/toolkit/inc/toolkit/awt/xthrobber.hxx
index fa0df0047180..67015e049a48 100644
--- a/toolkit/inc/toolkit/awt/xthrobber.hxx
+++ b/toolkit/inc/toolkit/awt/xthrobber.hxx
@@ -40,7 +40,6 @@
namespace toolkit
{
//........................................................................
- class Throbber_Impl;
//====================================================================
//= XThrobber
@@ -53,7 +52,6 @@ namespace toolkit
,public ::boost::noncopyable
{
private:
- Throbber_Impl *mpThrobber;
void SAL_CALL InitImageList() throw(::com::sun::star::uno::RuntimeException);
public:
@@ -66,6 +64,9 @@ namespace toolkit
virtual void SAL_CALL start() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL stop() throw (::com::sun::star::uno::RuntimeException);
+ // VCLXWindow
+ virtual void SetWindow( Window* pWindow );
+
private:
XThrobber( const XThrobber& ); // never implemented
XThrobber& operator=( const XThrobber& ); // never implemented
diff --git a/toolkit/inc/toolkit/helper/throbberimpl.hxx b/toolkit/inc/toolkit/helper/throbberimpl.hxx
deleted file mode 100644
index 92fb177fd89d..000000000000
--- a/toolkit/inc/toolkit/helper/throbberimpl.hxx
+++ /dev/null
@@ -1,89 +0,0 @@
-/*************************************************************************
- *
- * 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 _TOOLKIT_HELPER_THROBBERIMPL_HXX_
-#define _TOOLKIT_HELPER_THROBBERIMPL_HXX_
-
-#include <toolkit/awt/vclxwindow.hxx>
-#include <com/sun/star/uno/Reference.hxx>
-
-#include <com/sun/star/graphic/XGraphic.hpp>
-#include <vcl/timer.hxx>
-#include <vos/mutex.hxx>
-
-//........................................................................
-namespace toolkit
-//........................................................................
-{
-
- class Throbber_Impl
- {
- private:
- vos::IMutex& mrMutex; // Reference to SolarMutex
- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > > maImageList;
- VCLXWindow& mrParent;
-
- sal_Bool mbRepeat;
- sal_Int32 mnStepTime;
- sal_Int32 mnCurStep;
- sal_Int32 mnStepCount;
- AutoTimer maWaitTimer;
-
- DECL_LINK( TimeOutHdl, Throbber_Impl* );
-
- vos::IMutex& GetMutex() { return mrMutex; }
-
- public:
- Throbber_Impl( VCLXWindow& i_rParent );
- ~Throbber_Impl();
-
- // 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; }
-
- Window const* getWindow() const { return mrParent.GetWindow(); }
- Window* getWindow() { return mrParent.GetWindow(); }
-
- // XSimpleAnimation
- 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 );
-
- // Helpers
- sal_Bool isHCMode();
- };
-
-//........................................................................
-} // namespacetoolkit
-//........................................................................
-
-#endif //_TOOLKIT_HELPER_THROBBERIMPL_HXX_
-
diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx
index 6acf946930be..4130b841f34a 100755
--- a/toolkit/source/awt/animatedimagespeer.cxx
+++ b/toolkit/source/awt/animatedimagespeer.cxx
@@ -28,7 +28,6 @@
#include "toolkit/awt/animatedimagespeer.hxx"
#include "toolkit/helper/property.hxx"
-#include "toolkit/helper/throbberimpl.hxx"
/** === begin UNO includes === **/
#include <com/sun/star/awt/XAnimatedImages.hpp>
@@ -43,7 +42,7 @@
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/processfactory.hxx>
#include <tools/diagnose_ex.h>
-#include <vcl/imgctrl.hxx>
+#include <vcl/throbber.hxx>
#include <stl/limits>
@@ -80,11 +79,11 @@ namespace toolkit
//==================================================================================================================
struct AnimatedImagesPeer_Data
{
- Throbber_Impl aThrobber;
+ AnimatedImagesPeer& rAntiImpl;
::std::vector< Sequence< ::rtl::OUString > > aCachedImageSets;
- AnimatedImagesPeer_Data( VCLXWindow& i_window )
- :aThrobber( i_window )
+ AnimatedImagesPeer_Data( AnimatedImagesPeer& i_antiImpl )
+ :rAntiImpl( i_antiImpl )
,aCachedImageSets()
{
}
@@ -124,8 +123,8 @@ namespace toolkit
//--------------------------------------------------------------------------------------------------------------
void lcl_updateImageList_nothrow( AnimatedImagesPeer_Data& i_data )
{
- const Window* pWindow = i_data.aThrobber.getWindow();
- if ( pWindow == NULL )
+ Throbber* pThrobber = dynamic_cast< Throbber* >( i_data.rAntiImpl.GetWindow() );
+ if ( pThrobber == NULL )
return;
try
@@ -146,7 +145,7 @@ namespace toolkit
}
// find the set with the smallest difference between window size and image size
- const ::Size aWindowSizePixel = pWindow->GetSizePixel();
+ const ::Size aWindowSizePixel = pThrobber->GetSizePixel();
sal_Int32 nPreferredSet = -1;
long nMinimalDistance = ::std::numeric_limits< long >::max();
for ( ::std::vector< Size >::const_iterator check = aImageSizes.begin();
@@ -180,7 +179,7 @@ namespace toolkit
aImages[ imageIndex ] = lcl_getGraphic_throw( xGraphicProvider, *pImageURL );
}
}
- i_data.aThrobber.setImageList( aImages );
+ pThrobber->setImageList( aImages );
}
catch( const Exception& )
{
@@ -226,21 +225,28 @@ namespace toolkit
void SAL_CALL AnimatedImagesPeer::startAnimation( ) throw (RuntimeException)
{
::vos::OGuard aGuard( GetMutex() );
- m_pData->aThrobber.start();
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber != NULL)
+ pThrobber->start();
}
//------------------------------------------------------------------------------------------------------------------
void SAL_CALL AnimatedImagesPeer::stopAnimation( ) throw (RuntimeException)
{
::vos::OGuard aGuard( GetMutex() );
- m_pData->aThrobber.stop();
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber != NULL)
+ pThrobber->stop();
}
//------------------------------------------------------------------------------------------------------------------
::sal_Bool SAL_CALL AnimatedImagesPeer::isAnimationRunning( ) throw (RuntimeException)
{
::vos::OGuard aGuard( GetMutex() );
- return m_pData->aThrobber.isRunning();
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber != NULL)
+ return pThrobber->isRunning();
+ return sal_False;
}
//------------------------------------------------------------------------------------------------------------------
@@ -248,6 +254,13 @@ namespace toolkit
{
::vos::OGuard aGuard( GetMutex() );
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber == NULL )
+ {
+ VCLXWindow::setProperty( i_propertyName, i_value );
+ return;
+ }
+
const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName );
switch ( nPropertyId )
{
@@ -255,14 +268,14 @@ namespace toolkit
{
sal_Int32 nStepTime( 0 );
if ( i_value >>= nStepTime )
- m_pData->aThrobber.setStepTime( nStepTime );
+ pThrobber->setStepTime( nStepTime );
break;
}
case BASEPROPERTY_AUTO_REPEAT:
{
sal_Bool bRepeat( sal_True );
if ( i_value >>= bRepeat )
- m_pData->aThrobber.setRepeat( bRepeat );
+ pThrobber->setRepeat( bRepeat );
break;
}
@@ -290,15 +303,19 @@ namespace toolkit
Any aReturn;
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber == NULL )
+ return VCLXWindow::getProperty( i_propertyName );
+
const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName );
switch ( nPropertyId )
{
case BASEPROPERTY_STEP_TIME:
- aReturn <<= m_pData->aThrobber.getStepTime();
+ aReturn <<= pThrobber->getStepTime();
break;
case BASEPROPERTY_AUTO_REPEAT:
- aReturn <<= m_pData->aThrobber.getRepeat();
+ aReturn <<= pThrobber->getRepeat();
break;
case BASEPROPERTY_IMAGE_SCALE_MODE:
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 5d4dbe77116c..a609a7df3268 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -33,6 +33,7 @@
#include <tools/svwin.h>
#endif
#include <stdio.h>
+#include <com/sun/star/awt/ImageScaleMode.hpp>
#include <com/sun/star/awt/WindowAttribute.hpp>
#include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
#include <com/sun/star/awt/WindowClass.hpp>
@@ -116,6 +117,7 @@
#include <vcl/virdev.hxx>
#include <vcl/window.hxx>
#include <vcl/wrkwin.hxx>
+#include <vcl/throbber.hxx>
#include "toolkit/awt/vclxspinbutton.hxx"
#include <tools/debug.hxx>
@@ -986,19 +988,23 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp,
}
break;
case WINDOW_CONTROL:
- if ( aServiceName.EqualsAscii( "simpleanimation" ) )
+ if ( aServiceName.EqualsAscii( "simpleanimation" ) )
{
- pNewWindow = new FixedImage( pParent, nWinBits | WB_SCALE );
+ pNewWindow = new Throbber( pParent, nWinBits, Throbber::IMAGES_NONE );
+ ((Throbber*)pNewWindow)->SetScaleMode( css::awt::ImageScaleMode::Anisotropic );
+ // (compatibility)
*ppNewComp = new ::toolkit::XSimpleAnimation;
}
else if ( aServiceName.EqualsAscii( "throbber" ) )
{
- pNewWindow = new FixedImage( pParent, nWinBits | WB_SCALE );
+ pNewWindow = new Throbber( pParent, nWinBits, Throbber::IMAGES_NONE );
+ ((Throbber*)pNewWindow)->SetScaleMode( css::awt::ImageScaleMode::Anisotropic );
+ // (compatibility)
*ppNewComp = new ::toolkit::XThrobber;
}
else if ( aServiceName.EqualsAscii( "animatedimages" ) )
{
- pNewWindow = new ImageControl( pParent, nWinBits );
+ pNewWindow = new Throbber( pParent, nWinBits );
*ppNewComp = new ::toolkit::AnimatedImagesPeer;
}
break;
diff --git a/toolkit/source/awt/xsimpleanimation.cxx b/toolkit/source/awt/xsimpleanimation.cxx
index 63de993e0e43..75701cb94b46 100644
--- a/toolkit/source/awt/xsimpleanimation.cxx
+++ b/toolkit/source/awt/xsimpleanimation.cxx
@@ -29,8 +29,8 @@
#include "precompiled_toolkit.hxx"
#include "toolkit/awt/xsimpleanimation.hxx"
#include "toolkit/helper/property.hxx"
-#include "toolkit/helper/throbberimpl.hxx"
#include <tools/debug.hxx>
+#include <vcl/throbber.hxx>
//........................................................................
namespace toolkit
@@ -46,7 +46,6 @@ namespace toolkit
//--------------------------------------------------------------------
XSimpleAnimation::XSimpleAnimation()
- :mpThrobber( new Throbber_Impl( *this ) )
{
DBG_CTOR( XSimpleAnimation, NULL );
}
@@ -61,14 +60,18 @@ namespace toolkit
void SAL_CALL XSimpleAnimation::start() throw ( uno::RuntimeException )
{
::vos::OGuard aGuard( GetMutex() );
- mpThrobber->start();
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber != NULL)
+ pThrobber->start();
}
//--------------------------------------------------------------------
void SAL_CALL XSimpleAnimation::stop() throw ( uno::RuntimeException )
{
::vos::OGuard aGuard( GetMutex() );
- mpThrobber->stop();
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber != NULL)
+ pThrobber->stop();
}
//--------------------------------------------------------------------
@@ -76,7 +79,9 @@ namespace toolkit
throw ( uno::RuntimeException )
{
::vos::OGuard aGuard( GetMutex() );
- mpThrobber->setImageList( rImageList );
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber != NULL)
+ pThrobber->setImageList( rImageList );
}
//--------------------------------------------------------------------
@@ -85,27 +90,31 @@ namespace toolkit
{
::vos::OGuard aGuard( GetMutex() );
- if ( GetWindow() )
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber == NULL )
{
- sal_uInt16 nPropertyId = GetPropertyId( PropertyName );
- switch ( nPropertyId )
- {
- case BASEPROPERTY_STEP_TIME: {
- sal_Int32 nStepTime( 0 );
- if ( Value >>= nStepTime )
- mpThrobber->setStepTime( nStepTime );
-
- break;
- }
- case BASEPROPERTY_REPEAT: {
- sal_Bool bRepeat( sal_True );
- if ( Value >>= bRepeat )
- mpThrobber->setRepeat( bRepeat );
- break;
- }
- default:
- VCLXWindow::setProperty( PropertyName, Value );
+ VCLXWindow::setProperty( PropertyName, Value );
+ return;
+ }
+
+ sal_uInt16 nPropertyId = GetPropertyId( PropertyName );
+ switch ( nPropertyId )
+ {
+ case BASEPROPERTY_STEP_TIME: {
+ sal_Int32 nStepTime( 0 );
+ if ( Value >>= nStepTime )
+ pThrobber->setStepTime( nStepTime );
+
+ break;
+ }
+ case BASEPROPERTY_REPEAT: {
+ sal_Bool bRepeat( sal_True );
+ if ( Value >>= bRepeat )
+ pThrobber->setRepeat( bRepeat );
+ break;
}
+ default:
+ VCLXWindow::setProperty( PropertyName, Value );
}
}
@@ -115,22 +124,22 @@ namespace toolkit
{
::vos::OGuard aGuard( GetMutex() );
- uno::Any aReturn;
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber == NULL )
+ return VCLXWindow::getProperty( PropertyName );
- if ( GetWindow() )
+ uno::Any aReturn;
+ sal_uInt16 nPropertyId = GetPropertyId( PropertyName );
+ switch ( nPropertyId )
{
- sal_uInt16 nPropertyId = GetPropertyId( PropertyName );
- switch ( nPropertyId )
- {
- case BASEPROPERTY_STEP_TIME:
- aReturn <<= mpThrobber->getStepTime();
- break;
- case BASEPROPERTY_REPEAT:
- aReturn <<= mpThrobber->getRepeat();
- break;
- default:
- aReturn = VCLXWindow::getProperty( PropertyName );
- }
+ case BASEPROPERTY_STEP_TIME:
+ aReturn <<= pThrobber->getStepTime();
+ break;
+ case BASEPROPERTY_REPEAT:
+ aReturn <<= pThrobber->getRepeat();
+ break;
+ default:
+ aReturn = VCLXWindow::getProperty( PropertyName );
}
return aReturn;
}
diff --git a/toolkit/source/awt/xthrobber.cxx b/toolkit/source/awt/xthrobber.cxx
index 2a5d8d2d19af..768bd6ab4330 100644
--- a/toolkit/source/awt/xthrobber.cxx
+++ b/toolkit/source/awt/xthrobber.cxx
@@ -30,7 +30,6 @@
#include "toolkit/awt/xthrobber.hxx"
#include "toolkit/helper/property.hxx"
#include <toolkit/helper/tkresmgr.hxx>
-#include <toolkit/helper/throbberimpl.hxx>
#ifndef _TOOLKIT_AWT_XTHROBBER_HRC_
#include "xthrobber.hrc"
@@ -38,6 +37,7 @@
#include <tools/debug.hxx>
#include <vcl/fixed.hxx>
#include <vcl/timer.hxx>
+#include <vcl/throbber.hxx>
//........................................................................
namespace toolkit
@@ -53,10 +53,8 @@ namespace toolkit
//--------------------------------------------------------------------
XThrobber::XThrobber()
- :mpThrobber( new Throbber_Impl( *this ) )
{
DBG_CTOR( XThrobber, NULL );
- InitImageList();
}
//--------------------------------------------------------------------
@@ -69,14 +67,25 @@ namespace toolkit
void SAL_CALL XThrobber::start() throw ( uno::RuntimeException )
{
::vos::OGuard aGuard( GetMutex() );
- mpThrobber->start();
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber != NULL)
+ pThrobber->start();
}
//--------------------------------------------------------------------
void SAL_CALL XThrobber::stop() throw ( uno::RuntimeException )
{
::vos::OGuard aGuard( GetMutex() );
- mpThrobber->stop();
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber != NULL)
+ pThrobber->stop();
+ }
+
+ //--------------------------------------------------------------------
+ void XThrobber::SetWindow( Window* pWindow )
+ {
+ XThrobber_Base::SetWindow( pWindow );
+ InitImageList();
}
//--------------------------------------------------------------------
@@ -84,10 +93,15 @@ namespace toolkit
throw( uno::RuntimeException )
{
::vos::OGuard aGuard( GetMutex() );
+
+ Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) );
+ if ( pThrobber != NULL)
+ return;
+
uno::Sequence< uno::Reference< graphic::XGraphic > > aImageList(12);
sal_uInt16 nIconIdStart = RID_TK_ICON_THROBBER_START;
- if ( mpThrobber->isHCMode() )
+ if ( pThrobber->GetSettings().GetStyleSettings().GetHighContrastMode() )
nIconIdStart = RID_TK_HC_ICON_THROBBER_START;
for ( sal_uInt16 i=0; i<12; i++ )
@@ -96,7 +110,7 @@ namespace toolkit
aImageList[i] = aImage.GetXGraphic();
}
- mpThrobber->setImageList( aImageList );
+ pThrobber->setImageList( aImageList );
}
//........................................................................
diff --git a/toolkit/source/helper/makefile.mk b/toolkit/source/helper/makefile.mk
index bf10b0aa0178..a0a254ef1f00 100644
--- a/toolkit/source/helper/makefile.mk
+++ b/toolkit/source/helper/makefile.mk
@@ -53,7 +53,6 @@ SLOFILES= \
$(SLO)$/vclunohelper.obj \
$(SLO)$/externallock.obj \
$(SLO)$/imagealign.obj \
- $(SLO)$/throbberimpl.obj \
$(SLO)$/formpdfexport.obj \
$(SLO)$/accessibilityclient.obj \
$(SLO)$/fixedhyperbase.obj
diff --git a/toolkit/source/helper/throbberimpl.cxx b/toolkit/source/helper/throbberimpl.cxx
deleted file mode 100644
index 5eb6b838a924..000000000000
--- a/toolkit/source/helper/throbberimpl.cxx
+++ /dev/null
@@ -1,149 +0,0 @@
-/*************************************************************************
- *
- * 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_toolkit.hxx"
-#include <toolkit/helper/throbberimpl.hxx>
-
-#include <vcl/svapp.hxx>
-#include <vcl/imgctrl.hxx>
-
-//........................................................................
-namespace toolkit
-//........................................................................
-{
- using namespace ::com::sun::star;
-
- //--------------------------------------------------------------------
- Throbber_Impl::Throbber_Impl( VCLXWindow& i_rParent )
- :mrMutex( Application::GetSolarMutex() )
- ,mrParent( i_rParent )
- ,mbRepeat( sal_True )
- ,mnStepTime( 100 )
- ,mnCurStep( 0 )
- ,mnStepCount( 0 )
- {
- maWaitTimer.SetTimeout( mnStepTime );
- maWaitTimer.SetTimeoutHdl( LINK( this, Throbber_Impl, TimeOutHdl ) );
- }
-
- //--------------------------------------------------------------------
- Throbber_Impl::~Throbber_Impl()
- {
- maWaitTimer.Stop();
- }
-
- //--------------------------------------------------------------------
- void Throbber_Impl::start()
- {
- DBG_TESTSOLARMUTEX();
- maWaitTimer.Start();
- }
-
- //--------------------------------------------------------------------
- void Throbber_Impl::stop()
- {
- DBG_TESTSOLARMUTEX();
- maWaitTimer.Stop();
- }
-
- //--------------------------------------------------------------------
- bool Throbber_Impl::isRunning() const
- {
- DBG_TESTSOLARMUTEX();
- return maWaitTimer.IsActive();
- }
-
- //--------------------------------------------------------------------
- namespace
- {
- void lcl_setImage( FixedImage& i_fixedImage, Image const& i_image )
- {
- ImageControl* pImageControl = dynamic_cast< ImageControl* >( &i_fixedImage );
- if ( pImageControl != NULL )
- pImageControl->SetBitmap( i_image.GetBitmapEx() );
- else
- i_fixedImage.SetImage( i_image );
- }
- }
-
- //--------------------------------------------------------------------
- void Throbber_Impl::setImageList( const uno::Sequence< uno::Reference< graphic::XGraphic > >& rImageList )
- {
- DBG_TESTSOLARMUTEX();
-
- maImageList = rImageList;
-
- mnStepCount = maImageList.getLength();
- FixedImage* pFixedImage = dynamic_cast< FixedImage* >( mrParent.GetWindow() );
- if ( pFixedImage )
- lcl_setImage( *pFixedImage, mnStepCount ? maImageList[ 0 ] : Image() );
- }
-
- //--------------------------------------------------------------------
- sal_Bool Throbber_Impl::isHCMode()
- {
- FixedImage* pImage = dynamic_cast< FixedImage* >( mrParent.GetWindow() );
- if ( pImage )
- return pImage->GetSettings().GetStyleSettings().GetHighContrastMode();
- else
- return Application::GetSettings().GetStyleSettings().GetHighContrastMode();
- }
-
- // -----------------------------------------------------------------------
- IMPL_LINK( Throbber_Impl, TimeOutHdl, Throbber_Impl*, EMPTYARG )
- {
- ::vos::OGuard aGuard( GetMutex() );
- if ( !maImageList.getLength() )
- return 0;
-
- FixedImage* pFixedImage = dynamic_cast< FixedImage* >( mrParent.GetWindow() );
- if ( pFixedImage == NULL )
- return 0;
-
- if ( mnCurStep < mnStepCount - 1 )
- mnCurStep += 1;
- else
- {
- if ( mbRepeat )
- {
- // start over
- mnCurStep = 0;
- }
- else
- {
- stop();
- }
- }
-
- lcl_setImage( *pFixedImage, maImageList[ mnCurStep ] );
-
- return 0;
- }
-
-//........................................................................
-} // namespacetoolkit
-//........................................................................
-
diff --git a/vcl/inc/vcl/imgctrl.hxx b/vcl/inc/vcl/imgctrl.hxx
index fa3b01463f34..83bd300379d6 100644
--- a/vcl/inc/vcl/imgctrl.hxx
+++ b/vcl/inc/vcl/imgctrl.hxx
@@ -46,6 +46,7 @@ private:
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 );
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 59efccb8ee02..6af056eec45b 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..d0ed042db354 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;
}
// -----------------------------------------------------------------------
diff --git a/vcl/source/control/makefile.mk b/vcl/source/control/makefile.mk
index b1644e58ccd9..3c0a364499ad 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,17 +67,8 @@ 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
diff --git a/vcl/source/control/throbber.cxx b/vcl/source/control/throbber.cxx
new file mode 100644
index 000000000000..eab39b735b4d
--- /dev/null
+++ b/vcl/source/control/throbber.cxx
@@ -0,0 +1,283 @@
+/*************************************************************************
+ *
+ * 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>
+
+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
+{
+ ::std::vector< Image > lcl_loadImageSet( const Throbber::ImageSet i_imageSet )
+ {
+ ::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
+ )
+ {
+ aMediaProperties.put( "URL", *imageURL );
+ const Reference< XGraphic > xGraphic( 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;
+ if ( meImageSet == IMAGES_AUTO )
+ {
+ aImageSets.push_back( lcl_loadImageSet( IMAGES_16_PX ) );
+ aImageSets.push_back( lcl_loadImageSet( IMAGES_32_PX ) );
+ aImageSets.push_back( lcl_loadImageSet( IMAGES_64_PX ) );
+ }
+ else
+ {
+ aImageSets.push_back( lcl_loadImageSet( meImageSet ) );
+ }
+
+ // 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();
+ 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() );
+ SetBitmap( aInitialImage.GetBitmapEx() );
+}
+
+//--------------------------------------------------------------------
+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/res/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();
+ }
+ }
+
+ SetBitmap( maImageList[ mnCurStep ].GetBitmapEx() );
+
+ return 0;
+}