xref: /aoo41x/main/vcl/inc/vcl/throbber.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef VCL_THROBBER_HXX
29 #define VCL_THROBBER_HXX
30 
31 #include "vcl/dllapi.h"
32 #include "vcl/imgctrl.hxx"
33 #include "vcl/timer.hxx"
34 
35 #include <vos/mutex.hxx>
36 
37 #include <com/sun/star/graphic/XGraphic.hpp>
38 
39 #include <vector>
40 
41 class VCL_DLLPUBLIC Throbber : public ImageControl
42 {
43 public:
44     enum ImageSet
45     {
46         /// no (default) images at all
47         IMAGES_NONE,
48         /// automatically decide between different image sets, depending on what fits best the actual size
49         IMAGES_AUTO,
50         /// default images, 16x16 pixels
51         IMAGES_16_PX,
52         /// default images, 32x32 pixels
53         IMAGES_32_PX,
54         /// default images, 64x64 pixels
55         IMAGES_64_PX,
56     };
57 
58 public:
59                     Throbber( Window* i_parentWindow, WinBits i_style, const ImageSet i_imageSet = IMAGES_AUTO );
60                     Throbber( Window* i_parentWindow, const ResId& i_resId, const ImageSet i_imageSet = IMAGES_AUTO );
61                     ~Throbber();
62 
63     // Properties
64     void            setStepTime( sal_Int32 nStepTime )  { mnStepTime = nStepTime; }
65     sal_Int32       getStepTime() const                 { return mnStepTime; }
66 
67     void            setRepeat( sal_Bool bRepeat )       { mbRepeat = bRepeat; }
68     sal_Bool        getRepeat() const                   { return mbRepeat; }
69 
70     // animation control
71     void start();
72     void stop();
73     bool isRunning() const;
74 
75     void setImageList( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > >& ImageList );
76     void setImageList( ::std::vector< Image > const& i_images );
77 
78     // default images
79     static ::std::vector< ::rtl::OUString >
80         getDefaultImageURLs( const ImageSet i_imageSet );
81 
82 protected:
83     // Window overridables
84     virtual void        Resize();
85 
86 private:
87     SAL_DLLPRIVATE void initImages();
88 
89 private:
90     ::std::vector< Image >  maImageList;
91 
92     sal_Bool    mbRepeat;
93     sal_Int32   mnStepTime;
94     sal_Int32   mnCurStep;
95     sal_Int32   mnStepCount;
96     AutoTimer   maWaitTimer;
97     ImageSet    meImageSet;
98 
99     DECL_LINK( TimeOutHdl, void* );
100 };
101 
102 #endif // VCL_THROBBER_HXX
103 
104