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/XFileDialog.hpp>
24 #include <com/sun/star/awt/XTextComponent.hpp>
25 #include <com/sun/star/awt/XListBox.hpp>
26 #include <com/sun/star/awt/XProgressMonitor.hpp>
27 #include <com/sun/star/awt/TextAlign.hpp>
28 #include <com/sun/star/awt/XScrollBar.hpp>
29 #include <com/sun/star/awt/XVclContainerPeer.hpp>
30 #include <com/sun/star/awt/XTabControllerModel.hpp>
31 #include <com/sun/star/awt/XMessageBox.hpp>
32 #include <com/sun/star/awt/XTextEditField.hpp>
33 #include <com/sun/star/awt/Style.hpp>
34 #include <com/sun/star/awt/XTimeField.hpp>
35 #include <com/sun/star/awt/XVclWindowPeer.hpp>
36 #include <com/sun/star/awt/XControlModel.hpp>
37 #include <com/sun/star/awt/XSpinField.hpp>
38 #include <com/sun/star/awt/XUnoControlContainer.hpp>
39 #include <com/sun/star/awt/XTextLayoutConstrains.hpp>
40 #include <com/sun/star/awt/XNumericField.hpp>
41 #include <com/sun/star/awt/XButton.hpp>
42 #include <com/sun/star/awt/XTextArea.hpp>
43 #include <com/sun/star/awt/XImageButton.hpp>
44 #include <com/sun/star/awt/XFixedText.hpp>
45 #include <com/sun/star/awt/XControlContainer.hpp>
46 #include <com/sun/star/awt/XDialog.hpp>
47 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
48 #include <com/sun/star/awt/XRadioButton.hpp>
49 #include <com/sun/star/awt/XCurrencyField.hpp>
50 #include <com/sun/star/awt/XPatternField.hpp>
51 #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
52 #include <com/sun/star/awt/XTabController.hpp>
53 #include <com/sun/star/awt/XVclContainer.hpp>
54 #include <com/sun/star/awt/XDateField.hpp>
55 #include <com/sun/star/awt/XComboBox.hpp>
56 #include <com/sun/star/awt/XControl.hpp>
57 #include <com/sun/star/awt/XCheckBox.hpp>
58 #include <com/sun/star/awt/XLayoutConstrains.hpp>
59 #include <com/sun/star/awt/XProgressBar.hpp>
60 #include <rtl/ref.hxx>
64 #include "basecontainercontrol.hxx"
66 namespace unocontrols
{
70 #define PROGRESSMONITOR_FREEBORDER 10 // border around and between the controls
71 #define FIXEDTEXT_SERVICENAME "com.sun.star.awt.UnoControlFixedText"
72 #define BUTTON_SERVICENAME "com.sun.star.awt.UnoControlButton"
73 #define FIXEDTEXT_MODELNAME "com.sun.star.awt.UnoControlFixedTextModel"
74 #define BUTTON_MODELNAME "com.sun.star.awt.UnoControlButtonModel"
75 #define CONTROLNAME_TEXT "Text" // identifier the control in container
76 #define CONTROLNAME_BUTTON "Button" // -||-
77 #define CONTROLNAME_PROGRESSBAR "ProgressBar" // -||-
78 #define DEFAULT_BUTTONLABEL "Abbrechen"
79 #define PROGRESSMONITOR_DEFAULT_TOPIC ""
80 #define PROGRESSMONITOR_DEFAULT_TEXT ""
81 #define PROGRESSMONITOR_LINECOLOR_BRIGHT TRGB_COLORDATA( 0x00, 0xFF, 0xFF, 0xFF ) // white
82 #define PROGRESSMONITOR_LINECOLOR_SHADOW TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x00 ) // black
83 #define PROGRESSMONITOR_DEFAULT_WIDTH 350
84 #define PROGRESSMONITOR_DEFAULT_HEIGHT 100
89 struct IMPL_TextlistItem
91 OUString sTopic
; /// Left site of textline in dialog
92 OUString sText
; /// Right site of textline in dialog
97 class ProgressMonitor
: public ::com::sun::star::awt::XLayoutConstrains
98 , public ::com::sun::star::awt::XButton
99 , public ::com::sun::star::awt::XProgressMonitor
100 , public BaseContainerControl
107 // construct/destruct
109 /**_______________________________________________________________________________________________________
122 ProgressMonitor( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
);
124 /**_______________________________________________________________________________________________________
137 virtual ~ProgressMonitor();
141 /**_______________________________________________________________________________________________________
142 @short give answer, if interface is supported
143 @descr The interfaces are searched by type.
147 @param "rType" is the type of searched interface.
149 @return Any information about found interface
151 @onerror A RuntimeException is thrown.
154 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
)
155 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
157 /**_______________________________________________________________________________________________________
158 @short increment refcount
161 @onerror A RuntimeException is thrown.
164 virtual void SAL_CALL
acquire() throw() SAL_OVERRIDE
;
166 /**_______________________________________________________________________________________________________
167 @short decrement refcount
170 @onerror A RuntimeException is thrown.
173 virtual void SAL_CALL
release() throw() SAL_OVERRIDE
;
177 /**_______________________________________________________________________________________________________
178 @short get information about supported interfaces
179 @seealso XTypeProvider
180 @return Sequence of types of all supported interfaces
182 @onerror A RuntimeException is thrown.
185 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
189 /**_______________________________________________________________________________________________________
192 virtual ::com::sun::star::uno::Any SAL_CALL
queryAggregation( const ::com::sun::star::uno::Type
& aType
)
193 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
197 /**_______________________________________________________________________________________________________
198 @short add topic to dialog
199 @descr Add a topic with a text in right textlist (used for FixedText-member).<BR>
200 ( "beforeProgress" fix the right list ). The dialog metric is recalculated.
202 @seealso removeText(), updateText()
204 @param sTopic Name of topic<BR>
205 [sTopic != "" && sTopic != NULL]
206 @param sText Value of topic<BR>
207 [sText != "" && sText != NULL]
208 @param bbeforeProgress Position of topic<BR>
209 [True => before progressbar / False => below progressbar]
210 @onerror DEBUG = Assertion<BR>
214 virtual void SAL_CALL
addText(
215 const OUString
& sTopic
,
216 const OUString
& sText
,
217 sal_Bool bbeforeProgress
218 ) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
220 /**_______________________________________________________________________________________________________
223 virtual void SAL_CALL
removeText(
224 const OUString
& sTopic
,
225 sal_Bool bbeforeProgress
226 ) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
228 /**_______________________________________________________________________________________________________
231 virtual void SAL_CALL
updateText(
232 const OUString
& sTopic
,
233 const OUString
& sText
,
234 sal_Bool bbeforeProgress
235 ) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
239 /**_______________________________________________________________________________________________________
242 virtual void SAL_CALL
setForegroundColor( sal_Int32 nColor
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
244 /**_______________________________________________________________________________________________________
247 virtual void SAL_CALL
setBackgroundColor( sal_Int32 nColor
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
249 /**_______________________________________________________________________________________________________
252 virtual void SAL_CALL
setValue( sal_Int32 nValue
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
254 /**_______________________________________________________________________________________________________
257 virtual void SAL_CALL
setRange( sal_Int32 nMin
,
258 sal_Int32 nMax
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
260 /**_______________________________________________________________________________________________________
263 virtual sal_Int32 SAL_CALL
getValue() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
267 /**_______________________________________________________________________________________________________
270 virtual void SAL_CALL
addActionListener(
271 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
>& xListener
272 ) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
274 /**_______________________________________________________________________________________________________
277 virtual void SAL_CALL
removeActionListener(
278 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XActionListener
>& xListener
279 ) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
281 /**_______________________________________________________________________________________________________
284 virtual void SAL_CALL
setLabel( const OUString
& sLabel
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
286 /**_______________________________________________________________________________________________________
289 virtual void SAL_CALL
setActionCommand( const OUString
& sCommand
)
290 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
294 /**_______________________________________________________________________________________________________
297 virtual ::com::sun::star::awt::Size SAL_CALL
getMinimumSize() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
299 /**_______________________________________________________________________________________________________
302 virtual ::com::sun::star::awt::Size SAL_CALL
getPreferredSize() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
304 /**_______________________________________________________________________________________________________
307 virtual ::com::sun::star::awt::Size SAL_CALL
calcAdjustedSize( const ::com::sun::star::awt::Size
& aNewSize
)
308 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
312 /**_______________________________________________________________________________________________________
315 virtual void SAL_CALL
createPeer(
316 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XToolkit
>& xToolkit
,
317 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
>& xParent
318 ) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
320 /**_______________________________________________________________________________________________________
323 virtual sal_Bool SAL_CALL
setModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
>& xModel
)
324 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
326 /**_______________________________________________________________________________________________________
329 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
> SAL_CALL
getModel()
330 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
334 /**_______________________________________________________________________________________________________
337 virtual void SAL_CALL
dispose() throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
341 /**_______________________________________________________________________________________________________
344 virtual void SAL_CALL
setPosSize( sal_Int32 nX
,
348 sal_Int16 nFlags
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
352 /**_______________________________________________________________________________________________________
355 static const ::com::sun::star::uno::Sequence
< OUString
> impl_getStaticSupportedServiceNames();
357 /**_______________________________________________________________________________________________________
360 static const OUString
impl_getStaticImplementationName();
366 /**_______________________________________________________________________________________________________
369 virtual void impl_paint( sal_Int32 nX
,
371 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XGraphics
>& xGraphics
) SAL_OVERRIDE
;
376 using BaseControl::impl_recalcLayout
;
377 /**_______________________________________________________________________________________________________
380 void impl_recalcLayout();
382 /**_______________________________________________________________________________________________________
385 void impl_rebuildFixedText();
387 /**_______________________________________________________________________________________________________
390 void impl_cleanMemory();
392 /**_______________________________________________________________________________________________________
395 IMPL_TextlistItem
* impl_searchTopic( const OUString
& sTopic
, bool bbeforeProgress
);
401 /**_______________________________________________________________________________________________________
406 static bool impl_debug_checkParameter( const OUString
& sTopic
, const OUString
& sText
, bool bbeforeProgress
); // addText, updateText
407 static bool impl_debug_checkParameter( const OUString
& rTopic
, bool bbeforeProgress
); // removeText
414 ::std::vector
< IMPL_TextlistItem
* > maTextlist_Top
; // Elements before progress
415 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFixedText
> m_xTopic_Top
; // (used, if parameter "beforeProgress"=true in "addText, updateText, removeText")
416 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFixedText
> m_xText_Top
;
418 ::std::vector
< IMPL_TextlistItem
* > maTextlist_Bottom
; // Elements below of progress
419 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFixedText
> m_xTopic_Bottom
; // (used, if parameter "beforeProgress"=false in "addText, updateText, removeText")
420 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFixedText
> m_xText_Bottom
;
422 rtl::Reference
<ProgressBar
> m_xProgressBar
;
423 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XButton
> m_xButton
;
424 ::com::sun::star::awt::Rectangle m_a3DLine
;
426 }; // class ProgressMonitor
428 } // namespace unocontrols
430 #endif // INCLUDED_UNOCONTROLS_SOURCE_INC_PROGRESSMONITOR_HXX
432 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */