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 INCLUDED_SFX2_TASKPANE_HXX
21 : #define INCLUDED_SFX2_TASKPANE_HXX
22 :
23 : #include <sfx2/dllapi.h>
24 : #include <sfx2/childwin.hxx>
25 : #include <sfx2/titledockwin.hxx>
26 :
27 : #include <svtools/toolpanel/tabalignment.hxx>
28 : #include <svtools/toolpanel/tabitemcontent.hxx>
29 :
30 : #include <boost/scoped_ptr.hpp>
31 : #include <boost/optional.hpp>
32 :
33 : namespace svt
34 : {
35 : class ToolPanelDeck;
36 : }
37 :
38 :
39 : namespace sfx2
40 : {
41 :
42 :
43 :
44 : //= ITaskPaneToolPanelAccess
45 :
46 0 : class SAL_NO_VTABLE ITaskPaneToolPanelAccess
47 : {
48 : public:
49 : virtual void ActivateToolPanel( const OUString& i_rPanelURL ) = 0;
50 :
51 : protected:
52 0 : ~ITaskPaneToolPanelAccess() {}
53 : };
54 :
55 :
56 : //= TaskPaneWrapper
57 :
58 0 : class SFX2_DLLPUBLIC TaskPaneWrapper :public SfxChildWindow
59 : ,public ITaskPaneToolPanelAccess
60 : {
61 : public:
62 : TaskPaneWrapper(
63 : vcl::Window* i_pParent,
64 : sal_uInt16 i_nId,
65 : SfxBindings* i_pBindings,
66 : SfxChildWinInfo* i_pInfo
67 : );
68 :
69 : SFX_DECL_CHILDWINDOW( TaskPaneWrapper );
70 :
71 : // ITaskPaneToolPanelAccess
72 : virtual void ActivateToolPanel( const OUString& i_rPanelURL ) SAL_OVERRIDE;
73 : };
74 :
75 :
76 : //= IToolPanelCompare
77 :
78 : class SFX2_DLLPUBLIC SAL_NO_VTABLE IToolPanelCompare
79 : {
80 : public:
81 : /** compares to tool panel URLs
82 : @return
83 : <ul>
84 : <li>-1 if the tool panel described by i_rLHS should precede the one described by i_rRHS</li>
85 : <li>0 if the two panels have no particular relative order</li>
86 : <li>1 if the tool panel described by i_rLHS should succeed the one described by i_rRHS</li>
87 :
88 : */
89 : virtual short compareToolPanelsURLs(
90 : const OUString& i_rLHS,
91 : const OUString& i_rRHS
92 : ) const = 0;
93 :
94 : protected:
95 : ~IToolPanelCompare() {}
96 : };
97 :
98 :
99 : //= ModuleTaskPane
100 :
101 : class ModuleTaskPane_Impl;
102 : /** SFX-less version of a module dependent task pane, filled with tool panels as specified in the respective
103 : module's configuration
104 : */
105 : class SFX2_DLLPUBLIC ModuleTaskPane : public vcl::Window
106 : {
107 : public:
108 : /** creates a new instance
109 : @param i_rParentWindow
110 : the parent window
111 : @param i_rDocumentFrame
112 : the frame to which the task pane belongs. Will be passed to any custom tool panels created
113 : via an XUIElementFactory. Also, it is used to determine the module which the task pane is
114 : responsible for, thus controlling which tool panels are actually available.
115 : */
116 : ModuleTaskPane(
117 : vcl::Window& i_rParentWindow,
118 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rDocumentFrame
119 : );
120 : virtual ~ModuleTaskPane();
121 :
122 : /** determines whether a given module has any registered tool panels
123 : */
124 : static bool ModuleHasToolPanels( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rDocumentFrame );
125 :
126 : /** provides access to the Window aspect of the PanelDeck
127 :
128 : Be careful with this method. For instance, you're not allowed to insert arbitrary IToolPanel implementations
129 : into the deck, as the ModuleTaskPane has certain assumptions about the panel implementations. However,
130 : you're allowed to remove and re-insert panels, which have originally been created by the ModuleTaskPane
131 : itself.
132 : */
133 : ::svt::ToolPanelDeck& GetPanelDeck();
134 : const ::svt::ToolPanelDeck& GetPanelDeck() const;
135 :
136 : /** returns the position of the panel with the given resource URL
137 : */
138 : ::boost::optional< size_t >
139 : GetPanelPos( const OUString& i_rResourceURL );
140 :
141 : /// sets the "classical" layout of the tool panel deck, using drawers
142 : void SetDrawersLayout();
143 : /// sets the new layout of the tool panel deck, using tabs
144 : void SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent );
145 :
146 : protected:
147 : // Window overridables
148 : virtual void Resize() SAL_OVERRIDE;
149 : virtual void GetFocus() SAL_OVERRIDE;
150 :
151 : private:
152 : ::boost::scoped_ptr< ModuleTaskPane_Impl > m_pImpl;
153 : };
154 :
155 :
156 : //= TaskPaneController
157 :
158 : class TaskPaneController_Impl;
159 : /** is a helper class for connecting a ModuleTaskPane and a TitledDockingWindow, for clients of the ModuleTaskPane
160 : which do not use the TaskPaneDockingWindow
161 :
162 : The controller will add a drop down menu to the docking window which contains one item for each panel in the
163 : panel deck, and allows toggling their visibility.
164 : */
165 : class SFX2_DLLPUBLIC TaskPaneController
166 : {
167 : public:
168 : TaskPaneController(
169 : ModuleTaskPane& i_rTaskPane,
170 : TitledDockingWindow& i_rDockingWindow
171 : );
172 : ~TaskPaneController();
173 :
174 : /// activates the panel with the given URL
175 : void ActivateToolPanel( const OUString& i_rPanelURL );
176 :
177 : private:
178 : ::boost::scoped_ptr< TaskPaneController_Impl > m_pImpl;
179 : };
180 :
181 :
182 : //= TaskPaneDockingWindow
183 :
184 0 : class TaskPaneDockingWindow :public TitledDockingWindow
185 : ,public ITaskPaneToolPanelAccess
186 : {
187 : public:
188 : TaskPaneDockingWindow( SfxBindings* i_pBindings, TaskPaneWrapper& i_rWrapper,
189 : vcl::Window* i_pParent, WinBits i_nBits );
190 :
191 : // ITaskPaneToolPanelAccess
192 : virtual void ActivateToolPanel( const OUString& i_rPanelURL ) SAL_OVERRIDE;
193 :
194 : protected:
195 : // Window overridables
196 : virtual void GetFocus() SAL_OVERRIDE;
197 :
198 : // TitledDockingWindow overridables
199 : virtual void onLayoutDone() SAL_OVERRIDE;
200 :
201 : private:
202 : ModuleTaskPane m_aTaskPane;
203 : TaskPaneController m_aPaneController;
204 : };
205 :
206 :
207 : } // namespace sfx2
208 :
209 :
210 : #endif // INCLUDED_SFX2_TASKPANE_HXX
211 :
212 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|