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 "IDisposable.hxx"
24 #include "ISidebarReceiver.hxx"
25 #include <sfx2/sidebar/ILayoutableWindow.hxx>
27 #include <com/sun/star/frame/XStatusListener.hpp>
32 #include <vcl/ctrl.hxx>
33 #include <svtools/valueset.hxx>
34 #include <svtools/transfer.hxx>
35 #include <sfx2/shell.hxx>
37 #include <com/sun/star/ui/XSidebar.hpp>
47 namespace sd
{ namespace tools
{
48 class EventMultiplexerEvent
;
51 namespace sd
{ namespace sidebar
{
54 class SidebarViewShell
;
58 public DragSourceHelper
,
59 public DropTargetHelper
,
60 public sfx2::sidebar::ILayoutableWindow
63 /** Create a new layout menu. Depending on the given flag it
64 displays its own scroll bar or lets a surrounding window
67 the parent node in the control tree
68 @param i_rPanelViewShell
69 the view shell of the task pane.
73 ViewShellBase
& rViewShellBase
,
74 const css::uno::Reference
<css::ui::XSidebar
>& rxSidebar
);
75 virtual ~LayoutMenu();
76 virtual void dispose() SAL_OVERRIDE
;
80 /** Return a numerical value representing the currently selected
83 AutoLayout
GetSelectedAutoLayout();
85 // From ILayoutableWindow
86 virtual css::ui::LayoutSize
GetHeightForWidth (const sal_Int32 nWidth
) SAL_OVERRIDE
;
89 virtual void Paint (vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
90 virtual void Resize() SAL_OVERRIDE
;
92 /** Show a context menu when the right mouse button is pressed.
94 virtual void MouseButtonDown (const MouseEvent
& rEvent
) SAL_OVERRIDE
;
96 /** Call this method when the set of displayed layouts is not up-to-date
97 anymore. It will re-assemble this set according to the current
100 void InvalidateContent();
103 virtual void StartDrag (sal_Int8 nAction
, const Point
& rPosPixel
) SAL_OVERRIDE
;
106 virtual sal_Int8
AcceptDrop (const AcceptDropEvent
& rEvent
) SAL_OVERRIDE
;
107 virtual sal_Int8
ExecuteDrop (const ExecuteDropEvent
& rEvent
) SAL_OVERRIDE
;
109 /** The context menu is requested over this Command() method.
111 virtual void Command (const CommandEvent
& rEvent
) SAL_OVERRIDE
;
113 /** Call Fill() when switching to or from high contrast mode so that the
114 correct set of icons is displayed.
116 virtual void DataChanged (const DataChangedEvent
& rEvent
) SAL_OVERRIDE
;
118 using Window::GetWindow
;
119 using ValueSet::StartDrag
;
122 ViewShellBase
& mrBase
;
124 /** Do we use our own scroll bar or is viewport handling done by
127 bool mbUseOwnScrollBar
;
129 /** If we are asked for the preferred window size, then use this
130 many columns for the calculation.
132 const int mnPreferredColumnCount
;
133 css::uno::Reference
<css::frame::XStatusListener
> mxListener
;
134 bool mbSelectionUpdatePending
;
135 bool mbIsMainViewChangePending
;
136 css::uno::Reference
<css::ui::XSidebar
> mxSidebar
;
139 /** Calculate the number of displayed rows. This depends on the given
140 item size, the given number of columns, and the size of the
141 control. Note that this is not the number of rows managed by the
142 valueset. This number may be larger. In that case a vertical
143 scroll bar is displayed.
145 int CalculateRowCount (const Size
& rItemSize
, int nColumnCount
);
147 /** Fill the value set with the layouts that are applicable to the
148 current main view shell.
152 /** Remove all items from the value set.
156 /** Assign the given layout to all selected slides of a slide sorter.
157 If no slide sorter is active then this call is ignored. The slide
158 sorter in the center pane is preferred if the choice exists.
160 void AssignLayoutToSelectedSlides (AutoLayout aLayout
);
162 /** Insert a new page with the given layout. The page is inserted via
163 the main view shell, i.e. its SID_INSERTPAGE slot is called. If it
164 does not support this slot then inserting a new page does not take
165 place. The new page is inserted after the currently active one (the
166 one returned by ViewShell::GetActualPage().)
168 void InsertPageWithLayout (AutoLayout aLayout
);
170 /** Create a request structure that can be used with the SID_INSERTPAGE
171 and SID_MODIFYPAGE slots. The parameters are set so that the given
172 layout is assigned to the current page of the main view shell.
174 Supported slots are SID_INSERTPAGE and SID_MODIFYPAGE.
176 Layout of the page to insert or to assign.
178 SfxRequest
CreateRequest (
182 /** Select the layout that is used by the current page.
184 void UpdateSelection();
187 void implConstruct( DrawDocShell
& rDocumentShell
);
189 /** When clicked then set the current page of the view in the center pane.
191 DECL_LINK(ClickHandler
, void *);
192 DECL_LINK(RightClickHandler
, MouseEvent
*);
193 DECL_LINK(StateChangeHandler
, void *);
194 DECL_LINK(EventMultiplexerListener
, ::sd::tools::EventMultiplexerEvent
*);
195 DECL_LINK(WindowEventHandler
, VclWindowEvent
*);
196 DECL_LINK(OnMenuItemSelected
, Menu
*);
199 } } // end of namespace ::sd::toolpanel
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */