/src/libreoffice/vcl/source/window/window2.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 <limits.h> |
21 | | |
22 | | #include <o3tl/float_int_conversion.hxx> |
23 | | #include <sal/log.hxx> |
24 | | |
25 | | #include <tools/helpers.hxx> |
26 | | #include <tools/mapunit.hxx> |
27 | | |
28 | | #include <vcl/toolkit/dialog.hxx> |
29 | | #include <vcl/event.hxx> |
30 | | #include <vcl/toolkit/fixed.hxx> |
31 | | #include <vcl/layout.hxx> |
32 | | #include <vcl/timer.hxx> |
33 | | #include <vcl/window.hxx> |
34 | | #include <vcl/scrollable.hxx> |
35 | | #include <vcl/toolkit/scrbar.hxx> |
36 | | #include <vcl/dockwin.hxx> |
37 | | #include <vcl/settings.hxx> |
38 | | #include <vcl/builder.hxx> |
39 | | #include <o3tl/string_view.hxx> |
40 | | |
41 | | #include <window.h> |
42 | | #include <svdata.hxx> |
43 | | #include <salgdi.hxx> |
44 | | #include <salframe.hxx> |
45 | | #include <scrwnd.hxx> |
46 | | |
47 | | #include <com/sun/star/accessibility/AccessibleRelation.hpp> |
48 | | #include <com/sun/star/accessibility/AccessibleRole.hpp> |
49 | | |
50 | | using namespace com::sun::star; |
51 | | |
52 | | namespace vcl { |
53 | | |
54 | | void Window::ShowFocus( const tools::Rectangle& rRect ) |
55 | 0 | { |
56 | 0 | if( mpWindowImpl->mbInShowFocus ) |
57 | 0 | return; |
58 | 0 | mpWindowImpl->mbInShowFocus = true; |
59 | |
|
60 | 0 | ImplWinData* pWinData = ImplGetWinData(); |
61 | | |
62 | | // native themeing suggest not to use focus rects |
63 | 0 | if( ! ( mpWindowImpl->mbUseNativeFocus && |
64 | 0 | IsNativeWidgetEnabled() ) ) |
65 | 0 | { |
66 | 0 | if ( !mpWindowImpl->mbInPaint ) |
67 | 0 | { |
68 | 0 | if ( mpWindowImpl->mbFocusVisible ) |
69 | 0 | { |
70 | 0 | if ( *pWinData->mpFocusRect == rRect ) |
71 | 0 | { |
72 | 0 | mpWindowImpl->mbInShowFocus = false; |
73 | 0 | return; |
74 | 0 | } |
75 | | |
76 | 0 | ImplInvertFocus( *pWinData->mpFocusRect ); |
77 | 0 | } |
78 | | |
79 | 0 | ImplInvertFocus( rRect ); |
80 | 0 | } |
81 | 0 | pWinData->mpFocusRect = rRect; |
82 | 0 | mpWindowImpl->mbFocusVisible = true; |
83 | 0 | } |
84 | 0 | else |
85 | 0 | { |
86 | 0 | if( ! mpWindowImpl->mbNativeFocusVisible ) |
87 | 0 | { |
88 | 0 | mpWindowImpl->mbNativeFocusVisible = true; |
89 | 0 | if ( !mpWindowImpl->mbInPaint ) |
90 | 0 | Invalidate(); |
91 | 0 | } |
92 | 0 | } |
93 | 0 | mpWindowImpl->mbInShowFocus = false; |
94 | 0 | } |
95 | | |
96 | | void Window::HideFocus() |
97 | 0 | { |
98 | |
|
99 | 0 | if( mpWindowImpl->mbInHideFocus ) |
100 | 0 | return; |
101 | 0 | mpWindowImpl->mbInHideFocus = true; |
102 | | |
103 | | // native themeing can suggest not to use focus rects |
104 | 0 | if( ! ( mpWindowImpl->mbUseNativeFocus && |
105 | 0 | IsNativeWidgetEnabled() ) ) |
106 | 0 | { |
107 | 0 | if ( !mpWindowImpl->mbFocusVisible ) |
108 | 0 | { |
109 | 0 | mpWindowImpl->mbInHideFocus = false; |
110 | 0 | return; |
111 | 0 | } |
112 | | |
113 | 0 | if ( !mpWindowImpl->mbInPaint ) |
114 | 0 | ImplInvertFocus( *ImplGetWinData()->mpFocusRect ); |
115 | 0 | mpWindowImpl->mbFocusVisible = false; |
116 | 0 | } |
117 | 0 | else |
118 | 0 | { |
119 | 0 | if( mpWindowImpl->mbNativeFocusVisible ) |
120 | 0 | { |
121 | 0 | mpWindowImpl->mbNativeFocusVisible = false; |
122 | 0 | if ( !mpWindowImpl->mbInPaint ) |
123 | 0 | Invalidate(); |
124 | 0 | } |
125 | 0 | } |
126 | 0 | mpWindowImpl->mbInHideFocus = false; |
127 | 0 | } |
128 | | |
129 | | void Window::ShowTracking( const tools::Rectangle& rRect, ShowTrackFlags nFlags ) |
130 | 0 | { |
131 | 0 | ImplWinData* pWinData = ImplGetWinData(); |
132 | |
|
133 | 0 | if ( !mpWindowImpl->mbInPaint || !(nFlags & ShowTrackFlags::TrackWindow) ) |
134 | 0 | { |
135 | 0 | if ( mpWindowImpl->mbTrackVisible ) |
136 | 0 | { |
137 | 0 | if ( (*pWinData->mpTrackRect == rRect) && |
138 | 0 | (pWinData->mnTrackFlags == nFlags) ) |
139 | 0 | return; |
140 | | |
141 | 0 | InvertTracking( *pWinData->mpTrackRect, pWinData->mnTrackFlags ); |
142 | 0 | } |
143 | | |
144 | 0 | InvertTracking( rRect, nFlags ); |
145 | 0 | } |
146 | | |
147 | 0 | pWinData->mpTrackRect = rRect; |
148 | 0 | pWinData->mnTrackFlags = nFlags; |
149 | 0 | mpWindowImpl->mbTrackVisible = true; |
150 | 0 | } |
151 | | |
152 | | void Window::HideTracking() |
153 | 0 | { |
154 | 0 | if ( mpWindowImpl->mbTrackVisible ) |
155 | 0 | { |
156 | 0 | ImplWinData* pWinData = ImplGetWinData(); |
157 | 0 | if ( !mpWindowImpl->mbInPaint || !(pWinData->mnTrackFlags & ShowTrackFlags::TrackWindow) ) |
158 | 0 | InvertTracking( *pWinData->mpTrackRect, pWinData->mnTrackFlags ); |
159 | 0 | mpWindowImpl->mbTrackVisible = false; |
160 | 0 | } |
161 | 0 | } |
162 | | |
163 | | void Window::InvertTracking( const tools::Rectangle& rRect, ShowTrackFlags nFlags ) |
164 | 0 | { |
165 | 0 | OutputDevice *pOutDev = GetOutDev(); |
166 | 0 | tools::Rectangle aRect(pOutDev->LogicToDevicePixel(rRect)); |
167 | |
|
168 | 0 | if ( aRect.IsEmpty() ) |
169 | 0 | return; |
170 | 0 | aRect.Normalize(); |
171 | |
|
172 | 0 | SalGraphics* pGraphics; |
173 | |
|
174 | 0 | if ( nFlags & ShowTrackFlags::TrackWindow ) |
175 | 0 | { |
176 | 0 | if ( !GetOutDev()->IsDeviceOutputNecessary() ) |
177 | 0 | return; |
178 | | |
179 | | // we need a graphics |
180 | 0 | if ( !GetOutDev()->mpGraphics ) |
181 | 0 | { |
182 | 0 | if ( !pOutDev->AcquireGraphics() ) |
183 | 0 | return; |
184 | 0 | } |
185 | | |
186 | 0 | if ( GetOutDev()->mbInitClipRegion ) |
187 | 0 | GetOutDev()->InitClipRegion(); |
188 | |
|
189 | 0 | if ( GetOutDev()->mbOutputClipped ) |
190 | 0 | return; |
191 | | |
192 | 0 | pGraphics = GetOutDev()->mpGraphics; |
193 | 0 | } |
194 | 0 | else |
195 | 0 | { |
196 | 0 | pGraphics = ImplGetFrameGraphics(); |
197 | |
|
198 | 0 | if ( nFlags & ShowTrackFlags::Clip ) |
199 | 0 | { |
200 | 0 | vcl::Region aRegion( GetOutputRectPixel() ); |
201 | 0 | ImplClipBoundaries( aRegion, false, false ); |
202 | 0 | pOutDev->SelectClipRegion( aRegion, pGraphics ); |
203 | 0 | } |
204 | 0 | } |
205 | | |
206 | 0 | ShowTrackFlags nStyle = nFlags & ShowTrackFlags::StyleMask; |
207 | 0 | if ( nStyle == ShowTrackFlags::Object ) |
208 | 0 | pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SalInvert::TrackFrame, *GetOutDev() ); |
209 | 0 | else if ( nStyle == ShowTrackFlags::Split ) |
210 | 0 | pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SalInvert::N50, *GetOutDev() ); |
211 | 0 | else |
212 | 0 | { |
213 | 0 | tools::Long nBorder = 1; |
214 | 0 | if ( nStyle == ShowTrackFlags::Big ) |
215 | 0 | nBorder = 5; |
216 | 0 | pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), nBorder, SalInvert::N50, *GetOutDev() ); |
217 | 0 | pGraphics->Invert( aRect.Left(), aRect.Bottom()-nBorder+1, aRect.GetWidth(), nBorder, SalInvert::N50, *GetOutDev() ); |
218 | 0 | pGraphics->Invert( aRect.Left(), aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SalInvert::N50, *GetOutDev() ); |
219 | 0 | pGraphics->Invert( aRect.Right()-nBorder+1, aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SalInvert::N50, *GetOutDev() ); |
220 | 0 | } |
221 | 0 | } |
222 | | |
223 | | IMPL_LINK( Window, ImplTrackTimerHdl, Timer*, pTimer, void ) |
224 | 0 | { |
225 | 0 | if (!mpWindowImpl) |
226 | 0 | { |
227 | 0 | SAL_WARN("vcl", "ImplTrackTimerHdl has outlived dispose"); |
228 | 0 | return; |
229 | 0 | } |
230 | | |
231 | 0 | ImplSVData* pSVData = ImplGetSVData(); |
232 | | |
233 | | // if Button-Repeat we have to change the timeout |
234 | 0 | if ( pSVData->mpWinData->mnTrackFlags & StartTrackingFlags::ButtonRepeat ) |
235 | 0 | pTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonRepeat() ); |
236 | | |
237 | | // create Tracking-Event |
238 | 0 | Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY ); |
239 | 0 | if( GetOutDev()->ImplIsAntiparallel() ) |
240 | 0 | { |
241 | | // re-mirror frame pos at pChild |
242 | 0 | const OutputDevice *pOutDev = GetOutDev(); |
243 | 0 | pOutDev->ReMirror( aMousePos ); |
244 | 0 | } |
245 | 0 | MouseEvent aMEvt( ScreenToOutputPixel( aMousePos ), |
246 | 0 | mpWindowImpl->mpFrameData->mnClickCount, MouseEventModifiers::NONE, |
247 | 0 | mpWindowImpl->mpFrameData->mnMouseCode, |
248 | 0 | mpWindowImpl->mpFrameData->mnMouseCode ); |
249 | 0 | TrackingEvent aTEvt( aMEvt, TrackingEventFlags::Repeat ); |
250 | 0 | Tracking( aTEvt ); |
251 | 0 | } |
252 | | |
253 | | void Window::SetUseFrameData(bool bUseFrameData) |
254 | 0 | { |
255 | 0 | if (mpWindowImpl) |
256 | 0 | mpWindowImpl->mbUseFrameData = bUseFrameData; |
257 | 0 | } |
258 | | |
259 | | void Window::StartTracking( StartTrackingFlags nFlags ) |
260 | 0 | { |
261 | 0 | if (!mpWindowImpl) |
262 | 0 | return; |
263 | | |
264 | 0 | ImplSVData* pSVData = ImplGetSVData(); |
265 | 0 | VclPtr<vcl::Window> pTrackWin = mpWindowImpl->mbUseFrameData ? |
266 | 0 | mpWindowImpl->mpFrameData->mpTrackWin : |
267 | 0 | pSVData->mpWinData->mpTrackWin; |
268 | |
|
269 | 0 | if ( pTrackWin.get() != this ) |
270 | 0 | { |
271 | 0 | if ( pTrackWin ) |
272 | 0 | pTrackWin->EndTracking( TrackingEventFlags::Cancel ); |
273 | 0 | } |
274 | |
|
275 | 0 | SAL_WARN_IF(pSVData->mpWinData->mpTrackTimer, "vcl", "StartTracking called while TrackerTimer still running"); |
276 | | |
277 | 0 | if ( !mpWindowImpl->mbUseFrameData && |
278 | 0 | (nFlags & (StartTrackingFlags::ScrollRepeat | StartTrackingFlags::ButtonRepeat)) ) |
279 | 0 | { |
280 | 0 | pSVData->mpWinData->mpTrackTimer.reset(new AutoTimer("vcl::Window pSVData->mpWinData->mpTrackTimer")); |
281 | |
|
282 | 0 | if ( nFlags & StartTrackingFlags::ScrollRepeat ) |
283 | 0 | pSVData->mpWinData->mpTrackTimer->SetTimeout( MouseSettings::GetScrollRepeat() ); |
284 | 0 | else |
285 | 0 | pSVData->mpWinData->mpTrackTimer->SetTimeout( MouseSettings::GetButtonStartRepeat() ); |
286 | 0 | pSVData->mpWinData->mpTrackTimer->SetInvokeHandler( LINK( this, Window, ImplTrackTimerHdl ) ); |
287 | 0 | pSVData->mpWinData->mpTrackTimer->Start(); |
288 | 0 | } |
289 | |
|
290 | 0 | if (mpWindowImpl->mbUseFrameData) |
291 | 0 | { |
292 | 0 | mpWindowImpl->mpFrameData->mpTrackWin = this; |
293 | 0 | } |
294 | 0 | else |
295 | 0 | { |
296 | 0 | pSVData->mpWinData->mpTrackWin = this; |
297 | 0 | pSVData->mpWinData->mnTrackFlags = nFlags; |
298 | 0 | CaptureMouse(); |
299 | 0 | } |
300 | 0 | } |
301 | | |
302 | | void Window::EndTracking( TrackingEventFlags nFlags ) |
303 | 0 | { |
304 | 0 | if (!mpWindowImpl) |
305 | 0 | return; |
306 | | |
307 | 0 | ImplSVData* pSVData = ImplGetSVData(); |
308 | 0 | VclPtr<vcl::Window> pTrackWin = mpWindowImpl->mbUseFrameData ? |
309 | 0 | mpWindowImpl->mpFrameData->mpTrackWin : |
310 | 0 | pSVData->mpWinData->mpTrackWin; |
311 | |
|
312 | 0 | if ( pTrackWin.get() != this ) |
313 | 0 | return; |
314 | | |
315 | 0 | if ( !mpWindowImpl->mbUseFrameData && pSVData->mpWinData->mpTrackTimer ) |
316 | 0 | pSVData->mpWinData->mpTrackTimer.reset(); |
317 | |
|
318 | 0 | mpWindowImpl->mpFrameData->mpTrackWin = pSVData->mpWinData->mpTrackWin = nullptr; |
319 | 0 | pSVData->mpWinData->mnTrackFlags = StartTrackingFlags::NONE; |
320 | 0 | ReleaseMouse(); |
321 | | |
322 | | // call EndTracking if required |
323 | 0 | if (mpWindowImpl->mpFrameData) |
324 | 0 | { |
325 | 0 | Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY ); |
326 | 0 | if( GetOutDev()->ImplIsAntiparallel() ) |
327 | 0 | { |
328 | | // re-mirror frame pos at pChild |
329 | 0 | const OutputDevice *pOutDev = GetOutDev(); |
330 | 0 | pOutDev->ReMirror( aMousePos ); |
331 | 0 | } |
332 | |
|
333 | 0 | MouseEvent aMEvt( ScreenToOutputPixel( aMousePos ), |
334 | 0 | mpWindowImpl->mpFrameData->mnClickCount, MouseEventModifiers::NONE, |
335 | 0 | mpWindowImpl->mpFrameData->mnMouseCode, |
336 | 0 | mpWindowImpl->mpFrameData->mnMouseCode ); |
337 | 0 | TrackingEvent aTEvt( aMEvt, nFlags | TrackingEventFlags::End ); |
338 | | // CompatTracking effectively |
339 | 0 | if (!mpWindowImpl || mpWindowImpl->mbInDispose) |
340 | 0 | return Window::Tracking( aTEvt ); |
341 | 0 | else |
342 | 0 | return Tracking( aTEvt ); |
343 | 0 | } |
344 | 0 | } |
345 | | |
346 | | bool Window::IsTracking() const |
347 | 0 | { |
348 | 0 | if (!mpWindowImpl) |
349 | 0 | return false; |
350 | 0 | if (mpWindowImpl->mbUseFrameData && mpWindowImpl->mpFrameData) |
351 | 0 | { |
352 | 0 | return mpWindowImpl->mpFrameData->mpTrackWin == this; |
353 | 0 | } |
354 | 0 | if (!mpWindowImpl->mbUseFrameData && ImplGetSVData()->mpWinData) |
355 | 0 | { |
356 | 0 | return ImplGetSVData()->mpWinData->mpTrackWin == this; |
357 | 0 | } |
358 | 0 | return false; |
359 | 0 | } |
360 | | |
361 | | void Window::StartAutoScroll( StartAutoScrollFlags nFlags ) |
362 | 0 | { |
363 | 0 | ImplSVData* pSVData = ImplGetSVData(); |
364 | |
|
365 | 0 | if ( pSVData->mpWinData->mpAutoScrollWin.get() != this ) |
366 | 0 | { |
367 | 0 | if ( pSVData->mpWinData->mpAutoScrollWin ) |
368 | 0 | pSVData->mpWinData->mpAutoScrollWin->EndAutoScroll(); |
369 | 0 | } |
370 | |
|
371 | 0 | pSVData->mpWinData->mpAutoScrollWin = this; |
372 | 0 | pSVData->mpWinData->mnAutoScrollFlags = nFlags; |
373 | 0 | pSVData->maAppData.mpWheelWindow = VclPtr<ImplWheelWindow>::Create( this ); |
374 | 0 | } |
375 | | |
376 | | void Window::EndAutoScroll() |
377 | 0 | { |
378 | 0 | ImplSVData* pSVData = ImplGetSVData(); |
379 | |
|
380 | 0 | if ( pSVData->mpWinData->mpAutoScrollWin.get() == this ) |
381 | 0 | { |
382 | 0 | pSVData->mpWinData->mpAutoScrollWin = nullptr; |
383 | 0 | pSVData->mpWinData->mnAutoScrollFlags = StartAutoScrollFlags::NONE; |
384 | 0 | pSVData->maAppData.mpWheelWindow->ImplStop(); |
385 | 0 | pSVData->maAppData.mpWheelWindow.disposeAndClear(); |
386 | 0 | } |
387 | 0 | } |
388 | | |
389 | | VclPtr<vcl::Window> Window::SaveFocus() |
390 | 0 | { |
391 | 0 | ImplSVData* pSVData = ImplGetSVData(); |
392 | 0 | if ( pSVData->mpWinData->mpFocusWin ) |
393 | 0 | { |
394 | 0 | return pSVData->mpWinData->mpFocusWin; |
395 | 0 | } |
396 | 0 | else |
397 | 0 | return nullptr; |
398 | 0 | } |
399 | | |
400 | | void Window::EndSaveFocus(const VclPtr<vcl::Window>& xFocusWin) |
401 | 0 | { |
402 | 0 | if (xFocusWin && !xFocusWin->isDisposed()) |
403 | 0 | { |
404 | 0 | xFocusWin->GrabFocus(); |
405 | 0 | } |
406 | 0 | } |
407 | | |
408 | | void Window::SetZoom( double fZoom ) |
409 | 0 | { |
410 | 0 | if ( mpWindowImpl && mpWindowImpl->mfZoom != fZoom ) |
411 | 0 | { |
412 | 0 | mpWindowImpl->mfZoom = fZoom; |
413 | 0 | CompatStateChanged( StateChangedType::Zoom ); |
414 | 0 | } |
415 | 0 | } |
416 | | |
417 | | void Window::SetZoomedPointFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont) |
418 | 16.7k | { |
419 | 16.7k | double fZoom = GetZoom(); |
420 | 16.7k | if (fZoom != 1.0) |
421 | 0 | { |
422 | 0 | vcl::Font aFont(rFont); |
423 | 0 | Size aSize = aFont.GetFontSize(); |
424 | 0 | aSize.setWidth(basegfx::fround<tools::Long>(aSize.Width() * fZoom)); |
425 | 0 | aSize.setHeight(basegfx::fround<tools::Long>(aSize.Height() * fZoom)); |
426 | 0 | aFont.SetFontSize(aSize); |
427 | 0 | SetPointFont(rRenderContext, aFont); |
428 | 0 | } |
429 | 16.7k | else |
430 | 16.7k | { |
431 | 16.7k | SetPointFont(rRenderContext, rFont); |
432 | 16.7k | } |
433 | 16.7k | } |
434 | | |
435 | | tools::Long Window::CalcZoom( tools::Long nCalc ) const |
436 | 0 | { |
437 | 0 | double fZoom = GetZoom(); |
438 | 0 | if ( fZoom != 1.0) |
439 | 0 | { |
440 | 0 | double n = nCalc * fZoom; |
441 | 0 | nCalc = basegfx::fround<tools::Long>(n); |
442 | 0 | } |
443 | 0 | return nCalc; |
444 | 0 | } |
445 | | |
446 | | void Window::SetControlFont() |
447 | 0 | { |
448 | 0 | if (mpWindowImpl && mpWindowImpl->mpControlFont) |
449 | 0 | { |
450 | 0 | mpWindowImpl->mpControlFont.reset(); |
451 | 0 | CompatStateChanged(StateChangedType::ControlFont); |
452 | 0 | } |
453 | 0 | } |
454 | | |
455 | | void Window::SetControlFont(const vcl::Font& rFont) |
456 | 0 | { |
457 | 0 | if (rFont == vcl::Font()) |
458 | 0 | { |
459 | 0 | SetControlFont(); |
460 | 0 | return; |
461 | 0 | } |
462 | | |
463 | 0 | if (mpWindowImpl->mpControlFont) |
464 | 0 | { |
465 | 0 | if (*mpWindowImpl->mpControlFont == rFont) |
466 | 0 | return; |
467 | 0 | *mpWindowImpl->mpControlFont = rFont; |
468 | 0 | } |
469 | 0 | else |
470 | 0 | mpWindowImpl->mpControlFont = rFont; |
471 | | |
472 | 0 | CompatStateChanged(StateChangedType::ControlFont); |
473 | 0 | } |
474 | | |
475 | | vcl::Font Window::GetControlFont() const |
476 | 0 | { |
477 | 0 | if (mpWindowImpl->mpControlFont) |
478 | 0 | return *mpWindowImpl->mpControlFont; |
479 | 0 | else |
480 | 0 | { |
481 | 0 | vcl::Font aFont; |
482 | 0 | return aFont; |
483 | 0 | } |
484 | 0 | } |
485 | | |
486 | | void Window::ApplyControlFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont) |
487 | 16.7k | { |
488 | 16.7k | vcl::Font aFont(rFont); |
489 | 16.7k | if (IsControlFont()) |
490 | 0 | aFont.Merge(GetControlFont()); |
491 | 16.7k | SetZoomedPointFont(rRenderContext, aFont); |
492 | 16.7k | } |
493 | | |
494 | | void Window::SetControlForeground() |
495 | 0 | { |
496 | 0 | if (mpWindowImpl->mbControlForeground) |
497 | 0 | { |
498 | 0 | mpWindowImpl->maControlForeground = COL_TRANSPARENT; |
499 | 0 | mpWindowImpl->mbControlForeground = false; |
500 | 0 | CompatStateChanged(StateChangedType::ControlForeground); |
501 | 0 | } |
502 | 0 | } |
503 | | |
504 | | void Window::SetControlForeground(const Color& rColor) |
505 | 0 | { |
506 | 0 | if (rColor.IsTransparent()) |
507 | 0 | { |
508 | 0 | if (mpWindowImpl->mbControlForeground) |
509 | 0 | { |
510 | 0 | mpWindowImpl->maControlForeground = COL_TRANSPARENT; |
511 | 0 | mpWindowImpl->mbControlForeground = false; |
512 | 0 | CompatStateChanged(StateChangedType::ControlForeground); |
513 | 0 | } |
514 | 0 | } |
515 | 0 | else |
516 | 0 | { |
517 | 0 | if (mpWindowImpl->maControlForeground != rColor) |
518 | 0 | { |
519 | 0 | mpWindowImpl->maControlForeground = rColor; |
520 | 0 | mpWindowImpl->mbControlForeground = true; |
521 | 0 | CompatStateChanged(StateChangedType::ControlForeground); |
522 | 0 | } |
523 | 0 | } |
524 | 0 | } |
525 | | |
526 | | void Window::ApplyControlForeground(vcl::RenderContext& rRenderContext, const Color& rDefaultColor) |
527 | 8.28k | { |
528 | 8.28k | Color aTextColor(rDefaultColor); |
529 | 8.28k | if (IsControlForeground()) |
530 | 0 | aTextColor = GetControlForeground(); |
531 | 8.28k | rRenderContext.SetTextColor(aTextColor); |
532 | 8.28k | } |
533 | | |
534 | | void Window::SetControlBackground() |
535 | 0 | { |
536 | 0 | if (mpWindowImpl->mbControlBackground) |
537 | 0 | { |
538 | 0 | mpWindowImpl->maControlBackground = COL_TRANSPARENT; |
539 | 0 | mpWindowImpl->mbControlBackground = false; |
540 | 0 | CompatStateChanged(StateChangedType::ControlBackground); |
541 | 0 | } |
542 | 0 | } |
543 | | |
544 | | void Window::SetControlBackground(const Color& rColor) |
545 | 8.48k | { |
546 | 8.48k | if (rColor.IsTransparent()) |
547 | 0 | { |
548 | 0 | if (mpWindowImpl->mbControlBackground) |
549 | 0 | { |
550 | 0 | mpWindowImpl->maControlBackground = COL_TRANSPARENT; |
551 | 0 | mpWindowImpl->mbControlBackground = false; |
552 | 0 | CompatStateChanged(StateChangedType::ControlBackground); |
553 | 0 | } |
554 | 0 | } |
555 | 8.48k | else |
556 | 8.48k | { |
557 | 8.48k | if (mpWindowImpl->maControlBackground != rColor) |
558 | 8.48k | { |
559 | 8.48k | mpWindowImpl->maControlBackground = rColor; |
560 | 8.48k | mpWindowImpl->mbControlBackground = true; |
561 | 8.48k | CompatStateChanged(StateChangedType::ControlBackground); |
562 | 8.48k | } |
563 | 8.48k | } |
564 | 8.48k | } |
565 | | |
566 | | void Window::ApplyControlBackground(vcl::RenderContext& rRenderContext, const Color& rDefaultColor) |
567 | 8.28k | { |
568 | 8.28k | Color aColor(rDefaultColor); |
569 | 8.28k | if (IsControlBackground()) |
570 | 0 | aColor = GetControlBackground(); |
571 | 8.28k | rRenderContext.SetBackground(aColor); |
572 | 8.28k | } |
573 | | |
574 | | Size Window::CalcWindowSize( const Size& rOutSz ) const |
575 | 0 | { |
576 | 0 | Size aSz = rOutSz; |
577 | 0 | aSz.AdjustWidth(mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder ); |
578 | 0 | aSz.AdjustHeight(mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder ); |
579 | 0 | return aSz; |
580 | 0 | } |
581 | | |
582 | | Size Window::CalcOutputSize( const Size& rWinSz ) const |
583 | 0 | { |
584 | 0 | Size aSz = rWinSz; |
585 | 0 | aSz.AdjustWidth( -(mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder) ); |
586 | 0 | aSz.AdjustHeight( -(mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder) ); |
587 | 0 | return aSz; |
588 | 0 | } |
589 | | |
590 | | vcl::Font Window::GetDrawPixelFont(OutputDevice const * pDev) const |
591 | 0 | { |
592 | 0 | vcl::Font aFont = GetPointFont(*GetOutDev()); |
593 | 0 | Size aFontSize = aFont.GetFontSize(); |
594 | 0 | MapMode aPtMapMode(MapUnit::MapPoint); |
595 | 0 | aFontSize = pDev->LogicToPixel( aFontSize, aPtMapMode ); |
596 | 0 | aFont.SetFontSize( aFontSize ); |
597 | 0 | return aFont; |
598 | 0 | } |
599 | | |
600 | | tools::Long Window::GetDrawPixel( OutputDevice const * pDev, tools::Long nPixels ) const |
601 | 0 | { |
602 | 0 | tools::Long nP = nPixels; |
603 | 0 | if ( pDev->GetOutDevType() != OUTDEV_WINDOW ) |
604 | 0 | { |
605 | 0 | MapMode aMap( MapUnit::Map100thMM ); |
606 | 0 | Size aSz( nP, 0 ); |
607 | 0 | aSz = PixelToLogic( aSz, aMap ); |
608 | 0 | aSz = pDev->LogicToPixel( aSz, aMap ); |
609 | 0 | nP = aSz.Width(); |
610 | 0 | } |
611 | 0 | return nP; |
612 | 0 | } |
613 | | |
614 | | // returns how much was actually scrolled (so that abs(retval) <= abs(nN)) |
615 | | static double lcl_HandleScrollHelper( Scrollable* pScrl, double nN, bool isMultiplyByLineSize ) |
616 | 0 | { |
617 | 0 | if (!pScrl || !nN || pScrl->Inactive()) |
618 | 0 | return 0.0; |
619 | | |
620 | 0 | tools::Long nNewPos = pScrl->GetThumbPos(); |
621 | 0 | double scrolled = nN; |
622 | |
|
623 | 0 | if ( nN == double(-LONG_MAX) ) |
624 | 0 | nNewPos += pScrl->GetPageSize(); |
625 | 0 | else if ( nN == double(LONG_MAX) ) |
626 | 0 | nNewPos -= pScrl->GetPageSize(); |
627 | 0 | else |
628 | 0 | { |
629 | | // allowing both chunked and continuous scrolling |
630 | 0 | if(isMultiplyByLineSize){ |
631 | 0 | nN*=pScrl->GetLineSize(); |
632 | 0 | } |
633 | | |
634 | | // compute how many quantized units to scroll |
635 | 0 | tools::Long magnitude = o3tl::saturating_cast<tools::Long>(fabs(nN)); |
636 | 0 | tools::Long change = copysign(magnitude, nN); |
637 | |
|
638 | 0 | nNewPos = nNewPos - change; |
639 | |
|
640 | 0 | scrolled = double(change); |
641 | | // convert back to chunked/continuous |
642 | 0 | if(isMultiplyByLineSize){ |
643 | 0 | scrolled /= pScrl->GetLineSize(); |
644 | 0 | } |
645 | 0 | } |
646 | |
|
647 | 0 | pScrl->DoScroll( nNewPos ); |
648 | |
|
649 | 0 | return scrolled; |
650 | 0 | } |
651 | | |
652 | | bool Window::HandleScrollCommand( const CommandEvent& rCmd, |
653 | | Scrollable* pHScrl, Scrollable* pVScrl ) |
654 | 0 | { |
655 | 0 | bool bRet = false; |
656 | |
|
657 | 0 | if ( pHScrl || pVScrl ) |
658 | 0 | { |
659 | 0 | switch( rCmd.GetCommand() ) |
660 | 0 | { |
661 | 0 | case CommandEventId::StartAutoScroll: |
662 | 0 | { |
663 | 0 | StartAutoScrollFlags nFlags = StartAutoScrollFlags::NONE; |
664 | 0 | if ( pHScrl ) |
665 | 0 | { |
666 | 0 | if ( (pHScrl->GetVisibleSize() < pHScrl->GetRangeMax()) && |
667 | 0 | !pHScrl->Inactive() ) |
668 | 0 | nFlags |= StartAutoScrollFlags::Horz; |
669 | 0 | } |
670 | 0 | if ( pVScrl ) |
671 | 0 | { |
672 | 0 | if ( (pVScrl->GetVisibleSize() < pVScrl->GetRangeMax()) && |
673 | 0 | !pVScrl->Inactive() ) |
674 | 0 | nFlags |= StartAutoScrollFlags::Vert; |
675 | 0 | } |
676 | |
|
677 | 0 | if ( nFlags != StartAutoScrollFlags::NONE ) |
678 | 0 | { |
679 | 0 | StartAutoScroll( nFlags ); |
680 | 0 | bRet = true; |
681 | 0 | } |
682 | 0 | } |
683 | 0 | break; |
684 | | |
685 | 0 | case CommandEventId::Wheel: |
686 | 0 | { |
687 | 0 | const CommandWheelData* pData = rCmd.GetWheelData(); |
688 | |
|
689 | 0 | if ( pData && (CommandWheelMode::SCROLL == pData->GetMode()) ) |
690 | 0 | { |
691 | 0 | if (!pData->IsDeltaPixel()) |
692 | 0 | { |
693 | 0 | double nScrollLines = pData->GetScrollLines(); |
694 | 0 | double nLines; |
695 | 0 | double* partialScroll = pData->IsHorz() |
696 | 0 | ? &mpWindowImpl->mfPartialScrollX |
697 | 0 | : &mpWindowImpl->mfPartialScrollY; |
698 | 0 | if ( nScrollLines == COMMAND_WHEEL_PAGESCROLL ) |
699 | 0 | { |
700 | 0 | if ( pData->GetDelta() < 0 ) |
701 | 0 | nLines = double(-LONG_MAX); |
702 | 0 | else |
703 | 0 | nLines = double(LONG_MAX); |
704 | 0 | } |
705 | 0 | else |
706 | 0 | nLines = *partialScroll + pData->GetNotchDelta() * nScrollLines; |
707 | 0 | if ( nLines ) |
708 | 0 | { |
709 | 0 | Scrollable* pScrl = pData->IsHorz() ? pHScrl : pVScrl; |
710 | 0 | double scrolled = lcl_HandleScrollHelper( pScrl, nLines, true ); |
711 | 0 | *partialScroll = nLines - scrolled; |
712 | 0 | bRet = true; |
713 | 0 | } |
714 | 0 | } |
715 | 0 | else |
716 | 0 | { |
717 | | // Mobile / touch scrolling section |
718 | 0 | const Point & deltaPoint = rCmd.GetMousePosPixel(); |
719 | |
|
720 | 0 | double deltaXInPixels = double(deltaPoint.X()); |
721 | 0 | double deltaYInPixels = double(deltaPoint.Y()); |
722 | 0 | Size winSize = GetOutputSizePixel(); |
723 | |
|
724 | 0 | if(pHScrl) |
725 | 0 | { |
726 | 0 | double visSizeX = double(pHScrl->GetVisibleSize()); |
727 | 0 | double ratioX = deltaXInPixels / double(winSize.getWidth()); |
728 | 0 | tools::Long deltaXInLogic = tools::Long(visSizeX * ratioX); |
729 | | // Touch need to work by pixels. Did not apply this to |
730 | | // Android, as android code may require adaptations |
731 | | // to work with this scrolling code |
732 | 0 | #ifndef IOS |
733 | 0 | tools::Long lineSizeX = pHScrl->GetLineSize(); |
734 | |
|
735 | 0 | if(lineSizeX) |
736 | 0 | { |
737 | 0 | deltaXInLogic /= lineSizeX; |
738 | 0 | } |
739 | 0 | else |
740 | 0 | { |
741 | 0 | deltaXInLogic = 0; |
742 | 0 | } |
743 | 0 | #endif |
744 | 0 | if ( deltaXInLogic) |
745 | 0 | { |
746 | 0 | #ifndef IOS |
747 | 0 | bool const isMultiplyByLineSize = true; |
748 | | #else |
749 | | bool const isMultiplyByLineSize = false; |
750 | | #endif |
751 | 0 | lcl_HandleScrollHelper( pHScrl, deltaXInLogic, isMultiplyByLineSize ); |
752 | 0 | bRet = true; |
753 | 0 | } |
754 | 0 | } |
755 | 0 | if(pVScrl) |
756 | 0 | { |
757 | 0 | double visSizeY = double(pVScrl->GetVisibleSize()); |
758 | 0 | double ratioY = deltaYInPixels / double(winSize.getHeight()); |
759 | 0 | tools::Long deltaYInLogic = tools::Long(visSizeY * ratioY); |
760 | | |
761 | | // Touch need to work by pixels. Did not apply this to |
762 | | // Android, as android code may require adaptations |
763 | | // to work with this scrolling code |
764 | 0 | #ifndef IOS |
765 | 0 | tools::Long lineSizeY = pVScrl->GetLineSize(); |
766 | 0 | if(lineSizeY) |
767 | 0 | { |
768 | 0 | deltaYInLogic /= lineSizeY; |
769 | 0 | } |
770 | 0 | else |
771 | 0 | { |
772 | 0 | deltaYInLogic = 0; |
773 | 0 | } |
774 | 0 | #endif |
775 | 0 | if ( deltaYInLogic ) |
776 | 0 | { |
777 | 0 | #ifndef IOS |
778 | 0 | bool const isMultiplyByLineSize = true; |
779 | | #else |
780 | | bool const isMultiplyByLineSize = false; |
781 | | #endif |
782 | 0 | lcl_HandleScrollHelper( pVScrl, deltaYInLogic, isMultiplyByLineSize ); |
783 | |
|
784 | 0 | bRet = true; |
785 | 0 | } |
786 | 0 | } |
787 | 0 | } |
788 | 0 | } |
789 | 0 | } |
790 | 0 | break; |
791 | | |
792 | 0 | case CommandEventId::GesturePan: |
793 | 0 | { |
794 | 0 | const CommandGesturePanData* pData = rCmd.GetGesturePanData(); |
795 | 0 | if (pData) |
796 | 0 | { |
797 | 0 | if (pData->meEventType == GestureEventPanType::Begin) |
798 | 0 | { |
799 | 0 | if (pHScrl) |
800 | 0 | mpWindowImpl->mpFrameData->mnTouchPanPositionX = pHScrl->GetThumbPos(); |
801 | 0 | if (pVScrl) |
802 | 0 | mpWindowImpl->mpFrameData->mnTouchPanPositionY = pVScrl->GetThumbPos(); |
803 | 0 | } |
804 | 0 | else if (pData->meEventType == GestureEventPanType::Update) |
805 | 0 | { |
806 | 0 | bool bHorz = pData->meOrientation == PanningOrientation::Horizontal; |
807 | 0 | Scrollable* pScrl = bHorz ? pHScrl : pVScrl; |
808 | 0 | if (pScrl) |
809 | 0 | { |
810 | 0 | Point aGesturePt(pData->mfX, pData->mfY); |
811 | 0 | tools::Rectangle aWinRect(this->GetOutputRectPixel()); |
812 | 0 | bool bContains = aWinRect.Contains(aGesturePt); |
813 | 0 | if (bContains) |
814 | 0 | { |
815 | 0 | double nWinSize; |
816 | 0 | tools::Long nOriginalPos; |
817 | 0 | if (bHorz) |
818 | 0 | { |
819 | 0 | nWinSize = GetOutputSizePixel().getWidth(); |
820 | 0 | nOriginalPos = mpWindowImpl->mpFrameData->mnTouchPanPositionX; |
821 | 0 | } |
822 | 0 | else |
823 | 0 | { |
824 | 0 | nWinSize = GetOutputSizePixel().getHeight(); |
825 | 0 | nOriginalPos = mpWindowImpl->mpFrameData->mnTouchPanPositionY; |
826 | 0 | } |
827 | 0 | double nOffset = pData->mfOffset; |
828 | 0 | double nRatio = nOffset / nWinSize; |
829 | 0 | tools::Long nVisibleSize = pScrl->GetVisibleSize(); |
830 | 0 | tools::Long nDeltaInLogic = tools::Long(nVisibleSize * nRatio); |
831 | 0 | tools::Long nNewPos = nOriginalPos - nDeltaInLogic; |
832 | |
|
833 | 0 | pScrl->DoScroll(nNewPos); |
834 | 0 | } |
835 | 0 | } |
836 | 0 | } |
837 | 0 | else if (pData->meEventType == GestureEventPanType::End) |
838 | 0 | { |
839 | 0 | mpWindowImpl->mpFrameData->mnTouchPanPositionX = -1; |
840 | 0 | mpWindowImpl->mpFrameData->mnTouchPanPositionY = -1; |
841 | 0 | } |
842 | 0 | bRet = true; |
843 | 0 | } |
844 | 0 | break; |
845 | 0 | } |
846 | | |
847 | 0 | case CommandEventId::AutoScroll: |
848 | 0 | { |
849 | 0 | const CommandScrollData* pData = rCmd.GetAutoScrollData(); |
850 | 0 | if ( pData && (pData->GetDeltaX() || pData->GetDeltaY()) ) |
851 | 0 | { |
852 | 0 | ImplHandleScroll( pHScrl, pData->GetDeltaX(), |
853 | 0 | pVScrl, pData->GetDeltaY() ); |
854 | 0 | bRet = true; |
855 | 0 | } |
856 | 0 | } |
857 | 0 | break; |
858 | | |
859 | 0 | default: |
860 | 0 | break; |
861 | 0 | } |
862 | 0 | } |
863 | | |
864 | 0 | return bRet; |
865 | 0 | } |
866 | | |
867 | | void Window::ImplHandleScroll( Scrollable* pHScrl, double nX, |
868 | | Scrollable* pVScrl, double nY ) |
869 | 0 | { |
870 | 0 | lcl_HandleScrollHelper( pHScrl, nX, true ); |
871 | 0 | lcl_HandleScrollHelper( pVScrl, nY, true ); |
872 | 0 | } |
873 | | |
874 | | DockingManager* Window::GetDockingManager() |
875 | 33.1k | { |
876 | 33.1k | return ImplGetDockingManager(); |
877 | 33.1k | } |
878 | | |
879 | | void Window::EnableDocking( bool bEnable ) |
880 | 0 | { |
881 | | // update list of dockable windows |
882 | 0 | if( bEnable ) |
883 | 0 | ImplGetDockingManager()->AddWindow( this ); |
884 | 0 | else |
885 | 0 | ImplGetDockingManager()->RemoveWindow( this ); |
886 | 0 | } |
887 | | |
888 | | // retrieves the list of owner draw decorated windows for this window hierarchy |
889 | | ::std::vector<VclPtr<vcl::Window> >& Window::ImplGetOwnerDrawList() |
890 | 0 | { |
891 | 0 | return ImplGetTopmostFrameWindow()->mpWindowImpl->mpFrameData->maOwnerDrawList; |
892 | 0 | } |
893 | | |
894 | | void Window::SetHelpId( const OUString& rHelpId ) |
895 | 4.14k | { |
896 | 4.14k | mpWindowImpl->maHelpId = rHelpId; |
897 | 4.14k | } |
898 | | |
899 | | const OUString& Window::GetHelpId() const |
900 | 0 | { |
901 | 0 | return mpWindowImpl->maHelpId; |
902 | 0 | } |
903 | | |
904 | | // --------- old inline methods --------------- |
905 | | |
906 | | vcl::Window* Window::ImplGetWindow() const |
907 | 57.1k | { |
908 | 57.1k | if ( mpWindowImpl->mpClientWindow ) |
909 | 19.8k | return mpWindowImpl->mpClientWindow; |
910 | 37.2k | else |
911 | 37.2k | return const_cast<vcl::Window*>(this); |
912 | 57.1k | } |
913 | | |
914 | | ImplFrameData* Window::ImplGetFrameData() |
915 | 0 | { |
916 | 0 | return mpWindowImpl ? mpWindowImpl->mpFrameData : nullptr; |
917 | 0 | } |
918 | | |
919 | | SalFrame* Window::ImplGetFrame() const |
920 | 136k | { |
921 | 136k | return mpWindowImpl ? mpWindowImpl->mpFrame : nullptr; |
922 | 136k | } |
923 | | |
924 | | weld::Window* Window::GetFrameWeld() const |
925 | 139 | { |
926 | 139 | SalFrame* pFrame = ImplGetFrame(); |
927 | 139 | return pFrame ? pFrame->GetFrameWeld() : nullptr; |
928 | 139 | } |
929 | | |
930 | | vcl::Window* Window::GetFrameWindow() const |
931 | 8.28k | { |
932 | 8.28k | SalFrame* pFrame = ImplGetFrame(); |
933 | 8.28k | return pFrame ? pFrame->GetWindow() : nullptr; |
934 | 8.28k | } |
935 | | |
936 | | vcl::Window* Window::ImplGetParent() const |
937 | 287k | { |
938 | 287k | return mpWindowImpl ? mpWindowImpl->mpParent.get() : nullptr; |
939 | 287k | } |
940 | | |
941 | | vcl::Window* Window::ImplGetClientWindow() const |
942 | 8.28k | { |
943 | 8.28k | return mpWindowImpl ? mpWindowImpl->mpClientWindow.get() : nullptr; |
944 | 8.28k | } |
945 | | |
946 | | vcl::Window* Window::ImplGetBorderWindow() const |
947 | 9.49k | { |
948 | 9.49k | return mpWindowImpl ? mpWindowImpl->mpBorderWindow.get() : nullptr; |
949 | 9.49k | } |
950 | | |
951 | | vcl::Window* Window::ImplGetFirstOverlapWindow() |
952 | 103k | { |
953 | 103k | if (!mpWindowImpl) |
954 | 0 | { |
955 | 0 | return nullptr; |
956 | 0 | } |
957 | | |
958 | 103k | if ( mpWindowImpl->mbOverlapWin ) |
959 | 4.14k | return this; |
960 | 99.4k | else |
961 | 99.4k | return mpWindowImpl->mpOverlapWindow; |
962 | 103k | } |
963 | | |
964 | | const vcl::Window* Window::ImplGetFirstOverlapWindow() const |
965 | 0 | { |
966 | 0 | if (!mpWindowImpl) |
967 | 0 | { |
968 | 0 | return nullptr; |
969 | 0 | } |
970 | | |
971 | 0 | if ( mpWindowImpl->mbOverlapWin ) |
972 | 0 | return this; |
973 | 0 | else |
974 | 0 | return mpWindowImpl->mpOverlapWindow; |
975 | 0 | } |
976 | | |
977 | | vcl::Window* Window::ImplGetFrameWindow() const |
978 | 0 | { |
979 | 0 | return mpWindowImpl ? mpWindowImpl->mpFrameWindow.get() : nullptr; |
980 | 0 | } |
981 | | |
982 | | bool Window::IsDockingWindow() const |
983 | 0 | { |
984 | 0 | return mpWindowImpl && mpWindowImpl->mbDockWin; |
985 | 0 | } |
986 | | |
987 | | bool Window::ImplIsFloatingWindow() const |
988 | 0 | { |
989 | 0 | return mpWindowImpl && mpWindowImpl->mbFloatWin; |
990 | 0 | } |
991 | | |
992 | | bool Window::ImplIsSplitter() const |
993 | 0 | { |
994 | 0 | return mpWindowImpl && mpWindowImpl->mbSplitter; |
995 | 0 | } |
996 | | |
997 | | bool Window::ImplIsPushButton() const |
998 | 0 | { |
999 | 0 | return mpWindowImpl && mpWindowImpl->mbPushButton; |
1000 | 0 | } |
1001 | | |
1002 | | bool Window::ImplIsOverlapWindow() const |
1003 | 767k | { |
1004 | 767k | return mpWindowImpl && mpWindowImpl->mbOverlapWin; |
1005 | 767k | } |
1006 | | |
1007 | | void Window::ImplSetMouseTransparent( bool bTransparent ) |
1008 | 0 | { |
1009 | 0 | if (mpWindowImpl) |
1010 | 0 | mpWindowImpl->mbMouseTransparent = bTransparent; |
1011 | 0 | } |
1012 | | |
1013 | | void Window::SetCompoundControl( bool bCompound ) |
1014 | 0 | { |
1015 | 0 | if (mpWindowImpl) |
1016 | 0 | mpWindowImpl->mbCompoundControl = bCompound; |
1017 | 0 | } |
1018 | | |
1019 | | WinBits Window::GetStyle() const |
1020 | 279k | { |
1021 | 279k | return mpWindowImpl ? mpWindowImpl->mnStyle : 0; |
1022 | 279k | } |
1023 | | |
1024 | | WinBits Window::GetPrevStyle() const |
1025 | 0 | { |
1026 | 0 | return mpWindowImpl ? mpWindowImpl->mnPrevStyle : 0; |
1027 | 0 | } |
1028 | | |
1029 | | WindowExtendedStyle Window::GetExtendedStyle() const |
1030 | 8.48k | { |
1031 | 8.48k | return mpWindowImpl ? mpWindowImpl->mnExtendedStyle : WindowExtendedStyle::NONE; |
1032 | 8.48k | } |
1033 | | |
1034 | | void Window::SetType( WindowType eType ) |
1035 | 8.28k | { |
1036 | 8.28k | if (mpWindowImpl) |
1037 | 8.28k | mpWindowImpl->meType = eType; |
1038 | 8.28k | } |
1039 | | |
1040 | | WindowType Window::GetType() const |
1041 | 468k | { |
1042 | 468k | if (mpWindowImpl) |
1043 | 468k | return mpWindowImpl->meType; |
1044 | 0 | else |
1045 | 0 | return WindowType::NONE; |
1046 | 468k | } |
1047 | | |
1048 | | bool Window::IsFormControl() const |
1049 | 0 | { |
1050 | 0 | return mpWindowImpl ? mpWindowImpl->mbIsFormControl : false; |
1051 | 0 | } |
1052 | | |
1053 | | void Window::SetFormControl(bool bFormControl) |
1054 | 0 | { |
1055 | 0 | if (mpWindowImpl) |
1056 | 0 | mpWindowImpl->mbIsFormControl = bFormControl; |
1057 | 0 | } |
1058 | | |
1059 | | Dialog* Window::GetParentDialog() const |
1060 | 0 | { |
1061 | 0 | const vcl::Window *pWindow = this; |
1062 | |
|
1063 | 0 | while( pWindow ) |
1064 | 0 | { |
1065 | 0 | if( pWindow->IsDialog() ) |
1066 | 0 | break; |
1067 | | |
1068 | 0 | pWindow = pWindow->GetParent(); |
1069 | 0 | } |
1070 | |
|
1071 | 0 | return const_cast<Dialog *>(dynamic_cast<const Dialog*>(pWindow)); |
1072 | 0 | } |
1073 | | |
1074 | | bool Window::IsSystemWindow() const |
1075 | 44.2k | { |
1076 | 44.2k | return mpWindowImpl && mpWindowImpl->mbSysWin; |
1077 | 44.2k | } |
1078 | | |
1079 | | bool Window::IsDialog() const |
1080 | 0 | { |
1081 | 0 | return mpWindowImpl && mpWindowImpl->mbDialog; |
1082 | 0 | } |
1083 | | |
1084 | | bool Window::IsMenuFloatingWindow() const |
1085 | 0 | { |
1086 | 0 | return mpWindowImpl && mpWindowImpl->mbMenuFloatingWindow; |
1087 | 0 | } |
1088 | | |
1089 | | bool Window::IsNativeFrame() const |
1090 | 107k | { |
1091 | 107k | if( mpWindowImpl->mbFrame ) |
1092 | | // #101741 do not check for WB_CLOSEABLE because undecorated floaters (like menus!) are closeable |
1093 | 8.31k | if( mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE) ) |
1094 | 8.28k | return true; |
1095 | 30 | else |
1096 | 30 | return false; |
1097 | 99.4k | else |
1098 | 99.4k | return false; |
1099 | 107k | } |
1100 | | |
1101 | | void Window::EnableAllResize() |
1102 | 25.2k | { |
1103 | 25.2k | mpWindowImpl->mbAllResize = true; |
1104 | 25.2k | } |
1105 | | |
1106 | | void Window::EnableChildTransparentMode( bool bEnable ) |
1107 | 4.14k | { |
1108 | 4.14k | mpWindowImpl->mbChildTransparent = bEnable; |
1109 | 4.14k | } |
1110 | | |
1111 | | bool Window::IsChildTransparentModeEnabled() const |
1112 | 3 | { |
1113 | 3 | return mpWindowImpl && mpWindowImpl->mbChildTransparent; |
1114 | 3 | } |
1115 | | |
1116 | | bool Window::IsMouseTransparent() const |
1117 | 0 | { |
1118 | 0 | return mpWindowImpl && mpWindowImpl->mbMouseTransparent; |
1119 | 0 | } |
1120 | | |
1121 | | bool Window::IsPaintTransparent() const |
1122 | 0 | { |
1123 | 0 | return mpWindowImpl && mpWindowImpl->mbPaintTransparent; |
1124 | 0 | } |
1125 | | |
1126 | | void Window::SetDialogControlStart( bool bStart ) |
1127 | 0 | { |
1128 | 0 | mpWindowImpl->mbDlgCtrlStart = bStart; |
1129 | 0 | } |
1130 | | |
1131 | | bool Window::IsDialogControlStart() const |
1132 | 0 | { |
1133 | 0 | return mpWindowImpl && mpWindowImpl->mbDlgCtrlStart; |
1134 | 0 | } |
1135 | | |
1136 | | void Window::SetDialogControlFlags( DialogControlFlags nFlags ) |
1137 | 4.14k | { |
1138 | 4.14k | mpWindowImpl->mnDlgCtrlFlags = nFlags; |
1139 | 4.14k | } |
1140 | | |
1141 | | DialogControlFlags Window::GetDialogControlFlags() const |
1142 | 0 | { |
1143 | 0 | return mpWindowImpl->mnDlgCtrlFlags; |
1144 | 0 | } |
1145 | | |
1146 | | const InputContext& Window::GetInputContext() const |
1147 | 4.14k | { |
1148 | 4.14k | return mpWindowImpl->maInputContext; |
1149 | 4.14k | } |
1150 | | |
1151 | | bool Window::IsControlFont() const |
1152 | 16.7k | { |
1153 | 16.7k | return bool(mpWindowImpl->mpControlFont); |
1154 | 16.7k | } |
1155 | | |
1156 | | const Color& Window::GetControlForeground() const |
1157 | 0 | { |
1158 | 0 | return mpWindowImpl->maControlForeground; |
1159 | 0 | } |
1160 | | |
1161 | | bool Window::IsControlForeground() const |
1162 | 16.7k | { |
1163 | 16.7k | return mpWindowImpl->mbControlForeground; |
1164 | 16.7k | } |
1165 | | |
1166 | | const Color& Window::GetControlBackground() const |
1167 | 0 | { |
1168 | 0 | return mpWindowImpl->maControlBackground; |
1169 | 0 | } |
1170 | | |
1171 | | bool Window::IsControlBackground() const |
1172 | 58.3k | { |
1173 | 58.3k | return mpWindowImpl->mbControlBackground; |
1174 | 58.3k | } |
1175 | | |
1176 | | bool Window::IsInPaint() const |
1177 | 9 | { |
1178 | 9 | return mpWindowImpl && mpWindowImpl->mbInPaint; |
1179 | 9 | } |
1180 | | |
1181 | | vcl::Window* Window::GetParent() const |
1182 | 1.13M | { |
1183 | 1.13M | return mpWindowImpl ? mpWindowImpl->mpRealParent.get() : nullptr; |
1184 | 1.13M | } |
1185 | | |
1186 | | bool Window::IsVisible() const |
1187 | 148k | { |
1188 | 148k | return mpWindowImpl && mpWindowImpl->mbVisible; |
1189 | 148k | } |
1190 | | |
1191 | | bool Window::IsReallyVisible() const |
1192 | 311k | { |
1193 | 311k | return mpWindowImpl && mpWindowImpl->mbReallyVisible; |
1194 | 311k | } |
1195 | | |
1196 | | bool Window::IsReallyShown() const |
1197 | 82.8k | { |
1198 | 82.8k | return mpWindowImpl && mpWindowImpl->mbReallyShown; |
1199 | 82.8k | } |
1200 | | |
1201 | | bool Window::IsInInitShow() const |
1202 | 0 | { |
1203 | 0 | return mpWindowImpl->mbInInitShow; |
1204 | 0 | } |
1205 | | |
1206 | | bool Window::IsEnabled() const |
1207 | 0 | { |
1208 | 0 | return mpWindowImpl && !mpWindowImpl->mbDisabled; |
1209 | 0 | } |
1210 | | |
1211 | | bool Window::IsInputEnabled() const |
1212 | 0 | { |
1213 | 0 | return mpWindowImpl && !mpWindowImpl->mbInputDisabled; |
1214 | 0 | } |
1215 | | |
1216 | | bool Window::IsAlwaysEnableInput() const |
1217 | 0 | { |
1218 | 0 | return mpWindowImpl->meAlwaysInputMode == AlwaysInputEnabled; |
1219 | 0 | } |
1220 | | |
1221 | | ActivateModeFlags Window::GetActivateMode() const |
1222 | 8.51k | { |
1223 | 8.51k | return mpWindowImpl->mnActivateMode; |
1224 | | |
1225 | 8.51k | } |
1226 | | |
1227 | | bool Window::IsAlwaysOnTopEnabled() const |
1228 | 0 | { |
1229 | 0 | return mpWindowImpl->mbAlwaysOnTop; |
1230 | 0 | } |
1231 | | |
1232 | | bool Window::IsDefaultPos() const |
1233 | 0 | { |
1234 | 0 | return mpWindowImpl->mbDefPos; |
1235 | 0 | } |
1236 | | |
1237 | | bool Window::IsDefaultSize() const |
1238 | 0 | { |
1239 | 0 | return mpWindowImpl->mbDefSize; |
1240 | 0 | } |
1241 | | |
1242 | | Point Window::GetOffsetPixelFrom(const vcl::Window& rWindow) const |
1243 | 0 | { |
1244 | 0 | return Point(GetDeviceOriginX() - rWindow.GetDeviceOriginX(), GetDeviceOriginY() - rWindow.GetDeviceOriginY()); |
1245 | 0 | } |
1246 | | |
1247 | | void Window::EnablePaint( bool bEnable ) |
1248 | 962 | { |
1249 | 962 | mpWindowImpl->mbPaintDisabled = !bEnable; |
1250 | 962 | } |
1251 | | |
1252 | | bool Window::IsPaintEnabled() const |
1253 | 0 | { |
1254 | 0 | return !mpWindowImpl->mbPaintDisabled; |
1255 | 0 | } |
1256 | | |
1257 | | bool Window::IsUpdateMode() const |
1258 | 0 | { |
1259 | 0 | return !mpWindowImpl->mbNoUpdate; |
1260 | 0 | } |
1261 | | |
1262 | | void Window::SetParentUpdateMode( bool bUpdate ) |
1263 | 0 | { |
1264 | 0 | mpWindowImpl->mbNoParentUpdate = !bUpdate; |
1265 | 0 | } |
1266 | | |
1267 | | bool Window::IsActive() const |
1268 | 12.6k | { |
1269 | 12.6k | return mpWindowImpl->mbActive; |
1270 | 12.6k | } |
1271 | | |
1272 | | GetFocusFlags Window::GetGetFocusFlags() const |
1273 | 0 | { |
1274 | 0 | return mpWindowImpl->mnGetFocusFlags; |
1275 | 0 | } |
1276 | | |
1277 | | bool Window::IsCompoundControl() const |
1278 | 0 | { |
1279 | 0 | return mpWindowImpl && mpWindowImpl->mbCompoundControl; |
1280 | 0 | } |
1281 | | |
1282 | | bool Window::IsWait() const |
1283 | 0 | { |
1284 | 0 | return (mpWindowImpl->mnWaitCount != 0); |
1285 | 0 | } |
1286 | | |
1287 | | vcl::Cursor* Window::GetCursor() const |
1288 | 4.14k | { |
1289 | 4.14k | if (!mpWindowImpl) |
1290 | 0 | return nullptr; |
1291 | 4.14k | return mpWindowImpl->mpCursor; |
1292 | 4.14k | } |
1293 | | |
1294 | | double Window::GetZoom() const |
1295 | 16.7k | { |
1296 | 16.7k | return mpWindowImpl->mfZoom; |
1297 | 16.7k | } |
1298 | | |
1299 | | bool Window::IsZoom() const |
1300 | 0 | { |
1301 | 0 | return mpWindowImpl->mfZoom != 1.0; |
1302 | 0 | } |
1303 | | |
1304 | | void Window::SetHelpText( const OUString& rHelpText ) |
1305 | 0 | { |
1306 | 0 | mpWindowImpl->maHelpText = rHelpText; |
1307 | 0 | mpWindowImpl->mbHelpTextDynamic = true; |
1308 | 0 | } |
1309 | | |
1310 | | void Window::SetQuickHelpText( const OUString& rHelpText ) |
1311 | 4.14k | { |
1312 | 4.14k | if (mpWindowImpl) |
1313 | 4.14k | mpWindowImpl->maQuickHelpText = rHelpText; |
1314 | 4.14k | } |
1315 | | |
1316 | | const OUString& Window::GetQuickHelpText() const |
1317 | 0 | { |
1318 | 0 | return mpWindowImpl->maQuickHelpText; |
1319 | 0 | } |
1320 | | |
1321 | | bool Window::IsCreatedWithToolkit() const |
1322 | 0 | { |
1323 | 0 | return mpWindowImpl->mbCreatedWithToolkit; |
1324 | 0 | } |
1325 | | |
1326 | | void Window::SetCreatedWithToolkit( bool b ) |
1327 | 59.0k | { |
1328 | 59.0k | mpWindowImpl->mbCreatedWithToolkit = b; |
1329 | 59.0k | } |
1330 | | |
1331 | | PointerStyle Window::GetPointer() const |
1332 | 0 | { |
1333 | 0 | return mpWindowImpl->maPointer; |
1334 | 0 | } |
1335 | | |
1336 | | VCLXWindow* Window::GetWindowPeer() const |
1337 | 365k | { |
1338 | 365k | return mpWindowImpl ? mpWindowImpl->mpVCLXWindow : nullptr; |
1339 | 365k | } |
1340 | | |
1341 | | void Window::SetPosPixel( const Point& rNewPos ) |
1342 | 0 | { |
1343 | 0 | setPosSizePixel( rNewPos.X(), rNewPos.Y(), 0, 0, PosSizeFlags::Pos ); |
1344 | 0 | } |
1345 | | |
1346 | | void Window::SetSizePixel( const Size& rNewSize ) |
1347 | 37.4k | { |
1348 | 37.4k | setPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(), |
1349 | 37.4k | PosSizeFlags::Size ); |
1350 | 37.4k | } |
1351 | | |
1352 | | void Window::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) |
1353 | 0 | { |
1354 | 0 | setPosSizePixel( rNewPos.X(), rNewPos.Y(), |
1355 | 0 | rNewSize.Width(), rNewSize.Height()); |
1356 | 0 | } |
1357 | | |
1358 | | void Window::SetOutputSizePixel( const Size& rNewSize ) |
1359 | 16.7k | { |
1360 | 16.7k | SetSizePixel( Size( rNewSize.Width()+mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder, |
1361 | 16.7k | rNewSize.Height()+mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder ) ); |
1362 | 16.7k | } |
1363 | | |
1364 | | //When a widget wants to renegotiate layout, get toplevel parent dialog and call |
1365 | | //resize on it. Mark all intermediate containers (or container-alike) widgets |
1366 | | //as dirty for the size remains unchanged, but layout changed circumstances |
1367 | | namespace |
1368 | | { |
1369 | | bool queue_ungrouped_resize(vcl::Window const *pOrigWindow) |
1370 | 62.1k | { |
1371 | 62.1k | bool bSomeoneCares = false; |
1372 | | |
1373 | 62.1k | vcl::Window *pWindow = pOrigWindow->GetParent(); |
1374 | 62.1k | if (pWindow) |
1375 | 57.9k | { |
1376 | 57.9k | if (isContainerWindow(*pWindow)) |
1377 | 0 | { |
1378 | 0 | bSomeoneCares = true; |
1379 | 0 | } |
1380 | 57.9k | else if (pWindow->GetType() == WindowType::TABCONTROL) |
1381 | 0 | { |
1382 | 0 | bSomeoneCares = true; |
1383 | 0 | } |
1384 | 57.9k | pWindow->queue_resize(); |
1385 | 57.9k | } |
1386 | | |
1387 | 62.1k | return bSomeoneCares; |
1388 | 62.1k | } |
1389 | | } |
1390 | | |
1391 | | void Window::InvalidateSizeCache() |
1392 | 33.1k | { |
1393 | 33.1k | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1394 | 33.1k | pWindowImpl->mnOptimalWidthCache = -1; |
1395 | 33.1k | pWindowImpl->mnOptimalHeightCache = -1; |
1396 | 33.1k | } |
1397 | | |
1398 | | static bool HasParentDockingWindow(const vcl::Window* pWindow) |
1399 | 0 | { |
1400 | 0 | while( pWindow ) |
1401 | 0 | { |
1402 | 0 | if( pWindow->IsDockingWindow() ) |
1403 | 0 | return true; |
1404 | | |
1405 | 0 | pWindow = pWindow->GetParent(); |
1406 | 0 | } |
1407 | | |
1408 | 0 | return false; |
1409 | 0 | } |
1410 | | |
1411 | | void Window::queue_resize(StateChangedType eReason) |
1412 | 74.4k | { |
1413 | 74.4k | if (isDisposed()) |
1414 | 12.3k | return; |
1415 | | |
1416 | 62.1k | bool bSomeoneCares = queue_ungrouped_resize(this); |
1417 | | |
1418 | 62.1k | if (eReason != StateChangedType::Visible) |
1419 | 33.1k | { |
1420 | 33.1k | InvalidateSizeCache(); |
1421 | 33.1k | } |
1422 | | |
1423 | 62.1k | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1424 | 62.1k | if (pWindowImpl->m_xSizeGroup && pWindowImpl->m_xSizeGroup->get_mode() != VclSizeGroupMode::NONE) |
1425 | 0 | { |
1426 | 0 | std::set<VclPtr<vcl::Window> > &rWindows = pWindowImpl->m_xSizeGroup->get_widgets(); |
1427 | 0 | for (VclPtr<vcl::Window> const & pOther : rWindows) |
1428 | 0 | { |
1429 | 0 | if (pOther == this) |
1430 | 0 | continue; |
1431 | 0 | queue_ungrouped_resize(pOther); |
1432 | 0 | } |
1433 | 0 | } |
1434 | | |
1435 | 62.1k | if (bSomeoneCares && !isDisposed()) |
1436 | 0 | { |
1437 | | //fdo#57090 force a resync of the borders of the borderwindow onto this |
1438 | | //window in case they have changed |
1439 | 0 | vcl::Window* pBorderWindow = ImplGetBorderWindow(); |
1440 | 0 | if (pBorderWindow) |
1441 | 0 | pBorderWindow->Resize(); |
1442 | 0 | } |
1443 | 62.1k | if (VclPtr<vcl::Window> pParent = GetParentWithLOKNotifier()) |
1444 | 0 | { |
1445 | 0 | Size aSize = GetSizePixel(); |
1446 | 0 | if (!aSize.IsEmpty() && !pParent->IsInInitShow() |
1447 | 0 | && (GetParentDialog() || HasParentDockingWindow(this))) |
1448 | 0 | LogicInvalidate(nullptr); |
1449 | 0 | } |
1450 | 62.1k | } |
1451 | | |
1452 | | namespace |
1453 | | { |
1454 | | VclAlign toAlign(std::u16string_view rValue) |
1455 | 0 | { |
1456 | 0 | VclAlign eRet = VclAlign::Fill; |
1457 | |
|
1458 | 0 | if (rValue == u"fill") |
1459 | 0 | eRet = VclAlign::Fill; |
1460 | 0 | else if (rValue == u"start") |
1461 | 0 | eRet = VclAlign::Start; |
1462 | 0 | else if (rValue == u"end") |
1463 | 0 | eRet = VclAlign::End; |
1464 | 0 | else if (rValue == u"center") |
1465 | 0 | eRet = VclAlign::Center; |
1466 | 0 | return eRet; |
1467 | 0 | } |
1468 | | } |
1469 | | |
1470 | | bool Window::set_font_attribute(const OUString &rKey, std::u16string_view rValue) |
1471 | 0 | { |
1472 | 0 | if (rKey == "weight") |
1473 | 0 | { |
1474 | 0 | vcl::Font aFont(GetControlFont()); |
1475 | 0 | if (rValue == u"thin") |
1476 | 0 | aFont.SetWeight(WEIGHT_THIN); |
1477 | 0 | else if (rValue == u"ultralight") |
1478 | 0 | aFont.SetWeight(WEIGHT_ULTRALIGHT); |
1479 | 0 | else if (rValue == u"light") |
1480 | 0 | aFont.SetWeight(WEIGHT_LIGHT); |
1481 | 0 | else if (rValue == u"book") |
1482 | 0 | aFont.SetWeight(WEIGHT_SEMILIGHT); |
1483 | 0 | else if (rValue == u"normal") |
1484 | 0 | aFont.SetWeight(WEIGHT_NORMAL); |
1485 | 0 | else if (rValue == u"medium") |
1486 | 0 | aFont.SetWeight(WEIGHT_MEDIUM); |
1487 | 0 | else if (rValue == u"semibold") |
1488 | 0 | aFont.SetWeight(WEIGHT_SEMIBOLD); |
1489 | 0 | else if (rValue == u"bold") |
1490 | 0 | aFont.SetWeight(WEIGHT_BOLD); |
1491 | 0 | else if (rValue == u"ultrabold") |
1492 | 0 | aFont.SetWeight(WEIGHT_ULTRABOLD); |
1493 | 0 | else |
1494 | 0 | aFont.SetWeight(WEIGHT_BLACK); |
1495 | 0 | SetControlFont(aFont); |
1496 | 0 | } |
1497 | 0 | else if (rKey == "style") |
1498 | 0 | { |
1499 | 0 | vcl::Font aFont(GetControlFont()); |
1500 | 0 | if (rValue == u"normal") |
1501 | 0 | aFont.SetItalic(ITALIC_NONE); |
1502 | 0 | else if (rValue == u"oblique") |
1503 | 0 | aFont.SetItalic(ITALIC_OBLIQUE); |
1504 | 0 | else if (rValue == u"italic") |
1505 | 0 | aFont.SetItalic(ITALIC_NORMAL); |
1506 | 0 | SetControlFont(aFont); |
1507 | 0 | } |
1508 | 0 | else if (rKey == "underline") |
1509 | 0 | { |
1510 | 0 | vcl::Font aFont(GetControlFont()); |
1511 | 0 | aFont.SetUnderline(toBool(rValue) ? LINESTYLE_SINGLE : LINESTYLE_NONE); |
1512 | 0 | SetControlFont(aFont); |
1513 | 0 | } |
1514 | 0 | else if (rKey == "scale") |
1515 | 0 | { |
1516 | | // if no control font was set yet, take the underlying font from the device |
1517 | 0 | vcl::Font aFont(IsControlFont() ? GetControlFont() : GetPointFont(*GetOutDev())); |
1518 | 0 | aFont.SetFontHeight(aFont.GetFontHeight() * o3tl::toDouble(rValue)); |
1519 | 0 | SetControlFont(aFont); |
1520 | 0 | } |
1521 | 0 | else if (rKey == "size") |
1522 | 0 | { |
1523 | 0 | vcl::Font aFont(GetControlFont()); |
1524 | 0 | sal_Int32 nHeight = o3tl::toInt32(rValue) / 1000; |
1525 | 0 | aFont.SetFontHeight(nHeight); |
1526 | 0 | SetControlFont(aFont); |
1527 | 0 | } |
1528 | 0 | else |
1529 | 0 | { |
1530 | 0 | SAL_INFO("vcl.layout", "unhandled font attribute: " << rKey); |
1531 | 0 | return false; |
1532 | 0 | } |
1533 | 0 | return true; |
1534 | 0 | } |
1535 | | |
1536 | | bool Window::set_property(const OUString &rKey, const OUString &rValue) |
1537 | 0 | { |
1538 | 0 | if ((rKey == "label") || (rKey == "title") || (rKey == "text") ) |
1539 | 0 | { |
1540 | 0 | SetText(BuilderUtils::convertMnemonicMarkup(rValue)); |
1541 | 0 | } |
1542 | 0 | else if (rKey == "visible") |
1543 | 0 | Show(toBool(rValue)); |
1544 | 0 | else if (rKey == "sensitive") |
1545 | 0 | Enable(toBool(rValue)); |
1546 | 0 | else if (rKey == "resizable") |
1547 | 0 | { |
1548 | 0 | WinBits nBits = GetStyle(); |
1549 | 0 | nBits &= ~WB_SIZEABLE; |
1550 | 0 | if (toBool(rValue)) |
1551 | 0 | nBits |= WB_SIZEABLE; |
1552 | 0 | SetStyle(nBits); |
1553 | 0 | } |
1554 | 0 | else if (rKey == "xalign") |
1555 | 0 | { |
1556 | 0 | WinBits nBits = GetStyle(); |
1557 | 0 | nBits &= ~(WB_LEFT | WB_CENTER | WB_RIGHT); |
1558 | |
|
1559 | 0 | float f = rValue.toFloat(); |
1560 | 0 | assert(f == 0.0 || f == 1.0 || f == 0.5); |
1561 | 0 | if (f == 0.0) |
1562 | 0 | nBits |= WB_LEFT; |
1563 | 0 | else if (f == 1.0) |
1564 | 0 | nBits |= WB_RIGHT; |
1565 | 0 | else if (f == 0.5) |
1566 | 0 | nBits |= WB_CENTER; |
1567 | |
|
1568 | 0 | SetStyle(nBits); |
1569 | 0 | } |
1570 | 0 | else if (rKey == "justification") |
1571 | 0 | { |
1572 | 0 | WinBits nBits = GetStyle(); |
1573 | 0 | nBits &= ~(WB_LEFT | WB_CENTER | WB_RIGHT); |
1574 | |
|
1575 | 0 | if (rValue == "left") |
1576 | 0 | nBits |= WB_LEFT; |
1577 | 0 | else if (rValue == "right") |
1578 | 0 | nBits |= WB_RIGHT; |
1579 | 0 | else if (rValue == "center") |
1580 | 0 | nBits |= WB_CENTER; |
1581 | |
|
1582 | 0 | SetStyle(nBits); |
1583 | 0 | } |
1584 | 0 | else if (rKey == "yalign") |
1585 | 0 | { |
1586 | 0 | WinBits nBits = GetStyle(); |
1587 | 0 | nBits &= ~(WB_TOP | WB_VCENTER | WB_BOTTOM); |
1588 | |
|
1589 | 0 | float f = rValue.toFloat(); |
1590 | 0 | assert(f == 0.0 || f == 1.0 || f == 0.5); |
1591 | 0 | if (f == 0.0) |
1592 | 0 | nBits |= WB_TOP; |
1593 | 0 | else if (f == 1.0) |
1594 | 0 | nBits |= WB_BOTTOM; |
1595 | 0 | else if (f == 0.5) |
1596 | 0 | nBits |= WB_VCENTER; |
1597 | |
|
1598 | 0 | SetStyle(nBits); |
1599 | 0 | } |
1600 | 0 | else if (rKey == "wrap") |
1601 | 0 | { |
1602 | 0 | WinBits nBits = GetStyle(); |
1603 | 0 | nBits &= ~WB_WORDBREAK; |
1604 | 0 | if (toBool(rValue)) |
1605 | 0 | nBits |= WB_WORDBREAK; |
1606 | 0 | SetStyle(nBits); |
1607 | 0 | } |
1608 | 0 | else if (rKey == "height-request") |
1609 | 0 | set_height_request(rValue.toInt32()); |
1610 | 0 | else if (rKey == "width-request") |
1611 | 0 | set_width_request(rValue.toInt32()); |
1612 | 0 | else if (rKey == "hexpand") |
1613 | 0 | set_hexpand(toBool(rValue)); |
1614 | 0 | else if (rKey == "vexpand") |
1615 | 0 | set_vexpand(toBool(rValue)); |
1616 | 0 | else if (rKey == "halign") |
1617 | 0 | set_halign(toAlign(rValue)); |
1618 | 0 | else if (rKey == "valign") |
1619 | 0 | set_valign(toAlign(rValue)); |
1620 | 0 | else if (rKey == "tooltip-markup") |
1621 | 0 | SetQuickHelpText(rValue); |
1622 | 0 | else if (rKey == "tooltip-text") |
1623 | 0 | SetQuickHelpText(rValue); |
1624 | 0 | else if (rKey == "border-width") |
1625 | 0 | set_border_width(rValue.toInt32()); |
1626 | 0 | else if (rKey == "margin-start" || rKey == "margin-left") |
1627 | 0 | { |
1628 | 0 | assert(rKey == "margin-start" && "margin-left deprecated in favor of margin-start"); |
1629 | 0 | set_margin_start(rValue.toInt32()); |
1630 | 0 | } |
1631 | 0 | else if (rKey == "margin-end" || rKey == "margin-right") |
1632 | 0 | { |
1633 | 0 | assert(rKey == "margin-end" && "margin-right deprecated in favor of margin-end"); |
1634 | 0 | set_margin_end(rValue.toInt32()); |
1635 | 0 | } |
1636 | 0 | else if (rKey == "margin-top") |
1637 | 0 | set_margin_top(rValue.toInt32()); |
1638 | 0 | else if (rKey == "margin-bottom") |
1639 | 0 | set_margin_bottom(rValue.toInt32()); |
1640 | 0 | else if (rKey == "hscrollbar-policy") |
1641 | 0 | { |
1642 | 0 | WinBits nBits = GetStyle(); |
1643 | 0 | nBits &= ~(WB_AUTOHSCROLL|WB_HSCROLL); |
1644 | 0 | if (rValue == "always") |
1645 | 0 | nBits |= WB_HSCROLL; |
1646 | 0 | else if (rValue == "automatic") |
1647 | 0 | nBits |= WB_AUTOHSCROLL; |
1648 | 0 | SetStyle(nBits); |
1649 | 0 | } |
1650 | 0 | else if (rKey == "vscrollbar-policy") |
1651 | 0 | { |
1652 | 0 | WinBits nBits = GetStyle(); |
1653 | 0 | nBits &= ~(WB_AUTOVSCROLL|WB_VSCROLL); |
1654 | 0 | if (rValue == "always") |
1655 | 0 | nBits |= WB_VSCROLL; |
1656 | 0 | else if (rValue == "automatic") |
1657 | 0 | nBits |= WB_AUTOVSCROLL; |
1658 | 0 | SetStyle(nBits); |
1659 | 0 | } |
1660 | 0 | else if (rKey == "accessible-name") |
1661 | 0 | { |
1662 | 0 | SetAccessibleName(rValue); |
1663 | 0 | } |
1664 | 0 | else if (rKey == "accessible-description") |
1665 | 0 | { |
1666 | 0 | SetAccessibleDescription(rValue); |
1667 | 0 | } |
1668 | 0 | else if (rKey == "accessible-role") |
1669 | 0 | { |
1670 | 0 | sal_Int16 role = BuilderUtils::getRoleFromName(rValue); |
1671 | 0 | if (role != css::accessibility::AccessibleRole::UNKNOWN) |
1672 | 0 | SetAccessibleRole(role); |
1673 | 0 | } |
1674 | 0 | else if (rKey == "use-markup") |
1675 | 0 | { |
1676 | | //https://live.gnome.org/GnomeGoals/RemoveMarkupInMessages |
1677 | 0 | SAL_WARN_IF(toBool(rValue), "vcl.layout", "Use pango attributes instead of mark-up"); |
1678 | 0 | } |
1679 | 0 | else if (rKey == "has-focus") |
1680 | 0 | { |
1681 | 0 | if (toBool(rValue)) |
1682 | 0 | GrabFocus(); |
1683 | 0 | } |
1684 | 0 | else if (rKey == "can-focus") |
1685 | 0 | { |
1686 | 0 | WinBits nBits = GetStyle(); |
1687 | 0 | nBits &= ~(WB_TABSTOP|WB_NOTABSTOP); |
1688 | 0 | if (toBool(rValue)) |
1689 | 0 | nBits |= WB_TABSTOP; |
1690 | 0 | else |
1691 | 0 | nBits |= WB_NOTABSTOP; |
1692 | 0 | SetStyle(nBits); |
1693 | 0 | } |
1694 | 0 | else |
1695 | 0 | { |
1696 | 0 | SAL_INFO("vcl.layout", "unhandled property: " << rKey); |
1697 | 0 | return false; |
1698 | 0 | } |
1699 | 0 | return true; |
1700 | 0 | } |
1701 | | |
1702 | | void Window::set_height_request(sal_Int32 nHeightRequest) |
1703 | 0 | { |
1704 | 0 | if (!mpWindowImpl) |
1705 | 0 | return; |
1706 | | |
1707 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1708 | |
|
1709 | 0 | if ( pWindowImpl->mnHeightRequest != nHeightRequest ) |
1710 | 0 | { |
1711 | 0 | pWindowImpl->mnHeightRequest = nHeightRequest; |
1712 | 0 | queue_resize(); |
1713 | 0 | } |
1714 | 0 | } |
1715 | | |
1716 | | void Window::set_width_request(sal_Int32 nWidthRequest) |
1717 | 0 | { |
1718 | 0 | if (!mpWindowImpl) |
1719 | 0 | return; |
1720 | | |
1721 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1722 | |
|
1723 | 0 | if ( pWindowImpl->mnWidthRequest != nWidthRequest ) |
1724 | 0 | { |
1725 | 0 | pWindowImpl->mnWidthRequest = nWidthRequest; |
1726 | 0 | queue_resize(); |
1727 | 0 | } |
1728 | 0 | } |
1729 | | |
1730 | | Size Window::get_ungrouped_preferred_size() const |
1731 | 0 | { |
1732 | 0 | Size aRet(get_width_request(), get_height_request()); |
1733 | 0 | if (aRet.Width() == -1 || aRet.Height() == -1) |
1734 | 0 | { |
1735 | | //cache gets blown away by queue_resize |
1736 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1737 | 0 | if (pWindowImpl->mnOptimalWidthCache == -1 || pWindowImpl->mnOptimalHeightCache == -1) |
1738 | 0 | { |
1739 | 0 | Size aOptimal(GetOptimalSize()); |
1740 | 0 | pWindowImpl->mnOptimalWidthCache = aOptimal.Width(); |
1741 | 0 | pWindowImpl->mnOptimalHeightCache = aOptimal.Height(); |
1742 | 0 | } |
1743 | |
|
1744 | 0 | if (aRet.Width() == -1) |
1745 | 0 | aRet.setWidth( pWindowImpl->mnOptimalWidthCache ); |
1746 | 0 | if (aRet.Height() == -1) |
1747 | 0 | aRet.setHeight( pWindowImpl->mnOptimalHeightCache ); |
1748 | 0 | } |
1749 | 0 | return aRet; |
1750 | 0 | } |
1751 | | |
1752 | | Size Window::get_preferred_size() const |
1753 | 0 | { |
1754 | 0 | Size aRet(get_ungrouped_preferred_size()); |
1755 | |
|
1756 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1757 | 0 | if (pWindowImpl->m_xSizeGroup) |
1758 | 0 | { |
1759 | 0 | const VclSizeGroupMode eMode = pWindowImpl->m_xSizeGroup->get_mode(); |
1760 | 0 | if (eMode != VclSizeGroupMode::NONE) |
1761 | 0 | { |
1762 | 0 | const bool bIgnoreInHidden = pWindowImpl->m_xSizeGroup->get_ignore_hidden(); |
1763 | 0 | const std::set<VclPtr<vcl::Window> > &rWindows = pWindowImpl->m_xSizeGroup->get_widgets(); |
1764 | 0 | for (const vcl::Window* pOther : rWindows) |
1765 | 0 | { |
1766 | 0 | if (pOther == this) |
1767 | 0 | continue; |
1768 | 0 | if (bIgnoreInHidden && !pOther->IsVisible()) |
1769 | 0 | continue; |
1770 | 0 | Size aOtherSize = pOther->get_ungrouped_preferred_size(); |
1771 | 0 | if (eMode == VclSizeGroupMode::Both || eMode == VclSizeGroupMode::Horizontal) |
1772 | 0 | aRet.setWidth( std::max(aRet.Width(), aOtherSize.Width()) ); |
1773 | 0 | if (eMode == VclSizeGroupMode::Both || eMode == VclSizeGroupMode::Vertical) |
1774 | 0 | aRet.setHeight( std::max(aRet.Height(), aOtherSize.Height()) ); |
1775 | 0 | } |
1776 | 0 | } |
1777 | 0 | } |
1778 | |
|
1779 | 0 | return aRet; |
1780 | 0 | } |
1781 | | |
1782 | | VclAlign Window::get_halign() const |
1783 | 0 | { |
1784 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1785 | 0 | return pWindowImpl->meHalign; |
1786 | 0 | } |
1787 | | |
1788 | | void Window::set_halign(VclAlign eAlign) |
1789 | 0 | { |
1790 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1791 | 0 | pWindowImpl->meHalign = eAlign; |
1792 | 0 | } |
1793 | | |
1794 | | VclAlign Window::get_valign() const |
1795 | 0 | { |
1796 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1797 | 0 | return pWindowImpl->meValign; |
1798 | 0 | } |
1799 | | |
1800 | | void Window::set_valign(VclAlign eAlign) |
1801 | 0 | { |
1802 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1803 | 0 | pWindowImpl->meValign = eAlign; |
1804 | 0 | } |
1805 | | |
1806 | | bool Window::get_hexpand() const |
1807 | 0 | { |
1808 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1809 | 0 | return pWindowImpl->mbHexpand; |
1810 | 0 | } |
1811 | | |
1812 | | void Window::set_hexpand(bool bExpand) |
1813 | 0 | { |
1814 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1815 | 0 | pWindowImpl->mbHexpand = bExpand; |
1816 | 0 | } |
1817 | | |
1818 | | bool Window::get_vexpand() const |
1819 | 0 | { |
1820 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1821 | 0 | return pWindowImpl->mbVexpand; |
1822 | 0 | } |
1823 | | |
1824 | | void Window::set_vexpand(bool bExpand) |
1825 | 0 | { |
1826 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1827 | 0 | pWindowImpl->mbVexpand = bExpand; |
1828 | 0 | } |
1829 | | |
1830 | | bool Window::get_expand() const |
1831 | 0 | { |
1832 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1833 | 0 | return pWindowImpl->mbExpand; |
1834 | 0 | } |
1835 | | |
1836 | | void Window::set_expand(bool bExpand) |
1837 | 0 | { |
1838 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1839 | 0 | pWindowImpl->mbExpand = bExpand; |
1840 | 0 | } |
1841 | | |
1842 | | VclPackType Window::get_pack_type() const |
1843 | 0 | { |
1844 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1845 | 0 | return pWindowImpl->mePackType; |
1846 | 0 | } |
1847 | | |
1848 | | void Window::set_pack_type(VclPackType ePackType) |
1849 | 0 | { |
1850 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1851 | 0 | pWindowImpl->mePackType = ePackType; |
1852 | 0 | } |
1853 | | |
1854 | | sal_Int32 Window::get_padding() const |
1855 | 0 | { |
1856 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1857 | 0 | return pWindowImpl->mnPadding; |
1858 | 0 | } |
1859 | | |
1860 | | void Window::set_padding(sal_Int32 nPadding) |
1861 | 0 | { |
1862 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1863 | 0 | pWindowImpl->mnPadding = nPadding; |
1864 | 0 | } |
1865 | | |
1866 | | bool Window::get_fill() const |
1867 | 0 | { |
1868 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1869 | 0 | return pWindowImpl->mbFill; |
1870 | 0 | } |
1871 | | |
1872 | | void Window::set_fill(bool bFill) |
1873 | 0 | { |
1874 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1875 | 0 | pWindowImpl->mbFill = bFill; |
1876 | 0 | } |
1877 | | |
1878 | | sal_Int32 Window::get_grid_width() const |
1879 | 0 | { |
1880 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1881 | 0 | return pWindowImpl->mnGridWidth; |
1882 | 0 | } |
1883 | | |
1884 | | void Window::set_grid_width(sal_Int32 nCols) |
1885 | 0 | { |
1886 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1887 | 0 | pWindowImpl->mnGridWidth = nCols; |
1888 | 0 | } |
1889 | | |
1890 | | sal_Int32 Window::get_grid_left_attach() const |
1891 | 0 | { |
1892 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1893 | 0 | return pWindowImpl->mnGridLeftAttach; |
1894 | 0 | } |
1895 | | |
1896 | | void Window::set_grid_left_attach(sal_Int32 nAttach) |
1897 | 0 | { |
1898 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1899 | 0 | pWindowImpl->mnGridLeftAttach = nAttach; |
1900 | 0 | } |
1901 | | |
1902 | | sal_Int32 Window::get_grid_height() const |
1903 | 0 | { |
1904 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1905 | 0 | return pWindowImpl->mnGridHeight; |
1906 | 0 | } |
1907 | | |
1908 | | void Window::set_grid_height(sal_Int32 nRows) |
1909 | 0 | { |
1910 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1911 | 0 | pWindowImpl->mnGridHeight = nRows; |
1912 | 0 | } |
1913 | | |
1914 | | sal_Int32 Window::get_grid_top_attach() const |
1915 | 0 | { |
1916 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1917 | 0 | return pWindowImpl->mnGridTopAttach; |
1918 | 0 | } |
1919 | | |
1920 | | void Window::set_grid_top_attach(sal_Int32 nAttach) |
1921 | 0 | { |
1922 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1923 | 0 | pWindowImpl->mnGridTopAttach = nAttach; |
1924 | 0 | } |
1925 | | |
1926 | | void Window::set_border_width(sal_Int32 nBorderWidth) |
1927 | 33.1k | { |
1928 | 33.1k | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1929 | 33.1k | pWindowImpl->mnBorderWidth = nBorderWidth; |
1930 | 33.1k | } |
1931 | | |
1932 | | sal_Int32 Window::get_border_width() const |
1933 | 0 | { |
1934 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1935 | 0 | return pWindowImpl->mnBorderWidth; |
1936 | 0 | } |
1937 | | |
1938 | | void Window::set_margin_start(sal_Int32 nWidth) |
1939 | 0 | { |
1940 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1941 | 0 | if (pWindowImpl->mnMarginLeft != nWidth) |
1942 | 0 | { |
1943 | 0 | pWindowImpl->mnMarginLeft = nWidth; |
1944 | 0 | queue_resize(); |
1945 | 0 | } |
1946 | 0 | } |
1947 | | |
1948 | | sal_Int32 Window::get_margin_start() const |
1949 | 0 | { |
1950 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1951 | 0 | return pWindowImpl->mnMarginLeft; |
1952 | 0 | } |
1953 | | |
1954 | | void Window::set_margin_end(sal_Int32 nWidth) |
1955 | 0 | { |
1956 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1957 | 0 | if (pWindowImpl->mnMarginRight != nWidth) |
1958 | 0 | { |
1959 | 0 | pWindowImpl->mnMarginRight = nWidth; |
1960 | 0 | queue_resize(); |
1961 | 0 | } |
1962 | 0 | } |
1963 | | |
1964 | | sal_Int32 Window::get_margin_end() const |
1965 | 0 | { |
1966 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1967 | 0 | return pWindowImpl->mnMarginRight; |
1968 | 0 | } |
1969 | | |
1970 | | void Window::set_margin_top(sal_Int32 nWidth) |
1971 | 0 | { |
1972 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1973 | 0 | if (pWindowImpl->mnMarginTop != nWidth) |
1974 | 0 | { |
1975 | 0 | pWindowImpl->mnMarginTop = nWidth; |
1976 | 0 | queue_resize(); |
1977 | 0 | } |
1978 | 0 | } |
1979 | | |
1980 | | sal_Int32 Window::get_margin_top() const |
1981 | 0 | { |
1982 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1983 | 0 | return pWindowImpl->mnMarginTop; |
1984 | 0 | } |
1985 | | |
1986 | | void Window::set_margin_bottom(sal_Int32 nWidth) |
1987 | 0 | { |
1988 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1989 | 0 | if (pWindowImpl->mnMarginBottom != nWidth) |
1990 | 0 | { |
1991 | 0 | pWindowImpl->mnMarginBottom = nWidth; |
1992 | 0 | queue_resize(); |
1993 | 0 | } |
1994 | 0 | } |
1995 | | |
1996 | | sal_Int32 Window::get_margin_bottom() const |
1997 | 0 | { |
1998 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
1999 | 0 | return pWindowImpl->mnMarginBottom; |
2000 | 0 | } |
2001 | | |
2002 | | sal_Int32 Window::get_height_request() const |
2003 | 0 | { |
2004 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
2005 | 0 | return pWindowImpl->mnHeightRequest; |
2006 | 0 | } |
2007 | | |
2008 | | sal_Int32 Window::get_width_request() const |
2009 | 0 | { |
2010 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
2011 | 0 | return pWindowImpl->mnWidthRequest; |
2012 | 0 | } |
2013 | | |
2014 | | bool Window::get_secondary() const |
2015 | 0 | { |
2016 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
2017 | 0 | return pWindowImpl->mbSecondary; |
2018 | 0 | } |
2019 | | |
2020 | | void Window::set_secondary(bool bSecondary) |
2021 | 0 | { |
2022 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
2023 | 0 | pWindowImpl->mbSecondary = bSecondary; |
2024 | 0 | } |
2025 | | |
2026 | | bool Window::get_non_homogeneous() const |
2027 | 0 | { |
2028 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
2029 | 0 | return pWindowImpl->mbNonHomogeneous; |
2030 | 0 | } |
2031 | | |
2032 | | void Window::set_non_homogeneous(bool bNonHomogeneous) |
2033 | 0 | { |
2034 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
2035 | 0 | pWindowImpl->mbNonHomogeneous = bNonHomogeneous; |
2036 | 0 | } |
2037 | | |
2038 | | void Window::add_to_size_group(const std::shared_ptr<VclSizeGroup>& xGroup) |
2039 | 0 | { |
2040 | 0 | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
2041 | | //To-Do, multiple groups |
2042 | 0 | pWindowImpl->m_xSizeGroup = xGroup; |
2043 | 0 | pWindowImpl->m_xSizeGroup->insert(this); |
2044 | 0 | if (VclSizeGroupMode::NONE != pWindowImpl->m_xSizeGroup->get_mode()) |
2045 | 0 | queue_resize(); |
2046 | 0 | } |
2047 | | |
2048 | | void Window::remove_from_all_size_groups() |
2049 | 103k | { |
2050 | 103k | WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get(); |
2051 | | //To-Do, multiple groups |
2052 | 103k | if (pWindowImpl->m_xSizeGroup) |
2053 | 0 | { |
2054 | 0 | if (VclSizeGroupMode::NONE != pWindowImpl->m_xSizeGroup->get_mode()) |
2055 | 0 | queue_resize(); |
2056 | 0 | pWindowImpl->m_xSizeGroup->erase(this); |
2057 | 0 | pWindowImpl->m_xSizeGroup.reset(); |
2058 | 0 | } |
2059 | 103k | } |
2060 | | |
2061 | | void Window::add_mnemonic_label(FixedText *pLabel) |
2062 | 0 | { |
2063 | 0 | std::vector<VclPtr<FixedText> >& v = mpWindowImpl->m_aMnemonicLabels; |
2064 | 0 | if (std::find(v.begin(), v.end(), VclPtr<FixedText>(pLabel)) != v.end()) |
2065 | 0 | return; |
2066 | 0 | v.emplace_back(pLabel); |
2067 | 0 | pLabel->set_mnemonic_widget(this); |
2068 | 0 | } |
2069 | | |
2070 | | void Window::remove_mnemonic_label(FixedText *pLabel) |
2071 | 0 | { |
2072 | 0 | std::vector<VclPtr<FixedText> >& v = mpWindowImpl->m_aMnemonicLabels; |
2073 | 0 | auto aFind = std::find(v.begin(), v.end(), VclPtr<FixedText>(pLabel)); |
2074 | 0 | if (aFind == v.end()) |
2075 | 0 | return; |
2076 | 0 | v.erase(aFind); |
2077 | 0 | pLabel->set_mnemonic_widget(nullptr); |
2078 | 0 | } |
2079 | | |
2080 | | const std::vector<VclPtr<FixedText> >& Window::list_mnemonic_labels() const |
2081 | 103k | { |
2082 | 103k | return mpWindowImpl->m_aMnemonicLabels; |
2083 | 103k | } |
2084 | | |
2085 | | } /* namespace vcl */ |
2086 | | |
2087 | | void InvertFocusRect(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) |
2088 | 0 | { |
2089 | 0 | const int nBorder = 1; |
2090 | 0 | rRenderContext.Invert(tools::Rectangle(Point(rRect.Left(), rRect.Top()), Size(rRect.GetWidth(), nBorder)), InvertFlags::N50); |
2091 | 0 | rRenderContext.Invert(tools::Rectangle(Point(rRect.Left(), rRect.Bottom()-nBorder+1), Size(rRect.GetWidth(), nBorder)), InvertFlags::N50); |
2092 | 0 | rRenderContext.Invert(tools::Rectangle(Point(rRect.Left(), rRect.Top()+nBorder), Size(nBorder, rRect.GetHeight()-(nBorder*2))), InvertFlags::N50); |
2093 | 0 | rRenderContext.Invert(tools::Rectangle(Point(rRect.Right()-nBorder+1, rRect.Top()+nBorder), Size(nBorder, rRect.GetHeight()-(nBorder*2))), InvertFlags::N50); |
2094 | 0 | } |
2095 | | |
2096 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |