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 OUString PROGRESSMONITOR_DEFAULT_TOPIC
= u
""_ustr
;
40 inline constexpr OUString PROGRESSMONITOR_DEFAULT_TEXT
= u
""_ustr
;
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 using ProgressMonitor_BASE
= cppu::ImplInheritanceHelper
<BaseContainerControl
,
54 css::awt::XLayoutConstrains
,
56 css::awt::XProgressMonitor
>;
57 class ProgressMonitor final
: public ProgressMonitor_BASE
60 ProgressMonitor( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
62 virtual ~ProgressMonitor() override
;
67 @short add topic to dialog
68 @descr Add a topic with a text in right textlist (used for FixedText-member).<BR>
69 ( "beforeProgress" fix the right list ). The dialog metric is recalculated.
71 @seealso removeText(), updateText()
73 @param sTopic Name of topic<BR>
74 [sTopic != "" && sTopic != NULL]
75 @param sText Value of topic<BR>
76 [sText != "" && sText != NULL]
77 @param bbeforeProgress Position of topic<BR>
78 [True => before progressbar / False => below progressbar]
79 @onerror DEBUG = Assertion<BR>
83 virtual void SAL_CALL
addText(
84 const OUString
& sTopic
,
85 const OUString
& sText
,
86 sal_Bool bbeforeProgress
89 virtual void SAL_CALL
removeText(
90 const OUString
& sTopic
,
91 sal_Bool bbeforeProgress
94 virtual void SAL_CALL
updateText(
95 const OUString
& sTopic
,
96 const OUString
& sText
,
97 sal_Bool bbeforeProgress
102 virtual void SAL_CALL
setForegroundColor( sal_Int32 nColor
) override
;
104 virtual void SAL_CALL
setBackgroundColor( sal_Int32 nColor
) override
;
106 virtual void SAL_CALL
setValue( sal_Int32 nValue
) override
;
108 virtual void SAL_CALL
setRange( sal_Int32 nMin
,
109 sal_Int32 nMax
) override
;
111 virtual sal_Int32 SAL_CALL
getValue() override
;
115 virtual void SAL_CALL
addActionListener(
116 const css::uno::Reference
< css::awt::XActionListener
>& xListener
119 virtual void SAL_CALL
removeActionListener(
120 const css::uno::Reference
< css::awt::XActionListener
>& xListener
123 virtual void SAL_CALL
setLabel( const OUString
& sLabel
) override
;
125 virtual void SAL_CALL
setActionCommand( const OUString
& sCommand
) override
;
129 virtual css::awt::Size SAL_CALL
getMinimumSize() override
;
131 virtual css::awt::Size SAL_CALL
getPreferredSize() override
;
133 virtual css::awt::Size SAL_CALL
calcAdjustedSize( const css::awt::Size
& aNewSize
) override
;
137 virtual void SAL_CALL
createPeer(
138 const css::uno::Reference
< css::awt::XToolkit
>& xToolkit
,
139 const css::uno::Reference
< css::awt::XWindowPeer
>& xParent
142 virtual sal_Bool SAL_CALL
setModel( const css::uno::Reference
< css::awt::XControlModel
>& xModel
) override
;
144 virtual css::uno::Reference
< css::awt::XControlModel
> SAL_CALL
getModel() override
;
148 virtual void SAL_CALL
dispose() override
;
152 virtual void SAL_CALL
setPosSize( sal_Int32 nX
,
156 sal_Int16 nFlags
) override
;
159 virtual void impl_paint( sal_Int32 nX
,
161 const css::uno::Reference
< css::awt::XGraphics
>& xGraphics
) override
;
163 using BaseControl::impl_recalcLayout
;
165 void impl_recalcLayout();
167 void impl_rebuildFixedText();
169 void impl_cleanMemory();
171 IMPL_TextlistItem
* impl_searchTopic( std::u16string_view sTopic
, bool bbeforeProgress
);
175 static bool impl_debug_checkParameter( std::u16string_view sTopic
, std::u16string_view sText
); // addText, updateText
176 static bool impl_debug_checkParameter( std::u16string_view rTopic
); // removeText
181 ::std::vector
< IMPL_TextlistItem
> maTextlist_Top
; // Elements before progress
182 css::uno::Reference
< css::awt::XFixedText
> m_xTopic_Top
; // (used, if parameter "beforeProgress"=true in "addText, updateText, removeText")
183 css::uno::Reference
< css::awt::XFixedText
> m_xText_Top
;
185 ::std::vector
< IMPL_TextlistItem
> maTextlist_Bottom
; // Elements below of progress
186 css::uno::Reference
< css::awt::XFixedText
> m_xTopic_Bottom
; // (used, if parameter "beforeProgress"=false in "addText, updateText, removeText")
187 css::uno::Reference
< css::awt::XFixedText
> m_xText_Bottom
;
189 rtl::Reference
<ProgressBar
> m_xProgressBar
;
190 css::uno::Reference
< css::awt::XButton
> m_xButton
;
191 css::awt::Rectangle m_a3DLine
;
197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */