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 .
20 #ifndef INCLUDED_UNOCONTROLS_SOURCE_INC_PROGRESSMONITOR_HXX
21 #define INCLUDED_UNOCONTROLS_SOURCE_INC_PROGRESSMONITOR_HXX
23 #include <com/sun/star/awt/XProgressMonitor.hpp>
24 #include <com/sun/star/awt/XButton.hpp>
25 #include <com/sun/star/awt/XLayoutConstrains.hpp>
26 #include <rtl/ref.hxx>
31 #include <basecontainercontrol.hxx>
33 namespace com::sun::star::awt
{ class XFixedText
; }
34 namespace com::sun::star::awt
{ class XControlModel
; }
36 namespace unocontrols
{
40 #define PROGRESSMONITOR_FREEBORDER 10 // border around and between the controls
41 #define PROGRESSMONITOR_DEFAULT_TOPIC ""
42 #define PROGRESSMONITOR_DEFAULT_TEXT ""
43 #define PROGRESSMONITOR_LINECOLOR_BRIGHT sal_Int32(Color( 0x00, 0xFF, 0xFF, 0xFF )) // white
44 #define PROGRESSMONITOR_LINECOLOR_SHADOW sal_Int32(Color( 0x00, 0x00, 0x00, 0x00 )) // black
45 #define PROGRESSMONITOR_DEFAULT_WIDTH 350
46 #define PROGRESSMONITOR_DEFAULT_HEIGHT 100
49 struct IMPL_TextlistItem
51 OUString sTopic
; /// Left site of textline in dialog
52 OUString sText
; /// Right site of textline in dialog
55 class ProgressMonitor
: public css::awt::XLayoutConstrains
56 , public css::awt::XButton
57 , public css::awt::XProgressMonitor
58 , public BaseContainerControl
61 ProgressMonitor( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
63 virtual ~ProgressMonitor() override
;
68 @short give answer, if interface is supported
69 @descr The interfaces are searched by type.
73 @param "rType" is the type of searched interface.
75 @return Any information about found interface
77 @onerror A RuntimeException is thrown.
80 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
83 @short increment refcount
86 @onerror A RuntimeException is thrown.
89 virtual void SAL_CALL
acquire() throw() override
;
92 @short decrement refcount
95 @onerror A RuntimeException is thrown.
98 virtual void SAL_CALL
release() throw() override
;
103 @short get information about supported interfaces
104 @seealso XTypeProvider
105 @return Sequence of types of all supported interfaces
107 @onerror A RuntimeException is thrown.
110 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
114 virtual css::uno::Any SAL_CALL
queryAggregation( const css::uno::Type
& aType
) override
;
119 @short add topic to dialog
120 @descr Add a topic with a text in right textlist (used for FixedText-member).<BR>
121 ( "beforeProgress" fix the right list ). The dialog metric is recalculated.
123 @seealso removeText(), updateText()
125 @param sTopic Name of topic<BR>
126 [sTopic != "" && sTopic != NULL]
127 @param sText Value of topic<BR>
128 [sText != "" && sText != NULL]
129 @param bbeforeProgress Position of topic<BR>
130 [True => before progressbar / False => below progressbar]
131 @onerror DEBUG = Assertion<BR>
135 virtual void SAL_CALL
addText(
136 const OUString
& sTopic
,
137 const OUString
& sText
,
138 sal_Bool bbeforeProgress
141 virtual void SAL_CALL
removeText(
142 const OUString
& sTopic
,
143 sal_Bool bbeforeProgress
146 virtual void SAL_CALL
updateText(
147 const OUString
& sTopic
,
148 const OUString
& sText
,
149 sal_Bool bbeforeProgress
154 virtual void SAL_CALL
setForegroundColor( sal_Int32 nColor
) override
;
156 virtual void SAL_CALL
setBackgroundColor( sal_Int32 nColor
) override
;
158 virtual void SAL_CALL
setValue( sal_Int32 nValue
) override
;
160 virtual void SAL_CALL
setRange( sal_Int32 nMin
,
161 sal_Int32 nMax
) override
;
163 virtual sal_Int32 SAL_CALL
getValue() override
;
167 virtual void SAL_CALL
addActionListener(
168 const css::uno::Reference
< css::awt::XActionListener
>& xListener
171 virtual void SAL_CALL
removeActionListener(
172 const css::uno::Reference
< css::awt::XActionListener
>& xListener
175 virtual void SAL_CALL
setLabel( const OUString
& sLabel
) override
;
177 virtual void SAL_CALL
setActionCommand( const OUString
& sCommand
) override
;
181 virtual css::awt::Size SAL_CALL
getMinimumSize() override
;
183 virtual css::awt::Size SAL_CALL
getPreferredSize() override
;
185 virtual css::awt::Size SAL_CALL
calcAdjustedSize( const css::awt::Size
& aNewSize
) override
;
189 virtual void SAL_CALL
createPeer(
190 const css::uno::Reference
< css::awt::XToolkit
>& xToolkit
,
191 const css::uno::Reference
< css::awt::XWindowPeer
>& xParent
194 virtual sal_Bool SAL_CALL
setModel( const css::uno::Reference
< css::awt::XControlModel
>& xModel
) override
;
196 virtual css::uno::Reference
< css::awt::XControlModel
> SAL_CALL
getModel() override
;
200 virtual void SAL_CALL
dispose() override
;
204 virtual void SAL_CALL
setPosSize( sal_Int32 nX
,
208 sal_Int16 nFlags
) override
;
212 static css::uno::Sequence
< OUString
> impl_getStaticSupportedServiceNames();
214 static OUString
impl_getStaticImplementationName();
217 virtual void impl_paint( sal_Int32 nX
,
219 const css::uno::Reference
< css::awt::XGraphics
>& xGraphics
) override
;
222 using BaseControl::impl_recalcLayout
;
224 void impl_recalcLayout();
226 void impl_rebuildFixedText();
228 void impl_cleanMemory();
230 IMPL_TextlistItem
* impl_searchTopic( const OUString
& sTopic
, bool bbeforeProgress
);
235 static bool impl_debug_checkParameter( const OUString
& sTopic
, const OUString
& sText
); // addText, updateText
236 static bool impl_debug_checkParameter( const OUString
& rTopic
); // removeText
241 ::std::vector
< std::unique_ptr
<IMPL_TextlistItem
> > maTextlist_Top
; // Elements before progress
242 css::uno::Reference
< css::awt::XFixedText
> m_xTopic_Top
; // (used, if parameter "beforeProgress"=true in "addText, updateText, removeText")
243 css::uno::Reference
< css::awt::XFixedText
> m_xText_Top
;
245 ::std::vector
< std::unique_ptr
<IMPL_TextlistItem
> > maTextlist_Bottom
; // Elements below of progress
246 css::uno::Reference
< css::awt::XFixedText
> m_xTopic_Bottom
; // (used, if parameter "beforeProgress"=false in "addText, updateText, removeText")
247 css::uno::Reference
< css::awt::XFixedText
> m_xText_Bottom
;
249 rtl::Reference
<ProgressBar
> m_xProgressBar
;
250 css::uno::Reference
< css::awt::XButton
> m_xButton
;
251 css::awt::Rectangle m_a3DLine
;
256 #endif // INCLUDED_UNOCONTROLS_SOURCE_INC_PROGRESSMONITOR_HXX
258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */