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; // Timer
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 
92  long nScrollSize = GetSettings().GetStyleSettings().GetScrollBarSize();
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 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 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 
203 long ScrollBar::ImplCalcThumbPos( long nPixPos )
204 {
205  // Calculate position
206  long nCalcThumbPos;
207  nCalcThumbPos = ImplMulDiv( nPixPos, mnMaxRange-mnVisibleSize-mnMinRange,
209  nCalcThumbPos += mnMinRange;
210  return nCalcThumbPos;
211 }
212 
214 {
215  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 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, const Size& /* rSize */, DrawFlags nFlags )
374 {
375  Point aPos = pDev->LogicToPixel( rPos );
376 
377  pDev->Push();
378  pDev->SetMapMode();
379  if ( !(nFlags & DrawFlags::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 nDrawFlags)
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 ((nDrawFlags & SCRBAR_DRAW_PAGE1) || (nDrawFlags & 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 (nDrawFlags & SCRBAR_DRAW_PAGE1)
509  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Scrollbar, part1, aCtrlRegion1, nState1, scrValue, OUString());
510 
511  if (nDrawFlags & SCRBAR_DRAW_PAGE2)
512  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Scrollbar, part2, aCtrlRegion2, nState2, scrValue, OUString());
513  }
514  if ((nDrawFlags & SCRBAR_DRAW_BTN1) || (nDrawFlags & 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 (nDrawFlags & SCRBAR_DRAW_BTN1)
549  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Scrollbar, part1, aCtrlRegion1, nState1, scrValue, OUString());
550 
551  if (nDrawFlags & SCRBAR_DRAW_BTN2)
552  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Scrollbar, part2, aCtrlRegion2, nState2, scrValue, OUString());
553  }
554  if ((nDrawFlags & 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 long ScrollBar::ImplScroll( long nNewPos, bool bCallEndScroll )
675 {
676  long nOldPos = mnThumbPos;
677  SetThumbPos( nNewPos );
678  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 long ScrollBar::ImplDoAction( bool bCallEndScroll )
691 {
692  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:
732  aControlRegion, rMousePos, bIsInside )?
733  bIsInside:
734  maBtn1Rect.IsInside( rMousePos ) )
735  {
736  bAction = bCallAction;
738  }
739  else
741  break;
742 
744  if ( HitTestNativeScrollbar( bHorizontal? (IsRTLEnabled()? ControlPart::ButtonLeft: ControlPart::ButtonRight): ControlPart::ButtonDown,
745  aControlRegion, rMousePos, bIsInside )?
746  bIsInside:
747  maBtn2Rect.IsInside( 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.IsInside( 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.IsInside( 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  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  {
804  mnThumbPixPos += nMovePix;
805  if ( mnThumbPixPos < 0 )
806  mnThumbPixPos = 0;
809  long nOldPos = mnThumbPos;
811  ImplUpdateRects();
812  if ( mbFullDrag && (nOldPos != mnThumbPos) )
813  {
814  // When dragging in windows the repaint request gets starved so dragging
815  // the scrollbar feels slower than it actually is. Let's force an immediate
816  // repaint of the scrollbar.
818  {
819  Invalidate();
820  Update();
821  }
822  else
823  ImplDraw(*this);
824 
825  mnDelta = mnThumbPos-nOldPos;
826  Scroll();
827  mnDelta = 0;
828  }
829  }
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  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 
864  aControlRegion, rMousePos, bIsInside )?
865  bIsInside:
866  maBtn1Rect.IsInside( rMousePos ) )
867  {
868  if (rMEvt.IsLeft() && !(mnStateFlags & SCRBAR_STATE_BTN1_DISABLE) )
869  {
870  nTrackFlags = StartTrackingFlags::ButtonRepeat;
872  }
873  }
874  else if ( HitTestNativeScrollbar( bHorizontal? (IsRTLEnabled()? ControlPart::ButtonLeft: ControlPart::ButtonRight): ControlPart::ButtonDown,
875  aControlRegion, rMousePos, bIsInside )?
876  bIsInside:
877  maBtn2Rect.IsInside( 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.IsInside( 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  }
933  aControlRegion, rMousePos, bIsInside ) ||
934  bIsInside) )
935  {
936  nTrackFlags = StartTrackingFlags::ButtonRepeat;
937 
938  // HitTestNativeScrollbar, see remark at top of file
940  maPage1Rect, rMousePos, bIsInside )?
941  bIsInside:
942  maPage1Rect.IsInside( rMousePos ) )
943  {
945  }
946  else
947  {
949  }
950  }
951  }
952 
953  // Should we start Tracking?
955  {
956  // store original position for cancel and EndScroll delta
958  // #92906# Call StartTracking() before ImplDoMouseAction(), otherwise
959  // MouseButtonUp() / EndTracking() may be called if somebody is spending
960  // a lot of time in the scroll handler
961  StartTracking( nTrackFlags );
962  ImplDoMouseAction( rMousePos );
963 
964  if( bDragToMouse )
965  ImplDragThumb( rMousePos );
966  }
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  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  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  Invert( aRect );
1133 }
1134 
1136 {
1137  if( !mpData )
1138  {
1139  mpData.reset(new ImplScrollBarData);
1140  mpData->maTimer.SetInvokeHandler( LINK( this, ScrollBar, ImplAutoTimerHdl ) );
1141  mpData->maTimer.SetDebugName( "vcl::ScrollBar mpData->maTimer" );
1142  mpData->mbHide = false;
1143  }
1144  ImplInvert(); // react immediately
1145  mpData->maTimer.SetTimeout( GetSettings().GetStyleSettings().GetCursorBlinkTime() );
1146  mpData->maTimer.Start();
1148 }
1149 
1151 {
1152  if( mpData )
1153  mpData->maTimer.Stop();
1154  Invalidate();
1155 
1157 }
1158 
1160 {
1161  Control::StateChanged( nType );
1162 
1163  if ( nType == StateChangedType::InitShow )
1164  ImplCalc( false );
1165  else if ( nType == StateChangedType::Data )
1166  {
1167  if ( IsReallyVisible() && IsUpdateMode() )
1168  ImplCalc();
1169  }
1170  else if ( nType == StateChangedType::UpdateMode )
1171  {
1172  if ( IsReallyVisible() && IsUpdateMode() )
1173  {
1174  ImplCalc( false );
1175  Invalidate();
1176  }
1177  }
1178  else if ( nType == StateChangedType::Enable )
1179  {
1180  if ( IsReallyVisible() && IsUpdateMode() )
1181  Invalidate();
1182  }
1183  else if ( nType == StateChangedType::Style )
1184  {
1185  ImplInitStyle( GetStyle() );
1186  if ( IsReallyVisible() && IsUpdateMode() )
1187  {
1188  if ( (GetPrevStyle() & SCRBAR_VIEW_STYLE) !=
1189  (GetStyle() & SCRBAR_VIEW_STYLE) )
1190  {
1191  mbCalcSize = true;
1192  ImplCalc( false );
1193  Invalidate();
1194  }
1195  }
1196  }
1197 }
1198 
1200 {
1201  Control::DataChanged( rDCEvt );
1202 
1203  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1204  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
1205  {
1206  mbCalcSize = true;
1207  ImplCalc( false );
1208  Invalidate();
1209  }
1210 }
1211 
1213 {
1214  bool bHorizontal = ( GetStyle() & WB_HORZ ) != 0;
1215  bool bIsInside = false;
1216 
1217  Point aPoint( 0, 0 );
1218  tools::Rectangle aControlRegion( aPoint, GetOutputSizePixel() );
1219 
1221  aControlRegion, rPt, bIsInside )?
1222  bIsInside:
1223  maBtn1Rect.IsInside( rPt ) )
1224  return &maBtn1Rect;
1225  else if( HitTestNativeScrollbar( bHorizontal? (IsRTLEnabled()? ControlPart::ButtonLeft: ControlPart::ButtonRight): ControlPart::ButtonDown,
1226  aControlRegion, rPt, bIsInside )?
1227  bIsInside:
1228  maBtn2Rect.IsInside( rPt ) )
1229  return &maBtn2Rect;
1230  // HitTestNativeScrollbar, see remark at top of file
1232  maPage1Rect, rPt, bIsInside)?
1233  bIsInside:
1234  maPage1Rect.IsInside( rPt ) )
1235  return &maPage1Rect;
1236  // HitTestNativeScrollbar, see remark at top of file
1238  maPage2Rect, rPt, bIsInside)?
1239  bIsInside:
1240  maPage2Rect.IsInside( rPt ) )
1241  return &maPage2Rect;
1242  // HitTestNativeScrollbar, see remark at top of file
1244  maThumbRect, rPt, bIsInside)?
1245  bIsInside:
1246  maThumbRect.IsInside( rPt ) )
1247  return &maThumbRect;
1248  else
1249  return nullptr;
1250 }
1251 
1253 {
1254  const MouseEvent* pMouseEvt = nullptr;
1255 
1256  if( (rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != nullptr )
1257  {
1258  if( !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
1259  {
1260  // Trigger a redraw if mouse over state has changed
1262  {
1265  if( pRect != pLastRect || pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow() )
1266  {
1267  vcl::Region aRgn( GetActiveClipRegion() );
1268  vcl::Region aClipRegion;
1269 
1270  if ( pRect )
1271  aClipRegion.Union( *pRect );
1272  if ( pLastRect )
1273  aClipRegion.Union( *pLastRect );
1274 
1275  // Support for 3-button scroll bars
1277  if ( bHas3Buttons && ( pRect == &maBtn1Rect || pLastRect == &maBtn1Rect ) )
1278  {
1279  aClipRegion.Union( maBtn2Rect );
1280  }
1281 
1282  SetClipRegion( aClipRegion );
1283  Invalidate(aClipRegion.GetBoundRect());
1284 
1285  SetClipRegion( aRgn );
1286  }
1287  }
1288  }
1289  }
1290 
1291  return Control::PreNotify(rNEvt);
1292 }
1293 
1295 {
1297 }
1298 
1300 {
1302 }
1303 
1304 long ScrollBar::DoScroll( long nNewPos )
1305 {
1307  return 0;
1308 
1309  SAL_INFO("vcl.scrollbar", "DoScroll(" << nNewPos << ")");
1311  long nDelta = ImplScroll( nNewPos, true );
1313  return nDelta;
1314 }
1315 
1317 {
1318  if ( (meScrollType != ScrollType::DontKnow) ||
1319  (eScrollType == ScrollType::DontKnow) ||
1320  (eScrollType == ScrollType::Drag) )
1321  return 0;
1322 
1323  meScrollType = eScrollType;
1324  long nDelta = ImplDoAction( true );
1326  return nDelta;
1327 }
1328 
1329 void ScrollBar::SetRangeMin( long nNewRange )
1330 {
1331  SetRange( Range( nNewRange, GetRangeMax() ) );
1332 }
1333 
1334 void ScrollBar::SetRangeMax( long nNewRange )
1335 {
1336  SetRange( Range( GetRangeMin(), nNewRange ) );
1337 }
1338 
1339 void ScrollBar::SetRange( const Range& rRange )
1340 {
1341  // Adapt Range
1342  Range aRange = rRange;
1343  aRange.Justify();
1344  long nNewMinRange = aRange.Min();
1345  long nNewMaxRange = aRange.Max();
1346 
1347  // If Range differs, set a new one
1348  if ( (mnMinRange != nNewMinRange) ||
1349  (mnMaxRange != nNewMaxRange) )
1350  {
1351  mnMinRange = nNewMinRange;
1352  mnMaxRange = nNewMaxRange;
1353 
1354  // Adapt Thumb
1357  if ( mnThumbPos < mnMinRange )
1359 
1361  }
1362 }
1363 
1364 void ScrollBar::SetThumbPos( long nNewThumbPos )
1365 {
1366  if ( nNewThumbPos > mnMaxRange-mnVisibleSize )
1367  nNewThumbPos = mnMaxRange-mnVisibleSize;
1368  if ( nNewThumbPos < mnMinRange )
1369  nNewThumbPos = mnMinRange;
1370 
1371  if ( mnThumbPos != nNewThumbPos )
1372  {
1373  mnThumbPos = nNewThumbPos;
1375  }
1376 }
1377 
1378 void ScrollBar::SetVisibleSize( long nNewSize )
1379 {
1380  if ( mnVisibleSize != nNewSize )
1381  {
1382  mnVisibleSize = nNewSize;
1383 
1384  // Adapt Thumb
1387  if ( mnThumbPos < mnMinRange )
1390  }
1391 }
1392 
1394 {
1395  if (mbCalcSize)
1396  const_cast<ScrollBar*>(this)->ImplCalc(false);
1397 
1398  Size aRet = getCurrentCalcSize();
1399 
1400  const long nMinThumbSize = GetSettings().GetStyleSettings().GetMinThumbSize();
1401 
1402  if (GetStyle() & WB_HORZ)
1403  {
1404  aRet.setWidth( maBtn1Rect.GetWidth() + nMinThumbSize + maBtn2Rect.GetWidth() );
1405  }
1406  else
1407  {
1408  aRet.setHeight( maBtn1Rect.GetHeight() + nMinThumbSize + maBtn2Rect.GetHeight() );
1409  }
1410 
1411  return aRet;
1412 }
1413 
1415 {
1416  tools::Rectangle aCtrlRegion;
1417  aCtrlRegion.Union(maBtn1Rect);
1418  aCtrlRegion.Union(maBtn2Rect);
1419  aCtrlRegion.Union(maPage1Rect);
1420  aCtrlRegion.Union(maPage2Rect);
1421  aCtrlRegion.Union(maThumbRect);
1422  return aCtrlRegion.GetSize();
1423 }
1424 
1426 {
1427  Window::ImplInit( pParent, nStyle, nullptr );
1428 
1429  const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1430  long nScrollSize = rStyleSettings.GetScrollBarSize();
1431  SetSizePixel(Size(nScrollSize, nScrollSize));
1432 }
1433 
1436 {
1437  ImplInit( pParent, nStyle );
1438 }
1439 
1441 {
1442  if (rRenderContext.IsBackground())
1443  {
1444  Color aColor = rRenderContext.GetSettings().GetStyleSettings().GetFaceColor();
1445  ApplyControlBackground(rRenderContext, aColor);
1446  }
1447 }
1448 
1450 {
1451  Window::StateChanged( nType );
1452 
1454  {
1455  Invalidate();
1456  }
1457 }
1458 
1460 {
1461  Window::DataChanged( rDCEvt );
1462 
1463  if ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1464  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
1465  {
1466  Invalidate();
1467  }
1468 }
1469 
1470 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SCRBAR_STATE_PAGE1_DOWN
Definition: scrbar.cxx:59
long getHeight() const
long Width() const
const Color & GetShadowColor() const
bool IsControlBackground() const
Definition: window2.cxx:1076
long mnThumbPixRange
Definition: scrbar.hxx:51
virtual void Move()
Definition: window.cxx:1796
bool ImplCallEventListenersAndHandler(VclEventId nEvent, std::function< void()> const &callHandler)
this calls both our event listeners, and a specified handler
Definition: ctrl.cxx:305
long GetWidth() const
Point GetPointerPosPixel()
Definition: mouse.cxx:549
void SetRangeMin(long nNewRange)
Definition: scrbar.cxx:1329
#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
long GetHeight() const
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption)
Request rendering of a particular control and/or part.
SAL_DLLPRIVATE bool ImplDrawNative(vcl::RenderContext &rRenderContext, sal_uInt16 nDrawFlags)
Definition: scrbar.cxx:415
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)
long ImplMulDiv(long nNumber, long nNumerator, long nDenominator)
Definition: thumbpos.hxx:13
#define KEY_PAGEDOWN
Definition: keycodes.hxx:117
StartTrackingFlags
Definition: window.hxx:285
SAL_DLLPRIVATE void ImplDoMouseAction(const Point &rPos, bool bCallAction=true)
Definition: scrbar.cxx:718
void SetStyleSettings(const StyleSettings &rSet)
long Height() const
#define KEY_PAGEUP
Definition: keycodes.hxx:116
Link< ScrollBar *, void > maEndScrollHdl
Definition: scrbar.hxx:66
bool mbFullDrag
Definition: scrbar.hxx:64
Point BottomLeft() const
virtual void StateChanged(StateChangedType nType) override
Definition: scrbar.cxx:1159
void Union(const tools::Rectangle &rRegion)
Definition: region.cxx:508
long getWidth() const
bool IsBackground() const
Definition: outdev.hxx:634
long AdjustLeft(long nHorzMoveDelta)
#define SCRBAR_STATE_THUMB_DOWN
Definition: scrbar.cxx:61
const StyleSettings & GetStyleSettings() const
const Color & GetFaceColor() const
bool IsMapModeEnabled() const
Definition: outdev.hxx:1669
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:260
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: scrbar.cxx:1425
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1251
Link< ScrollBar *, void > maScrollHdl
Definition: scrbar.hxx:65
long DoScrollAction(ScrollType eScrollType)
Definition: scrbar.cxx:1316
tools::Rectangle maButton2Rect
void CompatStateChanged(StateChangedType nStateChange)
Definition: window.cxx:3852
tools::Rectangle maPage2Rect
Definition: scrbar.hxx:45
const MapMode & GetMapMode() const
Definition: outdev.hxx:1674
#define SCRBAR_STATE_BTN2_DOWN
Definition: scrbar.cxx:57
sal_uInt16 GetCode() const
Definition: keycod.hxx:53
WinBits GetPrevStyle() const
Definition: window2.cxx:947
virtual void Draw(OutputDevice *pDev, const Point &rPos, const Size &rSize, DrawFlags nFlags) override
Definition: scrbar.cxx:373
DataChangedEventType GetType() const
Definition: event.hxx:348
AutoTimer maTimer
Definition: scrbar.cxx:67
DrawButtonFlags
Definition: decoview.hxx:78
virtual void SetSettings(const AllSettings &rSettings)
Definition: outdev.cxx:213
void EnableMapMode(bool bEnable=true)
Definition: map.cxx:647
const Color & GetControlBackground() const
Definition: window2.cxx:1071
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:942
tools::Rectangle GetBoundRect() const
Definition: region.cxx:1214
long mnMouseOff
Definition: scrbar.hxx:50
bool IsMiddle() const
Definition: event.hxx:135
std::unique_ptr< ImplScrollBarData > mpData
Definition: scrbar.hxx:48
#define KEY_LEFT
Definition: keycodes.hxx:112
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:655
long mnVisibleSize
Definition: scrbar.hxx:57
#define SCRBAR_DRAW_PAGE2
Definition: scrbar.cxx:51
#define SCRBAR_VIEW_STYLE
Definition: scrbar.cxx:63
long AdjustBottom(long nVertMoveDelta)
long mnThumbPixSize
Definition: scrbar.hxx:53
bool IsTrackingRepeat() const
Definition: event.hxx:252
virtual Size GetOptimalSize() const override
Definition: scrbar.cxx:1393
bool IsEmpty() const
StateChangedType
Definition: window.hxx:311
sal_Int64 WinBits
long GetMinThumbSize() const
void SetBackground()
void Invert(const tools::Rectangle &rRect, InvertFlags nFlags=InvertFlags::NONE)
Definition: rect.cxx:128
long Right() const
sal_uInt16 GetButtons() const
Definition: event.hxx:131
SymbolType
Definition: vclenum.hxx:73
long mnStartPos
Definition: scrbar.hxx:49
SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext &rRenderContext)
Definition: scrbar.cxx:579
bool IsEnterWindow() const
Definition: event.hxx:122
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
Definition: window2.cxx:272
tools::Rectangle maThumbRect
Definition: scrbar.hxx:46
ControlState mnButton2State
tools::Rectangle maBtn1Rect
Definition: scrbar.hxx:42
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: scrbar.cxx:1083
AllSettingsFlags GetFlags() const
Definition: event.hxx:349
virtual void EndScroll()
Definition: scrbar.cxx:1299
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1303
sal_uInt16 GetModifier() const
Definition: keycod.hxx:56
long Top() const
static SAL_DLLPRIVATE void ImplCalcSymbolRect(tools::Rectangle &rRect)
Definition: brdwin.cxx:44
ScrollType meScrollType
Definition: scrbar.hxx:62
SAL_DLLPRIVATE long ImplCalcThumbPos(long nPixPos)
Definition: scrbar.cxx:203
tools::Rectangle maTrackRect
Definition: scrbar.hxx:47
virtual void StateChanged(StateChangedType nType) override
Definition: scrbar.cxx:1449
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:32
void Update()
Definition: paint.cxx:1276
void Justify()
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: scrbar.cxx:1459
An auto-timer is a multi-shot timer re-emitting itself at interval until destroyed or stopped...
Definition: timer.hxx:72
void SetLineColor()
long DoScroll(long nNewPos)
Definition: scrbar.cxx:1304
long mnThumbPixPos
Definition: scrbar.hxx:52
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: scrbar.cxx:1440
bool IsRTLEnabled() const
Definition: outdev.hxx:1354
void SetTop(long v)
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:51
long mnMinRange
Definition: scrbar.hxx:54
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: scrbar.cxx:832
bool IsLeaveWindow() const
Definition: event.hxx:124
virtual void Resize() override
Definition: scrbar.cxx:1102
ScrollBarBox(vcl::Window *pParent, WinBits nStyle=0)
Definition: scrbar.cxx:1434
DrawFlags
Definition: window.hxx:354
virtual void LoseFocus() override
Definition: scrbar.cxx:1150
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: scrbar.cxx:1199
tools::Rectangle maButton1Rect
SAL_DLLPRIVATE void ImplInvert()
Definition: scrbar.cxx:1118
void SetRangeMax(long nNewRange)
Definition: scrbar.cxx:1334
void SetVisibleSize(long nNewSize)
Definition: scrbar.cxx:1378
SAL_DLLPRIVATE Size getCurrentCalcSize() const
Definition: scrbar.cxx:1414
void SetSize(const Size &rSize)
void SetRange(const Range &rRange)
Definition: scrbar.cxx:1339
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1156
IMPL_LINK_NOARG(ScrollBar, ImplAutoTimerHdl, Timer *, void)
Definition: scrbar.cxx:1111
void SetOrigin(const Point &rOrigin)
Definition: mapmod.cxx:102
ScrollType
Definition: scrbar.hxx:28
void SetRight(long v)
tools::Rectangle maPage1Rect
Definition: scrbar.hxx:44
bool IsUpdateMode() const
Definition: window2.cxx:1162
void SetFillColor()
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
bool HasPaintEvent() const
Definition: paint.cxx:1249
long Bottom() const
SAL_DLLPRIVATE tools::Rectangle * ImplFindPartRect(const Point &rPt)
Definition: scrbar.cxx:1212
DrawSymbolFlags
Definition: decoview.hxx:34
MouseNotifyEvent GetType() const
Definition: event.hxx:294
bool IsInside(const Point &rPOINT) const
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: ctrl.cxx:59
const AllSettings & GetSettings() const
Definition: outdev.hxx:420
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
MapUnit GetMapUnit() const
Definition: mapmod.cxx:168
SAL_DLLPRIVATE void ImplDragThumb(const Point &rMousePos)
Definition: scrbar.cxx:793
virtual void Move() override
Definition: scrbar.cxx:1093
long GetRangeMin() const
Definition: scrbar.hxx:116
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:1818
const Color & GetCheckedColor() const
virtual ~ScrollBar() override
Definition: scrbar.cxx:110
long X() const
ScrollBar(vcl::Window *pParent, WinBits nStyle=WB_VERT)
Definition: scrbar.cxx:104
bool IsTrackingEnded() const
Definition: event.hxx:254
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: scrbar.cxx:1088
Size GetSize() const
long mnPageSize
Definition: scrbar.hxx:59
#define KEY_END
Definition: keycodes.hxx:115
tools::Rectangle maBtn2Rect
Definition: scrbar.hxx:43
void Scroll()
Definition: scrbar.cxx:1294
SAL_DLLPRIVATE void ImplCalc(bool bUpdate=true)
Definition: scrbar.cxx:232
long mnLineSize
Definition: scrbar.hxx:58
MapUnit GetMapUnit()
Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1185
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:940
ControlState mnThumbState
long mnThumbPos
Definition: scrbar.hxx:56
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1768
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:931
SAL_DLLPRIVATE long ImplDoAction(bool bCallEndScroll)
Definition: scrbar.cxx:690
bool IsModifierChanged() const
Definition: event.hxx:128
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: scrbar.cxx:1252
long Max() const
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:53
void SetFaceColor(const Color &rColor)
bool IsMouseOver() const
Definition: mouse.cxx:605
virtual void Resize() override
Definition: ctrl.cxx:74
#define KEY_DOWN
Definition: keycodes.hxx:110
long mnDelta
Definition: scrbar.hxx:60
long AdjustRight(long nHorzMoveDelta)
WindowType
Definition: ctrl.hxx:33
long GetRangeMax() const
Definition: scrbar.hxx:118
bool IsSynthetic() const
Definition: event.hxx:126
virtual void GetFocus()
Definition: window.cxx:1804
tools::Rectangle & Union(const tools::Rectangle &rRect)
const Color & GetButtonTextColor() const
bool mbCalcSize
Definition: scrbar.hxx:63
#define SCRBAR_STATE_BTN2_DISABLE
Definition: scrbar.cxx:58
const MouseEvent * GetMouseEvent() const
Definition: event.hxx:310
bool IsVisible() const
Definition: window2.cxx:1091
#define SAL_INFO(area, stream)
bool IsLeft() const
Definition: event.hxx:133
bool GetPrimaryButtonWarpsSlider() const
void SetBottom(long v)
long AdjustTop(long nVertMoveDelta)
sal_uInt16 mnStateFlags
Definition: scrbar.hxx:61
const Point & GetPosPixel() const
Definition: event.hxx:117
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: scrbar.cxx:1042
long Left() const
#define SCRBAR_STATE_PAGE2_DOWN
Definition: scrbar.cxx:60
#define SCRBAR_DRAW_BACKGROUND
Definition: scrbar.cxx:53
void ApplyControlBackground(vcl::RenderContext &rRenderContext, const Color &rDefaultColor)
Definition: window2.cxx:529
long mnMaxRange
Definition: scrbar.hxx:55
virtual vcl::Region GetActiveClipRegion() const override
#define KEY_HOME
Definition: keycodes.hxx:114
bool IsEnabled() const
Definition: window2.cxx:1111
void SetLeft(long v)
void DrawSymbol(const tools::Rectangle &rRect, SymbolType eType, const Color &rColor, DrawSymbolFlags nStyle=DrawSymbolFlags::NONE)
Definition: decoview.cxx:805
bool IsTrackingCanceled() const
Definition: event.hxx:256
WinBits GetStyle() const
Definition: window2.cxx:942
Definition: timer.hxx:26
SAL_DLLPRIVATE long ImplCalcThumbPosPix(long nPos)
Definition: scrbar.cxx:213
bool IsRight() const
Definition: event.hxx:137
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: scrbar.cxx:71
Point GetLastPointerPosPixel()
Definition: mouse.cxx:561
SAL_DLLPRIVATE long ImplScroll(long nNewPos, bool bCallEndScroll)
Definition: scrbar.cxx:674
#define SCRBAR_DRAW_THUMB
Definition: scrbar.cxx:52
long Min() const
long GetScrollBarSize() const
const MouseEvent & GetMouseEvent() const
Definition: event.hxx:250
bool IsReallyVisible() const
Definition: window2.cxx:1096
#define SCRBAR_DRAW_BTN1
Definition: scrbar.cxx:48
#define SCRBAR_DRAW_BTN2
Definition: scrbar.cxx:49
WinBits const WB_HORZ
bool HasFocus() const
Definition: window.cxx:2985
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: outdevstate.cxx:60
bool SupportsDoubleBuffering() const
Can the widget derived from this Window do the double-buffering via RenderContext properly...
Definition: window.cxx:3814
void setWidth(long nWidth)
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: scrbar.cxx:970
tools::Rectangle maThumbRect
#define SCRBAR_DRAW_PAGE1
Definition: scrbar.cxx:50
Point TopRight() const
#define KEY_RIGHT
Definition: keycodes.hxx:113
#define SCRBAR_STATE_BTN1_DOWN
Definition: scrbar.cxx:55
void SetThumbPos(long nThumbPos)
Definition: scrbar.cxx:1364
long Y() const
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:35
#define KEY_UP
Definition: keycodes.hxx:111
WinBits const WB_DRAG
void setHeight(long nHeight)