xref: /trunk/main/UnoControls/source/inc/progressbar.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 _UNOCONTROLS_PROGRESSBAR_CTRL_HXX
29 #define _UNOCONTROLS_PROGRESSBAR_CTRL_HXX
30 
31 //____________________________________________________________________________________________________________
32 //  includes of other projects
33 //____________________________________________________________________________________________________________
34 
35 #include <com/sun/star/lang/XServiceName.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 
38 //____________________________________________________________________________________________________________
39 //  includes of my own project
40 //____________________________________________________________________________________________________________
41 #include "basecontrol.hxx"
42 
43 //____________________________________________________________________________________________________________
44 //  namespaces
45 //____________________________________________________________________________________________________________
46 
47 namespace unocontrols{
48 
49 #define UNO3_REFERENCE                  ::com::sun::star::uno::Reference
50 #define UNO3_XMULTISERVICEFACTORY       ::com::sun::star::lang::XMultiServiceFactory
51 #define UNO3_RUNTIMEEXCEPTION           ::com::sun::star::uno::RuntimeException
52 #define UNO3_XCONTROLMODEL              ::com::sun::star::awt::XControlModel
53 #define UNO3_XPROGRESSBAR               ::com::sun::star::awt::XProgressBar
54 #define UNO3_ANY                        ::com::sun::star::uno::Any
55 #define UNO3_TYPE                       ::com::sun::star::uno::Type
56 #define UNO3_SEQUENCE                   ::com::sun::star::uno::Sequence
57 #define UNO3_XGRAPHICS                  ::com::sun::star::awt::XGraphics
58 #define UNO3_OUSTRING                   ::rtl::OUString
59 #define UNO3_SIZE                       ::com::sun::star::awt::Size
60 
61 //____________________________________________________________________________________________________________
62 //  defines
63 //____________________________________________________________________________________________________________
64 
65 #define SERVICENAME_PROGRESSBAR             "com.sun.star.awt.XProgressBar"
66 #define IMPLEMENTATIONNAME_PROGRESSBAR      "stardiv.UnoControls.ProgressBar"
67 #define FREESPACE                           4
68 #define DEFAULT_HORIZONTAL                  sal_True
69 #define DEFAULT_BLOCKDIMENSION              Size(1,1)
70 #define DEFAULT_BACKGROUNDCOLOR             TRGB_COLORDATA( 0x00, 0xC0, 0xC0, 0xC0 )    // lightgray
71 #define DEFAULT_FOREGROUNDCOLOR             TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x80 )    // blue
72 #define DEFAULT_MINRANGE                    INT_MIN
73 #define DEFAULT_MAXRANGE                    INT_MAX
74 #define DEFAULT_BLOCKVALUE                  1
75 #define DEFAULT_VALUE                       DEFAULT_MINRANGE
76 #define LINECOLOR_BRIGHT                    TRGB_COLORDATA( 0x00, 0xFF, 0xFF, 0xFF )    // white
77 #define LINECOLOR_SHADOW                    TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x00 )    // black
78 
79 //____________________________________________________________________________________________________________
80 //  classes
81 //____________________________________________________________________________________________________________
82 
83 class ProgressBar   : public UNO3_XCONTROLMODEL
84                     , public UNO3_XPROGRESSBAR
85                     , public BaseControl
86 {
87 
88 //____________________________________________________________________________________________________________
89 //  public methods
90 //____________________________________________________________________________________________________________
91 
92 public:
93 
94     //________________________________________________________________________________________________________
95     //  construct/destruct
96     //________________________________________________________________________________________________________
97 
98     /**_________________________________________________________________________________________________________
99         @short
100         @descr
101 
102         @seealso
103 
104         @param
105 
106         @return
107 
108         @onerror
109     */
110 
111     ProgressBar( const UNO3_REFERENCE< UNO3_XMULTISERVICEFACTORY >& xFactory );
112 
113     /**_________________________________________________________________________________________________________
114         @short
115         @descr
116 
117         @seealso
118 
119         @param
120 
121         @return
122 
123         @onerror
124     */
125 
126     virtual ~ProgressBar();
127 
128     //__________________________________________________________________________________________________________
129     //  XInterface
130     //__________________________________________________________________________________________________________
131 
132     /**_________________________________________________________________________________________________________
133         @short
134         @descr
135 
136         @seealso
137 
138         @param
139 
140         @return
141 
142         @onerror
143     */
144 
145     virtual UNO3_ANY SAL_CALL queryInterface( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION );
146 
147     /**_______________________________________________________________________________________________________
148         @short      increment refcount
149         @descr      -
150 
151         @seealso    XInterface
152         @seealso    release()
153 
154         @param      -
155 
156         @return     -
157 
158         @onerror    A RuntimeException is thrown.
159     */
160 
161     virtual void SAL_CALL acquire() throw();
162 
163     /**_______________________________________________________________________________________________________
164         @short      decrement refcount
165         @descr      -
166 
167         @seealso    XInterface
168         @seealso    acquire()
169 
170         @param      -
171 
172         @return     -
173 
174         @onerror    A RuntimeException is thrown.
175     */
176 
177     virtual void SAL_CALL release() throw();
178 
179     //__________________________________________________________________________________________________________
180     //  XTypeProvider
181     //__________________________________________________________________________________________________________
182 
183     /**_________________________________________________________________________________________________________
184         @short
185         @descr
186 
187         @seealso
188 
189         @param
190 
191         @return
192 
193         @onerror
194     */
195 
196     virtual UNO3_SEQUENCE< UNO3_TYPE > SAL_CALL getTypes() throw( UNO3_RUNTIMEEXCEPTION );
197 
198     //__________________________________________________________________________________________________________
199     //  XAggregation
200     //__________________________________________________________________________________________________________
201 
202     /**_________________________________________________________________________________________________________
203         @short
204         @descr
205 
206         @seealso
207 
208         @param
209 
210         @return
211 
212         @onerror
213     */
214 
215     UNO3_ANY SAL_CALL queryAggregation( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION );
216 
217     //________________________________________________________________________________________________________
218     //  XProgressBar
219     //________________________________________________________________________________________________________
220 
221     /**_________________________________________________________________________________________________________
222         @short
223         @descr
224 
225         @seealso
226 
227         @param
228 
229         @return
230 
231         @onerror
232     */
233 
234     virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) throw( UNO3_RUNTIMEEXCEPTION );
235 
236     /**_________________________________________________________________________________________________________
237         @short
238         @descr
239 
240         @seealso
241 
242         @param
243 
244         @return
245 
246         @onerror
247     */
248 
249     virtual void SAL_CALL setBackgroundColor( sal_Int32 nColor ) throw( UNO3_RUNTIMEEXCEPTION );
250 
251     /**_________________________________________________________________________________________________________
252         @short
253         @descr
254 
255         @seealso
256 
257         @param
258 
259         @return
260 
261         @onerror
262     */
263 
264     virtual void SAL_CALL setValue( sal_Int32 nValue ) throw( UNO3_RUNTIMEEXCEPTION );
265 
266     /**_________________________________________________________________________________________________________
267         @short
268         @descr
269 
270         @seealso
271 
272         @param
273 
274         @return
275 
276         @onerror
277     */
278 
279     virtual void SAL_CALL setRange( sal_Int32   nMin    ,
280                                     sal_Int32   nMax    ) throw( UNO3_RUNTIMEEXCEPTION );
281 
282     /**_________________________________________________________________________________________________________
283         @short
284         @descr
285 
286         @seealso
287 
288         @param
289 
290         @return
291 
292         @onerror
293     */
294 
295     virtual sal_Int32 SAL_CALL getValue() throw( UNO3_RUNTIMEEXCEPTION );
296 
297     //__________________________________________________________________________________________________________
298     //  XWindow
299     //__________________________________________________________________________________________________________
300 
301     /**_________________________________________________________________________________________________________
302         @short
303         @descr
304 
305         @seealso
306 
307         @param
308 
309         @return
310 
311         @onerror
312     */
313 
314     virtual void SAL_CALL setPosSize(   sal_Int32   nX      ,
315                                         sal_Int32   nY      ,
316                                         sal_Int32   nWidth  ,
317                                         sal_Int32   nHeight ,
318                                         sal_Int16   nFlags  ) throw( UNO3_RUNTIMEEXCEPTION );
319 
320     //__________________________________________________________________________________________________________
321     //  XControl
322     //__________________________________________________________________________________________________________
323 
324     /**_________________________________________________________________________________________________________
325         @short
326         @descr
327 
328         @seealso
329 
330         @param
331 
332         @return
333 
334         @onerror
335     */
336 
337     virtual sal_Bool SAL_CALL setModel( const UNO3_REFERENCE< UNO3_XCONTROLMODEL >& xModel ) throw( UNO3_RUNTIMEEXCEPTION );
338 
339     /**_________________________________________________________________________________________________________
340         @short
341         @descr
342 
343         @seealso
344 
345         @param
346 
347         @return
348 
349         @onerror
350     */
351 
352     virtual UNO3_REFERENCE< UNO3_XCONTROLMODEL > SAL_CALL getModel() throw( UNO3_RUNTIMEEXCEPTION );
353 
354     //__________________________________________________________________________________________________________
355     //  BaseControl
356     //__________________________________________________________________________________________________________
357 
358     /**_________________________________________________________________________________________________________
359         @short
360         @descr
361 
362         @seealso
363 
364         @param
365 
366         @return
367 
368         @onerror
369     */
370 
371     static const UNO3_SEQUENCE< UNO3_OUSTRING > impl_getStaticSupportedServiceNames();
372 
373     /**_________________________________________________________________________________________________________
374         @short
375         @descr
376 
377         @seealso
378 
379         @param
380 
381         @return
382 
383         @onerror
384     */
385 
386     static const UNO3_OUSTRING impl_getStaticImplementationName();
387 
388 //____________________________________________________________________________________________________________
389 //  protected methods
390 //____________________________________________________________________________________________________________
391 
392 protected:
393 
394     /**_________________________________________________________________________________________________________
395         @short
396         @descr
397 
398         @seealso
399 
400         @param
401 
402         @return
403 
404         @onerror
405     */
406 
407     virtual void impl_paint(        sal_Int32                           nX          ,
408                                     sal_Int32                           nY          ,
409                             const   UNO3_REFERENCE< UNO3_XGRAPHICS >&   xGraphics   );
410 
411     /**_________________________________________________________________________________________________________
412         @short
413         @descr
414 
415         @seealso
416 
417         @param
418 
419         @return
420 
421         @onerror
422     */
423 
424     void impl_recalcRange();
425 
426 //____________________________________________________________________________________________________________
427 //  private variables
428 //____________________________________________________________________________________________________________
429 
430 private:
431 
432     sal_Bool    m_bHorizontal       ;   // orientation for steps            [true=horizontal/false=vertikal]
433     UNO3_SIZE   m_aBlockSize        ;   // width and height of a block      [>=0,0]
434     sal_Int32   m_nForegroundColor  ;   //                                  (alpha,r,g,b)
435     sal_Int32   m_nBackgroundColor  ;   //                                  (alpha,r,g,b)
436     sal_Int32   m_nMinRange         ;   // lowest value  =   0%             [long, <_nMaxRange]
437     sal_Int32   m_nMaxRange         ;   // highest value = 100%             [long, >_nMinRange]
438     double      m_nBlockValue       ;   // value for one block              [long, >0]
439     sal_Int32   m_nValue            ;   // value for progress               [long]
440 
441 };  // class ProgressBar
442 
443 }   // namespace unocontrols
444 
445 #endif  // #ifndef _UNOCONTROLS_PROGRESSBAR_CTRL_HXX
446