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 <climits>
25 
26 #include <tools/color.hxx>
27 
28 #include <basecontrol.hxx>
29 
30 namespace unocontrols {
31 
32 #define PROGRESSBAR_DEFAULT_BLOCKDIMENSION Size(1,1)
35 constexpr bool PROGRESSBAR_DEFAULT_HORIZONTAL = true;
36 constexpr auto PROGRESSBAR_FREESPACE = 4;
37 constexpr auto PROGRESSBAR_DEFAULT_MINRANGE = INT_MIN;
38 constexpr auto PROGRESSBAR_DEFAULT_MAXRANGE = INT_MAX;
39 constexpr auto PROGRESSBAR_DEFAULT_VALUE = INT_MIN;
40 constexpr auto PROGRESSBAR_DEFAULT_BLOCKVALUE = 1;
41 constexpr sal_Int32 PROGRESSBAR_LINECOLOR_BRIGHT = sal_Int32(COL_WHITE);
42 constexpr sal_Int32 PROGRESSBAR_LINECOLOR_SHADOW = sal_Int32(COL_BLACK);
43 
44 class ProgressBar final : public css::awt::XControlModel
45  , public css::awt::XProgressBar
46  , public BaseControl
47 {
48 public:
49 
50  ProgressBar( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
51 
52  virtual ~ProgressBar() override;
53 
54  // XInterface
55 
56  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
57 
65  virtual void SAL_CALL acquire() noexcept override;
66 
74  virtual void SAL_CALL release() noexcept override;
75 
76  // XTypeProvider
77 
78  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
79 
80  // XAggregation
81 
82  css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& aType ) override;
83 
84  // XProgressBar
85 
86  virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) override;
87 
88  virtual void SAL_CALL setBackgroundColor( sal_Int32 nColor ) override;
89 
90  virtual void SAL_CALL setValue( sal_Int32 nValue ) override;
91 
92  virtual void SAL_CALL setRange(
93  sal_Int32 nMin ,
94  sal_Int32 nMax
95  ) override;
96 
97  virtual sal_Int32 SAL_CALL getValue() override;
98 
99  // XWindow
100 
101  virtual void SAL_CALL setPosSize(
102  sal_Int32 nX ,
103  sal_Int32 nY ,
104  sal_Int32 nWidth ,
105  sal_Int32 nHeight ,
106  sal_Int16 nFlags
107  ) override;
108 
109  // XControl
110 
111  virtual sal_Bool SAL_CALL setModel(
112  const css::uno::Reference< css::awt::XControlModel >& xModel
113  ) override;
114 
115  virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override;
116 
117 private:
118  virtual void impl_paint(
119  sal_Int32 nX ,
120  sal_Int32 nY ,
121  const css::uno::Reference< css::awt::XGraphics >& xGraphics
122  ) override;
123 
124  void impl_recalcRange();
125 
126  bool m_bHorizontal; // orientation for steps [true=horizontal/false=vertical]
127  css::awt::Size m_aBlockSize; // width and height of a block [>=0,0]
128  Color m_nForegroundColor; // (alpha,r,g,b)
129  Color m_nBackgroundColor; // (alpha,r,g,b)
130  sal_Int32 m_nMinRange; // lowest value = 0% [long, <_nMaxRange]
131  sal_Int32 m_nMaxRange; // highest value = 100% [long, >_nMinRange]
132  double m_nBlockValue; // value for one block [long, >0]
133  sal_Int32 m_nValue; // value for progress [long]
134 
135 };
136 
137 }
138 
139 
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL setRange(sal_Int32 nMin, sal_Int32 nMax) override
constexpr Color PROGRESSBAR_DEFAULT_BACKGROUNDCOLOR
Definition: progressbar.hxx:34
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
get information about supported interfaces XTypeProvider
virtual void SAL_CALL setValue(sal_Int32 nValue) override
css::awt::Size m_aBlockSize
virtual void SAL_CALL acquire() noexcept override
increment refcount XInterface release() A RuntimeException is thrown.
Definition: progressbar.cxx:79
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
constexpr auto PROGRESSBAR_DEFAULT_BLOCKVALUE
Definition: progressbar.hxx:40
virtual void SAL_CALL release() noexcept override
decrement refcount XInterface acquire() A RuntimeException is thrown.
Definition: progressbar.cxx:90
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:56
constexpr auto PROGRESSBAR_DEFAULT_VALUE
Definition: progressbar.hxx:39
ProgressBar(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
constexpr bool PROGRESSBAR_DEFAULT_HORIZONTAL
Definition: progressbar.hxx:35
virtual ~ProgressBar() override
Definition: progressbar.cxx:50
constexpr sal_Int32 PROGRESSBAR_LINECOLOR_SHADOW
Definition: progressbar.hxx:42
unsigned char sal_Bool
constexpr auto PROGRESSBAR_DEFAULT_MAXRANGE
Definition: progressbar.hxx:38
virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override
constexpr auto PROGRESSBAR_FREESPACE
Definition: progressbar.hxx:36
virtual sal_Int32 SAL_CALL getValue() override
constexpr sal_Int32 PROGRESSBAR_LINECOLOR_BRIGHT
Definition: progressbar.hxx:41
virtual void impl_paint(sal_Int32 nX, sal_Int32 nY, const css::uno::Reference< css::awt::XGraphics > &xGraphics) override
virtual sal_Bool SAL_CALL setModel(const css::uno::Reference< css::awt::XControlModel > &xModel) override
virtual void SAL_CALL setForegroundColor(sal_Int32 nColor) override
virtual void SAL_CALL setPosSize(sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nFlags) override
constexpr Color PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR
Definition: progressbar.hxx:33
css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &aType) override
Reference< XModel > xModel
constexpr::Color COL_BLUE(0x00, 0x00, 0x80)
constexpr auto PROGRESSBAR_DEFAULT_MINRANGE
Definition: progressbar.hxx:37
virtual void SAL_CALL setBackgroundColor(sal_Int32 nColor) override
sal_Int16 nValue