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 : #ifndef INCLUDED_SFX2_CHILDWIN_HXX
20 : #define INCLUDED_SFX2_CHILDWIN_HXX
21 :
22 : #include <sal/config.h>
23 : #include <sfx2/dllapi.h>
24 : #include <sal/types.h>
25 : #include <vcl/window.hxx>
26 : #include <com/sun/star/frame/XFrame.hpp>
27 :
28 : #include <sfx2/shell.hxx>
29 : #include <sfx2/chalign.hxx>
30 : #include <boost/ptr_container/ptr_vector.hpp>
31 :
32 : class SfxWorkWindow;
33 : class SfxModule;
34 : class SfxBindings;
35 : class SfxShell;
36 : class SfxChildWindow;
37 : class SfxChildWindowContext;
38 :
39 : #define SFX_CHILDWIN_ZOOMIN 0x01 // Fully retracted Float
40 : #define SFX_CHILDWIN_SMALL 0x02 // Half retracted Float
41 : #define SFX_CHILDWIN_FORCEDOCK 0x04 // Float forbidden
42 : #define SFX_CHILDWIN_AUTOHIDE 0x08 // DockingWindow in AutoHide mode
43 : #define SFX_CHILDWIN_TASK 0x10 // ChildWindow inside the Task
44 : #define SFX_CHILDWIN_CANTGETFOCUS 0x20 // ChildWindow can not get focus
45 : #define SFX_CHILDWIN_ALWAYSAVAILABLE 0x40 // ChildWindow is never disabled
46 : #define SFX_CHILDWIN_NEVERHIDE 0x80 // ChildWindow is can always made
47 : // visible/is visible
48 : #define CHILDWIN_NOPOS USHRT_MAX
49 :
50 : // ChildWindow Configuration
51 586159 : struct SfxChildWinInfo
52 : {
53 : bool bVisible;
54 : Point aPos;
55 : Size aSize;
56 : sal_uInt16 nFlags;
57 : OUString aExtraString;
58 : OUString aModule;
59 : OString aWinState;
60 :
61 189325 : SfxChildWinInfo()
62 189325 : {
63 189325 : bVisible = false;
64 189325 : nFlags = 0;
65 189325 : }
66 : bool GetExtraData_Impl( SfxChildAlignment *pAlign,
67 : SfxChildAlignment *pLastAlign = 0,
68 : Size *pSize = 0,
69 : sal_uInt16 *pLine = 0,
70 : sal_uInt16 *pPos = 0 ) const;
71 : };
72 :
73 : // ChildWindow factory methods
74 : typedef SfxChildWindow* (*SfxChildWinCtor)( vcl::Window *pParentWindow,
75 : sal_uInt16 nId,
76 : SfxBindings *pBindings,
77 : SfxChildWinInfo *pInfo);
78 :
79 : // ChildWindowsContexts factory methods
80 : typedef SfxChildWindowContext* (*SfxChildWinContextCtor)( vcl::Window *pParentWindow,
81 : SfxBindings *pBindings,
82 : SfxChildWinInfo *pInfo);
83 100 : struct SfxChildWinContextFactory
84 : {
85 : SfxChildWinContextCtor pCtor; // Factory method
86 : sal_uInt16 nContextId; // Idenifier for SfxInterface
87 : SfxChildWinInfo aInfo; // Configuration
88 :
89 238 : SfxChildWinContextFactory( SfxChildWinContextCtor pTheCtor, sal_uInt16 nID )
90 : : pCtor(pTheCtor)
91 238 : , nContextId(nID)
92 238 : {}
93 : };
94 :
95 : typedef boost::ptr_vector<SfxChildWinContextFactory> SfxChildWinContextArr_Impl;
96 :
97 : struct SfxChildWinFactory
98 : {
99 : SfxChildWinCtor pCtor; // Factory method
100 : sal_uInt16 nId; // ChildWindow-Id ( SlotId )
101 : SfxChildWinInfo aInfo; // Configuration
102 : sal_uInt16 nPos; // Position in UI
103 : SfxChildWinContextArr_Impl *pArr; // Array for Contexts
104 :
105 10436 : SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID,
106 : sal_uInt16 n )
107 : : pCtor(pTheCtor)
108 : , nId( nID )
109 : , nPos(n)
110 10436 : , pArr( NULL )
111 10436 : {}
112 :
113 4486 : ~SfxChildWinFactory()
114 4486 : {
115 4486 : delete pArr;
116 4486 : }
117 :
118 : };
119 :
120 : class FloatingWindow;
121 : struct SfxChildWindow_Impl;
122 : class SFX2_DLLPUBLIC SfxChildWindowContext
123 : {
124 : friend class SfxChildWindow;
125 : vcl::Window* pWindow;
126 : sal_uInt16 nContextId;
127 :
128 : protected:
129 : SfxChildWindowContext( sal_uInt16 nId );
130 :
131 : public:
132 : virtual ~SfxChildWindowContext();
133 :
134 120 : void SetWindow( vcl::Window* pWin )
135 120 : { pWindow=pWin; }
136 490 : vcl::Window* GetWindow() const
137 490 : { return pWindow; }
138 270 : sal_uInt16 GetContextId() const
139 270 : { return nContextId; }
140 :
141 : FloatingWindow* GetFloatingWindow() const;
142 :
143 : virtual void Resizing( Size& rSize );
144 : virtual bool Close();
145 : static void RegisterChildWindowContext(SfxModule*, sal_uInt16, SfxChildWinContextFactory*);
146 : };
147 :
148 : class SFX2_DLLPUBLIC SfxChildWindow
149 : {
150 : vcl::Window* pParent; // parent window ( Topwindow )
151 : sal_uInt16 nType; // ChildWindow-Id
152 :
153 : protected:
154 : SfxChildAlignment eChildAlignment; // Current ::com::sun::star::drawing::Alignment
155 : vcl::Window* pWindow; // actual contents
156 : SfxChildWindow_Impl* pImp; // Implementation data
157 :
158 : private:
159 : SfxChildWindowContext* pContext; // With context-sensitive ChildWindows:
160 : // Annother window in pWindow
161 : SAL_DLLPRIVATE SfxChildWindowContext*
162 : GetContext() const
163 : { return pContext; }
164 :
165 : protected:
166 : SfxChildWindow(vcl::Window *pParentWindow, sal_uInt16 nId);
167 :
168 : public:
169 : virtual ~SfxChildWindow();
170 : void Destroy();
171 57311 : vcl::Window* GetWindow() const
172 57311 : { return pWindow; }
173 5406 : vcl::Window* GetParent() const
174 5406 : { return pParent; }
175 79186 : SfxChildAlignment GetAlignment() const
176 79186 : { return eChildAlignment; }
177 : void SetAlignment(SfxChildAlignment eAlign);
178 0 : Size GetSizePixel() const
179 0 : { return pWindow->GetSizePixel(); }
180 : void SetPosSizePixel(const Point& rPoint, const Size& rSize)
181 : { pWindow->SetPosSizePixel(rPoint, rSize); }
182 : Point GetPosPixel()
183 : { return pWindow->GetPosPixel(); }
184 : virtual void Hide();
185 : virtual void Show( sal_uInt16 nFlags );
186 : sal_uInt16 GetFlags() const
187 : { return GetInfo().nFlags; }
188 : bool CanGetFocus() const;
189 : sal_uInt16 GetPosition();
190 92649 : sal_uInt16 GetType()
191 92649 : { return nType; }
192 :
193 : void CreateContext( sal_uInt16 nContextId, SfxBindings& );
194 24061 : sal_uInt16 GetContextId() const
195 24061 : { return pContext ? pContext->GetContextId(): 0; }
196 :
197 242 : vcl::Window* GetContextWindow() const
198 242 : { return pContext ? pContext->GetWindow(): 0; }
199 :
200 : vcl::Window* GetContextWindow( SfxModule *pModule ) const;
201 :
202 : virtual SfxChildWinInfo GetInfo() const;
203 : void SaveStatus(const SfxChildWinInfo& rInfo);
204 :
205 : static void RegisterChildWindow(SfxModule*, SfxChildWinFactory*);
206 :
207 : static SfxChildWindow* CreateChildWindow( sal_uInt16, vcl::Window*, SfxBindings*, SfxChildWinInfo&);
208 : void SetHideNotDelete( bool bOn );
209 : bool IsHideNotDelete() const;
210 : bool IsHideAtToggle() const;
211 : bool IsVisible() const;
212 : void SetWantsFocus( bool );
213 : bool WantsFocus() const;
214 :
215 : virtual bool QueryClose();
216 : virtual com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrame();
217 : void SetFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & );
218 :
219 : SAL_DLLPRIVATE static void InitializeChildWinFactory_Impl(sal_uInt16, SfxChildWinInfo&);
220 : SAL_DLLPRIVATE void SetVisible_Impl( bool bVis );
221 : SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* );
222 : SAL_DLLPRIVATE void Activate_Impl();
223 : SAL_DLLPRIVATE void Deactivate_Impl();
224 :
225 : SAL_DLLPRIVATE SfxChildWindowContext*
226 0 : GetContext_Impl() const
227 0 : { return pContext; }
228 : SAL_DLLPRIVATE void SetFactory_Impl( SfxChildWinFactory* );
229 : };
230 :
231 :
232 : //! soon obsolete !
233 : #define SFX_DECL_CHILDWINDOW_CONTEXT(Class) \
234 : static SfxChildWindowContext* CreateImpl(vcl::Window *pParent, \
235 : SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
236 : static void RegisterChildWindowContext(SfxModule *pMod=0); \
237 :
238 : //! The Macro of the future ...
239 : #define SFX_DECL_CHILDWINDOWCONTEXT(Class) \
240 : static SfxChildWindowContext* CreateImpl(vcl::Window *pParent, \
241 : SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
242 : static void RegisterChildWindowContext(sal_uInt16, SfxModule *pMod=0); \
243 :
244 : //! soon obsolete !
245 : #define SFX_IMPL_CHILDWINDOW_CONTEXT(Class, MyID, ShellClass) \
246 : SfxChildWindowContext* Class::CreateImpl( vcl::Window *pParent, \
247 : SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
248 : { \
249 : SfxChildWindowContext *pContext = new Class(pParent, \
250 : /* cast is safe here! */static_cast< sal_uInt16 >(ShellClass::GetInterfaceId()), \
251 : pBindings,pInfo); \
252 : return pContext; \
253 : } \
254 : void Class::RegisterChildWindowContext(SfxModule* pMod) \
255 : { \
256 : SfxChildWinContextFactory *pFact = new SfxChildWinContextFactory( \
257 : Class::CreateImpl, \
258 : /* cast is safe here! */static_cast< sal_uInt16 >(ShellClass::GetInterfaceId()) ); \
259 : SfxChildWindowContext::RegisterChildWindowContext(pMod, MyID, pFact); \
260 : }
261 :
262 : //! The Macro of the future ...
263 : // As a parameter and because of ContextId, CreateImpl must be handed the
264 : // factory. As long as Id is set to 0 and patched in
265 : // SfxChildWindow::CreateContext
266 : #define SFX_IMPL_CHILDWINDOWCONTEXT(Class, MyID) \
267 : SfxChildWindowContext* Class::CreateImpl( vcl::Window *pParent, \
268 : SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
269 : { \
270 : SfxChildWindowContext *pContext = new Class(pParent,0,pBindings,pInfo);\
271 : return pContext; \
272 : } \
273 : void Class::RegisterChildWindowContext(sal_uInt16 nId, SfxModule* pMod) \
274 : { \
275 : SfxChildWinContextFactory *pFact = new SfxChildWinContextFactory( \
276 : Class::CreateImpl, nId ); \
277 : SfxChildWindowContext::RegisterChildWindowContext(pMod, MyID, pFact); \
278 : }
279 :
280 : #define SFX_DECL_CHILDWINDOW(Class) \
281 : public : \
282 : static SfxChildWindow* CreateImpl(vcl::Window *pParent, sal_uInt16 nId, \
283 : SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
284 : static void RegisterChildWindow (bool bVisible=false, SfxModule *pMod=NULL, sal_uInt16 nFlags=0); \
285 : virtual SfxChildWinInfo GetInfo() const SAL_OVERRIDE
286 :
287 : #define SFX_DECL_CHILDWINDOW_WITHID(Class) \
288 : SFX_DECL_CHILDWINDOW(Class); \
289 : static sal_uInt16 GetChildWindowId ()\
290 :
291 : #define SFX_IMPL_CHILDWINDOW(Class, MyID) \
292 : SFX_IMPL_POS_CHILDWINDOW(Class, MyID, CHILDWIN_NOPOS)
293 :
294 : #define SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
295 : SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, CHILDWIN_NOPOS)
296 :
297 : #define SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
298 : SfxChildWindow* Class::CreateImpl( vcl::Window *pParent, \
299 : sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
300 : { \
301 : SfxChildWindow *pWin = new Class(pParent, nId, pBindings, pInfo);\
302 : return pWin; \
303 : } \
304 : void Class::RegisterChildWindow (bool bVis, SfxModule *pMod, sal_uInt16 nFlags) \
305 : { \
306 : SfxChildWinFactory *pFact = new SfxChildWinFactory( \
307 : Class::CreateImpl, MyID, Pos ); \
308 : pFact->aInfo.nFlags |= nFlags; \
309 : pFact->aInfo.bVisible = bVis; \
310 : SfxChildWindow::RegisterChildWindow(pMod, pFact); \
311 : }
312 :
313 : #define SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, Pos) \
314 : SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
315 : sal_uInt16 Class::GetChildWindowId () \
316 : { return MyID; } \
317 :
318 : #define SFX_IMPL_FLOATINGWINDOW(Class, MyID) \
319 : SFX_IMPL_CHILDWINDOW(Class, MyID) \
320 : SfxChildWinInfo Class::GetInfo() const \
321 : { \
322 : SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
323 : static_cast<SfxFloatingWindow*>(GetWindow())->FillInfo( aInfo ); \
324 : return aInfo; }
325 :
326 : #define SFX_IMPL_FLOATINGWINDOW_WITHID(Class, MyID) \
327 : SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
328 : SfxChildWinInfo Class::GetInfo() const \
329 : { \
330 : SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
331 : static_cast<SfxFloatingWindow*>(GetWindow())->FillInfo( aInfo ); \
332 : return aInfo; }
333 :
334 : #define SFX_IMPL_MODELESSDIALOG_WITHID(Class, MyID) \
335 : SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
336 : SfxChildWinInfo Class::GetInfo() const \
337 : { \
338 : SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
339 : static_cast<SfxModelessDialog*>(GetWindow())->FillInfo( aInfo ); \
340 : return aInfo; }
341 :
342 :
343 : #define SFX_IMPL_DOCKINGWINDOW(Class, MyID) \
344 : SFX_IMPL_CHILDWINDOW(Class, MyID) \
345 : SfxChildWinInfo Class::GetInfo() const \
346 : { \
347 : SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
348 : static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo ); \
349 : return aInfo; }
350 :
351 : #define SFX_IMPL_DOCKINGWINDOW_WITHID(Class, MyID) \
352 : SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
353 : SfxChildWinInfo Class::GetInfo() const \
354 : { \
355 : SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
356 : static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo ); \
357 : return aInfo; }
358 :
359 : #define SFX_IMPL_TOOLBOX(Class, MyID) \
360 : SFX_IMPL_CHILDWINDOW(Class, MyID) \
361 : SfxChildWinInfo Class::GetInfo() const \
362 : { \
363 : SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
364 : static_cast<SfxToolbox*>(GetWindow())->FillInfo( aInfo ); \
365 : return aInfo; }
366 :
367 : bool GetPosSizeFromString( const OUString& rStr, Point& rPos, Size& rSize );
368 :
369 : bool GetSplitSizeFromString( const OUString& rStr, Size& rSize );
370 :
371 : #endif
372 :
373 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|