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 <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/builder.hxx>
26 #include <vcl/floatwin.hxx>
29 // data to be sent with docking events
32 Point maMousePos
; // in
33 Rectangle maTrackRect
; // in/out
34 bool mbFloating
; // out
35 bool mbLivemode
; // in
36 bool mbInteractive
; // in
39 DockingData( const Point
& rPt
, const Rectangle
& rRect
, bool b
) :
40 maMousePos( rPt
), maTrackRect( rRect
), mbFloating( b
), mbLivemode( false ), mbInteractive( true )
46 Rectangle maWindowRect
; // in
47 bool mbFloating
; // in
48 bool mbCancelled
; // in
51 EndDockingData( const Rectangle
& rRect
, bool b
, bool bCancelled
) :
52 maWindowRect( rRect
), mbFloating( b
), mbCancelled( bCancelled
)
56 struct EndPopupModeData
58 Point maFloatingPos
; // in
61 EndPopupModeData() {};
62 EndPopupModeData( const Point
& rPos
, bool bTearoff
) :
63 maFloatingPos( rPos
), mbTearoff( bTearoff
)
67 /** ImplDockingWindowWrapper
69 * ImplDockingWindowWrapper obsoletes the DockingWindow class.
70 * It is better because it can make a "normal window" dockable.
71 * All DockingWindows should be converted the new class.
74 class ImplDockingWindowWrapper
76 friend class ::vcl::Window
;
77 friend class DockingManager
;
78 friend class DockingWindow
;
82 // the original 'Docking'window
83 VclPtr
<vcl::Window
> mpDockingWindow
;
85 // the original DockingWindow members
86 VclPtr
<FloatingWindow
> mpFloatWin
;
87 VclPtr
<vcl::Window
> mpOldBorderWin
;
88 VclPtr
<vcl::Window
> mpParent
;
101 sal_Int32 mnDockLeft
;
103 sal_Int32 mnDockRight
;
104 sal_Int32 mnDockBottom
;
106 bool mbDockCanceled
:1,
118 mbStartDockingEnabled
:1,
121 DECL_LINK( PopupModeEnd
, void* );
122 void ImplEnableStartDocking( bool bEnable
= true ) { mbStartDockingEnabled
= bEnable
; }
123 bool ImplStartDockingEnabled() { return mbStartDockingEnabled
; }
126 ImplDockingWindowWrapper( const vcl::Window
*pWindow
);
127 virtual ~ImplDockingWindowWrapper();
129 vcl::Window
* GetWindow() { return mpDockingWindow
; }
130 bool ImplStartDocking( const Point
& rPos
);
132 // those methods actually call the corresponding handlers
133 void StartDocking( const Point
& rPos
, Rectangle
& rRect
);
134 bool Docking( const Point
& rPos
, Rectangle
& rRect
);
135 void EndDocking( const Rectangle
& rRect
, bool bFloatMode
);
136 bool PrepareToggleFloatingMode();
137 void ToggleFloatingMode();
139 void SetDragArea( const Rectangle
& rRect
);
140 Rectangle
GetDragArea() const { return maDragArea
;}
144 bool IsLocked() const { return mbLocked
;}
146 void StartPopupMode( ToolBox
* pParentToolBox
, FloatWinPopupFlags nPopupModeFlags
);
147 bool IsInPopupMode() const;
149 void TitleButtonClick( TitleButton nButton
);
150 void Resizing( Size
& rSize
);
151 void Tracking( const TrackingEvent
& rTEvt
);
152 long Notify( NotifyEvent
& rNEvt
);
154 void ShowTitleButton( TitleButton nButton
, bool bVisible
= true );
156 void SetMinOutputSizePixel( const Size
& rSize
);
158 void SetMaxOutputSizePixel( const Size
& rSize
);
160 bool IsDocking() const { return mbDocking
; }
161 bool IsDockable() const { return mbDockable
; }
162 bool IsDockingCanceled() const { return mbDockCanceled
; }
163 bool IsFloatingPrevented() const { return mbFloatPrevented
; }
165 void SetFloatingMode( bool bFloatMode
= false );
166 bool IsFloatingMode() const;
167 FloatingWindow
* GetFloatingWindow() const { return mpFloatWin
; }
169 void SetFloatStyle( WinBits nWinStyle
);
170 WinBits
GetFloatStyle() const { return mnFloatBits
;}
172 void setPosSizePixel( long nX
, long nY
,
173 long nWidth
, long nHeight
,
174 PosSizeFlags nFlags
= PosSizeFlags::All
);
175 void SetPosSizePixel( const Point
& rNewPos
,
176 const Size
& rNewSize
)
177 { mpDockingWindow
->SetPosSizePixel( rNewPos
, rNewSize
); }
178 Point
GetPosPixel() const;
179 Size
GetSizePixel() const;
182 class VCL_DLLPUBLIC DockingManager
185 ::std::vector
<ImplDockingWindowWrapper
*> mDockingWindows
;
191 void AddWindow( const vcl::Window
*pWin
);
192 void RemoveWindow( const vcl::Window
*pWin
);
194 ImplDockingWindowWrapper
* GetDockingWindowWrapper( const vcl::Window
*pWin
);
195 bool IsDockable( const vcl::Window
*pWin
);
197 bool IsFloating( const vcl::Window
*pWin
);
198 void SetFloatingMode( const vcl::Window
*pWin
, bool bFloating
);
200 void Lock( const vcl::Window
*pWin
);
201 void Unlock( const vcl::Window
*pWin
);
202 bool IsLocked( const vcl::Window
*pWin
);
204 void StartPopupMode( ToolBox
*pParentToolBox
, const vcl::Window
*pWin
);
205 void StartPopupMode( ToolBox
*pParentToolBox
, const vcl::Window
*pWin
, FloatWinPopupFlags nPopupModeFlags
);
207 bool IsInPopupMode( const vcl::Window
*pWin
);
208 void EndPopupMode( const vcl::Window
*pWin
);
210 // required because those methods are not virtual in Window (!!!) and must
211 // be availbale from the toolkit
212 void SetPosSizePixel( vcl::Window
*pWin
, long nX
, long nY
,
213 long nWidth
, long nHeight
,
214 PosSizeFlags nFlags
= PosSizeFlags::All
);
215 Rectangle
GetPosSizePixel( const vcl::Window
*pWin
);
222 class VCL_DLLPUBLIC DockingWindow
224 , public VclBuilderContainer
228 VclPtr
<FloatingWindow
> mpFloatWin
;
229 VclPtr
<vcl::Window
> mpOldBorderWin
;
230 ImplData
* mpImplData
;
235 Size maRollUpOutSize
;
241 sal_Int32 mnDockLeft
;
243 sal_Int32 mnDockRight
;
244 sal_Int32 mnDockBottom
;
247 bool mbDockCanceled
:1,
261 mbIsCalculatingInitialLayoutSize
:1,
262 mbInitialLayoutDone
:1;
264 VclPtr
<vcl::Window
> mpDialogParent
;
266 SAL_DLLPRIVATE
void ImplInitDockingWindowData();
267 SAL_DLLPRIVATE
void setPosSizeOnContainee(Size aSize
, Window
&rBox
);
268 DECL_DLLPRIVATE_LINK_TYPED( ImplHandleLayoutTimerHdl
, Idle
*, void );
270 DockingWindow (const DockingWindow
&) SAL_DELETED_FUNCTION
;
271 DockingWindow
& operator= (const DockingWindow
&) SAL_DELETED_FUNCTION
;
274 using Window::ImplInit
;
275 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
276 SAL_DLLPRIVATE
void ImplInitSettings();
277 SAL_DLLPRIVATE
void ImplLoadRes( const ResId
& rResId
);
279 SAL_DLLPRIVATE
void DoInitialLayout();
281 void loadUI(vcl::Window
* pParent
, const OString
& rID
, const OUString
& rUIXMLDescription
,
282 const css::uno::Reference
<css::frame::XFrame
> &rFrame
);
285 bool isLayoutEnabled() const;
286 void setOptimalLayoutSize();
287 bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize
; }
289 SAL_DLLPRIVATE
bool ImplStartDocking( const Point
& rPos
);
290 SAL_DLLPRIVATE
bool isDeferredInit() const { return mbIsDefferedInit
; }
291 SAL_DLLPRIVATE
bool hasPendingLayout() const { return maLayoutIdle
.IsActive(); }
292 void doDeferredInit(WinBits nBits
);
294 DockingWindow( WindowType nType
);
297 DockingWindow(vcl::Window
* pParent
, WinBits nStyle
= WB_STDDOCKWIN
);
298 DockingWindow(vcl::Window
* pParent
, const ResId
& rResId
);
299 DockingWindow(vcl::Window
* pParent
, const OString
& rID
, const OUString
& rUIXMLDescription
,
300 const css::uno::Reference
<css::frame::XFrame
> &rFrame
= css::uno::Reference
<css::frame::XFrame
>());
301 virtual ~DockingWindow();
302 virtual void dispose() SAL_OVERRIDE
;
304 virtual void StartDocking();
305 virtual bool Docking( const Point
& rPos
, Rectangle
& rRect
);
306 virtual void EndDocking( const Rectangle
& rRect
, bool bFloatMode
);
307 virtual bool PrepareToggleFloatingMode();
308 virtual void ToggleFloatingMode();
310 virtual void Resizing( Size
& rSize
);
311 virtual bool Close();
312 virtual void Tracking( const TrackingEvent
& rTEvt
) SAL_OVERRIDE
;
313 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
314 virtual void StateChanged( StateChangedType nType
) SAL_OVERRIDE
;
315 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
317 void SetPin( bool bPin
);
318 bool IsPinned() const;
322 bool IsRollUp() const;
324 void SetRollUpOutputSizePixel( const Size
& rSize
);
325 Size
GetRollUpOutputSizePixel() const;
327 void SetMinOutputSizePixel( const Size
& rSize
);
328 const Size
& GetMinOutputSizePixel() const;
330 void SetMaxOutputSizePixel( const Size
& rSize
);
332 bool IsDocking() const { return mbDocking
; }
333 bool IsDockable() const { return mbDockable
; }
334 bool IsDockingCanceled() const { return mbDockCanceled
; }
335 bool IsDockingPrevented() const { return mbDockPrevented
; }
336 bool IsFloatingPrevented() const { return mbFloatPrevented
; }
338 void SetFloatingMode( bool bFloatMode
= false );
339 bool IsFloatingMode() const;
340 FloatingWindow
* GetFloatingWindow() const { return mpFloatWin
; }
342 void SetFloatingPos( const Point
& rNewPos
);
343 Point
GetFloatingPos() const;
345 void SetFloatStyle( WinBits nWinStyle
);
346 WinBits
GetFloatStyle() const;
348 virtual void setPosSizePixel( long nX
, long nY
,
349 long nWidth
, long nHeight
,
350 PosSizeFlags nFlags
= PosSizeFlags::All
) SAL_OVERRIDE
;
351 void SetPosSizePixel( const Point
& rNewPos
,
352 const Size
& rNewSize
) SAL_OVERRIDE
353 { Window::SetPosSizePixel( rNewPos
, rNewSize
); }
354 Point
GetPosPixel() const SAL_OVERRIDE
;
355 Size
GetSizePixel() const SAL_OVERRIDE
;
356 void SetOutputSizePixel( const Size
& rNewSize
) SAL_OVERRIDE
;
357 Size
GetOutputSizePixel() const;
359 virtual void SetText( const OUString
& rStr
) SAL_OVERRIDE
;
360 virtual OUString
GetText() const SAL_OVERRIDE
;
361 virtual Size
GetOptimalSize() const SAL_OVERRIDE
;
362 virtual void queue_resize(StateChangedType eReason
= StateChangedType::Layout
) SAL_OVERRIDE
;
365 inline void DockingWindow::SetPin( bool bPin
)
368 mpFloatWin
->SetPin( bPin
);
372 inline bool DockingWindow::IsPinned() const
375 return mpFloatWin
->IsPinned();
379 inline void DockingWindow::RollUp()
382 mpFloatWin
->RollUp();
386 inline void DockingWindow::RollDown()
389 mpFloatWin
->RollDown();
393 inline bool DockingWindow::IsRollUp() const
396 return mpFloatWin
->IsRollUp();
400 inline void DockingWindow::SetRollUpOutputSizePixel( const Size
& rSize
)
403 mpFloatWin
->SetRollUpOutputSizePixel( rSize
);
404 maRollUpOutSize
= rSize
;
407 inline Size
DockingWindow::GetRollUpOutputSizePixel() const
410 return mpFloatWin
->GetRollUpOutputSizePixel();
411 return maRollUpOutSize
;
414 inline void DockingWindow::SetMinOutputSizePixel( const Size
& rSize
)
417 mpFloatWin
->SetMinOutputSizePixel( rSize
);
418 maMinOutSize
= rSize
;
421 inline const Size
& DockingWindow::GetMinOutputSizePixel() const
424 return mpFloatWin
->GetMinOutputSizePixel();
428 inline void DockingWindow::SetFloatingPos( const Point
& rNewPos
)
431 mpFloatWin
->SetPosPixel( rNewPos
);
433 maFloatPos
= rNewPos
;
437 #endif // INCLUDED_VCL_DOCKWIN_HXX
439 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */