summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-01-24 15:33:46 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-01-24 20:37:14 +0100
commitfc056783bc63b2dfc8ede01a10ab8a7e653e4aa3 (patch)
tree37e4357e40dd1c0e3e1bf32be20dd00136c4bb32 /sd
parent2e1a38ceb6866248ec30f6fe58cd3adc1b910eec (diff)
move titledockwin to the one place it's used
Change-Id: Ia9a1e0f687de3f916d59f28112b7b00c0d4a6610 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128872 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/Library_sd.mk1
-rw-r--r--sd/inc/bitmaps.hlst2
-rw-r--r--sd/inc/strings.hrc2
-rw-r--r--sd/source/ui/dlg/PaneDockingWindow.cxx2
-rw-r--r--sd/source/ui/dlg/titledockwin.cxx261
-rw-r--r--sd/source/ui/inc/PaneDockingWindow.hxx4
-rw-r--r--sd/source/ui/inc/titledockwin.hxx94
7 files changed, 363 insertions, 3 deletions
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk
index 6705a8c572cd..1ded5eadc8ba 100644
--- a/sd/Library_sd.mk
+++ b/sd/Library_sd.mk
@@ -226,6 +226,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\
sd/source/ui/dlg/navigatr \
sd/source/ui/dlg/sdabstdlg \
sd/source/ui/dlg/sdtreelb \
+ sd/source/ui/dlg/titledockwin \
sd/source/ui/dlg/unchss \
sd/source/ui/docshell/docshel2 \
sd/source/ui/docshell/docshel3 \
diff --git a/sd/inc/bitmaps.hlst b/sd/inc/bitmaps.hlst
index 9e66e87dd032..e1c798cfae4e 100644
--- a/sd/inc/bitmaps.hlst
+++ b/sd/inc/bitmaps.hlst
@@ -207,4 +207,6 @@ inline constexpr OUStringLiteral BMP_MENU_PREV = u"cmd/sc_prevrecord.png";
inline constexpr OUStringLiteral BMP_MENU_FIRST = u"cmd/sc_firstrecord.png";
inline constexpr OUStringLiteral BMP_MENU_LAST = u"cmd/sc_lastrecord.png";
+inline constexpr OUStringLiteral SFX_BMP_CLOSE_DOC = u"sfx2/res/closedoc.png";
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sd/inc/strings.hrc b/sd/inc/strings.hrc
index 68be404dfaf9..c67d1c9d1579 100644
--- a/sd/inc/strings.hrc
+++ b/sd/inc/strings.hrc
@@ -483,4 +483,6 @@
#define RID_SVXSTR_MENU_FIRST NC_("RID_SVXSTR_MENU_FIRST", "~First Slide")
#define RID_SVXSTR_MENU_LAST NC_("RID_SVXSTR_MENU_LAST", "~Last Slide")
+#define STR_CLOSE_PANE NC_("STR_CLOSE_PANE", "Close Pane")
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/dlg/PaneDockingWindow.cxx b/sd/source/ui/dlg/PaneDockingWindow.cxx
index d2d5e4a70a71..6f7332ad9b96 100644
--- a/sd/source/ui/dlg/PaneDockingWindow.cxx
+++ b/sd/source/ui/dlg/PaneDockingWindow.cxx
@@ -28,7 +28,7 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::drawing::framework;
-using ::sfx2::TitledDockingWindow;
+using ::sd::TitledDockingWindow;
namespace sd {
diff --git a/sd/source/ui/dlg/titledockwin.cxx b/sd/source/ui/dlg/titledockwin.cxx
new file mode 100644
index 000000000000..f2aa744c200d
--- /dev/null
+++ b/sd/source/ui/dlg/titledockwin.cxx
@@ -0,0 +1,261 @@
+/* -*- 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 <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/eitem.hxx>
+#include <vcl/event.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/toolbox.hxx>
+
+#include <bitmaps.hlst>
+#include <strings.hrc>
+#include <sdresid.hxx>
+#include <titledockwin.hxx>
+
+namespace sd
+{
+ //= TitledDockingWindow
+ TitledDockingWindow::TitledDockingWindow( SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow, vcl::Window* i_pParent )
+ :SfxDockingWindow( i_pBindings, i_pChildWindow, i_pParent, WB_MOVEABLE|WB_CLOSEABLE|WB_DOCKABLE|WB_HIDE|WB_3DLOOK )
+ ,m_aToolbox( VclPtr<ToolBox>::Create(this) )
+ ,m_aContentWindow( VclPtr<vcl::Window>::Create(this, WB_DIALOGCONTROL) )
+ ,m_aBorder( 3, 1, 3, 3 )
+ ,m_nTitleBarHeight(0)
+ {
+ SetBackground( Wallpaper() );
+
+ m_aToolbox->SetSelectHdl( LINK( this, TitledDockingWindow, OnToolboxItemSelected ) );
+ m_aToolbox->SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetDialogColor() ) );
+ m_aToolbox->Show();
+ impl_resetToolBox();
+
+ m_aContentWindow->Show();
+ }
+
+ TitledDockingWindow::~TitledDockingWindow()
+ {
+ disposeOnce();
+ }
+
+ void TitledDockingWindow::dispose()
+ {
+ m_aToolbox.disposeAndClear();
+ m_aContentWindow.disposeAndClear();
+ SfxDockingWindow::dispose();
+ }
+
+ void TitledDockingWindow::SetTitle( const OUString& i_rTitle )
+ {
+ m_sTitle = i_rTitle;
+ Invalidate();
+ }
+
+
+ void TitledDockingWindow::SetText( const OUString& i_rText )
+ {
+ SfxDockingWindow::SetText( i_rText );
+ if ( m_sTitle.isEmpty() )
+ // our text is used as title, too => repaint
+ Invalidate();
+ }
+
+
+ void TitledDockingWindow::Resize()
+ {
+ SfxDockingWindow::Resize();
+ impl_layout();
+ }
+
+
+ void TitledDockingWindow::impl_layout()
+ {
+ m_aToolbox->ShowItem( ToolBoxItemId(1), !IsFloatingMode() );
+
+ const Size aToolBoxSize( m_aToolbox->CalcWindowSizePixel() );
+ Size aWindowSize( GetOutputSizePixel() );
+
+ // position the tool box
+ m_nTitleBarHeight = GetSettings().GetStyleSettings().GetTitleHeight();
+ if ( aToolBoxSize.Height() > m_nTitleBarHeight )
+ m_nTitleBarHeight = aToolBoxSize.Height();
+ m_aToolbox->SetPosSizePixel(
+ Point(
+ aWindowSize.Width() - aToolBoxSize.Width(),
+ ( m_nTitleBarHeight - aToolBoxSize.Height() ) / 2
+ ),
+ aToolBoxSize
+ );
+
+ // Place the content window.
+ if ( m_nTitleBarHeight < aToolBoxSize.Height() )
+ m_nTitleBarHeight = aToolBoxSize.Height();
+ aWindowSize.AdjustHeight( -m_nTitleBarHeight );
+ m_aContentWindow->SetPosSizePixel(
+ Point( m_aBorder.Left(), m_nTitleBarHeight + m_aBorder.Top() ),
+ Size(
+ aWindowSize.Width() - m_aBorder.Left() - m_aBorder.Right(),
+ aWindowSize.Height() - m_aBorder.Top() - m_aBorder.Bottom()
+ )
+ );
+ }
+
+ void TitledDockingWindow::ApplySettings(vcl::RenderContext& rRenderContext)
+ {
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+
+ // Font
+ ApplyControlFont(rRenderContext, rStyleSettings.GetAppFont());
+
+ // Color
+ ApplyControlForeground(rRenderContext, rStyleSettings.GetButtonTextColor());
+ rRenderContext.SetTextFillColor();
+ }
+
+ void TitledDockingWindow::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& i_rArea)
+ {
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+
+ SfxDockingWindow::Paint(rRenderContext, i_rArea);
+
+ rRenderContext.Push(vcl::PushFlags::FONT | vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
+
+ rRenderContext.SetFillColor(rStyleSettings.GetDialogColor());
+ rRenderContext.SetLineColor();
+
+ // bold font
+ vcl::Font aFont(rRenderContext.GetFont());
+ aFont.SetWeight(WEIGHT_BOLD);
+ rRenderContext.SetFont(aFont);
+
+ // Set border values.
+ Size aWindowSize(GetOutputSizePixel());
+ int nOuterLeft = 0;
+ int nInnerLeft = nOuterLeft + m_aBorder.Left() - 1;
+ int nOuterRight = aWindowSize.Width() - 1;
+ int nInnerRight = nOuterRight - m_aBorder.Right() + 1;
+ int nInnerTop = m_nTitleBarHeight + m_aBorder.Top() - 1;
+ int nOuterBottom = aWindowSize.Height() - 1;
+ int nInnerBottom = nOuterBottom - m_aBorder.Bottom() + 1;
+
+ // Paint title bar background.
+ ::tools::Rectangle aTitleBarBox(::tools::Rectangle(nOuterLeft, 0, nOuterRight, nInnerTop - 1));
+ rRenderContext.DrawRect(aTitleBarBox);
+
+ if (nInnerLeft > nOuterLeft)
+ rRenderContext.DrawRect(::tools::Rectangle(nOuterLeft, nInnerTop, nInnerLeft, nInnerBottom));
+ if (nOuterRight > nInnerRight)
+ rRenderContext.DrawRect(::tools::Rectangle(nInnerRight, nInnerTop, nOuterRight, nInnerBottom));
+ if (nInnerBottom < nOuterBottom)
+ rRenderContext.DrawRect(::tools::Rectangle(nOuterLeft, nInnerBottom, nOuterRight, nOuterBottom));
+
+ // Paint bevel border.
+ rRenderContext.SetFillColor();
+ rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
+ if (m_aBorder.Top() > 0)
+ rRenderContext.DrawLine(Point(nInnerLeft, nInnerTop), Point(nInnerLeft, nInnerBottom));
+ if (m_aBorder.Left() > 0)
+ rRenderContext.DrawLine(Point(nInnerLeft, nInnerTop), Point(nInnerRight, nInnerTop));
+
+ rRenderContext.SetLineColor(rStyleSettings.GetLightColor());
+ if (m_aBorder.Bottom() > 0)
+ rRenderContext.DrawLine(Point(nInnerRight, nInnerBottom), Point(nInnerLeft, nInnerBottom));
+ if (m_aBorder.Right() > 0)
+ rRenderContext.DrawLine(Point(nInnerRight, nInnerBottom), Point(nInnerRight, nInnerTop));
+
+ // Paint title bar text.
+ rRenderContext.SetLineColor(rStyleSettings.GetActiveTextColor());
+ aTitleBarBox.AdjustLeft(3 );
+ rRenderContext.DrawText(aTitleBarBox,
+ !m_sTitle.isEmpty() ? m_sTitle : GetText(),
+ DrawTextFlags::Left | DrawTextFlags::VCenter | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak);
+
+ // Restore original values of the output device.
+ rRenderContext.Pop();
+ }
+
+
+ void TitledDockingWindow::impl_resetToolBox()
+ {
+ m_aToolbox->Clear();
+
+ // Get the closer bitmap and set it as right most button.
+ m_aToolbox->InsertItem(ToolBoxItemId(1), Image(StockImage::Yes, SFX_BMP_CLOSE_DOC));
+ m_aToolbox->SetQuickHelpText(ToolBoxItemId(1), SdResId(STR_CLOSE_PANE));
+ m_aToolbox->ShowItem( ToolBoxItemId(1) );
+ }
+
+
+ IMPL_LINK( TitledDockingWindow, OnToolboxItemSelected, ToolBox*, pToolBox, void )
+ {
+ const ToolBoxItemId nId = pToolBox->GetCurItemId();
+
+ if ( nId == ToolBoxItemId(1) )
+ {
+ // the closer
+ EndTracking();
+ const sal_uInt16 nChildWindowId( GetChildWindow_Impl()->GetType() );
+ const SfxBoolItem aVisibility( nChildWindowId, false );
+ GetBindings().GetDispatcher()->ExecuteList(
+ nChildWindowId,
+ SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
+ { &aVisibility }
+ );
+ }
+ }
+
+
+ void TitledDockingWindow::StateChanged( StateChangedType i_nType )
+ {
+ switch ( i_nType )
+ {
+ case StateChangedType::InitShow:
+ impl_layout();
+ break;
+ default:;
+ }
+ SfxDockingWindow::StateChanged( i_nType );
+ }
+
+ void TitledDockingWindow::DataChanged( const DataChangedEvent& i_rDataChangedEvent )
+ {
+ SfxDockingWindow::DataChanged( i_rDataChangedEvent );
+
+ switch ( i_rDataChangedEvent.GetType() )
+ {
+ case DataChangedEventType::SETTINGS:
+ if ( !( i_rDataChangedEvent.GetFlags() & AllSettingsFlags::STYLE ) )
+ break;
+ [[fallthrough]];
+ case DataChangedEventType::FONTS:
+ case DataChangedEventType::FONTSUBSTITUTION:
+ {
+ impl_layout();
+ Invalidate();
+ }
+ break;
+ default: break;
+ }
+ }
+
+
+} // namespace sfx2
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/inc/PaneDockingWindow.hxx b/sd/source/ui/inc/PaneDockingWindow.hxx
index b2d38d7ed873..c69cb6f94904 100644
--- a/sd/source/ui/inc/PaneDockingWindow.hxx
+++ b/sd/source/ui/inc/PaneDockingWindow.hxx
@@ -19,11 +19,11 @@
#pragma once
-#include <sfx2/titledockwin.hxx>
+#include "titledockwin.hxx"
namespace sd {
- class PaneDockingWindow : public ::sfx2::TitledDockingWindow
+ class PaneDockingWindow : public ::sd::TitledDockingWindow
{
public:
/** Create a new docking window.
diff --git a/sd/source/ui/inc/titledockwin.hxx b/sd/source/ui/inc/titledockwin.hxx
new file mode 100644
index 000000000000..59e7e04b3531
--- /dev/null
+++ b/sd/source/ui/inc/titledockwin.hxx
@@ -0,0 +1,94 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <sfx2/dockwin.hxx>
+#include <tools/svborder.hxx>
+#include <vcl/vclptr.hxx>
+
+class ToolBox;
+
+namespace sd
+{
+ class TitledDockingWindow : public SfxDockingWindow
+ {
+ public:
+ TitledDockingWindow(
+ SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow,
+ vcl::Window* i_pParent
+ );
+
+ virtual ~TitledDockingWindow() override;
+ virtual void dispose() override;
+
+ /** sets a title to be displayed in the docking window
+ */
+ void SetTitle( const OUString& i_rTitle );
+
+ /** returns the content window, which is to be used as parent window for any content to be displayed
+ in the docking window.
+ */
+ vcl::Window& GetContentWindow() { return *m_aContentWindow; }
+ const vcl::Window& GetContentWindow() const { return *m_aContentWindow; }
+
+ /** Return the border that is painted around the inner window as
+ decoration.
+ */
+ const SvBorder& GetDecorationBorder() const { return m_aBorder; }
+
+ protected:
+ // Window overridables
+ virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& i_rArea) override;
+ virtual void Resize() override;
+ virtual void StateChanged( StateChangedType i_nType ) override;
+ virtual void DataChanged( const DataChangedEvent& i_rDataChangedEvent ) override;
+ virtual void SetText( const OUString& i_rText ) override;
+
+ virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
+ protected:
+ /** internal version of ResetToolBox
+ */
+ void impl_resetToolBox();
+
+ private:
+ DECL_LINK(OnToolboxItemSelected, ToolBox*, void);
+
+ void impl_layout();
+
+ private:
+ OUString m_sTitle;
+ VclPtr<ToolBox> m_aToolbox;
+ VclPtr<Window> m_aContentWindow;
+
+ /** The border that is painted around the inner window. The bevel
+ shadow lines are part of the border, so where the border is 0 no
+ such line is painted.
+ */
+ SvBorder m_aBorder;
+
+ /** Height of the title bar. Calculated in impl_layout().
+ */
+ int m_nTitleBarHeight;
+
+ };
+
+} // namespace sd
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */