LibreOffice Module sd (master) 1
PresenterScrollBar.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
25#include "PresenterTimer.hxx"
27#include <com/sun/star/awt/PosSize.hpp>
28#include <com/sun/star/awt/XWindowPeer.hpp>
29#include <com/sun/star/rendering/CompositeOperation.hpp>
30#include <com/sun/star/rendering/XPolyPolygon2D.hpp>
31
32#include <algorithm>
33#include <memory>
34#include <utility>
35#include <math.h>
36
37using namespace ::com::sun::star;
38using namespace ::com::sun::star::uno;
39
40const double gnScrollBarGap (10);
41
42namespace sdext::presenter {
43
44//===== PresenterScrollBar::MousePressRepeater ================================
45
47 : public std::enable_shared_from_this<MousePressRepeater>
48{
49public:
51 void Dispose();
52 void Start (const PresenterScrollBar::Area& reArea);
53 void Stop();
54 void SetMouseArea (const PresenterScrollBar::Area& reArea);
55
56private:
57 void Callback ();
58 void Execute();
59
63};
64
65//===== PresenterScrollBar ====================================================
66
67std::weak_ptr<PresenterBitmapContainer> PresenterScrollBar::mpSharedBitmaps;
68
70 const Reference<XComponentContext>& rxComponentContext,
71 const Reference<awt::XWindow>& rxParentWindow,
72 std::shared_ptr<PresenterPaintManager> xPaintManager,
73 ::std::function<void (double)> aThumbMotionListener)
75 mxComponentContext(rxComponentContext),
76 mpPaintManager(std::move(xPaintManager)),
77 mnThumbPosition(0),
78 mnTotalSize(0),
79 mnThumbSize(0),
80 mnLineHeight(10),
81 maDragAnchor(-1,-1),
82 maThumbMotionListener(std::move(aThumbMotionListener)),
83 meButtonDownArea(None),
84 meMouseMoveArea(None),
85 mbIsNotificationActive(false),
86 mpMousePressRepeater(std::make_shared<MousePressRepeater>(this)),
87 mpCanvasHelper(new PresenterCanvasHelper())
88{
89 try
90 {
91 Reference<lang::XMultiComponentFactory> xFactory (rxComponentContext->getServiceManager());
92 if ( ! xFactory.is())
93 throw RuntimeException();
94
96 xFactory->createInstanceWithContext(
97 "com.sun.star.comp.Draw.PresenterHelper",
98 rxComponentContext),
99 UNO_QUERY_THROW);
100
101 if (mxPresenterHelper.is())
102 mxWindow = mxPresenterHelper->createWindow(rxParentWindow,
103 false,
104 false,
105 false,
106 false);
107
108 // Make the background transparent. The slide show paints its own background.
109 Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY_THROW);
110 xPeer->setBackground(0xff000000);
111
112 mxWindow->setVisible(true);
113 mxWindow->addWindowListener(this);
114 mxWindow->addPaintListener(this);
115 mxWindow->addMouseListener(this);
116 mxWindow->addMouseMotionListener(this);
117 }
118 catch (RuntimeException&)
119 {
120 }
121}
122
124{
125}
126
128{
129 mpMousePressRepeater->Dispose();
130
131 if (mxWindow.is())
132 {
133 mxWindow->removeWindowListener(this);
134 mxWindow->removePaintListener(this);
135 mxWindow->removeMouseListener(this);
136 mxWindow->removeMouseMotionListener(this);
137
138 Reference<lang::XComponent> xComponent = mxWindow;
139 mxWindow = nullptr;
140 if (xComponent.is())
141 xComponent->dispose();
142 }
143
144 mpBitmaps.reset();
145}
146
147void PresenterScrollBar::SetVisible (const bool bIsVisible)
148{
149 if (mxWindow.is())
150 mxWindow->setVisible(bIsVisible);
151}
152
153void PresenterScrollBar::SetPosSize (const css::geometry::RealRectangle2D& rBox)
154{
155 if (mxWindow.is())
156 {
157 mxWindow->setPosSize(
158 sal_Int32(floor(rBox.X1)),
159 sal_Int32(ceil(rBox.Y1)),
160 sal_Int32(ceil(rBox.X2-rBox.X1)),
161 sal_Int32(floor(rBox.Y2-rBox.Y1)),
162 awt::PosSize::POSSIZE);
164 }
165}
166
168 double nPosition,
169 const bool bAsynchronousUpdate)
170{
171 nPosition = ValidateThumbPosition(nPosition);
172
173 if (nPosition == mnThumbPosition || mbIsNotificationActive)
174 return;
175
176 mnThumbPosition = nPosition;
177
179 Repaint(GetRectangle(Total), bAsynchronousUpdate);
180
182 try
183 {
185 }
186 catch (Exception&)
187 {
188 }
190}
191
192
193void PresenterScrollBar::SetTotalSize (const double nTotalSize)
194{
195 if (mnTotalSize != nTotalSize)
196 {
197 mnTotalSize = nTotalSize + 1;
199 Repaint(GetRectangle(Total), false);
200 }
201}
202
203void PresenterScrollBar::SetThumbSize (const double nThumbSize)
204{
205 OSL_ASSERT(nThumbSize>=0);
206 if (mnThumbSize != nThumbSize)
207 {
208 mnThumbSize = nThumbSize;
210 Repaint(GetRectangle(Total), false);
211 }
212}
213
214
215void PresenterScrollBar::SetLineHeight (const double nLineHeight)
216{
217 mnLineHeight = nLineHeight;
218}
219
220
221void PresenterScrollBar::SetCanvas (const Reference<css::rendering::XCanvas>& rxCanvas)
222{
223 if (mxCanvas == rxCanvas)
224 return;
225
226 mxCanvas = rxCanvas;
227 if (!mxCanvas.is())
228 return;
229
230 if (mpBitmaps == nullptr)
231 {
232 mpBitmaps = mpSharedBitmaps.lock();
233 if (!mpBitmaps)
234 {
235 try
236 {
237 mpBitmaps = std::make_shared<PresenterBitmapContainer>(
238 "PresenterScreenSettings/ScrollBar/Bitmaps",
239 std::shared_ptr<PresenterBitmapContainer>(),
241 mxCanvas);
243 }
244 catch(Exception&)
245 {
246 OSL_ASSERT(false);
247 }
248 }
251 }
252
253 Repaint(GetRectangle(Total), false);
254}
255
257{
258 mpBackgroundBitmap = rpBackgroundBitmap;
259}
260
262{
264}
265
267{
268 if (nPosition + mnThumbSize > mnTotalSize)
269 nPosition = mnTotalSize - mnThumbSize;
270 if (nPosition < 0)
271 nPosition = 0;
272 return nPosition;
273}
274
276 const awt::Rectangle& rUpdateBox)
277{
278 if ( ! mxCanvas.is() || ! mxWindow.is())
279 {
280 OSL_ASSERT(mxCanvas.is());
281 OSL_ASSERT(mxWindow.is());
282 return;
283 }
284
285 if (PresenterGeometryHelper::AreRectanglesDisjoint (rUpdateBox, mxWindow->getPosSize()))
286 return;
287
288 PaintBackground(rUpdateBox);
289 PaintComposite(rUpdateBox, PagerUp,
291 PaintComposite(rUpdateBox, PagerDown,
293 PaintComposite(rUpdateBox, Thumb,
297
298 Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
299 if (xSpriteCanvas.is())
300 xSpriteCanvas->updateScreen(false);
301}
302
303//----- XWindowListener -------------------------------------------------------
304
305void SAL_CALL PresenterScrollBar::windowResized (const css::awt::WindowEvent&) {}
306
307void SAL_CALL PresenterScrollBar::windowMoved (const css::awt::WindowEvent&) {}
308
309void SAL_CALL PresenterScrollBar::windowShown (const css::lang::EventObject&) {}
310
311void SAL_CALL PresenterScrollBar::windowHidden (const css::lang::EventObject&) {}
312
313//----- XPaintListener --------------------------------------------------------
314
315void SAL_CALL PresenterScrollBar::windowPaint (const css::awt::PaintEvent& rEvent)
316{
317 if (mxWindow.is())
318 {
319 awt::Rectangle aRepaintBox (rEvent.UpdateRect);
320 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
321 aRepaintBox.X += aWindowBox.X;
322 aRepaintBox.Y += aWindowBox.Y;
323 Paint(aRepaintBox);
324
325 Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
326 if (xSpriteCanvas.is())
327 xSpriteCanvas->updateScreen(false);
328 }
329}
330
331//----- XMouseListener --------------------------------------------------------
332
333void SAL_CALL PresenterScrollBar::mousePressed (const css::awt::MouseEvent& rEvent)
334{
335 maDragAnchor.X = rEvent.X;
336 maDragAnchor.Y = rEvent.Y;
337 meButtonDownArea = GetArea(rEvent.X, rEvent.Y);
338
340}
341
342void SAL_CALL PresenterScrollBar::mouseReleased (const css::awt::MouseEvent&)
343{
344 mpMousePressRepeater->Stop();
345
346 if (mxPresenterHelper.is())
347 mxPresenterHelper->releaseMouse(mxWindow);
348}
349
350void SAL_CALL PresenterScrollBar::mouseEntered (const css::awt::MouseEvent&) {}
351
352void SAL_CALL PresenterScrollBar::mouseExited (const css::awt::MouseEvent&)
353{
354 if (meMouseMoveArea != None)
355 {
356 const Area eOldMouseMoveArea (meMouseMoveArea);
358 Repaint(GetRectangle(eOldMouseMoveArea), true);
359 }
362
363 mpMousePressRepeater->Stop();
364}
365
366//----- XMouseMotionListener --------------------------------------------------
367
368void SAL_CALL PresenterScrollBar::mouseMoved (const css::awt::MouseEvent& rEvent)
369{
370 const Area eArea (GetArea(rEvent.X, rEvent.Y));
371 if (eArea != meMouseMoveArea)
372 {
373 const Area eOldMouseMoveArea (meMouseMoveArea);
374 meMouseMoveArea = eArea;
375 if (eOldMouseMoveArea != None)
376 Repaint(GetRectangle(eOldMouseMoveArea), meMouseMoveArea==None);
377 if (meMouseMoveArea != None)
379 }
380 mpMousePressRepeater->SetMouseArea(eArea);
381}
382
383void SAL_CALL PresenterScrollBar::mouseDragged (const css::awt::MouseEvent& rEvent)
384{
385 if (meButtonDownArea != Thumb)
386 return;
387
388 mpMousePressRepeater->Stop();
389
390 if (mxPresenterHelper.is())
391 mxPresenterHelper->captureMouse(mxWindow);
392
393 const double nDragDistance (GetDragDistance(rEvent.X,rEvent.Y));
394 UpdateDragAnchor(nDragDistance);
395 if (nDragDistance != 0)
396 {
397 SetThumbPosition(mnThumbPosition + nDragDistance, false);
398 }
399}
400
401//----- lang::XEventListener --------------------------------------------------
402
403void SAL_CALL PresenterScrollBar::disposing (const css::lang::EventObject& rEvent)
404{
405 if (rEvent.Source == mxWindow)
406 mxWindow = nullptr;
407}
408
409
410geometry::RealRectangle2D const & PresenterScrollBar::GetRectangle (const Area eArea) const
411{
412 OSL_ASSERT(eArea>=0 && eArea<AreaCount);
413
414 return maBox[eArea];
415}
416
418 const geometry::RealRectangle2D& rBox,
419 const bool bAsynchronousUpdate)
420{
421 if (mpPaintManager != nullptr)
422 mpPaintManager->Invalidate(
423 mxWindow,
425 bAsynchronousUpdate);
426}
427
429 const css::awt::Rectangle& rUpdateBox)
430{
432 return;
433
434 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
435 mpCanvasHelper->Paint(
437 mxCanvas,
438 rUpdateBox,
439 aWindowBox,
440 awt::Rectangle());
441}
442
444 const css::awt::Rectangle& rUpdateBox,
445 const Area eArea,
446 const SharedBitmapDescriptor& rpBitmaps)
447{
448 const geometry::RealRectangle2D aLocalBox (GetRectangle(eArea));
449 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
450 geometry::RealRectangle2D aBox (aLocalBox);
451 aBox.X1 += aWindowBox.X;
452 aBox.Y1 += aWindowBox.Y;
453 aBox.X2 += aWindowBox.X;
454 aBox.Y2 += aWindowBox.Y;
455
456 Reference<rendering::XBitmap> xBitmap (GetBitmap(eArea,rpBitmaps));
457
458 if (!xBitmap.is())
459 return;
460
461 Reference<rendering::XPolyPolygon2D> xClipPolygon (
465 mxCanvas->getDevice()));
466
467 const rendering::ViewState aViewState (
468 geometry::AffineMatrix2D(1,0,0, 0,1,0),
469 xClipPolygon);
470
471 const geometry::IntegerSize2D aBitmapSize (xBitmap->getSize());
472 rendering::RenderState aRenderState (
473 geometry::AffineMatrix2D(
474 1,0,aBox.X1 + (aBox.X2-aBox.X1 - aBitmapSize.Width)/2,
475 0,1,aBox.Y1 + (aBox.Y2-aBox.Y1 - aBitmapSize.Height)/2),
476 nullptr,
477 Sequence<double>(4),
478 rendering::CompositeOperation::SOURCE);
479
480 mxCanvas->drawBitmap(
481 xBitmap,
482 aViewState,
483 aRenderState);
484}
485
486PresenterScrollBar::Area PresenterScrollBar::GetArea (const double nX, const double nY) const
487{
488 const geometry::RealPoint2D aPoint(nX, nY);
489
491 {
493 return Thumb;
495 return PagerUp;
497 return PagerDown;
498 }
500 return PrevButton;
502 return NextButton;
503
504 return None;
505}
506
508 sal_Int32& rSize,
509 const SharedBitmapDescriptor& rpDescriptor)
510{
511 if (rpDescriptor)
512 {
513 Reference<rendering::XBitmap> xBitmap (rpDescriptor->GetNormalBitmap());
514 if (xBitmap.is())
515 {
516 const geometry::IntegerSize2D aBitmapSize (xBitmap->getSize());
517 const sal_Int32 nBitmapSize = static_cast<sal_Int32>(GetMinor(aBitmapSize.Width, aBitmapSize.Height));
518 if (nBitmapSize > rSize)
519 rSize = nBitmapSize;
520 }
521 }
522}
523
524css::uno::Reference<css::rendering::XBitmap> PresenterScrollBar::GetBitmap (
525 const Area eArea,
526 const SharedBitmapDescriptor& rpBitmaps) const
527{
528 if (!rpBitmaps)
529 return nullptr;
530 else
531 return rpBitmaps->GetBitmap(GetBitmapMode(eArea));
532}
533
535 const Area eArea) const
536{
537 if (IsDisabled(eArea))
539 else if (eArea == meMouseMoveArea)
541 else
543}
544
545bool PresenterScrollBar::IsDisabled (const Area eArea) const
546{
547 OSL_ASSERT(eArea>=0 && eArea<AreaCount);
548
549 return ! maEnabledState[eArea];
550}
551
552//===== PresenterVerticalScrollBar ============================================
553
555 const Reference<XComponentContext>& rxComponentContext,
556 const Reference<awt::XWindow>& rxParentWindow,
557 const std::shared_ptr<PresenterPaintManager>& rpPaintManager,
558 const ::std::function<void (double)>& rThumbMotionListener)
559 : PresenterScrollBar(rxComponentContext, rxParentWindow, rpPaintManager, rThumbMotionListener),
560 mnScrollBarWidth(0)
561{
562}
563
565{
566}
567
568double PresenterVerticalScrollBar::GetDragDistance (const sal_Int32, const sal_Int32 nY) const
569{
570 const double nDistance (nY - maDragAnchor.Y);
571 if (nDistance == 0)
572 return 0;
573 else
574 {
575 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
576 const double nBarWidth (aWindowBox.Width);
577 const double nPagerHeight (aWindowBox.Height - 2*nBarWidth);
578 const double nDragDistance (mnTotalSize / nPagerHeight * nDistance);
579 if (nDragDistance + mnThumbPosition < 0)
580 return -mnThumbPosition;
581 else if (mnThumbPosition + nDragDistance > mnTotalSize-mnThumbSize)
583 else
584 return nDragDistance;
585 }
586}
587
588void PresenterVerticalScrollBar::UpdateDragAnchor (const double nDragDistance)
589{
590 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
591 const double nBarWidth (aWindowBox.Width);
592 const double nPagerHeight (aWindowBox.Height - 2*nBarWidth);
593 maDragAnchor.Y += nDragDistance * nPagerHeight / mnTotalSize;
594}
595
597{
598 return mnScrollBarWidth;
599}
600
601double PresenterVerticalScrollBar::GetMinor (const double nX, const double) const
602{
603 return nX;
604}
605
607{
608 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
609 double nBottom = aWindowBox.Height;
610
612 {
613 Reference<rendering::XBitmap> xBitmap (mpNextButtonDescriptor->GetNormalBitmap());
614 if (xBitmap.is())
615 {
616 geometry::IntegerSize2D aSize (xBitmap->getSize());
617 maBox[NextButton] = geometry::RealRectangle2D(
618 0, nBottom - aSize.Height, aWindowBox.Width, nBottom);
619 nBottom -= aSize.Height + gnScrollBarGap;
620 }
621 }
623 {
624 Reference<rendering::XBitmap> xBitmap (mpPrevButtonDescriptor->GetNormalBitmap());
625 if (xBitmap.is())
626 {
627 geometry::IntegerSize2D aSize (xBitmap->getSize());
628 maBox[PrevButton] = geometry::RealRectangle2D(
629 0, nBottom - aSize.Height, aWindowBox.Width, nBottom);
630 nBottom -= aSize.Height + gnScrollBarGap;
631 }
632 }
633 const double nPagerHeight (nBottom);
634 maBox[Pager] = geometry::RealRectangle2D(
635 0,0, aWindowBox.Width, nBottom);
636 if (mnTotalSize < 1)
637 {
639
640 // Set up the enabled/disabled states.
641 maEnabledState[PrevButton] = false;
642 maEnabledState[PagerUp] = false;
643 maEnabledState[NextButton] = false;
644 maEnabledState[PagerDown] = false;
645 maEnabledState[Thumb] = false;
646 }
647 else
648 {
649 const double nThumbSize = ::std::min(mnThumbSize,mnTotalSize);
650 const double nThumbPosition = ::std::clamp(mnThumbPosition, 0.0, mnTotalSize - nThumbSize);
651 maBox[Thumb] = geometry::RealRectangle2D(
652 0, nThumbPosition / mnTotalSize * nPagerHeight,
653 aWindowBox.Width,
654 (nThumbPosition+nThumbSize) / mnTotalSize * nPagerHeight);
655
656 // Set up the enabled/disabled states.
657 maEnabledState[PrevButton] = nThumbPosition>0;
658 maEnabledState[PagerUp] = nThumbPosition>0;
659 maEnabledState[NextButton] = nThumbPosition+nThumbSize < mnTotalSize;
660 maEnabledState[PagerDown] = nThumbPosition+nThumbSize < mnTotalSize;
661 maEnabledState[Thumb] = nThumbSize < mnTotalSize;
662 }
663 maBox[PagerUp] = geometry::RealRectangle2D(
665 maBox[PagerDown] = geometry::RealRectangle2D(
669 maBox[Pager]);
670}
671
673{
674 if (mpBitmaps == nullptr)
675 return;
676
677 mpPrevButtonDescriptor = mpBitmaps->GetBitmap("Up");
678 mpNextButtonDescriptor = mpBitmaps->GetBitmap("Down");
679 mpPagerStartDescriptor = mpBitmaps->GetBitmap("PagerTop");
680 mpPagerCenterDescriptor = mpBitmaps->GetBitmap("PagerVertical");
681 mpPagerEndDescriptor = mpBitmaps->GetBitmap("PagerBottom");
682 mpThumbStartDescriptor = mpBitmaps->GetBitmap("ThumbTop");
683 mpThumbCenterDescriptor = mpBitmaps->GetBitmap("ThumbVertical");
684 mpThumbEndDescriptor = mpBitmaps->GetBitmap("ThumbBottom");
685
695 if (mnScrollBarWidth == 0)
696 mnScrollBarWidth = 20;
697}
698
700 const css::awt::Rectangle& rUpdateBox,
701 const Area eArea,
702 const SharedBitmapDescriptor& rpStartBitmaps,
703 const SharedBitmapDescriptor& rpCenterBitmaps,
704 const SharedBitmapDescriptor& rpEndBitmaps)
705{
706 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
707 geometry::RealRectangle2D aBox (GetRectangle(eArea));
708 aBox.X1 += aWindowBox.X;
709 aBox.Y1 += aWindowBox.Y;
710 aBox.X2 += aWindowBox.X;
711 aBox.Y2 += aWindowBox.Y;
712
713 // Get bitmaps and sizes.
714
716 mxCanvas,
717 rUpdateBox,
718 (eArea == Thumb
721 GetBitmap(eArea, rpStartBitmaps),
722 GetBitmap(eArea, rpCenterBitmaps),
723 GetBitmap(eArea, rpEndBitmaps));
724}
725
726//===== PresenterScrollBar::MousePressRepeater ================================
727
730 : mnMousePressRepeaterTaskId(PresenterTimer::NotAValidTaskId),
731 mpScrollBar(std::move(xScrollBar)),
732 meMouseArea(PresenterScrollBar::None)
733{
734}
735
737{
738 Stop();
739 mpScrollBar = nullptr;
740}
741
743{
744 meMouseArea = reArea;
745
746 if (mnMousePressRepeaterTaskId == PresenterTimer::NotAValidTaskId)
747 {
748 // Execute key press operation at least this one time.
749 Execute();
750
751 // Schedule repeated executions.
752 auto pThis(shared_from_this());
753 mnMousePressRepeaterTaskId = PresenterTimer::ScheduleRepeatedTask (
754 mpScrollBar->GetComponentContext(),
755 [pThis] (TimeValue const&) { return pThis->Callback(); },
756 500000000,
757 250000000);
758 }
759 else
760 {
761 // There is already an active repeating task.
762 }
763}
764
766{
767 if (mnMousePressRepeaterTaskId != PresenterTimer::NotAValidTaskId)
768 {
769 const sal_Int32 nTaskId (mnMousePressRepeaterTaskId);
770 mnMousePressRepeaterTaskId = PresenterTimer::NotAValidTaskId;
772 }
773}
774
776{
777 if (meMouseArea != reArea)
778 {
779 if (mnMousePressRepeaterTaskId != PresenterTimer::NotAValidTaskId)
780 {
781 Stop();
782 }
783 }
784}
785
787{
788 if (!mpScrollBar)
789 {
790 Stop();
791 return;
792 }
793
794 Execute();
795}
796
798{
799 const double nThumbPosition (mpScrollBar->GetThumbPosition());
800 switch (meMouseArea)
801 {
802 case PrevButton:
803 mpScrollBar->SetThumbPosition(nThumbPosition - mpScrollBar->GetLineHeight(), true);
804 break;
805
806 case NextButton:
807 mpScrollBar->SetThumbPosition(nThumbPosition + mpScrollBar->GetLineHeight(), true);
808 break;
809
810 case PagerUp:
811 mpScrollBar->SetThumbPosition(nThumbPosition - mpScrollBar->GetThumbSize()*0.8, true);
812 break;
813
814 case PagerDown:
815 mpScrollBar->SetThumbPosition(nThumbPosition + mpScrollBar->GetThumbSize()*0.8, true);
816 break;
817
818 default:
819 break;
820 }
821}
822
823} // end of namespace ::sdext::presenter
824
825/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
const double gnScrollBarGap(10)
Collection of functions to ease the life of a canvas user.
static css::geometry::RealRectangle2D Union(const css::geometry::RealRectangle2D &rBox1, const css::geometry::RealRectangle2D &rBox2)
static bool AreRectanglesDisjoint(const css::awt::Rectangle &rBox1, const css::awt::Rectangle &rBox2)
static bool IsInside(const css::geometry::RealRectangle2D &rBox, const css::geometry::RealPoint2D &rPoint)
static css::awt::Rectangle Intersection(const css::awt::Rectangle &rBox1, const css::awt::Rectangle &rBox2)
static css::awt::Rectangle ConvertRectangleWithConstantSize(const css::geometry::RealRectangle2D &rBox)
Convert the given rectangle to integer coordinates so that width and height remain constant when only...
static css::uno::Reference< css::rendering::XPolyPolygon2D > CreatePolygon(const css::awt::Rectangle &rBox, const css::uno::Reference< css::rendering::XGraphicDevice > &rxDevice)
static css::awt::Rectangle ConvertRectangle(const css::geometry::RealRectangle2D &rBox)
Return the bounding box with integer coordinates of the given rectangle.
void SetMouseArea(const PresenterScrollBar::Area &reArea)
void Start(const PresenterScrollBar::Area &reArea)
MousePressRepeater(::rtl::Reference< PresenterScrollBar > xScrollBar)
Base class of horizontal and vertical scroll bars.
virtual void UpdateDragAnchor(const double nDragDistance)=0
std::shared_ptr< PresenterBitmapContainer > mpBitmaps
void SetPosSize(const css::geometry::RealRectangle2D &rBox)
Set the bounding box of the scroll bar.
Area GetArea(const double nX, const double nY) const
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
virtual double GetDragDistance(const sal_Int32 nX, const sal_Int32 nY) const =0
css::uno::Reference< css::awt::XWindow > mxWindow
void SetThumbSize(const double nThumbSize)
Set the size of the movable thumb.
virtual double GetMinor(const double nX, const double nY) const =0
css::geometry::RealRectangle2D const & GetRectangle(const Area eArea) const
void Paint(const css::awt::Rectangle &rUpdateBox)
On some occasions it is necessary to trigger the painting of a scrollbar from the outside.
std::shared_ptr< MousePressRepeater > mpMousePressRepeater
virtual void SAL_CALL mouseEntered(const css::awt::MouseEvent &rEvent) override
css::uno::Reference< css::rendering::XCanvas > mxCanvas
virtual void SAL_CALL mousePressed(const css::awt::MouseEvent &rEvent) override
virtual void SAL_CALL windowShown(const css::lang::EventObject &rEvent) override
void SetThumbPosition(double nPosition, const bool bAsynchronousRepaint)
Set the position of the movable thumb.
virtual void SAL_CALL windowPaint(const css::awt::PaintEvent &rEvent) override
css::geometry::RealRectangle2D maBox[AreaCount]
static std::weak_ptr< PresenterBitmapContainer > mpSharedBitmaps
std::shared_ptr< PresenterPaintManager > mpPaintManager
void Repaint(const css::geometry::RealRectangle2D &rBox, const bool bAsynchronous)
virtual void SAL_CALL mouseMoved(const css::awt::MouseEvent &rEvent) override
virtual void SAL_CALL mouseExited(const css::awt::MouseEvent &rEvent) override
void UpdateWidthOrHeight(sal_Int32 &rSize, const SharedBitmapDescriptor &rpDescriptor)
std::unique_ptr< PresenterCanvasHelper > mpCanvasHelper
PresenterBitmapContainer::BitmapDescriptor::Mode GetBitmapMode(const Area eArea) const
PresenterScrollBar(const PresenterScrollBar &)=delete
virtual void SAL_CALL windowResized(const css::awt::WindowEvent &rEvent) override
virtual void SAL_CALL windowHidden(const css::lang::EventObject &rEvent) override
css::uno::Reference< css::drawing::XPresenterHelper > mxPresenterHelper
virtual void SAL_CALL windowMoved(const css::awt::WindowEvent &rEvent) override
void SetVisible(const bool bIsVisible)
void PaintBitmap(const css::awt::Rectangle &rRepaintBox, const Area eArea, const SharedBitmapDescriptor &rpBitmaps)
bool IsDisabled(const Area eArea) const
virtual void SAL_CALL mouseReleased(const css::awt::MouseEvent &rEvent) override
virtual void SAL_CALL mouseDragged(const css::awt::MouseEvent &rEvent) override
SharedBitmapDescriptor mpPagerCenterDescriptor
void SetBackground(const SharedBitmapDescriptor &rpBackgroundBitmap)
double ValidateThumbPosition(double nPosition)
void SetTotalSize(const double nTotalSize)
Set the upper border of the slider range.
::std::function< void(double)> maThumbMotionListener
void SetLineHeight(const double nLineHeight)
css::uno::Reference< css::rendering::XBitmap > GetBitmap(const Area eArea, const SharedBitmapDescriptor &rpBitmaps) const
void CheckValues()
Call this after changing total size or thumb position or size to move the thumb to a valid position.
void SetCanvas(const css::uno::Reference< css::rendering::XCanvas > &rxCanvas)
Set the canvas that is used for painting the scroll bar.
void PaintBackground(const css::awt::Rectangle &rRepaintBox)
virtual void PaintComposite(const css::awt::Rectangle &rRepaintBox, const Area eArea, const SharedBitmapDescriptor &rpStartBitmaps, const SharedBitmapDescriptor &rpCenterBitmaps, const SharedBitmapDescriptor &rpEndBitmaps)=0
SharedBitmapDescriptor mpThumbCenterDescriptor
css::geometry::RealPoint2D maDragAnchor
virtual void SAL_CALL disposing() override
The timer allows tasks to be scheduled for execution at a specified time in the future.
static void CancelTask(const sal_Int32 nTaskId)
static const sal_Int32 NotAValidTaskId
static sal_Int32 ScheduleRepeatedTask(const css::uno::Reference< css::uno::XComponentContext > &xContext, const Task &rTask, const sal_Int64 nFirst, const sal_Int64 nInterval)
Schedule a task to be executed repeatedly.
static void PaintVerticalBitmapComposite(const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const css::awt::Rectangle &rRepaintBox, const css::awt::Rectangle &rBoundingBox, const css::uno::Reference< css::rendering::XBitmap > &rxTopBitmap, const css::uno::Reference< css::rendering::XBitmap > &rxRepeatableCenterBitmap, const css::uno::Reference< css::rendering::XBitmap > &rxBottomBitmap)
PresenterVerticalScrollBar(const css::uno::Reference< css::uno::XComponentContext > &rxComponentContext, const css::uno::Reference< css::awt::XWindow > &rxParentWindow, const std::shared_ptr< PresenterPaintManager > &rpPaintManager, const ::std::function< void(double)> &rThumbMotionListener)
virtual sal_Int32 GetSize() const override
virtual void PaintComposite(const css::awt::Rectangle &rRepaintBox, const Area eArea, const SharedBitmapDescriptor &rpStartBitmaps, const SharedBitmapDescriptor &rpCenterBitmaps, const SharedBitmapDescriptor &rpEndBitmaps) override
virtual double GetDragDistance(const sal_Int32 nX, const sal_Int32 nY) const override
virtual double GetMinor(const double nX, const double nY) const override
virtual void UpdateDragAnchor(const double nDragDistance) override
aCursorMoveIdle Stop()
Reference< XSingleServiceFactory > xFactory
std::mutex m_aMutex
@ Exception
std::shared_ptr< T > make_shared(Args &&... args)
None
::cppu::WeakComponentImplHelper< css::awt::XWindowListener, css::awt::XPaintListener, css::awt::XMouseListener, css::awt::XMouseMotionListener > PresenterScrollBarInterfaceBase
std::shared_ptr< PresenterBitmapContainer::BitmapDescriptor > SharedBitmapDescriptor
const ::avmedia::MediaItem * Execute(const SdrMarkView *pSdrView, SfxRequest const &rReq)