diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2016-08-19 10:20:03 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-08-25 11:46:39 +0000 |
commit | 6488d249b0c5649313b6611660aca939e5c374bf (patch) | |
tree | 64646f153fd5ef2999dff69a51462dc72fd27369 /sfx2 | |
parent | b9ab0dd3e5eb3c948ee9a29006637e48d5751a5e (diff) |
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 <ci@libreoffice.org>
Tested-by: Yousuf Philips <philipz85@hotmail.com>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/Library_sfx.mk | 1 | ||||
-rw-r--r-- | sfx2/source/notebookbar/ContextVBox.cxx | 85 | ||||
-rw-r--r-- | sfx2/source/notebookbar/NotebookBarPopupMenu.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/notebookbar/SfxNotebookBar.cxx | 4 |
4 files changed, 89 insertions, 2 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 02956b1bb23e..a6220499ce05 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -241,6 +241,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/explorer/nochaos \ sfx2/source/inet/inettbc \ sfx2/source/notebookbar/BigToolBox \ + sfx2/source/notebookbar/ContextVBox \ sfx2/source/notebookbar/DropdownBox \ sfx2/source/notebookbar/NotebookBarPopupMenu \ sfx2/source/notebookbar/NotebookbarToolBox \ diff --git a/sfx2/source/notebookbar/ContextVBox.cxx b/sfx2/source/notebookbar/ContextVBox.cxx new file mode 100644 index 000000000000..3bbe14a1f3ea --- /dev/null +++ b/sfx2/source/notebookbar/ContextVBox.cxx @@ -0,0 +1,85 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <vcl/builderfactory.hxx> +#include <vcl/layout.hxx> +#include <sfx2/dllapi.h> +#include <sfx2/viewfrm.hxx> +#include <sfx2/notebookbar/NotebookbarContextControl.hxx> + +/* + * ContextVBox is a VclVBox which shows own childs depending on current context. + * This control can be used in the notebookbar .ui files + */ + +class SFX2_DLLPUBLIC ContextVBox : public VclVBox, + public NotebookbarContextControl +{ +public: + explicit ContextVBox( vcl::Window *pParent ) + : VclVBox( pParent ) + { + } + + virtual ~ContextVBox() override + { + disposeOnce(); + } + + virtual void dispose() override + { + VclVBox::dispose(); + } + + void SetContext( vcl::EnumContext::Context eContext ) override + { + for (int nChild = 0; nChild < GetChildCount(); ++nChild) + { + if ( GetChild( nChild )->GetType() == WINDOW_CONTAINER ) + { + VclContainer* pChild = static_cast<VclContainer*>( GetChild( nChild ) ); + + if ( pChild->HasContext( eContext ) || pChild->HasContext( vcl::EnumContext::Context::Context_Any ) ) + { + Size aSize( pChild->GetOptimalSize() ); + aSize.Height() += 6; + pChild->Show(); + pChild->SetSizePixel( aSize ); + } + else + { + pChild->Hide(); + pChild->SetSizePixel( Size( 0, 0 ) ); + } + } + } + Size aSize( GetOptimalSize() ); + aSize.Width() += 6; + SetSizePixel( aSize ); + } + + void SetIconClickHdl( Link<NotebookBar*, void> ) override + { + // Menu not supported + } +}; + +VCL_BUILDER_FACTORY(ContextVBox) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx b/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx index 72c4145133e2..9644b35a9462 100644 --- a/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx +++ b/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx @@ -15,6 +15,7 @@ #include <sfxlocal.hrc> #include <sfx2/sfxresid.hxx> #include "NotebookBarPopupMenu.hxx" +#include <vcl/tabctrl.hxx> using namespace sfx2; using namespace css::uno; diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index 64be63f50da0..41dac9c5c900 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -166,7 +166,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, pSysWindow->SetNotebookBar(aBuf.makeStringAndClear(), xFrame); pSysWindow->GetNotebookBar()->Show(); - pSysWindow->GetNotebookBar()->SetIconClickHdl(LINK(nullptr, SfxNotebookBar, ToggleMenubar)); + pSysWindow->GetNotebookBar()->SetIconClickHdl(LINK(nullptr, SfxNotebookBar, OpenNotebookbarPopupMenu)); SfxViewFrame* pView = SfxViewFrame::Current(); @@ -206,7 +206,7 @@ void SfxNotebookBar::RemoveListeners(SystemWindow* pSysWindow) } } -IMPL_STATIC_LINK_TYPED(SfxNotebookBar, ToggleMenubar, NotebookBar*, pNotebookbar, void) +IMPL_STATIC_LINK_TYPED(SfxNotebookBar, OpenNotebookbarPopupMenu, NotebookBar*, pNotebookbar, void) { if (pNotebookbar) { |