Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef SD_TASKPANE_LAYOUT_MENU_HXX
21 : #define SD_TASKPANE_LAYOUT_MENU_HXX
22 :
23 : #include "taskpane/TaskPaneTreeNode.hxx"
24 :
25 : #include <com/sun/star/frame/XStatusListener.hpp>
26 :
27 : #include "glob.hxx"
28 : #include "pres.hxx"
29 : #include <vcl/ctrl.hxx>
30 : #include <svtools/valueset.hxx>
31 : #include <svtools/transfer.hxx>
32 : #include <sfx2/shell.hxx>
33 :
34 :
35 : class SfxModule;
36 :
37 :
38 : namespace sd {
39 : class DrawDocShell;
40 : class ViewShellBase;
41 : }
42 :
43 :
44 : namespace sd { namespace tools {
45 : class EventMultiplexerEvent;
46 : } }
47 :
48 :
49 : namespace sd { namespace toolpanel {
50 :
51 : class ControlFactory;
52 : class ToolPanelViewShell;
53 :
54 :
55 : class LayoutMenu
56 : : public ValueSet,
57 : public TreeNode,
58 : public SfxShell,
59 : public DragSourceHelper,
60 : public DropTargetHelper
61 : {
62 : public:
63 : TYPEINFO();
64 3 : SFX_DECL_INTERFACE(SD_IF_SDLAYOUTMENU)
65 :
66 : /** Create a new layout menu. Depending on the given flag it
67 : displays its own scroll bar or lets a surrounding window
68 : handle that.
69 : @param i_pParent
70 : the parent node in the control tree
71 : @param i_rPanelViewShell
72 : the view shell of the task pane.
73 : */
74 : LayoutMenu (
75 : TreeNode* i_pParent,
76 : ToolPanelViewShell& i_rPanelViewShell);
77 : virtual ~LayoutMenu (void);
78 :
79 : static std::auto_ptr<ControlFactory> CreateControlFactory (
80 : ToolPanelViewShell& i_rPanelViewShell );
81 :
82 : /** Return a numerical value representing the currently selected
83 : layout.
84 : */
85 : AutoLayout GetSelectedAutoLayout (void);
86 :
87 :
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);
95 :
96 : // From ::Window
97 : virtual void Paint (const Rectangle& rRect);
98 : virtual void Resize (void);
99 :
100 : /** Show a context menu when the right mouse button is pressed.
101 : */
102 : virtual void MouseButtonDown (const MouseEvent& rEvent);
103 :
104 : void Execute (SfxRequest& rRequest);
105 : void GetState (SfxItemSet& rItemSet);
106 :
107 : /** The LayoutMenu does not support some main views. In this case the
108 : LayoutMenu is disabled. This state is updated in this method.
109 : @param eMode
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.
115 : */
116 : enum MasterMode { MM_NORMAL, MM_MASTER, MM_UNKNOWN };
117 : void UpdateEnabledState (const MasterMode eMode);
118 :
119 : // TreeNode overridables
120 : virtual TaskPaneShellManager* GetShellManager (void);
121 :
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
124 : settings.
125 : */
126 : void InvalidateContent (void);
127 :
128 : // DragSourceHelper
129 : virtual void StartDrag (sal_Int8 nAction, const Point& rPosPixel);
130 :
131 : // DropTargetHelper
132 : virtual sal_Int8 AcceptDrop (const AcceptDropEvent& rEvent);
133 : virtual sal_Int8 ExecuteDrop (const ExecuteDropEvent& rEvent);
134 :
135 : /** The context menu is requested over this Command() method.
136 : */
137 : virtual void Command (const CommandEvent& rEvent);
138 :
139 : /** Call Fill() when switching to or from high contrast mode so that the
140 : correct set of icons is displayed.
141 : */
142 : virtual void DataChanged (const DataChangedEvent& rEvent);
143 :
144 : using Window::GetWindow;
145 : using ValueSet::StartDrag;
146 :
147 : private:
148 : ViewShellBase& mrBase;
149 :
150 : TaskPaneShellManager* mpShellManager;
151 :
152 : /** Do we use our own scroll bar or is viewport handling done by
153 : our parent?
154 : */
155 : bool mbUseOwnScrollBar;
156 :
157 : /** If we are asked for the preferred window size, then use this
158 : many columns for the calculation.
159 : */
160 : const int mnPreferredColumnCount;
161 :
162 : ::com::sun::star::uno::Reference<com::sun::star::frame::XStatusListener> mxListener;
163 :
164 : bool mbSelectionUpdatePending;
165 :
166 : bool mbIsMainViewChangePending;
167 :
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.
173 : */
174 : int CalculateRowCount (const Size& rItemSize, int nColumnCount);
175 :
176 : /** Fill the value set with the layouts that are applicable to the
177 : current main view shell.
178 : */
179 : void Fill (void);
180 :
181 : /** Remove all items from the value set.
182 : */
183 : void Clear (void);
184 :
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.
188 : */
189 : void AssignLayoutToSelectedSlides (AutoLayout aLayout);
190 :
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().)
196 : */
197 : void InsertPageWithLayout (AutoLayout aLayout);
198 :
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.
202 : @param nSlotId
203 : Supported slots are SID_INSERTPAGE and SID_MODIFYPAGE.
204 : @param aLayout
205 : Layout of the page to insert or to assign.
206 : */
207 : SfxRequest CreateRequest (
208 : sal_uInt16 nSlotId,
209 : AutoLayout aLayout);
210 :
211 : /** Select the layout that is used by the current page.
212 : */
213 : void UpdateSelection (void);
214 :
215 : // internal ctor
216 : void implConstruct( DrawDocShell& rDocumentShell );
217 :
218 : /** When clicked then set the current page of the view in the center pane.
219 : */
220 : DECL_LINK(ClickHandler, void *);
221 : DECL_LINK(RightClickHandler, MouseEvent*);
222 : DECL_LINK(StateChangeHandler, void *);
223 : DECL_LINK(EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*);
224 : };
225 :
226 : } } // end of namespace ::sd::toolpanel
227 :
228 : #endif
229 :
230 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|