Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / dockwin.hxx
blobd4622a07ff7be3898c287acd33e3ba75e2661c14
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 <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/builder.hxx>
26 #include <vcl/floatwin.hxx>
27 #include <vector>
29 // data to be sent with docking events
30 struct DockingData
32 Point maMousePos; // in
33 tools::Rectangle maTrackRect; // in/out
34 bool mbFloating; // out
36 DockingData( const Point& rPt, const tools::Rectangle& rRect, bool b) :
37 maMousePos( rPt ), maTrackRect( rRect ), mbFloating( b )
38 {};
41 struct EndDockingData
43 tools::Rectangle maWindowRect; // in
44 bool mbFloating; // in
45 bool mbCancelled; // in
47 EndDockingData( const tools::Rectangle& rRect, bool b, bool bCancelled ) :
48 maWindowRect( rRect ), mbFloating( b ), mbCancelled( bCancelled )
49 {};
52 struct EndPopupModeData
54 Point maFloatingPos; // in
55 bool mbTearoff; // in
57 EndPopupModeData( const Point& rPos, bool bTearoff ) :
58 maFloatingPos( rPos ), mbTearoff( bTearoff )
59 {};
62 /** ImplDockingWindowWrapper
64 * ImplDockingWindowWrapper obsoletes the DockingWindow class.
65 * It is better because it can make a "normal window" dockable.
66 * All DockingWindows should be converted the new class.
69 class ImplDockingWindowWrapper final
71 friend class ::vcl::Window;
72 friend class DockingManager;
73 friend class DockingWindow;
75 private:
77 // the original 'Docking'window
78 VclPtr<vcl::Window> mpDockingWindow;
80 // the original DockingWindow members
81 VclPtr<FloatingWindow> mpFloatWin;
82 VclPtr<vcl::Window> mpOldBorderWin;
83 VclPtr<vcl::Window> mpParent;
84 Point maFloatPos;
85 Point maDockPos;
86 Point maMouseOff;
87 Point maMouseStart;
88 Size maRollUpOutSize;
89 Size maMinOutSize;
90 Size maMaxOutSize;
91 tools::Rectangle maDragArea;
92 long mnTrackX;
93 long mnTrackY;
94 long mnTrackWidth;
95 long mnTrackHeight;
96 sal_Int32 mnDockLeft;
97 sal_Int32 mnDockTop;
98 sal_Int32 mnDockRight;
99 sal_Int32 mnDockBottom;
100 WinBits mnFloatBits;
101 bool mbDockCanceled:1,
102 mbDocking:1,
103 mbLastFloatMode:1,
104 mbStartFloat: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() { return mbStartDockingEnabled; }
115 public:
116 ImplDockingWindowWrapper( const vcl::Window *pWindow );
117 ~ImplDockingWindowWrapper();
119 vcl::Window* GetWindow() { return mpDockingWindow; }
120 bool ImplStartDocking( const Point& rPos );
122 // those methods actually call the corresponding handlers
123 void StartDocking( const Point& rPos, tools::Rectangle& 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;}
132 void Lock();
133 void Unlock();
134 bool IsLocked() const { return mbLocked;}
136 void StartPopupMode( ToolBox* pParentToolBox, FloatWinPopupFlags nPopupModeFlags );
137 bool IsInPopupMode() const;
139 void TitleButtonClick( TitleButton nButton );
140 void Resizing( Size& rSize );
141 void Tracking( const TrackingEvent& rTEvt );
143 void ShowTitleButton( TitleButton nButton, bool bVisible );
145 void SetMinOutputSizePixel( const Size& rSize );
147 void SetMaxOutputSizePixel( const Size& rSize );
149 bool IsDocking() const { return mbDocking; }
150 bool IsDockingCanceled() const { return mbDockCanceled; }
152 void SetFloatingMode( bool bFloatMode );
153 bool IsFloatingMode() const;
154 FloatingWindow* GetFloatingWindow() const { return mpFloatWin; }
156 void SetFloatStyle( WinBits nWinStyle );
157 WinBits GetFloatStyle() const { return mnFloatBits;}
159 void setPosSizePixel( long nX, long nY,
160 long nWidth, long nHeight,
161 PosSizeFlags nFlags );
162 Point GetPosPixel() const;
163 Size GetSizePixel() const;
166 class VCL_DLLPUBLIC DockingManager
168 ::std::vector<ImplDockingWindowWrapper *> mDockingWindows;
170 public:
171 DockingManager();
172 ~DockingManager();
174 void AddWindow( const vcl::Window *pWin );
175 void RemoveWindow( const vcl::Window *pWin );
177 ImplDockingWindowWrapper* GetDockingWindowWrapper( const vcl::Window *pWin );
178 bool IsDockable( const vcl::Window *pWin );
180 bool IsFloating( const vcl::Window *pWin );
181 void SetFloatingMode( const vcl::Window *pWin, bool bFloating );
183 void Lock( const vcl::Window *pWin );
184 void Unlock( const vcl::Window *pWin );
185 bool IsLocked( const vcl::Window *pWin );
187 void StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWin );
188 void StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWin, FloatWinPopupFlags nPopupModeFlags );
190 bool IsInPopupMode( const vcl::Window *pWin );
191 void EndPopupMode( const vcl::Window *pWin );
193 // required because those methods are not virtual in Window (!!!) and must
194 // be availbale from the toolkit
195 void SetPosSizePixel( vcl::Window *pWin, long nX, long nY,
196 long nWidth, long nHeight,
197 PosSizeFlags nFlags );
198 tools::Rectangle GetPosSizePixel( const vcl::Window *pWin );
202 class VCL_DLLPUBLIC DockingWindow
203 : public vcl::Window
204 , public VclBuilderContainer
206 class ImplData;
207 private:
208 VclPtr<FloatingWindow> mpFloatWin;
209 VclPtr<vcl::Window> mpOldBorderWin;
210 ImplData* mpImplData;
211 Point maFloatPos;
212 Point maDockPos;
213 Point maMouseOff;
214 Point maMouseStart;
215 Size maRollUpOutSize;
216 Size maMinOutSize;
217 long mnTrackX;
218 long mnTrackY;
219 long mnTrackWidth;
220 long mnTrackHeight;
221 sal_Int32 mnDockLeft;
222 sal_Int32 mnDockTop;
223 sal_Int32 mnDockRight;
224 sal_Int32 mnDockBottom;
225 WinBits mnFloatBits;
226 Idle maLayoutIdle;
227 bool mbDockCanceled:1,
228 mbDockable:1,
229 mbDocking:1,
230 mbDragFull:1,
231 mbLastFloatMode:1,
232 mbStartFloat:1,
233 mbRollUp:1,
234 mbDockBtn:1,
235 mbHideBtn:1,
236 mbIsCalculatingInitialLayoutSize:1;
238 protected:
239 bool mbIsDefferedInit;
240 VclPtr<vcl::Window> mpDialogParent;
241 private:
243 SAL_DLLPRIVATE void ImplInitDockingWindowData();
244 SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, Window &rBox);
245 DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, Timer*, void );
247 DockingWindow (const DockingWindow &) = delete;
248 DockingWindow & operator= (const DockingWindow &) = delete;
250 protected:
251 SAL_DLLPRIVATE void SetIdleDebugName( const sal_Char *pDebugName );
253 using Window::ImplInit;
254 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
255 SAL_DLLPRIVATE void ImplInitSettings();
257 SAL_DLLPRIVATE void DoInitialLayout();
259 void loadUI(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
260 const css::uno::Reference<css::frame::XFrame> &rFrame);
262 public:
263 bool isLayoutEnabled() const;
264 void setOptimalLayoutSize();
266 SAL_DLLPRIVATE bool ImplStartDocking( const Point& rPos );
267 SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; }
268 virtual void doDeferredInit(WinBits nBits);
269 protected:
270 DockingWindow( WindowType nType );
272 public:
273 DockingWindow(vcl::Window* pParent, WinBits nStyle);
274 DockingWindow(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
275 const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
276 virtual ~DockingWindow() override;
277 virtual void dispose() override;
279 virtual void StartDocking();
280 virtual bool Docking( const Point& rPos, tools::Rectangle& rRect );
281 virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode );
282 virtual bool PrepareToggleFloatingMode();
283 virtual void ToggleFloatingMode();
285 virtual void Resizing( Size& rSize );
286 virtual bool Close();
287 virtual void Tracking( const TrackingEvent& rTEvt ) override;
288 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
289 virtual void StateChanged( StateChangedType nType ) override;
290 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
292 void RollDown();
293 bool IsRollUp() const;
295 void SetMinOutputSizePixel( const Size& rSize );
296 const Size& GetMinOutputSizePixel() const;
298 void SetMaxOutputSizePixel( const Size& rSize );
300 bool IsDocking() const { return mbDocking; }
301 bool IsDockable() const { return mbDockable; }
302 bool IsDockingCanceled() const { return mbDockCanceled; }
304 void SetFloatingMode( bool bFloatMode );
305 bool IsFloatingMode() const;
306 FloatingWindow* GetFloatingWindow() const { return mpFloatWin; }
308 void SetFloatingPos( const Point& rNewPos );
309 Point GetFloatingPos() const;
311 void SetFloatStyle( WinBits nWinStyle );
312 WinBits GetFloatStyle() const;
314 virtual void setPosSizePixel( long nX, long nY,
315 long nWidth, long nHeight,
316 PosSizeFlags nFlags = PosSizeFlags::All ) override;
317 using Window::SetPosSizePixel;
318 Point GetPosPixel() const override;
319 Size GetSizePixel() const override;
320 void SetOutputSizePixel( const Size& rNewSize ) override;
321 Size GetOutputSizePixel() const;
323 virtual void SetText( const OUString& rStr ) override;
324 virtual OUString GetText() const override;
325 virtual Size GetOptimalSize() const override;
326 virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
330 inline void DockingWindow::RollDown()
332 if ( mpFloatWin )
333 mpFloatWin->RollDown();
334 mbRollUp = false;
337 inline bool DockingWindow::IsRollUp() const
339 if ( mpFloatWin )
340 return mpFloatWin->IsRollUp();
341 return mbRollUp;
345 inline void DockingWindow::SetMinOutputSizePixel( const Size& rSize )
347 if ( mpFloatWin )
348 mpFloatWin->SetMinOutputSizePixel( rSize );
349 maMinOutSize = rSize;
352 inline const Size& DockingWindow::GetMinOutputSizePixel() const
354 if ( mpFloatWin )
355 return mpFloatWin->GetMinOutputSizePixel();
356 return maMinOutSize;
359 inline void DockingWindow::SetFloatingPos( const Point& rNewPos )
361 if ( mpFloatWin )
362 mpFloatWin->SetPosPixel( rNewPos );
363 else
364 maFloatPos = rNewPos;
367 inline void DockingWindow::SetIdleDebugName( const sal_Char *pDebugName )
369 maLayoutIdle.SetDebugName( pDebugName );
373 #endif // INCLUDED_VCL_DOCKWIN_HXX
375 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */