1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SD_SOURCE_UI_SIDEBAR_LAYOUTMENU_HXX
21 #define INCLUDED_SD_SOURCE_UI_SIDEBAR_LAYOUTMENU_HXX
23 #include <sfx2/sidebar/ILayoutableWindow.hxx>
25 #include <svtools/valueset.hxx>
26 #include <vcl/transfer.hxx>
27 #include <sfx2/shell.hxx>
28 #include <xmloff/autolayout.hxx>
30 namespace com
{ namespace sun
{ namespace star
{ namespace frame
{ class XStatusListener
; } } } }
31 namespace com
{ namespace sun
{ namespace star
{ namespace ui
{ class XSidebar
; } } } }
39 namespace sd
{ namespace tools
{
40 class EventMultiplexerEvent
;
43 namespace sd
{ namespace sidebar
{
47 public DragSourceHelper
,
48 public DropTargetHelper
,
49 public sfx2::sidebar::ILayoutableWindow
52 /** Create a new layout menu. Depending on the given flag it
53 displays its own scroll bar or lets a surrounding window
56 the parent node in the control tree
57 @param i_rPanelViewShell
58 the view shell of the task pane.
62 ViewShellBase
& rViewShellBase
,
63 const css::uno::Reference
<css::ui::XSidebar
>& rxSidebar
);
64 virtual ~LayoutMenu() override
;
65 virtual void dispose() override
;
69 /** Return a numerical value representing the currently selected
72 AutoLayout
GetSelectedAutoLayout();
74 // From ILayoutableWindow
75 virtual css::ui::LayoutSize
GetHeightForWidth (const sal_Int32 nWidth
) override
;
78 virtual void Resize() override
;
80 /** Show a context menu when the right mouse button is pressed.
82 virtual void MouseButtonDown (const MouseEvent
& rEvent
) override
;
84 /** Call this method when the set of displayed layouts is not up-to-date
85 anymore. It will re-assemble this set according to the current
88 void InvalidateContent();
91 virtual void StartDrag (sal_Int8 nAction
, const Point
& rPosPixel
) override
;
94 virtual sal_Int8
AcceptDrop (const AcceptDropEvent
& rEvent
) override
;
95 virtual sal_Int8
ExecuteDrop (const ExecuteDropEvent
& rEvent
) override
;
97 /** The context menu is requested over this Command() method.
99 virtual void Command (const CommandEvent
& rEvent
) override
;
101 /** Call Fill() when switching to or from high contrast mode so that the
102 correct set of icons is displayed.
104 virtual void DataChanged (const DataChangedEvent
& rEvent
) override
;
106 using Window::GetWindow
;
107 using ValueSet::StartDrag
;
110 ViewShellBase
& mrBase
;
112 /** If we are asked for the preferred window size, then use this
113 many columns for the calculation.
115 css::uno::Reference
<css::frame::XStatusListener
> mxListener
;
116 bool mbIsMainViewChangePending
;
117 css::uno::Reference
<css::ui::XSidebar
> mxSidebar
;
120 /** Calculate the number of displayed rows. This depends on the given
121 item size, the given number of columns, and the size of the
122 control. Note that this is not the number of rows managed by the
123 valueset. This number may be larger. In that case a vertical
124 scroll bar is displayed.
126 int CalculateRowCount (const Size
& rItemSize
, int nColumnCount
);
128 /** Fill the value set with the layouts that are applicable to the
129 current main view shell.
133 /** Remove all items from the value set.
137 /** Assign the given layout to all selected slides of a slide sorter.
138 If no slide sorter is active then this call is ignored. The slide
139 sorter in the center pane is preferred if the choice exists.
141 void AssignLayoutToSelectedSlides (AutoLayout aLayout
);
143 /** Insert a new page with the given layout. The page is inserted via
144 the main view shell, i.e. its SID_INSERTPAGE slot is called. If it
145 does not support this slot then inserting a new page does not take
146 place. The new page is inserted after the currently active one (the
147 one returned by ViewShell::GetActualPage().)
149 void InsertPageWithLayout (AutoLayout aLayout
);
151 /** Create a request structure that can be used with the SID_INSERTPAGE
152 and SID_MODIFYPAGE slots. The parameters are set so that the given
153 layout is assigned to the current page of the main view shell.
155 Supported slots are SID_INSERTPAGE and SID_MODIFYPAGE.
157 Layout of the page to insert or to assign.
159 SfxRequest
CreateRequest (
163 /** Select the layout that is used by the current page.
165 void UpdateSelection();
168 void implConstruct( DrawDocShell
& rDocumentShell
);
170 /** When clicked then set the current page of the view in the center pane.
172 DECL_LINK(ClickHandler
, ValueSet
*, void);
173 DECL_LINK(StateChangeHandler
, const OUString
&, void);
174 DECL_LINK(EventMultiplexerListener
, ::sd::tools::EventMultiplexerEvent
&, void);
175 DECL_LINK(WindowEventHandler
, VclWindowEvent
&, void);
176 DECL_LINK(OnMenuItemSelected
, Menu
*, bool);
179 } } // end of namespace ::sd::toolpanel
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */