From 6488d249b0c5649313b6611660aca939e5c374bf Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Fri, 19 Aug 2016 10:20:03 +0200 Subject: GSoC notebookbar: container with context support + added sfxlo-ContextVBox + notebookbar's .ui file must contain control implementing NotebookbarContextControl interface with id "ContextContainer" Change-Id: Ice81e23c4ba742564ebceeda95be120ea3f58c99 Reviewed-on: https://gerrit.libreoffice.org/28247 Tested-by: Jenkins Tested-by: Yousuf Philips Reviewed-by: Samuel Mehrbrodt --- .../sfx2/notebookbar/NotebookbarContextControl.hxx | 27 +++++++++++ include/sfx2/notebookbar/SfxNotebookBar.hxx | 2 +- include/vcl/IContext.hxx | 54 ++++++++++++++++++++++ include/vcl/layout.hxx | 4 +- include/vcl/notebookbar.hxx | 4 +- include/vcl/tabctrl.hxx | 8 ++-- include/vcl/tabpage.hxx | 8 +--- 7 files changed, 94 insertions(+), 13 deletions(-) create mode 100644 include/sfx2/notebookbar/NotebookbarContextControl.hxx create mode 100644 include/vcl/IContext.hxx (limited to 'include') diff --git a/include/sfx2/notebookbar/NotebookbarContextControl.hxx b/include/sfx2/notebookbar/NotebookbarContextControl.hxx new file mode 100644 index 000000000000..348b52101df1 --- /dev/null +++ b/include/sfx2/notebookbar/NotebookbarContextControl.hxx @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SFX2_NOTEBOOKBAR_NOTEBOOKBARCONTEXTCONTROL_HXX +#define INCLUDED_SFX2_NOTEBOOKBAR_NOTEBOOKBARCONTEXTCONTROL_HXX + +#include + +class NotebookBar; + +class NotebookbarContextControl +{ +public: + virtual ~NotebookbarContextControl() {} + virtual void SetContext( vcl::EnumContext::Context eContext ) = 0; + virtual void SetIconClickHdl( Link aHdl ) = 0; +}; + +#endif // INCLUDED_SFX2_NOTEBOOKBAR_NOTEBOOKBARCONTEXTCONTROL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx b/include/sfx2/notebookbar/SfxNotebookBar.hxx index 67ee405fb355..e3735658d857 100644 --- a/include/sfx2/notebookbar/SfxNotebookBar.hxx +++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx @@ -46,7 +46,7 @@ private: static css::uno::Reference m_xLayoutManager; static css::uno::Reference m_xFrame; - DECL_STATIC_LINK_TYPED(SfxNotebookBar, ToggleMenubar, NotebookBar*, void); + DECL_STATIC_LINK_TYPED(SfxNotebookBar, OpenNotebookbarPopupMenu, NotebookBar*, void); }; } // namespace sfx2 diff --git a/include/vcl/IContext.hxx b/include/vcl/IContext.hxx new file mode 100644 index 000000000000..09f9722a4597 --- /dev/null +++ b/include/vcl/IContext.hxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_ICONTEXT_HXX +#define INCLUDED_VCL_ICONTEXT_HXX + +#include +#include + +namespace vcl +{ + +class VCL_DLLPUBLIC IContext +{ +protected: + IContext() + { + maContext.push_back( vcl::EnumContext::Context::Context_Any ); + } + +public: + void SetContext(const std::vector& aContext) + { + maContext = aContext; + } + + bool HasContext( const vcl::EnumContext::Context eContext ) const + { + auto aFind = std::find(maContext.begin(), maContext.end(), eContext); + if (aFind == maContext.end()) + return false; + return true; + } + + const std::vector< vcl::EnumContext::Context >& GetContext() const + { + return maContext; + } + +private: + std::vector maContext; +}; + +} // namespace vcl + +#endif // INCLUDED_VCL_ICONTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx index 02fcaad564e9..eb9d94fdb171 100644 --- a/include/vcl/layout.hxx +++ b/include/vcl/layout.hxx @@ -19,10 +19,12 @@ #include #include #include +#include #include class VCL_DLLPUBLIC VclContainer : public vcl::Window, - public vcl::IPrioritable + public vcl::IPrioritable, + public vcl::IContext { public: VclContainer(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN); diff --git a/include/vcl/notebookbar.hxx b/include/vcl/notebookbar.hxx index 51f32aab6d45..d2a279ffe3ad 100644 --- a/include/vcl/notebookbar.hxx +++ b/include/vcl/notebookbar.hxx @@ -12,8 +12,8 @@ #include #include -#include #include +#include #include /// This implements Widget Layout-based notebook-like menu bar. @@ -35,7 +35,7 @@ public: const css::uno::Reference& getContextChangeEventListener() const { return m_pEventListener; } private: css::uno::Reference m_pEventListener; - VclPtr m_pTabControl; + NotebookbarContextControl* m_pContextContainer; }; diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx index a79522a03586..b24e3dacf4e3 100644 --- a/include/vcl/tabctrl.hxx +++ b/include/vcl/tabctrl.hxx @@ -23,6 +23,7 @@ #include #include #include +#include struct ImplTabItem; struct ImplTabCtrlData; @@ -196,13 +197,14 @@ public: class NotebookBar; -class VCL_DLLPUBLIC NotebookbarTabControl : public TabControl +class VCL_DLLPUBLIC NotebookbarTabControl : public TabControl, + public NotebookbarContextControl { public: NotebookbarTabControl( vcl::Window* pParent ); - void SetContext( vcl::EnumContext::Context eContext ); - void SetIconClickHdl( Link aHdl ); + void SetContext( vcl::EnumContext::Context eContext ) override; + void SetIconClickHdl( Link aHdl ) override; virtual sal_uInt16 GetPageId( const Point& rPos ) const override; virtual void SelectTabPage( sal_uInt16 nPageId ) override; diff --git a/include/vcl/tabpage.hxx b/include/vcl/tabpage.hxx index 5a35901c4007..0ee6776cca6f 100644 --- a/include/vcl/tabpage.hxx +++ b/include/vcl/tabpage.hxx @@ -24,19 +24,19 @@ #include #include #include +#include class VCL_DLLPUBLIC TabPage : public vcl::Window , public VclBuilderContainer + , public vcl::IContext { private: using Window::ImplInit; SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); SAL_DLLPRIVATE void ImplInitSettings(); - std::vector maContext; - public: explicit TabPage( vcl::Window* pParent, WinBits nStyle = 0 ); explicit TabPage( vcl::Window *pParent, const OString& rID, const OUString& rUIXMLDescription ); @@ -59,10 +59,6 @@ public: virtual void SetPosPixel(const Point& rNewPos) override; virtual void SetSizePixel(const Size& rNewSize) override; virtual Size GetOptimalSize() const override; - - void SetContext( const std::vector& aContext ); - bool HasContext( const vcl::EnumContext::Context eContext ) const; - const std::vector& GetContext() const; }; #endif // INCLUDED_VCL_TABPAGE_HXX -- cgit