/src/libreoffice/vcl/source/window/dockwin.cxx
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 | | #include <tools/time.hxx> |
21 | | #include <sal/log.hxx> |
22 | | #include <vcl/builder.hxx> |
23 | | #include <vcl/dndlistenercontainer.hxx> |
24 | | #include <vcl/event.hxx> |
25 | | #include <vcl/toolkit/floatwin.hxx> |
26 | | #include <vcl/layout.hxx> |
27 | | #include <vcl/notebookbar/NotebookBarAddonsItem.hxx> |
28 | | #include <vcl/dockwin.hxx> |
29 | | #include <vcl/svapp.hxx> |
30 | | #include <vcl/timer.hxx> |
31 | | #include <vcl/idle.hxx> |
32 | | #include <vcl/settings.hxx> |
33 | | #include <comphelper/lok.hxx> |
34 | | |
35 | | #include <accel.hxx> |
36 | | #include <svdata.hxx> |
37 | | #include <window.h> |
38 | | #include <brdwin.hxx> |
39 | | |
40 | | #include "impldockingwrapper.hxx" |
41 | | |
42 | 66.6k | #define DOCKWIN_FLOATSTYLES (WB_SIZEABLE | WB_MOVEABLE | WB_CLOSEABLE | WB_STANDALONE) |
43 | | |
44 | | class DockingWindow::ImplData |
45 | | { |
46 | | public: |
47 | | ImplData(); |
48 | | |
49 | | VclPtr<vcl::Window> mpParent; |
50 | | Size maMaxOutSize; |
51 | | }; |
52 | | |
53 | | DockingWindow::ImplData::ImplData() |
54 | 33.3k | { |
55 | 33.3k | mpParent = nullptr; |
56 | 33.3k | maMaxOutSize = Size( SHRT_MAX, SHRT_MAX ); |
57 | 33.3k | } |
58 | | |
59 | | namespace { |
60 | | |
61 | | class ImplDockFloatWin : public FloatingWindow |
62 | | { |
63 | | private: |
64 | | VclPtr<DockingWindow> mpDockWin; |
65 | | sal_uInt64 mnLastTicks; |
66 | | Idle maDockIdle; |
67 | | Point maDockPos; |
68 | | tools::Rectangle maDockRect; |
69 | | bool mbInMove; |
70 | | ImplSVEvent * mnLastUserEvent; |
71 | | |
72 | | DECL_LINK(DockingHdl, void *, void); |
73 | | DECL_LINK(DockTimerHdl, Timer *, void); |
74 | | public: |
75 | | ImplDockFloatWin( vcl::Window* pParent, WinBits nWinBits, |
76 | | DockingWindow* pDockingWin ); |
77 | | virtual ~ImplDockFloatWin() override; |
78 | | virtual void dispose() override; |
79 | | |
80 | | virtual void Move() override; |
81 | | virtual void Resize() override; |
82 | | virtual void Resizing( Size& rSize ) override; |
83 | | virtual bool Close() override; |
84 | | }; |
85 | | |
86 | | } |
87 | | |
88 | | ImplDockFloatWin::ImplDockFloatWin( vcl::Window* pParent, WinBits nWinBits, |
89 | | DockingWindow* pDockingWin ) : |
90 | 0 | FloatingWindow( pParent, nWinBits ), |
91 | 0 | mpDockWin( pDockingWin ), |
92 | 0 | mnLastTicks( tools::Time::GetSystemTicks() ), |
93 | 0 | maDockIdle( "vcl::ImplDockFloatWin maDockIdle" ), |
94 | 0 | mbInMove( false ), |
95 | 0 | mnLastUserEvent( nullptr ) |
96 | 0 | { |
97 | | // copy settings of DockingWindow |
98 | 0 | if ( pDockingWin ) |
99 | 0 | { |
100 | 0 | GetOutDev()->SetSettings( pDockingWin->GetSettings() ); |
101 | 0 | Enable( pDockingWin->IsEnabled(), false ); |
102 | 0 | EnableInput( pDockingWin->IsInputEnabled(), false ); |
103 | 0 | AlwaysEnableInput( pDockingWin->IsAlwaysEnableInput(), false ); |
104 | 0 | EnableAlwaysOnTop( pDockingWin->IsAlwaysOnTopEnabled() ); |
105 | 0 | SetActivateMode( pDockingWin->GetActivateMode() ); |
106 | 0 | } |
107 | |
|
108 | 0 | SetBackground(); |
109 | |
|
110 | 0 | maDockIdle.SetInvokeHandler( LINK( this, ImplDockFloatWin, DockTimerHdl ) ); |
111 | 0 | maDockIdle.SetPriority( TaskPriority::HIGH_IDLE ); |
112 | 0 | } |
113 | | |
114 | | ImplDockFloatWin::~ImplDockFloatWin() |
115 | 0 | { |
116 | 0 | disposeOnce(); |
117 | 0 | } |
118 | | |
119 | | void ImplDockFloatWin::dispose() |
120 | 0 | { |
121 | 0 | if( mnLastUserEvent ) |
122 | 0 | Application::RemoveUserEvent( mnLastUserEvent ); |
123 | |
|
124 | 0 | disposeBuilder(); |
125 | |
|
126 | 0 | mpDockWin.reset(); |
127 | 0 | FloatingWindow::dispose(); |
128 | 0 | } |
129 | | |
130 | | IMPL_LINK_NOARG(ImplDockFloatWin, DockTimerHdl, Timer *, void) |
131 | 0 | { |
132 | 0 | SAL_WARN_IF( !mpDockWin->IsFloatingMode(), "vcl", "docktimer called but not floating" ); |
133 | | |
134 | 0 | maDockIdle.Stop(); |
135 | 0 | PointerState aState = GetPointerState(); |
136 | |
|
137 | 0 | if( aState.mnState & KEY_MOD1 ) |
138 | 0 | { |
139 | | // i43499 CTRL disables docking now |
140 | 0 | mpDockWin->GetParent()->ImplGetFrameWindow()->HideTracking(); |
141 | 0 | mpDockWin->EndDocking( maDockRect, true ); |
142 | 0 | if( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) |
143 | 0 | maDockIdle.Start(); |
144 | 0 | } |
145 | 0 | else if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) ) |
146 | 0 | { |
147 | 0 | mpDockWin->GetParent()->ImplGetFrameWindow()->HideTracking(); |
148 | 0 | mpDockWin->EndDocking( maDockRect, false ); |
149 | 0 | } |
150 | 0 | else |
151 | 0 | { |
152 | 0 | mpDockWin->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, ShowTrackFlags::Big | ShowTrackFlags::TrackWindow ); |
153 | 0 | maDockIdle.Start(); |
154 | 0 | } |
155 | 0 | } |
156 | | |
157 | | IMPL_LINK_NOARG(ImplDockFloatWin, DockingHdl, void*, void) |
158 | 0 | { |
159 | 0 | PointerState aState = mpDockWin->GetParent()->GetPointerState(); |
160 | |
|
161 | 0 | mnLastUserEvent = nullptr; |
162 | 0 | if( mpDockWin->IsDockable() && |
163 | 0 | (tools::Time::GetSystemTicks() - mnLastTicks > 500) && |
164 | 0 | ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) && |
165 | 0 | !(aState.mnState & KEY_MOD1) ) // i43499 CTRL disables docking now |
166 | 0 | { |
167 | 0 | maDockPos = mpDockWin->GetParent()->AbsoluteScreenToOutputPixel( OutputToAbsoluteScreenPixel( Point() ) ); |
168 | 0 | maDockPos = mpDockWin->GetParent()->OutputToScreenPixel( maDockPos ); // sfx expects screen coordinates |
169 | |
|
170 | 0 | if( ! mpDockWin->IsDocking() ) |
171 | 0 | mpDockWin->StartDocking(); |
172 | 0 | maDockRect = tools::Rectangle( maDockPos, mpDockWin->GetSizePixel() ); |
173 | | |
174 | | // mouse pos also in screen pixels |
175 | 0 | Point aMousePos = mpDockWin->GetParent()->OutputToScreenPixel( aState.maPos ); |
176 | |
|
177 | 0 | bool bFloatMode = mpDockWin->Docking( aMousePos, maDockRect ); |
178 | 0 | if( ! bFloatMode ) |
179 | 0 | { |
180 | 0 | mpDockWin->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, ShowTrackFlags::Object | ShowTrackFlags::TrackWindow ); |
181 | 0 | DockTimerHdl( nullptr ); |
182 | 0 | } |
183 | 0 | else |
184 | 0 | { |
185 | 0 | mpDockWin->GetParent()->ImplGetFrameWindow()->HideTracking(); |
186 | 0 | maDockIdle.Stop(); |
187 | 0 | mpDockWin->EndDocking( maDockRect, true ); |
188 | 0 | } |
189 | 0 | } |
190 | 0 | mbInMove = false; |
191 | 0 | } |
192 | | |
193 | | void ImplDockFloatWin::Move() |
194 | 0 | { |
195 | 0 | if( mbInMove ) |
196 | 0 | return; |
197 | | |
198 | 0 | mbInMove = true; |
199 | 0 | FloatingWindow::Move(); |
200 | 0 | mpDockWin->Move(); |
201 | | |
202 | | /* |
203 | | * note: the window should only dock if |
204 | | * the user releases all mouse buttons. The real problem here |
205 | | * is that we don't get mouse events (at least not on X) |
206 | | * if the mouse is on the decoration. So we have to start an |
207 | | * awkward timer based process that polls the modifier/buttons |
208 | | * to see whether they are in the right condition shortly after the |
209 | | * last Move message. |
210 | | */ |
211 | 0 | if( ! mnLastUserEvent ) |
212 | 0 | mnLastUserEvent = Application::PostUserEvent( LINK( this, ImplDockFloatWin, DockingHdl ), nullptr, true ); |
213 | 0 | } |
214 | | |
215 | | void ImplDockFloatWin::Resize() |
216 | 0 | { |
217 | 0 | FloatingWindow::Resize(); |
218 | 0 | Size aSize( GetSizePixel() ); |
219 | 0 | mpDockWin->ImplPosSizeWindow( 0, 0, aSize.Width(), aSize.Height(), PosSizeFlags::PosSize ); |
220 | 0 | } |
221 | | |
222 | | void ImplDockFloatWin::Resizing( Size& rSize ) |
223 | 0 | { |
224 | 0 | FloatingWindow::Resizing( rSize ); |
225 | 0 | mpDockWin->Resizing( rSize ); |
226 | 0 | } |
227 | | |
228 | | bool ImplDockFloatWin::Close() |
229 | 0 | { |
230 | 0 | return mpDockWin->Close(); |
231 | 0 | } |
232 | | |
233 | | void DockingWindow::ImplStartDocking( const Point& rPos ) |
234 | 0 | { |
235 | 0 | if ( !mbDockable ) |
236 | 0 | return; |
237 | | |
238 | 0 | maMouseOff = rPos; |
239 | 0 | mbDocking = true; |
240 | 0 | mbLastFloatMode = IsFloatingMode(); |
241 | 0 | mbStartFloat = mbLastFloatMode; |
242 | | |
243 | | // calculate FloatingBorder |
244 | 0 | VclPtr<FloatingWindow> pWin; |
245 | 0 | if ( mpFloatWin ) |
246 | 0 | pWin = mpFloatWin; |
247 | 0 | else |
248 | 0 | pWin = VclPtr<ImplDockFloatWin>::Create( mpImplData->mpParent, mnFloatBits, nullptr ); |
249 | 0 | pWin->GetBorder( mnDockLeft, mnDockTop, mnDockRight, mnDockBottom ); |
250 | 0 | if ( !mpFloatWin ) |
251 | 0 | pWin.disposeAndClear(); |
252 | |
|
253 | 0 | Point aPos = OutputToScreenPixel( Point() ); |
254 | 0 | Size aSize = Window::GetOutputSizePixel(); |
255 | 0 | mnTrackX = aPos.X(); |
256 | 0 | mnTrackY = aPos.Y(); |
257 | 0 | mnTrackWidth = aSize.Width(); |
258 | 0 | mnTrackHeight = aSize.Height(); |
259 | |
|
260 | 0 | if ( mbLastFloatMode ) |
261 | 0 | { |
262 | 0 | maMouseOff.AdjustX(mnDockLeft ); |
263 | 0 | maMouseOff.AdjustY(mnDockTop ); |
264 | 0 | mnTrackX -= mnDockLeft; |
265 | 0 | mnTrackY -= mnDockTop; |
266 | 0 | mnTrackWidth += mnDockLeft+mnDockRight; |
267 | 0 | mnTrackHeight += mnDockTop+mnDockBottom; |
268 | 0 | } |
269 | |
|
270 | 0 | if ( GetSettings().GetStyleSettings().GetDragFullOptions() & DragFullOptions::Docking && |
271 | 0 | !( mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ) ) // no full drag when migrating to system window |
272 | 0 | mbDragFull = true; |
273 | 0 | else |
274 | 0 | { |
275 | 0 | StartDocking(); |
276 | 0 | mbDragFull = false; |
277 | 0 | ImplUpdateAll(); |
278 | 0 | ImplGetFrameWindow()->ImplUpdateAll(); |
279 | 0 | } |
280 | |
|
281 | 0 | StartTracking( StartTrackingFlags::KeyMod ); |
282 | 0 | } |
283 | | |
284 | | void DockingWindow::ImplInitDockingWindowData() |
285 | 33.3k | { |
286 | 33.3k | mpWindowImpl->mbDockWin = true; |
287 | 33.3k | mpFloatWin = nullptr; |
288 | 33.3k | mpOldBorderWin = nullptr; |
289 | 33.3k | mpImplData.reset(new ImplData); |
290 | 33.3k | mnTrackX = 0; |
291 | 33.3k | mnTrackY = 0; |
292 | 33.3k | mnTrackWidth = 0; |
293 | 33.3k | mnTrackHeight = 0; |
294 | 33.3k | mnDockLeft = 0; |
295 | 33.3k | mnDockTop = 0; |
296 | 33.3k | mnDockRight = 0; |
297 | 33.3k | mnDockBottom = 0; |
298 | 33.3k | mnFloatBits = 0; |
299 | 33.3k | mbDockCanceled = false; |
300 | 33.3k | mbDockable = false; |
301 | 33.3k | mbDocking = false; |
302 | 33.3k | mbDragFull = false; |
303 | 33.3k | mbLastFloatMode = false; |
304 | 33.3k | mbStartFloat = false; |
305 | 33.3k | mbDockBtn = false; |
306 | 33.3k | mbHideBtn = false; |
307 | 33.3k | mbIsDeferredInit = false; |
308 | 33.3k | mbIsCalculatingInitialLayoutSize = false; |
309 | 33.3k | mpDialogParent = nullptr; |
310 | | |
311 | | //To-Do, reuse maResizeTimer |
312 | 33.3k | maLayoutIdle.SetPriority(TaskPriority::RESIZE); |
313 | 33.3k | maLayoutIdle.SetInvokeHandler( LINK( this, DockingWindow, ImplHandleLayoutTimerHdl ) ); |
314 | 33.3k | } |
315 | | |
316 | | void DockingWindow::ImplInit( vcl::Window* pParent, WinBits nStyle ) |
317 | 33.3k | { |
318 | 33.3k | if ( !(nStyle & WB_NODIALOGCONTROL) ) |
319 | 33.3k | nStyle |= WB_DIALOGCONTROL; |
320 | | |
321 | 33.3k | mpImplData->mpParent = pParent; |
322 | 33.3k | mbDockable = (nStyle & WB_DOCKABLE) != 0; |
323 | 33.3k | mnFloatBits = WB_BORDER | (nStyle & DOCKWIN_FLOATSTYLES); |
324 | 33.3k | nStyle &= ~(DOCKWIN_FLOATSTYLES | WB_BORDER); |
325 | | |
326 | 33.3k | Window::ImplInit( pParent, nStyle, nullptr ); |
327 | | |
328 | 33.3k | ImplInitSettings(); |
329 | 33.3k | } |
330 | | |
331 | | void DockingWindow::ImplInitSettings() |
332 | 33.3k | { |
333 | | // Hack: to be able to build DockingWindows w/o background before switching |
334 | | // TODO: Hack |
335 | 33.3k | if ( !IsBackground() ) |
336 | 33.3k | return; |
337 | | |
338 | 0 | const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); |
339 | |
|
340 | 0 | Color aColor; |
341 | 0 | if ( IsControlBackground() ) |
342 | 0 | aColor = GetControlBackground(); |
343 | 0 | else if ( Window::GetStyle() & WB_3DLOOK ) |
344 | 0 | aColor = rStyleSettings.GetFaceColor(); |
345 | 0 | else |
346 | 0 | aColor = rStyleSettings.GetWindowColor(); |
347 | 0 | SetBackground( aColor ); |
348 | 0 | } |
349 | | |
350 | | DockingWindow::DockingWindow( WindowType eType, const char* pIdleDebugName ) : |
351 | 33.3k | Window(eType), |
352 | 33.3k | maLayoutIdle( pIdleDebugName ) |
353 | 33.3k | { |
354 | 33.3k | ImplInitDockingWindowData(); |
355 | 33.3k | } DockingWindow::DockingWindow(WindowType, char const*) Line | Count | Source | 351 | 33.3k | Window(eType), | 352 | 33.3k | maLayoutIdle( pIdleDebugName ) | 353 | 33.3k | { | 354 | 33.3k | ImplInitDockingWindowData(); | 355 | 33.3k | } |
Unexecuted instantiation: DockingWindow::DockingWindow(WindowType, char const*) |
356 | | |
357 | | DockingWindow::DockingWindow( vcl::Window* pParent, WinBits nStyle, const char* pIdleDebugName ) : |
358 | 0 | Window( WindowType::DOCKINGWINDOW ), |
359 | 0 | maLayoutIdle( pIdleDebugName ) |
360 | 0 | { |
361 | 0 | ImplInitDockingWindowData(); |
362 | 0 | ImplInit( pParent, nStyle ); |
363 | 0 | } Unexecuted instantiation: DockingWindow::DockingWindow(vcl::Window*, long, char const*) Unexecuted instantiation: DockingWindow::DockingWindow(vcl::Window*, long, char const*) |
364 | | |
365 | | //Find the real parent stashed in mpDialogParent. |
366 | | void DockingWindow::doDeferredInit(WinBits nBits) |
367 | 0 | { |
368 | 0 | vcl::Window *pParent = mpDialogParent; |
369 | 0 | mpDialogParent = nullptr; |
370 | 0 | ImplInit(pParent, nBits); |
371 | 0 | mbIsDeferredInit = false; |
372 | 0 | } |
373 | | |
374 | | void DockingWindow::loadUI(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, |
375 | | const css::uno::Reference<css::frame::XFrame> &rFrame) |
376 | 0 | { |
377 | 0 | mbIsDeferredInit = true; |
378 | 0 | mpDialogParent = pParent; //should be unset in doDeferredInit |
379 | 0 | m_pUIBuilder.reset( new VclBuilder(this, AllSettings::GetUIRootDir(), rUIXMLDescription, rID, rFrame) ); |
380 | 0 | } |
381 | | |
382 | | DockingWindow::DockingWindow(vcl::Window* pParent, const OUString& rID, |
383 | | const OUString& rUIXMLDescription, const char* pIdleDebugName, |
384 | | const css::uno::Reference<css::frame::XFrame> &rFrame) |
385 | 0 | : Window(WindowType::DOCKINGWINDOW), |
386 | 0 | maLayoutIdle( pIdleDebugName ) |
387 | 0 | { |
388 | 0 | ImplInitDockingWindowData(); |
389 | |
|
390 | 0 | loadUI(pParent, rID, rUIXMLDescription, rFrame); |
391 | 0 | } Unexecuted instantiation: DockingWindow::DockingWindow(vcl::Window*, rtl::OUString const&, rtl::OUString const&, char const*, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) Unexecuted instantiation: DockingWindow::DockingWindow(vcl::Window*, rtl::OUString const&, rtl::OUString const&, char const*, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) |
392 | | |
393 | | DockingWindow::~DockingWindow() |
394 | 33.3k | { |
395 | 33.3k | disposeOnce(); |
396 | 33.3k | } |
397 | | |
398 | | void DockingWindow::dispose() |
399 | 33.3k | { |
400 | 33.3k | if ( IsFloatingMode() ) |
401 | 0 | { |
402 | 0 | Show( false, ShowFlags::NoFocusChange ); |
403 | 0 | SetFloatingMode(false); |
404 | 0 | } |
405 | 33.3k | mpImplData.reset(); |
406 | 33.3k | mpFloatWin.reset(); |
407 | 33.3k | mpOldBorderWin.reset(); |
408 | 33.3k | mpDialogParent.reset(); |
409 | 33.3k | disposeBuilder(); |
410 | 33.3k | Window::dispose(); |
411 | 33.3k | } |
412 | | |
413 | | void DockingWindow::Tracking( const TrackingEvent& rTEvt ) |
414 | 0 | { |
415 | 0 | if( GetDockingManager()->IsDockable( this ) ) // new docking interface |
416 | 0 | return Window::Tracking( rTEvt ); |
417 | | |
418 | 0 | if ( !mbDocking ) |
419 | 0 | return; |
420 | | |
421 | 0 | if ( rTEvt.IsTrackingEnded() ) |
422 | 0 | { |
423 | 0 | mbDocking = false; |
424 | 0 | if ( mbDragFull ) |
425 | 0 | { |
426 | | // reset old state on Cancel |
427 | 0 | if ( rTEvt.IsTrackingCanceled() ) |
428 | 0 | { |
429 | 0 | StartDocking(); |
430 | 0 | tools::Rectangle aRect( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ); |
431 | 0 | EndDocking( aRect, mbStartFloat ); |
432 | 0 | } |
433 | 0 | } |
434 | 0 | else |
435 | 0 | { |
436 | 0 | HideTracking(); |
437 | 0 | if ( rTEvt.IsTrackingCanceled() ) |
438 | 0 | { |
439 | 0 | mbDockCanceled = true; |
440 | 0 | EndDocking( tools::Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode ); |
441 | 0 | mbDockCanceled = false; |
442 | 0 | } |
443 | 0 | else |
444 | 0 | EndDocking( tools::Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode ); |
445 | 0 | } |
446 | 0 | } |
447 | | // dock only for non-synthetic MouseEvents |
448 | 0 | else if ( !rTEvt.GetMouseEvent().IsSynthetic() || rTEvt.GetMouseEvent().IsModifierChanged() ) |
449 | 0 | { |
450 | 0 | Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel(); |
451 | 0 | Point aFrameMousePos = OutputToScreenPixel( aMousePos ); |
452 | 0 | Size aFrameSize = mpWindowImpl->mpFrameWindow->GetOutputSizePixel(); |
453 | 0 | if ( aFrameMousePos.X() < 0 ) |
454 | 0 | aFrameMousePos.setX( 0 ); |
455 | 0 | if ( aFrameMousePos.Y() < 0 ) |
456 | 0 | aFrameMousePos.setY( 0 ); |
457 | 0 | if ( aFrameMousePos.X() > aFrameSize.Width()-1 ) |
458 | 0 | aFrameMousePos.setX( aFrameSize.Width()-1 ); |
459 | 0 | if ( aFrameMousePos.Y() > aFrameSize.Height()-1 ) |
460 | 0 | aFrameMousePos.setY( aFrameSize.Height()-1 ); |
461 | 0 | aMousePos = ScreenToOutputPixel( aFrameMousePos ); |
462 | 0 | aMousePos.AdjustX( -(maMouseOff.X()) ); |
463 | 0 | aMousePos.AdjustY( -(maMouseOff.Y()) ); |
464 | 0 | Point aFramePos = OutputToScreenPixel( aMousePos ); |
465 | 0 | tools::Rectangle aTrackRect( aFramePos, Size( mnTrackWidth, mnTrackHeight ) ); |
466 | 0 | tools::Rectangle aCompRect = aTrackRect; |
467 | 0 | aFramePos.AdjustX(maMouseOff.X() ); |
468 | 0 | aFramePos.AdjustY(maMouseOff.Y() ); |
469 | 0 | if ( mbDragFull ) |
470 | 0 | StartDocking(); |
471 | 0 | bool bFloatMode = Docking( aFramePos, aTrackRect ); |
472 | 0 | if ( mbLastFloatMode != bFloatMode ) |
473 | 0 | { |
474 | 0 | if ( bFloatMode ) |
475 | 0 | { |
476 | 0 | aTrackRect.AdjustLeft( -mnDockLeft ); |
477 | 0 | aTrackRect.AdjustTop( -mnDockTop ); |
478 | 0 | aTrackRect.AdjustRight(mnDockRight ); |
479 | 0 | aTrackRect.AdjustBottom(mnDockBottom ); |
480 | 0 | } |
481 | 0 | else |
482 | 0 | { |
483 | 0 | if ( aCompRect == aTrackRect ) |
484 | 0 | { |
485 | 0 | aTrackRect.AdjustLeft(mnDockLeft ); |
486 | 0 | aTrackRect.AdjustTop(mnDockTop ); |
487 | 0 | aTrackRect.AdjustRight( -mnDockRight ); |
488 | 0 | aTrackRect.AdjustBottom( -mnDockBottom ); |
489 | 0 | } |
490 | 0 | } |
491 | 0 | mbLastFloatMode = bFloatMode; |
492 | 0 | } |
493 | 0 | if ( mbDragFull ) |
494 | 0 | { |
495 | 0 | Point aOldPos = OutputToScreenPixel( Point() ); |
496 | 0 | EndDocking( aTrackRect, mbLastFloatMode ); |
497 | | // repaint if state or position has changed |
498 | 0 | if ( aOldPos != OutputToScreenPixel( Point() ) ) |
499 | 0 | { |
500 | 0 | ImplUpdateAll(); |
501 | 0 | ImplGetFrameWindow()->ImplUpdateAll(); |
502 | 0 | } |
503 | | // EndDocking( aTrackRect, mbLastFloatMode ); |
504 | 0 | } |
505 | 0 | else |
506 | 0 | { |
507 | 0 | ShowTrackFlags nTrackStyle; |
508 | 0 | if ( bFloatMode ) |
509 | 0 | nTrackStyle = ShowTrackFlags::Big; |
510 | 0 | else |
511 | 0 | nTrackStyle = ShowTrackFlags::Object; |
512 | 0 | tools::Rectangle aShowTrackRect = aTrackRect; |
513 | 0 | aShowTrackRect.SetPos( ScreenToOutputPixel( aShowTrackRect.TopLeft() ) ); |
514 | 0 | ShowTracking( aShowTrackRect, nTrackStyle ); |
515 | | |
516 | | // recalculate mouse offset, as the rectangle was changed |
517 | 0 | maMouseOff.setX( aFramePos.X() - aTrackRect.Left() ); |
518 | 0 | maMouseOff.setY( aFramePos.Y() - aTrackRect.Top() ); |
519 | 0 | } |
520 | |
|
521 | 0 | mnTrackX = aTrackRect.Left(); |
522 | 0 | mnTrackY = aTrackRect.Top(); |
523 | 0 | mnTrackWidth = aTrackRect.GetWidth(); |
524 | 0 | mnTrackHeight = aTrackRect.GetHeight(); |
525 | 0 | } |
526 | 0 | } |
527 | | |
528 | | bool DockingWindow::EventNotify( NotifyEvent& rNEvt ) |
529 | 0 | { |
530 | 0 | if( GetDockingManager()->IsDockable( this ) ) // new docking interface |
531 | 0 | return Window::EventNotify( rNEvt ); |
532 | | |
533 | 0 | if ( mbDockable ) |
534 | 0 | { |
535 | 0 | const bool bDockingSupportCrippled = !StyleSettings::GetDockingFloatsSupported(); |
536 | |
|
537 | 0 | if ( rNEvt.GetType() == NotifyEventType::MOUSEBUTTONDOWN ) |
538 | 0 | { |
539 | 0 | const MouseEvent* pMEvt = rNEvt.GetMouseEvent(); |
540 | 0 | if ( pMEvt->IsLeft() ) |
541 | 0 | { |
542 | 0 | if (!bDockingSupportCrippled && pMEvt->IsMod1() && (pMEvt->GetClicks() == 2) ) |
543 | 0 | { |
544 | 0 | SetFloatingMode( !IsFloatingMode() ); |
545 | 0 | if ( IsFloatingMode() ) |
546 | 0 | ToTop( ToTopFlags::GrabFocusOnly ); |
547 | 0 | return true; |
548 | 0 | } |
549 | 0 | else if ( pMEvt->GetClicks() == 1 ) |
550 | 0 | { |
551 | | // check if window is floating standalone (IsFloating()) |
552 | | // or only partially floating and still docked with one border |
553 | | // ( !mpWindowImpl->mbFrame) |
554 | 0 | if( ! IsFloatingMode() || ! mpFloatWin->mpWindowImpl->mbFrame ) |
555 | 0 | { |
556 | 0 | Point aPos = pMEvt->GetPosPixel(); |
557 | 0 | vcl::Window* pWindow = rNEvt.GetWindow(); |
558 | 0 | if ( pWindow != this ) |
559 | 0 | { |
560 | 0 | aPos = pWindow->OutputToScreenPixel( aPos ); |
561 | 0 | aPos = ScreenToOutputPixel( aPos ); |
562 | 0 | } |
563 | 0 | ImplStartDocking( aPos ); |
564 | 0 | } |
565 | 0 | return true; |
566 | 0 | } |
567 | 0 | } |
568 | 0 | } |
569 | 0 | else if( rNEvt.GetType() == NotifyEventType::KEYINPUT ) |
570 | 0 | { |
571 | 0 | const vcl::KeyCode& rKey = rNEvt.GetKeyEvent()->GetKeyCode(); |
572 | 0 | if( rKey.GetCode() == KEY_F10 && rKey.GetModifier() && |
573 | 0 | rKey.IsShift() && rKey.IsMod1() && !bDockingSupportCrippled ) |
574 | 0 | { |
575 | 0 | SetFloatingMode( !IsFloatingMode() ); |
576 | 0 | if ( IsFloatingMode() ) |
577 | 0 | ToTop( ToTopFlags::GrabFocusOnly ); |
578 | 0 | return true; |
579 | 0 | } |
580 | 0 | } |
581 | 0 | } |
582 | | |
583 | 0 | return Window::EventNotify( rNEvt ); |
584 | 0 | } |
585 | | |
586 | | void DockingWindow::StartDocking() |
587 | 0 | { |
588 | 0 | mbDocking = true; |
589 | 0 | } |
590 | | |
591 | | bool DockingWindow::Docking( const Point&, tools::Rectangle& ) |
592 | 0 | { |
593 | 0 | return IsFloatingMode(); |
594 | 0 | } |
595 | | |
596 | | void DockingWindow::EndDocking( const tools::Rectangle& rRect, bool bFloatMode ) |
597 | 0 | { |
598 | 0 | bool bOrigDockCanceled = mbDockCanceled; |
599 | 0 | if (bFloatMode && !StyleSettings::GetDockingFloatsSupported()) |
600 | 0 | mbDockCanceled = true; |
601 | |
|
602 | 0 | if ( !IsDockingCanceled() ) |
603 | 0 | { |
604 | 0 | if ( bFloatMode != IsFloatingMode() ) |
605 | 0 | { |
606 | 0 | SetFloatingMode( bFloatMode ); |
607 | 0 | if ( IsFloatingMode() ) |
608 | 0 | ToTop( ToTopFlags::GrabFocusOnly ); |
609 | 0 | if ( bFloatMode && mpFloatWin ) |
610 | 0 | mpFloatWin->SetPosSizePixel( rRect.TopLeft(), rRect.GetSize() ); |
611 | 0 | } |
612 | 0 | if ( !bFloatMode ) |
613 | 0 | { |
614 | 0 | Point aPos = rRect.TopLeft(); |
615 | 0 | aPos = GetParent()->ScreenToOutputPixel( aPos ); |
616 | 0 | Window::SetPosSizePixel( aPos, rRect.GetSize() ); |
617 | 0 | } |
618 | 0 | } |
619 | 0 | mbDocking = false; |
620 | 0 | mbDockCanceled = bOrigDockCanceled; |
621 | 0 | } |
622 | | |
623 | | bool DockingWindow::PrepareToggleFloatingMode() |
624 | 0 | { |
625 | 0 | return true; |
626 | 0 | } |
627 | | |
628 | | bool DockingWindow::Close() |
629 | 0 | { |
630 | 0 | VclPtr<vcl::Window> xWindow = this; |
631 | 0 | CallEventListeners( VclEventId::WindowClose ); |
632 | 0 | if ( xWindow->isDisposed() ) |
633 | 0 | return false; |
634 | | |
635 | 0 | if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() ) |
636 | 0 | return false; |
637 | | |
638 | 0 | Show( false, ShowFlags::NoFocusChange ); |
639 | 0 | return true; |
640 | 0 | } |
641 | | |
642 | | void DockingWindow::ToggleFloatingMode() |
643 | 0 | { |
644 | 0 | } |
645 | | |
646 | | void DockingWindow::Resizing( Size& ) |
647 | 0 | { |
648 | 0 | } |
649 | | |
650 | | void DockingWindow::DoInitialLayout() |
651 | 0 | { |
652 | 0 | if (GetSettings().GetStyleSettings().GetAutoMnemonic()) |
653 | 0 | GenerateAutoMnemonicsOnHierarchy(this); |
654 | |
|
655 | 0 | if (isLayoutEnabled()) |
656 | 0 | { |
657 | 0 | mbIsCalculatingInitialLayoutSize = true; |
658 | 0 | setDeferredProperties(); |
659 | 0 | if (IsFloatingMode()) |
660 | 0 | setOptimalLayoutSize(); |
661 | 0 | mbIsCalculatingInitialLayoutSize = false; |
662 | 0 | } |
663 | 0 | } |
664 | | |
665 | | void DockingWindow::StateChanged( StateChangedType nType ) |
666 | 0 | { |
667 | 0 | switch(nType) |
668 | 0 | { |
669 | 0 | case StateChangedType::InitShow: |
670 | 0 | DoInitialLayout(); |
671 | 0 | break; |
672 | | |
673 | 0 | case StateChangedType::ControlBackground: |
674 | 0 | ImplInitSettings(); |
675 | 0 | Invalidate(); |
676 | 0 | break; |
677 | | |
678 | 0 | case StateChangedType::Style: |
679 | 0 | mbDockable = (GetStyle() & WB_DOCKABLE) != 0; |
680 | 0 | break; |
681 | | |
682 | 0 | default: |
683 | 0 | break; |
684 | 0 | } |
685 | | |
686 | 0 | Window::StateChanged( nType ); |
687 | 0 | } |
688 | | |
689 | | void DockingWindow::DataChanged( const DataChangedEvent& rDCEvt ) |
690 | 0 | { |
691 | 0 | if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) && |
692 | 0 | (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) ) |
693 | 0 | { |
694 | 0 | ImplInitSettings(); |
695 | 0 | Invalidate(); |
696 | 0 | } |
697 | 0 | else |
698 | 0 | Window::DataChanged( rDCEvt ); |
699 | 0 | } |
700 | | |
701 | | void DockingWindow::SetFloatingMode( bool bFloatMode ) |
702 | 0 | { |
703 | 0 | ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); |
704 | 0 | if( pWrapper ) |
705 | 0 | { |
706 | 0 | pWrapper->SetFloatingMode( bFloatMode ); |
707 | 0 | return; |
708 | 0 | } |
709 | 0 | if ( IsFloatingMode() == bFloatMode ) |
710 | 0 | return; |
711 | | |
712 | 0 | if ( !PrepareToggleFloatingMode() ) // changes to floating mode can be vetoed |
713 | 0 | return; |
714 | | |
715 | 0 | bool bVisible = IsVisible(); |
716 | |
|
717 | 0 | if ( bFloatMode ) |
718 | 0 | { |
719 | | // set deferred properties early, so border width will end up |
720 | | // in our mpWindowImpl->mnBorderWidth, not in mpBorderWindow. |
721 | | // (see its usage in setPosSizeOnContainee and GetOptimalSize.) |
722 | 0 | setDeferredProperties(); |
723 | |
|
724 | 0 | Show( false, ShowFlags::NoFocusChange ); |
725 | |
|
726 | 0 | maDockPos = Window::GetPosPixel(); |
727 | |
|
728 | 0 | vcl::Window* pRealParent = mpWindowImpl->mpRealParent; |
729 | 0 | mpOldBorderWin = mpWindowImpl->mpBorderWindow; |
730 | |
|
731 | 0 | VclPtrInstance<ImplDockFloatWin> pWin( |
732 | 0 | mpImplData->mpParent, |
733 | 0 | mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ? mnFloatBits | WB_SYSTEMWINDOW : mnFloatBits, |
734 | 0 | this ); |
735 | 0 | mpFloatWin = pWin; |
736 | 0 | mpWindowImpl->mpBorderWindow = nullptr; |
737 | 0 | mpWindowImpl->mnLeftBorder = 0; |
738 | 0 | mpWindowImpl->mnTopBorder = 0; |
739 | 0 | mpWindowImpl->mnRightBorder = 0; |
740 | 0 | mpWindowImpl->mnBottomBorder = 0; |
741 | | // if the parent gets destroyed, we also have to reset the parent of the BorderWindow |
742 | 0 | if ( mpOldBorderWin ) |
743 | 0 | mpOldBorderWin->SetParent( pWin ); |
744 | | |
745 | | // #i123765# reset the buffered DropTargets when undocking, else it may not |
746 | | // be correctly initialized |
747 | 0 | mpWindowImpl->mxDNDListenerContainer.clear(); |
748 | |
|
749 | 0 | SetParent( pWin ); |
750 | 0 | SetPosPixel( Point() ); |
751 | 0 | mpWindowImpl->mpBorderWindow = pWin; |
752 | 0 | pWin->mpWindowImpl->mpClientWindow = this; |
753 | 0 | mpWindowImpl->mpRealParent = pRealParent; |
754 | 0 | pWin->SetText( Window::GetText() ); |
755 | 0 | Size aSize(Window::GetSizePixel()); |
756 | 0 | pWin->SetOutputSizePixel(aSize); |
757 | 0 | pWin->SetPosPixel( maFloatPos ); |
758 | | // pass on DockingData to FloatingWindow |
759 | 0 | pWin->ShowTitleButton( TitleButton::Docking, mbDockBtn ); |
760 | 0 | pWin->ShowTitleButton( TitleButton::Hide, mbHideBtn ); |
761 | 0 | pWin->SetMinOutputSizePixel( maMinOutSize ); |
762 | |
|
763 | 0 | pWin->SetMaxOutputSizePixel( mpImplData->maMaxOutSize ); |
764 | 0 | } |
765 | 0 | else |
766 | 0 | { |
767 | 0 | Show( false, ShowFlags::NoFocusChange ); |
768 | | |
769 | | // store FloatingData in FloatingWindow |
770 | 0 | maFloatPos = mpFloatWin->GetPosPixel(); |
771 | 0 | mbDockBtn = mpFloatWin->IsTitleButtonVisible( TitleButton::Docking ); |
772 | 0 | mbHideBtn = mpFloatWin->IsTitleButtonVisible( TitleButton::Hide ); |
773 | 0 | maMinOutSize = mpFloatWin->GetMinOutputSizePixel(); |
774 | 0 | mpImplData->maMaxOutSize = mpFloatWin->GetMaxOutputSizePixel(); |
775 | |
|
776 | 0 | vcl::Window* pRealParent = mpWindowImpl->mpRealParent; |
777 | 0 | mpWindowImpl->mpBorderWindow = nullptr; |
778 | 0 | if ( mpOldBorderWin ) |
779 | 0 | { |
780 | 0 | SetParent( mpOldBorderWin ); |
781 | 0 | static_cast<ImplBorderWindow*>(mpOldBorderWin.get())->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder ); |
782 | 0 | mpOldBorderWin->Resize(); |
783 | 0 | } |
784 | 0 | mpWindowImpl->mpBorderWindow = mpOldBorderWin; |
785 | 0 | SetParent( pRealParent ); |
786 | 0 | mpWindowImpl->mpRealParent = pRealParent; |
787 | 0 | mpFloatWin.disposeAndClear(); |
788 | 0 | SetPosPixel( maDockPos ); |
789 | 0 | } |
790 | |
|
791 | 0 | ToggleFloatingMode(); |
792 | |
|
793 | 0 | if (bVisible) |
794 | 0 | Show(); |
795 | |
|
796 | 0 | CallEventListeners(VclEventId::WindowToggleFloating); |
797 | 0 | } |
798 | | |
799 | | void DockingWindow::SetFloatStyle( WinBits nStyle ) |
800 | 0 | { |
801 | 0 | ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); |
802 | 0 | if( pWrapper ) |
803 | 0 | { |
804 | 0 | pWrapper->SetFloatStyle( nStyle ); |
805 | 0 | return; |
806 | 0 | } |
807 | | |
808 | 0 | mnFloatBits = nStyle; |
809 | 0 | } |
810 | | |
811 | | WinBits DockingWindow::GetFloatStyle() const |
812 | 0 | { |
813 | 0 | ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); |
814 | 0 | if( pWrapper ) |
815 | 0 | { |
816 | 0 | return pWrapper->GetFloatStyle(); |
817 | 0 | } |
818 | | |
819 | 0 | return mnFloatBits; |
820 | 0 | } |
821 | | |
822 | | void DockingWindow::setPosSizePixel( tools::Long nX, tools::Long nY, |
823 | | tools::Long nWidth, tools::Long nHeight, |
824 | | PosSizeFlags nFlags ) |
825 | 16.6k | { |
826 | 16.6k | ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); |
827 | 16.6k | if (pWrapper) |
828 | 0 | { |
829 | 0 | if (!pWrapper->mpFloatWin) |
830 | 0 | Window::setPosSizePixel( nX, nY, nWidth, nHeight, nFlags ); |
831 | 0 | } |
832 | 16.6k | else |
833 | 16.6k | { |
834 | 16.6k | if (!mpFloatWin) |
835 | 16.6k | Window::setPosSizePixel( nX, nY, nWidth, nHeight, nFlags ); |
836 | 0 | else if (comphelper::LibreOfficeKit::isActive()) |
837 | 0 | { |
838 | 0 | if ((nFlags & PosSizeFlags::Size) == PosSizeFlags::Size) |
839 | 0 | mpFloatWin->SetOutputSizePixel({ nWidth, nHeight }); |
840 | 0 | if ((nFlags & PosSizeFlags::Pos) == PosSizeFlags::Pos) |
841 | 0 | mpFloatWin->SetPosPixel({ nX, nY }); |
842 | 0 | } |
843 | 16.6k | } |
844 | | |
845 | 16.6k | if (::isLayoutEnabled(this)) |
846 | 0 | setPosSizeOnContainee(); |
847 | 16.6k | } |
848 | | |
849 | | Point DockingWindow::GetPosPixel() const |
850 | 0 | { |
851 | 0 | ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); |
852 | 0 | if( pWrapper ) |
853 | 0 | { |
854 | 0 | if ( pWrapper->mpFloatWin ) |
855 | 0 | return pWrapper->mpFloatWin->GetPosPixel(); |
856 | 0 | else |
857 | 0 | return Window::GetPosPixel(); |
858 | 0 | } |
859 | | |
860 | 0 | if ( mpFloatWin ) |
861 | 0 | return mpFloatWin->GetPosPixel(); |
862 | 0 | else |
863 | 0 | return Window::GetPosPixel(); |
864 | 0 | } |
865 | | |
866 | | Size DockingWindow::GetSizePixel() const |
867 | 16.6k | { |
868 | 16.6k | ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); |
869 | 16.6k | if( pWrapper ) |
870 | 0 | { |
871 | 0 | if ( pWrapper->mpFloatWin ) |
872 | 0 | return pWrapper->mpFloatWin->GetSizePixel(); |
873 | 0 | else |
874 | 0 | return Window::GetSizePixel(); |
875 | 0 | } |
876 | | |
877 | 16.6k | if ( mpFloatWin ) |
878 | 0 | return mpFloatWin->GetSizePixel(); |
879 | 16.6k | else |
880 | 16.6k | return Window::GetSizePixel(); |
881 | 16.6k | } |
882 | | |
883 | | void DockingWindow::SetOutputSizePixel( const Size& rNewSize ) |
884 | 0 | { |
885 | 0 | ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); |
886 | 0 | if( pWrapper ) |
887 | 0 | { |
888 | 0 | if ( pWrapper->mpFloatWin ) |
889 | 0 | pWrapper->mpFloatWin->SetOutputSizePixel( rNewSize ); |
890 | 0 | else |
891 | 0 | Window::SetOutputSizePixel( rNewSize ); |
892 | 0 | return; |
893 | 0 | } |
894 | | |
895 | 0 | if ( mpFloatWin ) |
896 | 0 | mpFloatWin->SetOutputSizePixel( rNewSize ); |
897 | 0 | else |
898 | 0 | Window::SetOutputSizePixel( rNewSize ); |
899 | 0 | } |
900 | | |
901 | | Size DockingWindow::GetOutputSizePixel() const |
902 | 0 | { |
903 | 0 | ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); |
904 | 0 | if( pWrapper ) |
905 | 0 | { |
906 | 0 | if ( pWrapper->mpFloatWin ) |
907 | 0 | return pWrapper->mpFloatWin->GetOutputSizePixel(); |
908 | 0 | else |
909 | 0 | return Window::GetOutputSizePixel(); |
910 | 0 | } |
911 | | |
912 | 0 | if ( mpFloatWin ) |
913 | 0 | return mpFloatWin->GetOutputSizePixel(); |
914 | 0 | else |
915 | 0 | return Window::GetOutputSizePixel(); |
916 | 0 | } |
917 | | |
918 | | Point DockingWindow::GetFloatingPos() const |
919 | 0 | { |
920 | 0 | ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); |
921 | 0 | if( pWrapper ) |
922 | 0 | { |
923 | 0 | if ( pWrapper->mpFloatWin ) |
924 | 0 | { |
925 | 0 | vcl::WindowData aData; |
926 | 0 | aData.setMask(vcl::WindowDataMask::Pos); |
927 | 0 | pWrapper->mpFloatWin->GetWindowState( aData ); |
928 | 0 | AbsoluteScreenPixelPoint aPos(aData.x(), aData.y()); |
929 | | // LOK needs logic coordinates not absolute screen position for autofilter menu |
930 | 0 | if (!comphelper::LibreOfficeKit::isActive()) |
931 | 0 | return pWrapper->mpFloatWin->GetParent()->ImplGetFrameWindow()->AbsoluteScreenToOutputPixel( aPos ); |
932 | 0 | return Point(aPos); |
933 | 0 | } |
934 | 0 | else |
935 | 0 | return maFloatPos; |
936 | 0 | } |
937 | | |
938 | 0 | if ( mpFloatWin ) |
939 | 0 | { |
940 | 0 | vcl::WindowData aData; |
941 | 0 | aData.setMask(vcl::WindowDataMask::Pos); |
942 | 0 | mpFloatWin->GetWindowState( aData ); |
943 | 0 | AbsoluteScreenPixelPoint aPos(aData.x(), aData.y()); |
944 | 0 | return mpFloatWin->GetParent()->ImplGetFrameWindow()->AbsoluteScreenToOutputPixel( aPos ); |
945 | 0 | } |
946 | 0 | else |
947 | 0 | return maFloatPos; |
948 | 0 | } |
949 | | |
950 | | bool DockingWindow::IsFloatingMode() const |
951 | 33.3k | { |
952 | 33.3k | ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); |
953 | 33.3k | if( pWrapper ) |
954 | 0 | return pWrapper->IsFloatingMode(); |
955 | 33.3k | else |
956 | 33.3k | return (mpFloatWin != nullptr); |
957 | 33.3k | } |
958 | | |
959 | | void DockingWindow::SetMaxOutputSizePixel( const Size& rSize ) |
960 | 0 | { |
961 | 0 | if ( mpFloatWin ) |
962 | 0 | mpFloatWin->SetMaxOutputSizePixel( rSize ); |
963 | 0 | mpImplData->maMaxOutSize = rSize; |
964 | 0 | } |
965 | | |
966 | | void DockingWindow::SetText(const OUString& rStr) |
967 | 0 | { |
968 | 0 | setDeferredProperties(); |
969 | 0 | Window::SetText(rStr); |
970 | 0 | } |
971 | | |
972 | | OUString DockingWindow::GetText() const |
973 | 0 | { |
974 | 0 | const_cast<DockingWindow*>(this)->setDeferredProperties(); |
975 | 0 | return Window::GetText(); |
976 | 0 | } |
977 | | |
978 | | bool DockingWindow::isLayoutEnabled() const |
979 | 0 | { |
980 | | //pre dtor called, and single child is a container => we're layout enabled |
981 | 0 | return mpImplData && ::isLayoutEnabled(this); |
982 | 0 | } |
983 | | |
984 | | void DockingWindow::setOptimalLayoutSize() |
985 | 0 | { |
986 | 0 | maLayoutIdle.Stop(); |
987 | | |
988 | | //resize DockingWindow to fit requisition on initial show |
989 | 0 | Size aSize = get_preferred_size(); |
990 | |
|
991 | 0 | Size aMax(bestmaxFrameSizeForScreenSize(Size(GetDesktopRectPixel().GetSize()))); |
992 | |
|
993 | 0 | aSize.setWidth( std::min(aMax.Width(), aSize.Width()) ); |
994 | 0 | aSize.setHeight( std::min(aMax.Height(), aSize.Height()) ); |
995 | |
|
996 | 0 | SetMinOutputSizePixel(aSize); |
997 | 0 | setPosSizeOnContainee(); |
998 | 0 | } |
999 | | |
1000 | | void DockingWindow::setPosSizeOnContainee() |
1001 | 0 | { |
1002 | 0 | Size aSize = GetOutputSizePixel(); |
1003 | | |
1004 | | // Don't make the border width accessible via get_border_width(), |
1005 | | // otherwise the floating window will handle the border as well. |
1006 | 0 | sal_Int32 nBorderWidth = mpWindowImpl->mnBorderWidth; |
1007 | |
|
1008 | 0 | aSize.AdjustWidth( -(2 * nBorderWidth) ); |
1009 | 0 | aSize.AdjustHeight( -(2 * nBorderWidth) ); |
1010 | |
|
1011 | 0 | Window* pBox = GetWindow(GetWindowType::FirstChild); |
1012 | 0 | assert(pBox); |
1013 | 0 | VclContainer::setLayoutAllocation(*pBox, Point(nBorderWidth, nBorderWidth), aSize); |
1014 | 0 | } |
1015 | | |
1016 | | Size DockingWindow::GetOptimalSize() const |
1017 | 0 | { |
1018 | 0 | if (!isLayoutEnabled()) |
1019 | 0 | return Window::GetOptimalSize(); |
1020 | | |
1021 | 0 | Size aSize = VclContainer::getLayoutRequisition(*GetWindow(GetWindowType::FirstChild)); |
1022 | | |
1023 | | // Don't make the border width accessible via get_border_width(), |
1024 | | // otherwise the floating window will handle the border as well. |
1025 | 0 | sal_Int32 nBorderWidth = mpWindowImpl->mnBorderWidth; |
1026 | |
|
1027 | 0 | aSize.AdjustHeight(2 * nBorderWidth ); |
1028 | 0 | aSize.AdjustWidth(2 * nBorderWidth ); |
1029 | |
|
1030 | 0 | return aSize; |
1031 | 0 | } |
1032 | | |
1033 | | void DockingWindow::queue_resize(StateChangedType eReason) |
1034 | 0 | { |
1035 | 0 | bool bTriggerLayout = true; |
1036 | 0 | if (maLayoutIdle.IsActive() || mbIsCalculatingInitialLayoutSize) |
1037 | 0 | { |
1038 | 0 | bTriggerLayout = false; |
1039 | 0 | } |
1040 | 0 | if (!isLayoutEnabled()) |
1041 | 0 | { |
1042 | 0 | bTriggerLayout = false; |
1043 | 0 | } |
1044 | 0 | if (bTriggerLayout) |
1045 | 0 | { |
1046 | 0 | InvalidateSizeCache(); |
1047 | 0 | maLayoutIdle.Start(); |
1048 | 0 | } |
1049 | 0 | vcl::Window::queue_resize(eReason); |
1050 | 0 | } |
1051 | | |
1052 | | IMPL_LINK_NOARG(DockingWindow, ImplHandleLayoutTimerHdl, Timer*, void) |
1053 | 0 | { |
1054 | 0 | if (!isLayoutEnabled()) |
1055 | 0 | { |
1056 | 0 | SAL_WARN_IF(GetWindow(GetWindowType::FirstChild), "vcl.layout", "DockingWindow has become non-layout because extra children have been added directly to it."); |
1057 | 0 | return; |
1058 | 0 | } |
1059 | 0 | setPosSizeOnContainee(); |
1060 | 0 | } |
1061 | | |
1062 | | void DockingWindow::SetMinOutputSizePixel( const Size& rSize ) |
1063 | 0 | { |
1064 | 0 | if ( mpFloatWin ) |
1065 | 0 | mpFloatWin->SetMinOutputSizePixel( rSize ); |
1066 | 0 | maMinOutSize = rSize; |
1067 | 0 | } |
1068 | | |
1069 | | const Size& DockingWindow::GetMinOutputSizePixel() const |
1070 | 0 | { |
1071 | 0 | if ( mpFloatWin ) |
1072 | 0 | return mpFloatWin->GetMinOutputSizePixel(); |
1073 | 0 | return maMinOutSize; |
1074 | 0 | } |
1075 | | |
1076 | | void DockingWindow::SetFloatingPos( const Point& rNewPos ) |
1077 | 0 | { |
1078 | 0 | if ( mpFloatWin ) |
1079 | 0 | mpFloatWin->SetPosPixel( rNewPos ); |
1080 | 0 | else |
1081 | 0 | maFloatPos = rNewPos; |
1082 | 0 | } |
1083 | | |
1084 | | SystemWindow* DockingWindow::GetFloatingWindow() const |
1085 | 0 | { |
1086 | 0 | return mpFloatWin; |
1087 | 0 | } |
1088 | | |
1089 | | DropdownDockingWindow::DropdownDockingWindow(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rFrame, bool bTearable) |
1090 | 0 | : DockingWindow(pParent, |
1091 | 0 | !bTearable ? u"InterimDockParent"_ustr : u"InterimTearableParent"_ustr, |
1092 | 0 | !bTearable ? u"vcl/ui/interimdockparent.ui"_ustr : u"vcl/ui/interimtearableparent.ui"_ustr, |
1093 | 0 | "vcl::DropdownDockingWindow maLayoutIdle", |
1094 | 0 | rFrame) |
1095 | 0 | , m_xBox(m_pUIBuilder->get(u"box")) |
1096 | 0 | { |
1097 | 0 | } Unexecuted instantiation: DropdownDockingWindow::DropdownDockingWindow(vcl::Window*, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, bool) Unexecuted instantiation: DropdownDockingWindow::DropdownDockingWindow(vcl::Window*, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, bool) |
1098 | | |
1099 | | DropdownDockingWindow::~DropdownDockingWindow() |
1100 | 0 | { |
1101 | 0 | disposeOnce(); |
1102 | 0 | } |
1103 | | |
1104 | | void DropdownDockingWindow::dispose() |
1105 | 0 | { |
1106 | 0 | m_xBox.reset(); |
1107 | 0 | DockingWindow::dispose(); |
1108 | 0 | } |
1109 | | |
1110 | | ResizableDockingWindow::ResizableDockingWindow(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rFrame) |
1111 | 0 | : DockingWindow(pParent, u"DockingWindow"_ustr, u"vcl/ui/dockingwindow.ui"_ustr, "vcl::ResizableDockingWindow maLayoutIdle", rFrame) |
1112 | 0 | , m_xBox(m_pUIBuilder->get(u"box")) |
1113 | 0 | { |
1114 | 0 | } Unexecuted instantiation: ResizableDockingWindow::ResizableDockingWindow(vcl::Window*, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) Unexecuted instantiation: ResizableDockingWindow::ResizableDockingWindow(vcl::Window*, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) |
1115 | | |
1116 | | ResizableDockingWindow::ResizableDockingWindow(vcl::Window* pParent, WinBits nStyle) |
1117 | 0 | : DockingWindow(pParent, nStyle, "vcl::ResizableDockingWindow maLayoutIdle") |
1118 | 0 | { |
1119 | 0 | } Unexecuted instantiation: ResizableDockingWindow::ResizableDockingWindow(vcl::Window*, long) Unexecuted instantiation: ResizableDockingWindow::ResizableDockingWindow(vcl::Window*, long) |
1120 | | |
1121 | | // needed to blow away the cached size of the boundary between vcl and hosted child widget |
1122 | | void ResizableDockingWindow::InvalidateChildSizeCache() |
1123 | 0 | { |
1124 | | // find the bottom vcl::Window of the hierarchy and queue_resize on that |
1125 | | // one will invalidate all the size caches upwards |
1126 | 0 | vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); |
1127 | 0 | while (true) |
1128 | 0 | { |
1129 | 0 | vcl::Window* pSubChild = pChild->GetWindow(GetWindowType::FirstChild); |
1130 | 0 | if (!pSubChild) |
1131 | 0 | break; |
1132 | 0 | pChild = pSubChild; |
1133 | 0 | } |
1134 | 0 | pChild->queue_resize(); |
1135 | 0 | } |
1136 | | |
1137 | | ResizableDockingWindow::~ResizableDockingWindow() |
1138 | 0 | { |
1139 | 0 | disposeOnce(); |
1140 | 0 | } |
1141 | | |
1142 | | void ResizableDockingWindow::dispose() |
1143 | 0 | { |
1144 | 0 | m_xBox.reset(); |
1145 | 0 | DockingWindow::dispose(); |
1146 | 0 | } |
1147 | | |
1148 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |