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 Color( 0xC0, 0xC0, 0xC0 ) // lightgray 34 #define PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR Color( 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( 0xFF, 0xFF, 0xFF )) // white 40 #define PROGRESSBAR_LINECOLOR_SHADOW sal_Int32(Color( 0x00, 0x00, 0x00 )) // black 41 42 class ProgressBar final : 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 56 /** 57 @short increment refcount 58 @seealso XInterface 59 @seealso release() 60 @onerror A RuntimeException is thrown. 61 */ 62 63 virtual void SAL_CALL acquire() noexcept override; 64 65 /** 66 @short decrement refcount 67 @seealso XInterface 68 @seealso acquire() 69 @onerror A RuntimeException is thrown. 70 */ 71 72 virtual void SAL_CALL release() noexcept 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 private: 116 virtual void impl_paint( 117 sal_Int32 nX , 118 sal_Int32 nY , 119 const css::uno::Reference< css::awt::XGraphics >& xGraphics 120 ) override; 121 122 void impl_recalcRange(); 123 124 bool m_bHorizontal; // orientation for steps [true=horizontal/false=vertical] 125 css::awt::Size m_aBlockSize; // width and height of a block [>=0,0] 126 Color m_nForegroundColor; // (alpha,r,g,b) 127 Color m_nBackgroundColor; // (alpha,r,g,b) 128 sal_Int32 m_nMinRange; // lowest value = 0% [long, <_nMaxRange] 129 sal_Int32 m_nMaxRange; // highest value = 100% [long, >_nMinRange] 130 double m_nBlockValue; // value for one block [long, >0] 131 sal_Int32 m_nValue; // value for progress [long] 132 133 }; 134 135 } 136 137 138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 139