LibreOffice Module sfx2 (master) 1
infobar.hxx
Go to the documentation of this file.
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#ifndef INCLUDED_SFX2_INFOBAR_HXX
10#define INCLUDED_SFX2_INFOBAR_HXX
11
12#include <vector>
13
15
16#include <sfx2/childwin.hxx>
17#include <sfx2/dllapi.h>
19
20// These must match the values in offapi/com/sun/star/frame/InfobarType.idl
21enum class InfobarType
22{
23 INFO = 0,
24 SUCCESS = 1,
25 WARNING = 2,
26 DANGER = 3
27};
28
30{
31public:
32 OUString msId;
37};
38
42{
43private:
45
46public:
47 SfxInfoBarContainerChild(vcl::Window* pParent, sal_uInt16 nId, SfxBindings* pBindings,
48 SfxChildWinInfo* pInfo);
49 virtual ~SfxInfoBarContainerChild() override;
50
52
53 void Update();
54};
55
56class ExtraButton;
57
61{
62private:
63 OUString m_sId;
68 std::unique_ptr<weld::Image> m_xImage;
69 std::unique_ptr<weld::Label> m_xPrimaryMessage;
70 std::unique_ptr<weld::TextView> m_xSecondaryMessage;
71 std::unique_ptr<weld::Container> m_xButtonBox;
72 std::unique_ptr<weld::Toolbar> m_xCloseBtn;
73 std::vector<std::unique_ptr<ExtraButton>> m_aActionBtns;
74
75 DECL_DLLPRIVATE_LINK(SizeAllocHdl, const Size&, void);
76
77 void SetForeAndBackgroundColors(InfobarType eType);
78 void SetCloseButtonImage();
79
80public:
81 SfxInfoBarWindow(vcl::Window* parent, OUString sId, const OUString& sPrimaryMessage,
82 const OUString& sSecondaryMessage, InfobarType InfobarType,
83 bool bShowCloseButton);
84 Size DoLayout();
85 virtual void Layout() override;
86 virtual ~SfxInfoBarWindow() override;
87 virtual void dispose() override;
88
89 const OUString& getId() const { return m_sId; }
90 void Update(const OUString& sPrimaryMessage, const OUString& sSecondaryMessage,
91 InfobarType eType);
94
102 weld::Button& addButton(const OUString* pCommand = nullptr);
103
104 void SetCommandHandler(weld::Button& rBtn, const OUString& aCommand);
105
106private:
107 DECL_DLLPRIVATE_LINK(CloseHandler, const OUString&, void);
108};
109
111{
112private:
114 std::vector<VclPtr<SfxInfoBarWindow>> m_pInfoBars;
117
118 DECL_LINK(DoUpdateLayout, Timer*, void);
119
120public:
122 virtual ~SfxInfoBarContainerWindow() override;
123 virtual void dispose() override;
124
125 VclPtr<SfxInfoBarWindow> appendInfoBar(const OUString& sId, const OUString& sPrimaryMessage,
126 const OUString& sSecondaryMessage, InfobarType ibType,
127 bool bShowCloseButton);
128 VclPtr<SfxInfoBarWindow> getInfoBar(std::u16string_view sId);
129 bool hasInfoBarWithID(std::u16string_view sId);
130 void removeInfoBar(VclPtr<SfxInfoBarWindow> const& pInfoBar);
131 static bool isInfobarEnabled(std::u16string_view sId);
132
133 void TriggerUpdateLayout();
134
135 virtual void Resize() override;
136};
137
138#endif
139
140/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString msId
Definition: infobar.hxx:32
OUString msPrimaryMessage
Definition: infobar.hxx:33
bool mbShowCloseButton
Definition: infobar.hxx:36
InfobarType maInfobarType
Definition: infobar.hxx:35
OUString msSecondaryMessage
Definition: infobar.hxx:34
SfxChildWindow for positioning the InfoBar in the view.
Definition: infobar.hxx:42
SfxBindings * m_pBindings
Definition: infobar.hxx:44
SFX_DECL_CHILDWINDOW_WITHID(SfxInfoBarContainerChild)
VclPtr< SfxInfoBarWindow > appendInfoBar(const OUString &sId, const OUString &sPrimaryMessage, const OUString &sSecondaryMessage, InfobarType ibType, bool bShowCloseButton)
Definition: infobar.cxx:371
std::vector< VclPtr< SfxInfoBarWindow > > m_pInfoBars
Definition: infobar.hxx:114
SfxInfoBarContainerWindow(SfxInfoBarContainerChild *pChildWin)
Definition: infobar.cxx:349
virtual ~SfxInfoBarContainerWindow() override
Definition: infobar.cxx:361
SfxInfoBarContainerChild * m_pChildWin
Definition: infobar.hxx:113
static bool isInfobarEnabled(std::u16string_view sId)
Definition: infobar.cxx:423
virtual void Resize() override
Definition: infobar.cxx:448
virtual void dispose() override
Definition: infobar.cxx:363
bool hasInfoBarWithID(std::u16string_view sId)
Definition: infobar.cxx:405
DECL_LINK(DoUpdateLayout, Timer *, void)
void removeInfoBar(VclPtr< SfxInfoBarWindow > const &pInfoBar)
Definition: infobar.cxx:410
VclPtr< SfxInfoBarWindow > getInfoBar(std::u16string_view sId)
Definition: infobar.cxx:395
Class representing a single InfoBar to be added in a SfxInfoBarContainerWindow.
Definition: infobar.hxx:61
std::unique_ptr< weld::Image > m_xImage
Definition: infobar.hxx:68
const OUString & getId() const
Definition: infobar.hxx:89
DECL_DLLPRIVATE_LINK(CloseHandler, const OUString &, void)
Size m_aMessageSize
Definition: infobar.hxx:65
std::unique_ptr< weld::TextView > m_xSecondaryMessage
Definition: infobar.hxx:70
OUString m_sId
Definition: infobar.hxx:63
DECL_DLLPRIVATE_LINK(SizeAllocHdl, const Size &, void)
Size m_aOrigMessageSize
Definition: infobar.hxx:66
std::unique_ptr< weld::Toolbar > m_xCloseBtn
Definition: infobar.hxx:72
InfobarType m_eType
Definition: infobar.hxx:64
void SetCommandHandler(weld::Button &rBtn, const OUString &aCommand)
basegfx::BColor m_aForegroundColor
Definition: infobar.hxx:93
std::unique_ptr< weld::Label > m_xPrimaryMessage
Definition: infobar.hxx:69
std::vector< std::unique_ptr< ExtraButton > > m_aActionBtns
Definition: infobar.hxx:73
std::unique_ptr< weld::Container > m_xButtonBox
Definition: infobar.hxx:71
basegfx::BColor m_aBackgroundColor
Definition: infobar.hxx:92
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
InfobarType
Definition: infobar.hxx:22
Layout
void dispose()