summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2013-05-23 18:43:08 +0200
committerJan Holesovsky <kendy@suse.cz>2013-06-02 04:54:53 +0200
commit4f14ed6d346a488976262e69fdbc2fd21881b659 (patch)
treeb3e43401a9c11a63097d57281e51889875551126
parent916afbea4f20a72e7c3defee17676d8ec23841c1 (diff)
sidebar: Introduce PanelLayout class.
This allows sidebars to be defined using Widget layout / .ui files. Change-Id: I7d5daf2579d6359ba48d4df4be344bb75ce16273
-rw-r--r--include/svx/sidebar/PanelLayout.hxx31
-rw-r--r--sfx2/source/sidebar/SidebarPanelBase.cxx10
-rw-r--r--svx/Library_svx.mk1
-rw-r--r--svx/source/sidebar/PanelLayout.cxx35
4 files changed, 76 insertions, 1 deletions
diff --git a/include/svx/sidebar/PanelLayout.hxx b/include/svx/sidebar/PanelLayout.hxx
new file mode 100644
index 000000000000..c29f6b90f4ed
--- /dev/null
+++ b/include/svx/sidebar/PanelLayout.hxx
@@ -0,0 +1,31 @@
+/* -*- 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 SIDEBAR_PANELLAYOUT_HXX
+#define SIDEBAR_PANELLAYOUT_HXX
+
+#include <svx/svxdllapi.h>
+
+#include <vcl/builder.hxx>
+#include <vcl/ctrl.hxx>
+
+/// This class is the base for the Widget Layout-based sidebar panels.
+class SVX_DLLPUBLIC PanelLayout : public Control, public VclBuilderContainer
+{
+public:
+ PanelLayout(Window* pParent, const OString& rID, const OUString& rUIXMLDescription);
+ virtual ~PanelLayout() {}
+
+ virtual Size GetOptimalSize() const;
+ virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/sidebar/SidebarPanelBase.cxx b/sfx2/source/sidebar/SidebarPanelBase.cxx
index 9aef9fa7f622..263e9706e924 100644
--- a/sfx2/source/sidebar/SidebarPanelBase.cxx
+++ b/sfx2/source/sidebar/SidebarPanelBase.cxx
@@ -21,6 +21,7 @@
#include "sfx2/sidebar/IContextChangeReceiver.hxx"
#include "sfx2/imagemgr.hxx"
#include <vcl/ctrl.hxx>
+#include <vcl/layout.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
@@ -228,7 +229,14 @@ ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWi
else
{
ILayoutableWindow* pLayoutableWindow = dynamic_cast<ILayoutableWindow*>(mpControl);
- if (pLayoutableWindow != NULL)
+
+ if (isLayoutEnabled(mpControl))
+ {
+ // widget layout-based sidebar
+ Size aSize(mpControl->GetOptimalSize());
+ return ui::LayoutSize(aSize.Height(), aSize.Height(), aSize.Height());
+ }
+ else if (pLayoutableWindow != NULL)
return pLayoutableWindow->GetHeightForWidth(nWidth);
else if (mpControl != NULL)
{
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk
index 76f54c9bc4ae..385e5a3fe96d 100644
--- a/svx/Library_svx.mk
+++ b/svx/Library_svx.mk
@@ -165,6 +165,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
svx/source/sidebar/nbdtmg \
svx/source/sidebar/nbdtmgfact \
svx/source/sidebar/PanelFactory \
+ svx/source/sidebar/PanelLayout \
svx/source/sidebar/SelectionAnalyzer \
svx/source/sidebar/SelectionChangeHandler \
svx/source/sidebar/debug/ColorPanel \
diff --git a/svx/source/sidebar/PanelLayout.cxx b/svx/source/sidebar/PanelLayout.cxx
new file mode 100644
index 000000000000..17c1e30e9a78
--- /dev/null
+++ b/svx/source/sidebar/PanelLayout.cxx
@@ -0,0 +1,35 @@
+/* -*- 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 <svx/sidebar/PanelLayout.hxx>
+#include <vcl/layout.hxx>
+
+PanelLayout::PanelLayout(Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
+ : Control(pParent)
+{
+ m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID);
+}
+
+Size PanelLayout::GetOptimalSize() const
+{
+ if (isLayoutEnabled(this))
+ return VclContainer::getLayoutRequisition(*GetWindow(WINDOW_FIRSTCHILD));
+
+ return Control::GetOptimalSize();
+}
+
+void PanelLayout::setPosSizePixel(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags)
+{
+ Control::setPosSizePixel(nX, nY, nWidth, nHeight, nFlags);
+
+ if (isLayoutEnabled(this) && (nFlags & WINDOW_POSSIZE_SIZE))
+ VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), Size(nWidth, nHeight));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */