1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <vcl/dllapi.h>
23 #include <vcl/syswin.hxx>
24 #include <o3tl/deleter.hxx>
30 enum class FloatWinPopupFlags
;
32 // data to be sent with docking events
35 Point maMousePos
; // in
36 tools::Rectangle maTrackRect
; // in/out
37 bool mbFloating
; // out
39 DockingData( const Point
& rPt
, const tools::Rectangle
& rRect
, bool b
) :
40 maMousePos( rPt
), maTrackRect( rRect
), mbFloating( b
)
46 tools::Rectangle maWindowRect
; // in
47 bool mbFloating
; // in
48 bool mbCancelled
; // in
50 EndDockingData( const tools::Rectangle
& rRect
, bool b
, bool bCancelled
) :
51 maWindowRect( rRect
), mbFloating( b
), mbCancelled( bCancelled
)
55 struct EndPopupModeData
57 Point maFloatingPos
; // in
60 EndPopupModeData( const Point
& rPos
, bool bTearoff
) :
61 maFloatingPos( rPos
), mbTearoff( bTearoff
)
65 class ImplDockingWindowWrapper
;
67 class VCL_DLLPUBLIC DockingManager
69 std::vector
<std::unique_ptr
<ImplDockingWindowWrapper
, o3tl::default_delete
<ImplDockingWindowWrapper
>>> mvDockingWindows
;
72 SAL_DLLPRIVATE
DockingManager();
73 SAL_DLLPRIVATE
~DockingManager();
75 DockingManager
& operator=( DockingManager
const & ) = delete; // MSVC2015 workaround
76 DockingManager( DockingManager
const & ) = delete; // MSVC2015 workaround
78 SAL_DLLPRIVATE
void AddWindow( const vcl::Window
*pWin
);
79 SAL_DLLPRIVATE
void RemoveWindow( const vcl::Window
*pWin
);
81 SAL_DLLPRIVATE ImplDockingWindowWrapper
* GetDockingWindowWrapper( const vcl::Window
*pWin
);
82 bool IsDockable( const vcl::Window
*pWin
);
84 bool IsFloating( const vcl::Window
*pWin
);
85 void SetFloatingMode( const vcl::Window
*pWin
, bool bFloating
);
86 SystemWindow
* GetFloatingWindow(const vcl::Window
*pWin
);
88 void Lock( const vcl::Window
*pWin
);
89 void Unlock( const vcl::Window
*pWin
);
90 bool IsLocked( const vcl::Window
*pWin
);
92 SAL_DLLPRIVATE
void StartPopupMode( const vcl::Window
*pWin
, const tools::Rectangle
& rRect
, FloatWinPopupFlags nPopupModeFlags
);
93 void StartPopupMode( ToolBox
*pParentToolBox
, const vcl::Window
*pWin
);
94 void StartPopupMode( ToolBox
*pParentToolBox
, const vcl::Window
*pWin
, FloatWinPopupFlags nPopupModeFlags
);
96 SAL_DLLPRIVATE
void SetPopupModeEndHdl( const vcl::Window
*pWindow
, const Link
<FloatingWindow
*,void>& rLink
);
98 SAL_DLLPRIVATE
bool IsInPopupMode( const vcl::Window
*pWin
);
99 void EndPopupMode( const vcl::Window
*pWin
);
101 // required because those methods are not virtual in Window (!!!) and must
102 // be available from the toolkit
103 void SetPosSizePixel( vcl::Window
const *pWin
, tools::Long nX
, tools::Long nY
,
104 tools::Long nWidth
, tools::Long nHeight
,
105 PosSizeFlags nFlags
);
106 tools::Rectangle
GetPosSizePixel( const vcl::Window
*pWin
);
110 class VCL_DLLPUBLIC DockingWindow
112 , public VclBuilderContainer
114 class SAL_DLLPRIVATE ImplData
;
116 VclPtr
<FloatingWindow
> mpFloatWin
;
117 VclPtr
<vcl::Window
> mpOldBorderWin
;
118 std::unique_ptr
<ImplData
> mpImplData
;
123 tools::Long mnTrackX
;
124 tools::Long mnTrackY
;
125 tools::Long mnTrackWidth
;
126 tools::Long mnTrackHeight
;
127 sal_Int32 mnDockLeft
;
129 sal_Int32 mnDockRight
;
130 sal_Int32 mnDockBottom
;
133 bool mbDockCanceled
:1,
141 mbIsCalculatingInitialLayoutSize
:1;
144 bool mbIsDeferredInit
;
145 VclPtr
<vcl::Window
> mpDialogParent
;
148 SAL_DLLPRIVATE
void ImplInitDockingWindowData();
149 SAL_DLLPRIVATE
void setPosSizeOnContainee();
150 DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl
, Timer
*, void );
152 DockingWindow (const DockingWindow
&) = delete;
153 DockingWindow
& operator= (const DockingWindow
&) = delete;
156 using Window::ImplInit
;
157 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
158 SAL_DLLPRIVATE
void ImplInitSettings();
160 SAL_DLLPRIVATE
void DoInitialLayout();
162 SAL_DLLPRIVATE
void loadUI(vcl::Window
* pParent
, const OUString
& rID
, const OUString
& rUIXMLDescription
,
163 const css::uno::Reference
<css::frame::XFrame
> &rFrame
);
166 SAL_DLLPRIVATE
bool isLayoutEnabled() const;
167 SAL_DLLPRIVATE
void setOptimalLayoutSize();
169 //FIXME: is it okay to make this public?
170 void ImplStartDocking( const Point
& rPos
);
171 SAL_DLLPRIVATE
bool isDeferredInit() const { return mbIsDeferredInit
; }
172 virtual void doDeferredInit(WinBits nBits
);
174 SAL_DLLPRIVATE
DockingWindow( WindowType nType
, const char* pIdleDebugName
= "vcl::DockingWindow maLayoutIdle");
176 DockingWindow(vcl::Window
* pParent
, WinBits nStyle
, const char* pIdleDebugName
= "vcl::DockingWindow maLayoutIdle");
177 SAL_DLLPRIVATE
DockingWindow(vcl::Window
* pParent
, const OUString
& rID
, const OUString
& rUIXMLDescription
,
178 const char* pIdleDebugName
= "vcl::DockingWindow maLayoutIdle",
179 const css::uno::Reference
<css::frame::XFrame
> &rFrame
= css::uno::Reference
<css::frame::XFrame
>());
180 virtual ~DockingWindow() override
;
181 virtual void dispose() override
;
183 virtual void StartDocking();
184 virtual bool Docking( const Point
& rPos
, tools::Rectangle
& rRect
);
185 virtual void EndDocking( const tools::Rectangle
& rRect
, bool bFloatMode
);
186 virtual bool PrepareToggleFloatingMode();
187 virtual void ToggleFloatingMode();
189 virtual void Resizing( Size
& rSize
);
190 virtual bool Close();
191 virtual void Tracking( const TrackingEvent
& rTEvt
) override
;
192 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
193 virtual void StateChanged( StateChangedType nType
) override
;
194 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
196 void SetMinOutputSizePixel( const Size
& rSize
);
197 const Size
& GetMinOutputSizePixel() const;
199 SAL_DLLPRIVATE
void SetMaxOutputSizePixel( const Size
& rSize
);
201 bool IsDocking() const { return mbDocking
; }
202 bool IsDockable() const { return mbDockable
; }
203 bool IsDockingCanceled() const { return mbDockCanceled
; }
205 void SetFloatingMode( bool bFloatMode
);
206 bool IsFloatingMode() const;
207 SystemWindow
* GetFloatingWindow() const;
209 void SetFloatingPos( const Point
& rNewPos
);
210 Point
GetFloatingPos() const;
212 void SetFloatStyle( WinBits nWinStyle
);
213 WinBits
GetFloatStyle() const;
215 virtual void setPosSizePixel( tools::Long nX
, tools::Long nY
,
216 tools::Long nWidth
, tools::Long nHeight
,
217 PosSizeFlags nFlags
= PosSizeFlags::All
) override
;
219 Point
GetPosPixel() const override
;
220 Size
GetSizePixel() const override
;
221 void SetOutputSizePixel( const Size
& rNewSize
) override
;
222 Size
GetOutputSizePixel() const;
224 virtual void SetText( const OUString
& rStr
) override
;
225 virtual OUString
GetText() const override
;
226 virtual Size
GetOptimalSize() const override
;
227 virtual void queue_resize(StateChangedType eReason
= StateChangedType::Layout
) override
;
230 class VCL_DLLPUBLIC DropdownDockingWindow
: public DockingWindow
233 VclPtr
<vcl::Window
> m_xBox
;
235 DropdownDockingWindow(vcl::Window
* pParent
,
236 const css::uno::Reference
<css::frame::XFrame
> &rFrame
= css::uno::Reference
<css::frame::XFrame
>(),
237 bool bTearable
= false);
238 virtual ~DropdownDockingWindow() override
;
239 virtual void dispose() override
;
242 class VCL_DLLPUBLIC ResizableDockingWindow
: public DockingWindow
245 VclPtr
<vcl::Window
> m_xBox
;
247 ResizableDockingWindow(vcl::Window
* pParent
,
248 const css::uno::Reference
<css::frame::XFrame
> &rFrame
= css::uno::Reference
<css::frame::XFrame
>());
249 void InvalidateChildSizeCache();
250 ResizableDockingWindow(vcl::Window
* pParent
, WinBits nStyle
);
251 virtual ~ResizableDockingWindow() override
;
252 virtual void dispose() override
;
255 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */