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