nss: upgrade to release 3.73
[LibreOffice.git] / include / vcl / dockwin.hxx
blob0dd5988c23e77ab513810185aeb5978c1565b9e5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
27 #include <memory>
28 #include <vector>
30 // data to be sent with docking events
31 struct DockingData
33 Point 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 )
39 {};
42 struct EndDockingData
44 tools::Rectangle maWindowRect; // in
45 bool mbFloating; // in
46 bool mbCancelled; // in
48 EndDockingData( const tools::Rectangle& rRect, bool b, bool bCancelled ) :
49 maWindowRect( rRect ), mbFloating( b ), mbCancelled( bCancelled )
50 {};
53 struct EndPopupModeData
55 Point maFloatingPos; // in
56 bool mbTearoff; // in
58 EndPopupModeData( const Point& rPos, bool bTearoff ) :
59 maFloatingPos( rPos ), mbTearoff( bTearoff )
60 {};
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;
76 private:
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;
85 Link<FloatingWindow*,void> maPopupModeEndHdl;
86 Point maFloatPos;
87 Point maDockPos;
88 Point maMouseOff;
89 Size maRollUpOutSize;
90 Size maMinOutSize;
91 Size maMaxOutSize;
92 tools::Rectangle maDragArea;
93 tools::Long mnTrackX;
94 tools::Long mnTrackY;
95 tools::Long mnTrackWidth;
96 tools::Long mnTrackHeight;
97 sal_Int32 mnDockLeft;
98 sal_Int32 mnDockTop;
99 sal_Int32 mnDockRight;
100 sal_Int32 mnDockBottom;
101 WinBits mnFloatBits;
102 bool mbDockCanceled:1,
103 mbDocking:1,
104 mbLastFloatMode:1,
105 mbRollUp:1,
106 mbDockBtn:1,
107 mbHideBtn:1,
108 mbStartDockingEnabled:1,
109 mbLocked:1;
111 DECL_LINK( PopupModeEnd, FloatingWindow*, void );
112 void ImplEnableStartDocking() { mbStartDockingEnabled = true; }
113 bool ImplStartDockingEnabled() const { return mbStartDockingEnabled; }
114 void ImplPreparePopupMode();
116 public:
117 ImplDockingWindowWrapper( const vcl::Window *pWindow );
118 ~ImplDockingWindowWrapper();
120 vcl::Window* GetWindow() { return mpDockingWindow; }
121 void ImplStartDocking( const Point& rPos );
123 // those methods actually call the corresponding handlers
124 void StartDocking( const Point& rPos, tools::Rectangle const & rRect );
125 bool Docking( const Point& rPos, tools::Rectangle& rRect );
126 void EndDocking( const tools::Rectangle& rRect, bool bFloatMode );
127 bool PrepareToggleFloatingMode();
128 void ToggleFloatingMode();
130 void SetDragArea( const tools::Rectangle& rRect );
131 const tools::Rectangle& GetDragArea() const { return maDragArea;}
133 void Lock();
134 void Unlock();
135 bool IsLocked() const { return mbLocked;}
137 void StartPopupMode( const tools::Rectangle& rRect, FloatWinPopupFlags nPopupModeFlags );
138 void StartPopupMode( ToolBox* pParentToolBox, FloatWinPopupFlags nPopupModeFlags );
139 bool IsInPopupMode() const;
141 void SetPopupModeEndHdl( const Link<FloatingWindow*,void>& rLink ) { maPopupModeEndHdl = rLink; }
143 void TitleButtonClick( TitleButton nButton );
144 void Resizing( Size& rSize );
145 void Tracking( const TrackingEvent& rTEvt );
147 void ShowTitleButton( TitleButton nButton, bool bVisible );
149 void SetMinOutputSizePixel( const Size& rSize );
151 void SetMaxOutputSizePixel( const Size& rSize );
153 bool IsDocking() const { return mbDocking; }
154 bool IsDockingCanceled() const { return mbDockCanceled; }
156 void SetFloatingMode( bool bFloatMode );
157 bool IsFloatingMode() const;
158 FloatingWindow* GetFloatingWindow() const { return mpFloatWin; }
160 void SetFloatStyle( WinBits nWinStyle );
161 WinBits GetFloatStyle() const { return mnFloatBits;}
163 void setPosSizePixel( tools::Long nX, tools::Long nY,
164 tools::Long nWidth, tools::Long nHeight,
165 PosSizeFlags nFlags );
166 Point GetPosPixel() const;
167 Size GetSizePixel() const;
170 class VCL_DLLPUBLIC DockingManager
172 std::vector<std::unique_ptr<ImplDockingWindowWrapper, o3tl::default_delete<ImplDockingWindowWrapper>>> mvDockingWindows;
174 public:
175 DockingManager();
176 ~DockingManager();
178 DockingManager& operator=( DockingManager const & ) = delete; // MSVC2015 workaround
179 DockingManager( DockingManager const & ) = delete; // MSVC2015 workaround
181 void AddWindow( const vcl::Window *pWin );
182 void RemoveWindow( const vcl::Window *pWin );
184 ImplDockingWindowWrapper* GetDockingWindowWrapper( const vcl::Window *pWin );
185 bool IsDockable( const vcl::Window *pWin );
187 bool IsFloating( const vcl::Window *pWin );
188 void SetFloatingMode( const vcl::Window *pWin, bool bFloating );
190 void Lock( const vcl::Window *pWin );
191 void Unlock( const vcl::Window *pWin );
192 bool IsLocked( const vcl::Window *pWin );
194 void StartPopupMode( const vcl::Window *pWin, const tools::Rectangle& rRect, FloatWinPopupFlags nPopupModeFlags );
195 void StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWin );
196 void StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWin, FloatWinPopupFlags nPopupModeFlags );
198 void SetPopupModeEndHdl( const vcl::Window *pWindow, const Link<FloatingWindow*,void>& rLink );
200 bool IsInPopupMode( const vcl::Window *pWin );
201 void EndPopupMode( const vcl::Window *pWin );
203 // required because those methods are not virtual in Window (!!!) and must
204 // be available from the toolkit
205 void SetPosSizePixel( vcl::Window const *pWin, tools::Long nX, tools::Long nY,
206 tools::Long nWidth, tools::Long nHeight,
207 PosSizeFlags nFlags );
208 tools::Rectangle GetPosSizePixel( const vcl::Window *pWin );
212 class VCL_DLLPUBLIC DockingWindow
213 : public vcl::Window
214 , public VclBuilderContainer
216 class SAL_DLLPRIVATE ImplData;
217 private:
218 VclPtr<FloatingWindow> mpFloatWin;
219 VclPtr<vcl::Window> mpOldBorderWin;
220 std::unique_ptr<ImplData> mpImplData;
221 Point maFloatPos;
222 Point maDockPos;
223 Point maMouseOff;
224 Size maRollUpOutSize;
225 Size maMinOutSize;
226 tools::Long mnTrackX;
227 tools::Long mnTrackY;
228 tools::Long mnTrackWidth;
229 tools::Long mnTrackHeight;
230 sal_Int32 mnDockLeft;
231 sal_Int32 mnDockTop;
232 sal_Int32 mnDockRight;
233 sal_Int32 mnDockBottom;
234 WinBits mnFloatBits;
235 Idle maLayoutIdle;
236 bool mbDockCanceled:1,
237 mbDockable:1,
238 mbDocking:1,
239 mbDragFull:1,
240 mbLastFloatMode:1,
241 mbStartFloat:1,
242 mbRollUp:1,
243 mbDockBtn:1,
244 mbHideBtn:1,
245 mbIsCalculatingInitialLayoutSize:1;
247 protected:
248 bool mbIsDeferredInit;
249 VclPtr<vcl::Window> mpDialogParent;
250 private:
252 SAL_DLLPRIVATE void ImplInitDockingWindowData();
253 SAL_DLLPRIVATE void setPosSizeOnContainee();
254 DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, Timer*, void );
256 DockingWindow (const DockingWindow &) = delete;
257 DockingWindow & operator= (const DockingWindow &) = delete;
259 protected:
260 SAL_DLLPRIVATE void SetIdleDebugName( const char *pDebugName );
262 using Window::ImplInit;
263 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
264 SAL_DLLPRIVATE void ImplInitSettings();
266 SAL_DLLPRIVATE void DoInitialLayout();
268 void loadUI(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
269 const css::uno::Reference<css::frame::XFrame> &rFrame);
271 public:
272 bool isLayoutEnabled() const;
273 void setOptimalLayoutSize();
275 //FIXME: is it okay to make this public?
276 void ImplStartDocking( const Point& rPos );
277 SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDeferredInit; }
278 virtual void doDeferredInit(WinBits nBits);
279 protected:
280 DockingWindow( WindowType nType );
282 public:
283 DockingWindow(vcl::Window* pParent, WinBits nStyle);
284 DockingWindow(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
285 const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
286 virtual ~DockingWindow() override;
287 virtual void dispose() override;
289 virtual void StartDocking();
290 virtual bool Docking( const Point& rPos, tools::Rectangle& rRect );
291 virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode );
292 virtual bool PrepareToggleFloatingMode();
293 virtual void ToggleFloatingMode();
295 virtual void Resizing( Size& rSize );
296 virtual bool Close();
297 virtual void Tracking( const TrackingEvent& rTEvt ) override;
298 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
299 virtual void StateChanged( StateChangedType nType ) override;
300 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
302 void RollDown();
303 bool IsRollUp() const;
305 void SetMinOutputSizePixel( const Size& rSize );
306 const Size& GetMinOutputSizePixel() const;
308 void SetMaxOutputSizePixel( const Size& rSize );
310 bool IsDocking() const { return mbDocking; }
311 bool IsDockable() const { return mbDockable; }
312 bool IsDockingCanceled() const { return mbDockCanceled; }
314 void SetFloatingMode( bool bFloatMode );
315 bool IsFloatingMode() const;
316 FloatingWindow* GetFloatingWindow() const { return mpFloatWin; }
318 void SetFloatingPos( const Point& rNewPos );
319 Point GetFloatingPos() const;
321 void SetFloatStyle( WinBits nWinStyle );
322 WinBits GetFloatStyle() const;
324 virtual void setPosSizePixel( tools::Long nX, tools::Long nY,
325 tools::Long nWidth, tools::Long nHeight,
326 PosSizeFlags nFlags = PosSizeFlags::All ) override;
327 using Window::SetPosSizePixel;
328 Point GetPosPixel() const override;
329 Size GetSizePixel() const override;
330 void SetOutputSizePixel( const Size& rNewSize ) override;
331 Size GetOutputSizePixel() const;
333 virtual void SetText( const OUString& rStr ) override;
334 virtual OUString GetText() const override;
335 virtual Size GetOptimalSize() const override;
336 virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
340 inline void DockingWindow::RollDown()
342 if ( mpFloatWin )
343 mpFloatWin->RollDown();
344 mbRollUp = false;
347 inline bool DockingWindow::IsRollUp() const
349 if ( mpFloatWin )
350 return mpFloatWin->IsRollUp();
351 return mbRollUp;
355 inline void DockingWindow::SetMinOutputSizePixel( const Size& rSize )
357 if ( mpFloatWin )
358 mpFloatWin->SetMinOutputSizePixel( rSize );
359 maMinOutSize = rSize;
362 inline const Size& DockingWindow::GetMinOutputSizePixel() const
364 if ( mpFloatWin )
365 return mpFloatWin->GetMinOutputSizePixel();
366 return maMinOutSize;
369 inline void DockingWindow::SetFloatingPos( const Point& rNewPos )
371 if ( mpFloatWin )
372 mpFloatWin->SetPosPixel( rNewPos );
373 else
374 maFloatPos = rNewPos;
377 inline void DockingWindow::SetIdleDebugName( const char *pDebugName )
379 maLayoutIdle.SetDebugName( pDebugName );
383 #endif // INCLUDED_VCL_DOCKWIN_HXX
385 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */