1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <com/sun/star/awt/XProgressBar.hpp>
26 #include <tools/color.hxx>
28 #include <basecontrol.hxx>
30 namespace unocontrols
{
32 #define PROGRESSBAR_DEFAULT_BLOCKDIMENSION Size(1,1)
33 constexpr Color PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR
= COL_BLUE
;
34 constexpr Color PROGRESSBAR_DEFAULT_BACKGROUNDCOLOR
= COL_LIGHTGRAY
;
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
);
44 using ProgressBar_BASE
= cppu::ImplInheritanceHelper
<BaseControl
,
45 css::awt::XControlModel
,
46 css::awt::XProgressBar
>;
48 class ProgressBar final
: public ProgressBar_BASE
52 ProgressBar( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
54 virtual ~ProgressBar() override
;
58 virtual void SAL_CALL
setForegroundColor( sal_Int32 nColor
) override
;
60 virtual void SAL_CALL
setBackgroundColor( sal_Int32 nColor
) override
;
62 virtual void SAL_CALL
setValue( sal_Int32 nValue
) override
;
64 virtual void SAL_CALL
setRange(
69 virtual sal_Int32 SAL_CALL
getValue() override
;
73 virtual void SAL_CALL
setPosSize(
83 virtual sal_Bool SAL_CALL
setModel(
84 const css::uno::Reference
< css::awt::XControlModel
>& xModel
87 virtual css::uno::Reference
< css::awt::XControlModel
> SAL_CALL
getModel() override
;
90 virtual void impl_paint(
93 const css::uno::Reference
< css::awt::XGraphics
>& xGraphics
96 void impl_recalcRange();
98 bool m_bHorizontal
; // orientation for steps [true=horizontal/false=vertical]
99 css::awt::Size m_aBlockSize
; // width and height of a block [>=0,0]
100 Color m_nForegroundColor
; // (alpha,r,g,b)
101 Color m_nBackgroundColor
; // (alpha,r,g,b)
102 sal_Int32 m_nMinRange
; // lowest value = 0% [long, <_nMaxRange]
103 sal_Int32 m_nMaxRange
; // highest value = 100% [long, >_nMinRange]
104 double m_nBlockValue
; // value for one block [long, >0]
105 sal_Int32 m_nValue
; // value for progress [long]
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */