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