Bump version to 6.4-15
[LibreOffice.git] / UnoControls / source / inc / progressmonitor.hxx
blob339b6e6cb6ccf7e78e97d79b083e23bb7ef490db
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
28 #include <vector>
29 #include <memory>
31 #include <basecontainercontrol.hxx>
33 namespace com::sun::star::awt { class XFixedText; }
34 namespace com::sun::star::awt { class XControlModel; }
36 namespace unocontrols {
38 class ProgressBar;
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
48 /// Item of TextList
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
60 public:
61 ProgressMonitor( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
63 virtual ~ProgressMonitor() override;
65 // XInterface
67 /**
68 @short give answer, if interface is supported
69 @descr The interfaces are searched by type.
71 @seealso XInterface
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;
82 /**
83 @short increment refcount
84 @seealso XInterface
85 @seealso release()
86 @onerror A RuntimeException is thrown.
89 virtual void SAL_CALL acquire() throw() override;
91 /**
92 @short decrement refcount
93 @seealso XInterface
94 @seealso acquire()
95 @onerror A RuntimeException is thrown.
98 virtual void SAL_CALL release() throw() override;
100 // XTypeProvider
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;
112 // XAggregation
114 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& aType ) override;
116 // XProgressMonitor
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>
132 RELEASE = nothing
135 virtual void SAL_CALL addText(
136 const OUString& sTopic ,
137 const OUString& sText ,
138 sal_Bool bbeforeProgress
139 ) override;
141 virtual void SAL_CALL removeText(
142 const OUString& sTopic ,
143 sal_Bool bbeforeProgress
144 ) override;
146 virtual void SAL_CALL updateText(
147 const OUString& sTopic ,
148 const OUString& sText ,
149 sal_Bool bbeforeProgress
150 ) override;
152 // XProgressBar
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;
165 // XButton
167 virtual void SAL_CALL addActionListener(
168 const css::uno::Reference< css::awt::XActionListener >& xListener
169 ) override;
171 virtual void SAL_CALL removeActionListener(
172 const css::uno::Reference< css::awt::XActionListener >& xListener
173 ) override;
175 virtual void SAL_CALL setLabel( const OUString& sLabel ) override;
177 virtual void SAL_CALL setActionCommand( const OUString& sCommand ) override;
179 // XLayoutConstrains
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;
187 // XControl
189 virtual void SAL_CALL createPeer(
190 const css::uno::Reference< css::awt::XToolkit >& xToolkit ,
191 const css::uno::Reference< css::awt::XWindowPeer >& xParent
192 ) override;
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;
198 // XComponent
200 virtual void SAL_CALL dispose() override;
202 // XWindow
204 virtual void SAL_CALL setPosSize( sal_Int32 nX ,
205 sal_Int32 nY ,
206 sal_Int32 nWidth ,
207 sal_Int32 nHeight ,
208 sal_Int16 nFlags ) override;
210 // BaseControl
212 static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames();
214 static OUString impl_getStaticImplementationName();
216 protected:
217 virtual void impl_paint( sal_Int32 nX ,
218 sal_Int32 nY ,
219 const css::uno::Reference< css::awt::XGraphics >& xGraphics ) override;
221 private:
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 );
232 // debug methods
234 private:
235 static bool impl_debug_checkParameter( const OUString& sTopic, const OUString& sText ); // addText, updateText
236 static bool impl_debug_checkParameter( const OUString& rTopic ); // removeText
238 // private variables
240 private:
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: */