LibreOffice Module UnoControls (master)  1
progressbar.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #pragma once
21 
22 #include <com/sun/star/awt/XProgressBar.hpp>
23 
24 #include <tools/color.hxx>
25 
26 #include <basecontrol.hxx>
27 
28 namespace unocontrols {
29 
30 #define PROGRESSBAR_FREESPACE 4
31 #define PROGRESSBAR_DEFAULT_HORIZONTAL true
32 #define PROGRESSBAR_DEFAULT_BLOCKDIMENSION Size(1,1)
33 #define PROGRESSBAR_DEFAULT_BACKGROUNDCOLOR sal_Int32(Color( 0x00, 0xC0, 0xC0, 0xC0 )) // lightgray
34 #define PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR sal_Int32(Color( 0x00, 0x00, 0x00, 0x80 )) // blue
35 #define PROGRESSBAR_DEFAULT_MINRANGE INT_MIN
36 #define PROGRESSBAR_DEFAULT_MAXRANGE INT_MAX
37 #define PROGRESSBAR_DEFAULT_BLOCKVALUE 1
38 #define PROGRESSBAR_DEFAULT_VALUE PROGRESSBAR_DEFAULT_MINRANGE
39 #define PROGRESSBAR_LINECOLOR_BRIGHT sal_Int32(Color( 0x00, 0xFF, 0xFF, 0xFF )) // white
40 #define PROGRESSBAR_LINECOLOR_SHADOW sal_Int32(Color( 0x00, 0x00, 0x00, 0x00 )) // black
41 
42 class ProgressBar : public css::awt::XControlModel
43  , public css::awt::XProgressBar
44  , public BaseControl
45 {
46 public:
47 
48  ProgressBar( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
49 
50  virtual ~ProgressBar() override;
51 
52  // XInterface
53 
54  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
55 
63  virtual void SAL_CALL acquire() throw() override;
64 
72  virtual void SAL_CALL release() throw() override;
73 
74  // XTypeProvider
75 
76  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
77 
78  // XAggregation
79 
80  css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& aType ) override;
81 
82  // XProgressBar
83 
84  virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) override;
85 
86  virtual void SAL_CALL setBackgroundColor( sal_Int32 nColor ) override;
87 
88  virtual void SAL_CALL setValue( sal_Int32 nValue ) override;
89 
90  virtual void SAL_CALL setRange(
91  sal_Int32 nMin ,
92  sal_Int32 nMax
93  ) override;
94 
95  virtual sal_Int32 SAL_CALL getValue() override;
96 
97  // XWindow
98 
99  virtual void SAL_CALL setPosSize(
100  sal_Int32 nX ,
101  sal_Int32 nY ,
102  sal_Int32 nWidth ,
103  sal_Int32 nHeight ,
104  sal_Int16 nFlags
105  ) override;
106 
107  // XControl
108 
109  virtual sal_Bool SAL_CALL setModel(
110  const css::uno::Reference< css::awt::XControlModel >& xModel
111  ) override;
112 
113  virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override;
114 
115  // BaseControl
116 
117  static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames();
118 
119  static OUString impl_getStaticImplementationName();
120 
121 protected:
122  virtual void impl_paint(
123  sal_Int32 nX ,
124  sal_Int32 nY ,
125  const css::uno::Reference< css::awt::XGraphics >& xGraphics
126  ) override;
127 
128  void impl_recalcRange();
129 
130 private:
131  bool m_bHorizontal; // orientation for steps [true=horizontal/false=vertical]
132  css::awt::Size m_aBlockSize; // width and height of a block [>=0,0]
133  Color m_nForegroundColor; // (alpha,r,g,b)
134  Color m_nBackgroundColor; // (alpha,r,g,b)
135  sal_Int32 m_nMinRange; // lowest value = 0% [long, <_nMaxRange]
136  sal_Int32 m_nMaxRange; // highest value = 100% [long, >_nMinRange]
137  double m_nBlockValue; // value for one block [long, >0]
138  sal_Int32 m_nValue; // value for progress [long]
139 
140 };
141 
142 }
143 
144 
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames()
css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &aType) override
virtual void SAL_CALL setValue(sal_Int32 nValue) override
virtual void SAL_CALL setForegroundColor(sal_Int32 nColor) override
virtual void SAL_CALL setBackgroundColor(sal_Int32 nColor) override
virtual void SAL_CALL acquire() override
increment refcount XInterface release() A RuntimeException is thrown.
Definition: progressbar.cxx:81
css::awt::Size m_aBlockSize
virtual void SAL_CALL release() override
decrement refcount XInterface acquire() A RuntimeException is thrown.
Definition: progressbar.cxx:92
virtual void SAL_CALL setRange(sal_Int32 nMin, sal_Int32 nMax) override
sal_Int16 const nValue
virtual void impl_paint(sal_Int32 nX, sal_Int32 nY, const css::uno::Reference< css::awt::XGraphics > &xGraphics) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
get information about supported interfaces XTypeProvider
virtual ~ProgressBar() override
Definition: progressbar.cxx:52
ProgressBar(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual void SAL_CALL setPosSize(sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nFlags) override
unsigned char sal_Bool
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
give answer, if interface is supported The interfaces are searched by type.
Definition: progressbar.cxx:58
virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override
virtual sal_Bool SAL_CALL setModel(const css::uno::Reference< css::awt::XControlModel > &xModel) override
static OUString impl_getStaticImplementationName()
Reference< XModel > xModel
virtual sal_Int32 SAL_CALL getValue() override