summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-12-07 11:18:33 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-12-07 21:05:06 +0100
commit35b5f03e41e21085b67b56e29c52dcddc9a36c30 (patch)
treefdd93138f52d9f2f83a02fb3f54f50f23eb8732f /sfx2
parenta91e21b9acab16bd31dbefa4640d2e5f3c3c7d63 (diff)
move various notebookbar widgets into vcl
and we can drop their factories then Change-Id: I1e261886dd7700710ba628da4bbeeba65efa1531 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107134 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/Library_sfx.mk5
-rw-r--r--sfx2/inc/pch/precompiled_sfx.hxx4
-rw-r--r--sfx2/source/notebookbar/ContextVBox.cxx76
-rw-r--r--sfx2/source/notebookbar/DropdownBox.cxx119
-rw-r--r--sfx2/source/notebookbar/DropdownBox.hxx49
-rw-r--r--sfx2/source/notebookbar/NotebookbarPopup.cxx159
-rw-r--r--sfx2/source/notebookbar/NotebookbarPopup.hxx57
-rw-r--r--sfx2/source/notebookbar/NotebookbarTabControl.cxx2
-rw-r--r--sfx2/source/notebookbar/PriorityHBox.cxx200
-rw-r--r--sfx2/source/notebookbar/PriorityHBox.hxx63
-rw-r--r--sfx2/source/notebookbar/PriorityMergedHBox.cxx213
-rw-r--r--sfx2/source/notebookbar/SfxNotebookBar.cxx4
12 files changed, 5 insertions, 946 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 3f1b76ecd80f..4673541ec989 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -241,12 +241,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/doc/saveastemplatedlg \
sfx2/source/explorer/nochaos \
sfx2/source/inet/inettbc \
- sfx2/source/notebookbar/ContextVBox \
- sfx2/source/notebookbar/DropdownBox \
- sfx2/source/notebookbar/PriorityHBox \
- sfx2/source/notebookbar/PriorityMergedHBox \
sfx2/source/notebookbar/SfxNotebookBar \
- sfx2/source/notebookbar/NotebookbarPopup \
sfx2/source/notebookbar/NotebookbarTabControl \
sfx2/source/notify/eventsupplier \
sfx2/source/notify/globalevents \
diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx
index f3e5ecb809aa..77a97600c3c3 100644
--- a/sfx2/inc/pch/precompiled_sfx.hxx
+++ b/sfx2/inc/pch/precompiled_sfx.hxx
@@ -13,7 +13,7 @@
manual changes will be rewritten by the next run of update_pch.sh (which presumably
also fixes all possible problems, so it's usually better to use it).
- Generated on 2020-12-04 09:59:39 using:
+ Generated on 2020-12-07 11:30:59 using:
./bin/update_pch sfx2 sfx --cutoff=3 --exclude:system --exclude:module --exclude:local
If after updating build fails, use the following command to locate conflicting headers:
@@ -93,7 +93,7 @@
#include <vcl/Scanline.hxx>
#include <vcl/alpha.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/builderfactory.hxx>
+#include <vcl/builder.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/ctrl.hxx>
diff --git a/sfx2/source/notebookbar/ContextVBox.cxx b/sfx2/source/notebookbar/ContextVBox.cxx
deleted file mode 100644
index b1494340fdc8..000000000000
--- a/sfx2/source/notebookbar/ContextVBox.cxx
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- 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 <sal/config.h>
-
-#include <vcl/NotebookbarContextControl.hxx>
-#include <vcl/builderfactory.hxx>
-#include <vcl/layout.hxx>
-#include <sfx2/dllapi.h>
-
-/*
- * ContextVBox is a VclVBox which shows own children 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();
- }
-
- void SetContext( vcl::EnumContext::Context eContext ) override
- {
- for (int nChild = 0; nChild < GetChildCount(); ++nChild)
- {
- if ( GetChild( nChild )->GetType() == WindowType::CONTAINER )
- {
- VclContainer* pChild = static_cast<VclContainer*>( GetChild( nChild ) );
-
- if ( pChild->HasContext( eContext ) || pChild->HasContext( vcl::EnumContext::Context::Any ) )
- {
- Size aSize( pChild->GetOptimalSize() );
- aSize.AdjustHeight(6 );
- pChild->Show();
- pChild->SetSizePixel( aSize );
- }
- else
- {
- pChild->Hide();
- pChild->SetSizePixel( Size( 0, 0 ) );
- }
- }
- }
- Size aSize( GetOptimalSize() );
- aSize.AdjustWidth(6 );
- SetSizePixel( aSize );
- }
-};
-
-VCL_BUILDER_FACTORY(ContextVBox)
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/DropdownBox.cxx b/sfx2/source/notebookbar/DropdownBox.cxx
deleted file mode 100644
index 315c30a2f95d..000000000000
--- a/sfx2/source/notebookbar/DropdownBox.cxx
+++ /dev/null
@@ -1,119 +0,0 @@
-/* -*- 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/button.hxx>
-#include <vcl/layout.hxx>
-#include "DropdownBox.hxx"
-
-#define NOTEBOOK_HEADER_HEIGHT 30
-
-/*
- * DropdownBox - shows content or moves it to the popup
- * which can be opened by clicking on a button
- */
-
-DropdownBox::DropdownBox(vcl::Window* pParent)
- : VclHBox(pParent)
- , IPrioritable()
- , m_bInFullView(true)
-{
- m_pButton = VclPtr<PushButton>::Create(this, WB_FLATBUTTON);
- m_pButton->SetClickHdl(LINK(this, DropdownBox, PBClickHdl));
- m_pButton->SetSymbol(SymbolType::MENU);
- m_pButton->set_width_request(15);
- m_pButton->SetQuickHelpText(GetQuickHelpText());
- m_pButton->Resize();
-}
-
-DropdownBox::~DropdownBox() { disposeOnce(); }
-
-void DropdownBox::dispose()
-{
- m_pButton.disposeAndClear();
- if (m_pPopup)
- m_pPopup.disposeAndClear();
-
- VclHBox::dispose();
-}
-
-void DropdownBox::HideContent()
-{
- if (m_bInFullView)
- {
- m_bInFullView = false;
-
- for (int i = 0; i < GetChildCount(); i++)
- GetChild(i)->Hide();
-
- m_pButton->Show();
- SetOutputSizePixel(Size(m_pButton->GetSizePixel().Width(), GetSizePixel().Height()));
- }
-}
-
-bool DropdownBox::IsHidden() { return !m_bInFullView; }
-
-void DropdownBox::ShowContent()
-{
- if (!m_bInFullView)
- {
- m_bInFullView = true;
-
- for (int i = 0; i < GetChildCount(); i++)
- GetChild(i)->Show();
-
- m_pButton->Hide();
- }
-}
-
-IMPL_LINK(DropdownBox, PBClickHdl, Button*, /*pButton*/, void)
-{
- if (m_pPopup)
- m_pPopup.disposeAndClear();
-
- m_pPopup = VclPtr<NotebookbarPopup>::Create(this);
-
- for (int i = 0; i < GetChildCount(); i++)
- {
- if (GetChild(i) != m_pButton)
- {
- Window* pChild = GetChild(i);
- pChild->Show();
-
- pChild->SetParent(m_pPopup->getBox());
- // count is decreased because we moved child
- i--;
- }
- }
-
- m_pPopup->hideSeparators(true);
-
- m_pPopup->getBox()->set_height_request(GetSizePixel().Height());
-
- tools::Long x = GetPosPixel().getX();
- tools::Long y = GetPosPixel().getY() + NOTEBOOK_HEADER_HEIGHT + GetSizePixel().Height();
- tools::Rectangle aRect(x, y, x, y);
-
- m_pPopup->StartPopupMode(aRect, FloatWinPopupFlags::Down | FloatWinPopupFlags::GrabFocus
- | FloatWinPopupFlags::AllMouseButtonClose);
-}
-
-VCL_BUILDER_FACTORY(DropdownBox)
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/DropdownBox.hxx b/sfx2/source/notebookbar/DropdownBox.hxx
deleted file mode 100644
index 769cd2e42fae..000000000000
--- a/sfx2/source/notebookbar/DropdownBox.hxx
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- 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 .
- */
-
-#ifndef INCLUDED_SFX2_NOTEBOOKBAR_DROPDOWNBOX_HXX
-#define INCLUDED_SFX2_NOTEBOOKBAR_DROPDOWNBOX_HXX
-
-#include <vcl/IPrioritable.hxx>
-#include <vcl/layout.hxx>
-#include "NotebookbarPopup.hxx"
-
-class DropdownBox : public VclHBox, public vcl::IPrioritable
-{
-private:
- bool m_bInFullView;
- VclPtr<PushButton> m_pButton;
- VclPtr<NotebookbarPopup> m_pPopup;
-
-public:
- explicit DropdownBox(vcl::Window* pParent);
- virtual ~DropdownBox() override;
- virtual void dispose() override;
-
- void HideContent() override;
- void ShowContent() override;
- bool IsHidden() override;
-
-private:
- DECL_LINK(PBClickHdl, Button*, void);
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/NotebookbarPopup.cxx b/sfx2/source/notebookbar/NotebookbarPopup.cxx
deleted file mode 100644
index cba325a43c56..000000000000
--- a/sfx2/source/notebookbar/NotebookbarPopup.cxx
+++ /dev/null
@@ -1,159 +0,0 @@
-/* -*- 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/.
- */
-
-#include "NotebookbarPopup.hxx"
-#include <vcl/IPrioritable.hxx>
-#include <vcl/layout.hxx>
-
-NotebookbarPopup::NotebookbarPopup(const VclPtr<VclHBox>& pParent)
- : FloatingWindow(pParent, "Popup", "sfx/ui/notebookbarpopup.ui")
- , m_pParent(pParent)
-{
- get(m_pBox, "box");
- m_pBox->SetSizePixel(Size(100, 75));
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- const BitmapEx& aPersona = rStyleSettings.GetPersonaHeader();
-
- if (!aPersona.IsEmpty())
- m_pBox->SetBackground(Wallpaper(aPersona));
- else
- m_pBox->SetBackground(rStyleSettings.GetDialogColor());
-}
-
-NotebookbarPopup::~NotebookbarPopup() { disposeOnce(); }
-
-VclHBox* NotebookbarPopup::getBox() { return m_pBox.get(); }
-
-void NotebookbarPopup::PopupModeEnd()
-{
- hideSeparators(false);
- while (m_pBox->GetChildCount())
- {
- vcl::IPrioritable* pChild = dynamic_cast<vcl::IPrioritable*>(GetChild(0));
- if (pChild)
- pChild->HideContent();
-
- vcl::Window* pWindow = m_pBox->GetChild(0);
- pWindow->SetParent(m_pParent);
-
- // resize after all children of box are empty
- if (m_pParent && !m_pBox->GetChildCount())
- m_pParent->Resize();
- }
-
- FloatingWindow::PopupModeEnd();
-}
-
-void NotebookbarPopup::hideSeparators(bool bHide)
-{
- // separator on the beginning
- vcl::Window* pWindow = m_pBox->GetChild(0);
- while (pWindow && pWindow->GetType() == WindowType::CONTAINER)
- {
- pWindow = pWindow->GetChild(0);
- }
- if (pWindow && pWindow->GetType() == WindowType::FIXEDLINE)
- {
- if (bHide)
- pWindow->Hide();
- else
- pWindow->Show();
- }
-
- // separator on the end
- pWindow = m_pBox->GetChild(m_pBox->GetChildCount() - 1);
- while (pWindow && pWindow->GetType() == WindowType::CONTAINER)
- {
- pWindow = pWindow->GetChild(pWindow->GetChildCount() - 1);
- }
- if (pWindow && pWindow->GetType() == WindowType::FIXEDLINE)
- {
- if (bHide)
- pWindow->Hide();
- else
- pWindow->Show();
- }
-
- if (bHide)
- {
- sal_Int32 BoxId = 0;
- while (BoxId <= m_pBox->GetChildCount() - 1)
- {
- if (m_pBox->GetChild(BoxId))
- {
- pWindow = m_pBox->GetChild(BoxId);
- ApplyBackground(pWindow);
- }
- BoxId++;
- }
- }
- else
- {
- sal_Int32 BoxId = m_pBox->GetChildCount() - 1;
- while (BoxId >= 0)
- {
- if (m_pBox->GetChild(BoxId))
- {
- pWindow = m_pBox->GetChild(BoxId);
- RemoveBackground(pWindow);
- }
- BoxId--;
- }
- }
-}
-
-void NotebookbarPopup::dispose()
-{
- PopupModeEnd();
- m_pBox.disposeAndClear();
- m_pParent.clear();
-
- FloatingWindow::dispose();
-}
-
-void NotebookbarPopup::ApplyBackground(vcl::Window* pWindow)
-{
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- const BitmapEx& aPersona = rStyleSettings.GetPersonaHeader();
-
- if (!aPersona.IsEmpty())
- pWindow->SetBackground(Wallpaper(aPersona));
- else
- pWindow->SetBackground(rStyleSettings.GetDialogColor());
-
- sal_Int32 nNext = 0;
- VclPtr<vcl::Window> pChild = pWindow->GetChild(nNext);
- while (pChild && pWindow->GetType() == WindowType::CONTAINER)
- {
- ApplyBackground(pChild);
- nNext++;
- if (pWindow->GetChild(nNext) && pWindow->GetType() == WindowType::CONTAINER)
- pChild = pWindow->GetChild(nNext);
- else
- break;
- }
-}
-
-void NotebookbarPopup::RemoveBackground(vcl::Window* pWindow)
-{
- pWindow->SetBackground(Wallpaper(COL_TRANSPARENT));
-
- sal_Int32 nNext = 0;
- VclPtr<vcl::Window> pChild = pWindow->GetChild(nNext);
- while (pChild && pWindow->GetType() == WindowType::CONTAINER)
- {
- RemoveBackground(pChild);
- nNext++;
- if (pWindow->GetChild(nNext) && pWindow->GetType() == WindowType::CONTAINER)
- pChild = pWindow->GetChild(nNext);
- else
- break;
- }
-}
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/NotebookbarPopup.hxx b/sfx2/source/notebookbar/NotebookbarPopup.hxx
deleted file mode 100644
index c417a75f4328..000000000000
--- a/sfx2/source/notebookbar/NotebookbarPopup.hxx
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- 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 .
- */
-
-#ifndef INCLUDED_SFX2_NOTEBOOKBAR_NOTEBOOKBARPOPUP_HXX
-#define INCLUDED_SFX2_NOTEBOOKBAR_NOTEBOOKBARPOPUP_HXX
-
-#include <vcl/layout.hxx>
-#include <vcl/floatwin.hxx>
-
-/*
- * Popup - shows hidden content, controls are moved to this popup
- * and after close moved to the original parent
- */
-
-class NotebookbarPopup : public FloatingWindow
-{
-private:
- VclPtr<VclHBox> m_pBox;
- ScopedVclPtr<VclHBox> m_pParent;
-
-public:
- explicit NotebookbarPopup(const VclPtr<VclHBox>& pParent);
-
- virtual ~NotebookbarPopup() override;
-
- VclHBox* getBox();
-
- virtual void PopupModeEnd() override;
-
- void hideSeparators(bool bHide);
-
- void dispose() override;
-
- void ApplyBackground(vcl::Window* pWindow);
-
- void RemoveBackground(vcl::Window* pWindow);
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/NotebookbarTabControl.cxx b/sfx2/source/notebookbar/NotebookbarTabControl.cxx
index a8362087a263..8a637ae1af48 100644
--- a/sfx2/source/notebookbar/NotebookbarTabControl.cxx
+++ b/sfx2/source/notebookbar/NotebookbarTabControl.cxx
@@ -19,7 +19,7 @@
#include <vcl/builderfactory.hxx>
#include <vcl/layout.hxx>
-#include <vcl/notebookbar.hxx>
+#include <vcl/notebookbar/notebookbar.hxx>
#include <vcl/tabpage.hxx>
#include <sfx2/viewfrm.hxx>
#include <notebookbar/NotebookbarTabControl.hxx>
diff --git a/sfx2/source/notebookbar/PriorityHBox.cxx b/sfx2/source/notebookbar/PriorityHBox.cxx
deleted file mode 100644
index 5851e51cdaf4..000000000000
--- a/sfx2/source/notebookbar/PriorityHBox.cxx
+++ /dev/null
@@ -1,200 +0,0 @@
-/* -*- 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 "PriorityHBox.hxx"
-#include <comphelper/lok.hxx>
-
-namespace
-{
-bool lcl_comparePriority(const vcl::IPrioritable* a, const vcl::IPrioritable* b)
-{
- return a->GetPriority() < b->GetPriority();
-}
-}
-
-PriorityHBox::PriorityHBox(vcl::Window* pParent)
- : VclHBox(pParent)
- , m_bInitialized(false)
-{
-}
-
-PriorityHBox::~PriorityHBox() { disposeOnce(); }
-
-void PriorityHBox::Initialize()
-{
- m_bInitialized = true;
-
- GetChildrenWithPriorities();
- SetSizeFromParent();
-}
-
-int PriorityHBox::GetHiddenCount() const
-{
- int nCount = 0;
-
- for (auto pWindow : m_aSortedChildren)
- if (pWindow->IsHidden())
- nCount++;
-
- return nCount;
-}
-
-void PriorityHBox::SetSizeFromParent()
-{
- vcl::Window* pParent = GetParent();
- if (pParent)
- {
- Size aParentSize = pParent->GetSizePixel();
- SetSizePixel(Size(aParentSize.getWidth(), aParentSize.getHeight()));
- }
-}
-
-Size PriorityHBox::calculateRequisition() const
-{
- if (!m_bInitialized)
- {
- return VclHBox::calculateRequisition();
- }
-
- sal_uInt16 nVisibleChildren = 0;
-
- Size aSize;
- for (vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); pChild;
- pChild = pChild->GetWindow(GetWindowType::Next))
- {
- if (!pChild->IsVisible())
- continue;
- ++nVisibleChildren;
- Size aChildSize = getLayoutRequisition(*pChild);
-
- bool bAlwaysExpanded = true;
-
- vcl::IPrioritable* pPrioritable = dynamic_cast<vcl::IPrioritable*>(pChild);
- if (pPrioritable && pPrioritable->GetPriority() != VCL_PRIORITY_DEFAULT)
- bAlwaysExpanded = false;
-
- if (bAlwaysExpanded)
- {
- tools::Long nPrimaryDimension = getPrimaryDimension(aChildSize);
- nPrimaryDimension += pChild->get_padding() * 2;
- setPrimaryDimension(aChildSize, nPrimaryDimension);
- }
- else
- setPrimaryDimension(aChildSize, 0);
-
- accumulateMaxes(aChildSize, aSize);
- }
-
- return finalizeMaxes(aSize, nVisibleChildren);
-}
-
-void PriorityHBox::Resize()
-{
- if (!m_bInitialized)
- Initialize();
-
- if (!m_bInitialized || comphelper::LibreOfficeKit::isActive())
- {
- return VclHBox::Resize();
- }
-
- tools::Long nWidth = GetSizePixel().Width();
- tools::Long nCurrentWidth = VclHBox::calculateRequisition().getWidth();
-
- // Hide lower priority controls
- for (vcl::IPrioritable* pPrioritable : m_aSortedChildren)
- {
- if (nCurrentWidth <= nWidth)
- break;
-
- vcl::Window* pWindow = dynamic_cast<vcl::Window*>(pPrioritable);
-
- if (pWindow && pWindow->GetParent() == this)
- {
- nCurrentWidth -= pWindow->GetOutputWidthPixel() + get_spacing();
- pWindow->Show();
- pPrioritable->HideContent();
- nCurrentWidth += pWindow->GetOutputWidthPixel() + get_spacing();
- }
- }
-
- auto pChildR = m_aSortedChildren.rbegin();
- // Show higher priority controls if we already have enough space
- while (pChildR != m_aSortedChildren.rend())
- {
- vcl::Window* pWindow = dynamic_cast<vcl::Window*>(*pChildR);
- vcl::IPrioritable* pPrioritable = *pChildR;
-
- if (pWindow->GetParent() != this)
- {
- pChildR++;
- continue;
- }
-
- if (pWindow)
- {
- nCurrentWidth -= pWindow->GetOutputWidthPixel() + get_spacing();
- pWindow->Show();
- pPrioritable->ShowContent();
- nCurrentWidth += getLayoutRequisition(*pWindow).Width() + get_spacing();
-
- if (nCurrentWidth > nWidth)
- {
- pPrioritable->HideContent();
- break;
- }
- }
-
- pChildR++;
- }
-
- VclHBox::Resize();
-}
-
-void PriorityHBox::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
-{
- if (!m_bInitialized)
- Initialize();
-
- VclHBox::Paint(rRenderContext, rRect);
-}
-
-void PriorityHBox::GetChildrenWithPriorities()
-{
- for (sal_uInt16 i = 0; i < GetChildCount(); ++i)
- {
- vcl::Window* pChild = GetChild(i);
-
- // Add only containers which have explicitly assigned priority.
- vcl::IPrioritable* pPrioritable = dynamic_cast<vcl::IPrioritable*>(pChild);
- if (pPrioritable && pPrioritable->GetPriority() != VCL_PRIORITY_DEFAULT)
- m_aSortedChildren.push_back(pPrioritable);
- }
-
- if (m_aSortedChildren.empty())
- m_bInitialized = false;
-
- std::sort(m_aSortedChildren.begin(), m_aSortedChildren.end(), lcl_comparePriority);
-}
-
-VCL_BUILDER_FACTORY(PriorityHBox)
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/PriorityHBox.hxx b/sfx2/source/notebookbar/PriorityHBox.hxx
deleted file mode 100644
index 7e797327642e..000000000000
--- a/sfx2/source/notebookbar/PriorityHBox.hxx
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- 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/IPrioritable.hxx>
-#include <vcl/layout.hxx>
-
-#include <vector>
-
-#ifndef INCLUDED_SFX2_NOTEBOOKBAR_PRIORITYHBOX_HXX
-#define INCLUDED_SFX2_NOTEBOOKBAR_PRIORITYHBOX_HXX
-
-/*
- * PriorityHBox is a VclHBox which hides its own children if there is no sufficient space.
- * Hiding order can be modified using child's priorities. If a control have default
- * priority assigned (VCL_PRIORITY_DEFAULT), it is always shown.
- */
-
-class PriorityHBox : public VclHBox
-{
-protected:
- bool m_bInitialized;
-
- std::vector<vcl::IPrioritable*> m_aSortedChildren;
-
- virtual int GetHiddenCount() const;
-
- virtual void GetChildrenWithPriorities();
-
-public:
- explicit PriorityHBox(vcl::Window* pParent);
-
- virtual ~PriorityHBox() override;
-
- void Initialize();
-
- void SetSizeFromParent();
-
- virtual Size calculateRequisition() const override;
-
- virtual void Resize() override;
-
- virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/PriorityMergedHBox.cxx b/sfx2/source/notebookbar/PriorityMergedHBox.cxx
deleted file mode 100644
index bb4e00b0fe52..000000000000
--- a/sfx2/source/notebookbar/PriorityMergedHBox.cxx
+++ /dev/null
@@ -1,213 +0,0 @@
-/* -*- 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/button.hxx>
-#include <vcl/layout.hxx>
-#include <bitmaps.hlst>
-#include "PriorityHBox.hxx"
-#include "NotebookbarPopup.hxx"
-#include <comphelper/lok.hxx>
-
-#define DUMMY_WIDTH 50
-#define BUTTON_WIDTH 30
-
-/*
-* PriorityMergedHBox is a VclHBox which hides its own children if there is no sufficient space.
-*/
-
-namespace
-{
-class PriorityMergedHBox : public PriorityHBox
-{
-private:
- VclPtr<PushButton> m_pButton;
- VclPtr<NotebookbarPopup> m_pPopup;
-
- DECL_LINK(PBClickHdl, Button*, void);
-
-public:
- explicit PriorityMergedHBox(vcl::Window* pParent)
- : PriorityHBox(pParent)
- {
- m_pButton = VclPtr<PushButton>::Create(this, WB_FLATBUTTON);
- m_pButton->SetClickHdl(LINK(this, PriorityMergedHBox, PBClickHdl));
- m_pButton->SetModeImage(Image(StockImage::Yes, CHEVRON));
- m_pButton->set_width_request(25);
- m_pButton->set_pack_type(VclPackType::End);
- m_pButton->Show();
- }
-
- virtual ~PriorityMergedHBox() override { disposeOnce(); }
-
- virtual void Resize() override
- {
- if (comphelper::LibreOfficeKit::isActive())
- return VclHBox::Resize();
-
- if (!m_bInitialized)
- Initialize();
-
- if (!m_bInitialized)
- {
- return VclHBox::Resize();
- }
-
- tools::Long nWidth = GetSizePixel().Width();
- tools::Long nCurrentWidth = VclHBox::calculateRequisition().getWidth() + BUTTON_WIDTH;
-
- // Hide lower priority controls
- for (int i = GetChildCount() - 1; i >= 0; i--)
- {
- vcl::Window* pWindow = GetChild(i);
-
- if (nCurrentWidth <= nWidth)
- break;
-
- if (pWindow && pWindow->GetParent() == this && pWindow->IsVisible())
- {
- if (pWindow->GetOutputWidthPixel())
- nCurrentWidth -= pWindow->GetOutputWidthPixel();
- else
- nCurrentWidth -= DUMMY_WIDTH;
- pWindow->Hide();
- }
- }
-
- // Show higher priority controls if we already have enough space
- for (int i = 0; i < GetChildCount(); i++)
- {
- vcl::Window* pWindow = GetChild(i);
-
- if (pWindow->GetParent() != this)
- {
- continue;
- }
-
- if (pWindow && !pWindow->IsVisible())
- {
- pWindow->Show();
- nCurrentWidth += getLayoutRequisition(*pWindow).Width() + get_spacing();
-
- if (nCurrentWidth > nWidth)
- {
- pWindow->Hide();
- break;
- }
- }
- }
-
- VclHBox::Resize();
-
- if (GetHiddenCount())
- m_pButton->Show();
- else
- m_pButton->Hide();
- }
-
- virtual void dispose() override
- {
- m_pButton.disposeAndClear();
- if (m_pPopup)
- m_pPopup.disposeAndClear();
- PriorityHBox::dispose();
- }
-
- int GetHiddenCount() const override
- {
- int nCount = 0;
-
- for (int i = GetChildCount() - 1; i >= 0; i--)
- {
- vcl::Window* pWindow = GetChild(i);
- if (pWindow && pWindow->GetParent() == this && !pWindow->IsVisible())
- nCount++;
- }
-
- return nCount;
- }
-
- Size calculateRequisition() const override
- {
- if (!m_bInitialized)
- {
- return VclHBox::calculateRequisition();
- }
-
- sal_uInt16 nVisibleChildren = 0;
-
- Size aSize;
- for (vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); pChild;
- pChild = pChild->GetWindow(GetWindowType::Next))
- {
- if (!pChild->IsVisible())
- continue;
- ++nVisibleChildren;
- Size aChildSize = getLayoutRequisition(*pChild);
-
- tools::Long nPrimaryDimension = getPrimaryDimension(aChildSize);
- nPrimaryDimension += pChild->get_padding() * 2;
- setPrimaryDimension(aChildSize, nPrimaryDimension);
-
- accumulateMaxes(aChildSize, aSize);
- }
-
- setPrimaryDimension(aSize, 200);
- return finalizeMaxes(aSize, nVisibleChildren);
- }
-
- void GetChildrenWithPriorities() override{};
-};
-}
-
-IMPL_LINK(PriorityMergedHBox, PBClickHdl, Button*, /*pButton*/, void)
-{
- if (m_pPopup)
- m_pPopup.disposeAndClear();
-
- m_pPopup = VclPtr<NotebookbarPopup>::Create(this);
-
- for (int i = 0; i < GetChildCount(); i++)
- {
- vcl::Window* pWindow = GetChild(i);
- if (pWindow != m_pButton)
- {
- if (!pWindow->IsVisible())
- {
- pWindow->Show();
- pWindow->SetParent(m_pPopup->getBox());
- // count is decreased because we moved child
- i--;
- }
- }
- }
-
- m_pPopup->hideSeparators(true);
-
- tools::Long x = m_pButton->GetPosPixel().getX();
- tools::Long y = m_pButton->GetPosPixel().getY() + GetSizePixel().Height();
- tools::Rectangle aRect(x, y, x, y);
-
- m_pPopup->StartPopupMode(aRect, FloatWinPopupFlags::Down | FloatWinPopupFlags::GrabFocus
- | FloatWinPopupFlags::AllMouseButtonClose);
-}
-
-VCL_BUILDER_FACTORY(PriorityMergedHBox)
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index c87c37118755..f2690c9e04b7 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -11,7 +11,7 @@
#include <sfx2/viewsh.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/notebookbar/SfxNotebookBar.hxx>
-#include <vcl/notebookbar.hxx>
+#include <vcl/notebookbar/notebookbar.hxx>
#include <vcl/syswin.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/sfxsids.hrc>
@@ -26,7 +26,7 @@
#include <unotools/confignode.hxx>
#include <comphelper/types.hxx>
#include <framework/addonsoptions.hxx>
-#include <vcl/NotebookBarAddonsMerger.hxx>
+#include <vcl/notebookbar/NotebookBarAddonsMerger.hxx>
#include <vector>
#include <map>
#include <vcl/WeldedTabbedNotebookbar.hxx>