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 #ifndef INCLUDED_SFX2_INFOBAR_HXX
10 #define INCLUDED_SFX2_INFOBAR_HXX
14 #include <vcl/button.hxx>
15 #include <vcl/fixed.hxx>
16 #include <basegfx/color/bcolor.hxx>
18 #include <sfx2/dllapi.h>
19 #include <sfx2/childwin.hxx>
21 // These must match the values in offapi/com/sun/star/frame/InfobarType.idl
22 enum class InfobarType
{
33 OUString msPrimaryMessage
;
34 OUString msSecondaryMessage
;
35 InfobarType maInfobarType
;
36 bool mbShowCloseButton
;
39 /** SfxChildWindow for positioning the InfoBar in the view.
41 class SFX2_DLLPUBLIC SfxInfoBarContainerChild final
: public SfxChildWindow
44 SfxBindings
* const m_pBindings
;
47 SfxInfoBarContainerChild( vcl::Window
* pParent
,
49 SfxBindings
* pBindings
,
50 SfxChildWinInfo
* pInfo
);
51 virtual ~SfxInfoBarContainerChild() override
;
53 SFX_DECL_CHILDWINDOW_WITHID( SfxInfoBarContainerChild
);
58 /** Class representing a single InfoBar to be added in a SfxInfoBarContainerWindow.
60 class SFX2_DLLPUBLIC SfxInfoBarWindow final
: public vcl::Window
65 VclPtr
<FixedImage
> m_pImage
;
66 VclPtr
<FixedText
> m_pPrimaryMessage
;
67 VclPtr
<FixedText
> m_pSecondaryMessage
;
68 VclPtr
<Button
> m_pCloseBtn
;
69 std::vector
< VclPtr
<PushButton
> > m_aActionBtns
;
71 void SetForeAndBackgroundColors( InfobarType eType
);
74 SfxInfoBarWindow( vcl::Window
* parent
, const OUString
& sId
,
75 const OUString
& sPrimaryMessage
,
76 const OUString
& sSecondaryMessage
,
77 InfobarType InfobarType
,
78 bool bShowCloseButton
, WinBits nMessageStyle
);
79 virtual ~SfxInfoBarWindow( ) override
;
80 virtual void dispose() override
;
82 const OUString
& getId() const { return m_sId
; }
83 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& ) override
;
84 virtual void Resize( ) override
;
85 void Update(const OUString
& sPrimaryMessage
, const OUString
& sSecondaryMessage
,
87 basegfx::BColor m_aBackgroundColor
;
88 basegfx::BColor m_aForegroundColor
;
90 /** Add button to Infobar.
91 * Infobar takes ownership of the button so the button is
92 * destroyed when the infobar gets destroyed.
94 void addButton(PushButton
* pButton
);
97 DECL_LINK( CloseHandler
, Button
*, void );
100 class SfxInfoBarContainerWindow final
: public vcl::Window
103 SfxInfoBarContainerChild
* m_pChildWin
;
104 std::vector
< VclPtr
<SfxInfoBarWindow
> > m_pInfoBars
;
107 SfxInfoBarContainerWindow(SfxInfoBarContainerChild
* pChildWin
);
108 virtual ~SfxInfoBarContainerWindow( ) override
;
109 virtual void dispose() override
;
111 VclPtr
<SfxInfoBarWindow
> appendInfoBar(const OUString
& sId
,
112 const OUString
& sPrimaryMessage
,
113 const OUString
& sSecondaryMessage
,
115 WinBits nMessageStyle
,
116 bool bShowCloseButton
);
117 VclPtr
<SfxInfoBarWindow
> getInfoBar(const OUString
& sId
);
118 bool hasInfoBarWithID(const OUString
& sId
);
119 void removeInfoBar(VclPtr
<SfxInfoBarWindow
> const & pInfoBar
);
121 virtual void Resize() override
;
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */