LibreOffice Module vcl (master)  1
scrbar.cxx
Go to the documentation of this file.
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 <vcl/event.hxx>
21 #include <vcl/decoview.hxx>
22 #include <vcl/scrbar.hxx>
23 #include <vcl/timer.hxx>
24 #include <vcl/settings.hxx>
25 #include <vcl/vclevent.hxx>
26 
27 #include <sal/log.hxx>
28 
29 /* #i77549#
30  HACK: for scrollbars in case of thumb rect, page up and page down rect we
31  abuse the HitTestNativeScrollbar interface. All theming engines but macOS
32  are actually able to draw the thumb according to our internal representation.
33  However macOS draws a little outside. The canonical way would be to enhance the
34  HitTestNativeScrollbar passing a ScrollbarValue additionally so all necessary
35  information is available in the call.
36  .
37  However since there is only this one small exception we will deviate a little and
38  instead pass the respective rect as control region to allow for a small correction.
39 
40  So all places using HitTestNativeScrollbar on ControlPart::ThumbHorz, ControlPart::ThumbVert,
41  ControlPart::TrackHorzLeft, ControlPart::TrackHorzRight, ControlPart::TrackVertUpper, ControlPart::TrackVertLower
42  do not use the control rectangle as region but the actual part rectangle, making
43  only small deviations feasible.
44 */
45 
46 #include "thumbpos.hxx"
47 
48 #define SCRBAR_DRAW_BTN1 (sal_uInt16(0x0001))
49 #define SCRBAR_DRAW_BTN2 (sal_uInt16(0x0002))
50 #define SCRBAR_DRAW_PAGE1 (sal_uInt16(0x0004))
51 #define SCRBAR_DRAW_PAGE2 (sal_uInt16(0x0008))
52 #define SCRBAR_DRAW_THUMB (sal_uInt16(0x0010))
53 #define SCRBAR_DRAW_BACKGROUND (sal_uInt16(0x0020))
54 
55 #define SCRBAR_STATE_BTN1_DOWN (sal_uInt16(0x0001))
56 #define SCRBAR_STATE_BTN1_DISABLE (sal_uInt16(0x0002))
57 #define SCRBAR_STATE_BTN2_DOWN (sal_uInt16(0x0004))
58 #define SCRBAR_STATE_BTN2_DISABLE (sal_uInt16(0x0008))
59 #define SCRBAR_STATE_PAGE1_DOWN (sal_uInt16(0x0010))
60 #define SCRBAR_STATE_PAGE2_DOWN (sal_uInt16(0x0020))
61 #define SCRBAR_STATE_THUMB_DOWN (sal_uInt16(0x0040))
62 
63 #define SCRBAR_VIEW_STYLE (WB_3DLOOK | WB_HORZ | WB_VERT)
64 
66 {
67  AutoTimer maTimer { "vcl::ScrollBar mpData->maTimer" };
68  bool mbHide;
69 };
70 
71 void ScrollBar::ImplInit( vcl::Window* pParent, WinBits nStyle )
72 {
73  mpData = nullptr;
74  mnThumbPixRange = 0;
75  mnThumbPixPos = 0;
76  mnThumbPixSize = 0;
77  mnMinRange = 0;
78  mnMaxRange = 100;
79  mnThumbPos = 0;
80  mnVisibleSize = 0;
81  mnLineSize = 1;
82  mnPageSize = 1;
83  mnDelta = 0;
84  mnStateFlags = 0;
86  mbCalcSize = true;
87  mbFullDrag = false;
88 
89  ImplInitStyle( nStyle );
90  Control::ImplInit( pParent, nStyle, nullptr );
91 
93  SetSizePixel( Size( nScrollSize, nScrollSize ) );
94 }
95 
97 {
98  if ( nStyle & WB_DRAG )
99  mbFullDrag = true;
100  else
101  mbFullDrag = bool(GetSettings().GetStyleSettings().GetDragFullOptions() & DragFullOptions::Scroll);
102 }
103 
106 {
107  ImplInit( pParent, nStyle );
108 }
109 
111 {
112  disposeOnce();
113 }
114 
116 {
117  mpData.reset();
119 }
120 
121 void ScrollBar::ImplUpdateRects( bool bUpdate )
122 {
125 
126  if ( mnThumbPixRange )
127  {
128  if ( GetStyle() & WB_HORZ )
129  {
132  if ( !mnThumbPixPos )
134  else
138  else
139  {
142  }
143  }
144  else
145  {
148  if ( !mnThumbPixPos )
150  else
154  else
155  {
158  }
159  }
160  }
161  else
162  {
163  if ( GetStyle() & WB_HORZ )
164  {
165  const tools::Long nSpace = maTrackRect.Right() - maTrackRect.Left();
166  if ( nSpace > 0 )
167  {
169  maPage1Rect.SetRight( maTrackRect.Left() + (nSpace/2) );
172  }
173  }
174  else
175  {
176  const tools::Long nSpace = maTrackRect.Bottom() - maTrackRect.Top();
177  if ( nSpace > 0 )
178  {
180  maPage1Rect.SetBottom( maTrackRect.Top() + (nSpace/2) );
183  }
184  }
185  }
186 
188  {
189  // disable scrollbar buttons only in VCL's own 'theme'
190  // as it is uncommon on other platforms
191  if ( mnThumbPos == mnMinRange )
195  }
196 
197  if ( bUpdate )
198  {
199  Invalidate();
200  }
201 }
202 
204 {
205  // Calculate position
206  tools::Long nCalcThumbPos;
207  nCalcThumbPos = ImplMulDiv( nPixPos, mnMaxRange-mnVisibleSize-mnMinRange,
209  nCalcThumbPos += mnMinRange;
210  return nCalcThumbPos;
211 }
212 
214 {
215  tools::Long nCalcThumbPos;
216 
217  // Calculate position
218  nCalcThumbPos = ImplMulDiv( nPos-mnMinRange, mnThumbPixRange-mnThumbPixSize,
220 
221  // At the start and end of the ScrollBar, we try to show the display correctly
222  if ( !nCalcThumbPos && (mnThumbPos > mnMinRange) )
223  nCalcThumbPos = 1;
224  if ( nCalcThumbPos &&
225  ((nCalcThumbPos+mnThumbPixSize) >= mnThumbPixRange) &&
227  nCalcThumbPos--;
228 
229  return nCalcThumbPos;
230 }
231 
232 void ScrollBar::ImplCalc( bool bUpdate )
233 {
234  const Size aSize = GetOutputSizePixel();
235  const tools::Long nMinThumbSize = GetSettings().GetStyleSettings().GetMinThumbSize();
236 
237  if ( mbCalcSize )
238  {
239  Size aOldSize = getCurrentCalcSize();
240 
241  const tools::Rectangle aControlRegion( Point(0,0), aSize );
242  tools::Rectangle aBtn1Region, aBtn2Region, aTrackRegion, aBoundingRegion;
243 
244  // reset rectangles to empty *and* (0,0) position
248 
249  if ( GetStyle() & WB_HORZ )
250  {
252  aControlRegion, ControlState::NONE, ImplControlValue(), aBoundingRegion, aBtn1Region ) &&
254  aControlRegion, ControlState::NONE, ImplControlValue(), aBoundingRegion, aBtn2Region ) )
255  {
256  maBtn1Rect = aBtn1Region;
257  maBtn2Rect = aBtn2Region;
258  }
259  else
260  {
261  Size aBtnSize( aSize.Height(), aSize.Height() );
263  maBtn2Rect.SetLeft( aSize.Width()-aSize.Height() );
264  maBtn1Rect.SetSize( aBtnSize );
265  maBtn2Rect.SetSize( aBtnSize );
266  }
267 
269  aControlRegion, ControlState::NONE, ImplControlValue(), aBoundingRegion, aTrackRegion ) )
270  maTrackRect = aTrackRegion;
271  else
273 
274  // Check if available space is big enough for thumb ( min thumb size = ScrBar width/height )
276  if( mnThumbPixRange > 0 )
277  {
282  }
283  else
284  mnThumbPixRange = 0;
285  }
286  else // WB_VERT
287  {
289  aControlRegion, ControlState::NONE, ImplControlValue(), aBoundingRegion, aBtn1Region ) &&
291  aControlRegion, ControlState::NONE, ImplControlValue(), aBoundingRegion, aBtn2Region ) )
292  {
293  maBtn1Rect = aBtn1Region;
294  maBtn2Rect = aBtn2Region;
295  }
296  else
297  {
298  const Size aBtnSize( aSize.Width(), aSize.Width() );
300  maBtn2Rect.SetTop( aSize.Height()-aSize.Width() );
301  maBtn1Rect.SetSize( aBtnSize );
302  maBtn2Rect.SetSize( aBtnSize );
303  }
304 
306  aControlRegion, ControlState::NONE, ImplControlValue(), aBoundingRegion, aTrackRegion ) )
307  maTrackRect = aTrackRegion;
308  else
310 
311  // Check if available space is big enough for thumb
313  if( mnThumbPixRange > 0 )
314  {
319  }
320  else
321  mnThumbPixRange = 0;
322  }
323 
324  mbCalcSize = false;
325 
326  Size aNewSize = getCurrentCalcSize();
327  if (aOldSize != aNewSize)
328  {
329  queue_resize();
330  }
331  }
332 
333  if ( mnThumbPixRange )
334  {
335  // Calculate values
336  if ( (mnVisibleSize >= (mnMaxRange-mnMinRange)) ||
337  ((mnMaxRange-mnMinRange) <= 0) )
338  {
340  mnThumbPixPos = 0;
342  }
343  else
344  {
345  if ( mnVisibleSize )
347  else
348  {
349  if ( GetStyle() & WB_HORZ )
351  else
353  }
354  if ( mnThumbPixSize < nMinThumbSize )
355  mnThumbPixSize = nMinThumbSize;
359  }
360  }
361 
362  // If we're ought to output again and we have been triggered
363  // a Paint event via an Action, we don't output directly,
364  // but invalidate everything
365  if ( bUpdate && HasPaintEvent() )
366  {
367  Invalidate();
368  bUpdate = false;
369  }
370  ImplUpdateRects( bUpdate );
371 }
372 
373 void ScrollBar::Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags )
374 {
375  Point aPos = pDev->LogicToPixel( rPos );
376 
377  pDev->Push();
378  pDev->SetMapMode();
379  if ( !(nFlags & SystemTextColorFlags::Mono) )
380  {
381  // DecoView uses the FaceColor...
382  AllSettings aSettings = pDev->GetSettings();
383  StyleSettings aStyleSettings = aSettings.GetStyleSettings();
384  if ( IsControlBackground() )
385  aStyleSettings.SetFaceColor( GetControlBackground() );
386  else
387  aStyleSettings.SetFaceColor( GetSettings().GetStyleSettings().GetFaceColor() );
388 
389  aSettings.SetStyleSettings( aStyleSettings );
390  pDev->SetSettings( aSettings );
391  }
392 
393  // For printing:
394  // - calculate the size of the rects
395  // - because this is zero-based add the correct offset
396  // - print
397  // - force recalculate
398 
399  if ( mbCalcSize )
400  ImplCalc( false );
401 
402  maBtn1Rect+=aPos;
403  maBtn2Rect+=aPos;
404  maThumbRect+=aPos;
405  maTrackRect+=aPos;
406  maPage1Rect+=aPos;
407  maPage2Rect+=aPos;
408 
409  ImplDraw(*pDev);
410  pDev->Pop();
411 
412  mbCalcSize = true;
413 }
414 
415 bool ScrollBar::ImplDrawNative(vcl::RenderContext& rRenderContext, sal_uInt16 nSystemTextColorFlags)
416 {
417  ScrollbarValue scrValue;
418 
419  bool bNativeOK = rRenderContext.IsNativeControlSupported(ControlType::Scrollbar, ControlPart::Entire);
420  if (!bNativeOK)
421  return false;
422 
423  bool bHorz = (GetStyle() & WB_HORZ) != 0;
424 
425  // Draw the entire background if the control supports it
427  {
430 
431  scrValue.mnMin = mnMinRange;
432  scrValue.mnMax = mnMaxRange;
433  scrValue.mnCur = mnThumbPos;
434  scrValue.mnVisibleSize = mnVisibleSize;
435  scrValue.maThumbRect = maThumbRect;
436  scrValue.maButton1Rect = maBtn1Rect;
437  scrValue.maButton2Rect = maBtn2Rect;
440  scrValue.mnButton2State = ((mnStateFlags & SCRBAR_STATE_BTN2_DOWN) ? ControlState::PRESSED : ControlState::NONE) |
442  scrValue.mnThumbState = nState | ((mnStateFlags & SCRBAR_STATE_THUMB_DOWN) ? ControlState::PRESSED : ControlState::NONE);
443 
444  if (IsMouseOver())
445  {
447  if (pRect)
448  {
449  if (pRect == &maThumbRect)
451  else if (pRect == &maBtn1Rect)
453  else if (pRect == &maBtn2Rect)
455  }
456  }
457 
458  tools::Rectangle aCtrlRegion;
459  aCtrlRegion.Union(maBtn1Rect);
460  aCtrlRegion.Union(maBtn2Rect);
461  aCtrlRegion.Union(maPage1Rect);
462  aCtrlRegion.Union(maPage2Rect);
463  aCtrlRegion.Union(maThumbRect);
464 
465  tools::Rectangle aRequestedRegion(Point(0,0), GetOutputSizePixel());
466  // if the actual native control region is smaller then the region that
467  // we requested the control to draw in, then draw a background rectangle
468  // to avoid drawing artifacts in the uncovered region
469  if (aCtrlRegion.GetWidth() < aRequestedRegion.GetWidth() ||
470  aCtrlRegion.GetHeight() < aRequestedRegion.GetHeight())
471  {
472  Color aFaceColor = rRenderContext.GetSettings().GetStyleSettings().GetFaceColor();
473  rRenderContext.SetFillColor(aFaceColor);
474  rRenderContext.SetLineColor(aFaceColor);
475  rRenderContext.DrawRect(aRequestedRegion);
476  }
477 
478  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Scrollbar, (bHorz ? ControlPart::DrawBackgroundHorz : ControlPart::DrawBackgroundVert),
479  aCtrlRegion, nState, scrValue, OUString());
480  }
481  else
482  {
483  if ((nSystemTextColorFlags & SCRBAR_DRAW_PAGE1) || (nSystemTextColorFlags & SCRBAR_DRAW_PAGE2))
484  {
487  tools::Rectangle aCtrlRegion1(maPage1Rect);
488  tools::Rectangle aCtrlRegion2(maPage2Rect);
491  ControlState nState2 = nState1;
492 
494  nState2 |= ((mnStateFlags & SCRBAR_STATE_PAGE2_DOWN) ? ControlState::PRESSED : ControlState::NONE);
495 
496  if (IsMouseOver())
497  {
499  if (pRect)
500  {
501  if (pRect == &maPage1Rect)
502  nState1 |= ControlState::ROLLOVER;
503  else if (pRect == &maPage2Rect)
504  nState2 |= ControlState::ROLLOVER;
505  }
506  }
507 
508  if (nSystemTextColorFlags & SCRBAR_DRAW_PAGE1)
509  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Scrollbar, part1, aCtrlRegion1, nState1, scrValue, OUString());
510 
511  if (nSystemTextColorFlags & SCRBAR_DRAW_PAGE2)
512  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Scrollbar, part2, aCtrlRegion2, nState2, scrValue, OUString());
513  }
514  if ((nSystemTextColorFlags & SCRBAR_DRAW_BTN1) || (nSystemTextColorFlags & SCRBAR_DRAW_BTN2))
515  {
518  tools::Rectangle aCtrlRegion1(maBtn1Rect);
519  tools::Rectangle aCtrlRegion2(maBtn2Rect);
521  ControlState nState2 = nState1;
522 
523  if (!Window::IsEnabled() || !IsEnabled())
524  nState1 = (nState2 &= ~ControlState::ENABLED);
525  else
526  nState1 = (nState2 |= ControlState::ENABLED);
527 
529  nState2 |= ((mnStateFlags & SCRBAR_STATE_BTN2_DOWN) ? ControlState::PRESSED : ControlState::NONE);
530 
532  nState1 &= ~ControlState::ENABLED;
534  nState2 &= ~ControlState::ENABLED;
535 
536  if (IsMouseOver())
537  {
539  if (pRect)
540  {
541  if (pRect == &maBtn1Rect)
542  nState1 |= ControlState::ROLLOVER;
543  else if (pRect == &maBtn2Rect)
544  nState2 |= ControlState::ROLLOVER;
545  }
546  }
547 
548  if (nSystemTextColorFlags & SCRBAR_DRAW_BTN1)
549  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Scrollbar, part1, aCtrlRegion1, nState1, scrValue, OUString());
550 
551  if (nSystemTextColorFlags & SCRBAR_DRAW_BTN2)
552  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Scrollbar, part2, aCtrlRegion2, nState2, scrValue, OUString());
553  }
554  if ((nSystemTextColorFlags & SCRBAR_DRAW_THUMB) && !maThumbRect.IsEmpty())
555  {
557  tools::Rectangle aCtrlRegion(maThumbRect);
558 
560  nState |= ControlState::PRESSED;
561 
562  if (HasFocus())
563  nState |= ControlState::FOCUSED;
564 
565  if (IsMouseOver())
566  {
568  if (pRect && pRect == &maThumbRect)
569  nState |= ControlState::ROLLOVER;
570  }
571 
573  aCtrlRegion, nState, scrValue, OUString());
574  }
575  }
576  return bNativeOK;
577 }
578 
580 {
581  DecorationView aDecoView(&rRenderContext);
582  tools::Rectangle aTempRect;
583  DrawButtonFlags nStyle;
584  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
585  SymbolType eSymbolType;
586  bool bEnabled = IsEnabled();
587 
588  // Finish some open calculations (if any)
589  if (mbCalcSize)
590  ImplCalc(false);
591 
592  //vcl::Window *pWin = NULL;
593  //if (rRenderContext.GetOutDevType() == OUTDEV_WINDOW)
594  // pWin = static_cast<vcl::Window*>(&rRenderContext);
595 
596  // Draw the entire control if the native theme engine needs it
598  {
599  ImplDrawNative(rRenderContext, SCRBAR_DRAW_BACKGROUND);
600  return;
601  }
602 
603  if (!ImplDrawNative(rRenderContext, SCRBAR_DRAW_BTN1))
604  {
607  nStyle |= DrawButtonFlags::Pressed;
608  aTempRect = aDecoView.DrawButton( PixelToLogic(maBtn1Rect), nStyle );
609  ImplCalcSymbolRect( aTempRect );
610  DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE;
611  if ((mnStateFlags & SCRBAR_STATE_BTN1_DISABLE) || !bEnabled)
612  nSymbolStyle |= DrawSymbolFlags::Disable;
613  if (GetStyle() & WB_HORZ)
614  eSymbolType = SymbolType::SPIN_LEFT;
615  else
616  eSymbolType = SymbolType::SPIN_UP;
617  aDecoView.DrawSymbol(aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nSymbolStyle);
618  }
619 
620  if (!ImplDrawNative(rRenderContext, SCRBAR_DRAW_BTN2))
621  {
624  nStyle |= DrawButtonFlags::Pressed;
625  aTempRect = aDecoView.DrawButton(PixelToLogic(maBtn2Rect), nStyle);
626  ImplCalcSymbolRect(aTempRect);
627  DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE;
628  if ((mnStateFlags & SCRBAR_STATE_BTN2_DISABLE) || !bEnabled)
629  nSymbolStyle |= DrawSymbolFlags::Disable;
630  if (GetStyle() & WB_HORZ)
631  eSymbolType = SymbolType::SPIN_RIGHT;
632  else
633  eSymbolType = SymbolType::SPIN_DOWN;
634  aDecoView.DrawSymbol(aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nSymbolStyle);
635  }
636 
637  rRenderContext.SetLineColor();
638 
639  if (!ImplDrawNative(rRenderContext, SCRBAR_DRAW_THUMB))
640  {
641  if (!maThumbRect.IsEmpty())
642  {
643  if (bEnabled)
644  {
646  aTempRect = aDecoView.DrawButton(PixelToLogic(maThumbRect), nStyle);
647  }
648  else
649  {
650  rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
651  rRenderContext.DrawRect(PixelToLogic(maThumbRect));
652  }
653  }
654  }
655 
656  if (!ImplDrawNative(rRenderContext, SCRBAR_DRAW_PAGE1))
657  {
659  rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
660  else
661  rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
662  rRenderContext.DrawRect(PixelToLogic(maPage1Rect));
663  }
664  if (!ImplDrawNative(rRenderContext, SCRBAR_DRAW_PAGE2))
665  {
667  rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
668  else
669  rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
670  rRenderContext.DrawRect(PixelToLogic(maPage2Rect));
671  }
672 }
673 
674 tools::Long ScrollBar::ImplScroll( tools::Long nNewPos, bool bCallEndScroll )
675 {
676  tools::Long nOldPos = mnThumbPos;
677  SetThumbPos( nNewPos );
678  tools::Long nDelta = mnThumbPos-nOldPos;
679  if ( nDelta )
680  {
681  mnDelta = nDelta;
682  Scroll();
683  if ( bCallEndScroll )
684  EndScroll();
685  mnDelta = 0;
686  }
687  return nDelta;
688 }
689 
690 tools::Long ScrollBar::ImplDoAction( bool bCallEndScroll )
691 {
692  tools::Long nDelta = 0;
693 
694  switch ( meScrollType )
695  {
696  case ScrollType::LineUp:
697  nDelta = ImplScroll( mnThumbPos-mnLineSize, bCallEndScroll );
698  break;
699 
701  nDelta = ImplScroll( mnThumbPos+mnLineSize, bCallEndScroll );
702  break;
703 
704  case ScrollType::PageUp:
705  nDelta = ImplScroll( mnThumbPos-mnPageSize, bCallEndScroll );
706  break;
707 
709  nDelta = ImplScroll( mnThumbPos+mnPageSize, bCallEndScroll );
710  break;
711  default:
712  ;
713  }
714 
715  return nDelta;
716 }
717 
718 void ScrollBar::ImplDoMouseAction( const Point& rMousePos, bool bCallAction )
719 {
720  sal_uInt16 nOldStateFlags = mnStateFlags;
721  bool bAction = false;
722  bool bHorizontal = ( GetStyle() & WB_HORZ ) != 0;
723  bool bIsInside = false;
724 
725  Point aPoint( 0, 0 );
726  tools::Rectangle aControlRegion( aPoint, GetOutputSizePixel() );
727 
728  switch ( meScrollType )
729  {
730  case ScrollType::LineUp:
731  if ( GetOutDev()->HitTestNativeScrollbar( bHorizontal? (IsRTLEnabled()? ControlPart::ButtonRight: ControlPart::ButtonLeft): ControlPart::ButtonUp,
732  aControlRegion, rMousePos, bIsInside )?
733  bIsInside:
734  maBtn1Rect.Contains( rMousePos ) )
735  {
736  bAction = bCallAction;
738  }
739  else
741  break;
742 
744  if ( GetOutDev()->HitTestNativeScrollbar( bHorizontal? (IsRTLEnabled()? ControlPart::ButtonLeft: ControlPart::ButtonRight): ControlPart::ButtonDown,
745  aControlRegion, rMousePos, bIsInside )?
746  bIsInside:
747  maBtn2Rect.Contains( rMousePos ) )
748  {
749  bAction = bCallAction;
751  }
752  else
754  break;
755 
756  case ScrollType::PageUp:
757  // HitTestNativeScrollbar, see remark at top of file
759  maPage1Rect, rMousePos, bIsInside )?
760  bIsInside:
761  maPage1Rect.Contains( rMousePos ) )
762  {
763  bAction = bCallAction;
765  }
766  else
768  break;
769 
771  // HitTestNativeScrollbar, see remark at top of file
773  maPage2Rect, rMousePos, bIsInside )?
774  bIsInside:
775  maPage2Rect.Contains( rMousePos ) )
776  {
777  bAction = bCallAction;
779  }
780  else
782  break;
783  default:
784  ;
785  }
786 
787  if ( nOldStateFlags != mnStateFlags )
788  Invalidate();
789  if ( bAction )
790  ImplDoAction( false );
791 }
792 
793 void ScrollBar::ImplDragThumb( const Point& rMousePos )
794 {
795  tools::Long nMovePix;
796  if ( GetStyle() & WB_HORZ )
797  nMovePix = rMousePos.X()-(maThumbRect.Left()+mnMouseOff);
798  else
799  nMovePix = rMousePos.Y()-(maThumbRect.Top()+mnMouseOff);
800 
801  // Move thumb if necessary
802  if ( !nMovePix )
803  return;
804 
805  mnThumbPixPos += nMovePix;
806  if ( mnThumbPixPos < 0 )
807  mnThumbPixPos = 0;
810  tools::Long nOldPos = mnThumbPos;
812  ImplUpdateRects();
813  if ( !(mbFullDrag && (nOldPos != mnThumbPos)) )
814  return;
815 
816  // When dragging in windows the repaint request gets starved so dragging
817  // the scrollbar feels slower than it actually is. Let's force an immediate
818  // repaint of the scrollbar.
820  {
821  Invalidate();
823  }
824  else
825  ImplDraw(*GetOutDev());
826 
827  mnDelta = mnThumbPos-nOldPos;
828  Scroll();
829  mnDelta = 0;
830 }
831 
833 {
834  bool bPrimaryWarps = GetSettings().GetStyleSettings().GetPrimaryButtonWarpsSlider();
835  bool bWarp = bPrimaryWarps ? rMEvt.IsLeft() : rMEvt.IsMiddle();
836  bool bPrimaryWarping = bWarp && rMEvt.IsLeft();
837  bool bPage = bPrimaryWarps ? rMEvt.IsRight() : rMEvt.IsLeft();
838 
839  if (!rMEvt.IsLeft() && !rMEvt.IsMiddle() && !rMEvt.IsRight())
840  return;
841 
842  Point aPosPixel;
843  if (!IsMapModeEnabled() && GetMapMode().GetMapUnit() == MapUnit::MapTwip)
844  {
845  // rMEvt coordinates are in twips.
847  EnableMapMode();
848  MapMode aMapMode = GetMapMode();
849  aMapMode.SetOrigin(Point(0, 0));
850  SetMapMode(aMapMode);
851  aPosPixel = LogicToPixel(rMEvt.GetPosPixel());
852  GetOutDev()->Pop();
853  }
854  const Point& rMousePos = (GetMapMode().GetMapUnit() != MapUnit::MapTwip ? rMEvt.GetPosPixel() : aPosPixel);
856  bool bHorizontal = ( GetStyle() & WB_HORZ ) != 0;
857  bool bIsInside = false;
858  bool bDragToMouse = false;
859 
860  Point aPoint( 0, 0 );
861  tools::Rectangle aControlRegion( aPoint, GetOutputSizePixel() );
862 
863  if ( GetOutDev()->HitTestNativeScrollbar( bHorizontal? (IsRTLEnabled()? ControlPart::ButtonRight: ControlPart::ButtonLeft): ControlPart::ButtonUp,
864  aControlRegion, rMousePos, bIsInside )?
865  bIsInside:
866  maBtn1Rect.Contains( rMousePos ) )
867  {
868  if (rMEvt.IsLeft() && !(mnStateFlags & SCRBAR_STATE_BTN1_DISABLE) )
869  {
870  nTrackFlags = StartTrackingFlags::ButtonRepeat;
872  }
873  }
874  else if ( GetOutDev()->HitTestNativeScrollbar( bHorizontal? (IsRTLEnabled()? ControlPart::ButtonLeft: ControlPart::ButtonRight): ControlPart::ButtonDown,
875  aControlRegion, rMousePos, bIsInside )?
876  bIsInside:
877  maBtn2Rect.Contains( rMousePos ) )
878  {
879  if (rMEvt.IsLeft() && !(mnStateFlags & SCRBAR_STATE_BTN2_DISABLE) )
880  {
881  nTrackFlags = StartTrackingFlags::ButtonRepeat;
883  }
884  }
885  else
886  {
888  maThumbRect, rMousePos, bIsInside )
889  ? bIsInside : maThumbRect.Contains( rMousePos );
890 
891  bool bThumbAction = bWarp || bPage;
892 
893  bool bDragHandling = bWarp || (bThumbHit && bThumbAction);
894  if( bDragHandling )
895  {
896  if( mpData )
897  {
898  mpData->mbHide = true; // disable focus blinking
899  if (HasFocus())
900  {
901  mnStateFlags |= SCRBAR_DRAW_THUMB; // paint without focus
902  Invalidate();
903  }
904  }
905 
907  {
908  nTrackFlags = StartTrackingFlags::NONE;
910 
911  // calculate mouse offset
912  if (bWarp && (!bThumbHit || !bPrimaryWarping))
913  {
914  bDragToMouse = true;
915  if ( GetStyle() & WB_HORZ )
917  else
919  }
920  else
921  {
922  if ( GetStyle() & WB_HORZ )
923  mnMouseOff = rMousePos.X()-maThumbRect.Left();
924  else
925  mnMouseOff = rMousePos.Y()-maThumbRect.Top();
926  }
927 
929  Invalidate();
930  }
931  }
932  else if(bPage && (!GetOutDev()->HitTestNativeScrollbar( bHorizontal? ControlPart::TrackHorzArea : ControlPart::TrackVertArea,
933  aControlRegion, rMousePos, bIsInside ) ||
934  bIsInside) )
935  {
936  nTrackFlags = StartTrackingFlags::ButtonRepeat;
937 
938  // HitTestNativeScrollbar, see remark at top of file
939  if ( GetOutDev()->HitTestNativeScrollbar( bHorizontal? ControlPart::TrackHorzLeft : ControlPart::TrackVertUpper,
940  maPage1Rect, rMousePos, bIsInside )?
941  bIsInside:
942  maPage1Rect.Contains( rMousePos ) )
943  {
945  }
946  else
947  {
949  }
950  }
951  }
952 
953  // Should we start Tracking?
955  return;
956 
957  // store original position for cancel and EndScroll delta
959  // #92906# Call StartTracking() before ImplDoMouseAction(), otherwise
960  // MouseButtonUp() / EndTracking() may be called if somebody is spending
961  // a lot of time in the scroll handler
962  StartTracking( nTrackFlags );
963  ImplDoMouseAction( rMousePos );
964 
965  if( bDragToMouse )
966  ImplDragThumb( rMousePos );
967 
968 }
969 
970 void ScrollBar::Tracking( const TrackingEvent& rTEvt )
971 {
972  if ( rTEvt.IsTrackingEnded() )
973  {
974  // Restore Button and PageRect status
975  sal_uInt16 nOldStateFlags = mnStateFlags;
979  if ( nOldStateFlags != mnStateFlags )
980  Invalidate();
981 
982  // Restore the old ThumbPosition when canceled
983  if ( rTEvt.IsTrackingCanceled() )
984  {
985  tools::Long nOldPos = mnThumbPos;
987  mnDelta = mnThumbPos-nOldPos;
988  Scroll();
989  }
990 
992  {
993  // On a SCROLLDRAG we recalculate the Thumb, so that it's back to a
994  // rounded ThumbPosition
995  ImplCalc();
996 
997  if ( !mbFullDrag && (mnStartPos != mnThumbPos) )
998  {
1000  Scroll();
1001  mnDelta = 0;
1002  }
1003  }
1004 
1006  EndScroll();
1007  mnDelta = 0;
1009 
1010  if( mpData )
1011  mpData->mbHide = false; // re-enable focus blinking
1012  }
1013  else
1014  {
1015  Point aPosPixel;
1016  if (!IsMapModeEnabled() && GetMapMode().GetMapUnit() == MapUnit::MapTwip)
1017  {
1018  // rTEvt coordinates are in twips.
1020  EnableMapMode();
1021  MapMode aMapMode = GetMapMode();
1022  aMapMode.SetOrigin(Point(0, 0));
1023  SetMapMode(aMapMode);
1024  aPosPixel = LogicToPixel(rTEvt.GetMouseEvent().GetPosPixel());
1025  GetOutDev()->Pop();
1026  }
1027  const Point rMousePos = (GetMapMode().GetMapUnit() != MapUnit::MapTwip ? rTEvt.GetMouseEvent().GetPosPixel() : aPosPixel);
1028 
1029  // Dragging is treated in a special way
1030  if ( meScrollType == ScrollType::Drag )
1031  ImplDragThumb( rMousePos );
1032  else
1033  ImplDoMouseAction( rMousePos, rTEvt.IsTrackingRepeat() );
1034 
1035  // If ScrollBar values are translated in a way that there's
1036  // nothing left to track, we cancel here
1037  if ( !IsVisible() || (mnVisibleSize >= (mnMaxRange-mnMinRange)) )
1038  EndTracking();
1039  }
1040 }
1041 
1042 void ScrollBar::KeyInput( const KeyEvent& rKEvt )
1043 {
1044  if ( !rKEvt.GetKeyCode().GetModifier() )
1045  {
1046  switch ( rKEvt.GetKeyCode().GetCode() )
1047  {
1048  case KEY_HOME:
1049  DoScroll( 0 );
1050  break;
1051 
1052  case KEY_END:
1053  DoScroll( GetRangeMax() );
1054  break;
1055 
1056  case KEY_LEFT:
1057  case KEY_UP:
1059  break;
1060 
1061  case KEY_RIGHT:
1062  case KEY_DOWN:
1064  break;
1065 
1066  case KEY_PAGEUP:
1068  break;
1069 
1070  case KEY_PAGEDOWN:
1072  break;
1073 
1074  default:
1075  Control::KeyInput( rKEvt );
1076  break;
1077  }
1078  }
1079  else
1080  Control::KeyInput( rKEvt );
1081 }
1082 
1084 {
1085  rRenderContext.SetBackground();
1086 }
1087 
1089 {
1090  ImplDraw(rRenderContext);
1091 }
1092 
1094 {
1095  Control::Move();
1096  mbCalcSize = true;
1097  if (IsReallyVisible())
1098  ImplCalc(false);
1099  Invalidate();
1100 }
1101 
1103 {
1104  Control::Resize();
1105  mbCalcSize = true;
1106  if ( IsReallyVisible() )
1107  ImplCalc( false );
1108  Invalidate();
1109 }
1110 
1111 IMPL_LINK_NOARG(ScrollBar, ImplAutoTimerHdl, Timer *, void)
1112 {
1113  if( mpData && mpData->mbHide )
1114  return;
1115  ImplInvert();
1116 }
1117 
1119 {
1120  tools::Rectangle aRect( maThumbRect );
1121  if( aRect.getWidth() > 4 )
1122  {
1123  aRect.AdjustLeft(2 );
1124  aRect.AdjustRight( -2 );
1125  }
1126  if( aRect.getHeight() > 4 )
1127  {
1128  aRect.AdjustTop(2 );
1129  aRect.AdjustBottom( -2 );
1130  }
1131 
1132  GetOutDev()->Invert( aRect );
1133 }
1134 
1136 {
1137  if( !mpData )
1138  {
1139  mpData.reset(new ImplScrollBarData);
1140  mpData->maTimer.SetInvokeHandler( LINK( this, ScrollBar, ImplAutoTimerHdl ) );
1141  mpData->mbHide = false;
1142  }
1143  ImplInvert(); // react immediately
1144  mpData->maTimer.SetTimeout( GetSettings().GetStyleSettings().GetCursorBlinkTime() );
1145  mpData->maTimer.Start();
1147 }
1148 
1150 {
1151  if( mpData )
1152  mpData->maTimer.Stop();
1153  Invalidate();
1154 
1156 }
1157 
1159 {
1160  Control::StateChanged( nType );
1161 
1162  if ( nType == StateChangedType::InitShow )
1163  ImplCalc( false );
1164  else if ( nType == StateChangedType::Data )
1165  {
1166  if ( IsReallyVisible() && IsUpdateMode() )
1167  ImplCalc();
1168  }
1169  else if ( nType == StateChangedType::UpdateMode )
1170  {
1171  if ( IsReallyVisible() && IsUpdateMode() )
1172  {
1173  ImplCalc( false );
1174  Invalidate();
1175  }
1176  }
1177  else if ( nType == StateChangedType::Enable )
1178  {
1179  if ( IsReallyVisible() && IsUpdateMode() )
1180  Invalidate();
1181  }
1182  else if ( nType == StateChangedType::Style )
1183  {
1184  ImplInitStyle( GetStyle() );
1185  if ( IsReallyVisible() && IsUpdateMode() )
1186  {
1187  if ( (GetPrevStyle() & SCRBAR_VIEW_STYLE) !=
1188  (GetStyle() & SCRBAR_VIEW_STYLE) )
1189  {
1190  mbCalcSize = true;
1191  ImplCalc( false );
1192  Invalidate();
1193  }
1194  }
1195  }
1196 }
1197 
1199 {
1200  Control::DataChanged( rDCEvt );
1201 
1202  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1203  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
1204  {
1205  mbCalcSize = true;
1206  ImplCalc( false );
1207  Invalidate();
1208  }
1209 }
1210 
1212 {
1213  bool bHorizontal = ( GetStyle() & WB_HORZ ) != 0;
1214  bool bIsInside = false;
1215 
1216  Point aPoint( 0, 0 );
1217  tools::Rectangle aControlRegion( aPoint, GetOutputSizePixel() );
1218 
1219  if( GetOutDev()->HitTestNativeScrollbar( bHorizontal? (IsRTLEnabled()? ControlPart::ButtonRight: ControlPart::ButtonLeft): ControlPart::ButtonUp,
1220  aControlRegion, rPt, bIsInside )?
1221  bIsInside:
1222  maBtn1Rect.Contains( rPt ) )
1223  return &maBtn1Rect;
1224  else if( GetOutDev()->HitTestNativeScrollbar( bHorizontal? (IsRTLEnabled()? ControlPart::ButtonLeft: ControlPart::ButtonRight): ControlPart::ButtonDown,
1225  aControlRegion, rPt, bIsInside )?
1226  bIsInside:
1227  maBtn2Rect.Contains( rPt ) )
1228  return &maBtn2Rect;
1229  // HitTestNativeScrollbar, see remark at top of file
1231  maPage1Rect, rPt, bIsInside)?
1232  bIsInside:
1233  maPage1Rect.Contains( rPt ) )
1234  return &maPage1Rect;
1235  // HitTestNativeScrollbar, see remark at top of file
1237  maPage2Rect, rPt, bIsInside)?
1238  bIsInside:
1239  maPage2Rect.Contains( rPt ) )
1240  return &maPage2Rect;
1241  // HitTestNativeScrollbar, see remark at top of file
1243  maThumbRect, rPt, bIsInside)?
1244  bIsInside:
1245  maThumbRect.Contains( rPt ) )
1246  return &maThumbRect;
1247  else
1248  return nullptr;
1249 }
1250 
1252 {
1253  if( rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE )
1254  {
1255  const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent();
1256  if( pMouseEvt && !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
1257  {
1258  // Trigger a redraw if mouse over state has changed
1260  {
1263  if( pRect != pLastRect || pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow() )
1264  {
1265  vcl::Region aRgn( GetOutDev()->GetActiveClipRegion() );
1266  vcl::Region aClipRegion;
1267 
1268  if ( pRect )
1269  aClipRegion.Union( *pRect );
1270  if ( pLastRect )
1271  aClipRegion.Union( *pLastRect );
1272 
1273  // Support for 3-button scroll bars
1275  if ( bHas3Buttons && ( pRect == &maBtn1Rect || pLastRect == &maBtn1Rect ) )
1276  {
1277  aClipRegion.Union( maBtn2Rect );
1278  }
1279 
1280  GetOutDev()->SetClipRegion( aClipRegion );
1281  Invalidate(aClipRegion.GetBoundRect());
1282 
1283  GetOutDev()->SetClipRegion( aRgn );
1284  }
1285  }
1286  }
1287  }
1288 
1289  return Control::PreNotify(rNEvt);
1290 }
1291 
1293 {
1295 }
1296 
1298 {
1300 }
1301 
1303 {
1305  return 0;
1306 
1307  SAL_INFO("vcl.scrollbar", "DoScroll(" << nNewPos << ")");
1309  tools::Long nDelta = ImplScroll( nNewPos, true );
1311  return nDelta;
1312 }
1313 
1315 {
1316  if ( (meScrollType != ScrollType::DontKnow) ||
1317  (eScrollType == ScrollType::DontKnow) ||
1318  (eScrollType == ScrollType::Drag) )
1319  return 0;
1320 
1321  meScrollType = eScrollType;
1322  tools::Long nDelta = ImplDoAction( true );
1324  return nDelta;
1325 }
1326 
1328 {
1329  SetRange( Range( nNewRange, GetRangeMax() ) );
1330 }
1331 
1333 {
1334  SetRange( Range( GetRangeMin(), nNewRange ) );
1335 }
1336 
1337 void ScrollBar::SetRange( const Range& rRange )
1338 {
1339  // Adapt Range
1340  Range aRange = rRange;
1341  aRange.Justify();
1342  tools::Long nNewMinRange = aRange.Min();
1343  tools::Long nNewMaxRange = aRange.Max();
1344 
1345  // If Range differs, set a new one
1346  if ( (mnMinRange == nNewMinRange) && (mnMaxRange == nNewMaxRange))
1347  return;
1348 
1349  mnMinRange = nNewMinRange;
1350  mnMaxRange = nNewMaxRange;
1351 
1352  // Adapt Thumb
1355  if ( mnThumbPos < mnMinRange )
1357 
1359 }
1360 
1362 {
1363  if ( nNewThumbPos > mnMaxRange-mnVisibleSize )
1364  nNewThumbPos = mnMaxRange-mnVisibleSize;
1365  if ( nNewThumbPos < mnMinRange )
1366  nNewThumbPos = mnMinRange;
1367 
1368  if ( mnThumbPos != nNewThumbPos )
1369  {
1370  mnThumbPos = nNewThumbPos;
1372  }
1373 }
1374 
1376 {
1377  if ( mnVisibleSize != nNewSize )
1378  {
1379  mnVisibleSize = nNewSize;
1380 
1381  // Adapt Thumb
1384  if ( mnThumbPos < mnMinRange )
1387  }
1388 }
1389 
1391 {
1392  if (mbCalcSize)
1393  const_cast<ScrollBar*>(this)->ImplCalc(false);
1394 
1395  Size aRet = getCurrentCalcSize();
1396 
1397  const tools::Long nMinThumbSize = GetSettings().GetStyleSettings().GetMinThumbSize();
1398 
1399  if (GetStyle() & WB_HORZ)
1400  {
1401  aRet.setWidth( maBtn1Rect.GetWidth() + nMinThumbSize + maBtn2Rect.GetWidth() );
1402  }
1403  else
1404  {
1405  aRet.setHeight( maBtn1Rect.GetHeight() + nMinThumbSize + maBtn2Rect.GetHeight() );
1406  }
1407 
1408  return aRet;
1409 }
1410 
1412 {
1413  tools::Rectangle aCtrlRegion;
1414  aCtrlRegion.Union(maBtn1Rect);
1415  aCtrlRegion.Union(maBtn2Rect);
1416  aCtrlRegion.Union(maPage1Rect);
1417  aCtrlRegion.Union(maPage2Rect);
1418  aCtrlRegion.Union(maThumbRect);
1419  return aCtrlRegion.GetSize();
1420 }
1421 
1423 {
1424  Window::ImplInit( pParent, nStyle, nullptr );
1425 
1426  const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1427  tools::Long nScrollSize = rStyleSettings.GetScrollBarSize();
1428  SetSizePixel(Size(nScrollSize, nScrollSize));
1429 }
1430 
1433 {
1434  ImplInit( pParent, nStyle );
1435 }
1436 
1438 {
1439  if (rRenderContext.IsBackground())
1440  {
1441  Color aColor = rRenderContext.GetSettings().GetStyleSettings().GetFaceColor();
1442  ApplyControlBackground(rRenderContext, aColor);
1443  }
1444 }
1445 
1447 {
1448  Window::StateChanged( nType );
1449 
1451  {
1452  Invalidate();
1453  }
1454 }
1455 
1457 {
1458  Window::DataChanged( rDCEvt );
1459 
1460  if ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1461  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
1462  {
1463  Invalidate();
1464  }
1465 }
1466 
1467 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SCRBAR_STATE_PAGE1_DOWN
Definition: scrbar.cxx:59
void SetRangeMin(tools::Long nNewRange)
Definition: scrbar.cxx:1327
tools::Long mnMaxRange
Definition: scrbar.hxx:55
const Color & GetShadowColor() const
bool IsControlBackground() const
Definition: window2.cxx:1081
virtual void Move()
Definition: window.cxx:1833
bool ImplCallEventListenersAndHandler(VclEventId nEvent, std::function< void()> const &callHandler)
this calls both our event listeners, and a specified handler
Definition: ctrl.cxx:300
tools::Long mnStartPos
Definition: scrbar.hxx:49
sal_Int32 GetMinThumbSize() const
Point GetPointerPosPixel()
Definition: mouse.cxx:556
#define SCRBAR_STATE_BTN1_DISABLE
Definition: scrbar.cxx:56
virtual void GetFocus() override
Definition: scrbar.cxx:1135
SAL_DLLPRIVATE void ImplUpdateRects(bool bUpdate=true)
Definition: scrbar.cxx:121
tools::Long GetRangeMax() const
Definition: scrbar.hxx:118
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
void setWidth(tools::Long nWidth)
AutoTimer maTimer vcl::ScrollBar mpData maTimer
Definition: scrbar.cxx:67
StartTrackingFlags
Definition: window.hxx:263
tools::Long getWidth() const
SAL_DLLPRIVATE void ImplDoMouseAction(const Point &rPos, bool bCallAction=true)
Definition: scrbar.cxx:718
void SetStyleSettings(const StyleSettings &rSet)
Link< ScrollBar *, void > maEndScrollHdl
Definition: scrbar.hxx:66
constexpr tools::Long Left() const
bool mbFullDrag
Definition: scrbar.hxx:64
virtual void StateChanged(StateChangedType nType) override
Definition: scrbar.cxx:1158
bool Contains(const Point &rPOINT) const
tools::Long mnLineSize
Definition: scrbar.hxx:58
void Union(const tools::Rectangle &rRegion)
Definition: region.cxx:505
bool IsBackground() const
Definition: outdev.hxx:522
#define SCRBAR_STATE_THUMB_DOWN
Definition: scrbar.cxx:61
tools::Long ImplMulDiv(tools::Long nNumber, tools::Long nNumerator, tools::Long nDenominator)
Definition: thumbpos.hxx:13
long Long
const StyleSettings & GetStyleSettings() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
Definition: stack.cxx:33
tools::Long mnVisibleSize
Definition: scrbar.hxx:57
const Color & GetFaceColor() const
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:255
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: scrbar.cxx:1422
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1256
Link< ScrollBar *, void > maScrollHdl
Definition: scrbar.hxx:65
tools::Rectangle maButton2Rect
SAL_DLLPRIVATE void CompatStateChanged(StateChangedType nStateChange)
Definition: window.cxx:3891
tools::Rectangle maPage2Rect
Definition: scrbar.hxx:45
#define SCRBAR_STATE_BTN2_DOWN
Definition: scrbar.cxx:57
sal_uInt16 GetCode() const
Definition: keycod.hxx:49
WinBits GetPrevStyle() const
Definition: window2.cxx:952
DataChangedEventType GetType() const
Definition: event.hxx:362
DrawButtonFlags
Definition: decoview.hxx:53
virtual void SetSettings(const AllSettings &rSettings)
Definition: outdev.cxx:216
const Color & GetControlBackground() const
Definition: window2.cxx:1076
SAL_DLLPRIVATE void ImplInitStyle(WinBits nStyle)
Definition: scrbar.cxx:96
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: scrbar.cxx:115
tools::Rectangle DrawButton(const tools::Rectangle &rRect, DrawButtonFlags nStyle)
Definition: decoview.cxx:916
void SetRangeMax(tools::Long nNewRange)
Definition: scrbar.cxx:1332
tools::Rectangle GetBoundRect() const
Definition: region.cxx:1217
bool IsMiddle() const
Definition: event.hxx:151
SAL_DLLPRIVATE tools::Long ImplDoAction(bool bCallEndScroll)
Definition: scrbar.cxx:690
tools::Long mnPageSize
Definition: scrbar.hxx:59
void PaintImmediately()
Definition: paint.cxx:1292
std::unique_ptr< ImplScrollBarData > mpData
Definition: scrbar.hxx:48
bool IsRTLEnabled() const
Definition: window3.cxx:127
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
Definition: window2.cxx:244
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
void SetMapMode()
Definition: map.cxx:594
tools::Long mnDelta
Definition: scrbar.hxx:60
constexpr sal_uInt16 KEY_UP
Definition: keycodes.hxx:111
#define SCRBAR_DRAW_PAGE2
Definition: scrbar.cxx:51
#define SCRBAR_VIEW_STYLE
Definition: scrbar.cxx:63
bool IsTrackingRepeat() const
Definition: event.hxx:259
constexpr sal_uInt16 KEY_END
Definition: keycodes.hxx:115
virtual Size GetOptimalSize() const override
Definition: scrbar.cxx:1390
tools::Long getHeight() const
StateChangedType
Definition: window.hxx:289
constexpr tools::Long Width() const
sal_Int64 WinBits
void SetBackground()
Definition: background.cxx:27
void Invert(const tools::Rectangle &rRect, InvertFlags nFlags=InvertFlags::NONE)
Definition: rect.cxx:149
tools::Long mnThumbPixRange
Definition: scrbar.hxx:51
sal_uInt16 GetButtons() const
Definition: event.hxx:147
SymbolType
Definition: vclenum.hxx:73
SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext &rRenderContext)
Definition: scrbar.cxx:579
bool IsEnterWindow() const
Definition: event.hxx:138
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
Definition: window2.cxx:271
tools::Rectangle maThumbRect
Definition: scrbar.hxx:46
void EnableMapMode(bool bEnable=true)
Definition: window3.cxx:105
constexpr Point BottomLeft() const
ControlState mnButton2State
tools::Long mnVisibleSize
tools::Rectangle maBtn1Rect
Definition: scrbar.hxx:42
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: scrbar.cxx:1083
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
constexpr sal_uInt16 KEY_PAGEUP
Definition: keycodes.hxx:116
tools::Long GetRangeMin() const
Definition: scrbar.hxx:116
virtual void EndScroll()
Definition: scrbar.cxx:1297
constexpr tools::Long GetWidth() const
SystemTextColorFlags
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
Definition: scrbar.cxx:373
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1321
void Pop()
Definition: stack.cxx:92
sal_uInt16 GetModifier() const
Definition: keycod.hxx:52
static SAL_DLLPRIVATE void ImplCalcSymbolRect(tools::Rectangle &rRect)
Definition: brdwin.cxx:44
ScrollType meScrollType
Definition: scrbar.hxx:62
SAL_DLLPRIVATE tools::Long ImplCalcThumbPosPix(tools::Long nPos) const
Definition: scrbar.cxx:213
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
void SetThumbPos(tools::Long nThumbPos)
Definition: scrbar.cxx:1361
tools::Rectangle maTrackRect
Definition: scrbar.hxx:47
virtual void StateChanged(StateChangedType nType) override
Definition: scrbar.cxx:1446
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:51
tools::Long mnThumbPixPos
Definition: scrbar.hxx:52
constexpr bool IsEmpty() const
constexpr void SetLeft(tools::Long v)
constexpr sal_uInt16 KEY_DOWN
Definition: keycodes.hxx:110
void Justify()
SAL_DLLPRIVATE tools::Long ImplCalcThumbPos(tools::Long nPixPos) const
Definition: scrbar.cxx:203
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: scrbar.cxx:1456
An auto-timer is a multi-shot timer re-emitting itself at interval until destroyed or stopped...
Definition: timer.hxx:66
void SetLineColor()
Definition: line.cxx:36
sal_Int32 GetScrollBarSize() const
tools::Long mnThumbPos
Definition: scrbar.hxx:56
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: scrbar.cxx:1437
Point LogicToPixel(const Point &rLogicPt) const
Definition: window3.cxx:131
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:52
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: scrbar.cxx:832
bool IsLeaveWindow() const
Definition: event.hxx:140
virtual void Resize() override
Definition: scrbar.cxx:1102
ScrollBarBox(vcl::Window *pParent, WinBits nStyle=0)
Definition: scrbar.cxx:1431
tools::Long DoScrollAction(ScrollType eScrollType)
Definition: scrbar.cxx:1314
virtual void LoseFocus() override
Definition: scrbar.cxx:1149
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: scrbar.cxx:1198
tools::Rectangle maButton1Rect
constexpr sal_uInt16 KEY_HOME
Definition: keycodes.hxx:114
SAL_DLLPRIVATE void ImplInvert()
Definition: scrbar.cxx:1118
const MapMode & GetMapMode() const
Definition: window3.cxx:99
void SetVisibleSize(tools::Long nNewSize)
Definition: scrbar.cxx:1375
SAL_DLLPRIVATE Size getCurrentCalcSize() const
Definition: scrbar.cxx:1411
void SetSize(const Size &rSize)
SAL_DLLPRIVATE tools::Long ImplScroll(tools::Long nNewPos, bool bCallEndScroll)
Definition: scrbar.cxx:674
void SetRange(const Range &rRange)
Definition: scrbar.cxx:1337
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1165
IMPL_LINK_NOARG(ScrollBar, ImplAutoTimerHdl, Timer *, void)
Definition: scrbar.cxx:1111
void SetOrigin(const Point &rOrigin)
Definition: mapmod.cxx:104
ScrollType
Definition: scrbar.hxx:28
tools::Rectangle maPage1Rect
Definition: scrbar.hxx:44
bool IsUpdateMode() const
Definition: window2.cxx:1167
constexpr tools::Long Right() const
void SetFillColor()
Definition: fill.cxx:29
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:168
const AllSettings & GetSettings() const
Definition: window3.cxx:129
bool HasPaintEvent() const
Definition: paint.cxx:1265
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
Query the native control's actual drawing region (including adornment)
Definition: window3.cxx:79
SAL_DLLPRIVATE tools::Rectangle * ImplFindPartRect(const Point &rPt)
Definition: scrbar.cxx:1211
constexpr sal_uInt16 KEY_PAGEDOWN
Definition: keycodes.hxx:117
DrawSymbolFlags
Definition: decoview.hxx:34
constexpr tools::Long Top() const
MouseNotifyEvent GetType() const
Definition: event.hxx:308
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor=COL_AUTO)
Request rendering of a particular control and/or part.
constexpr void SetRight(tools::Long v)
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: ctrl.cxx:57
const AllSettings & GetSettings() const
Definition: outdev.hxx:287
MapUnit GetMapUnit() const
Definition: mapmod.cxx:138
constexpr void SetBottom(tools::Long v)
SAL_DLLPRIVATE void ImplDragThumb(const Point &rMousePos)
Definition: scrbar.cxx:793
virtual void Move() override
Definition: scrbar.cxx:1093
Point PixelToLogic(const Point &rDevicePt) const
Definition: window3.cxx:161
ControlState mnButton1State
bool HitTestNativeScrollbar(ControlPart nPart, const tools::Rectangle &rControlRegion, const Point &aPos, bool &rIsInside) const
Query the native control to determine if it was acted upon.
virtual void LoseFocus()
Definition: window.cxx:1855
const Color & GetCheckedColor() const
virtual ~ScrollBar() override
Definition: scrbar.cxx:110
ScrollBar(vcl::Window *pParent, WinBits nStyle=WB_VERT)
Definition: scrbar.cxx:104
constexpr void SetTop(tools::Long v)
bool IsTrackingEnded() const
Definition: event.hxx:261
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: scrbar.cxx:1088
tools::Rectangle maBtn2Rect
Definition: scrbar.hxx:43
void Scroll()
Definition: scrbar.cxx:1292
SAL_DLLPRIVATE void ImplCalc(bool bUpdate=true)
Definition: scrbar.cxx:232
tools::Long AdjustTop(tools::Long nVertMoveDelta)
constexpr sal_uInt16 KEY_RIGHT
Definition: keycodes.hxx:113
MapUnit GetMapUnit()
tools::Long Min() const
constexpr tools::Long Bottom() const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:878
ControlState mnThumbState
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1805
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:938
tools::Long mnMinRange
Definition: scrbar.hxx:54
bool IsModifierChanged() const
Definition: event.hxx:144
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: scrbar.cxx:1251
bool IsMapModeEnabled() const
Definition: window3.cxx:106
tools::Long DoScroll(tools::Long nNewPos)
Definition: scrbar.cxx:1302
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
constexpr Size GetSize() const
void SetFaceColor(const Color &rColor)
bool IsMouseOver() const
Definition: mouse.cxx:612
virtual void Resize() override
Definition: ctrl.cxx:73
WindowType
Definition: ctrl.hxx:81
bool IsSynthetic() const
Definition: event.hxx:142
virtual void GetFocus()
Definition: window.cxx:1841
tools::Rectangle & Union(const tools::Rectangle &rRect)
const Color & GetButtonTextColor() const
constexpr tools::Long Height() const
bool mbCalcSize
Definition: scrbar.hxx:63
#define SCRBAR_STATE_BTN2_DISABLE
Definition: scrbar.cxx:58
const MouseEvent * GetMouseEvent() const
Definition: event.hxx:324
bool IsVisible() const
Definition: window2.cxx:1096
#define SAL_INFO(area, stream)
constexpr Point TopRight() const
::OutputDevice const * GetOutDev() const
Definition: window.cxx:568
bool IsLeft() const
Definition: event.hxx:149
bool GetPrimaryButtonWarpsSlider() const
sal_uInt16 mnStateFlags
Definition: scrbar.hxx:61
const Point & GetPosPixel() const
Definition: event.hxx:123
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: scrbar.cxx:1042
#define SCRBAR_STATE_PAGE2_DOWN
Definition: scrbar.cxx:60
#define SCRBAR_DRAW_BACKGROUND
Definition: scrbar.cxx:53
tools::Long mnThumbPixSize
Definition: scrbar.hxx:53
void ApplyControlBackground(vcl::RenderContext &rRenderContext, const Color &rDefaultColor)
Definition: window2.cxx:523
Size GetOutputSizePixel() const
Definition: window3.cxx:89
void setHeight(tools::Long nHeight)
bool IsEnabled() const
Definition: window2.cxx:1116
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
void DrawSymbol(const tools::Rectangle &rRect, SymbolType eType, const Color &rColor, DrawSymbolFlags nStyle=DrawSymbolFlags::NONE)
Definition: decoview.cxx:779
bool IsTrackingCanceled() const
Definition: event.hxx:263
WinBits GetStyle() const
Definition: window2.cxx:947
Definition: timer.hxx:26
bool IsRight() const
Definition: event.hxx:153
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: scrbar.cxx:71
constexpr sal_uInt16 KEY_LEFT
Definition: keycodes.hxx:112
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
Definition: window3.cxx:74
Point GetLastPointerPosPixel()
Definition: mouse.cxx:568
#define SCRBAR_DRAW_THUMB
Definition: scrbar.cxx:52
const MouseEvent & GetMouseEvent() const
Definition: event.hxx:257
bool IsReallyVisible() const
Definition: window2.cxx:1101
#define SCRBAR_DRAW_BTN1
Definition: scrbar.cxx:48
#define SCRBAR_DRAW_BTN2
Definition: scrbar.cxx:49
tools::Long Max() const
WinBits const WB_HORZ
bool HasFocus() const
Definition: window.cxx:2981
bool SupportsDoubleBuffering() const
Can the widget derived from this Window do the double-buffering via RenderContext properly...
Definition: window.cxx:3853
tools::Long mnMouseOff
Definition: scrbar.hxx:50
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: scrbar.cxx:970
void SetMapMode()
Definition: window3.cxx:125
sal_Int32 nState
tools::Rectangle maThumbRect
#define SCRBAR_DRAW_PAGE1
Definition: scrbar.cxx:50
#define SCRBAR_STATE_BTN1_DOWN
Definition: scrbar.cxx:55
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
constexpr tools::Long GetHeight() const
WinBits const WB_DRAG
SAL_DLLPRIVATE bool ImplDrawNative(vcl::RenderContext &rRenderContext, sal_uInt16 SystemTextColorFlags)
Definition: scrbar.cxx:415