Update ooo320-m1
[ooovba.git] / toolkit / source / helper / throbberimpl.cxx
blob48552eba5bb95927e18f447c40b8a1e96463389c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: throbberimpl.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_toolkit.hxx"
31 #include <toolkit/helper/throbberimpl.hxx>
33 #include <vcl/svapp.hxx>
34 #include <vcl/fixed.hxx>
36 //........................................................................
37 namespace toolkit
38 //........................................................................
40 using namespace ::com::sun::star;
42 //--------------------------------------------------------------------
43 Throbber_Impl::Throbber_Impl( uno::Reference< VCLXWindow > xParent,
44 sal_Int32 nStepTime,
45 sal_Bool bRepeat )
46 :mrMutex( Application::GetSolarMutex() )
48 mxParent = xParent;
49 mbRepeat = bRepeat;
50 mnStepTime = nStepTime;
51 maWaitTimer.SetTimeout( mnStepTime );
52 maWaitTimer.SetTimeoutHdl( LINK( this, Throbber_Impl, TimeOutHdl ) );
55 //--------------------------------------------------------------------
56 Throbber_Impl::~Throbber_Impl()
58 maWaitTimer.Stop();
59 mxParent = NULL;
62 //--------------------------------------------------------------------
63 void Throbber_Impl::start() throw ( uno::RuntimeException )
65 ::vos::OGuard aGuard( GetMutex() );
67 mnCurStep = 0;
68 maWaitTimer.Start();
71 //--------------------------------------------------------------------
72 void Throbber_Impl::stop() throw ( uno::RuntimeException )
74 ::vos::OGuard aGuard( GetMutex() );
76 maWaitTimer.Stop();
79 //--------------------------------------------------------------------
80 void Throbber_Impl::setImageList( const uno::Sequence< uno::Reference< graphic::XGraphic > >& rImageList )
81 throw ( uno::RuntimeException )
83 ::vos::OGuard aGuard( GetMutex() );
85 maImageList = rImageList;
87 mnStepCount = maImageList.getLength();
88 FixedImage* pImage = static_cast< FixedImage* >( mxParent->GetWindow() );
89 if ( pImage )
91 if ( mnStepCount )
92 pImage->SetImage( maImageList[ 0 ] );
93 else
94 pImage->SetImage( Image() );
98 //--------------------------------------------------------------------
99 void Throbber_Impl::initImage()
100 throw ( uno::RuntimeException )
102 FixedImage* pImage = static_cast< FixedImage* >( mxParent->GetWindow() );
103 if ( pImage && maImageList.getLength() )
104 pImage->SetImage( maImageList[ 0 ] );
107 //--------------------------------------------------------------------
108 sal_Bool Throbber_Impl::isHCMode()
109 throw ( uno::RuntimeException )
111 FixedImage* pImage = static_cast< FixedImage* >( mxParent->GetWindow() );
112 if ( pImage )
113 return pImage->GetSettings().GetStyleSettings().GetFaceColor().IsDark();
114 else
115 return Application::GetSettings().GetStyleSettings().GetFaceColor().IsDark();
118 // -----------------------------------------------------------------------
119 IMPL_LINK( Throbber_Impl, TimeOutHdl, Throbber_Impl*, EMPTYARG )
121 ::vos::OGuard aGuard( GetMutex() );
123 FixedImage* pImage = static_cast< FixedImage* >( mxParent->GetWindow() );
125 if ( !pImage || !maImageList.getLength() )
126 return 0;
128 if ( mnCurStep < mnStepCount - 1 )
129 mnCurStep += 1;
130 else
131 mnCurStep = 0;
133 pImage->SetImage( maImageList[ mnCurStep ] );
135 return 0;
138 //........................................................................
139 } // namespacetoolkit
140 //........................................................................