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