1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: throbberimpl.cxx,v $
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 //........................................................................
38 //........................................................................
40 using namespace ::com::sun::star
;
42 //--------------------------------------------------------------------
43 Throbber_Impl::Throbber_Impl( uno::Reference
< VCLXWindow
> xParent
,
46 :mrMutex( Application::GetSolarMutex() )
50 mnStepTime
= nStepTime
;
51 maWaitTimer
.SetTimeout( mnStepTime
);
52 maWaitTimer
.SetTimeoutHdl( LINK( this, Throbber_Impl
, TimeOutHdl
) );
55 //--------------------------------------------------------------------
56 Throbber_Impl::~Throbber_Impl()
62 //--------------------------------------------------------------------
63 void Throbber_Impl::start() throw ( uno::RuntimeException
)
65 ::vos::OGuard
aGuard( GetMutex() );
71 //--------------------------------------------------------------------
72 void Throbber_Impl::stop() throw ( uno::RuntimeException
)
74 ::vos::OGuard
aGuard( GetMutex() );
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() );
92 pImage
->SetImage( maImageList
[ 0 ] );
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() );
113 return pImage
->GetSettings().GetStyleSettings().GetFaceColor().IsDark();
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() )
128 if ( mnCurStep
< mnStepCount
- 1 )
133 pImage
->SetImage( maImageList
[ mnCurStep
] );
138 //........................................................................
139 } // namespacetoolkit
140 //........................................................................