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 #pragma once
21 
22 #include <vcl/dllapi.h>
23 #include <vcl/syswin.hxx>
24 #include <o3tl/deleter.hxx>
25 #include <memory>
26 #include <vector>
27 
28 class ToolBox;
29 class FloatingWindow;
30 enum class FloatWinPopupFlags;
31 
32 // data to be sent with docking events
34 {
37  bool mbFloating; // out
38 
39  DockingData( const Point& rPt, const tools::Rectangle& rRect, bool b) :
40  maMousePos( rPt ), maTrackRect( rRect ), mbFloating( b )
41  {};
42 };
43 
45 {
47  bool mbFloating; // in
48  bool mbCancelled; // in
49 
50  EndDockingData( const tools::Rectangle& rRect, bool b, bool bCancelled ) :
51  maWindowRect( rRect ), mbFloating( b ), mbCancelled( bCancelled )
52  {};
53 };
54 
56 {
58  bool mbTearoff; // in
59 
60  EndPopupModeData( const Point& rPos, bool bTearoff ) :
61  maFloatingPos( rPos ), mbTearoff( bTearoff )
62  {};
63 };
64 
66 
68 {
69  std::vector<std::unique_ptr<ImplDockingWindowWrapper, o3tl::default_delete<ImplDockingWindowWrapper>>> mvDockingWindows;
70 
71 public:
73  ~DockingManager();
74 
75  DockingManager& operator=( DockingManager const & ) = delete; // MSVC2015 workaround
76  DockingManager( DockingManager const & ) = delete; // MSVC2015 workaround
77 
78  void AddWindow( const vcl::Window *pWin );
79  void RemoveWindow( const vcl::Window *pWin );
80 
81  ImplDockingWindowWrapper* GetDockingWindowWrapper( const vcl::Window *pWin );
82  bool IsDockable( const vcl::Window *pWin );
83 
84  bool IsFloating( const vcl::Window *pWin );
85  void SetFloatingMode( const vcl::Window *pWin, bool bFloating );
86  SystemWindow* GetFloatingWindow(const vcl::Window *pWin);
87 
88  void Lock( const vcl::Window *pWin );
89  void Unlock( const vcl::Window *pWin );
90  bool IsLocked( const vcl::Window *pWin );
91 
92  void StartPopupMode( const vcl::Window *pWin, const tools::Rectangle& rRect, FloatWinPopupFlags nPopupModeFlags );
93  void StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWin );
94  void StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWin, FloatWinPopupFlags nPopupModeFlags );
95 
96  void SetPopupModeEndHdl( const vcl::Window *pWindow, const Link<FloatingWindow*,void>& rLink );
97 
98  bool IsInPopupMode( const vcl::Window *pWin );
99  void EndPopupMode( const vcl::Window *pWin );
100 
101  // required because those methods are not virtual in Window (!!!) and must
102  // be available from the toolkit
103  void SetPosSizePixel( vcl::Window const *pWin, tools::Long nX, tools::Long nY,
104  tools::Long nWidth, tools::Long nHeight,
105  PosSizeFlags nFlags );
106  tools::Rectangle GetPosSizePixel( const vcl::Window *pWin );
107 };
108 
109 
111  : public vcl::Window
112  , public VclBuilderContainer
113 {
114  class SAL_DLLPRIVATE ImplData;
115 private:
118  std::unique_ptr<ImplData> mpImplData;
127  sal_Int32 mnDockLeft;
128  sal_Int32 mnDockTop;
129  sal_Int32 mnDockRight;
130  sal_Int32 mnDockBottom;
133  bool mbDockCanceled:1,
134  mbDockable:1,
135  mbDocking:1,
136  mbDragFull:1,
137  mbLastFloatMode:1,
138  mbStartFloat:1,
139  mbDockBtn:1,
140  mbHideBtn:1,
141  mbIsCalculatingInitialLayoutSize:1;
142 
143 protected:
146 private:
147 
148  SAL_DLLPRIVATE void ImplInitDockingWindowData();
149  SAL_DLLPRIVATE void setPosSizeOnContainee();
150  DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, Timer*, void );
151 
152  DockingWindow (const DockingWindow &) = delete;
153  DockingWindow & operator= (const DockingWindow &) = delete;
154 
155 protected:
156  using Window::ImplInit;
157  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
158  SAL_DLLPRIVATE void ImplInitSettings();
159 
160  SAL_DLLPRIVATE void DoInitialLayout();
161 
162  void loadUI(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
163  const css::uno::Reference<css::frame::XFrame> &rFrame);
164 
165 public:
166  bool isLayoutEnabled() const;
167  void setOptimalLayoutSize();
168 
169  //FIXME: is it okay to make this public?
170  void ImplStartDocking( const Point& rPos );
171  SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDeferredInit; }
172  virtual void doDeferredInit(WinBits nBits);
173 protected:
174  DockingWindow( WindowType nType, const char* pIdleDebugName = "vcl::DockingWindow maLayoutIdle");
175 public:
176  DockingWindow(vcl::Window* pParent, WinBits nStyle, const char* pIdleDebugName = "vcl::DockingWindow maLayoutIdle");
177  DockingWindow(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
178  const char* pIdleDebugName = "vcl::DockingWindow maLayoutIdle",
179  const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
180  virtual ~DockingWindow() override;
181  virtual void dispose() override;
182 
183  virtual void StartDocking();
184  virtual bool Docking( const Point& rPos, tools::Rectangle& rRect );
185  virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode );
186  virtual bool PrepareToggleFloatingMode();
187  virtual void ToggleFloatingMode();
188 
189  virtual void Resizing( Size& rSize );
190  virtual bool Close();
191  virtual void Tracking( const TrackingEvent& rTEvt ) override;
192  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
193  virtual void StateChanged( StateChangedType nType ) override;
194  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
195 
196  void SetMinOutputSizePixel( const Size& rSize );
197  const Size& GetMinOutputSizePixel() const;
198 
199  void SetMaxOutputSizePixel( const Size& rSize );
200 
201  bool IsDocking() const { return mbDocking; }
202  bool IsDockable() const { return mbDockable; }
203  bool IsDockingCanceled() const { return mbDockCanceled; }
204 
205  void SetFloatingMode( bool bFloatMode );
206  bool IsFloatingMode() const;
207  SystemWindow* GetFloatingWindow() const;
208 
209  void SetFloatingPos( const Point& rNewPos );
210  Point GetFloatingPos() const;
211 
212  void SetFloatStyle( WinBits nWinStyle );
213  WinBits GetFloatStyle() const;
214 
215  virtual void setPosSizePixel( tools::Long nX, tools::Long nY,
216  tools::Long nWidth, tools::Long nHeight,
217  PosSizeFlags nFlags = PosSizeFlags::All ) override;
218 
219  Point GetPosPixel() const override;
220  Size GetSizePixel() const override;
221  void SetOutputSizePixel( const Size& rNewSize ) override;
222  Size GetOutputSizePixel() const;
223 
224  virtual void SetText( const OUString& rStr ) override;
225  virtual OUString GetText() const override;
226  virtual Size GetOptimalSize() const override;
227  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
228 };
229 
231 {
232 protected:
234 public:
236  const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>(),
237  bool bTearable = false);
238  virtual ~DropdownDockingWindow() override;
239  virtual void dispose() override;
240 };
241 
243 {
244 protected:
246 public:
248  const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
249  void InvalidateChildSizeCache();
250  ResizableDockingWindow(vcl::Window* pParent, WinBits nStyle);
251  virtual ~ResizableDockingWindow() override;
252  virtual void dispose() override;
253 };
254 
255 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Point GetPosPixel() const
Definition: window.cxx:2797
virtual void SetText(const OUString &rStr)
Definition: window.cxx:3032
VclReferenceBase & operator=(const VclReferenceBase &)=delete
VclPtr< vcl::Window > m_xBox
Definition: dockwin.hxx:245
Idle maLayoutIdle
Definition: dockwin.hxx:132
bool IsDockable() const
Definition: dockwin.hxx:202
DECL_DLLPRIVATE_LINK(ImplHandlePaintHdl, Timer *, void)
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_Int32 mnDockRight
Definition: dockwin.hxx:129
long Long
bool mbIsDeferredInit
Definition: dockwin.hxx:144
Point maDockPos
Definition: dockwin.hxx:120
virtual Size GetSizePixel() const
Definition: window.cxx:2405
bool mbFloating
Definition: dockwin.hxx:37
virtual Size GetOptimalSize() const
Definition: window3.cxx:26
PosSizeFlags
Definition: window.hxx:125
Point maMouseOff
Definition: dockwin.hxx:121
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: window.cxx:140
FloatWinPopupFlags
Definition: vclenum.hxx:368
bool IsDockingCanceled() const
Definition: dockwin.hxx:203
bool mbCancelled
Definition: dockwin.hxx:48
StateChangedType
Definition: window.hxx:289
sal_Int64 WinBits
EndDockingData(const tools::Rectangle &rRect, bool b, bool bCancelled)
Definition: dockwin.hxx:50
virtual void Tracking(const TrackingEvent &rTEvt)
Definition: window.cxx:1935
std::vector< std::unique_ptr< ImplDockingWindowWrapper, o3tl::default_delete< ImplDockingWindowWrapper > > > mvDockingWindows
Definition: dockwin.hxx:69
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1350
virtual void SetOutputSizePixel(const Size &rNewSize)
Definition: window2.cxx:1297
virtual OUString GetText() const
Definition: window.cxx:3061
WinBits mnFloatBits
Definition: dockwin.hxx:131
sal_Int32 mnDockBottom
Definition: dockwin.hxx:130
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: dockwin.cxx:395
tools::Long mnTrackX
Definition: dockwin.hxx:123
Point maFloatPos
Definition: dockwin.hxx:119
virtual bool EventNotify(NotifyEvent &rNEvt)
Definition: event.cxx:104
A toolbar: contains all those icons, typically below the menu bar.
Definition: toolbox.hxx:75
VclPtr< vcl::Window > m_xBox
Definition: dockwin.hxx:233
ImplDockingWindowWrapper.
bool IsDocking() const
Definition: dockwin.hxx:201
tools::Rectangle maTrackRect
Definition: dockwin.hxx:36
Point maFloatingPos
Definition: dockwin.hxx:57
bool isLayoutEnabled(const vcl::Window *pWindow)
Definition: layout.cxx:2912
Point maMousePos
Definition: dockwin.hxx:35
Size maMinOutSize
Definition: dockwin.hxx:122
DockingData(const Point &rPt, const tools::Rectangle &rRect, bool b)
Definition: dockwin.hxx:39
tools::Long mnTrackWidth
Definition: dockwin.hxx:125
VclPtr< vcl::Window > mpOldBorderWin
Definition: dockwin.hxx:117
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2669
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:941
bool mbFloating
Definition: dockwin.hxx:47
tools::Long mnTrackY
Definition: dockwin.hxx:124
WindowType
tools::Long mnTrackHeight
Definition: dockwin.hxx:126
sal_Int32 mnDockTop
Definition: dockwin.hxx:128
EndPopupModeData(const Point &rPos, bool bTearoff)
Definition: dockwin.hxx:60
std::unique_ptr< ImplData > mpImplData
Definition: dockwin.hxx:118
Size GetOutputSizePixel() const
Definition: window3.cxx:89
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1943
sal_Int32 mnDockLeft
Definition: dockwin.hxx:127
Definition: timer.hxx:26
VclPtr< FloatingWindow > mpFloatWin
Definition: dockwin.hxx:116
VclPtr< vcl::Window > mpDialogParent
Definition: dockwin.hxx:145
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:34
tools::Rectangle maWindowRect
Definition: dockwin.hxx:46
SAL_DLLPRIVATE bool isDeferredInit() const
Definition: dockwin.hxx:171
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36