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 .
20 #ifndef INCLUDED_VCL_DOCKWIN_HXX
21 #define INCLUDED_VCL_DOCKWIN_HXX
23 #include <vcl/dllapi.h>
24 #include <o3tl/deleter.hxx>
25 #include <vcl/builder.hxx>
26 #include <vcl/floatwin.hxx>
30 // data to be sent with docking events
33 Point
const maMousePos
; // in
34 tools::Rectangle maTrackRect
; // in/out
35 bool mbFloating
; // out
37 DockingData( const Point
& rPt
, const tools::Rectangle
& rRect
, bool b
) :
38 maMousePos( rPt
), maTrackRect( rRect
), mbFloating( b
)
44 tools::Rectangle
const maWindowRect
; // in
45 bool const mbFloating
; // in
46 bool const mbCancelled
; // in
48 EndDockingData( const tools::Rectangle
& rRect
, bool b
, bool bCancelled
) :
49 maWindowRect( rRect
), mbFloating( b
), mbCancelled( bCancelled
)
53 struct EndPopupModeData
55 Point
const maFloatingPos
; // in
56 bool const mbTearoff
; // in
58 EndPopupModeData( const Point
& rPos
, bool bTearoff
) :
59 maFloatingPos( rPos
), mbTearoff( bTearoff
)
63 /** ImplDockingWindowWrapper
65 * ImplDockingWindowWrapper obsoletes the DockingWindow class.
66 * It is better because it can make a "normal window" dockable.
67 * All DockingWindows should be converted the new class.
70 class ImplDockingWindowWrapper final
72 friend class ::vcl::Window
;
73 friend class DockingManager
;
74 friend class DockingWindow
;
78 // the original 'Docking'window
79 VclPtr
<vcl::Window
> mpDockingWindow
;
81 // the original DockingWindow members
82 VclPtr
<FloatingWindow
> mpFloatWin
;
83 VclPtr
<vcl::Window
> mpOldBorderWin
;
84 VclPtr
<vcl::Window
> mpParent
;
91 tools::Rectangle maDragArea
;
98 sal_Int32 mnDockRight
;
99 sal_Int32 mnDockBottom
;
101 bool mbDockCanceled
:1,
107 mbStartDockingEnabled
:1,
110 DECL_LINK( PopupModeEnd
, FloatingWindow
*, void );
111 void ImplEnableStartDocking() { mbStartDockingEnabled
= true; }
112 bool ImplStartDockingEnabled() const { return mbStartDockingEnabled
; }
113 void ImplPreparePopupMode();
116 ImplDockingWindowWrapper( const vcl::Window
*pWindow
);
117 ~ImplDockingWindowWrapper();
119 vcl::Window
* GetWindow() { return mpDockingWindow
; }
120 void ImplStartDocking( const Point
& rPos
);
122 // those methods actually call the corresponding handlers
123 void StartDocking( const Point
& rPos
, tools::Rectangle
const & rRect
);
124 bool Docking( const Point
& rPos
, tools::Rectangle
& rRect
);
125 void EndDocking( const tools::Rectangle
& rRect
, bool bFloatMode
);
126 bool PrepareToggleFloatingMode();
127 void ToggleFloatingMode();
129 void SetDragArea( const tools::Rectangle
& rRect
);
130 const tools::Rectangle
& GetDragArea() const { return maDragArea
;}
134 bool IsLocked() const { return mbLocked
;}
136 void StartPopupMode( const tools::Rectangle
& rRect
, FloatWinPopupFlags nPopupModeFlags
);
137 void StartPopupMode( ToolBox
* pParentToolBox
, FloatWinPopupFlags nPopupModeFlags
);
138 bool IsInPopupMode() const;
140 void TitleButtonClick( TitleButton nButton
);
141 void Resizing( Size
& rSize
);
142 void Tracking( const TrackingEvent
& rTEvt
);
144 void ShowTitleButton( TitleButton nButton
, bool bVisible
);
146 void SetMinOutputSizePixel( const Size
& rSize
);
148 void SetMaxOutputSizePixel( const Size
& rSize
);
150 bool IsDocking() const { return mbDocking
; }
151 bool IsDockingCanceled() const { return mbDockCanceled
; }
153 void SetFloatingMode( bool bFloatMode
);
154 bool IsFloatingMode() const;
155 FloatingWindow
* GetFloatingWindow() const { return mpFloatWin
; }
157 void SetFloatStyle( WinBits nWinStyle
);
158 WinBits
GetFloatStyle() const { return mnFloatBits
;}
160 void setPosSizePixel( long nX
, long nY
,
161 long nWidth
, long nHeight
,
162 PosSizeFlags nFlags
);
163 Point
GetPosPixel() const;
164 Size
GetSizePixel() const;
167 class VCL_DLLPUBLIC DockingManager
169 std::vector
<std::unique_ptr
<ImplDockingWindowWrapper
, o3tl::default_delete
<ImplDockingWindowWrapper
>>> mvDockingWindows
;
175 DockingManager
& operator=( DockingManager
const & ) = delete; // MSVC2015 workaround
176 DockingManager( DockingManager
const & ) = delete; // MSVC2015 workaround
178 void AddWindow( const vcl::Window
*pWin
);
179 void RemoveWindow( const vcl::Window
*pWin
);
181 ImplDockingWindowWrapper
* GetDockingWindowWrapper( const vcl::Window
*pWin
);
182 bool IsDockable( const vcl::Window
*pWin
);
184 bool IsFloating( const vcl::Window
*pWin
);
185 void SetFloatingMode( const vcl::Window
*pWin
, bool bFloating
);
187 void Lock( const vcl::Window
*pWin
);
188 void Unlock( const vcl::Window
*pWin
);
189 bool IsLocked( const vcl::Window
*pWin
);
191 void StartPopupMode( const vcl::Window
*pWin
, const tools::Rectangle
& rRect
, FloatWinPopupFlags nPopupModeFlags
);
192 void StartPopupMode( ToolBox
*pParentToolBox
, const vcl::Window
*pWin
);
193 void StartPopupMode( ToolBox
*pParentToolBox
, const vcl::Window
*pWin
, FloatWinPopupFlags nPopupModeFlags
);
195 bool IsInPopupMode( const vcl::Window
*pWin
);
196 void EndPopupMode( const vcl::Window
*pWin
);
198 // required because those methods are not virtual in Window (!!!) and must
199 // be available from the toolkit
200 void SetPosSizePixel( vcl::Window
const *pWin
, long nX
, long nY
,
201 long nWidth
, long nHeight
,
202 PosSizeFlags nFlags
);
203 tools::Rectangle
GetPosSizePixel( const vcl::Window
*pWin
);
207 class VCL_DLLPUBLIC DockingWindow
209 , public VclBuilderContainer
213 VclPtr
<FloatingWindow
> mpFloatWin
;
214 VclPtr
<vcl::Window
> mpOldBorderWin
;
215 std::unique_ptr
<ImplData
> mpImplData
;
219 Size maRollUpOutSize
;
225 sal_Int32 mnDockLeft
;
227 sal_Int32 mnDockRight
;
228 sal_Int32 mnDockBottom
;
231 bool mbDockCanceled
:1,
240 mbIsCalculatingInitialLayoutSize
:1;
243 bool mbIsDeferredInit
;
244 VclPtr
<vcl::Window
> mpDialogParent
;
247 SAL_DLLPRIVATE
void ImplInitDockingWindowData();
248 SAL_DLLPRIVATE
void setPosSizeOnContainee();
249 DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl
, Timer
*, void );
251 DockingWindow (const DockingWindow
&) = delete;
252 DockingWindow
& operator= (const DockingWindow
&) = delete;
255 SAL_DLLPRIVATE
void SetIdleDebugName( const sal_Char
*pDebugName
);
257 using Window::ImplInit
;
258 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
259 SAL_DLLPRIVATE
void ImplInitSettings();
261 SAL_DLLPRIVATE
void DoInitialLayout();
263 void loadUI(vcl::Window
* pParent
, const OString
& rID
, const OUString
& rUIXMLDescription
,
264 const css::uno::Reference
<css::frame::XFrame
> &rFrame
);
267 bool isLayoutEnabled() const;
268 void setOptimalLayoutSize();
270 //FIXME: is it okay to make this public?
271 void ImplStartDocking( const Point
& rPos
);
272 SAL_DLLPRIVATE
bool isDeferredInit() const { return mbIsDeferredInit
; }
273 virtual void doDeferredInit(WinBits nBits
);
275 DockingWindow( WindowType nType
);
278 DockingWindow(vcl::Window
* pParent
, WinBits nStyle
);
279 DockingWindow(vcl::Window
* pParent
, const OString
& rID
, const OUString
& rUIXMLDescription
,
280 const css::uno::Reference
<css::frame::XFrame
> &rFrame
= css::uno::Reference
<css::frame::XFrame
>());
281 virtual ~DockingWindow() override
;
282 virtual void dispose() override
;
284 virtual void StartDocking();
285 virtual bool Docking( const Point
& rPos
, tools::Rectangle
& rRect
);
286 virtual void EndDocking( const tools::Rectangle
& rRect
, bool bFloatMode
);
287 virtual bool PrepareToggleFloatingMode();
288 virtual void ToggleFloatingMode();
290 virtual void Resizing( Size
& rSize
);
291 virtual bool Close();
292 virtual void Tracking( const TrackingEvent
& rTEvt
) override
;
293 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
294 virtual void StateChanged( StateChangedType nType
) override
;
295 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
298 bool IsRollUp() const;
300 void SetMinOutputSizePixel( const Size
& rSize
);
301 const Size
& GetMinOutputSizePixel() const;
303 void SetMaxOutputSizePixel( const Size
& rSize
);
305 bool IsDocking() const { return mbDocking
; }
306 bool IsDockable() const { return mbDockable
; }
307 bool IsDockingCanceled() const { return mbDockCanceled
; }
309 void SetFloatingMode( bool bFloatMode
);
310 bool IsFloatingMode() const;
311 FloatingWindow
* GetFloatingWindow() const { return mpFloatWin
; }
313 void SetFloatingPos( const Point
& rNewPos
);
314 Point
GetFloatingPos() const;
316 void SetFloatStyle( WinBits nWinStyle
);
317 WinBits
GetFloatStyle() const;
319 virtual void setPosSizePixel( long nX
, long nY
,
320 long nWidth
, long nHeight
,
321 PosSizeFlags nFlags
= PosSizeFlags::All
) override
;
322 using Window::SetPosSizePixel
;
323 Point
GetPosPixel() const override
;
324 Size
GetSizePixel() const override
;
325 void SetOutputSizePixel( const Size
& rNewSize
) override
;
326 Size
GetOutputSizePixel() const;
328 virtual void SetText( const OUString
& rStr
) override
;
329 virtual OUString
GetText() const override
;
330 virtual Size
GetOptimalSize() const override
;
331 virtual void queue_resize(StateChangedType eReason
= StateChangedType::Layout
) override
;
335 inline void DockingWindow::RollDown()
338 mpFloatWin
->RollDown();
342 inline bool DockingWindow::IsRollUp() const
345 return mpFloatWin
->IsRollUp();
350 inline void DockingWindow::SetMinOutputSizePixel( const Size
& rSize
)
353 mpFloatWin
->SetMinOutputSizePixel( rSize
);
354 maMinOutSize
= rSize
;
357 inline const Size
& DockingWindow::GetMinOutputSizePixel() const
360 return mpFloatWin
->GetMinOutputSizePixel();
364 inline void DockingWindow::SetFloatingPos( const Point
& rNewPos
)
367 mpFloatWin
->SetPosPixel( rNewPos
);
369 maFloatPos
= rNewPos
;
372 inline void DockingWindow::SetIdleDebugName( const sal_Char
*pDebugName
)
374 maLayoutIdle
.SetDebugName( pDebugName
);
378 #endif // INCLUDED_VCL_DOCKWIN_HXX
380 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */