fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / sfx2 / childwin.hxx
blobd0c5e50fce1f2b7eddc1536dafcb0834c2bf7d91
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #ifndef _SFX_CHILDWIN_HXX
20 #define _SFX_CHILDWIN_HXX
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>
28 #include <sfx2/shell.hxx>
29 #include <sfx2/chalign.hxx>
30 #include <boost/ptr_container/ptr_vector.hpp>
32 class SfxWorkWindow;
33 class SfxModule;
34 class SfxBindings;
35 class SfxShell;
36 class SfxChildWindow;
37 class SfxChildWindowContext;
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
50 // ChildWindow Configuration
51 struct SfxChildWinInfo
53 sal_Bool bVisible;
54 Point aPos;
55 Size aSize;
56 sal_uInt16 nFlags;
57 String aExtraString;
58 OString aWinState;
60 SfxChildWinInfo()
62 bVisible = sal_False;
63 nFlags = 0;
65 sal_Bool GetExtraData_Impl( SfxChildAlignment *pAlign,
66 SfxChildAlignment *pLastAlign = 0,
67 Size *pSize = 0,
68 sal_uInt16 *pLine = 0,
69 sal_uInt16 *pPos = 0 ) const;
72 // ChildWindow factory methods
73 typedef SfxChildWindow* (*SfxChildWinCtor)( ::Window *pParentWindow,
74 sal_uInt16 nId,
75 SfxBindings *pBindings,
76 SfxChildWinInfo *pInfo);
78 // ChildWindowsContexts factory methods
79 typedef SfxChildWindowContext* (*SfxChildWinContextCtor)( ::Window *pParentWindow,
80 SfxBindings *pBindings,
81 SfxChildWinInfo *pInfo);
82 struct SfxChildWinContextFactory
84 SfxChildWinContextCtor pCtor; // Factory method
85 sal_uInt16 nContextId; // Idenifier for SfxInterface
86 SfxChildWinInfo aInfo; // Configuration
88 SfxChildWinContextFactory( SfxChildWinContextCtor pTheCtor, sal_uInt16 nID )
89 : pCtor(pTheCtor)
90 , nContextId(nID)
94 typedef boost::ptr_vector<SfxChildWinContextFactory> SfxChildWinContextArr_Impl;
96 struct SfxChildWinFactory
98 SfxChildWinCtor pCtor; // Factory method
99 sal_uInt16 nId; // ChildWindow-Id ( SlotId )
100 SfxChildWinInfo aInfo; // Configuration
101 sal_uInt16 nPos; // Position in UI
102 SfxChildWinContextArr_Impl *pArr; // Array for Contexts
104 SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID,
105 sal_uInt16 n )
106 : pCtor(pTheCtor)
107 , nId( nID )
108 , nPos(n)
109 , pArr( NULL )
112 ~SfxChildWinFactory()
114 delete pArr;
119 class FloatingWindow;
120 struct SfxChildWindow_Impl;
121 class SFX2_DLLPUBLIC SfxChildWindowContext
123 friend class SfxChildWindow;
124 ::Window* pWindow;
125 sal_uInt16 nContextId;
127 protected:
128 SfxChildWindowContext( sal_uInt16 nId );
130 public:
131 virtual ~SfxChildWindowContext();
133 void SetWindow( ::Window* pWin )
134 { pWindow=pWin; }
135 ::Window* GetWindow() const
136 { return pWindow; }
137 sal_uInt16 GetContextId() const
138 { return nContextId; }
140 FloatingWindow* GetFloatingWindow() const;
142 virtual void Resizing( Size& rSize );
143 virtual sal_Bool Close();
144 static void RegisterChildWindowContext(SfxModule*, sal_uInt16, SfxChildWinContextFactory*);
147 class SFX2_DLLPUBLIC SfxChildWindow
149 ::Window* pParent; // parent window ( Topwindow )
150 sal_uInt16 nType; // ChildWindow-Id
152 protected:
153 SfxChildAlignment eChildAlignment; // Current ::com::sun::star::drawing::Alignment
154 ::Window* pWindow; // actual contents
155 SfxChildWindow_Impl* pImp; // Implementation data
157 private:
158 SfxChildWindowContext* pContext; // With context-sensitive ChildWindows:
159 // Annother window in pWindow
160 SAL_DLLPRIVATE SfxChildWindowContext*
161 GetContext() const
162 { return pContext; }
164 protected:
165 SfxChildWindow(::Window *pParentWindow, sal_uInt16 nId);
167 public:
168 virtual ~SfxChildWindow();
169 void Destroy();
170 ::Window* GetWindow() const
171 { return pWindow; }
172 ::Window* GetParent() const
173 { return pParent; }
174 SfxChildAlignment GetAlignment() const
175 { return eChildAlignment; }
176 void SetAlignment(SfxChildAlignment eAlign);
177 Size GetSizePixel() const
178 { return pWindow->GetSizePixel(); }
179 void SetPosSizePixel(const Point& rPoint, const Size& rSize)
180 { pWindow->SetPosSizePixel(rPoint, rSize); }
181 Point GetPosPixel()
182 { return pWindow->GetPosPixel(); }
183 virtual void Hide();
184 virtual void Show( sal_uInt16 nFlags );
185 sal_uInt16 GetFlags() const
186 { return GetInfo().nFlags; }
187 sal_Bool CanGetFocus() const;
188 sal_uInt16 GetPosition();
189 sal_uInt16 GetType()
190 { return nType; }
192 void CreateContext( sal_uInt16 nContextId, SfxBindings& );
193 sal_uInt16 GetContextId() const
194 { return pContext ? pContext->GetContextId(): 0; }
196 ::Window* GetContextWindow() const
197 { return pContext ? pContext->GetWindow(): 0; }
199 ::Window* GetContextWindow( SfxModule *pModule ) const;
201 virtual SfxChildWinInfo GetInfo() const;
202 void SaveStatus(const SfxChildWinInfo& rInfo);
204 static void RegisterChildWindow(SfxModule*, SfxChildWinFactory*);
206 static SfxChildWindow* CreateChildWindow( sal_uInt16, ::Window*, SfxBindings*, SfxChildWinInfo&);
207 void SetHideNotDelete( sal_Bool bOn );
208 sal_Bool IsHideNotDelete() const;
209 sal_Bool IsHideAtToggle() const;
210 sal_Bool IsVisible() const;
211 void SetWantsFocus( sal_Bool );
212 sal_Bool WantsFocus() const;
214 virtual sal_Bool QueryClose();
215 virtual com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrame();
216 void SetFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & );
218 SAL_DLLPRIVATE static void InitializeChildWinFactory_Impl(sal_uInt16, SfxChildWinInfo&);
219 SAL_DLLPRIVATE void SetVisible_Impl( sal_Bool bVis );
220 SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* );
221 SAL_DLLPRIVATE void Activate_Impl();
222 SAL_DLLPRIVATE void Deactivate_Impl();
224 SAL_DLLPRIVATE SfxChildWindowContext*
225 GetContext_Impl() const
226 { return pContext; }
227 SAL_DLLPRIVATE void SetFactory_Impl( SfxChildWinFactory* );
230 //------------------------------------------------------------------
231 //! soon obsolete !
232 #define SFX_DECL_CHILDWINDOW_CONTEXT(Class) \
233 static SfxChildWindowContext* CreateImpl(::Window *pParent, \
234 SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
235 static void RegisterChildWindowContext(SfxModule *pMod=0); \
237 //! The Macro of the future ...
238 #define SFX_DECL_CHILDWINDOWCONTEXT(Class) \
239 static SfxChildWindowContext* CreateImpl(::Window *pParent, \
240 SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
241 static void RegisterChildWindowContext(sal_uInt16, SfxModule *pMod=0); \
243 //! soon obsolete !
244 #define SFX_IMPL_CHILDWINDOW_CONTEXT(Class, MyID, ShellClass) \
245 SfxChildWindowContext* Class::CreateImpl( ::Window *pParent, \
246 SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
248 SfxChildWindowContext *pContext = new Class(pParent, \
249 /* cast is safe here! */static_cast< sal_uInt16 >(ShellClass::GetInterfaceId()), \
250 pBindings,pInfo); \
251 return pContext; \
253 void Class::RegisterChildWindowContext(SfxModule* pMod) \
255 SfxChildWinContextFactory *pFact = new SfxChildWinContextFactory( \
256 Class::CreateImpl, \
257 /* cast is safe here! */static_cast< sal_uInt16 >(ShellClass::GetInterfaceId()) ); \
258 SfxChildWindowContext::RegisterChildWindowContext(pMod, MyID, pFact); \
261 //! The Macro of the future ...
262 // As a parameter and because of ContextId, CreateImpl must be handed the
263 // factory. As long as Id is set to 0 and patched in
264 // SfxChildWindow::CreateContext
265 #define SFX_IMPL_CHILDWINDOWCONTEXT(Class, MyID) \
266 SfxChildWindowContext* Class::CreateImpl( ::Window *pParent, \
267 SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
269 SfxChildWindowContext *pContext = new Class(pParent,0,pBindings,pInfo);\
270 return pContext; \
272 void Class::RegisterChildWindowContext(sal_uInt16 nId, SfxModule* pMod) \
274 SfxChildWinContextFactory *pFact = new SfxChildWinContextFactory( \
275 Class::CreateImpl, nId ); \
276 SfxChildWindowContext::RegisterChildWindowContext(pMod, MyID, pFact); \
279 #define SFX_DECL_CHILDWINDOW(Class) \
280 public : \
281 static SfxChildWindow* CreateImpl(::Window *pParent, sal_uInt16 nId, \
282 SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
283 static void RegisterChildWindow (sal_Bool bVisible=sal_False, SfxModule *pMod=NULL, sal_uInt16 nFlags=0); \
284 virtual SfxChildWinInfo GetInfo() const
286 #define SFX_DECL_CHILDWINDOW_WITHID(Class) \
287 SFX_DECL_CHILDWINDOW(Class); \
288 static sal_uInt16 GetChildWindowId ()\
290 #define SFX_IMPL_CHILDWINDOW(Class, MyID) \
291 SFX_IMPL_POS_CHILDWINDOW(Class, MyID, CHILDWIN_NOPOS)
293 #define SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
294 SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, CHILDWIN_NOPOS)
296 #define SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
297 SfxChildWindow* Class::CreateImpl( ::Window *pParent, \
298 sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
300 SfxChildWindow *pWin = new Class(pParent, nId, pBindings, pInfo);\
301 return pWin; \
303 void Class::RegisterChildWindow (sal_Bool bVis, SfxModule *pMod, sal_uInt16 nFlags) \
305 SfxChildWinFactory *pFact = new SfxChildWinFactory( \
306 Class::CreateImpl, MyID, Pos ); \
307 pFact->aInfo.nFlags |= nFlags; \
308 pFact->aInfo.bVisible = bVis; \
309 SfxChildWindow::RegisterChildWindow(pMod, pFact); \
312 #define SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, Pos) \
313 SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
314 sal_uInt16 Class::GetChildWindowId () \
315 { return MyID; } \
317 #define SFX_IMPL_FLOATINGWINDOW(Class, MyID) \
318 SFX_IMPL_CHILDWINDOW(Class, MyID) \
319 SfxChildWinInfo Class::GetInfo() const \
321 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
322 ((SfxFloatingWindow*)GetWindow())->FillInfo( aInfo ); \
323 return aInfo; }
325 #define SFX_IMPL_FLOATINGWINDOW_WITHID(Class, MyID) \
326 SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
327 SfxChildWinInfo Class::GetInfo() const \
329 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
330 ((SfxFloatingWindow*)GetWindow())->FillInfo( aInfo ); \
331 return aInfo; }
333 #define SFX_IMPL_MODELESSDIALOG_WITHID(Class, MyID) \
334 SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
335 SfxChildWinInfo Class::GetInfo() const \
337 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
338 ((SfxModelessDialog*)GetWindow())->FillInfo( aInfo ); \
339 return aInfo; }
342 #define SFX_IMPL_DOCKINGWINDOW(Class, MyID) \
343 SFX_IMPL_CHILDWINDOW(Class, MyID) \
344 SfxChildWinInfo Class::GetInfo() const \
346 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
347 ((SfxDockingWindow*)GetWindow())->FillInfo( aInfo ); \
348 return aInfo; }
350 #define SFX_IMPL_DOCKINGWINDOW_WITHID(Class, MyID) \
351 SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
352 SfxChildWinInfo Class::GetInfo() const \
354 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
355 ((SfxDockingWindow*)GetWindow())->FillInfo( aInfo ); \
356 return aInfo; }
358 #define SFX_IMPL_TOOLBOX(Class, MyID) \
359 SFX_IMPL_CHILDWINDOW(Class, MyID) \
360 SfxChildWinInfo Class::GetInfo() const \
362 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
363 ((SfxToolbox*)GetWindow())->FillInfo( aInfo ); \
364 return aInfo; }
366 //------------------------------------------------------------------
368 #endif
370 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */