summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <eszkadev@gmail.com>2016-07-01 15:53:46 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-07-08 13:23:24 +0000
commitd3dd6b5c41cbd16620bf53189b9c08ad5600fdc8 (patch)
treed0a38e7bd742d0fc670dab52cfaf3b5a3a9ddb1d
parentb39596b109e05e6b49687e072bcb1e0b39b21dcc (diff)
GSoC notebookbar: container with priority
+ extended vcl builder to parse priority + IPrioritable interface for controls with priorities + added IPrioritable as a base for VclContainer + Added PriorityHBox - box which shows controls if we have enough space PriorityHBox listen vcl events from SystemWindow to detect Resize Change-Id: I74ac1a80e7d0a061f5e7a8584dbb2abf956053c7 Reviewed-on: https://gerrit.libreoffice.org/26983 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r--extras/source/glade/libreoffice-catalog.xml.in3
-rw-r--r--include/vcl/IPrioritable.hxx44
-rw-r--r--include/vcl/builder.hxx4
-rw-r--r--include/vcl/layout.hxx4
-rw-r--r--sfx2/Library_sfx.mk1
-rw-r--r--sfx2/source/doc/objxtor.cxx3
-rw-r--r--sfx2/source/notebookbar/PriorityHBox.cxx152
-rw-r--r--sw/uiconfig/swriter/ui/notebookbar.ui703
-rw-r--r--vcl/source/window/builder.cxx50
-rw-r--r--vcl/source/window/layout.cxx2
10 files changed, 649 insertions, 317 deletions
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index a822164e04bc..b92d24be5670 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -827,5 +827,8 @@
<glade-widget-class title="Button with small padding" name="vcllo-SmallButton"
generic-name="SmallButton" parent="GtkButton"
icon-name="widget-gtk-button"/>
+ <glade-widget-class title="Horizontal box hiding childs depending on its priorities" name="sfxlo-PriorityHBox"
+ generic-name="PriorityHBox" parent="GtkBox"
+ icon-name="widget-gtk-box"/>
</glade-widget-classes>
</glade-catalog>
diff --git a/include/vcl/IPrioritable.hxx b/include/vcl/IPrioritable.hxx
new file mode 100644
index 000000000000..11146681ee65
--- /dev/null
+++ b/include/vcl/IPrioritable.hxx
@@ -0,0 +1,44 @@
+/* -*- 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_IPRIORITABLE_HXX
+#define INCLUDED_VCL_IPRIORITABLE_HXX
+
+#define VCL_PRIORITY_DEFAULT -1
+
+namespace vcl
+{
+
+class VCL_DLLPUBLIC IPrioritable
+{
+protected:
+ IPrioritable() : m_nPriority(VCL_PRIORITY_DEFAULT)
+ {
+ }
+
+public:
+ int GetPriority() const
+ {
+ return m_nPriority;
+ }
+
+ void SetPriority(int nPriority)
+ {
+ m_nPriority = nPriority;
+ }
+
+private:
+ int m_nPriority;
+};
+
+} // namespace vcl
+
+#endif // INCLUDED_VCL_IPRIORITABLE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 13ff4200cb98..787f6ea30b81 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -351,8 +351,8 @@ private:
void handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader);
VclPtr<vcl::Window> handleObject(vcl::Window *pParent, xmlreader::XmlReader &reader);
void handlePacking(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader);
- static std::vector<vcl::EnumContext::Context> handleStyle(xmlreader::XmlReader &reader);
- static vcl::EnumContext::Context getContext(xmlreader::XmlReader &reader);
+ static std::vector<vcl::EnumContext::Context> handleStyle(xmlreader::XmlReader &reader, int &nPriority);
+ static OString getStyleClass(xmlreader::XmlReader &reader);
void applyPackingProperty(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader);
void collectProperty(xmlreader::XmlReader &reader, const OString &rID, stringmap &rVec);
static void collectPangoAttribute(xmlreader::XmlReader &reader, stringmap &rMap);
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index a3e21042989c..59d7d6c6ae45 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -14,13 +14,15 @@
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>
+#include <vcl/IPrioritable.hxx>
#include <vcl/scrbar.hxx>
#include <vcl/vclmedit.hxx>
#include <vcl/window.hxx>
#include <vcl/vclptr.hxx>
#include <set>
-class VCL_DLLPUBLIC VclContainer : public vcl::Window
+class VCL_DLLPUBLIC VclContainer : public vcl::Window,
+ public vcl::IPrioritable
{
public:
VclContainer(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN);
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 0b77f45d62b7..fddb89b8af75 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -234,6 +234,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/doc/saveastemplatedlg \
sfx2/source/explorer/nochaos \
sfx2/source/inet/inettbc \
+ sfx2/source/notebookbar/PriorityHBox \
sfx2/source/notebookbar/SfxNotebookBar \
sfx2/source/notify/eventsupplier \
sfx2/source/notify/globalevents \
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index 8f7a814bdce6..f3cc4f2d716a 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -97,6 +97,7 @@
#include "appbaslib.hxx"
#include <sfx2/sfxbasemodel.hxx>
#include <shellimpl.hxx>
+#include <sfx2/notebookbar/SfxNotebookBar.hxx>
#include <basic/basicmanagerrepository.hxx>
@@ -622,6 +623,8 @@ bool SfxObjectShell::PrepareClose
return false;
}
+ if ( pFrame )
+ sfx2::SfxNotebookBar::CloseMethod(pFrame->GetBindings());
pImpl->bPreparedForClose = true;
return true;
}
diff --git a/sfx2/source/notebookbar/PriorityHBox.cxx b/sfx2/source/notebookbar/PriorityHBox.cxx
new file mode 100644
index 000000000000..88f91bc90518
--- /dev/null
+++ b/sfx2/source/notebookbar/PriorityHBox.cxx
@@ -0,0 +1,152 @@
+/* -*- 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 <vector>
+
+bool lcl_comparePriority(const vcl::IPrioritable* a, const vcl::IPrioritable* b)
+{
+ return a->GetPriority() < b->GetPriority();
+}
+
+/*
+ * PriorityHBox is a VclHBox which hides own childs 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 SFX2_DLLPUBLIC PriorityHBox : public VclHBox
+{
+private:
+ bool m_bInitialized;
+ long m_nNeededWidth;
+
+ std::vector<IPrioritable*> m_aSortedChilds;
+
+public:
+ PriorityHBox(vcl::Window *pParent)
+ : VclHBox(pParent)
+ , m_bInitialized(false)
+ , m_nNeededWidth(0)
+ {
+ }
+
+ virtual ~PriorityHBox() override
+ {
+ disposeOnce();
+ }
+
+ virtual void dispose() override
+ {
+ if (m_bInitialized && SfxViewFrame::Current())
+ {
+ SystemWindow* pSystemWindow = SfxViewFrame::Current()->GetFrame().GetSystemWindow();
+ pSystemWindow->RemoveEventListener(LINK(this, PriorityHBox, WindowEventListener));
+ }
+ VclHBox::dispose();
+ }
+
+ virtual void Resize() override
+ {
+ long nWidth = GetSizePixel().Width();
+ long nCurrentWidth = m_nNeededWidth;
+
+ // Hide lower priority controls
+ auto pChild = m_aSortedChilds.begin();
+ while (nCurrentWidth > nWidth && pChild != m_aSortedChilds.end())
+ {
+ VclContainer* pContainer = static_cast<VclContainer*>(*pChild);
+ nCurrentWidth -= pContainer->GetSizePixel().Width() + get_spacing();
+ pContainer->Hide();
+ pChild++;
+ }
+
+ // Show higher priority controls if we already have enough space
+ while (pChild != m_aSortedChilds.end())
+ {
+ static_cast<VclContainer*>(*pChild)->Show();
+ pChild++;
+ }
+
+ VclHBox::Resize();
+ }
+
+ virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) override
+ {
+ if (!m_bInitialized)
+ {
+ m_bInitialized = true;
+
+ SystemWindow* pSystemWindow = SfxViewFrame::Current()->GetFrame().GetSystemWindow();
+ pSystemWindow->AddEventListener(LINK(this, PriorityHBox, WindowEventListener));
+
+ CalcNeededWidth();
+
+ long nWidth = pSystemWindow->GetSizePixel().Width();
+ SetSizePixel(Size(nWidth, GetSizePixel().Height()));
+ }
+
+ VclHBox::Paint(rRenderContext, rRect);
+ }
+
+ void CalcNeededWidth()
+ {
+ int spacing = get_spacing();
+
+ for (sal_uInt16 i = 0; i < GetChildCount(); ++i)
+ {
+ vcl::Window* pChild = GetChild(i);
+ m_nNeededWidth += pChild->GetSizePixel().Width() + spacing;
+
+ // Add only containers which have explicitly assigned priority.
+ if (pChild->GetType() == WINDOW_CONTAINER)
+ {
+ IPrioritable* pPrioritable = dynamic_cast<IPrioritable*>(pChild);
+ if (pPrioritable->GetPriority() != VCL_PRIORITY_DEFAULT)
+ m_aSortedChilds.push_back(pPrioritable);
+ }
+ }
+
+ std::sort(m_aSortedChilds.begin(), m_aSortedChilds.end(), lcl_comparePriority);
+ }
+
+private:
+ DECL_LINK_TYPED( WindowEventListener, VclWindowEvent&, void );
+};
+
+IMPL_LINK_TYPED( PriorityHBox, WindowEventListener, VclWindowEvent&, rEvent, void )
+{
+ if (rEvent.GetId() == VCLEVENT_WINDOW_RESIZE)
+ {
+ vcl::Window* pEventWindow = rEvent.GetWindow();
+
+ OSL_ENSURE(pEventWindow, "PriorityHBox::WindowEventListener: no window!");
+
+ long nWidth = pEventWindow->GetSizePixel().Width();
+ SetSizePixel(Size(nWidth, GetSizePixel().Height()));
+ }
+}
+
+VCL_BUILDER_FACTORY(PriorityHBox)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/uiconfig/swriter/ui/notebookbar.ui b/sw/uiconfig/swriter/ui/notebookbar.ui
index 8df7c6426143..00949e278f24 100644
--- a/sw/uiconfig/swriter/ui/notebookbar.ui
+++ b/sw/uiconfig/swriter/ui/notebookbar.ui
@@ -254,7 +254,7 @@
</packing>
</child>
<child>
- <object class="GtkBox" id="box3">
+ <object class="sfxlo-PriorityHBox" id="box3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
@@ -323,6 +323,17 @@
<property name="position">1</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box18">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="vcllo-SmallButton" id="FormatPaintbrush">
<property name="visible">True</property>
@@ -337,14 +348,17 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">0</property>
</packing>
</child>
+ <style>
+ <class name="priority-2"/>
+ </style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -356,7 +370,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -415,72 +429,6 @@
<property name="position">1</property>
</packing>
</child>
- <child>
- <object class="sfxlo-SidebarToolBox" id="fontadjust">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="show_arrow">False</property>
- <child>
- <object class="GtkToolButton" id="grow">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="is_important">True</property>
- <property name="action_name">.uno:Grow</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="shrink">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="is_important">True</property>
- <property name="action_name">.uno:Shrink</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="sfxlo-SidebarToolBox" id="reset">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="show_arrow">False</property>
- <child>
- <object class="GtkToolButton" id="ResetAttributes">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="is_important">True</property>
- <property name="action_name">.uno:ResetAttributes</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
</object>
<packing>
<property name="expand">False</property>
@@ -576,73 +524,6 @@
</packing>
</child>
<child>
- <object class="sfxlo-SidebarToolBox" id="position">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="show_arrow">False</property>
- <child>
- <object class="GtkToolButton" id="subscript">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="is_important">True</property>
- <property name="action_name">.uno:SubScript</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="superscript">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="is_important">True</property>
- <property name="action_name">.uno:SuperScript</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="sfxlo-SidebarToolBox" id="spacingbar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkMenuToolButton" id="spacing">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="is_important">True</property>
- <property name="action_name">.uno:Spacing</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
<object class="sfxlo-SidebarToolBox" id="colorbar_writer">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -705,7 +586,168 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box27">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="sfxlo-SidebarToolBox" id="fontadjust">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="show_arrow">False</property>
+ <child>
+ <object class="GtkToolButton" id="grow1">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="is_important">True</property>
+ <property name="action_name">.uno:Grow</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="shrink1">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="is_important">True</property>
+ <property name="action_name">.uno:Shrink</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="sfxlo-SidebarToolBox" id="position1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="show_arrow">False</property>
+ <child>
+ <object class="GtkToolButton" id="subscript2">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="is_important">True</property>
+ <property name="action_name">.uno:SubScript</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="superscript2">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="is_important">True</property>
+ <property name="action_name">.uno:SuperScript</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="priority-4"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box67">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="sfxlo-SidebarToolBox" id="reset1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="show_arrow">False</property>
+ <child>
+ <object class="GtkToolButton" id="ResetAttributes2">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="is_important">True</property>
+ <property name="action_name">.uno:ResetAttributes</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="sfxlo-SidebarToolBox" id="spacingbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkMenuToolButton" id="spacing1">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="is_important">True</property>
+ <property name="action_name">.uno:Spacing</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="priority-3"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
</packing>
</child>
<child>
@@ -717,7 +759,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="position">6</property>
</packing>
</child>
<child>
@@ -798,90 +840,6 @@
<property name="position">0</property>
</packing>
</child>
- <child>
- <object class="sfxlo-SidebarToolBox" id="indent">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="has_tooltip">True</property>
- <property name="tooltip_text" translatable="yes">Indent</property>
- <child>
- <object class="GtkToolButton" id="increaseindent">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="has_tooltip">True</property>
- <property name="tooltip_text" translatable="yes">Increase Indent</property>
- <property name="is_important">True</property>
- <property name="action_name">.uno:IncrementIndent</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="decreaseindent">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="has_tooltip">True</property>
- <property name="tooltip_text" translatable="yes">Decrease Indent</property>
- <property name="is_important">True</property>
- <property name="action_name">.uno:DecrementIndent</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="sfxlo-SidebarToolBox" id="writedirection">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="show_arrow">False</property>
- <child>
- <object class="GtkToolButton" id="lefttoright">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="is_important">True</property>
- <property name="action_name">.uno:ParaLeftToRight</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="righttoleft">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="is_important">True</property>
- <property name="action_name">.uno:ParaRightToLeft</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">2</property>
- </packing>
- </child>
</object>
<packing>
<property name="expand">False</property>
@@ -957,119 +915,253 @@
<property name="position">0</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">7</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box28">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox" id="box31">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkSeparator" id="separator28">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="sfxlo-SidebarToolBox" id="line">
+ <object class="GtkBox" id="box66">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">end</property>
+ <property name="spacing">12</property>
<child>
- <object class="GtkMenuToolButton" id="LineSpacing">
+ <object class="sfxlo-SidebarToolBox" id="indent">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="action_name">.uno:LineSpacing</property>
- <property name="use_underline">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_text" translatable="yes">Indent</property>
+ <child>
+ <object class="GtkToolButton" id="increaseindent1">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_text" translatable="yes">Increase Indent</property>
+ <property name="is_important">True</property>
+ <property name="action_name">.uno:IncrementIndent</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="decreaseindent1">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_text" translatable="yes">Decrease Indent</property>
+ <property name="is_important">True</property>
+ <property name="action_name">.uno:DecrementIndent</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
- <property name="homogeneous">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="sfxlo-SidebarToolBox" id="writedirection">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="show_arrow">False</property>
+ <child>
+ <object class="GtkToolButton" id="lefttoright1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="is_important">True</property>
+ <property name="action_name">.uno:ParaLeftToRight</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="righttoleft1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="is_important">True</property>
+ <property name="action_name">.uno:ParaRightToLeft</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="sfxlo-SidebarToolBox" id="verticalalignment">
+ <object class="GtkBox" id="box32">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="has_tooltip">True</property>
- <property name="tooltip_text" translatable="yes">Vertical Alignment</property>
- <property name="halign">end</property>
- <property name="hexpand">True</property>
- <property name="show_arrow">False</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkToolButton" id="cellverttop">
+ <object class="GtkSeparator" id="separator20">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="action_name">.uno:CellVertTop</property>
- <property name="use_underline">True</property>
+ <property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
- <property name="homogeneous">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkToolButton" id="cellvertcenter">
+ <object class="sfxlo-SidebarToolBox" id="line">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="action_name">.uno:CellVertCenter</property>
- <property name="use_underline">True</property>
+ <property name="halign">end</property>
+ <child>
+ <object class="GtkMenuToolButton" id="LineSpacing1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="action_name">.uno:LineSpacing</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">False</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
- <property name="homogeneous">True</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
- <object class="GtkToolButton" id="cellvertbottom">
+ <object class="sfxlo-SidebarToolBox" id="verticalalignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="action_name">.uno:CellVertBottom</property>
- <property name="use_underline">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_text" translatable="yes">Vertical Alignment</property>
+ <property name="halign">end</property>
+ <property name="hexpand">True</property>
+ <property name="show_arrow">False</property>
+ <child>
+ <object class="GtkToolButton" id="cellverttop1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="action_name">.uno:CellVertTop</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="cellvertcenter1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="action_name">.uno:CellVertCenter</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="cellvertbottom1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="action_name">.uno:CellVertBottom</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
- <property name="homogeneous">True</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">4</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator" id="separator18">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
+ <style>
+ <class name="priority-1"/>
+ </style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkSeparator" id="separator18">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">5</property>
+ <property name="position">8</property>
</packing>
</child>
<child>
@@ -1142,40 +1234,57 @@
<property name="position">1</property>
</packing>
</child>
+ <style>
+ <class name="priority-3"/>
+ </style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">6</property>
+ <property name="position">10</property>
</packing>
</child>
<child>
- <object class="GtkSeparator" id="separator19">
+ <object class="GtkBox" id="box30">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">7</property>
- </packing>
- </child>
- <child>
- <object class="vcllo-SmallButton" id="SearchDialog">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action_name">.uno:SearchDialog</property>
- <property name="image">SearchDialogImg</property>
- <property name="relief">none</property>
- <property name="image_position">top</property>
- <property name="always_show_image">True</property>
+ <child>
+ <object class="GtkSeparator" id="separator19">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="vcllo-SmallButton" id="SearchDialog">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="action_name">.uno:SearchDialog</property>
+ <property name="image">SearchDialogImg</property>
+ <property name="relief">none</property>
+ <property name="image_position">top</property>
+ <property name="always_show_image">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <style>
+ <class name="priority-4"/>
+ </style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">8</property>
+ <property name="position">12</property>
</packing>
</child>
</object>
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 7e449982c5d4..eee51ba2a15e 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -20,6 +20,7 @@
#include <vcl/field.hxx>
#include <vcl/fixed.hxx>
#include <vcl/fixedhyper.hxx>
+#include <vcl/IPrioritable.hxx>
#include <vcl/layout.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/menubtn.hxx>
@@ -1960,7 +1961,8 @@ void VclBuilder::handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &read
}
else if (name.equals("style"))
{
- context = handleStyle(reader);
+ int nPriority = 0;
+ context = handleStyle(reader, nPriority);
--nLevel;
}
else if (name.equals("property"))
@@ -2862,6 +2864,13 @@ VclPtr<vcl::Window> VclBuilder::handleObject(vcl::Window *pParent, xmlreader::Xm
}
else if (name.equals("items"))
aItems = handleItems(reader, sID);
+ else if (name.equals("style"))
+ {
+ int nPriority = 0;
+ handleStyle(reader, nPriority);
+ if (nPriority != 0)
+ dynamic_cast<vcl::IPrioritable*>(pCurrentChild.get())->SetPriority(nPriority);
+ }
else
{
++nLevel;
@@ -3048,7 +3057,7 @@ void VclBuilder::applyPackingProperty(vcl::Window *pCurrent,
}
}
-std::vector<vcl::EnumContext::Context> VclBuilder::handleStyle(xmlreader::XmlReader &reader)
+std::vector<vcl::EnumContext::Context> VclBuilder::handleStyle(xmlreader::XmlReader &reader, int &nPriority)
{
std::vector<vcl::EnumContext::Context> aContext;
@@ -3070,7 +3079,24 @@ std::vector<vcl::EnumContext::Context> VclBuilder::handleStyle(xmlreader::XmlRea
++nLevel;
if (name.equals("class"))
{
- aContext.push_back(getContext(reader));
+ OString classStyle = getStyleClass(reader);
+
+ if (classStyle.startsWith("context-"))
+ {
+ OString sContext = classStyle.copy(classStyle.indexOf('-') + 1);
+ OUString sContext2 = OUString(sContext.getStr(), sContext.getLength(), RTL_TEXTENCODING_UTF8);
+ aContext.push_back(vcl::EnumContext::GetContextEnum(sContext2));
+ }
+ else if (classStyle.startsWith("priority-"))
+ {
+ OString aPriority = classStyle.copy(classStyle.indexOf('-') + 1);
+ OUString aPriority2 = OUString(aPriority.getStr(), aPriority.getLength(), RTL_TEXTENCODING_UTF8);
+ nPriority = aPriority2.toInt32();
+ }
+ else
+ {
+ SAL_WARN("vcl.layout", "unknown class: " << classStyle.getStr());
+ }
}
}
@@ -3086,32 +3112,22 @@ std::vector<vcl::EnumContext::Context> VclBuilder::handleStyle(xmlreader::XmlRea
return aContext;
}
-vcl::EnumContext::Context VclBuilder::getContext(xmlreader::XmlReader &reader)
+OString VclBuilder::getStyleClass(xmlreader::XmlReader &reader)
{
xmlreader::Span name;
int nsId;
+ OString aRet;
while (reader.nextAttribute(&nsId, &name))
{
if (name.equals("name"))
{
name = reader.getAttributeValue(false);
- OString sKey(name.begin, name.length);
-
- if (sKey.startsWith("context-"))
- {
- OString sContext = sKey.copy(sKey.indexOf('-') + 1);
- OUString sContext2 = OUString(sContext.getStr(), sContext.getLength(), RTL_TEXTENCODING_UTF8);
- return vcl::EnumContext::GetContextEnum(sContext2);
- }
- else
- {
- SAL_WARN("vcl.layout", "unknown class: " << sKey.getStr());
- }
+ aRet = OString (name.begin, name.length);
}
}
- return vcl::EnumContext::Context::Context_Any;
+ return aRet;
}
OString VclBuilder::getTranslation(const OString &rID, const OString &rProperty) const
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index e48a78d7e57b..f93aaaaa2af5 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -11,6 +11,7 @@
#include <o3tl/enumarray.hxx>
#include <o3tl/enumrange.hxx>
#include <vcl/dialog.hxx>
+#include <vcl/IPrioritable.hxx>
#include <vcl/layout.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/svapp.hxx>
@@ -20,6 +21,7 @@
VclContainer::VclContainer(vcl::Window *pParent, WinBits nStyle)
: Window(WINDOW_CONTAINER)
+ , IPrioritable()
, m_bLayoutDirty(true)
{
ImplInit(pParent, nStyle, nullptr);