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 <basegfx/color/bcolor.hxx>
15 #include <vcl/button.hxx>
16 #include <vcl/fixed.hxx>
18 #include <sfx2/childwin.hxx>
19 #include <sfx2/dllapi.h>
21 // These must match the values in offapi/com/sun/star/frame/InfobarType.idl
22 enum class InfobarType
34 OUString msPrimaryMessage
;
35 OUString msSecondaryMessage
;
36 InfobarType maInfobarType
;
37 bool mbShowCloseButton
;
40 /** SfxChildWindow for positioning the InfoBar in the view.
42 class SFX2_DLLPUBLIC SfxInfoBarContainerChild final
: public SfxChildWindow
45 SfxBindings
* const m_pBindings
;
48 SfxInfoBarContainerChild(vcl::Window
* pParent
, sal_uInt16 nId
, SfxBindings
* pBindings
,
49 SfxChildWinInfo
* pInfo
);
50 virtual ~SfxInfoBarContainerChild() override
;
52 SFX_DECL_CHILDWINDOW_WITHID(SfxInfoBarContainerChild
);
57 /** Class representing a single InfoBar to be added in a SfxInfoBarContainerWindow.
59 class SFX2_DLLPUBLIC SfxInfoBarWindow final
: public vcl::Window
64 VclPtr
<FixedImage
> m_pImage
;
65 VclPtr
<FixedText
> m_pPrimaryMessage
;
66 VclPtr
<FixedText
> m_pSecondaryMessage
;
67 VclPtr
<Button
> m_pCloseBtn
;
68 std::vector
<VclPtr
<PushButton
>> m_aActionBtns
;
70 void SetForeAndBackgroundColors(InfobarType eType
);
73 SfxInfoBarWindow(vcl::Window
* parent
, const OUString
& sId
, const OUString
& sPrimaryMessage
,
74 const OUString
& sSecondaryMessage
, InfobarType InfobarType
,
75 bool bShowCloseButton
, WinBits nMessageStyle
);
76 virtual ~SfxInfoBarWindow() override
;
77 virtual void dispose() override
;
79 const OUString
& getId() const { return m_sId
; }
80 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
;
81 virtual void Resize() override
;
82 void Update(const OUString
& sPrimaryMessage
, const OUString
& sSecondaryMessage
,
84 basegfx::BColor m_aBackgroundColor
;
85 basegfx::BColor m_aForegroundColor
;
87 /** Add button to Infobar.
88 * Infobar takes ownership of the button so the button is
89 * destroyed when the infobar gets destroyed.
91 void addButton(PushButton
* pButton
);
94 DECL_LINK(CloseHandler
, Button
*, void);
97 class SfxInfoBarContainerWindow final
: public vcl::Window
100 SfxInfoBarContainerChild
* m_pChildWin
;
101 std::vector
<VclPtr
<SfxInfoBarWindow
>> m_pInfoBars
;
104 SfxInfoBarContainerWindow(SfxInfoBarContainerChild
* pChildWin
);
105 virtual ~SfxInfoBarContainerWindow() override
;
106 virtual void dispose() override
;
108 VclPtr
<SfxInfoBarWindow
> appendInfoBar(const OUString
& sId
, const OUString
& sPrimaryMessage
,
109 const OUString
& sSecondaryMessage
, InfobarType ibType
,
110 WinBits nMessageStyle
, bool bShowCloseButton
);
111 VclPtr
<SfxInfoBarWindow
> getInfoBar(const OUString
& sId
);
112 bool hasInfoBarWithID(const OUString
& sId
);
113 void removeInfoBar(VclPtr
<SfxInfoBarWindow
> const& pInfoBar
);
115 virtual void Resize() override
;
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */