Don't search for old (<= 2.0) .NET SDK anymore
[LibreOffice.git] / include / sfx2 / childwin.hxx
blob3059d38a5cbb4cbfe95b1172201de000a846b3ad
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 INCLUDED_SFX2_CHILDWIN_HXX
20 #define INCLUDED_SFX2_CHILDWIN_HXX
22 #include <memory>
23 #include <sal/config.h>
25 #include <sfx2/dllapi.h>
26 #include <sal/types.h>
27 #include <o3tl/typed_flags_set.hxx>
28 #include <vcl/window.hxx>
29 #include <com/sun/star/frame/XFrame.hpp>
31 #include <sfx2/shell.hxx>
32 #include <sfx2/chalign.hxx>
34 #include <sfx2/bindings.hxx>
35 // complete SfxBindings for complete SfxChildWinCtor, SfxChildWinContextCtor
36 // under -fsanitize=function
38 class SfxWorkWindow;
39 class SfxModule;
40 class SfxShell;
41 class SfxChildWindow;
42 class SfxChildWindowContext;
44 enum class SfxChildWindowFlags
46 NONE = 0x00,
47 ZOOMIN = 0x01, // Fully retracted Float
48 FORCEDOCK = 0x04, // Float forbidden
49 TASK = 0x10, // ChildWindow inside the Task
50 CANTGETFOCUS = 0x20, // ChildWindow can not get focus
51 ALWAYSAVAILABLE = 0x40, // ChildWindow is never disabled
52 NEVERHIDE = 0x80 // ChildWindow is can always made
53 // visible/is visible
56 namespace o3tl
58 template<> struct typed_flags<SfxChildWindowFlags> : is_typed_flags<SfxChildWindowFlags, 0xf5> {};
62 #define CHILDWIN_NOPOS USHRT_MAX
64 // ChildWindow Configuration
65 struct SAL_DLLPUBLIC_RTTI SfxChildWinInfo
67 bool bVisible;
68 Point aPos;
69 Size aSize;
70 SfxChildWindowFlags nFlags;
71 OUString aExtraString;
72 OUString aModule;
73 OString aWinState;
75 SfxChildWinInfo()
77 bVisible = false;
78 nFlags = SfxChildWindowFlags::NONE;
80 bool GetExtraData_Impl( SfxChildAlignment *pAlign ) const;
83 // ChildWindow factory methods
84 typedef SfxChildWindow* (*SfxChildWinCtor)( vcl::Window *pParentWindow,
85 sal_uInt16 nId,
86 SfxBindings *pBindings,
87 SfxChildWinInfo *pInfo);
89 // ChildWindowsContexts factory methods
90 typedef SfxChildWindowContext* (*SfxChildWinContextCtor)( vcl::Window *pParentWindow,
91 SfxBindings *pBindings,
92 SfxChildWinInfo *pInfo);
93 struct SfxChildWinContextFactory
95 SfxChildWinContextCtor pCtor; // Factory method
96 sal_uInt16 nContextId; // Identifier for SfxInterface
98 SfxChildWinContextFactory( SfxChildWinContextCtor pTheCtor, sal_uInt16 nID )
99 : pCtor(pTheCtor)
100 , nContextId(nID)
104 class SfxChildWinContextArr_Impl;
106 struct SFX2_DLLPUBLIC SfxChildWinFactory
108 SfxChildWinCtor pCtor; // Factory method
109 sal_uInt16 nId; // ChildWindow-Id ( SlotId )
110 SfxChildWinInfo aInfo; // Configuration
111 sal_uInt16 nPos; // Position in UI
112 std::unique_ptr<SfxChildWinContextArr_Impl> pArr; // Array for Contexts
114 SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID, sal_uInt16 n );
115 ~SfxChildWinFactory();
118 class FloatingWindow;
119 struct SfxChildWindow_Impl;
120 class SFX2_DLLPUBLIC SfxChildWindowContext
122 friend class SfxChildWindow;
123 VclPtr<vcl::Window> pWindow;
124 sal_uInt16 nContextId;
126 protected:
127 SfxChildWindowContext( sal_uInt16 nId );
129 public:
130 virtual ~SfxChildWindowContext();
132 void SetWindow( vcl::Window* pWin )
133 { pWindow=pWin; }
134 vcl::Window* GetWindow() const
135 { return pWindow; }
136 sal_uInt16 GetContextId() const
137 { return nContextId; }
139 static FloatingWindow* GetFloatingWindow(vcl::Window *pParent);
141 static void RegisterChildWindowContext(SfxModule*, sal_uInt16, SfxChildWinContextFactory*);
144 class SFX2_DLLPUBLIC SfxChildWindow
146 VclPtr<vcl::Window> pParent; // parent window ( Topwindow )
147 sal_uInt16 nType; // ChildWindow-Id
148 VclPtr<vcl::Window> pWindow; // actual contents
149 SfxChildAlignment eChildAlignment; // Current css::drawing::Alignment
150 std::unique_ptr< SfxChildWindow_Impl> pImpl; // Implementation data
151 std::unique_ptr<SfxChildWindowContext> pContext; // With context-sensitive ChildWindows:
152 // Another window in pWindow
153 SAL_DLLPRIVATE void ClearWorkwin();
155 protected:
156 void SetWindow(const VclPtr<vcl::Window>& p) { pWindow = p; }
157 SfxChildWindow(vcl::Window *pParentWindow, sal_uInt16 nId);
159 public:
160 virtual ~SfxChildWindow();
161 void Destroy();
162 vcl::Window* GetWindow() const
163 { return pWindow; }
164 vcl::Window* GetParent() const
165 { return pParent; }
166 SfxChildAlignment GetAlignment() const
167 { return eChildAlignment; }
168 void SetAlignment(SfxChildAlignment eAlign);
169 Size GetSizePixel() const
170 { return pWindow->GetSizePixel(); }
171 virtual void Hide();
172 virtual void Show( ShowFlags nFlags );
173 sal_uInt16 GetPosition();
174 sal_uInt16 GetType()
175 { return nType; }
177 void CreateContext( sal_uInt16 nContextId, SfxBindings& );
178 sal_uInt16 GetContextId() const
179 { return pContext ? pContext->GetContextId(): 0; }
181 vcl::Window* GetContextWindow() const
182 { return pContext ? pContext->GetWindow(): nullptr; }
184 vcl::Window* GetContextWindow( SfxModule const *pModule ) const;
186 virtual SfxChildWinInfo GetInfo() const;
187 void SaveStatus(const SfxChildWinInfo& rInfo);
189 static void RegisterChildWindow(SfxModule*, SfxChildWinFactory*);
191 static SfxChildWindow* CreateChildWindow( sal_uInt16, vcl::Window*, SfxBindings*, SfxChildWinInfo const &);
192 void SetHideNotDelete( bool bOn );
193 bool IsHideNotDelete() const;
194 bool IsVisible() const;
195 void SetWantsFocus( bool );
196 bool WantsFocus() const;
198 virtual bool QueryClose();
199 const css::uno::Reference< css::frame::XFrame >& GetFrame();
200 void SetFrame( const css::uno::Reference< css::frame::XFrame > & );
202 SAL_DLLPRIVATE static void InitializeChildWinFactory_Impl(sal_uInt16, SfxChildWinInfo&);
203 void SetVisible_Impl( bool bVis );
204 SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* );
205 SAL_DLLPRIVATE void Activate_Impl();
207 SAL_DLLPRIVATE SfxChildWindowContext*
208 GetContext_Impl() const
209 { return pContext.get(); }
210 SAL_DLLPRIVATE void SetFactory_Impl( SfxChildWinFactory* );
214 //! The Macro of the future ...
215 #define SFX_DECL_CHILDWINDOWCONTEXT(Class) \
216 static SfxChildWindowContext* CreateImpl(vcl::Window *pParent, \
217 SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
218 static void RegisterChildWindowContext(sal_uInt16, SfxModule *pMod=nullptr); \
220 //! The Macro of the future ...
221 // As a parameter and because of ContextId, CreateImpl must be handed the
222 // factory. As long as Id is set to 0 and patched in
223 // SfxChildWindow::CreateContext
224 #define SFX_IMPL_CHILDWINDOWCONTEXT(Class, MyID) \
225 SfxChildWindowContext* Class::CreateImpl( vcl::Window *pParent, \
226 SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
228 SfxChildWindowContext *pContext = new Class(pParent,0,pBindings,pInfo);\
229 return pContext; \
231 void Class::RegisterChildWindowContext(sal_uInt16 nId, SfxModule* pMod) \
233 SfxChildWinContextFactory *pFact = new SfxChildWinContextFactory( \
234 Class::CreateImpl, nId ); \
235 SfxChildWindowContext::RegisterChildWindowContext(pMod, MyID, pFact); \
238 #define SFX_DECL_CHILDWINDOW(Class) \
239 public : \
240 static SfxChildWindow* CreateImpl(vcl::Window *pParent, sal_uInt16 nId, \
241 SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
242 static void RegisterChildWindow (bool bVisible=false, SfxModule *pMod=nullptr, SfxChildWindowFlags nFlags=SfxChildWindowFlags::NONE); \
243 virtual SfxChildWinInfo GetInfo() const override
245 #define SFX_DECL_CHILDWINDOW_WITHID(Class) \
246 SFX_DECL_CHILDWINDOW(Class); \
247 static sal_uInt16 GetChildWindowId ()\
249 #define SFX_IMPL_CHILDWINDOW(Class, MyID) \
250 SFX_IMPL_POS_CHILDWINDOW(Class, MyID, CHILDWIN_NOPOS)
252 #define SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
253 SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, CHILDWIN_NOPOS)
255 #define SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
256 SfxChildWindow* Class::CreateImpl( vcl::Window *pParent, \
257 sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
259 SfxChildWindow *pWin = new Class(pParent, nId, pBindings, pInfo);\
260 return pWin; \
262 void Class::RegisterChildWindow (bool bVis, SfxModule *pMod, SfxChildWindowFlags nFlags) \
264 SfxChildWinFactory *pFact = new SfxChildWinFactory( \
265 Class::CreateImpl, MyID, Pos ); \
266 pFact->aInfo.nFlags |= nFlags; \
267 pFact->aInfo.bVisible = bVis; \
268 SfxChildWindow::RegisterChildWindow(pMod, pFact); \
271 #define SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, Pos) \
272 SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
273 sal_uInt16 Class::GetChildWindowId () \
274 { return MyID; } \
276 #define SFX_IMPL_FLOATINGWINDOW(Class, MyID) \
277 SFX_IMPL_CHILDWINDOW(Class, MyID) \
278 SfxChildWinInfo Class::GetInfo() const \
280 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
281 static_cast<SfxFloatingWindow*>(GetWindow())->FillInfo( aInfo ); \
282 return aInfo; }
284 #define SFX_IMPL_FLOATINGWINDOW_WITHID(Class, MyID) \
285 SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
286 SfxChildWinInfo Class::GetInfo() const \
288 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
289 static_cast<SfxFloatingWindow*>(GetWindow())->FillInfo( aInfo ); \
290 return aInfo; }
292 #define SFX_IMPL_MODELESSDIALOG_WITHID(Class, MyID) \
293 SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
294 SfxChildWinInfo Class::GetInfo() const \
296 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
297 static_cast<SfxModelessDialog*>(GetWindow())->FillInfo( aInfo ); \
298 return aInfo; }
301 #define SFX_IMPL_DOCKINGWINDOW(Class, MyID) \
302 SFX_IMPL_CHILDWINDOW(Class, MyID) \
303 SfxChildWinInfo Class::GetInfo() const \
305 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
306 static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo ); \
307 return aInfo; }
309 #define SFX_IMPL_DOCKINGWINDOW_WITHID(Class, MyID) \
310 SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
311 SfxChildWinInfo Class::GetInfo() const \
313 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
314 static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo ); \
315 return aInfo; }
317 bool GetPosSizeFromString( const OUString& rStr, Point& rPos, Size& rSize );
319 bool GetSplitSizeFromString( const OUString& rStr, Size& rSize );
321 #endif
323 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */