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 SD_TASKPANE_LAYOUT_MENU_HXX
21 #define SD_TASKPANE_LAYOUT_MENU_HXX
23 #include "taskpane/TaskPaneTreeNode.hxx"
25 #include <com/sun/star/frame/XStatusListener.hpp>
29 #include <vcl/ctrl.hxx>
30 #include <svtools/valueset.hxx>
31 #include <svtools/transfer.hxx>
32 #include <sfx2/shell.hxx>
44 namespace sd
{ namespace tools
{
45 class EventMultiplexerEvent
;
49 namespace sd
{ namespace toolpanel
{
52 class ToolPanelViewShell
;
59 public DragSourceHelper
,
60 public DropTargetHelper
64 SFX_DECL_INTERFACE(SD_IF_SDLAYOUTMENU
)
66 /** Create a new layout menu. Depending on the given flag it
67 displays its own scroll bar or lets a surrounding window
70 the parent node in the control tree
71 @param i_rPanelViewShell
72 the view shell of the task pane.
76 ToolPanelViewShell
& i_rPanelViewShell
);
77 virtual ~LayoutMenu (void);
79 static std::auto_ptr
<ControlFactory
> CreateControlFactory (
80 ToolPanelViewShell
& i_rPanelViewShell
);
82 /** Return a numerical value representing the currently selected
85 AutoLayout
GetSelectedAutoLayout (void);
88 // From ILayoutableWindow
89 virtual Size
GetPreferredSize (void);
90 virtual sal_Int32
GetPreferredWidth (sal_Int32 nHeight
);
91 virtual sal_Int32
GetPreferredHeight (sal_Int32 nWidth
);
92 virtual sal_Int32
GetMinimumWidth (void);
93 virtual bool IsResizable (void);
94 virtual ::Window
* GetWindow (void);
97 virtual void Paint (const Rectangle
& rRect
);
98 virtual void Resize (void);
100 /** Show a context menu when the right mouse button is pressed.
102 virtual void MouseButtonDown (const MouseEvent
& rEvent
);
104 void Execute (SfxRequest
& rRequest
);
105 void GetState (SfxItemSet
& rItemSet
);
107 /** The LayoutMenu does not support some main views. In this case the
108 LayoutMenu is disabled. This state is updated in this method.
110 On some occasions the edit mode is being switched when this
111 method is called can not (yet) be reliably detected. Luckily,
112 in these cases the new value is provided by some broadcaster.
113 On other occasions the edit mode is not modified and is also not
114 provided. Therefore the Unknown value.
116 enum MasterMode
{ MM_NORMAL
, MM_MASTER
, MM_UNKNOWN
};
117 void UpdateEnabledState (const MasterMode eMode
);
119 // TreeNode overridables
120 virtual TaskPaneShellManager
* GetShellManager (void);
122 /** Call this method when the set of displayed layouts is not up-to-date
123 anymore. It will re-assemple this set according to the current
126 void InvalidateContent (void);
129 virtual void StartDrag (sal_Int8 nAction
, const Point
& rPosPixel
);
132 virtual sal_Int8
AcceptDrop (const AcceptDropEvent
& rEvent
);
133 virtual sal_Int8
ExecuteDrop (const ExecuteDropEvent
& rEvent
);
135 /** The context menu is requested over this Command() method.
137 virtual void Command (const CommandEvent
& rEvent
);
139 /** Call Fill() when switching to or from high contrast mode so that the
140 correct set of icons is displayed.
142 virtual void DataChanged (const DataChangedEvent
& rEvent
);
144 using Window::GetWindow
;
145 using ValueSet::StartDrag
;
148 ViewShellBase
& mrBase
;
150 TaskPaneShellManager
* mpShellManager
;
152 /** Do we use our own scroll bar or is viewport handling done by
155 bool mbUseOwnScrollBar
;
157 /** If we are asked for the preferred window size, then use this
158 many columns for the calculation.
160 const int mnPreferredColumnCount
;
162 ::com::sun::star::uno::Reference
<com::sun::star::frame::XStatusListener
> mxListener
;
164 bool mbSelectionUpdatePending
;
166 bool mbIsMainViewChangePending
;
168 /** Calculate the number of displayed rows. This depends on the given
169 item size, the given number of columns, and the size of the
170 control. Note that this is not the number of rows managed by the
171 valueset. This number may be larger. In that case a vertical
172 scroll bar is displayed.
174 int CalculateRowCount (const Size
& rItemSize
, int nColumnCount
);
176 /** Fill the value set with the layouts that are applicable to the
177 current main view shell.
181 /** Remove all items from the value set.
185 /** Assign the given layout to all selected slides of a slide sorter.
186 If no slide sorter is active then this call is ignored. The slide
187 sorter in the center pane is preferred if the choice exists.
189 void AssignLayoutToSelectedSlides (AutoLayout aLayout
);
191 /** Insert a new page with the given layout. The page is inserted via
192 the main view shell, i.e. its SID_INSERTPAGE slot is called. It it
193 does not support this slot then inserting a new page does not take
194 place. The new page is inserted after the currently active one (the
195 one returned by ViewShell::GetActualPage().)
197 void InsertPageWithLayout (AutoLayout aLayout
);
199 /** Create a request structure that can be used with the SID_INSERTPAGE
200 and SID_MODIFYPAGE slots. The parameters are set so that the given
201 layout is assigned to the current page of the main view shell.
203 Supported slots are SID_INSERTPAGE and SID_MODIFYPAGE.
205 Layout of the page to insert or to assign.
207 SfxRequest
CreateRequest (
211 /** Select the layout that is used by the current page.
213 void UpdateSelection (void);
216 void implConstruct( DrawDocShell
& rDocumentShell
);
218 /** When clicked then set the current page of the view in the center pane.
220 DECL_LINK(ClickHandler
, void *);
221 DECL_LINK(RightClickHandler
, MouseEvent
*);
222 DECL_LINK(StateChangeHandler
, void *);
223 DECL_LINK(EventMultiplexerListener
, ::sd::tools::EventMultiplexerEvent
*);
226 } } // end of namespace ::sd::toolpanel
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */