Line data Source code
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 :
21 : #include <limits.h>
22 : #include <tools/debug.hxx>
23 : #include <tools/poly.hxx>
24 :
25 : #include <vcl/bitmap.hxx>
26 : #include <vcl/dialog.hxx>
27 : #include <vcl/event.hxx>
28 : #include <vcl/layout.hxx>
29 : #include <vcl/timer.hxx>
30 : #include <vcl/metric.hxx>
31 : #include <vcl/virdev.hxx>
32 : #include <vcl/window.hxx>
33 : #include <vcl/scrbar.hxx>
34 : #include <vcl/dockwin.hxx>
35 : #include <vcl/tabctrl.hxx>
36 :
37 : #include <window.h>
38 : #include <outfont.hxx>
39 : #include <outdev.h>
40 : #include <svdata.hxx>
41 : #include <impbmp.hxx>
42 : #include <salbmp.hxx>
43 : #include <salgdi.hxx>
44 : #include <salframe.hxx>
45 : #include <scrwnd.hxx>
46 :
47 : using namespace com::sun::star;
48 :
49 : // =======================================================================
50 :
51 : DBG_NAMEEX( Window )
52 :
53 : // =======================================================================
54 :
55 : #define IMPL_MAXSAVEBACKSIZE (640*480)
56 : #define IMPL_MAXALLSAVEBACKSIZE (800*600*2)
57 :
58 : // =======================================================================
59 :
60 0 : struct ImplFocusDelData : public ImplDelData
61 : {
62 : Window* mpFocusWin;
63 : };
64 :
65 : // =======================================================================
66 :
67 0 : sal_Bool Window::ImplIsWindowInFront( const Window* pTestWindow ) const
68 : {
69 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
70 : DBG_CHKOBJ( pTestWindow, Window, ImplDbgCheckWindow );
71 :
72 : // check for overlapping window
73 0 : pTestWindow = pTestWindow->ImplGetFirstOverlapWindow();
74 0 : const Window* pTempWindow = pTestWindow;
75 0 : const Window* pThisWindow = ImplGetFirstOverlapWindow();
76 0 : if ( pTempWindow == pThisWindow )
77 0 : return sal_False;
78 0 : do
79 : {
80 0 : if ( pTempWindow == pThisWindow )
81 0 : return sal_True;
82 0 : if ( pTempWindow->mpWindowImpl->mbFrame )
83 0 : break;
84 0 : pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow;
85 : }
86 : while ( pTempWindow );
87 0 : pTempWindow = pThisWindow;
88 0 : do
89 : {
90 0 : if ( pTempWindow == pTestWindow )
91 0 : return sal_False;
92 0 : if ( pTempWindow->mpWindowImpl->mbFrame )
93 0 : break;
94 0 : pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow;
95 : }
96 : while ( pTempWindow );
97 :
98 : // move window to same level
99 0 : if ( pThisWindow->mpWindowImpl->mpOverlapWindow != pTestWindow->mpWindowImpl->mpOverlapWindow )
100 : {
101 0 : sal_uInt16 nThisLevel = 0;
102 0 : sal_uInt16 nTestLevel = 0;
103 0 : pTempWindow = pThisWindow;
104 0 : do
105 : {
106 0 : nThisLevel++;
107 0 : pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow;
108 : }
109 0 : while ( !pTempWindow->mpWindowImpl->mbFrame );
110 0 : pTempWindow = pTestWindow;
111 0 : do
112 : {
113 0 : nTestLevel++;
114 0 : pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow;
115 : }
116 0 : while ( !pTempWindow->mpWindowImpl->mbFrame );
117 :
118 0 : if ( nThisLevel < nTestLevel )
119 : {
120 0 : do
121 : {
122 0 : if ( pTestWindow->mpWindowImpl->mpOverlapWindow == pThisWindow->mpWindowImpl->mpOverlapWindow )
123 0 : break;
124 0 : if ( pTestWindow->mpWindowImpl->mbFrame )
125 0 : break;
126 0 : pTestWindow = pTestWindow->mpWindowImpl->mpOverlapWindow;
127 : }
128 : while ( pTestWindow );
129 : }
130 : else
131 : {
132 0 : do
133 : {
134 0 : if ( pThisWindow->mpWindowImpl->mpOverlapWindow == pTempWindow->mpWindowImpl->mpOverlapWindow )
135 0 : break;
136 0 : if ( pThisWindow->mpWindowImpl->mbFrame )
137 0 : break;
138 0 : pThisWindow = pThisWindow->mpWindowImpl->mpOverlapWindow;
139 : }
140 : while ( pThisWindow );
141 : }
142 : }
143 :
144 : // if TestWindow is before ThisWindow, it is in front
145 0 : pTempWindow = pTestWindow;
146 0 : do
147 : {
148 0 : if ( pTempWindow == pThisWindow )
149 0 : return sal_True;
150 0 : pTempWindow = pTempWindow->mpWindowImpl->mpNext;
151 : }
152 : while ( pTempWindow );
153 :
154 0 : return sal_False;
155 : }
156 :
157 : // =======================================================================
158 :
159 0 : void Window::ImplSaveOverlapBackground()
160 : {
161 : DBG_ASSERT( !mpWindowImpl->mpOverlapData->mpSaveBackDev, "Window::ImplSaveOverlapBackground() - Background already saved" );
162 :
163 0 : if ( !mpWindowImpl->mbFrame )
164 : {
165 0 : sal_uLong nSaveBackSize = mnOutWidth*mnOutHeight;
166 0 : if ( nSaveBackSize <= IMPL_MAXSAVEBACKSIZE )
167 : {
168 0 : if ( nSaveBackSize+mpWindowImpl->mpFrameData->mnAllSaveBackSize <= IMPL_MAXALLSAVEBACKSIZE )
169 : {
170 0 : Size aOutSize( mnOutWidth, mnOutHeight );
171 0 : mpWindowImpl->mpOverlapData->mpSaveBackDev = new VirtualDevice( *mpWindowImpl->mpFrameWindow );
172 0 : if ( mpWindowImpl->mpOverlapData->mpSaveBackDev->SetOutputSizePixel( aOutSize ) )
173 : {
174 0 : mpWindowImpl->mpFrameWindow->ImplUpdateAll();
175 :
176 0 : if ( mpWindowImpl->mbInitWinClipRegion )
177 0 : ImplInitWinClipRegion();
178 :
179 0 : mpWindowImpl->mpOverlapData->mnSaveBackSize = nSaveBackSize;
180 0 : mpWindowImpl->mpFrameData->mnAllSaveBackSize += nSaveBackSize;
181 0 : Point aDevPt;
182 : mpWindowImpl->mpFrameWindow->ImplGetFrameDev( Point( mnOutOffX, mnOutOffY ),
183 : aDevPt, aOutSize,
184 0 : *(mpWindowImpl->mpOverlapData->mpSaveBackDev) );
185 0 : mpWindowImpl->mpOverlapData->mpNextBackWin = mpWindowImpl->mpFrameData->mpFirstBackWin;
186 0 : mpWindowImpl->mpFrameData->mpFirstBackWin = this;
187 : }
188 : else
189 : {
190 0 : delete mpWindowImpl->mpOverlapData->mpSaveBackDev;
191 0 : mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL;
192 : }
193 : }
194 : }
195 : }
196 0 : }
197 :
198 : // -----------------------------------------------------------------------
199 :
200 0 : sal_Bool Window::ImplRestoreOverlapBackground( Region& rInvRegion )
201 : {
202 0 : if ( mpWindowImpl->mpOverlapData->mpSaveBackDev )
203 : {
204 0 : if ( mpWindowImpl->mbInitWinClipRegion )
205 0 : ImplInitWinClipRegion();
206 :
207 0 : if ( mpWindowImpl->mpOverlapData->mpSaveBackDev )
208 : {
209 0 : Point aDevPt;
210 0 : Point aDestPt( mnOutOffX, mnOutOffY );
211 0 : Size aDevSize = mpWindowImpl->mpOverlapData->mpSaveBackDev->GetOutputSizePixel();
212 0 : if ( mpWindowImpl->mpOverlapData->mpSaveBackRgn )
213 : {
214 0 : mpWindowImpl->mpOverlapData->mpSaveBackRgn->Intersect( mpWindowImpl->maWinClipRegion );
215 0 : rInvRegion = mpWindowImpl->maWinClipRegion;
216 0 : rInvRegion.Exclude( *mpWindowImpl->mpOverlapData->mpSaveBackRgn );
217 : mpWindowImpl->mpFrameWindow->ImplDrawFrameDev( aDestPt, aDevPt, aDevSize,
218 : *(mpWindowImpl->mpOverlapData->mpSaveBackDev),
219 0 : *mpWindowImpl->mpOverlapData->mpSaveBackRgn );
220 : }
221 : else
222 : {
223 : mpWindowImpl->mpFrameWindow->ImplDrawFrameDev( aDestPt, aDevPt, aDevSize,
224 : *(mpWindowImpl->mpOverlapData->mpSaveBackDev),
225 0 : mpWindowImpl->maWinClipRegion );
226 : }
227 0 : ImplDeleteOverlapBackground();
228 : }
229 :
230 0 : return sal_True;
231 : }
232 :
233 0 : return sal_False;
234 : }
235 :
236 : // -----------------------------------------------------------------------
237 :
238 0 : void Window::ImplDeleteOverlapBackground()
239 : {
240 0 : if ( mpWindowImpl->mpOverlapData->mpSaveBackDev )
241 : {
242 0 : mpWindowImpl->mpFrameData->mnAllSaveBackSize -= mpWindowImpl->mpOverlapData->mnSaveBackSize;
243 0 : delete mpWindowImpl->mpOverlapData->mpSaveBackDev;
244 0 : mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL;
245 0 : if ( mpWindowImpl->mpOverlapData->mpSaveBackRgn )
246 : {
247 0 : delete mpWindowImpl->mpOverlapData->mpSaveBackRgn;
248 0 : mpWindowImpl->mpOverlapData->mpSaveBackRgn = NULL;
249 : }
250 :
251 : // remove window from the list
252 0 : if ( mpWindowImpl->mpFrameData->mpFirstBackWin == this )
253 0 : mpWindowImpl->mpFrameData->mpFirstBackWin = mpWindowImpl->mpOverlapData->mpNextBackWin;
254 : else
255 : {
256 0 : Window* pTemp = mpWindowImpl->mpFrameData->mpFirstBackWin;
257 0 : while ( pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin != this )
258 0 : pTemp = pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin;
259 0 : pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin = mpWindowImpl->mpOverlapData->mpNextBackWin;
260 : }
261 0 : mpWindowImpl->mpOverlapData->mpNextBackWin = NULL;
262 : }
263 0 : }
264 :
265 : // -----------------------------------------------------------------------
266 :
267 0 : void Window::ImplInvalidateAllOverlapBackgrounds()
268 : {
269 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
270 :
271 0 : Window* pWindow = mpWindowImpl->mpFrameData->mpFirstBackWin;
272 0 : while ( pWindow )
273 : {
274 : // remember next window here already, as this window could
275 : // be removed within the next if clause from the list
276 0 : Window* pNext = pWindow->mpWindowImpl->mpOverlapData->mpNextBackWin;
277 :
278 0 : if ( ImplIsWindowInFront( pWindow ) )
279 : {
280 : Rectangle aRect1( Point( mnOutOffX, mnOutOffY ),
281 0 : Size( mnOutWidth, mnOutHeight ) );
282 : Rectangle aRect2( Point( pWindow->mnOutOffX, pWindow->mnOutOffY ),
283 0 : Size( pWindow->mnOutWidth, pWindow->mnOutHeight ) );
284 0 : aRect1.Intersection( aRect2 );
285 0 : if ( !aRect1.IsEmpty() )
286 : {
287 0 : if ( !pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn )
288 0 : pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn = new Region( aRect2 );
289 0 : pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn->Exclude( aRect1 );
290 0 : if ( pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn->IsEmpty() )
291 0 : pWindow->ImplDeleteOverlapBackground();
292 : }
293 :
294 : }
295 :
296 0 : pWindow = pNext;
297 : }
298 0 : }
299 :
300 : // -----------------------------------------------------------------------
301 :
302 0 : void Window::ShowFocus( const Rectangle& rRect )
303 : {
304 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
305 :
306 0 : if( mpWindowImpl->mbInShowFocus )
307 0 : return;
308 0 : mpWindowImpl->mbInShowFocus = sal_True;
309 :
310 0 : ImplWinData* pWinData = ImplGetWinData();
311 :
312 : // native themeing suggest not to use focus rects
313 0 : if( ! ( mpWindowImpl->mbUseNativeFocus &&
314 0 : IsNativeWidgetEnabled() ) )
315 : {
316 0 : if ( !mpWindowImpl->mbInPaint )
317 : {
318 0 : if ( mpWindowImpl->mbFocusVisible )
319 : {
320 0 : if ( *(pWinData->mpFocusRect) == rRect )
321 : {
322 0 : mpWindowImpl->mbInShowFocus = sal_False;
323 0 : return;
324 : }
325 :
326 0 : ImplInvertFocus( *(pWinData->mpFocusRect) );
327 : }
328 :
329 0 : ImplInvertFocus( rRect );
330 : }
331 0 : if ( !pWinData->mpFocusRect )
332 0 : pWinData->mpFocusRect = new Rectangle( rRect );
333 : else
334 0 : *(pWinData->mpFocusRect) = rRect;
335 0 : mpWindowImpl->mbFocusVisible = sal_True;
336 : }
337 : else
338 : {
339 0 : if( ! mpWindowImpl->mbNativeFocusVisible )
340 : {
341 0 : mpWindowImpl->mbNativeFocusVisible = sal_True;
342 0 : if ( !mpWindowImpl->mbInPaint )
343 0 : Invalidate();
344 : }
345 : }
346 0 : mpWindowImpl->mbInShowFocus = sal_False;
347 : }
348 :
349 : // -----------------------------------------------------------------------
350 :
351 1265 : void Window::HideFocus()
352 : {
353 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
354 :
355 1265 : if( mpWindowImpl->mbInHideFocus )
356 0 : return;
357 1265 : mpWindowImpl->mbInHideFocus = sal_True;
358 :
359 : // native themeing can suggest not to use focus rects
360 1265 : if( ! ( mpWindowImpl->mbUseNativeFocus &&
361 1265 : IsNativeWidgetEnabled() ) )
362 : {
363 1265 : if ( !mpWindowImpl->mbFocusVisible )
364 : {
365 1265 : mpWindowImpl->mbInHideFocus = sal_False;
366 1265 : return;
367 : }
368 :
369 0 : if ( !mpWindowImpl->mbInPaint )
370 0 : ImplInvertFocus( *(ImplGetWinData()->mpFocusRect) );
371 0 : mpWindowImpl->mbFocusVisible = sal_False;
372 : }
373 : else
374 : {
375 0 : if( mpWindowImpl->mbNativeFocusVisible )
376 : {
377 0 : mpWindowImpl->mbNativeFocusVisible = sal_False;
378 0 : if ( !mpWindowImpl->mbInPaint )
379 0 : Invalidate();
380 : }
381 : }
382 0 : mpWindowImpl->mbInHideFocus = sal_False;
383 : }
384 :
385 : // -----------------------------------------------------------------------
386 :
387 1140 : void Window::Invert( const Rectangle& rRect, sal_uInt16 nFlags )
388 : {
389 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
390 :
391 1140 : if ( !IsDeviceOutputNecessary() )
392 : return;
393 :
394 1132 : Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
395 :
396 1132 : if ( aRect.IsEmpty() )
397 : return;
398 1132 : aRect.Justify();
399 :
400 : // we need a graphics
401 1132 : if ( !mpGraphics )
402 : {
403 0 : if ( !ImplGetGraphics() )
404 : return;
405 : }
406 :
407 1132 : if ( mbInitClipRegion )
408 197 : ImplInitClipRegion();
409 :
410 1132 : if ( mbOutputClipped )
411 : return;
412 :
413 1132 : SalInvert nSalFlags = 0;
414 1132 : if ( nFlags & INVERT_HIGHLIGHT )
415 0 : nSalFlags |= SAL_INVERT_HIGHLIGHT;
416 1132 : if ( nFlags & INVERT_50 )
417 0 : nSalFlags |= SAL_INVERT_50;
418 1132 : mpGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), nSalFlags, this );
419 : }
420 :
421 : // -----------------------------------------------------------------------
422 :
423 0 : void Window::Invert( const Polygon& rPoly, sal_uInt16 nFlags )
424 : {
425 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
426 :
427 0 : if ( !IsDeviceOutputNecessary() )
428 : return;
429 :
430 0 : sal_uInt16 nPoints = rPoly.GetSize();
431 :
432 0 : if ( nPoints < 2 )
433 : return;
434 :
435 0 : Polygon aPoly( ImplLogicToDevicePixel( rPoly ) );
436 :
437 : // we need a graphics
438 0 : if ( !mpGraphics )
439 : {
440 0 : if ( !ImplGetGraphics() )
441 : return;
442 : }
443 :
444 0 : if ( mbInitClipRegion )
445 0 : ImplInitClipRegion();
446 :
447 0 : if ( mbOutputClipped )
448 : return;
449 :
450 0 : SalInvert nSalFlags = 0;
451 0 : if ( nFlags & INVERT_HIGHLIGHT )
452 0 : nSalFlags |= SAL_INVERT_HIGHLIGHT;
453 0 : if ( nFlags & INVERT_50 )
454 0 : nSalFlags |= SAL_INVERT_50;
455 0 : const SalPoint* pPtAry = (const SalPoint*)aPoly.GetConstPointAry();
456 0 : mpGraphics->Invert( nPoints, pPtAry, nSalFlags, this );
457 : }
458 :
459 : // -----------------------------------------------------------------------
460 :
461 0 : void Window::ShowTracking( const Rectangle& rRect, sal_uInt16 nFlags )
462 : {
463 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
464 :
465 0 : ImplWinData* pWinData = ImplGetWinData();
466 :
467 0 : if ( !mpWindowImpl->mbInPaint || !(nFlags & SHOWTRACK_WINDOW) )
468 : {
469 0 : if ( mpWindowImpl->mbTrackVisible )
470 : {
471 0 : if ( (*(pWinData->mpTrackRect) == rRect) &&
472 : (pWinData->mnTrackFlags == nFlags) )
473 0 : return;
474 :
475 0 : InvertTracking( *(pWinData->mpTrackRect), pWinData->mnTrackFlags );
476 : }
477 :
478 0 : InvertTracking( rRect, nFlags );
479 : }
480 :
481 0 : if ( !pWinData->mpTrackRect )
482 0 : pWinData->mpTrackRect = new Rectangle( rRect );
483 : else
484 0 : *(pWinData->mpTrackRect) = rRect;
485 0 : pWinData->mnTrackFlags = nFlags;
486 0 : mpWindowImpl->mbTrackVisible = sal_True;
487 : }
488 :
489 : // -----------------------------------------------------------------------
490 :
491 0 : void Window::HideTracking()
492 : {
493 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
494 :
495 0 : if ( mpWindowImpl->mbTrackVisible )
496 : {
497 0 : ImplWinData* pWinData = ImplGetWinData();
498 0 : if ( !mpWindowImpl->mbInPaint || !(pWinData->mnTrackFlags & SHOWTRACK_WINDOW) )
499 0 : InvertTracking( *(pWinData->mpTrackRect), pWinData->mnTrackFlags );
500 0 : mpWindowImpl->mbTrackVisible = sal_False;
501 : }
502 0 : }
503 :
504 : // -----------------------------------------------------------------------
505 :
506 0 : void Window::InvertTracking( const Rectangle& rRect, sal_uInt16 nFlags )
507 : {
508 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
509 :
510 0 : Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
511 :
512 0 : if ( aRect.IsEmpty() )
513 : return;
514 0 : aRect.Justify();
515 :
516 : SalGraphics* pGraphics;
517 :
518 0 : if ( nFlags & SHOWTRACK_WINDOW )
519 : {
520 0 : if ( !IsDeviceOutputNecessary() )
521 : return;
522 :
523 : // we need a graphics
524 0 : if ( !mpGraphics )
525 : {
526 0 : if ( !ImplGetGraphics() )
527 : return;
528 : }
529 :
530 0 : if ( mbInitClipRegion )
531 0 : ImplInitClipRegion();
532 :
533 0 : if ( mbOutputClipped )
534 : return;
535 :
536 0 : pGraphics = mpGraphics;
537 : }
538 : else
539 : {
540 0 : pGraphics = ImplGetFrameGraphics();
541 :
542 0 : if ( nFlags & SHOWTRACK_CLIP )
543 : {
544 0 : Point aPoint( mnOutOffX, mnOutOffY );
545 : Region aRegion( Rectangle( aPoint,
546 0 : Size( mnOutWidth, mnOutHeight ) ) );
547 0 : ImplClipBoundaries( aRegion, sal_False, sal_False );
548 0 : ImplSelectClipRegion( aRegion, pGraphics );
549 : }
550 : }
551 :
552 0 : sal_uInt16 nStyle = nFlags & SHOWTRACK_STYLE;
553 0 : if ( nStyle == SHOWTRACK_OBJECT )
554 0 : pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SAL_INVERT_TRACKFRAME, this );
555 0 : else if ( nStyle == SHOWTRACK_SPLIT )
556 0 : pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SAL_INVERT_50, this );
557 : else
558 : {
559 0 : long nBorder = 1;
560 0 : if ( nStyle == SHOWTRACK_BIG )
561 0 : nBorder = 5;
562 0 : pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), nBorder, SAL_INVERT_50, this );
563 0 : pGraphics->Invert( aRect.Left(), aRect.Bottom()-nBorder+1, aRect.GetWidth(), nBorder, SAL_INVERT_50, this );
564 0 : pGraphics->Invert( aRect.Left(), aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SAL_INVERT_50, this );
565 0 : pGraphics->Invert( aRect.Right()-nBorder+1, aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SAL_INVERT_50, this );
566 : }
567 : }
568 :
569 : // -----------------------------------------------------------------------
570 :
571 0 : void Window::InvertTracking( const Polygon& rPoly, sal_uInt16 nFlags )
572 : {
573 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
574 :
575 0 : sal_uInt16 nPoints = rPoly.GetSize();
576 :
577 0 : if ( nPoints < 2 )
578 : return;
579 :
580 0 : Polygon aPoly( ImplLogicToDevicePixel( rPoly ) );
581 :
582 : SalGraphics* pGraphics;
583 :
584 0 : if ( nFlags & SHOWTRACK_WINDOW )
585 : {
586 0 : if ( !IsDeviceOutputNecessary() )
587 : return;
588 :
589 : // we need a graphics
590 0 : if ( !mpGraphics )
591 : {
592 0 : if ( !ImplGetGraphics() )
593 : return;
594 : }
595 :
596 0 : if ( mbInitClipRegion )
597 0 : ImplInitClipRegion();
598 :
599 0 : if ( mbOutputClipped )
600 : return;
601 :
602 0 : pGraphics = mpGraphics;
603 : }
604 : else
605 : {
606 0 : pGraphics = ImplGetFrameGraphics();
607 :
608 0 : if ( nFlags & SHOWTRACK_CLIP )
609 : {
610 0 : Point aPoint( mnOutOffX, mnOutOffY );
611 : Region aRegion( Rectangle( aPoint,
612 0 : Size( mnOutWidth, mnOutHeight ) ) );
613 0 : ImplClipBoundaries( aRegion, sal_False, sal_False );
614 0 : ImplSelectClipRegion( aRegion, pGraphics );
615 : }
616 : }
617 :
618 0 : const SalPoint* pPtAry = (const SalPoint*)aPoly.GetConstPointAry();
619 0 : pGraphics->Invert( nPoints, pPtAry, SAL_INVERT_TRACKFRAME, this );
620 : }
621 :
622 : // -----------------------------------------------------------------------
623 :
624 0 : IMPL_LINK( Window, ImplTrackTimerHdl, Timer*, pTimer )
625 : {
626 0 : ImplSVData* pSVData = ImplGetSVData();
627 :
628 : // Bei Button-Repeat muessen wir den Timeout umsetzen
629 0 : if ( pSVData->maWinData.mnTrackFlags & STARTTRACK_BUTTONREPEAT )
630 0 : pTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonRepeat() );
631 :
632 : // Tracking-Event erzeugen
633 0 : Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY );
634 0 : if( ImplIsAntiparallel() )
635 : {
636 : // - RTL - re-mirror frame pos at pChild
637 0 : ImplReMirror( aMousePos );
638 : }
639 : MouseEvent aMEvt( ImplFrameToOutput( aMousePos ),
640 : mpWindowImpl->mpFrameData->mnClickCount, 0,
641 0 : mpWindowImpl->mpFrameData->mnMouseCode, mpWindowImpl->mpFrameData->mnMouseCode );
642 0 : TrackingEvent aTEvt( aMEvt, TRACKING_REPEAT );
643 0 : Tracking( aTEvt );
644 :
645 0 : return 0;
646 : }
647 :
648 : // -----------------------------------------------------------------------
649 :
650 0 : void Window::StartTracking( sal_uInt16 nFlags )
651 : {
652 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
653 :
654 0 : ImplSVData* pSVData = ImplGetSVData();
655 :
656 0 : if ( pSVData->maWinData.mpTrackWin != this )
657 : {
658 0 : if ( pSVData->maWinData.mpTrackWin )
659 0 : pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL );
660 : }
661 :
662 0 : if ( nFlags & (STARTTRACK_SCROLLREPEAT | STARTTRACK_BUTTONREPEAT) )
663 : {
664 0 : pSVData->maWinData.mpTrackTimer = new AutoTimer;
665 :
666 0 : if ( nFlags & STARTTRACK_SCROLLREPEAT )
667 0 : pSVData->maWinData.mpTrackTimer->SetTimeout( GetSettings().GetMouseSettings().GetScrollRepeat() );
668 : else
669 0 : pSVData->maWinData.mpTrackTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonStartRepeat() );
670 0 : pSVData->maWinData.mpTrackTimer->SetTimeoutHdl( LINK( this, Window, ImplTrackTimerHdl ) );
671 0 : pSVData->maWinData.mpTrackTimer->Start();
672 : }
673 :
674 0 : pSVData->maWinData.mpTrackWin = this;
675 0 : pSVData->maWinData.mnTrackFlags = nFlags;
676 0 : CaptureMouse();
677 0 : }
678 :
679 : // -----------------------------------------------------------------------
680 :
681 0 : void Window::EndTracking( sal_uInt16 nFlags )
682 : {
683 0 : ImplSVData* pSVData = ImplGetSVData();
684 :
685 0 : if ( pSVData->maWinData.mpTrackWin == this )
686 : {
687 : // due to DbgChkThis in brackets, as the window could be destroyed
688 : // in the handler
689 : {
690 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
691 :
692 0 : if ( pSVData->maWinData.mpTrackTimer )
693 : {
694 0 : delete pSVData->maWinData.mpTrackTimer;
695 0 : pSVData->maWinData.mpTrackTimer = NULL;
696 : }
697 :
698 0 : pSVData->maWinData.mpTrackWin = NULL;
699 0 : pSVData->maWinData.mnTrackFlags = 0;
700 0 : ReleaseMouse();
701 : }
702 :
703 : // call EndTracking if required
704 0 : if ( !(nFlags & ENDTRACK_DONTCALLHDL) )
705 : {
706 0 : Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY );
707 0 : if( ImplIsAntiparallel() )
708 : {
709 : // - RTL - re-mirror frame pos at pChild
710 0 : ImplReMirror( aMousePos );
711 : }
712 :
713 : MouseEvent aMEvt( ImplFrameToOutput( aMousePos ),
714 : mpWindowImpl->mpFrameData->mnClickCount, 0,
715 0 : mpWindowImpl->mpFrameData->mnMouseCode, mpWindowImpl->mpFrameData->mnMouseCode );
716 0 : TrackingEvent aTEvt( aMEvt, nFlags | ENDTRACK_END );
717 0 : Tracking( aTEvt );
718 : }
719 : }
720 0 : }
721 :
722 : // -----------------------------------------------------------------------
723 :
724 4463 : sal_Bool Window::IsTracking() const
725 : {
726 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
727 :
728 4463 : return (ImplGetSVData()->maWinData.mpTrackWin == this);
729 : }
730 :
731 : // -----------------------------------------------------------------------
732 :
733 0 : void Window::StartAutoScroll( sal_uInt16 nFlags )
734 : {
735 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
736 :
737 0 : ImplSVData* pSVData = ImplGetSVData();
738 :
739 0 : if ( pSVData->maWinData.mpAutoScrollWin != this )
740 : {
741 0 : if ( pSVData->maWinData.mpAutoScrollWin )
742 0 : pSVData->maWinData.mpAutoScrollWin->EndAutoScroll();
743 : }
744 :
745 0 : pSVData->maWinData.mpAutoScrollWin = this;
746 0 : pSVData->maWinData.mnAutoScrollFlags = nFlags;
747 0 : pSVData->maAppData.mpWheelWindow = new ImplWheelWindow( this );
748 0 : }
749 :
750 : // -----------------------------------------------------------------------
751 :
752 0 : void Window::EndAutoScroll()
753 : {
754 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
755 :
756 0 : ImplSVData* pSVData = ImplGetSVData();
757 :
758 0 : if ( pSVData->maWinData.mpAutoScrollWin == this )
759 : {
760 0 : pSVData->maWinData.mpAutoScrollWin = NULL;
761 0 : pSVData->maWinData.mnAutoScrollFlags = 0;
762 0 : pSVData->maAppData.mpWheelWindow->ImplStop();
763 0 : pSVData->maAppData.mpWheelWindow->doLazyDelete();
764 0 : pSVData->maAppData.mpWheelWindow = NULL;
765 : }
766 0 : }
767 :
768 : // -----------------------------------------------------------------------
769 :
770 0 : void Window::SaveBackground( const Point& rPos, const Size& rSize,
771 : const Point& rDestOff, VirtualDevice& rSaveDevice )
772 : {
773 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
774 :
775 0 : if ( mpWindowImpl->mpPaintRegion )
776 : {
777 0 : Region aClip( *mpWindowImpl->mpPaintRegion );
778 0 : const Point aPixPos( LogicToPixel( rPos ) );
779 :
780 0 : aClip.Move( -mnOutOffX, -mnOutOffY );
781 0 : aClip.Intersect( Rectangle( aPixPos, LogicToPixel( rSize ) ) );
782 :
783 0 : if ( !aClip.IsEmpty() )
784 : {
785 0 : const Region aOldClip( rSaveDevice.GetClipRegion() );
786 0 : const Point aPixOffset( rSaveDevice.LogicToPixel( rDestOff ) );
787 0 : const sal_Bool bMap = rSaveDevice.IsMapModeEnabled();
788 :
789 : // move clip region to have the same distance to DestOffset
790 0 : aClip.Move( aPixOffset.X() - aPixPos.X(), aPixOffset.Y() - aPixPos.Y() );
791 :
792 : // set pixel clip region
793 0 : rSaveDevice.EnableMapMode( sal_False );
794 0 : rSaveDevice.SetClipRegion( aClip );
795 0 : rSaveDevice.EnableMapMode( bMap );
796 0 : rSaveDevice.DrawOutDev( rDestOff, rSize, rPos, rSize, *this );
797 0 : rSaveDevice.SetClipRegion( aOldClip );
798 0 : }
799 : }
800 : else
801 0 : rSaveDevice.DrawOutDev( rDestOff, rSize, rPos, rSize, *this );
802 0 : }
803 :
804 : // -----------------------------------------------------------------------
805 :
806 0 : sal_uIntPtr Window::SaveFocus()
807 : {
808 0 : ImplSVData* pSVData = ImplGetSVData();
809 0 : if ( pSVData->maWinData.mpFocusWin )
810 : {
811 0 : ImplFocusDelData* pDelData = new ImplFocusDelData;
812 0 : pSVData->maWinData.mpFocusWin->ImplAddDel( pDelData );
813 0 : pDelData->mpFocusWin = pSVData->maWinData.mpFocusWin;
814 0 : return (sal_uIntPtr)(void*)pDelData;
815 : }
816 : else
817 0 : return 0;
818 : }
819 :
820 : // -----------------------------------------------------------------------
821 :
822 0 : sal_Bool Window::EndSaveFocus( sal_uIntPtr nSaveId, sal_Bool bRestore )
823 : {
824 0 : if ( !nSaveId )
825 0 : return sal_False;
826 : else
827 : {
828 0 : sal_Bool bOK = sal_True;
829 0 : ImplFocusDelData* pDelData = (ImplFocusDelData*)(void*)nSaveId;
830 0 : if ( !pDelData->IsDead() )
831 : {
832 0 : pDelData->mpFocusWin->ImplRemoveDel( pDelData );
833 0 : if ( bRestore )
834 0 : pDelData->mpFocusWin->GrabFocus();
835 : }
836 : else
837 0 : bOK = !bRestore;
838 0 : delete pDelData;
839 0 : return bOK;
840 : }
841 : }
842 :
843 : // -----------------------------------------------------------------------
844 :
845 0 : void Window::SetZoom( const Fraction& rZoom )
846 : {
847 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
848 :
849 0 : if ( mpWindowImpl->maZoom != rZoom )
850 : {
851 0 : mpWindowImpl->maZoom = rZoom;
852 0 : StateChanged( STATE_CHANGE_ZOOM );
853 : }
854 0 : }
855 :
856 : // -----------------------------------------------------------------------
857 :
858 0 : inline long WinFloatRound( double fVal )
859 : {
860 0 : return( fVal > 0.0 ? (long) ( fVal + 0.5 ) : -(long) ( -fVal + 0.5 ) );
861 : }
862 :
863 : // -----------------------------------------------------------------------
864 :
865 3635 : void Window::SetZoomedPointFont( const Font& rFont )
866 : {
867 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
868 :
869 3635 : const Fraction& rZoom = GetZoom();
870 3635 : if ( rZoom.GetNumerator() != rZoom.GetDenominator() )
871 : {
872 0 : Font aFont( rFont );
873 0 : Size aSize = aFont.GetSize();
874 0 : double n = (double)aSize.Width();
875 0 : n *= (double)rZoom.GetNumerator();
876 0 : n /= (double)rZoom.GetDenominator();
877 0 : aSize.Width() = WinFloatRound( n );
878 0 : n = (double)aSize.Height();
879 0 : n *= (double)rZoom.GetNumerator();
880 0 : n /= (double)rZoom.GetDenominator();
881 0 : aSize.Height() = WinFloatRound( n );
882 0 : aFont.SetSize( aSize );
883 0 : SetPointFont( aFont );
884 :
885 : // Use another font if the representation is to be scaled,
886 : // and the actual font is not scalable
887 0 : FontMetric aMetric = GetFontMetric();
888 0 : long nFontDiff = Abs( GetFont().GetSize().Height()-aMetric.GetSize().Height() );
889 0 : if ( (aMetric.GetType() == TYPE_RASTER) && (nFontDiff >= 2) )
890 : {
891 : sal_uInt16 nType;
892 0 : if ( aMetric.GetPitch() == PITCH_FIXED )
893 0 : nType = DEFAULTFONT_FIXED;
894 : else
895 0 : nType = DEFAULTFONT_UI_SANS;
896 0 : Font aTempFont = GetDefaultFont( nType, GetSettings().GetLanguageTag().getLanguageType(), 0 );
897 0 : aFont.SetName( aTempFont.GetName() );
898 0 : SetPointFont( aFont );
899 0 : }
900 : }
901 : else
902 3635 : SetPointFont( rFont );
903 3635 : }
904 :
905 : // -----------------------------------------------------------------------
906 :
907 1690 : long Window::CalcZoom( long nCalc ) const
908 : {
909 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
910 :
911 1690 : const Fraction& rZoom = GetZoom();
912 1690 : if ( rZoom.GetNumerator() != rZoom.GetDenominator() )
913 : {
914 0 : double n = (double)nCalc;
915 0 : n *= (double)rZoom.GetNumerator();
916 0 : n /= (double)rZoom.GetDenominator();
917 0 : nCalc = WinFloatRound( n );
918 : }
919 1690 : return nCalc;
920 : }
921 :
922 : // -----------------------------------------------------------------------
923 :
924 0 : void Window::SetControlFont()
925 : {
926 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
927 :
928 0 : if ( mpWindowImpl->mpControlFont )
929 : {
930 0 : delete mpWindowImpl->mpControlFont;
931 0 : mpWindowImpl->mpControlFont = NULL;
932 0 : StateChanged( STATE_CHANGE_CONTROLFONT );
933 : }
934 0 : }
935 :
936 : // -----------------------------------------------------------------------
937 :
938 28 : void Window::SetControlFont( const Font& rFont )
939 : {
940 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
941 :
942 28 : if ( rFont == Font() )
943 : {
944 0 : SetControlFont();
945 0 : return;
946 : }
947 :
948 28 : if ( mpWindowImpl->mpControlFont )
949 : {
950 16 : if ( *mpWindowImpl->mpControlFont == rFont )
951 16 : return;
952 0 : *mpWindowImpl->mpControlFont = rFont;
953 : }
954 : else
955 12 : mpWindowImpl->mpControlFont = new Font( rFont );
956 :
957 12 : StateChanged( STATE_CHANGE_CONTROLFONT );
958 : }
959 :
960 : // -----------------------------------------------------------------------
961 :
962 24 : Font Window::GetControlFont() const
963 : {
964 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
965 :
966 24 : if ( mpWindowImpl->mpControlFont )
967 24 : return *mpWindowImpl->mpControlFont;
968 : else
969 : {
970 0 : Font aFont;
971 0 : return aFont;
972 : }
973 : }
974 :
975 : // -----------------------------------------------------------------------
976 :
977 0 : void Window::SetControlForeground()
978 : {
979 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
980 :
981 0 : if ( mpWindowImpl->mbControlForeground )
982 : {
983 0 : mpWindowImpl->maControlForeground = Color( COL_TRANSPARENT );
984 0 : mpWindowImpl->mbControlForeground = sal_False;
985 0 : StateChanged( STATE_CHANGE_CONTROLFOREGROUND );
986 : }
987 0 : }
988 :
989 : // -----------------------------------------------------------------------
990 :
991 0 : void Window::SetControlForeground( const Color& rColor )
992 : {
993 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
994 :
995 0 : if ( rColor.GetTransparency() )
996 : {
997 0 : if ( mpWindowImpl->mbControlForeground )
998 : {
999 0 : mpWindowImpl->maControlForeground = Color( COL_TRANSPARENT );
1000 0 : mpWindowImpl->mbControlForeground = sal_False;
1001 0 : StateChanged( STATE_CHANGE_CONTROLFOREGROUND );
1002 : }
1003 : }
1004 : else
1005 : {
1006 0 : if ( mpWindowImpl->maControlForeground != rColor )
1007 : {
1008 0 : mpWindowImpl->maControlForeground = rColor;
1009 0 : mpWindowImpl->mbControlForeground = sal_True;
1010 0 : StateChanged( STATE_CHANGE_CONTROLFOREGROUND );
1011 : }
1012 : }
1013 0 : }
1014 :
1015 : // -----------------------------------------------------------------------
1016 :
1017 0 : void Window::SetControlBackground()
1018 : {
1019 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1020 :
1021 0 : if ( mpWindowImpl->mbControlBackground )
1022 : {
1023 0 : mpWindowImpl->maControlBackground = Color( COL_TRANSPARENT );
1024 0 : mpWindowImpl->mbControlBackground = sal_False;
1025 0 : StateChanged( STATE_CHANGE_CONTROLBACKGROUND );
1026 : }
1027 0 : }
1028 :
1029 : // -----------------------------------------------------------------------
1030 :
1031 252 : void Window::SetControlBackground( const Color& rColor )
1032 : {
1033 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1034 :
1035 252 : if ( rColor.GetTransparency() )
1036 : {
1037 0 : if ( mpWindowImpl->mbControlBackground )
1038 : {
1039 0 : mpWindowImpl->maControlBackground = Color( COL_TRANSPARENT );
1040 0 : mpWindowImpl->mbControlBackground = sal_False;
1041 0 : StateChanged( STATE_CHANGE_CONTROLBACKGROUND );
1042 : }
1043 : }
1044 : else
1045 : {
1046 252 : if ( mpWindowImpl->maControlBackground != rColor )
1047 : {
1048 252 : mpWindowImpl->maControlBackground = rColor;
1049 252 : mpWindowImpl->mbControlBackground = sal_True;
1050 252 : StateChanged( STATE_CHANGE_CONTROLBACKGROUND );
1051 : }
1052 : }
1053 252 : }
1054 :
1055 : // -----------------------------------------------------------------------
1056 :
1057 0 : Size Window::CalcWindowSize( const Size& rOutSz ) const
1058 : {
1059 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1060 :
1061 0 : Size aSz = rOutSz;
1062 0 : aSz.Width() += mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder;
1063 0 : aSz.Height() += mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder;
1064 0 : return aSz;
1065 : }
1066 :
1067 : // -----------------------------------------------------------------------
1068 :
1069 0 : Size Window::CalcOutputSize( const Size& rWinSz ) const
1070 : {
1071 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1072 :
1073 0 : Size aSz = rWinSz;
1074 0 : aSz.Width() -= mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder;
1075 0 : aSz.Height() -= mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder;
1076 0 : return aSz;
1077 : }
1078 :
1079 : // -----------------------------------------------------------------------
1080 :
1081 0 : Font Window::GetDrawPixelFont( OutputDevice* pDev ) const
1082 : {
1083 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1084 :
1085 0 : Font aFont = GetPointFont();
1086 0 : Size aFontSize = aFont.GetSize();
1087 0 : MapMode aPtMapMode( MAP_POINT );
1088 0 : aFontSize = pDev->LogicToPixel( aFontSize, aPtMapMode );
1089 0 : aFont.SetSize( aFontSize );
1090 0 : return aFont;
1091 : }
1092 :
1093 : // -----------------------------------------------------------------------
1094 :
1095 0 : long Window::GetDrawPixel( OutputDevice* pDev, long nPixels ) const
1096 : {
1097 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1098 :
1099 0 : long nP = nPixels;
1100 0 : if ( pDev->GetOutDevType() != OUTDEV_WINDOW )
1101 : {
1102 0 : MapMode aMap( MAP_100TH_MM );
1103 0 : Size aSz( nP, 0 );
1104 0 : aSz = PixelToLogic( aSz, aMap );
1105 0 : aSz = pDev->LogicToPixel( aSz, aMap );
1106 0 : nP = aSz.Width();
1107 : }
1108 0 : return nP;
1109 : }
1110 :
1111 : // -----------------------------------------------------------------------
1112 :
1113 0 : sal_Bool Window::HandleScrollCommand( const CommandEvent& rCmd,
1114 : ScrollBar* pHScrl, ScrollBar* pVScrl )
1115 : {
1116 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1117 :
1118 0 : sal_Bool bRet = sal_False;
1119 :
1120 0 : if ( pHScrl || pVScrl )
1121 : {
1122 0 : switch( rCmd.GetCommand() )
1123 : {
1124 : case COMMAND_STARTAUTOSCROLL:
1125 : {
1126 0 : sal_uInt16 nFlags = 0;
1127 0 : if ( pHScrl )
1128 : {
1129 0 : if ( (pHScrl->GetVisibleSize() < pHScrl->GetRangeMax()) &&
1130 0 : pHScrl->IsEnabled() && pHScrl->IsInputEnabled() && ! pHScrl->IsInModalMode() )
1131 0 : nFlags |= AUTOSCROLL_HORZ;
1132 : }
1133 0 : if ( pVScrl )
1134 : {
1135 0 : if ( (pVScrl->GetVisibleSize() < pVScrl->GetRangeMax()) &&
1136 0 : pVScrl->IsEnabled() && pVScrl->IsInputEnabled() && ! pVScrl->IsInModalMode() )
1137 0 : nFlags |= AUTOSCROLL_VERT;
1138 : }
1139 :
1140 0 : if ( nFlags )
1141 : {
1142 0 : StartAutoScroll( nFlags );
1143 0 : bRet = sal_True;
1144 : }
1145 : }
1146 0 : break;
1147 :
1148 : case COMMAND_WHEEL:
1149 : {
1150 0 : const CommandWheelData* pData = rCmd.GetWheelData();
1151 :
1152 0 : if ( pData && (COMMAND_WHEEL_SCROLL == pData->GetMode()) )
1153 : {
1154 0 : sal_uLong nScrollLines = pData->GetScrollLines();
1155 : long nLines;
1156 0 : if ( nScrollLines == COMMAND_WHEEL_PAGESCROLL )
1157 : {
1158 0 : if ( pData->GetDelta() < 0 )
1159 0 : nLines = -LONG_MAX;
1160 : else
1161 0 : nLines = LONG_MAX;
1162 : }
1163 : else
1164 0 : nLines = pData->GetNotchDelta() * (long)nScrollLines;
1165 0 : if ( nLines )
1166 : {
1167 : ImplHandleScroll( NULL,
1168 : 0L,
1169 0 : pData->IsHorz() ? pHScrl : pVScrl,
1170 0 : nLines );
1171 0 : bRet = sal_True;
1172 : }
1173 : }
1174 : }
1175 0 : break;
1176 :
1177 : case COMMAND_AUTOSCROLL:
1178 : {
1179 0 : const CommandScrollData* pData = rCmd.GetAutoScrollData();
1180 0 : if ( pData && (pData->GetDeltaX() || pData->GetDeltaY()) )
1181 : {
1182 : ImplHandleScroll( pHScrl, pData->GetDeltaX(),
1183 0 : pVScrl, pData->GetDeltaY() );
1184 0 : bRet = sal_True;
1185 : }
1186 : }
1187 0 : break;
1188 :
1189 : default:
1190 0 : break;
1191 : }
1192 : }
1193 :
1194 0 : return bRet;
1195 : }
1196 :
1197 : // -----------------------------------------------------------------------
1198 :
1199 0 : void Window::ImplHandleScroll( ScrollBar* pHScrl, long nX,
1200 : ScrollBar* pVScrl, long nY )
1201 : {
1202 0 : if ( pHScrl && nX && pHScrl->IsEnabled() && pHScrl->IsInputEnabled() && ! pHScrl->IsInModalMode() )
1203 : {
1204 0 : long nNewPos = pHScrl->GetThumbPos();
1205 :
1206 0 : if ( nX == -LONG_MAX )
1207 0 : nNewPos += pHScrl->GetPageSize();
1208 0 : else if ( nX == LONG_MAX )
1209 0 : nNewPos -= pHScrl->GetPageSize();
1210 : else
1211 : {
1212 0 : const double fVal = (double)nNewPos - ((double)nX * pHScrl->GetLineSize());
1213 :
1214 0 : if ( fVal < LONG_MIN )
1215 0 : nNewPos = LONG_MIN;
1216 0 : else if ( fVal > LONG_MAX )
1217 0 : nNewPos = LONG_MAX;
1218 : else
1219 0 : nNewPos = (long)fVal;
1220 : }
1221 :
1222 0 : pHScrl->DoScroll( nNewPos );
1223 : }
1224 :
1225 0 : if ( pVScrl && nY && pVScrl->IsEnabled() && pVScrl->IsInputEnabled() && ! pVScrl->IsInModalMode() )
1226 : {
1227 0 : long nNewPos = pVScrl->GetThumbPos();
1228 :
1229 0 : if ( nY == -LONG_MAX )
1230 0 : nNewPos += pVScrl->GetPageSize();
1231 0 : else if ( nY == LONG_MAX )
1232 0 : nNewPos -= pVScrl->GetPageSize();
1233 : else
1234 : {
1235 0 : const double fVal = (double)nNewPos - ((double)nY * pVScrl->GetLineSize());
1236 :
1237 0 : if ( fVal < LONG_MIN )
1238 0 : nNewPos = LONG_MIN;
1239 0 : else if ( fVal > LONG_MAX )
1240 0 : nNewPos = LONG_MAX;
1241 : else
1242 0 : nNewPos = (long)fVal;
1243 : }
1244 :
1245 0 : pVScrl->DoScroll( nNewPos );
1246 : }
1247 0 : }
1248 :
1249 22065 : DockingManager* Window::GetDockingManager()
1250 : {
1251 22065 : return ImplGetDockingManager();
1252 : }
1253 :
1254 731 : void Window::EnableDocking( sal_Bool bEnable )
1255 : {
1256 : // update list of dockable windows
1257 731 : if( bEnable )
1258 731 : ImplGetDockingManager()->AddWindow( this );
1259 : else
1260 0 : ImplGetDockingManager()->RemoveWindow( this );
1261 731 : }
1262 :
1263 :
1264 : // retrieves the list of owner draw decorated windows for this window hiearchy
1265 0 : ::std::vector<Window *>& Window::ImplGetOwnerDrawList()
1266 : {
1267 0 : return ImplGetTopmostFrameWindow()->mpWindowImpl->mpFrameData->maOwnerDrawList;
1268 : }
1269 :
1270 0 : Window* Window::ImplGetTopmostFrameWindow()
1271 : {
1272 0 : Window *pTopmostParent = this;
1273 0 : while( pTopmostParent->ImplGetParent() )
1274 0 : pTopmostParent = pTopmostParent->ImplGetParent();
1275 0 : return pTopmostParent->mpWindowImpl->mpFrameWindow;
1276 : }
1277 :
1278 2403 : void Window::SetHelpId( const OString& rHelpId )
1279 : {
1280 2403 : mpWindowImpl->maHelpId = rHelpId;
1281 2403 : }
1282 :
1283 3738 : const OString& Window::GetHelpId() const
1284 : {
1285 3738 : return mpWindowImpl->maHelpId;
1286 : }
1287 :
1288 244 : void Window::SetUniqueId( const OString& rUniqueId )
1289 : {
1290 244 : mpWindowImpl->maUniqId = rUniqueId;
1291 244 : }
1292 :
1293 0 : const OString& Window::GetUniqueId() const
1294 : {
1295 0 : return mpWindowImpl->maUniqId;
1296 : }
1297 :
1298 : // --------- old inline methods ---------------
1299 :
1300 28700 : Window* Window::ImplGetWindow()
1301 : {
1302 28700 : if ( mpWindowImpl->mpClientWindow )
1303 26220 : return mpWindowImpl->mpClientWindow;
1304 : else
1305 2480 : return this;
1306 : }
1307 :
1308 0 : ImplFrameData* Window::ImplGetFrameData()
1309 : {
1310 0 : return mpWindowImpl->mpFrameData;
1311 : }
1312 :
1313 3563 : SalFrame* Window::ImplGetFrame() const
1314 : {
1315 3563 : return mpWindowImpl->mpFrame;
1316 : }
1317 :
1318 155904 : Window* Window::ImplGetParent() const
1319 : {
1320 155904 : return mpWindowImpl->mpParent;
1321 : }
1322 :
1323 2377 : Window* Window::ImplGetClientWindow() const
1324 : {
1325 2377 : return mpWindowImpl->mpClientWindow;
1326 : }
1327 :
1328 273 : Window* Window::ImplGetBorderWindow() const
1329 : {
1330 273 : return mpWindowImpl->mpBorderWindow;
1331 : }
1332 :
1333 6351 : Window* Window::ImplGetFirstOverlapWindow()
1334 : {
1335 6351 : if ( mpWindowImpl->mbOverlapWin )
1336 67 : return this;
1337 : else
1338 6284 : return mpWindowImpl->mpOverlapWindow;
1339 : }
1340 :
1341 0 : const Window* Window::ImplGetFirstOverlapWindow() const
1342 : {
1343 0 : if ( mpWindowImpl->mbOverlapWin )
1344 0 : return this;
1345 : else
1346 0 : return mpWindowImpl->mpOverlapWindow;
1347 : }
1348 :
1349 410 : Window* Window::ImplGetFrameWindow() const
1350 : {
1351 410 : return mpWindowImpl->mpFrameWindow;
1352 : }
1353 :
1354 0 : sal_Bool Window::ImplIsDockingWindow() const
1355 : {
1356 0 : return mpWindowImpl->mbDockWin;
1357 : }
1358 :
1359 0 : sal_Bool Window::ImplIsFloatingWindow() const
1360 : {
1361 0 : return mpWindowImpl->mbFloatWin;
1362 : }
1363 :
1364 0 : sal_Bool Window::ImplIsSplitter() const
1365 : {
1366 0 : return mpWindowImpl->mbSplitter;
1367 : }
1368 :
1369 32 : sal_Bool Window::ImplIsPushButton() const
1370 : {
1371 32 : return mpWindowImpl->mbPushButton;
1372 : }
1373 :
1374 225648 : sal_Bool Window::ImplIsOverlapWindow() const
1375 : {
1376 225648 : return mpWindowImpl->mbOverlapWin;
1377 : }
1378 :
1379 0 : void Window::ImplSetMouseTransparent( sal_Bool bTransparent )
1380 : {
1381 0 : mpWindowImpl->mbMouseTransparent = bTransparent;
1382 0 : }
1383 :
1384 0 : Point Window::ImplOutputToFrame( const Point& rPos )
1385 : {
1386 0 : return Point( rPos.X()+mnOutOffX, rPos.Y()+mnOutOffY );
1387 : }
1388 :
1389 1002 : Point Window::ImplFrameToOutput( const Point& rPos )
1390 : {
1391 1002 : return Point( rPos.X()-mnOutOffX, rPos.Y()-mnOutOffY );
1392 : }
1393 :
1394 0 : void Window::SetCompoundControl( sal_Bool bCompound )
1395 : {
1396 0 : mpWindowImpl->mbCompoundControl = bCompound;
1397 0 : }
1398 :
1399 0 : void Window::IncrementLockCount()
1400 : {
1401 0 : mpWindowImpl->mnLockCount++;
1402 0 : }
1403 :
1404 0 : void Window::DecrementLockCount()
1405 : {
1406 0 : mpWindowImpl->mnLockCount--;
1407 0 : }
1408 :
1409 92024 : WinBits Window::GetStyle() const
1410 : {
1411 92024 : return mpWindowImpl->mnStyle;
1412 : }
1413 :
1414 944 : WinBits Window::GetPrevStyle() const
1415 : {
1416 944 : return mpWindowImpl->mnPrevStyle;
1417 : }
1418 :
1419 0 : WinBits Window::GetExtendedStyle() const
1420 : {
1421 0 : return mpWindowImpl->mnExtendedStyle;
1422 : }
1423 :
1424 708 : void Window::SetType( WindowType nType )
1425 : {
1426 708 : mpWindowImpl->mnType = nType;
1427 708 : }
1428 :
1429 224741 : WindowType Window::GetType() const
1430 : {
1431 224741 : return mpWindowImpl->mnType;
1432 : }
1433 :
1434 0 : Dialog* Window::GetParentDialog() const
1435 : {
1436 0 : const Window *pWindow = this;
1437 :
1438 0 : while( pWindow )
1439 : {
1440 0 : if( pWindow->IsDialog() )
1441 0 : break;
1442 :
1443 0 : pWindow = pWindow->GetParent();
1444 : }
1445 :
1446 0 : return const_cast<Dialog *>(dynamic_cast<const Dialog*>(pWindow));
1447 : }
1448 :
1449 7356 : sal_Bool Window::IsSystemWindow() const
1450 : {
1451 7356 : return mpWindowImpl->mbSysWin;
1452 : }
1453 :
1454 43557 : sal_Bool Window::IsDialog() const
1455 : {
1456 43557 : return mpWindowImpl->mbDialog;
1457 : }
1458 :
1459 0 : sal_Bool Window::IsMenuFloatingWindow() const
1460 : {
1461 0 : return mpWindowImpl->mbMenuFloatingWindow;
1462 : }
1463 :
1464 0 : sal_Bool Window::IsToolbarFloatingWindow() const
1465 : {
1466 0 : return mpWindowImpl->mbToolbarFloatingWindow;
1467 : }
1468 :
1469 1514 : void Window::EnableAllResize( sal_Bool bEnable )
1470 : {
1471 1514 : mpWindowImpl->mbAllResize = bEnable;
1472 1514 : }
1473 :
1474 1448 : void Window::EnableChildTransparentMode( sal_Bool bEnable )
1475 : {
1476 1448 : mpWindowImpl->mbChildTransparent = bEnable;
1477 1448 : }
1478 :
1479 36 : sal_Bool Window::IsChildTransparentModeEnabled() const
1480 : {
1481 36 : return mpWindowImpl->mbChildTransparent;
1482 : }
1483 :
1484 0 : sal_Bool Window::IsMouseTransparent() const
1485 : {
1486 0 : return mpWindowImpl->mbMouseTransparent;
1487 : }
1488 :
1489 34658 : sal_Bool Window::IsPaintTransparent() const
1490 : {
1491 34658 : return mpWindowImpl->mbPaintTransparent;
1492 : }
1493 :
1494 0 : void Window::SetDialogControlStart( sal_Bool bStart )
1495 : {
1496 0 : mpWindowImpl->mbDlgCtrlStart = bStart;
1497 0 : }
1498 :
1499 32 : sal_Bool Window::IsDialogControlStart() const
1500 : {
1501 32 : return mpWindowImpl->mbDlgCtrlStart;
1502 : }
1503 :
1504 236 : void Window::SetDialogControlFlags( sal_uInt16 nFlags )
1505 : {
1506 236 : mpWindowImpl->mnDlgCtrlFlags = nFlags;
1507 236 : }
1508 :
1509 404 : sal_uInt16 Window::GetDialogControlFlags() const
1510 : {
1511 404 : return mpWindowImpl->mnDlgCtrlFlags;
1512 : }
1513 :
1514 785 : const InputContext& Window::GetInputContext() const
1515 : {
1516 785 : return mpWindowImpl->maInputContext;
1517 : }
1518 :
1519 3635 : sal_Bool Window::IsControlFont() const
1520 : {
1521 3635 : return (mpWindowImpl->mpControlFont != 0);
1522 : }
1523 :
1524 0 : Color Window::GetControlForeground() const
1525 : {
1526 0 : return mpWindowImpl->maControlForeground;
1527 : }
1528 :
1529 4906 : sal_Bool Window::IsControlForeground() const
1530 : {
1531 4906 : return mpWindowImpl->mbControlForeground;
1532 : }
1533 :
1534 90 : Color Window::GetControlBackground() const
1535 : {
1536 90 : return mpWindowImpl->maControlBackground;
1537 : }
1538 :
1539 9502 : sal_Bool Window::IsControlBackground() const
1540 : {
1541 9502 : return mpWindowImpl->mbControlBackground;
1542 : }
1543 :
1544 2451 : sal_Bool Window::IsInPaint() const
1545 : {
1546 2451 : return mpWindowImpl->mbInPaint;
1547 : }
1548 :
1549 340271 : Window* Window::GetParent() const
1550 : {
1551 340271 : return mpWindowImpl->mpRealParent;
1552 : }
1553 :
1554 45415 : sal_Bool Window::IsVisible() const
1555 : {
1556 45415 : return mpWindowImpl->mbVisible;
1557 : }
1558 :
1559 105830 : sal_Bool Window::IsReallyVisible() const
1560 : {
1561 105830 : return mpWindowImpl->mbReallyVisible;
1562 : }
1563 :
1564 6550 : sal_Bool Window::IsReallyShown() const
1565 : {
1566 6550 : return mpWindowImpl->mbReallyShown;
1567 : }
1568 :
1569 0 : sal_Bool Window::IsInInitShow() const
1570 : {
1571 0 : return mpWindowImpl->mbInInitShow;
1572 : }
1573 :
1574 4557 : sal_Bool Window::IsEnabled() const
1575 : {
1576 4557 : return !mpWindowImpl->mbDisabled;
1577 : }
1578 :
1579 1139 : sal_Bool Window::IsInputEnabled() const
1580 : {
1581 1139 : return !mpWindowImpl->mbInputDisabled;
1582 : }
1583 :
1584 0 : sal_Bool Window::IsAlwaysEnableInput() const
1585 : {
1586 0 : return mpWindowImpl->meAlwaysInputMode == AlwaysInputEnabled;
1587 : }
1588 :
1589 365 : sal_uInt16 Window::GetActivateMode() const
1590 : {
1591 365 : return mpWindowImpl->mnActivateMode;
1592 :
1593 : }
1594 :
1595 0 : sal_Bool Window::IsAlwaysOnTopEnabled() const
1596 : {
1597 0 : return mpWindowImpl->mbAlwaysOnTop;
1598 : }
1599 :
1600 0 : sal_Bool Window::IsDefaultPos() const
1601 : {
1602 0 : return mpWindowImpl->mbDefPos;
1603 : }
1604 :
1605 0 : sal_Bool Window::IsDefaultSize() const
1606 : {
1607 0 : return mpWindowImpl->mbDefSize;
1608 : }
1609 :
1610 1288 : void Window::EnablePaint( sal_Bool bEnable )
1611 : {
1612 1288 : mpWindowImpl->mbPaintDisabled = !bEnable;
1613 1288 : }
1614 :
1615 4394 : sal_Bool Window::IsPaintEnabled() const
1616 : {
1617 4394 : return !mpWindowImpl->mbPaintDisabled;
1618 : }
1619 :
1620 2922 : sal_Bool Window::IsUpdateMode() const
1621 : {
1622 2922 : return !mpWindowImpl->mbNoUpdate;
1623 : }
1624 :
1625 0 : void Window::SetParentUpdateMode( sal_Bool bUpdate )
1626 : {
1627 0 : mpWindowImpl->mbNoParentUpdate = !bUpdate;
1628 0 : }
1629 :
1630 2053 : sal_Bool Window::IsActive() const
1631 : {
1632 2053 : return mpWindowImpl->mbActive;
1633 : }
1634 :
1635 142 : sal_uInt16 Window::GetGetFocusFlags() const
1636 : {
1637 142 : return mpWindowImpl->mnGetFocusFlags;
1638 : }
1639 :
1640 1332 : sal_Bool Window::IsCompoundControl() const
1641 : {
1642 1332 : return mpWindowImpl->mbCompoundControl;
1643 : }
1644 :
1645 0 : sal_Bool Window::IsWait() const
1646 : {
1647 0 : return (mpWindowImpl->mnWaitCount != 0);
1648 : }
1649 :
1650 204 : Cursor* Window::GetCursor() const
1651 : {
1652 204 : return mpWindowImpl->mpCursor;
1653 : }
1654 :
1655 5325 : const Fraction& Window::GetZoom() const
1656 : {
1657 5325 : return mpWindowImpl->maZoom;
1658 : }
1659 :
1660 0 : sal_Bool Window::IsZoom() const
1661 : {
1662 0 : return mpWindowImpl->maZoom.GetNumerator() != mpWindowImpl->maZoom.GetDenominator();
1663 : }
1664 :
1665 0 : void Window::SetHelpText( const XubString& rHelpText )
1666 : {
1667 0 : mpWindowImpl->maHelpText = rHelpText;
1668 0 : mpWindowImpl->mbHelpTextDynamic = sal_True;
1669 0 : }
1670 :
1671 720 : void Window::SetQuickHelpText( const XubString& rHelpText )
1672 : {
1673 720 : mpWindowImpl->maQuickHelpText = rHelpText;
1674 720 : }
1675 :
1676 0 : const XubString& Window::GetQuickHelpText() const
1677 : {
1678 0 : return mpWindowImpl->maQuickHelpText;
1679 : }
1680 :
1681 0 : void Window::SetData( void* pNewData )
1682 : {
1683 0 : mpWindowImpl->mpUserData = pNewData;
1684 0 : }
1685 :
1686 0 : void* Window::GetData() const
1687 : {
1688 0 : return mpWindowImpl->mpUserData;
1689 : }
1690 :
1691 784 : sal_Bool Window::IsCreatedWithToolkit() const
1692 : {
1693 784 : return mpWindowImpl->mbCreatedWithToolkit;
1694 : }
1695 :
1696 2160 : void Window::SetCreatedWithToolkit( sal_Bool b )
1697 : {
1698 2160 : mpWindowImpl->mbCreatedWithToolkit = b;
1699 :
1700 2160 : }
1701 0 : const Pointer& Window::GetPointer() const
1702 : {
1703 0 : return mpWindowImpl->maPointer;
1704 : }
1705 :
1706 16118 : VCLXWindow* Window::GetWindowPeer() const
1707 : {
1708 16118 : return mpWindowImpl->mpVCLXWindow;
1709 : }
1710 :
1711 6 : void Window::SetPosPixel( const Point& rNewPos )
1712 : {
1713 6 : setPosSizePixel( rNewPos.X(), rNewPos.Y(), 0, 0, WINDOW_POSSIZE_POS );
1714 6 : }
1715 :
1716 5052 : void Window::SetSizePixel( const Size& rNewSize )
1717 : {
1718 : setPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(),
1719 5052 : WINDOW_POSSIZE_SIZE );
1720 5052 : }
1721 :
1722 9914 : void Window::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
1723 : {
1724 : setPosSizePixel( rNewPos.X(), rNewPos.Y(),
1725 : rNewSize.Width(), rNewSize.Height(),
1726 9914 : WINDOW_POSSIZE_POSSIZE );
1727 9914 : }
1728 :
1729 2610 : void Window::SetOutputSizePixel( const Size& rNewSize )
1730 : {
1731 2610 : SetSizePixel( Size( rNewSize.Width()+mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder,
1732 5220 : rNewSize.Height()+mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder ) );
1733 2610 : }
1734 :
1735 : //When a widget wants to renegotiate layout, get toplevel parent dialog and call
1736 : //resize on it. Mark all intermediate containers (or container-alike) widgets
1737 : //as dirty for the size remains unchanged, but layout changed circumstances
1738 11562 : void Window::queue_resize()
1739 : {
1740 11562 : bool bSomeoneCares = false;
1741 :
1742 11562 : Dialog *pDialog = NULL;
1743 :
1744 11562 : Window *pWindow = this;
1745 :
1746 66052 : while( pWindow )
1747 : {
1748 42928 : if (isContainerWindow(*pWindow))
1749 : {
1750 0 : VclContainer *pContainer = static_cast<VclContainer*>(pWindow);
1751 0 : pContainer->markLayoutDirty();
1752 0 : bSomeoneCares = true;
1753 : }
1754 42928 : else if (pWindow->GetType() == WINDOW_TABCONTROL)
1755 : {
1756 0 : TabControl *pTabControl = static_cast<TabControl*>(pWindow);
1757 0 : pTabControl->markLayoutDirty();
1758 : }
1759 42928 : else if (pWindow->IsDialog())
1760 : {
1761 0 : pDialog = dynamic_cast<Dialog*>(pWindow);
1762 0 : break;
1763 : }
1764 42928 : pWindow = pWindow->GetParent();
1765 : }
1766 :
1767 11562 : if (bSomeoneCares)
1768 : {
1769 : //fdo#57090 force a resync of the borders of the borderwindow onto this
1770 : //window in case they have changed
1771 0 : Window* pBorderWindow = ImplGetBorderWindow();
1772 0 : if (pBorderWindow)
1773 0 : pBorderWindow->Resize();
1774 : }
1775 :
1776 11562 : if (!pDialog || pDialog == this)
1777 23124 : return;
1778 0 : pDialog->queue_layout();
1779 : }
1780 :
1781 : namespace
1782 : {
1783 0 : VclAlign toAlign(const OString &rValue)
1784 : {
1785 0 : VclAlign eRet = VCL_ALIGN_FILL;
1786 :
1787 0 : if (rValue.equalsL(RTL_CONSTASCII_STRINGPARAM("fill")))
1788 0 : eRet = VCL_ALIGN_FILL;
1789 0 : else if (rValue.equalsL(RTL_CONSTASCII_STRINGPARAM("start")))
1790 0 : eRet = VCL_ALIGN_START;
1791 0 : else if (rValue.equalsL(RTL_CONSTASCII_STRINGPARAM("end")))
1792 0 : eRet = VCL_ALIGN_END;
1793 0 : else if (rValue.equalsL(RTL_CONSTASCII_STRINGPARAM("center")))
1794 0 : eRet = VCL_ALIGN_CENTER;
1795 0 : return eRet;
1796 : }
1797 : }
1798 :
1799 0 : bool Window::set_font_attribute(const OString &rKey, const OString &rValue)
1800 : {
1801 0 : if (rKey == "weight")
1802 : {
1803 0 : Font aFont(GetControlFont());
1804 0 : if (rValue == "thin")
1805 0 : aFont.SetWeight(WEIGHT_THIN);
1806 0 : else if (rValue == "ultralight")
1807 0 : aFont.SetWeight(WEIGHT_ULTRALIGHT);
1808 0 : else if (rValue == "light")
1809 0 : aFont.SetWeight(WEIGHT_LIGHT);
1810 0 : else if (rValue == "book")
1811 0 : aFont.SetWeight(WEIGHT_SEMILIGHT);
1812 0 : else if (rValue == "normal")
1813 0 : aFont.SetWeight(WEIGHT_NORMAL);
1814 0 : else if (rValue == "medium")
1815 0 : aFont.SetWeight(WEIGHT_MEDIUM);
1816 0 : else if (rValue == "semibold")
1817 0 : aFont.SetWeight(WEIGHT_SEMIBOLD);
1818 0 : else if (rValue == "bold")
1819 0 : aFont.SetWeight(WEIGHT_BOLD);
1820 0 : else if (rValue == "ultrabold")
1821 0 : aFont.SetWeight(WEIGHT_ULTRABOLD);
1822 : else
1823 0 : aFont.SetWeight(WEIGHT_BLACK);
1824 0 : SetControlFont(aFont);
1825 : }
1826 0 : else if (rKey == "style")
1827 : {
1828 0 : Font aFont(GetControlFont());
1829 0 : if (rValue == "normal")
1830 0 : aFont.SetItalic(ITALIC_NONE);
1831 0 : else if (rValue == "oblique")
1832 0 : aFont.SetItalic(ITALIC_OBLIQUE);
1833 0 : else if (rValue == "italic")
1834 0 : aFont.SetItalic(ITALIC_NORMAL);
1835 0 : SetControlFont(aFont);
1836 : }
1837 : else
1838 : {
1839 : SAL_INFO("vcl.layout", "unhandled font attribute: " << rKey.getStr());
1840 0 : return false;
1841 : }
1842 0 : return true;
1843 : }
1844 :
1845 :
1846 0 : bool Window::set_property(const OString &rKey, const OString &rValue)
1847 : {
1848 0 : if (
1849 0 : (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("label"))) ||
1850 0 : (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("title"))) ||
1851 0 : (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("text")))
1852 : )
1853 : {
1854 0 : SetText(OStringToOUString(VclBuilder::convertMnemonicMarkup(rValue), RTL_TEXTENCODING_UTF8));
1855 : }
1856 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("visible")))
1857 0 : Show(toBool(rValue));
1858 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("sensitive")))
1859 0 : Enable(toBool(rValue));
1860 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("resizable")))
1861 : {
1862 0 : WinBits nBits = GetStyle();
1863 0 : nBits &= ~(WB_SIZEABLE);
1864 0 : if (toBool(rValue))
1865 0 : nBits |= WB_SIZEABLE;
1866 0 : SetStyle(nBits);
1867 : }
1868 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("xalign")))
1869 : {
1870 0 : WinBits nBits = GetStyle();
1871 0 : nBits &= ~(WB_LEFT | WB_CENTER | WB_RIGHT);
1872 :
1873 0 : float f = rValue.toFloat();
1874 0 : if (f == 0.0)
1875 0 : nBits |= WB_LEFT;
1876 0 : else if (f == 1.0)
1877 0 : nBits |= WB_RIGHT;
1878 0 : else if (f == 0.5)
1879 0 : nBits |= WB_CENTER;
1880 :
1881 0 : SetStyle(nBits);
1882 : }
1883 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("yalign")))
1884 : {
1885 0 : WinBits nBits = GetStyle();
1886 0 : nBits &= ~(WB_TOP | WB_VCENTER | WB_BOTTOM);
1887 :
1888 0 : float f = rValue.toFloat();
1889 0 : if (f == 0.0)
1890 0 : nBits |= WB_TOP;
1891 0 : else if (f == 1.0)
1892 0 : nBits |= WB_BOTTOM;
1893 0 : else if (f == 0.5)
1894 0 : nBits |= WB_CENTER;
1895 :
1896 0 : SetStyle(nBits);
1897 : }
1898 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("wrap")))
1899 : {
1900 0 : WinBits nBits = GetStyle();
1901 0 : nBits &= ~(WB_WORDBREAK);
1902 0 : if (toBool(rValue))
1903 0 : nBits |= WB_WORDBREAK;
1904 0 : SetStyle(nBits);
1905 : }
1906 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("height-request")))
1907 0 : set_height_request(rValue.toInt32());
1908 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("width-request")))
1909 0 : set_width_request(rValue.toInt32());
1910 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("hexpand")))
1911 0 : set_hexpand(toBool(rValue));
1912 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("vexpand")))
1913 0 : set_vexpand(toBool(rValue));
1914 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("halign")))
1915 0 : set_halign(toAlign(rValue));
1916 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("valign")))
1917 0 : set_valign(toAlign(rValue));
1918 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("tooltip-markup")))
1919 0 : SetQuickHelpText(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
1920 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("tooltip-text")))
1921 0 : SetQuickHelpText(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
1922 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("border-width")))
1923 0 : set_border_width(rValue.toInt32());
1924 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("margin-left")))
1925 0 : set_margin_left(rValue.toInt32());
1926 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("margin-right")))
1927 0 : set_margin_right(rValue.toInt32());
1928 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("margin-top")))
1929 0 : set_margin_top(rValue.toInt32());
1930 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("margin-bottom")))
1931 0 : set_margin_bottom(rValue.toInt32());
1932 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("hscrollbar-policy")))
1933 : {
1934 0 : WinBits nBits = GetStyle();
1935 0 : nBits &= ~(WB_AUTOHSCROLL|WB_HSCROLL);
1936 0 : if (rValue == "always")
1937 0 : nBits |= WB_HSCROLL;
1938 0 : else if (rValue == "automatic")
1939 0 : nBits |= WB_AUTOHSCROLL;
1940 0 : SetStyle(nBits);
1941 : }
1942 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("vscrollbar-policy")))
1943 : {
1944 0 : WinBits nBits = GetStyle();
1945 0 : nBits &= ~(WB_AUTOVSCROLL|WB_VSCROLL);
1946 0 : if (rValue == "always")
1947 0 : nBits |= WB_VSCROLL;
1948 0 : else if (rValue == "automatic")
1949 0 : nBits |= WB_AUTOVSCROLL;
1950 0 : SetStyle(nBits);
1951 : }
1952 0 : else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("use-markup")))
1953 : {
1954 : //https://live.gnome.org/GnomeGoals/RemoveMarkupInMessages
1955 : SAL_WARN_IF(toBool(rValue), "vcl.layout", "Use pango attributes instead of mark-up");
1956 : }
1957 : else
1958 : {
1959 : SAL_INFO("vcl.layout", "unhandled property: " << rKey.getStr());
1960 0 : return false;
1961 : }
1962 0 : return true;
1963 : }
1964 :
1965 0 : void Window::set_height_request(sal_Int32 nHeightRequest)
1966 : {
1967 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1968 :
1969 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
1970 :
1971 0 : if ( pWindowImpl->mnHeightRequest != nHeightRequest )
1972 : {
1973 0 : pWindowImpl->mnHeightRequest = nHeightRequest;
1974 0 : queue_resize();
1975 : }
1976 0 : }
1977 :
1978 0 : void Window::set_width_request(sal_Int32 nWidthRequest)
1979 : {
1980 : DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1981 :
1982 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
1983 :
1984 0 : if ( pWindowImpl->mnWidthRequest != nWidthRequest )
1985 : {
1986 0 : pWindowImpl->mnWidthRequest = nWidthRequest;
1987 0 : queue_resize();
1988 : }
1989 0 : }
1990 :
1991 0 : Size Window::get_preferred_size() const
1992 : {
1993 0 : Size aRet(get_width_request(), get_height_request());
1994 0 : if (aRet.Width() == -1 || aRet.Height() == -1)
1995 : {
1996 0 : Size aOptimal = GetOptimalSize(WINDOWSIZE_PREFERRED);
1997 0 : if (aRet.Width() == -1)
1998 0 : aRet.Width() = aOptimal.Width();
1999 0 : if (aRet.Height() == -1)
2000 0 : aRet.Height() = aOptimal.Height();
2001 : }
2002 0 : return aRet;
2003 : }
2004 :
2005 0 : VclAlign Window::get_halign() const
2006 : {
2007 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2008 0 : return pWindowImpl->meHalign;
2009 : }
2010 :
2011 0 : void Window::set_halign(VclAlign eAlign)
2012 : {
2013 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2014 0 : pWindowImpl->meHalign = eAlign;
2015 0 : }
2016 :
2017 0 : VclAlign Window::get_valign() const
2018 : {
2019 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2020 0 : return pWindowImpl->meValign;
2021 : }
2022 :
2023 0 : void Window::set_valign(VclAlign eAlign)
2024 : {
2025 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2026 0 : pWindowImpl->meValign = eAlign;
2027 0 : }
2028 :
2029 0 : bool Window::get_hexpand() const
2030 : {
2031 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2032 0 : return pWindowImpl->mbHexpand;
2033 : }
2034 :
2035 0 : void Window::set_hexpand(bool bExpand)
2036 : {
2037 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2038 0 : pWindowImpl->mbHexpand = bExpand;
2039 0 : }
2040 :
2041 0 : bool Window::get_vexpand() const
2042 : {
2043 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2044 0 : return pWindowImpl->mbVexpand;
2045 : }
2046 :
2047 0 : void Window::set_vexpand(bool bExpand)
2048 : {
2049 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2050 0 : pWindowImpl->mbVexpand = bExpand;
2051 0 : }
2052 :
2053 0 : bool Window::get_expand() const
2054 : {
2055 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2056 0 : return pWindowImpl->mbExpand;
2057 : }
2058 :
2059 0 : void Window::set_expand(bool bExpand)
2060 : {
2061 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2062 0 : pWindowImpl->mbExpand = bExpand;
2063 0 : }
2064 :
2065 0 : VclPackType Window::get_pack_type() const
2066 : {
2067 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2068 0 : return pWindowImpl->mePackType;
2069 : }
2070 :
2071 0 : void Window::set_pack_type(VclPackType ePackType)
2072 : {
2073 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2074 0 : pWindowImpl->mePackType = ePackType;
2075 0 : }
2076 :
2077 0 : sal_Int32 Window::get_padding() const
2078 : {
2079 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2080 0 : return pWindowImpl->mnPadding;
2081 : }
2082 :
2083 0 : void Window::set_padding(sal_Int32 nPadding)
2084 : {
2085 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2086 0 : pWindowImpl->mnPadding = nPadding;
2087 0 : }
2088 :
2089 0 : bool Window::get_fill() const
2090 : {
2091 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2092 0 : return pWindowImpl->mbFill;
2093 : }
2094 :
2095 0 : void Window::set_fill(bool bFill)
2096 : {
2097 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2098 0 : pWindowImpl->mbFill = bFill;
2099 0 : }
2100 :
2101 0 : sal_Int32 Window::get_grid_width() const
2102 : {
2103 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2104 0 : return pWindowImpl->mnGridWidth;
2105 : }
2106 :
2107 0 : void Window::set_grid_width(sal_Int32 nCols)
2108 : {
2109 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2110 0 : pWindowImpl->mnGridWidth = nCols;
2111 0 : }
2112 :
2113 0 : sal_Int32 Window::get_grid_left_attach() const
2114 : {
2115 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2116 0 : return pWindowImpl->mnGridLeftAttach;
2117 : }
2118 :
2119 0 : void Window::set_grid_left_attach(sal_Int32 nAttach)
2120 : {
2121 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2122 0 : pWindowImpl->mnGridLeftAttach = nAttach;
2123 0 : }
2124 :
2125 0 : sal_Int32 Window::get_grid_height() const
2126 : {
2127 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2128 0 : return pWindowImpl->mnGridHeight;
2129 : }
2130 :
2131 0 : void Window::set_grid_height(sal_Int32 nRows)
2132 : {
2133 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2134 0 : pWindowImpl->mnGridHeight = nRows;
2135 0 : }
2136 :
2137 0 : sal_Int32 Window::get_grid_top_attach() const
2138 : {
2139 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2140 0 : return pWindowImpl->mnGridTopAttach;
2141 : }
2142 :
2143 0 : void Window::set_grid_top_attach(sal_Int32 nAttach)
2144 : {
2145 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2146 0 : pWindowImpl->mnGridTopAttach = nAttach;
2147 0 : }
2148 :
2149 0 : void Window::set_border_width(sal_Int32 nBorderWidth)
2150 : {
2151 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2152 0 : pWindowImpl->mnBorderWidth = nBorderWidth;
2153 0 : }
2154 :
2155 0 : sal_Int32 Window::get_border_width() const
2156 : {
2157 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2158 0 : return pWindowImpl->mnBorderWidth;
2159 : }
2160 :
2161 0 : void Window::set_margin_left(sal_Int32 nWidth)
2162 : {
2163 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2164 0 : pWindowImpl->mnMarginLeft = nWidth;
2165 0 : }
2166 :
2167 0 : sal_Int32 Window::get_margin_left() const
2168 : {
2169 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2170 0 : return pWindowImpl->mnMarginLeft;
2171 : }
2172 :
2173 0 : void Window::set_margin_right(sal_Int32 nWidth)
2174 : {
2175 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2176 0 : pWindowImpl->mnMarginRight = nWidth;
2177 0 : }
2178 :
2179 0 : sal_Int32 Window::get_margin_right() const
2180 : {
2181 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2182 0 : return pWindowImpl->mnMarginRight;
2183 : }
2184 :
2185 0 : void Window::set_margin_top(sal_Int32 nWidth)
2186 : {
2187 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2188 0 : pWindowImpl->mnMarginTop = nWidth;
2189 0 : }
2190 :
2191 0 : sal_Int32 Window::get_margin_top() const
2192 : {
2193 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2194 0 : return pWindowImpl->mnMarginTop;
2195 : }
2196 :
2197 0 : void Window::set_margin_bottom(sal_Int32 nWidth)
2198 : {
2199 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2200 0 : pWindowImpl->mnMarginBottom = nWidth;
2201 0 : }
2202 :
2203 0 : sal_Int32 Window::get_margin_bottom() const
2204 : {
2205 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2206 0 : return pWindowImpl->mnMarginBottom;
2207 : }
2208 :
2209 0 : sal_Int32 Window::get_height_request() const
2210 : {
2211 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2212 0 : return pWindowImpl->mnHeightRequest;
2213 : }
2214 :
2215 0 : sal_Int32 Window::get_width_request() const
2216 : {
2217 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2218 0 : return pWindowImpl->mnWidthRequest;
2219 : }
2220 :
2221 0 : bool Window::get_secondary() const
2222 : {
2223 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2224 0 : return pWindowImpl->mbSecondary;
2225 : }
2226 :
2227 0 : void Window::set_secondary(bool bSecondary)
2228 : {
2229 0 : WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2230 0 : pWindowImpl->mbSecondary = bSecondary;
2231 108 : }
2232 :
2233 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|