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  SAL_DLLPRIVATE void SetIdleDebugName( const char *pDebugName );
157 
158  using Window::ImplInit;
159  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
160  SAL_DLLPRIVATE void ImplInitSettings();
161 
162  SAL_DLLPRIVATE void DoInitialLayout();
163 
164  void loadUI(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
165  const css::uno::Reference<css::frame::XFrame> &rFrame);
166 
167 public:
168  bool isLayoutEnabled() const;
169  void setOptimalLayoutSize();
170 
171  //FIXME: is it okay to make this public?
172  void ImplStartDocking( const Point& rPos );
173  SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDeferredInit; }
174  virtual void doDeferredInit(WinBits nBits);
175 protected:
176  DockingWindow( WindowType nType );
177 
178 public:
179  DockingWindow(vcl::Window* pParent, WinBits nStyle);
180  DockingWindow(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
181  const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
182  virtual ~DockingWindow() override;
183  virtual void dispose() override;
184 
185  virtual void StartDocking();
186  virtual bool Docking( const Point& rPos, tools::Rectangle& rRect );
187  virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode );
188  virtual bool PrepareToggleFloatingMode();
189  virtual void ToggleFloatingMode();
190 
191  virtual void Resizing( Size& rSize );
192  virtual bool Close();
193  virtual void Tracking( const TrackingEvent& rTEvt ) override;
194  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
195  virtual void StateChanged( StateChangedType nType ) override;
196  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
197 
198  void SetMinOutputSizePixel( const Size& rSize );
199  const Size& GetMinOutputSizePixel() const;
200 
201  void SetMaxOutputSizePixel( const Size& rSize );
202 
203  bool IsDocking() const { return mbDocking; }
204  bool IsDockable() const { return mbDockable; }
205  bool IsDockingCanceled() const { return mbDockCanceled; }
206 
207  void SetFloatingMode( bool bFloatMode );
208  bool IsFloatingMode() const;
209  SystemWindow* GetFloatingWindow() const;
210 
211  void SetFloatingPos( const Point& rNewPos );
212  Point GetFloatingPos() const;
213 
214  void SetFloatStyle( WinBits nWinStyle );
215  WinBits GetFloatStyle() const;
216 
217  virtual void setPosSizePixel( tools::Long nX, tools::Long nY,
218  tools::Long nWidth, tools::Long nHeight,
219  PosSizeFlags nFlags = PosSizeFlags::All ) override;
220 
221  Point GetPosPixel() const override;
222  Size GetSizePixel() const override;
223  void SetOutputSizePixel( const Size& rNewSize ) override;
224  Size GetOutputSizePixel() const;
225 
226  virtual void SetText( const OUString& rStr ) override;
227  virtual OUString GetText() const override;
228  virtual Size GetOptimalSize() const override;
229  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
230 };
231 
233 {
234 protected:
236 public:
238  const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>(),
239  bool bTearable = false);
240  virtual ~DropdownDockingWindow() override;
241  virtual void dispose() override;
242 };
243 
245 {
246 protected:
248 public:
250  const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
251  void InvalidateChildSizeCache();
252  ResizableDockingWindow(vcl::Window* pParent, WinBits nStyle);
253  virtual ~ResizableDockingWindow() override;
254  virtual void dispose() override;
255 };
256 
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Point GetPosPixel() const
Definition: window.cxx:2781
virtual void SetText(const OUString &rStr)
Definition: window.cxx:3016
VclReferenceBase & operator=(const VclReferenceBase &)=delete
VclPtr< vcl::Window > m_xBox
Definition: dockwin.hxx:247
Idle maLayoutIdle
Definition: dockwin.hxx:132
bool IsDockable() const
Definition: dockwin.hxx:204
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:2392
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:137
FloatWinPopupFlags
Definition: vclenum.hxx:367
bool IsDockingCanceled() const
Definition: dockwin.hxx:205
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:1922
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:1321
virtual void SetOutputSizePixel(const Size &rNewSize)
Definition: window2.cxx:1268
virtual OUString GetText() const
Definition: window.cxx:3045
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:391
tools::Long mnTrackX
Definition: dockwin.hxx:123
Point maFloatPos
Definition: dockwin.hxx:119
virtual bool EventNotify(NotifyEvent &rNEvt)
Definition: event.cxx:104
VclPtr< vcl::Window > m_xBox
Definition: dockwin.hxx:235
ImplDockingWindowWrapper.
bool IsDocking() const
Definition: dockwin.hxx:203
tools::Rectangle maTrackRect
Definition: dockwin.hxx:36
Point maFloatingPos
Definition: dockwin.hxx:57
bool isLayoutEnabled(const vcl::Window *pWindow)
Definition: layout.cxx:2899
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:2656
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:935
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:1930
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:173
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36