Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _UNOCONTROLS_PROGRESSMONITOR_CTRL_HXX
21 : #define _UNOCONTROLS_PROGRESSMONITOR_CTRL_HXX
22 :
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>
61 :
62 : #include <vector>
63 :
64 : #include "basecontainercontrol.hxx"
65 :
66 : namespace unocontrols{
67 :
68 : class ProgressBar;
69 :
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_BACKGROUNDCOLOR TRGB_COLORDATA( 0x00, 0xC0, 0xC0, 0xC0 ) // lighgray
82 : #define PROGRESSMONITOR_LINECOLOR_BRIGHT TRGB_COLORDATA( 0x00, 0xFF, 0xFF, 0xFF ) // white
83 : #define PROGRESSMONITOR_LINECOLOR_SHADOW TRGB_COLORDATA( 0x00, 0x00, 0x00, 0x00 ) // black
84 : #define PROGRESSMONITOR_DEFAULT_WIDTH 350
85 : #define PROGRESSMONITOR_DEFAULT_HEIGHT 100
86 :
87 : // structs, types
88 :
89 : /// Item of TextList
90 0 : struct IMPL_TextlistItem
91 : {
92 : OUString sTopic; /// Left site of textline in dialog
93 : OUString sText; /// Right site of textline in dialog
94 : };
95 :
96 : // class declaration
97 :
98 : class ProgressMonitor : public ::com::sun::star::awt::XLayoutConstrains
99 : , public ::com::sun::star::awt::XButton
100 : , public ::com::sun::star::awt::XProgressMonitor
101 : , public BaseContainerControl
102 : {
103 :
104 : // public methods
105 :
106 : public:
107 :
108 : // construct/destruct
109 :
110 : /**_______________________________________________________________________________________________________
111 : @short
112 : @descr
113 :
114 : @seealso
115 :
116 : @param
117 :
118 : @return
119 :
120 : @onerror
121 : */
122 :
123 : ProgressMonitor( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
124 :
125 : /**_______________________________________________________________________________________________________
126 : @short
127 : @descr
128 :
129 : @seealso
130 :
131 : @param
132 :
133 : @return
134 :
135 : @onerror
136 : */
137 :
138 : virtual ~ProgressMonitor();
139 :
140 : // XInterface
141 :
142 : /**_______________________________________________________________________________________________________
143 : @short give answer, if interface is supported
144 : @descr The interfaces are searched by type.
145 :
146 : @seealso XInterface
147 :
148 : @param "rType" is the type of searched interface.
149 :
150 : @return Any information about found interface
151 :
152 : @onerror A RuntimeException is thrown.
153 : */
154 :
155 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
156 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
157 :
158 : /**_______________________________________________________________________________________________________
159 : @short increment refcount
160 : @seealso XInterface
161 : @seealso release()
162 : @onerror A RuntimeException is thrown.
163 : */
164 :
165 : virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
166 :
167 : /**_______________________________________________________________________________________________________
168 : @short decrement refcount
169 : @seealso XInterface
170 : @seealso acquire()
171 : @onerror A RuntimeException is thrown.
172 : */
173 :
174 : virtual void SAL_CALL release() throw() SAL_OVERRIDE;
175 :
176 : // XTypeProvider
177 :
178 : /**_______________________________________________________________________________________________________
179 : @short get information about supported interfaces
180 : @seealso XTypeProvider
181 : @return Sequence of types of all supported interfaces
182 :
183 : @onerror A RuntimeException is thrown.
184 : */
185 :
186 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
187 :
188 : // XAggregation
189 :
190 : /**_______________________________________________________________________________________________________
191 : */
192 :
193 : virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& aType )
194 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
195 :
196 : // XProgressMonitor
197 :
198 : /**_______________________________________________________________________________________________________
199 : @short add topic to dialog
200 : @descr Add a topic with a text in right textlist (used for FixedText-member).<BR>
201 : ( "beforeProgress" fix the right list ). The dialog metric is recalculated.
202 :
203 : @seealso removeText(), updateText()
204 :
205 : @param sTopic Name of topic<BR>
206 : [sTopic != "" && sTopic != NULL]
207 : @param sText Value of topic<BR>
208 : [sText != "" && sText != NULL]
209 : @param bbeforeProgress Position of topic<BR>
210 : [True => before progressbar / False => below progressbar]
211 : @onerror DEBUG = Assertion<BR>
212 : RELEASE = nothing
213 : */
214 :
215 : virtual void SAL_CALL addText(
216 : const OUString& sTopic ,
217 : const OUString& sText ,
218 : sal_Bool bbeforeProgress
219 : ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
220 :
221 : /**_______________________________________________________________________________________________________
222 : */
223 :
224 : virtual void SAL_CALL removeText(
225 : const OUString& sTopic ,
226 : sal_Bool bbeforeProgress
227 : ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
228 :
229 : /**_______________________________________________________________________________________________________
230 : */
231 :
232 : virtual void SAL_CALL updateText(
233 : const OUString& sTopic ,
234 : const OUString& sText ,
235 : sal_Bool bbeforeProgress
236 : ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
237 :
238 : // XProgressBar
239 :
240 : /**_______________________________________________________________________________________________________
241 : */
242 :
243 : virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
244 :
245 : /**_______________________________________________________________________________________________________
246 : */
247 :
248 : virtual void SAL_CALL setBackgroundColor( sal_Int32 nColor ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
249 :
250 : /**_______________________________________________________________________________________________________
251 : */
252 :
253 : virtual void SAL_CALL setValue( sal_Int32 nValue ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
254 :
255 : /**_______________________________________________________________________________________________________
256 : */
257 :
258 : virtual void SAL_CALL setRange( sal_Int32 nMin ,
259 : sal_Int32 nMax ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
260 :
261 : /**_______________________________________________________________________________________________________
262 : */
263 :
264 : virtual sal_Int32 SAL_CALL getValue() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
265 :
266 : // XButton
267 :
268 : /**_______________________________________________________________________________________________________
269 : */
270 :
271 : virtual void SAL_CALL addActionListener(
272 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& xListener
273 : ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
274 :
275 : /**_______________________________________________________________________________________________________
276 : */
277 :
278 : virtual void SAL_CALL removeActionListener(
279 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& xListener
280 : ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
281 :
282 : /**_______________________________________________________________________________________________________
283 : */
284 :
285 : virtual void SAL_CALL setLabel( const OUString& sLabel ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
286 :
287 : /**_______________________________________________________________________________________________________
288 : */
289 :
290 : virtual void SAL_CALL setActionCommand( const OUString& sCommand )
291 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
292 :
293 : // XLayoutConstrains
294 :
295 : /**_______________________________________________________________________________________________________
296 : */
297 :
298 : virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
299 :
300 : /**_______________________________________________________________________________________________________
301 : */
302 :
303 : virtual ::com::sun::star::awt::Size SAL_CALL getPreferredSize() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
304 :
305 : /**_______________________________________________________________________________________________________
306 : */
307 :
308 : virtual ::com::sun::star::awt::Size SAL_CALL calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize )
309 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
310 :
311 : // XControl
312 :
313 : /**_______________________________________________________________________________________________________
314 : */
315 :
316 : virtual void SAL_CALL createPeer(
317 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& xToolkit ,
318 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent
319 : ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
320 :
321 : /**_______________________________________________________________________________________________________
322 : */
323 :
324 : virtual sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& xModel )
325 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
326 :
327 : /**_______________________________________________________________________________________________________
328 : */
329 :
330 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > SAL_CALL getModel()
331 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
332 :
333 : // XComponent
334 :
335 : /**_______________________________________________________________________________________________________
336 : */
337 :
338 : virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
339 :
340 : // XWindow
341 :
342 : /**_______________________________________________________________________________________________________
343 : */
344 :
345 : virtual void SAL_CALL setPosSize( sal_Int32 nX ,
346 : sal_Int32 nY ,
347 : sal_Int32 nWidth ,
348 : sal_Int32 nHeight ,
349 : sal_Int16 nFlags ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
350 :
351 : // BaseControl
352 :
353 : /**_______________________________________________________________________________________________________
354 : */
355 :
356 : static const ::com::sun::star::uno::Sequence< OUString > impl_getStaticSupportedServiceNames();
357 :
358 : /**_______________________________________________________________________________________________________
359 : */
360 :
361 : static const OUString impl_getStaticImplementationName();
362 :
363 : // protected methods
364 :
365 : protected:
366 :
367 : /**_______________________________________________________________________________________________________
368 : */
369 :
370 : virtual void impl_paint( sal_Int32 nX ,
371 : sal_Int32 nY ,
372 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics ) SAL_OVERRIDE;
373 :
374 : // private methods
375 :
376 : private:
377 : using BaseControl::impl_recalcLayout;
378 : /**_______________________________________________________________________________________________________
379 : */
380 :
381 : void impl_recalcLayout();
382 :
383 : /**_______________________________________________________________________________________________________
384 : */
385 :
386 : void impl_rebuildFixedText();
387 :
388 : /**_______________________________________________________________________________________________________
389 : */
390 :
391 : void impl_cleanMemory();
392 :
393 : /**_______________________________________________________________________________________________________
394 : */
395 :
396 : IMPL_TextlistItem* impl_searchTopic( const OUString& sTopic , bool bbeforeProgress );
397 :
398 : // debug methods
399 :
400 : private:
401 :
402 : /**_______________________________________________________________________________________________________
403 : */
404 :
405 : #ifdef DBG_UTIL
406 :
407 : bool impl_debug_checkParameter( const OUString& sTopic, const OUString& sText, bool bbeforeProgress ); // addText, updateText
408 : bool impl_debug_checkParameter( const OUString& rTopic, bool bbeforeProgress ); // removeText
409 :
410 : #endif
411 :
412 : // private variables
413 :
414 : private:
415 : ::std::vector < IMPL_TextlistItem* > maTextlist_Top; // Elements before progress
416 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFixedText > m_xTopic_Top; // (used, if parameter "beforeProgress"=sal_True in "addText, updateText, removeText")
417 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFixedText > m_xText_Top;
418 :
419 : ::std::vector < IMPL_TextlistItem* > maTextlist_Bottom; // Elements below of progress
420 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFixedText > m_xTopic_Bottom; // (used, if parameter "beforeProgress"=sal_False in "addText, updateText, removeText")
421 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFixedText > m_xText_Bottom;
422 :
423 : rtl::Reference<ProgressBar> m_xProgressBar;
424 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XButton > m_xButton;
425 : ::com::sun::star::awt::Rectangle m_a3DLine;
426 :
427 : }; // class ProgressMonitor
428 :
429 : } // namespace unocontrols
430 :
431 : #endif // #ifndef _UNOCONTROLS_PROGRESSMONITOR_CTRL_HXX
432 :
433 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|