LibreOffice Module sfx2 (master) 1
childwin.hxx
Go to the documentation of this file.
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 <memory>
23#include <sal/config.h>
24
25#include <sfx2/dllapi.h>
26#include <sal/types.h>
28#include <vcl/window.hxx>
29
30#include <sfx2/chalign.hxx>
31#include <sfx2/basedlgs.hxx>
32
33namespace com::sun::star::frame { class XFrame; }
34
35class SfxWorkWindow;
36class SfxModule;
37class SfxChildWindow;
38class SfxBindings;
40
42{
43 NONE = 0x000,
44 FORCEDOCK = 0x004, // Float forbidden
45 TASK = 0x010, // ChildWindow inside the Task
46 CANTGETFOCUS = 0x020, // ChildWindow can not get focus
47 ALWAYSAVAILABLE = 0x040, // ChildWindow is never disabled
48 NEVERHIDE = 0x080, // ChildWindow is always visible
49 NEVERCLONE = 0x100, // ChildWindow is not recreated in new view
50};
51
52namespace o3tl
53{
54 template<> struct typed_flags<SfxChildWindowFlags> : is_typed_flags<SfxChildWindowFlags, 0x1f4> {};
55}
56
57
58#define CHILDWIN_NOPOS USHRT_MAX
59
60// ChildWindow Configuration
61struct SAL_DLLPUBLIC_RTTI SfxChildWinInfo
62{
63 OUString aExtraString;
64 OUString aModule;
65 OUString aWinState;
70
72 {
73 bVisible = false;
75 }
76 bool GetExtraData_Impl( SfxChildAlignment *pAlign ) const;
77};
78
79// ChildWindow factory methods
80typedef std::unique_ptr<SfxChildWindow> (*SfxChildWinCtor)( vcl::Window *pParentWindow,
81 sal_uInt16 nId,
82 SfxBindings *pBindings,
83 SfxChildWinInfo *pInfo);
84
86{
87 SfxChildWinCtor pCtor; // Factory method
88 SfxChildWinInfo aInfo; // Configuration
89 sal_uInt16 nId; // ChildWindow-Id ( SlotId )
90 sal_uInt16 nPos; // Position in UI
91
92 SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID, sal_uInt16 n );
93};
94
96
97extern SFX2_DLLPUBLIC bool ParentIsFloatingWindow(const vcl::Window *pParent);
98
100{
101 VclPtr<vcl::Window> pParent; // parent window ( Topwindow )
102 VclPtr<vcl::Window> pWindow; // actual contents
103 std::unique_ptr< SfxChildWindow_Impl> pImpl; // Implementation data
104 std::shared_ptr<SfxDialogController> xController; // actual contents
105 SfxChildAlignment eChildAlignment; // Current css::drawing::Alignment
106 // Another window in pWindow
107 sal_uInt16 nType; // ChildWindow-Id
108 SAL_DLLPRIVATE void ClearWorkwin();
109
110protected:
111 void SetWindow(const VclPtr<vcl::Window>& p) { pWindow = p; }
112 SfxChildWindow(vcl::Window *pParentWindow, sal_uInt16 nId);
113
114public:
115 virtual ~SfxChildWindow();
116 void Destroy();
118 { return pWindow; }
119 void SetController(std::shared_ptr<SfxDialogController> controller) { xController = controller; }
120 void ClearController() { xController.reset(); }
121 std::shared_ptr<SfxDialogController>& GetController() { return xController; }
122 const std::shared_ptr<SfxDialogController>& GetController() const { return xController; }
124 { return pParent; }
126 { return eChildAlignment; }
127 void SetAlignment(SfxChildAlignment eAlign);
128 virtual void Hide();
129 virtual void Show( ShowFlags nFlags );
130 sal_uInt16 GetPosition() const;
131 sal_uInt16 GetType() const
132 { return nType; }
133
134 virtual SfxChildWinInfo GetInfo() const;
135 void SaveStatus(const SfxChildWinInfo& rInfo);
136
137 static void RegisterChildWindow(SfxModule*, const SfxChildWinFactory&);
138
139 static std::unique_ptr<SfxChildWindow> CreateChildWindow( sal_uInt16, vcl::Window*, SfxBindings*, SfxChildWinInfo const &);
140 void SetHideNotDelete( bool bOn );
141 bool IsHideNotDelete() const;
142 bool IsVisible() const;
143 void SetWantsFocus( bool );
144 bool WantsFocus() const;
145
146 virtual bool QueryClose();
147 const css::uno::Reference< css::frame::XFrame >& GetFrame() const;
148 void SetFrame( const css::uno::Reference< css::frame::XFrame > & );
149
150 SAL_DLLPRIVATE static void InitializeChildWinFactory_Impl(sal_uInt16, SfxChildWinInfo&);
151 void SetVisible_Impl( bool bVis );
152 SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* );
153 SAL_DLLPRIVATE void Activate_Impl();
154
155 SAL_DLLPRIVATE void SetFactory_Impl( const SfxChildWinFactory* );
156};
157
159
160#define SFX_DECL_CHILDWINDOW(Class) \
161 public : \
162 static std::unique_ptr<SfxChildWindow> CreateImpl(vcl::Window *pParent, sal_uInt16 nId, \
163 SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
164 static void RegisterChildWindow (bool bVisible=false, SfxModule *pMod=nullptr, SfxChildWindowFlags nFlags=SfxChildWindowFlags::NONE); \
165 virtual SfxChildWinInfo GetInfo() const override
166
167#define SFX_DECL_CHILDWINDOW_WITHID(Class) \
168 SFX_DECL_CHILDWINDOW(Class); \
169 static sal_uInt16 GetChildWindowId ()\
170
171#define SFX_IMPL_CHILDWINDOW(Class, MyID) \
172 SFX_IMPL_POS_CHILDWINDOW(Class, MyID, CHILDWIN_NOPOS)
173
174#define SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
175 SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, CHILDWIN_NOPOS)
176
177#define SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
178 std::unique_ptr<SfxChildWindow> Class::CreateImpl( vcl::Window *pParent, \
179 sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
180 { \
181 return std::make_unique<Class>(pParent, nId, pBindings, pInfo);\
182 } \
183 void Class::RegisterChildWindow (bool bVis, SfxModule *pMod, SfxChildWindowFlags nFlags) \
184 { \
185 SfxChildWinFactory aFact( \
186 Class::CreateImpl, MyID, Pos ); \
187 aFact.aInfo.nFlags |= nFlags; \
188 aFact.aInfo.bVisible = bVis; \
189 SfxChildWindow::RegisterChildWindow(pMod, aFact); \
190 }
191
192#define SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, Pos) \
193 SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
194 sal_uInt16 Class::GetChildWindowId () \
195 { return MyID; } \
196
197#define SFX_IMPL_MODELESSDIALOGCONTOLLER(Class, MyID) \
198 SFX_IMPL_CHILDWINDOW(Class, MyID) \
199 SfxChildWinInfo Class::GetInfo() const \
200 { \
201 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
202 static_cast<const SfxModelessDialogController*>(GetController().get())->FillInfo( aInfo ); \
203 return aInfo; }
204
205#define SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(Class, MyID) \
206 SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
207 SfxChildWinInfo Class::GetInfo() const \
208 { \
209 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
210 static_cast<const SfxModelessDialogController*>(GetController().get())->FillInfo( aInfo ); \
211 return aInfo; }
212
213#define SFX_IMPL_DOCKINGWINDOW(Class, MyID) \
214 SFX_IMPL_CHILDWINDOW(Class, MyID) \
215 SfxChildWinInfo Class::GetInfo() const \
216 { \
217 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
218 static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo ); \
219 return aInfo; }
220
221#define SFX_IMPL_DOCKINGWINDOW_WITHID(Class, MyID) \
222 SFX_IMPL_CHILDWINDOW_WITHID(Class, MyID) \
223 SfxChildWinInfo Class::GetInfo() const \
224 { \
225 SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
226 static_cast<SfxDockingWindow*>(GetWindow())->FillInfo( aInfo ); \
227 return aInfo; }
228
229bool GetPosSizeFromString( std::u16string_view rStr, Point& rPos, Size& rSize );
230
231bool GetSplitSizeFromString( std::u16string_view rStr, Size& rSize );
232
233#endif
234
235/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxChildAlignment
Definition: chalign.hxx:27
bool GetSplitSizeFromString(std::u16string_view rStr, Size &rSize)
Definition: childwin.cxx:124
std::unique_ptr< SfxChildWindow >(* SfxChildWinCtor)(vcl::Window *pParentWindow, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo)
Definition: childwin.hxx:80
bool GetPosSizeFromString(std::u16string_view rStr, Point &rPos, Size &rSize)
Definition: childwin.cxx:109
SfxChildWindowFlags
Definition: childwin.hxx:42
const int nCloseResponseToJustHide
Definition: childwin.hxx:158
SFX2_DLLPUBLIC bool ParentIsFloatingWindow(const vcl::Window *pParent)
Definition: childwin.cxx:415
sal_uInt16 GetType() const
Definition: childwin.hxx:131
void SetController(std::shared_ptr< SfxDialogController > controller)
Definition: childwin.hxx:119
SfxChildAlignment eChildAlignment
Definition: childwin.hxx:105
vcl::Window * GetWindow() const
Definition: childwin.hxx:117
SfxChildAlignment GetAlignment() const
Definition: childwin.hxx:125
const std::shared_ptr< SfxDialogController > & GetController() const
Definition: childwin.hxx:122
sal_uInt16 nType
Definition: childwin.hxx:107
vcl::Window * GetParent() const
Definition: childwin.hxx:123
VclPtr< vcl::Window > pParent
Definition: childwin.hxx:101
std::shared_ptr< SfxDialogController > & GetController()
Definition: childwin.hxx:121
std::unique_ptr< SfxChildWindow_Impl > pImpl
Definition: childwin.hxx:103
VclPtr< vcl::Window > pWindow
Definition: childwin.hxx:102
void SetWindow(const VclPtr< vcl::Window > &p)
Definition: childwin.hxx:111
void ClearController()
Definition: childwin.hxx:120
std::shared_ptr< SfxDialogController > xController
Definition: childwin.hxx:104
virtual bool QueryClose() override
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
void * p
NONE
sal_Int16 nId
QPRO_FUNC_TYPE nType
SfxChildWinInfo aInfo
Definition: childwin.hxx:88
SfxChildWinCtor pCtor
Definition: childwin.hxx:87
sal_uInt16 nPos
Definition: childwin.hxx:90
sal_uInt16 nId
Definition: childwin.hxx:89
OUString aModule
Definition: childwin.hxx:64
SfxChildWindowFlags nFlags
Definition: childwin.hxx:68
OUString aWinState
Definition: childwin.hxx:65
OUString aExtraString
Definition: childwin.hxx:63
Reference< XController > xController
bool bVisible
ShowFlags