xref: /aoo4110/main/vcl/inc/vcl/throbber.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef VCL_THROBBER_HXX
25 #define VCL_THROBBER_HXX
26 
27 #include "vcl/dllapi.h"
28 #include "vcl/imgctrl.hxx"
29 #include "vcl/timer.hxx"
30 
31 #include <vos/mutex.hxx>
32 
33 #include <com/sun/star/graphic/XGraphic.hpp>
34 
35 #include <vector>
36 
37 class VCL_DLLPUBLIC Throbber : public ImageControl
38 {
39 public:
40     enum ImageSet
41     {
42         /// no (default) images at all
43         IMAGES_NONE,
44         /// automatically decide between different image sets, depending on what fits best the actual size
45         IMAGES_AUTO,
46         /// default images, 16x16 pixels
47         IMAGES_16_PX,
48         /// default images, 32x32 pixels
49         IMAGES_32_PX,
50         /// default images, 64x64 pixels
51         IMAGES_64_PX,
52     };
53 
54 public:
55                     Throbber( Window* i_parentWindow, WinBits i_style, const ImageSet i_imageSet = IMAGES_AUTO );
56                     Throbber( Window* i_parentWindow, const ResId& i_resId, const ImageSet i_imageSet = IMAGES_AUTO );
57                     ~Throbber();
58 
59     // Properties
setStepTime(sal_Int32 nStepTime)60     void            setStepTime( sal_Int32 nStepTime )  { mnStepTime = nStepTime; }
getStepTime() const61     sal_Int32       getStepTime() const                 { return mnStepTime; }
62 
setRepeat(sal_Bool bRepeat)63     void            setRepeat( sal_Bool bRepeat )       { mbRepeat = bRepeat; }
getRepeat() const64     sal_Bool        getRepeat() const                   { return mbRepeat; }
65 
66     // animation control
67     void start();
68     void stop();
69     bool isRunning() const;
70 
71     void setImageList( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > >& ImageList );
72     void setImageList( ::std::vector< Image > const& i_images );
73 
74     // default images
75     static ::std::vector< ::rtl::OUString >
76         getDefaultImageURLs( const ImageSet i_imageSet );
77 
78 protected:
79     // Window overridables
80     virtual void        Resize();
81 
82 private:
83     SAL_DLLPRIVATE void initImages();
84 
85 private:
86     ::std::vector< Image >  maImageList;
87 
88     sal_Bool    mbRepeat;
89     sal_Int32   mnStepTime;
90     sal_Int32   mnCurStep;
91     sal_Int32   mnStepCount;
92     AutoTimer   maWaitTimer;
93     ImageSet    meImageSet;
94 
95     DECL_LINK( TimeOutHdl, void* );
96 };
97 
98 #endif // VCL_THROBBER_HXX
99 
100