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 _SV_DOCKWIN_HXX
21 #define _SV_DOCKWIN_HXX
23 #include <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/floatwin.hxx>
28 // data to be sent with docking events
31 Point maMousePos
; // in
32 Rectangle maTrackRect
; // in/out
33 sal_Bool mbFloating
; // out
34 sal_Bool mbLivemode
; // in
35 sal_Bool mbInteractive
; // in
38 DockingData( const Point
& rPt
, const Rectangle
& rRect
, sal_Bool b
) :
39 maMousePos( rPt
), maTrackRect( rRect
), mbFloating( b
), mbLivemode( sal_False
), mbInteractive( sal_True
)
45 Rectangle maWindowRect
; // in
46 sal_Bool mbFloating
; // in
47 sal_Bool mbCancelled
; // in
50 EndDockingData( const Rectangle
& rRect
, sal_Bool b
, sal_Bool bCancelled
) :
51 maWindowRect( rRect
), mbFloating( b
), mbCancelled( bCancelled
)
55 struct EndPopupModeData
57 Point maFloatingPos
; // in
58 sal_Bool mbTearoff
; // in
60 EndPopupModeData() {};
61 EndPopupModeData( const Point
& rPos
, sal_Bool bTearoff
) :
62 maFloatingPos( rPos
), mbTearoff( bTearoff
)
66 /** ImplDockingWindowWrapper
68 * ImplDockingWindowWrapper obsoletes the DockingWindow class.
69 * It is better because it can make a "normal window" dockable.
70 * All DockingWindows should be converted the new class.
73 class ImplDockingWindowWrapper
76 friend class DockingManager
;
77 friend class DockingWindow
;
81 // the original 'Docking'window
82 Window
*mpDockingWindow
;
84 // the original DockingWindow members
85 FloatingWindow
* mpFloatWin
;
86 Window
* mpOldBorderWin
;
100 sal_Int32 mnDockLeft
;
102 sal_Int32 mnDockRight
;
103 sal_Int32 mnDockBottom
;
105 sal_Bool mbDockCanceled
:1,
117 mbStartDockingEnabled
:1,
122 DECL_LINK( PopupModeEnd
, void* );
123 void ImplEnableStartDocking( sal_Bool bEnable
= sal_True
) { mbStartDockingEnabled
= bEnable
; }
124 sal_Bool
ImplStartDockingEnabled() { return mbStartDockingEnabled
; }
127 ImplDockingWindowWrapper( const Window
*pWindow
);
128 virtual ~ImplDockingWindowWrapper();
130 Window
* GetWindow() { return mpDockingWindow
; }
131 sal_Bool
ImplStartDocking( const Point
& rPos
);
133 // those methods actually call the corresponding handlers
134 void StartDocking( const Point
& rPos
, Rectangle
& rRect
);
135 sal_Bool
Docking( const Point
& rPos
, Rectangle
& rRect
);
136 void EndDocking( const Rectangle
& rRect
, sal_Bool bFloatMode
);
137 sal_Bool
PrepareToggleFloatingMode();
138 void ToggleFloatingMode();
140 void SetDragArea( const Rectangle
& rRect
);
141 Rectangle
GetDragArea() const;
145 sal_Bool
IsLocked() const;
147 void StartPopupMode( ToolBox
* pParentToolBox
, sal_uLong nPopupModeFlags
);
148 sal_Bool
IsInPopupMode() const;
150 void TitleButtonClick( sal_uInt16 nButton
);
154 void Resizing( Size
& rSize
);
156 void Tracking( const TrackingEvent
& rTEvt
);
157 long Notify( NotifyEvent
& rNEvt
);
159 void ShowTitleButton( sal_uInt16 nButton
, sal_Bool bVisible
= sal_True
);
161 void SetMinOutputSizePixel( const Size
& rSize
);
163 void SetMaxOutputSizePixel( const Size
& rSize
);
165 sal_Bool
IsDocking() const { return mbDocking
; }
166 sal_Bool
IsDockable() const { return mbDockable
; }
167 sal_Bool
IsDockingCanceled() const { return mbDockCanceled
; }
168 sal_Bool
IsFloatingPrevented() const { return mbFloatPrevented
; }
170 void SetFloatingMode( sal_Bool bFloatMode
= sal_False
);
171 sal_Bool
IsFloatingMode() const;
172 FloatingWindow
* GetFloatingWindow() const { return mpFloatWin
; }
174 void SetFloatStyle( WinBits nWinStyle
);
175 WinBits
GetFloatStyle() const;
177 virtual void setPosSizePixel( long nX
, long nY
,
178 long nWidth
, long nHeight
,
179 sal_uInt16 nFlags
= WINDOW_POSSIZE_ALL
);
180 void SetPosSizePixel( const Point
& rNewPos
,
181 const Size
& rNewSize
)
182 { mpDockingWindow
->SetPosSizePixel( rNewPos
, rNewSize
); }
183 Point
GetPosPixel() const;
184 Size
GetSizePixel() const;
187 class VCL_DLLPUBLIC DockingManager
190 ::std::vector
<ImplDockingWindowWrapper
*> mDockingWindows
;
196 void AddWindow( const Window
*pWin
);
197 void RemoveWindow( const Window
*pWin
);
199 ImplDockingWindowWrapper
* GetDockingWindowWrapper( const Window
*pWin
);
200 sal_Bool
IsDockable( const Window
*pWin
);
202 sal_Bool
IsFloating( const Window
*pWin
);
203 void SetFloatingMode( const Window
*pWin
, sal_Bool bFloating
);
205 void Lock( const Window
*pWin
);
206 void Unlock( const Window
*pWin
);
207 sal_Bool
IsLocked( const Window
*pWin
);
209 void StartPopupMode( ToolBox
*pParentToolBox
, const Window
*pWin
);
210 void StartPopupMode( ToolBox
*pParentToolBox
, const Window
*pWin
, sal_uLong nPopupModeFlags
);
212 sal_Bool
IsInPopupMode( const Window
*pWin
);
213 void EndPopupMode( const Window
*pWin
);
215 // required because those methods are not virtual in Window (!!!) and must
216 // be availbale from the toolkit
217 void SetPosSizePixel( Window
*pWin
, long nX
, long nY
,
218 long nWidth
, long nHeight
,
219 sal_uInt16 nFlags
= WINDOW_POSSIZE_ALL
);
220 Rectangle
GetPosSizePixel( const Window
*pWin
);
227 class VCL_DLLPUBLIC DockingWindow
: public Window
231 FloatingWindow
* mpFloatWin
;
232 Window
* mpOldBorderWin
;
233 ImplData
* mpImplData
;
238 Size maRollUpOutSize
;
244 sal_Int32 mnDockLeft
;
246 sal_Int32 mnDockRight
;
247 sal_Int32 mnDockBottom
;
249 sal_Bool mbDockCanceled
:1,
263 SAL_DLLPRIVATE
void ImplInitDockingWindowData();
265 // Copy assignment is forbidden and not implemented.
266 SAL_DLLPRIVATE
DockingWindow (const DockingWindow
&);
267 SAL_DLLPRIVATE DockingWindow
& operator= (const DockingWindow
&);
270 using Window::ImplInit
;
271 SAL_DLLPRIVATE
void ImplInit( Window
* pParent
, WinBits nStyle
);
272 SAL_DLLPRIVATE
void ImplInitSettings();
273 SAL_DLLPRIVATE
void ImplLoadRes( const ResId
& rResId
);
276 SAL_DLLPRIVATE sal_Bool
ImplStartDocking( const Point
& rPos
);
279 DockingWindow( WindowType nType
);
282 DockingWindow( Window
* pParent
, WinBits nStyle
= WB_STDDOCKWIN
);
283 DockingWindow( Window
* pParent
, const ResId
& rResId
);
286 virtual void StartDocking();
287 virtual sal_Bool
Docking( const Point
& rPos
, Rectangle
& rRect
);
288 virtual void EndDocking( const Rectangle
& rRect
, sal_Bool bFloatMode
);
289 virtual sal_Bool
PrepareToggleFloatingMode();
290 virtual void ToggleFloatingMode();
292 virtual void TitleButtonClick( sal_uInt16 nButton
);
295 virtual void PopupModeEnd();
296 virtual void Resizing( Size
& rSize
);
297 virtual sal_Bool
Close();
298 virtual void Tracking( const TrackingEvent
& rTEvt
);
299 virtual long Notify( NotifyEvent
& rNEvt
);
300 virtual void StateChanged( StateChangedType nType
);
301 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
303 void SetPin( sal_Bool bPin
);
304 sal_Bool
IsPined() const;
308 sal_Bool
IsRollUp() const;
310 void SetRollUpOutputSizePixel( const Size
& rSize
);
311 Size
GetRollUpOutputSizePixel() const;
313 void SetMinOutputSizePixel( const Size
& rSize
);
314 const Size
& GetMinOutputSizePixel() const;
316 void SetMaxOutputSizePixel( const Size
& rSize
);
318 sal_Bool
IsDocking() const { return mbDocking
; }
319 sal_Bool
IsDockable() const { return mbDockable
; }
320 sal_Bool
IsDockingCanceled() const { return mbDockCanceled
; }
321 sal_Bool
IsDockingPrevented() const { return mbDockPrevented
; }
322 sal_Bool
IsFloatingPrevented() const { return mbFloatPrevented
; }
324 void SetFloatingMode( sal_Bool bFloatMode
= sal_False
);
325 sal_Bool
IsFloatingMode() const;
326 FloatingWindow
* GetFloatingWindow() const { return mpFloatWin
; }
328 void SetFloatingPos( const Point
& rNewPos
);
329 Point
GetFloatingPos() const;
331 void SetFloatStyle( WinBits nWinStyle
);
332 WinBits
GetFloatStyle() const;
334 virtual void setPosSizePixel( long nX
, long nY
,
335 long nWidth
, long nHeight
,
336 sal_uInt16 nFlags
= WINDOW_POSSIZE_ALL
);
337 void SetPosSizePixel( const Point
& rNewPos
,
338 const Size
& rNewSize
)
339 { Window::SetPosSizePixel( rNewPos
, rNewSize
); }
340 Point
GetPosPixel() const;
341 Size
GetSizePixel() const;
342 void SetOutputSizePixel( const Size
& rNewSize
);
343 Size
GetOutputSizePixel() const;
346 inline void DockingWindow::SetPin( sal_Bool bPin
)
349 mpFloatWin
->SetPin( bPin
);
353 inline sal_Bool
DockingWindow::IsPined() const
356 return mpFloatWin
->IsPined();
360 inline void DockingWindow::RollUp()
363 mpFloatWin
->RollUp();
367 inline void DockingWindow::RollDown()
370 mpFloatWin
->RollDown();
371 mbRollUp
= sal_False
;
374 inline sal_Bool
DockingWindow::IsRollUp() const
377 return mpFloatWin
->IsRollUp();
381 inline void DockingWindow::SetRollUpOutputSizePixel( const Size
& rSize
)
384 mpFloatWin
->SetRollUpOutputSizePixel( rSize
);
385 maRollUpOutSize
= rSize
;
388 inline Size
DockingWindow::GetRollUpOutputSizePixel() const
391 return mpFloatWin
->GetRollUpOutputSizePixel();
392 return maRollUpOutSize
;
395 inline void DockingWindow::SetMinOutputSizePixel( const Size
& rSize
)
398 mpFloatWin
->SetMinOutputSizePixel( rSize
);
399 maMinOutSize
= rSize
;
402 inline const Size
& DockingWindow::GetMinOutputSizePixel() const
405 return mpFloatWin
->GetMinOutputSizePixel();
409 inline void DockingWindow::SetFloatingPos( const Point
& rNewPos
)
412 mpFloatWin
->SetPosPixel( rNewPos
);
414 maFloatPos
= rNewPos
;
418 #endif // _SV_DOCKWIN_HXX
420 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */