LibreOffice Module vcl (master)  1
dockwin.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_VCL_DOCKWIN_HXX
21 #define INCLUDED_VCL_DOCKWIN_HXX
22 
23 #include <config_options.h>
24 #include <vcl/dllapi.h>
25 #include <o3tl/deleter.hxx>
26 #include <vcl/builder.hxx>
27 #include <vcl/floatwin.hxx>
28 #include <memory>
29 #include <vector>
30 
31 // data to be sent with docking events
33 {
36  bool mbFloating; // out
37 
38  DockingData( const Point& rPt, const tools::Rectangle& rRect, bool b) :
39  maMousePos( rPt ), maTrackRect( rRect ), mbFloating( b )
40  {};
41 };
42 
44 {
46  bool mbFloating; // in
47  bool mbCancelled; // in
48 
49  EndDockingData( const tools::Rectangle& rRect, bool b, bool bCancelled ) :
50  maWindowRect( rRect ), mbFloating( b ), mbCancelled( bCancelled )
51  {};
52 };
53 
55 {
57  bool mbTearoff; // in
58 
59  EndPopupModeData( const Point& rPos, bool bTearoff ) :
60  maFloatingPos( rPos ), mbTearoff( bTearoff )
61  {};
62 };
63 
72 {
73  friend class ::vcl::Window;
74  friend class DockingManager;
75  friend class DockingWindow;
76 
77 private:
78 
79  // the original 'Docking'window
81 
82  // the original DockingWindow members
93  long mnTrackX;
94  long mnTrackY;
97  sal_Int32 mnDockLeft;
98  sal_Int32 mnDockTop;
99  sal_Int32 mnDockRight;
100  sal_Int32 mnDockBottom;
103  mbDocking:1,
104  mbLastFloatMode:1,
105  mbRollUp:1,
106  mbDockBtn:1,
107  mbHideBtn:1,
109  mbLocked:1;
110 
111  DECL_LINK( PopupModeEnd, FloatingWindow*, void );
114  void ImplPreparePopupMode();
115 
116 public:
117  ImplDockingWindowWrapper( const vcl::Window *pWindow );
119 
121  void ImplStartDocking( const Point& rPos );
122 
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 );
128  void ToggleFloatingMode();
129 
130  void SetDragArea( const tools::Rectangle& rRect );
131  const tools::Rectangle& GetDragArea() const { return maDragArea;}
132 
133  void Lock();
134  void Unlock();
135  bool IsLocked() const { return mbLocked;}
136 
137  void StartPopupMode( const tools::Rectangle& rRect, FloatWinPopupFlags nPopupModeFlags );
138  void StartPopupMode( ToolBox* pParentToolBox, FloatWinPopupFlags nPopupModeFlags );
139  bool IsInPopupMode() const;
140 
141  void TitleButtonClick( TitleButton nButton );
142  void Resizing( Size& rSize );
143  void Tracking( const TrackingEvent& rTEvt );
144 
145  void ShowTitleButton( TitleButton nButton, bool bVisible );
146 
147  void SetMinOutputSizePixel( const Size& rSize );
148 
149  void SetMaxOutputSizePixel( const Size& rSize );
150 
151  bool IsDocking() const { return mbDocking; }
152  bool IsDockingCanceled() const { return mbDockCanceled; }
153 
154  void SetFloatingMode( bool bFloatMode );
155  bool IsFloatingMode() const;
157 
158  void SetFloatStyle( WinBits nWinStyle );
159  WinBits GetFloatStyle() const { return mnFloatBits;}
160 
161  void setPosSizePixel( long nX, long nY,
162  long nWidth, long nHeight,
163  PosSizeFlags nFlags );
164  Point GetPosPixel() const;
165  Size GetSizePixel() const;
166 };
167 
168 class UNLESS_MERGELIBS(VCL_DLLPUBLIC) DockingManager
169 {
170  std::vector<std::unique_ptr<ImplDockingWindowWrapper, o3tl::default_delete<ImplDockingWindowWrapper>>> mvDockingWindows;
171 
172 public:
173  DockingManager();
174  ~DockingManager();
175 
176  DockingManager& operator=( DockingManager const & ) = delete; // MSVC2015 workaround
177  DockingManager( DockingManager const & ) = delete; // MSVC2015 workaround
178 
179  void AddWindow( const vcl::Window *pWin );
180  void RemoveWindow( const vcl::Window *pWin );
181 
182  ImplDockingWindowWrapper* GetDockingWindowWrapper( const vcl::Window *pWin );
183  bool IsDockable( const vcl::Window *pWin );
184 
185  bool IsFloating( const vcl::Window *pWin );
186  void SetFloatingMode( const vcl::Window *pWin, bool bFloating );
187 
188  void Lock( const vcl::Window *pWin );
189  void Unlock( const vcl::Window *pWin );
190  bool IsLocked( const vcl::Window *pWin );
191 
192  void StartPopupMode( const vcl::Window *pWin, const tools::Rectangle& rRect, FloatWinPopupFlags nPopupModeFlags );
193  void StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWin );
194  void StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWin, FloatWinPopupFlags nPopupModeFlags );
195 
196  bool IsInPopupMode( const vcl::Window *pWin );
197  void EndPopupMode( const vcl::Window *pWin );
198 
199  // required because those methods are not virtual in Window (!!!) and must
200  // be available from the toolkit
201  void SetPosSizePixel( vcl::Window const *pWin, long nX, long nY,
202  long nWidth, long nHeight,
203  PosSizeFlags nFlags );
204  tools::Rectangle GetPosSizePixel( const vcl::Window *pWin );
205 };
206 
207 
209  : public vcl::Window
210  , public VclBuilderContainer
211 {
212  class SAL_DLLPRIVATE ImplData;
213 private:
216  std::unique_ptr<ImplData> mpImplData;
222  long mnTrackX;
223  long mnTrackY;
226  sal_Int32 mnDockLeft;
227  sal_Int32 mnDockTop;
228  sal_Int32 mnDockRight;
229  sal_Int32 mnDockBottom;
232  bool mbDockCanceled:1,
233  mbDockable:1,
234  mbDocking:1,
235  mbDragFull:1,
236  mbLastFloatMode:1,
237  mbStartFloat:1,
238  mbRollUp:1,
239  mbDockBtn:1,
240  mbHideBtn:1,
241  mbIsCalculatingInitialLayoutSize:1;
242 
243 protected:
246 private:
247 
248  SAL_DLLPRIVATE void ImplInitDockingWindowData();
249  SAL_DLLPRIVATE void setPosSizeOnContainee();
250  DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, Timer*, void );
251 
252  DockingWindow (const DockingWindow &) = delete;
253  DockingWindow & operator= (const DockingWindow &) = delete;
254 
255 protected:
256  SAL_DLLPRIVATE void SetIdleDebugName( const char *pDebugName );
257 
258  using Window::ImplInit;
259  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
260  SAL_DLLPRIVATE void ImplInitSettings();
261 
262  SAL_DLLPRIVATE void DoInitialLayout();
263 
264  void loadUI(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
265  const css::uno::Reference<css::frame::XFrame> &rFrame);
266 
267 public:
268  bool isLayoutEnabled() const;
269  void setOptimalLayoutSize();
270 
271  //FIXME: is it okay to make this public?
272  void ImplStartDocking( const Point& rPos );
273  SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDeferredInit; }
274  virtual void doDeferredInit(WinBits nBits);
275 protected:
276  DockingWindow( WindowType nType );
277 
278 public:
279  DockingWindow(vcl::Window* pParent, WinBits nStyle);
280  DockingWindow(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
281  const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
282  virtual ~DockingWindow() override;
283  virtual void dispose() override;
284 
285  virtual void StartDocking();
286  virtual bool Docking( const Point& rPos, tools::Rectangle& rRect );
287  virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode );
288  virtual bool PrepareToggleFloatingMode();
289  virtual void ToggleFloatingMode();
290 
291  virtual void Resizing( Size& rSize );
292  virtual bool Close();
293  virtual void Tracking( const TrackingEvent& rTEvt ) override;
294  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
295  virtual void StateChanged( StateChangedType nType ) override;
296  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
297 
298  void RollDown();
299  bool IsRollUp() const;
300 
301  void SetMinOutputSizePixel( const Size& rSize );
302  const Size& GetMinOutputSizePixel() const;
303 
304  void SetMaxOutputSizePixel( const Size& rSize );
305 
306  bool IsDocking() const { return mbDocking; }
307  bool IsDockable() const { return mbDockable; }
308  bool IsDockingCanceled() const { return mbDockCanceled; }
309 
310  void SetFloatingMode( bool bFloatMode );
311  bool IsFloatingMode() const;
312  FloatingWindow* GetFloatingWindow() const { return mpFloatWin; }
313 
314  void SetFloatingPos( const Point& rNewPos );
315  Point GetFloatingPos() const;
316 
317  void SetFloatStyle( WinBits nWinStyle );
318  WinBits GetFloatStyle() const;
319 
320  virtual void setPosSizePixel( long nX, long nY,
321  long nWidth, long nHeight,
322  PosSizeFlags nFlags = PosSizeFlags::All ) override;
323  using Window::SetPosSizePixel;
324  Point GetPosPixel() const override;
325  Size GetSizePixel() const override;
326  void SetOutputSizePixel( const Size& rNewSize ) override;
327  Size GetOutputSizePixel() const;
328 
329  virtual void SetText( const OUString& rStr ) override;
330  virtual OUString GetText() const override;
331  virtual Size GetOptimalSize() const override;
332  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
333 };
334 
335 
337 {
338  if ( mpFloatWin )
339  mpFloatWin->RollDown();
340  mbRollUp = false;
341 }
342 
343 inline bool DockingWindow::IsRollUp() const
344 {
345  if ( mpFloatWin )
346  return mpFloatWin->IsRollUp();
347  return mbRollUp;
348 }
349 
350 
351 inline void DockingWindow::SetMinOutputSizePixel( const Size& rSize )
352 {
353  if ( mpFloatWin )
354  mpFloatWin->SetMinOutputSizePixel( rSize );
355  maMinOutSize = rSize;
356 }
357 
359 {
360  if ( mpFloatWin )
361  return mpFloatWin->GetMinOutputSizePixel();
362  return maMinOutSize;
363 }
364 
365 inline void DockingWindow::SetFloatingPos( const Point& rNewPos )
366 {
367  if ( mpFloatWin )
368  mpFloatWin->SetPosPixel( rNewPos );
369  else
370  maFloatPos = rNewPos;
371 }
372 
373 inline void DockingWindow::SetIdleDebugName( const char *pDebugName )
374 {
375  maLayoutIdle.SetDebugName( pDebugName );
376 }
377 
378 
379 #endif // INCLUDED_VCL_DOCKWIN_HXX
380 
381 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VclPtr< vcl::Window > mpOldBorderWin
Definition: dockwin.hxx:84
void RollDown()
Definition: syswin.cxx:385
Idle maLayoutIdle
Definition: dockwin.hxx:231
const Size & GetMinOutputSizePixel() const
Definition: dockwin.hxx:358
void StartPopupMode(const tools::Rectangle &rRect, FloatWinPopupFlags nPopupModeFlags)
Definition: dockmgr.cxx:820
bool IsDockable() const
Definition: dockwin.hxx:307
bool Docking(const Point &rPos, tools::Rectangle &rRect)
Definition: dockmgr.cxx:635
bool IsDocking() const
Definition: dockwin.hxx:151
bool IsRollUp() const
Definition: syswin.hxx:147
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_Int32 mnDockRight
Definition: dockwin.hxx:228
VclPtr< vcl::Window > mpDockingWindow
Definition: dockwin.hxx:80
SAL_DLLPRIVATE void SetIdleDebugName(const char *pDebugName)
Definition: dockwin.hxx:373
bool mbIsDeferredInit
Definition: dockwin.hxx:244
Point maDockPos
Definition: dockwin.hxx:218
void ImplStartDocking(const Point &rPos)
Definition: dockmgr.cxx:489
bool mbFloating
Definition: dockwin.hxx:36
bool IsDockingCanceled() const
Definition: dockwin.hxx:152
void RollDown()
Definition: dockwin.hxx:336
void SetFloatingPos(const Point &rNewPos)
Definition: dockwin.hxx:365
Point GetPosPixel() const
Definition: dockmgr.cxx:997
PosSizeFlags
Definition: window.hxx:141
Point maMouseOff
Definition: dockwin.hxx:219
void SetMinOutputSizePixel(const Size &rSize)
Definition: dockmgr.cxx:1015
bool IsDockingCanceled() const
Definition: dockwin.hxx:308
Size GetSizePixel() const
Definition: dockmgr.cxx:1005
bool mbCancelled
Definition: dockwin.hxx:47
bool IsFloatingMode() const
Definition: dockmgr.cxx:1029
void Tracking(const TrackingEvent &rTEvt)
Definition: dockmgr.cxx:540
long mnTrackWidth
Definition: dockwin.hxx:224
StateChangedType
Definition: window.hxx:311
sal_Int64 WinBits
EndDockingData(const tools::Rectangle &rRect, bool b, bool bCancelled)
Definition: dockwin.hxx:49
tools::Rectangle maDragArea
Definition: dockwin.hxx:92
bool IsRollUp() const
Definition: dockwin.hxx:343
void ShowTitleButton(TitleButton nButton, bool bVisible)
Definition: dockmgr.cxx:735
ImplDockingWindowWrapper(const vcl::Window *pWindow)
Definition: dockmgr.cxx:450
WinBits mnFloatBits
Definition: dockwin.hxx:230
VclPtr< vcl::Window > mpParent
Definition: dockwin.hxx:85
void EndDocking(const tools::Rectangle &rRect, bool bFloatMode)
Definition: dockmgr.cxx:644
const Size & GetMinOutputSizePixel() const
Definition: syswin.hxx:153
void SetDebugName(const char *pDebugName)
Definition: task.hxx:81
void SetDragArea(const tools::Rectangle &rRect)
Definition: dockmgr.cxx:1034
sal_Int32 mnDockBottom
Definition: dockwin.hxx:229
vcl::Window * GetWindow()
Definition: dockwin.hxx:120
void SetMinOutputSizePixel(const Size &rSize)
Definition: syswin.cxx:397
Point maFloatPos
Definition: dockwin.hxx:217
FloatingWindow * GetFloatingWindow() const
Definition: dockwin.hxx:312
WinBits GetFloatStyle() const
Definition: dockwin.hxx:159
ImplDockingWindowWrapper.
Definition: dockwin.hxx:71
bool IsDocking() const
Definition: dockwin.hxx:306
tools::Rectangle maTrackRect
Definition: dockwin.hxx:35
void TitleButtonClick(TitleButton nButton)
Definition: dockmgr.cxx:711
Point maFloatingPos
Definition: dockwin.hxx:56
VclPtr< FloatingWindow > mpFloatWin
Definition: dockwin.hxx:83
DECL_LINK(PopupModeEnd, FloatingWindow *, void)
bool isLayoutEnabled(const vcl::Window *pWindow)
Definition: layout.cxx:2722
bool IsInPopupMode() const
Definition: dockmgr.cxx:859
Point maMousePos
Definition: dockwin.hxx:34
FloatWinPopupFlags
Definition: floatwin.hxx:31
Size maMinOutSize
Definition: dockwin.hxx:221
DockingData(const Point &rPt, const tools::Rectangle &rRect, bool b)
Definition: dockwin.hxx:38
void SetFloatingMode(bool bFloatMode)
Definition: dockmgr.cxx:867
bool PrepareToggleFloatingMode()
Definition: dockmgr.cxx:689
VclPtr< vcl::Window > mpOldBorderWin
Definition: dockwin.hxx:215
bool mbFloating
Definition: dockwin.hxx:46
WindowType
void SetMaxOutputSizePixel(const Size &rSize)
Definition: dockmgr.cxx:1022
bool ImplStartDockingEnabled() const
Definition: dockwin.hxx:113
void StartDocking(const Point &rPos, tools::Rectangle const &rRect)
Definition: dockmgr.cxx:627
sal_Int32 mnDockTop
Definition: dockwin.hxx:227
bool IsLocked() const
Definition: dockwin.hxx:135
FloatingWindow * GetFloatingWindow() const
Definition: dockwin.hxx:156
friend class DockingManager
Definition: dockwin.hxx:74
EndPopupModeData(const Point &rPos, bool bTearoff)
Definition: dockwin.hxx:59
void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags)
Definition: dockmgr.cxx:987
std::unique_ptr< ImplData > mpImplData
Definition: dockwin.hxx:216
const tools::Rectangle & GetDragArea() const
Definition: dockwin.hxx:131
long mnTrackHeight
Definition: dockwin.hxx:225
sal_Int32 mnDockLeft
Definition: dockwin.hxx:226
Definition: timer.hxx:26
Size maRollUpOutSize
Definition: dockwin.hxx:220
void dispose()
VclPtr< FloatingWindow > mpFloatWin
Definition: dockwin.hxx:214
void SetMinOutputSizePixel(const Size &rSize)
Definition: dockwin.hxx:351
virtual void SetPosPixel(const Point &rNewPos)
Definition: window2.cxx:1257
VclPtr< vcl::Window > mpDialogParent
Definition: dockwin.hxx:245
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:30
tools::Rectangle maWindowRect
Definition: dockwin.hxx:45
SAL_DLLPRIVATE bool isDeferredInit() const
Definition: dockwin.hxx:273
void SetFloatStyle(WinBits nWinStyle)
Definition: dockmgr.cxx:981
void Resizing(Size &rSize)
Definition: dockmgr.cxx:727
TitleButton
Definition: syswin.hxx:52