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/XProgressMonitor.hpp>
23 #include <com/sun/star/awt/XButton.hpp>
24 #include <com/sun/star/awt/XLayoutConstrains.hpp>
25 #include <rtl/ref.hxx>
29 #include <basecontainercontrol.hxx>
31 namespace com::sun::star::awt
{ class XFixedText
; }
32 namespace com::sun::star::awt
{ class XControlModel
; }
34 namespace unocontrols
{
38 #define PROGRESSMONITOR_FREEBORDER 10 // border around and between the controls
39 inline constexpr OUStringLiteral PROGRESSMONITOR_DEFAULT_TOPIC
= u
"";
40 inline constexpr OUStringLiteral PROGRESSMONITOR_DEFAULT_TEXT
= u
"";
41 #define PROGRESSMONITOR_LINECOLOR_BRIGHT sal_Int32(Color( 0xFF, 0xFF, 0xFF )) // white
42 #define PROGRESSMONITOR_LINECOLOR_SHADOW sal_Int32(Color( 0x00, 0x00, 0x00 )) // black
43 #define PROGRESSMONITOR_DEFAULT_WIDTH 350
44 #define PROGRESSMONITOR_DEFAULT_HEIGHT 100
47 struct IMPL_TextlistItem
49 OUString sTopic
; /// Left site of textline in dialog
50 OUString sText
; /// Right site of textline in dialog
53 class ProgressMonitor final
: public css::awt::XLayoutConstrains
54 , public css::awt::XButton
55 , public css::awt::XProgressMonitor
56 , public BaseContainerControl
59 ProgressMonitor( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
61 virtual ~ProgressMonitor() override
;
66 @short give answer, if interface is supported
67 @descr The interfaces are searched by type.
71 @param "rType" is the type of searched interface.
73 @return Any information about found interface
75 @onerror A RuntimeException is thrown.
78 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
81 @short increment refcount
84 @onerror A RuntimeException is thrown.
87 virtual void SAL_CALL
acquire() noexcept override
;
90 @short decrement refcount
93 @onerror A RuntimeException is thrown.
96 virtual void SAL_CALL
release() noexcept override
;
101 @short get information about supported interfaces
102 @seealso XTypeProvider
103 @return Sequence of types of all supported interfaces
105 @onerror A RuntimeException is thrown.
108 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
113 @short add topic to dialog
114 @descr Add a topic with a text in right textlist (used for FixedText-member).<BR>
115 ( "beforeProgress" fix the right list ). The dialog metric is recalculated.
117 @seealso removeText(), updateText()
119 @param sTopic Name of topic<BR>
120 [sTopic != "" && sTopic != NULL]
121 @param sText Value of topic<BR>
122 [sText != "" && sText != NULL]
123 @param bbeforeProgress Position of topic<BR>
124 [True => before progressbar / False => below progressbar]
125 @onerror DEBUG = Assertion<BR>
129 virtual void SAL_CALL
addText(
130 const OUString
& sTopic
,
131 const OUString
& sText
,
132 sal_Bool bbeforeProgress
135 virtual void SAL_CALL
removeText(
136 const OUString
& sTopic
,
137 sal_Bool bbeforeProgress
140 virtual void SAL_CALL
updateText(
141 const OUString
& sTopic
,
142 const OUString
& sText
,
143 sal_Bool bbeforeProgress
148 virtual void SAL_CALL
setForegroundColor( sal_Int32 nColor
) override
;
150 virtual void SAL_CALL
setBackgroundColor( sal_Int32 nColor
) override
;
152 virtual void SAL_CALL
setValue( sal_Int32 nValue
) override
;
154 virtual void SAL_CALL
setRange( sal_Int32 nMin
,
155 sal_Int32 nMax
) override
;
157 virtual sal_Int32 SAL_CALL
getValue() override
;
161 virtual void SAL_CALL
addActionListener(
162 const css::uno::Reference
< css::awt::XActionListener
>& xListener
165 virtual void SAL_CALL
removeActionListener(
166 const css::uno::Reference
< css::awt::XActionListener
>& xListener
169 virtual void SAL_CALL
setLabel( const OUString
& sLabel
) override
;
171 virtual void SAL_CALL
setActionCommand( const OUString
& sCommand
) override
;
175 virtual css::awt::Size SAL_CALL
getMinimumSize() override
;
177 virtual css::awt::Size SAL_CALL
getPreferredSize() override
;
179 virtual css::awt::Size SAL_CALL
calcAdjustedSize( const css::awt::Size
& aNewSize
) override
;
183 virtual void SAL_CALL
createPeer(
184 const css::uno::Reference
< css::awt::XToolkit
>& xToolkit
,
185 const css::uno::Reference
< css::awt::XWindowPeer
>& xParent
188 virtual sal_Bool SAL_CALL
setModel( const css::uno::Reference
< css::awt::XControlModel
>& xModel
) override
;
190 virtual css::uno::Reference
< css::awt::XControlModel
> SAL_CALL
getModel() override
;
194 virtual void SAL_CALL
dispose() override
;
198 virtual void SAL_CALL
setPosSize( sal_Int32 nX
,
202 sal_Int16 nFlags
) override
;
205 virtual void impl_paint( sal_Int32 nX
,
207 const css::uno::Reference
< css::awt::XGraphics
>& xGraphics
) override
;
209 using BaseControl::impl_recalcLayout
;
211 void impl_recalcLayout();
213 void impl_rebuildFixedText();
215 void impl_cleanMemory();
217 IMPL_TextlistItem
* impl_searchTopic( std::u16string_view sTopic
, bool bbeforeProgress
);
221 static bool impl_debug_checkParameter( std::u16string_view sTopic
, std::u16string_view sText
); // addText, updateText
222 static bool impl_debug_checkParameter( std::u16string_view rTopic
); // removeText
227 ::std::vector
< IMPL_TextlistItem
> maTextlist_Top
; // Elements before progress
228 css::uno::Reference
< css::awt::XFixedText
> m_xTopic_Top
; // (used, if parameter "beforeProgress"=true in "addText, updateText, removeText")
229 css::uno::Reference
< css::awt::XFixedText
> m_xText_Top
;
231 ::std::vector
< IMPL_TextlistItem
> maTextlist_Bottom
; // Elements below of progress
232 css::uno::Reference
< css::awt::XFixedText
> m_xTopic_Bottom
; // (used, if parameter "beforeProgress"=false in "addText, updateText, removeText")
233 css::uno::Reference
< css::awt::XFixedText
> m_xText_Bottom
;
235 rtl::Reference
<ProgressBar
> m_xProgressBar
;
236 css::uno::Reference
< css::awt::XButton
> m_xButton
;
237 css::awt::Rectangle m_a3DLine
;
243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */