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 {
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 mbFloating; // in
46  bool mbCancelled; // in
47 
48  EndDockingData( const tools::Rectangle& rRect, bool b, bool bCancelled ) :
49  maWindowRect( rRect ), mbFloating( b ), mbCancelled( bCancelled )
50  {};
51 };
52 
54 {
56  bool 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
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 SetPopupModeEndHdl( const Link<FloatingWindow*,void>& rLink ) { maPopupModeEndHdl = rLink; }
142 
143  void TitleButtonClick( TitleButton nButton );
144  void Resizing( Size& rSize );
145  void Tracking( const TrackingEvent& rTEvt );
146 
147  void ShowTitleButton( TitleButton nButton, bool bVisible );
148 
149  void SetMinOutputSizePixel( const Size& rSize );
150 
151  void SetMaxOutputSizePixel( const Size& rSize );
152 
153  bool IsDocking() const { return mbDocking; }
154  bool IsDockingCanceled() const { return mbDockCanceled; }
155 
156  void SetFloatingMode( bool bFloatMode );
157  bool IsFloatingMode() const;
159 
160  void SetFloatStyle( WinBits nWinStyle );
161  WinBits GetFloatStyle() const { return mnFloatBits;}
162 
163  void setPosSizePixel( long nX, long nY,
164  long nWidth, long nHeight,
165  PosSizeFlags nFlags );
166  Point GetPosPixel() const;
167  Size GetSizePixel() const;
168 };
169 
171 {
172  std::vector<std::unique_ptr<ImplDockingWindowWrapper, o3tl::default_delete<ImplDockingWindowWrapper>>> mvDockingWindows;
173 
174 public:
175  DockingManager();
176  ~DockingManager();
177 
178  DockingManager& operator=( DockingManager const & ) = delete; // MSVC2015 workaround
179  DockingManager( DockingManager const & ) = delete; // MSVC2015 workaround
180 
181  void AddWindow( const vcl::Window *pWin );
182  void RemoveWindow( const vcl::Window *pWin );
183 
184  ImplDockingWindowWrapper* GetDockingWindowWrapper( const vcl::Window *pWin );
185  bool IsDockable( const vcl::Window *pWin );
186 
187  bool IsFloating( const vcl::Window *pWin );
188  void SetFloatingMode( const vcl::Window *pWin, bool bFloating );
189 
190  void Lock( const vcl::Window *pWin );
191  void Unlock( const vcl::Window *pWin );
192  bool IsLocked( const vcl::Window *pWin );
193 
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 );
197 
198  void SetPopupModeEndHdl( const vcl::Window *pWindow, const Link<FloatingWindow*,void>& rLink );
199 
200  bool IsInPopupMode( const vcl::Window *pWin );
201  void EndPopupMode( const vcl::Window *pWin );
202 
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, long nX, long nY,
206  long nWidth, long nHeight,
207  PosSizeFlags nFlags );
208  tools::Rectangle GetPosSizePixel( const vcl::Window *pWin );
209 };
210 
211 
213  : public vcl::Window
214  , public VclBuilderContainer
215 {
216  class SAL_DLLPRIVATE ImplData;
217 private:
220  std::unique_ptr<ImplData> mpImplData;
226  long mnTrackX;
227  long mnTrackY;
230  sal_Int32 mnDockLeft;
231  sal_Int32 mnDockTop;
232  sal_Int32 mnDockRight;
233  sal_Int32 mnDockBottom;
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;
246 
247 protected:
250 private:
251 
252  SAL_DLLPRIVATE void ImplInitDockingWindowData();
253  SAL_DLLPRIVATE void setPosSizeOnContainee();
254  DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, Timer*, void );
255 
256  DockingWindow (const DockingWindow &) = delete;
257  DockingWindow & operator= (const DockingWindow &) = delete;
258 
259 protected:
260  SAL_DLLPRIVATE void SetIdleDebugName( const char *pDebugName );
261 
262  using Window::ImplInit;
263  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
264  SAL_DLLPRIVATE void ImplInitSettings();
265 
266  SAL_DLLPRIVATE void DoInitialLayout();
267 
268  void loadUI(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
269  const css::uno::Reference<css::frame::XFrame> &rFrame);
270 
271 public:
272  bool isLayoutEnabled() const;
273  void setOptimalLayoutSize();
274 
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 );
281 
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;
288 
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();
294 
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;
301 
302  void RollDown();
303  bool IsRollUp() const;
304 
305  void SetMinOutputSizePixel( const Size& rSize );
306  const Size& GetMinOutputSizePixel() const;
307 
308  void SetMaxOutputSizePixel( const Size& rSize );
309 
310  bool IsDocking() const { return mbDocking; }
311  bool IsDockable() const { return mbDockable; }
312  bool IsDockingCanceled() const { return mbDockCanceled; }
313 
314  void SetFloatingMode( bool bFloatMode );
315  bool IsFloatingMode() const;
316  FloatingWindow* GetFloatingWindow() const { return mpFloatWin; }
317 
318  void SetFloatingPos( const Point& rNewPos );
319  Point GetFloatingPos() const;
320 
321  void SetFloatStyle( WinBits nWinStyle );
322  WinBits GetFloatStyle() const;
323 
324  virtual void setPosSizePixel( long nX, long nY,
325  long nWidth, long nHeight,
326  PosSizeFlags nFlags = PosSizeFlags::All ) override;
328  Point GetPosPixel() const override;
329  Size GetSizePixel() const override;
330  void SetOutputSizePixel( const Size& rNewSize ) override;
331  Size GetOutputSizePixel() const;
332 
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;
337 };
338 
339 
341 {
342  if ( mpFloatWin )
343  mpFloatWin->RollDown();
344  mbRollUp = false;
345 }
346 
347 inline bool DockingWindow::IsRollUp() const
348 {
349  if ( mpFloatWin )
350  return mpFloatWin->IsRollUp();
351  return mbRollUp;
352 }
353 
354 
355 inline void DockingWindow::SetMinOutputSizePixel( const Size& rSize )
356 {
357  if ( mpFloatWin )
358  mpFloatWin->SetMinOutputSizePixel( rSize );
359  maMinOutSize = rSize;
360 }
361 
363 {
364  if ( mpFloatWin )
365  return mpFloatWin->GetMinOutputSizePixel();
366  return maMinOutSize;
367 }
368 
369 inline void DockingWindow::SetFloatingPos( const Point& rNewPos )
370 {
371  if ( mpFloatWin )
372  mpFloatWin->SetPosPixel( rNewPos );
373  else
374  maFloatPos = rNewPos;
375 }
376 
377 inline void DockingWindow::SetIdleDebugName( const char *pDebugName )
378 {
379  maLayoutIdle.SetDebugName( pDebugName );
380 }
381 
382 
383 #endif // INCLUDED_VCL_DOCKWIN_HXX
384 
385 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Point GetPosPixel() const
Definition: window.cxx:2792
virtual void SetText(const OUString &rStr)
Definition: window.cxx:3010
VclPtr< vcl::Window > mpOldBorderWin
Definition: dockwin.hxx:83
void RollDown()
Definition: syswin.cxx:385
Idle maLayoutIdle
Definition: dockwin.hxx:235
const Size & GetMinOutputSizePixel() const
Definition: dockwin.hxx:362
void SetPopupModeEndHdl(const Link< FloatingWindow *, void > &rLink)
Definition: dockwin.hxx:141
void StartPopupMode(const tools::Rectangle &rRect, FloatWinPopupFlags nPopupModeFlags)
Definition: dockmgr.cxx:829
bool IsDockable() const
Definition: dockwin.hxx:311
bool Docking(const Point &rPos, tools::Rectangle &rRect)
Definition: dockmgr.cxx:644
DECL_DLLPRIVATE_LINK(ImplHandlePaintHdl, Timer *, void)
bool IsDocking() const
Definition: dockwin.hxx:153
bool IsRollUp() const
Definition: syswin.hxx:146
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_Int32 mnDockRight
Definition: dockwin.hxx:232
VclPtr< vcl::Window > mpDockingWindow
Definition: dockwin.hxx:79
SAL_DLLPRIVATE void SetIdleDebugName(const char *pDebugName)
Definition: dockwin.hxx:377
bool mbIsDeferredInit
Definition: dockwin.hxx:248
Point maDockPos
Definition: dockwin.hxx:222
void ImplStartDocking(const Point &rPos)
Definition: dockmgr.cxx:498
virtual Size GetSizePixel() const
Definition: window.cxx:2395
bool mbFloating
Definition: dockwin.hxx:35
bool IsDockingCanceled() const
Definition: dockwin.hxx:154
void RollDown()
Definition: dockwin.hxx:340
virtual Size GetOptimalSize() const
Definition: window3.cxx:33
void SetFloatingPos(const Point &rNewPos)
Definition: dockwin.hxx:369
Point GetPosPixel() const
Definition: dockmgr.cxx:1007
PosSizeFlags
Definition: window.hxx:140
Point maMouseOff
Definition: dockwin.hxx:223
void SetMinOutputSizePixel(const Size &rSize)
Definition: dockmgr.cxx:1025
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: window.cxx:145
bool IsDockingCanceled() const
Definition: dockwin.hxx:312
Size GetSizePixel() const
Definition: dockmgr.cxx:1015
bool mbCancelled
Definition: dockwin.hxx:46
bool IsFloatingMode() const
Definition: dockmgr.cxx:1039
void Tracking(const TrackingEvent &rTEvt)
Definition: dockmgr.cxx:549
long mnTrackWidth
Definition: dockwin.hxx:228
StateChangedType
Definition: window.hxx:317
virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2667
sal_Int64 WinBits
EndDockingData(const tools::Rectangle &rRect, bool b, bool bCancelled)
Definition: dockwin.hxx:48
tools::Rectangle maDragArea
Definition: dockwin.hxx:92
bool IsRollUp() const
Definition: dockwin.hxx:347
virtual void Tracking(const TrackingEvent &rTEvt)
Definition: window.cxx:1926
std::vector< std::unique_ptr< ImplDockingWindowWrapper, o3tl::default_delete< ImplDockingWindowWrapper > > > mvDockingWindows
Definition: dockwin.hxx:172
void ShowTitleButton(TitleButton nButton, bool bVisible)
Definition: dockmgr.cxx:744
ImplDockingWindowWrapper(const vcl::Window *pWindow)
Definition: dockmgr.cxx:458
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1327
virtual void SetOutputSizePixel(const Size &rNewSize)
Definition: window2.cxx:1274
virtual OUString GetText() const
Definition: window.cxx:3039
WinBits mnFloatBits
Definition: dockwin.hxx:234
VclPtr< vcl::Window > mpParent
Definition: dockwin.hxx:84
void EndDocking(const tools::Rectangle &rRect, bool bFloatMode)
Definition: dockmgr.cxx:653
const Size & GetMinOutputSizePixel() const
Definition: syswin.hxx:152
void SetDebugName(const char *pDebugName)
Definition: task.hxx:81
void SetDragArea(const tools::Rectangle &rRect)
Definition: dockmgr.cxx:1044
sal_Int32 mnDockBottom
Definition: dockwin.hxx:233
vcl::Window * GetWindow()
Definition: dockwin.hxx:120
void SetMinOutputSizePixel(const Size &rSize)
Definition: syswin.cxx:397
Point maFloatPos
Definition: dockwin.hxx:221
virtual bool EventNotify(NotifyEvent &rNEvt)
Definition: event.cxx:103
FloatingWindow * GetFloatingWindow() const
Definition: dockwin.hxx:316
WinBits GetFloatStyle() const
Definition: dockwin.hxx:161
ImplDockingWindowWrapper.
Definition: dockwin.hxx:70
bool IsDocking() const
Definition: dockwin.hxx:310
tools::Rectangle maTrackRect
Definition: dockwin.hxx:34
void TitleButtonClick(TitleButton nButton)
Definition: dockmgr.cxx:720
Point maFloatingPos
Definition: dockwin.hxx:55
VclPtr< FloatingWindow > mpFloatWin
Definition: dockwin.hxx:82
DECL_LINK(PopupModeEnd, FloatingWindow *, void)
bool isLayoutEnabled(const vcl::Window *pWindow)
Definition: layout.cxx:2841
bool IsInPopupMode() const
Definition: dockmgr.cxx:869
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
Point maMousePos
Definition: dockwin.hxx:33
FloatWinPopupFlags
Definition: floatwin.hxx:31
Size maMinOutSize
Definition: dockwin.hxx:225
DockingData(const Point &rPt, const tools::Rectangle &rRect, bool b)
Definition: dockwin.hxx:37
Link< FloatingWindow *, void > maPopupModeEndHdl
Definition: dockwin.hxx:85
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
Definition: window2.cxx:1268
void SetFloatingMode(bool bFloatMode)
Definition: dockmgr.cxx:877
bool PrepareToggleFloatingMode()
Definition: dockmgr.cxx:698
VclPtr< vcl::Window > mpOldBorderWin
Definition: dockwin.hxx:219
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:935
bool mbFloating
Definition: dockwin.hxx:45
WindowType
void SetMaxOutputSizePixel(const Size &rSize)
Definition: dockmgr.cxx:1032
bool ImplStartDockingEnabled() const
Definition: dockwin.hxx:113
void StartDocking(const Point &rPos, tools::Rectangle const &rRect)
Definition: dockmgr.cxx:636
sal_Int32 mnDockTop
Definition: dockwin.hxx:231
bool IsLocked() const
Definition: dockwin.hxx:135
FloatingWindow * GetFloatingWindow() const
Definition: dockwin.hxx:158
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:997
std::unique_ptr< ImplData > mpImplData
Definition: dockwin.hxx:220
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1934
const tools::Rectangle & GetDragArea() const
Definition: dockwin.hxx:131
long mnTrackHeight
Definition: dockwin.hxx:229
sal_Int32 mnDockLeft
Definition: dockwin.hxx:230
OutputDevice & operator=(const OutputDevice &)=delete
Definition: timer.hxx:26
Size maRollUpOutSize
Definition: dockwin.hxx:224
VclPtr< FloatingWindow > mpFloatWin
Definition: dockwin.hxx:218
void SetMinOutputSizePixel(const Size &rSize)
Definition: dockwin.hxx:355
virtual void SetPosPixel(const Point &rNewPos)
Definition: window2.cxx:1257
VclPtr< vcl::Window > mpDialogParent
Definition: dockwin.hxx:249
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:30
tools::Rectangle maWindowRect
Definition: dockwin.hxx:44
SAL_DLLPRIVATE bool isDeferredInit() const
Definition: dockwin.hxx:277
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:35
void SetFloatStyle(WinBits nWinStyle)
Definition: dockmgr.cxx:991
void Resizing(Size &rSize)
Definition: dockmgr.cxx:736
TitleButton
Definition: syswin.hxx:51