/src/libreoffice/include/vcl/dockwin.hxx
Line | Count | Source |
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 |
33 | | struct DockingData |
34 | | { |
35 | | Point maMousePos; // in |
36 | | tools::Rectangle maTrackRect; // in/out |
37 | | bool mbFloating; // out |
38 | | |
39 | | DockingData( const Point& rPt, const tools::Rectangle& rRect, bool b) : |
40 | 0 | maMousePos( rPt ), maTrackRect( rRect ), mbFloating( b ) |
41 | 0 | {}; |
42 | | }; |
43 | | |
44 | | struct EndDockingData |
45 | | { |
46 | | tools::Rectangle maWindowRect; // in |
47 | | bool mbFloating; // in |
48 | | bool mbCancelled; // in |
49 | | |
50 | | EndDockingData( const tools::Rectangle& rRect, bool b, bool bCancelled ) : |
51 | 0 | maWindowRect( rRect ), mbFloating( b ), mbCancelled( bCancelled ) |
52 | 0 | {}; |
53 | | }; |
54 | | |
55 | | struct EndPopupModeData |
56 | | { |
57 | | Point maFloatingPos; // in |
58 | | bool mbTearoff; // in |
59 | | |
60 | | EndPopupModeData( const Point& rPos, bool bTearoff ) : |
61 | 0 | maFloatingPos( rPos ), mbTearoff( bTearoff ) |
62 | 0 | {}; |
63 | | }; |
64 | | |
65 | | class ImplDockingWindowWrapper; |
66 | | |
67 | | class VCL_DLLPUBLIC DockingManager |
68 | | { |
69 | | std::vector<std::unique_ptr<ImplDockingWindowWrapper, o3tl::default_delete<ImplDockingWindowWrapper>>> mvDockingWindows; |
70 | | |
71 | | public: |
72 | | SAL_DLLPRIVATE DockingManager(); |
73 | | SAL_DLLPRIVATE ~DockingManager(); |
74 | | |
75 | | DockingManager& operator=( DockingManager const & ) = delete; // MSVC2015 workaround |
76 | | DockingManager( DockingManager const & ) = delete; // MSVC2015 workaround |
77 | | |
78 | | SAL_DLLPRIVATE void AddWindow( const vcl::Window *pWin ); |
79 | | SAL_DLLPRIVATE void RemoveWindow( const vcl::Window *pWin ); |
80 | | |
81 | | SAL_DLLPRIVATE 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 | | SAL_DLLPRIVATE 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 | | SAL_DLLPRIVATE void SetPopupModeEndHdl( const vcl::Window *pWindow, const Link<FloatingWindow*,void>& rLink ); |
97 | | |
98 | | SAL_DLLPRIVATE 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 | | |
110 | | class VCL_DLLPUBLIC DockingWindow |
111 | | : public vcl::Window |
112 | | , public VclBuilderContainer |
113 | | { |
114 | | class SAL_DLLPRIVATE ImplData; |
115 | | private: |
116 | | VclPtr<FloatingWindow> mpFloatWin; |
117 | | VclPtr<vcl::Window> mpOldBorderWin; |
118 | | std::unique_ptr<ImplData> mpImplData; |
119 | | Point maFloatPos; |
120 | | Point maDockPos; |
121 | | Point maMouseOff; |
122 | | Size maMinOutSize; |
123 | | tools::Long mnTrackX; |
124 | | tools::Long mnTrackY; |
125 | | tools::Long mnTrackWidth; |
126 | | tools::Long mnTrackHeight; |
127 | | sal_Int32 mnDockLeft; |
128 | | sal_Int32 mnDockTop; |
129 | | sal_Int32 mnDockRight; |
130 | | sal_Int32 mnDockBottom; |
131 | | WinBits mnFloatBits; |
132 | | Idle maLayoutIdle; |
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: |
144 | | bool mbIsDeferredInit; |
145 | | VclPtr<vcl::Window> mpDialogParent; |
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 | | SAL_DLLPRIVATE void loadUI(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, |
163 | | const css::uno::Reference<css::frame::XFrame> &rFrame); |
164 | | |
165 | | public: |
166 | | SAL_DLLPRIVATE bool isLayoutEnabled() const; |
167 | | SAL_DLLPRIVATE void setOptimalLayoutSize(); |
168 | | |
169 | | //FIXME: is it okay to make this public? |
170 | | void ImplStartDocking( const Point& rPos ); |
171 | 0 | SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDeferredInit; } |
172 | | virtual void doDeferredInit(WinBits nBits); |
173 | | protected: |
174 | | SAL_DLLPRIVATE DockingWindow( WindowType eType, const char* pIdleDebugName = "vcl::DockingWindow maLayoutIdle"); |
175 | | public: |
176 | | DockingWindow(vcl::Window* pParent, WinBits nStyle, const char* pIdleDebugName = "vcl::DockingWindow maLayoutIdle"); |
177 | | SAL_DLLPRIVATE DockingWindow(vcl::Window* pParent, const OUString& 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 | | SAL_DLLPRIVATE void SetMaxOutputSizePixel( const Size& rSize ); |
200 | | |
201 | 0 | bool IsDocking() const { return mbDocking; } |
202 | 0 | bool IsDockable() const { return mbDockable; } |
203 | 0 | 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 | | |
230 | | class VCL_DLLPUBLIC DropdownDockingWindow : public DockingWindow |
231 | | { |
232 | | protected: |
233 | | VclPtr<vcl::Window> m_xBox; |
234 | | public: |
235 | | DropdownDockingWindow(vcl::Window* pParent, |
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 | | |
242 | | class VCL_DLLPUBLIC ResizableDockingWindow : public DockingWindow |
243 | | { |
244 | | protected: |
245 | | VclPtr<vcl::Window> m_xBox; |
246 | | public: |
247 | | ResizableDockingWindow(vcl::Window* pParent, |
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: */ |