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 INCLUDED_UNOCONTROLS_SOURCE_INC_STATUSINDICATOR_HXX
21 #define INCLUDED_UNOCONTROLS_SOURCE_INC_STATUSINDICATOR_HXX
22 
23 #include <com/sun/star/awt/XLayoutConstrains.hpp>
24 #include <com/sun/star/task/XStatusIndicator.hpp>
25 #include <rtl/ref.hxx>
26 
27 #include <basecontainercontrol.hxx>
28 
29 namespace com::sun::star::awt { class XControlModel; }
30 namespace com::sun::star::awt { class XFixedText; }
31 namespace com::sun::star::awt { class XGraphics; }
32 namespace com::sun::star::awt { class XToolkit; }
33 namespace com::sun::star::awt { class XWindowPeer; }
34 
35 namespace unocontrols {
36 
37 class ProgressBar;
38 
39 #define STATUSINDICATOR_FREEBORDER              5                                                       // border around and between the controls
40 #define STATUSINDICATOR_BACKGROUNDCOLOR         sal_Int32(Color( 0x00, 0xC0, 0xC0, 0xC0 ))              // lightgray
41 #define STATUSINDICATOR_LINECOLOR_BRIGHT        sal_Int32(Color( 0x00, 0xFF, 0xFF, 0xFF ))              // white
42 #define STATUSINDICATOR_LINECOLOR_SHADOW        sal_Int32(Color( 0x00, 0x00, 0x00, 0x00 ))              // black
43 #define STATUSINDICATOR_DEFAULT_WIDTH           300
44 #define STATUSINDICATOR_DEFAULT_HEIGHT          25
45 
46 class StatusIndicator   : public css::awt::XLayoutConstrains
47                         , public css::task::XStatusIndicator
48                         , public BaseContainerControl
49 {
50 public:
51     StatusIndicator( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
52 
53     virtual ~StatusIndicator() override;
54 
55     //  XInterface
56 
57     /**
58         @short      give answer, if interface is supported
59         @descr      The interfaces are searched by type.
60 
61         @seealso    XInterface
62 
63         @param      "rType" is the type of searched interface.
64 
65         @return     Any     information about found interface
66 
67         @onerror    A RuntimeException is thrown.
68     */
69 
70     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
71 
72     /**
73         @short      increment refcount
74         @seealso    XInterface
75         @seealso    release()
76         @onerror    A RuntimeException is thrown.
77     */
78 
79     virtual void SAL_CALL acquire() throw() override;
80 
81     /**
82         @short      decrement refcount
83         @seealso    XInterface
84         @seealso    acquire()
85         @onerror    A RuntimeException is thrown.
86     */
87 
88     virtual void SAL_CALL release() throw() override;
89 
90     //  XTypeProvider
91 
92     /**
93         @short      get information about supported interfaces
94         @seealso    XTypeProvider
95         @return     Sequence of types of all supported interfaces
96 
97         @onerror    A RuntimeException is thrown.
98     */
99 
100     virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
101 
102     //  XAggregation
103 
104     virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type& aType ) override;
105 
106     //  XStatusIndicator
107 
108     virtual void SAL_CALL start(
109         const OUString&  sText   ,
110         sal_Int32 nRange
111     ) override;
112 
113     virtual void SAL_CALL end() override;
114 
115     virtual void SAL_CALL reset() override;
116 
117     virtual void SAL_CALL setText( const OUString& sText ) override;
118 
119     virtual void SAL_CALL setValue( sal_Int32 nValue ) override;
120 
121     //  XLayoutConstrains
122 
123     virtual css::awt::Size SAL_CALL getMinimumSize() override;
124 
125     virtual css::awt::Size SAL_CALL getPreferredSize() override;
126 
127     virtual css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override;
128 
129     //  XControl
130 
131     virtual void SAL_CALL createPeer(
132         const   css::uno::Reference< css::awt::XToolkit >&    xToolkit    ,
133         const   css::uno::Reference< css::awt::XWindowPeer >& xParent
134     ) override;
135 
136     virtual sal_Bool SAL_CALL setModel( const css::uno::Reference< css::awt::XControlModel >& xModel ) override;
137 
138     virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override;
139 
140     //  XComponent
141 
142     virtual void SAL_CALL dispose() override;
143 
144     //  XWindow
145 
146     virtual void SAL_CALL setPosSize(   sal_Int32   nX      ,
147                                         sal_Int32   nY      ,
148                                         sal_Int32   nWidth  ,
149                                         sal_Int32   nHeight ,
150                                         sal_Int16   nFlags  ) override;
151 
152     //  BaseControl
153 
154     static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames();
155 
156     static OUString impl_getStaticImplementationName();
157 
158 protected:
159     virtual css::awt::WindowDescriptor impl_getWindowDescriptor(
160         const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer
161     ) override;
162 
163     virtual void impl_paint (
164         sal_Int32 nX,
165         sal_Int32 nY,
166         const css::uno::Reference< css::awt::XGraphics > & rGraphics
167     ) override;
168 
169     virtual void impl_recalcLayout( const css::awt::WindowEvent& aEvent ) override;
170 
171 private:
172     css::uno::Reference< css::awt::XFixedText >   m_xText;
173     rtl::Reference<ProgressBar>                   m_xProgressBar;
174 
175 };
176 
177 }
178 
179 #endif // INCLUDED_UNOCONTROLS_SOURCE_INC_STATUSINDICATOR_HXX
180 
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
182