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 #ifndef INCLUDED_UNOCONTROLS_SOURCE_INC_PROGRESSBAR_HXX 21 #define INCLUDED_UNOCONTROLS_SOURCE_INC_PROGRESSBAR_HXX 22 23 #include <com/sun/star/awt/XProgressBar.hpp> 24 25 #include <tools/color.hxx> 26 27 #include <basecontrol.hxx> 28 29 namespace unocontrols { 30 31 #define PROGRESSBAR_FREESPACE 4 32 #define PROGRESSBAR_DEFAULT_HORIZONTAL true 33 #define PROGRESSBAR_DEFAULT_BLOCKDIMENSION Size(1,1) 34 #define PROGRESSBAR_DEFAULT_BACKGROUNDCOLOR sal_Int32(Color( 0x00, 0xC0, 0xC0, 0xC0 )) // lightgray 35 #define PROGRESSBAR_DEFAULT_FOREGROUNDCOLOR sal_Int32(Color( 0x00, 0x00, 0x00, 0x80 )) // blue 36 #define PROGRESSBAR_DEFAULT_MINRANGE INT_MIN 37 #define PROGRESSBAR_DEFAULT_MAXRANGE INT_MAX 38 #define PROGRESSBAR_DEFAULT_BLOCKVALUE 1 39 #define PROGRESSBAR_DEFAULT_VALUE PROGRESSBAR_DEFAULT_MINRANGE 40 #define PROGRESSBAR_LINECOLOR_BRIGHT sal_Int32(Color( 0x00, 0xFF, 0xFF, 0xFF )) // white 41 #define PROGRESSBAR_LINECOLOR_SHADOW sal_Int32(Color( 0x00, 0x00, 0x00, 0x00 )) // black 42 43 class ProgressBar : public css::awt::XControlModel 44 , public css::awt::XProgressBar 45 , public BaseControl 46 { 47 public: 48 49 ProgressBar( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); 50 51 virtual ~ProgressBar() override; 52 53 // XInterface 54 55 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; 56 57 /** 58 @short increment refcount 59 @seealso XInterface 60 @seealso release() 61 @onerror A RuntimeException is thrown. 62 */ 63 64 virtual void SAL_CALL acquire() throw() override; 65 66 /** 67 @short decrement refcount 68 @seealso XInterface 69 @seealso acquire() 70 @onerror A RuntimeException is thrown. 71 */ 72 73 virtual void SAL_CALL release() throw() override; 74 75 // XTypeProvider 76 77 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; 78 79 // XAggregation 80 81 css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& aType ) override; 82 83 // XProgressBar 84 85 virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) override; 86 87 virtual void SAL_CALL setBackgroundColor( sal_Int32 nColor ) override; 88 89 virtual void SAL_CALL setValue( sal_Int32 nValue ) override; 90 91 virtual void SAL_CALL setRange( 92 sal_Int32 nMin , 93 sal_Int32 nMax 94 ) override; 95 96 virtual sal_Int32 SAL_CALL getValue() override; 97 98 // XWindow 99 100 virtual void SAL_CALL setPosSize( 101 sal_Int32 nX , 102 sal_Int32 nY , 103 sal_Int32 nWidth , 104 sal_Int32 nHeight , 105 sal_Int16 nFlags 106 ) override; 107 108 // XControl 109 110 virtual sal_Bool SAL_CALL setModel( 111 const css::uno::Reference< css::awt::XControlModel >& xModel 112 ) override; 113 114 virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override; 115 116 // BaseControl 117 118 static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames(); 119 120 static OUString impl_getStaticImplementationName(); 121 122 protected: 123 virtual void impl_paint( 124 sal_Int32 nX , 125 sal_Int32 nY , 126 const css::uno::Reference< css::awt::XGraphics >& xGraphics 127 ) override; 128 129 void impl_recalcRange(); 130 131 private: 132 bool m_bHorizontal; // orientation for steps [true=horizontal/false=vertical] 133 css::awt::Size m_aBlockSize; // width and height of a block [>=0,0] 134 Color m_nForegroundColor; // (alpha,r,g,b) 135 Color m_nBackgroundColor; // (alpha,r,g,b) 136 sal_Int32 m_nMinRange; // lowest value = 0% [long, <_nMaxRange] 137 sal_Int32 m_nMaxRange; // highest value = 100% [long, >_nMinRange] 138 double m_nBlockValue; // value for one block [long, >0] 139 sal_Int32 m_nValue; // value for progress [long] 140 141 }; 142 143 } 144 145 #endif // INCLUDED_UNOCONTROLS_SOURCE_INC_PROGRESSBAR_HXX 146 147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 148