Update ooo320-m1
[ooovba.git] / sd / source / ui / toolpanel / LayoutMenu.hxx
blobf866ce46b2ccb8652e72b067673bb8e0cab942a7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: LayoutMenu.hxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_TASKPANE_LAYOUT_MENU_HXX
32 #define SD_TASKPANE_LAYOUT_MENU_HXX
34 #include "taskpane/TaskPaneTreeNode.hxx"
36 #ifndef _COM_SUN_STAR_FRAME_XSTATUS_LISTENER_HPP_
37 #include <com/sun/star/frame/XStatusListener.hpp>
38 #endif
40 #include "glob.hxx"
41 #include "pres.hxx"
42 #include <vcl/ctrl.hxx>
43 #include <svtools/valueset.hxx>
44 #include <svtools/transfer.hxx>
45 #include <sfx2/shell.hxx>
48 class SfxModule;
51 namespace sd {
52 class DrawDocShell;
53 class PaneManagerEvent;
54 class ViewShellBase;
58 namespace sd { namespace tools {
59 class EventMultiplexerEvent;
60 } }
63 namespace sd { namespace toolpanel {
65 class ControlFactory;
68 class LayoutMenu
69 : public ValueSet,
70 public TreeNode,
71 public SfxShell,
72 public DragSourceHelper,
73 public DropTargetHelper
75 public:
76 TYPEINFO();
77 SFX_DECL_INTERFACE(SD_IF_SDLAYOUTMENU)
79 /** Create a new layout menu. Depending on the given flag it
80 displays its own scroll bar or lets a surrounding window
81 handle that.
82 @param rDocumentShell
83 Used to determine writing direction.
84 @param rViewShellBase
85 Gives access to the view shell at whose active page the
86 layout will be set.
87 @param bUseOwnScrollBar
88 When <TRUE/> then we will show our own scroll bar when not
89 all icons can be displayed in the visible window area.
90 When <FALSE/> then rely on an outer scroll bar. In this
91 case we will set the height of the window so that all
92 icons are visible.
94 LayoutMenu (
95 TreeNode* pParent,
96 DrawDocShell& rDocumentShell,
97 ViewShellBase& rViewShellBase,
98 bool bUseOwnScrollBar);
99 virtual ~LayoutMenu (void);
101 static std::auto_ptr<ControlFactory> CreateControlFactory (
102 ViewShellBase& rBase,
103 DrawDocShell& rDocShell);
105 /** Return the name of the currently selected layout.
107 String GetSelectedLayoutName (void);
109 /** Return a numerical value representing the currently selected
110 layout.
112 AutoLayout GetSelectedAutoLayout (void);
115 // From ILayoutableWindow
116 virtual Size GetPreferredSize (void);
117 virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight);
118 virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
119 virtual sal_Int32 GetMinimumWidth (void);
120 virtual bool IsResizable (void);
121 virtual ::Window* GetWindow (void);
123 // From ::Window
124 virtual void Paint (const Rectangle& rRect);
125 virtual void Resize (void);
127 /** Show a context menu when the right mouse button is pressed.
129 virtual void MouseButtonDown (const MouseEvent& rEvent);
131 void Execute (SfxRequest& rRequest);
132 void GetState (SfxItemSet& rItemSet);
134 /** The LayoutMenu does not support some main views. In this case the
135 LayoutMenu is disabled. This state is updated in this method.
136 @param eMode
137 On some occasions the edit mode is being switched when this
138 method is called can not (yet) be reliably detected. Luckily,
139 in these cases the new value is provided by some broadcaster.
140 On other occasions the edit mode is not modified and is also not
141 provided. Therefore the Unknown value.
143 enum MasterMode { MM_NORMAL, MM_MASTER, MM_UNKNOWN };
144 void UpdateEnabledState (const MasterMode eMode);
146 /** Call this method when the set of displayed layouts is not up-to-date
147 anymore. It will re-assemple this set according to the current
148 settings.
150 void InvalidateContent (void);
152 // DragSourceHelper
153 virtual void StartDrag (sal_Int8 nAction, const Point& rPosPixel);
155 // DropTargetHelper
156 virtual sal_Int8 AcceptDrop (const AcceptDropEvent& rEvent);
157 virtual sal_Int8 ExecuteDrop (const ExecuteDropEvent& rEvent);
159 /** The context menu is requested over this Command() method.
161 virtual void Command (const CommandEvent& rEvent);
163 /** Call Fill() when switching to or from high contrast mode so that the
164 correct set of icons is displayed.
166 virtual void DataChanged (const DataChangedEvent& rEvent);
168 using Window::GetWindow;
169 using ValueSet::StartDrag;
171 private:
172 ViewShellBase& mrBase;
174 /** Do we use our own scroll bar or is viewport handling done by
175 our parent?
177 bool mbUseOwnScrollBar;
179 /** If we are asked for the preferred window size, then use this
180 many columns for the calculation.
182 const int mnPreferredColumnCount;
184 ::com::sun::star::uno::Reference<com::sun::star::frame::XStatusListener> mxListener;
186 bool mbSelectionUpdatePending;
188 bool mbIsMainViewChangePending;
190 /** Calculate the number of displayed rows. This depends on the given
191 item size, the given number of columns, and the size of the
192 control. Note that this is not the number of rows managed by the
193 valueset. This number may be larger. In that case a vertical
194 scroll bar is displayed.
196 int CalculateRowCount (const Size& rItemSize, int nColumnCount);
198 /** Fill the value set with the layouts that are applicable to the
199 current main view shell.
201 void Fill (void);
203 /** Remove all items from the value set.
205 void Clear (void);
207 /** Assign the given layout to all selected slides of a slide sorter.
208 If no slide sorter is active then this call is ignored. The slide
209 sorter in the center pane is preferred if the choice exists.
211 void AssignLayoutToSelectedSlides (AutoLayout aLayout);
213 /** Insert a new page with the given layout. The page is inserted via
214 the main view shell, i.e. its SID_INSERTPAGE slot is called. It it
215 does not support this slot then inserting a new page does not take
216 place. The new page is inserted after the currently active one (the
217 one returned by ViewShell::GetActualPage().)
219 void InsertPageWithLayout (AutoLayout aLayout);
221 /** Create a request structure that can be used with the SID_INSERTPAGE
222 and SID_MODIFYPAGE slots. The parameters are set so that the given
223 layout is assigned to the current page of the main view shell.
224 @param nSlotId
225 Supported slots are SID_INSERTPAGE and SID_MODIFYPAGE.
226 @param aLayout
227 Layout of the page to insert or to assign.
229 SfxRequest CreateRequest (
230 USHORT nSlotId,
231 AutoLayout aLayout);
233 /** Select the layout that is used by the current page.
235 void UpdateSelection (void);
237 /** When clicked then set the current page of the view in the center pane.
239 DECL_LINK(ClickHandler, ValueSet*);
240 DECL_LINK(RightClickHandler, MouseEvent*);
241 DECL_LINK(StateChangeHandler, ::rtl::OUString*);
242 DECL_LINK(EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*);
245 } } // end of namespace ::sd::toolpanel
247 #endif