summaryrefslogtreecommitdiff
path: root/include/sfx2/infobar.hxx
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-11-18 09:08:03 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-11-22 14:29:04 +0100
commitfa070a798536d4017baada1e8f036b0e18dad9c7 (patch)
tree3e34754fb883a8d46cc8e42e8c0f494f5a26f977 /include/sfx2/infobar.hxx
parent54239c99b7f9d82ec14492aff29e450abdafc61d (diff)
tdf#97926 Add UNO API for Infobar
This allows creating, updating and removing infobars from macros/extensions. It also extends the infobar with a primary and a secondary text, so there can be a bold summary at the beginning at the infobar with a longer text following in normal letters. Macro sample: ------------------------------------------------------------ Sub AddInfobar dim buttons(1) as new com.sun.star.beans.StringPair buttons(0).first = "Close doc" buttons(0).second = ".uno:CloseDoc" buttons(1).first = "Paste into doc" buttons(1).second = ".uno:Paste" ThisComponent.getCurrentController().appendInfobar("my", "Hello world", "Things happened. What now?", com.sun.star.frame.InfobarType.INFO, buttons, true) End Sub Sub UpdateInfobar ThisComponent.getCurrentController().updateInfobar("my", "WARNING","Do not read this message.", com.sun.star.frame.InfobarType.WARNING) End Sub Sub RemoveInfobar ThisComponent.getCurrentController().removeInfobar("my") End Sub ------------------------------------------------------------ Change-Id: I5d0a223525845d23ffab17acdaa431e0eb783fec Reviewed-on: https://gerrit.libreoffice.org/29816 Reviewed-by: Serge Krot (CIB) <Serge.Krot@cib.de> Tested-by: Serge Krot (CIB) <Serge.Krot@cib.de> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> (cherry picked from commit 9e3ba7c3036c4d21e01d6f75ed29a1e8c4208141) Reviewed-on: https://gerrit.libreoffice.org/83405 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'include/sfx2/infobar.hxx')
-rw-r--r--include/sfx2/infobar.hxx38
1 files changed, 22 insertions, 16 deletions
diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx
index 4543189c0373..a0dcdbd00f1d 100644
--- a/include/sfx2/infobar.hxx
+++ b/include/sfx2/infobar.hxx
@@ -18,11 +18,12 @@
#include <sfx2/dllapi.h>
#include <sfx2/childwin.hxx>
-enum class InfoBarType {
- Info,
- Success,
- Warning,
- Danger
+// These must match the values in offapi/com/sun/star/frame/InfobarType.idl
+enum class InfobarType {
+ INFO = 0,
+ SUCCESS = 1,
+ WARNING = 2,
+ DANGER = 3
};
/** SfxChildWindow for positioning the InfoBar in the view.
@@ -50,27 +51,30 @@ class SFX2_DLLPUBLIC SfxInfoBarWindow final : public vcl::Window
{
private:
OUString const m_sId;
- InfoBarType m_eType;
+ InfobarType m_eType;
VclPtr<FixedImage> m_pImage;
- VclPtr<FixedText> m_pMessage;
+ VclPtr<FixedText> m_pPrimaryMessage;
+ VclPtr<FixedText> m_pSecondaryMessage;
VclPtr<Button> m_pCloseBtn;
std::vector< VclPtr<PushButton> > m_aActionBtns;
- void SetForeAndBackgroundColors( InfoBarType eType );
+ void SetForeAndBackgroundColors( InfobarType eType );
public:
SfxInfoBarWindow( vcl::Window* parent, const OUString& sId,
- const OUString& sMessage,
- InfoBarType infoBarType,
- WinBits nMessageStyle);
+ const OUString& sPrimaryMessage,
+ const OUString& sSecondaryMessage,
+ InfobarType InfobarType,
+ bool bShowCloseButton, WinBits nMessageStyle);
virtual ~SfxInfoBarWindow( ) override;
virtual void dispose() override;
const OUString& getId() const { return m_sId; }
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
virtual void Resize( ) override;
- void Update( const OUString& sNewMessage, InfoBarType eType );
- basegfx::BColor m_aBackgroundColor;
+ void Update(const OUString& sPrimaryMessage, const OUString& sSecondaryMessage,
+ InfobarType eType);
+ basegfx::BColor m_aBackgroundColor;
basegfx::BColor m_aForegroundColor;
/** Add button to Infobar.
@@ -95,9 +99,11 @@ class SfxInfoBarContainerWindow final : public vcl::Window
virtual void dispose() override;
VclPtr<SfxInfoBarWindow> appendInfoBar(const OUString& sId,
- const OUString& sMessage,
- InfoBarType ibType,
- WinBits nMessageStyle);
+ const OUString& sPrimaryMessage,
+ const OUString& sSecondaryMessage,
+ InfobarType ibType,
+ WinBits nMessageStyle,
+ bool bShowCloseButton);
VclPtr<SfxInfoBarWindow> getInfoBar(const OUString& sId);
bool hasInfoBarWithID(const OUString& sId);
void removeInfoBar(VclPtr<SfxInfoBarWindow> const & pInfoBar);