1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sdext.hxx"
26
27 #include "PresenterScrollBar.hxx"
28 #include "PresenterBitmapContainer.hxx"
29 #include "PresenterCanvasHelper.hxx"
30 #include "PresenterGeometryHelper.hxx"
31 #include "PresenterPaintManager.hxx"
32 #include "PresenterTimer.hxx"
33 #include "PresenterUIPainter.hxx"
34 #include <com/sun/star/awt/PosSize.hpp>
35 #include <com/sun/star/awt/WindowAttribute.hpp>
36 #include <com/sun/star/awt/XWindowPeer.hpp>
37 #include <com/sun/star/awt/XToolkit.hpp>
38 #include <com/sun/star/rendering/CompositeOperation.hpp>
39 #include <com/sun/star/rendering/TexturingMode.hpp>
40 #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
41 #include <boost/bind.hpp>
42 #include <boost/enable_shared_from_this.hpp>
43 #include <boost/weak_ptr.hpp>
44 #include <math.h>
45
46 using namespace ::com::sun::star;
47 using namespace ::com::sun::star::uno;
48 using ::rtl::OUString;
49
50 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
51
52 const static double gnScrollBarGap (10);
53
54 namespace sdext { namespace presenter {
55
56 //===== PresenterScrollBar::MousePressRepeater ================================
57
58 class PresenterScrollBar::MousePressRepeater
59 : public ::boost::enable_shared_from_this<MousePressRepeater>
60 {
61 public:
62 MousePressRepeater (const ::rtl::Reference<PresenterScrollBar>& rpScrollBar);
63 void Dispose (void);
64 void Start (const PresenterScrollBar::Area& reArea);
65 void Stop (void);
66 void SetMouseArea (const PresenterScrollBar::Area& reArea);
67
68 private:
69 void Callback (const TimeValue& rCurrentTime);
70 void Execute (void);
71
72 sal_Int32 mnMousePressRepeaterTaskId;
73 ::rtl::Reference<PresenterScrollBar> mpScrollBar;
74 PresenterScrollBar::Area meMouseArea;
75 };
76
77
78
79
80 //===== PresenterScrollBar ====================================================
81
82 boost::weak_ptr<PresenterBitmapContainer> PresenterScrollBar::mpSharedBitmaps;
83
PresenterScrollBar(const Reference<XComponentContext> & rxComponentContext,const Reference<awt::XWindow> & rxParentWindow,const::boost::shared_ptr<PresenterPaintManager> & rpPaintManager,const::boost::function<void (double)> & rThumbMotionListener)84 PresenterScrollBar::PresenterScrollBar (
85 const Reference<XComponentContext>& rxComponentContext,
86 const Reference<awt::XWindow>& rxParentWindow,
87 const ::boost::shared_ptr<PresenterPaintManager>& rpPaintManager,
88 const ::boost::function<void(double)>& rThumbMotionListener)
89 : PresenterScrollBarInterfaceBase(m_aMutex),
90 mxComponentContext(rxComponentContext),
91 mxParentWindow(rxParentWindow),
92 mxWindow(),
93 mxCanvas(),
94 mxPresenterHelper(),
95 mpPaintManager(rpPaintManager),
96 mnThumbPosition(0),
97 mnTotalSize(0),
98 mnThumbSize(0),
99 mnLineHeight(10),
100 maDragAnchor(-1,-1),
101 maThumbMotionListener(rThumbMotionListener),
102 meButtonDownArea(None),
103 meMouseMoveArea(None),
104 mbIsNotificationActive(false),
105 mpBitmaps(),
106 mpPrevButtonDescriptor(),
107 mpNextButtonDescriptor(),
108 mpPagerStartDescriptor(),
109 mpPagerCenterDescriptor(),
110 mpPagerEndDescriptor(),
111 mpThumbStartDescriptor(),
112 mpThumbCenterDescriptor(),
113 mpThumbEndDescriptor(),
114 mpMousePressRepeater(new MousePressRepeater(this)),
115 mpBackgroundBitmap(),
116 mpCanvasHelper(new PresenterCanvasHelper())
117 {
118 try
119 {
120 Reference<lang::XMultiComponentFactory> xFactory (rxComponentContext->getServiceManager());
121 if ( ! xFactory.is())
122 throw RuntimeException();
123
124 mxPresenterHelper = Reference<drawing::XPresenterHelper>(
125 xFactory->createInstanceWithContext(
126 OUString::createFromAscii("com.sun.star.comp.Draw.PresenterHelper"),
127 rxComponentContext),
128 UNO_QUERY_THROW);
129
130 if (mxPresenterHelper.is())
131 mxWindow = mxPresenterHelper->createWindow(rxParentWindow,
132 sal_False,
133 sal_False,
134 sal_False,
135 sal_False);
136
137 // Make the background transparent. The slide show paints its own background.
138 Reference<awt::XWindowPeer> xPeer (mxWindow, UNO_QUERY_THROW);
139 if (xPeer.is())
140 {
141 xPeer->setBackground(0xff000000);
142 }
143
144 mxWindow->setVisible(sal_True);
145 mxWindow->addWindowListener(this);
146 mxWindow->addPaintListener(this);
147 mxWindow->addMouseListener(this);
148 mxWindow->addMouseMotionListener(this);
149 }
150 catch (RuntimeException&)
151 {
152 }
153 }
154
155
156
157
~PresenterScrollBar(void)158 PresenterScrollBar::~PresenterScrollBar (void)
159 {
160 }
161
162
163
164
disposing(void)165 void SAL_CALL PresenterScrollBar::disposing (void)
166 {
167 mpMousePressRepeater->Dispose();
168
169 if (mxWindow.is())
170 {
171 mxWindow->removeWindowListener(this);
172 mxWindow->removePaintListener(this);
173 mxWindow->removeMouseListener(this);
174 mxWindow->removeMouseMotionListener(this);
175
176 Reference<lang::XComponent> xComponent (mxWindow, UNO_QUERY);
177 mxWindow = NULL;
178 if (xComponent.is())
179 xComponent->dispose();
180 }
181
182 mpBitmaps.reset();
183 }
184
185
186
187
SetVisible(const bool bIsVisible)188 void PresenterScrollBar::SetVisible (const bool bIsVisible)
189 {
190 if (mxWindow.is())
191 mxWindow->setVisible(bIsVisible);
192 }
193
194
195
196
SetPosSize(const css::geometry::RealRectangle2D & rBox)197 void PresenterScrollBar::SetPosSize (const css::geometry::RealRectangle2D& rBox)
198 {
199 if (mxWindow.is())
200 {
201 mxWindow->setPosSize(
202 sal_Int32(floor(rBox.X1)),
203 sal_Int32(ceil(rBox.Y1)),
204 sal_Int32(ceil(rBox.X2-rBox.X1)),
205 sal_Int32(floor(rBox.Y2-rBox.Y1)),
206 awt::PosSize::POSSIZE);
207 UpdateBorders();
208 }
209 }
210
211
212
213
SetThumbPosition(double nPosition,const bool bAsynchronousUpdate)214 void PresenterScrollBar::SetThumbPosition (
215 double nPosition,
216 const bool bAsynchronousUpdate)
217 {
218 SetThumbPosition(nPosition, bAsynchronousUpdate, true, true);
219 }
220
221
222
223
SetThumbPosition(double nPosition,const bool bAsynchronousUpdate,const bool bValidate,const bool bNotify)224 void PresenterScrollBar::SetThumbPosition (
225 double nPosition,
226 const bool bAsynchronousUpdate,
227 const bool bValidate,
228 const bool bNotify)
229 {
230 if (bValidate)
231 nPosition = ValidateThumbPosition(nPosition);
232
233 if (nPosition != mnThumbPosition && ! mbIsNotificationActive)
234 {
235 mnThumbPosition = nPosition;
236
237 UpdateBorders();
238 Repaint(GetRectangle(Total), bAsynchronousUpdate);
239 if (bNotify)
240 NotifyThumbPositionChange();
241 }
242 }
243
244
245
246
GetThumbPosition(void) const247 double PresenterScrollBar::GetThumbPosition (void) const
248 {
249 return mnThumbPosition;
250 }
251
252
253
254
SetTotalSize(const double nTotalSize)255 void PresenterScrollBar::SetTotalSize (const double nTotalSize)
256 {
257 if (mnTotalSize != nTotalSize)
258 {
259 mnTotalSize = nTotalSize + 1;
260 UpdateBorders();
261 Repaint(GetRectangle(Total), false);
262 }
263 }
264
265
266
267
GetTotalSize(void) const268 double PresenterScrollBar::GetTotalSize (void) const
269 {
270 return mnTotalSize;
271 }
272
273
274
275
SetThumbSize(const double nThumbSize)276 void PresenterScrollBar::SetThumbSize (const double nThumbSize)
277 {
278 OSL_ASSERT(nThumbSize>=0);
279 if (mnThumbSize != nThumbSize)
280 {
281 mnThumbSize = nThumbSize;
282 UpdateBorders();
283 Repaint(GetRectangle(Total), false);
284 }
285 }
286
287
288
289
GetThumbSize(void) const290 double PresenterScrollBar::GetThumbSize (void) const
291 {
292 return mnThumbSize;
293 }
294
295
296
297
SetLineHeight(const double nLineHeight)298 void PresenterScrollBar::SetLineHeight (const double nLineHeight)
299 {
300 mnLineHeight = nLineHeight;
301 }
302
303
304
305
GetLineHeight(void) const306 double PresenterScrollBar::GetLineHeight (void) const
307 {
308 return mnLineHeight;
309 }
310
311
312
313
SetCanvas(const Reference<css::rendering::XCanvas> & rxCanvas)314 void PresenterScrollBar::SetCanvas (const Reference<css::rendering::XCanvas>& rxCanvas)
315 {
316 if (mxCanvas != rxCanvas)
317 {
318 mxCanvas = rxCanvas;
319 if (mxCanvas.is())
320 {
321 if (mpBitmaps.get()==NULL)
322 {
323 if (mpSharedBitmaps.expired())
324 {
325 try
326 {
327 mpBitmaps.reset(new PresenterBitmapContainer(
328 OUString::createFromAscii("PresenterScreenSettings/ScrollBar/Bitmaps"),
329 ::boost::shared_ptr<PresenterBitmapContainer>(),
330 mxComponentContext,
331 mxCanvas));
332 mpSharedBitmaps = mpBitmaps;
333 }
334 catch(Exception&)
335 {
336 OSL_ASSERT(false);
337 }
338 }
339 else
340 mpBitmaps = ::boost::shared_ptr<PresenterBitmapContainer>(mpSharedBitmaps);
341 UpdateBitmaps();
342 UpdateBorders();
343 }
344
345 Repaint(GetRectangle(Total), false);
346 }
347 }
348 }
349
350
351
352
SetBackground(const SharedBitmapDescriptor & rpBackgroundBitmap)353 void PresenterScrollBar::SetBackground (const SharedBitmapDescriptor& rpBackgroundBitmap)
354 {
355 mpBackgroundBitmap = rpBackgroundBitmap;
356 }
357
358
359
CheckValues(void)360 void PresenterScrollBar::CheckValues (void)
361 {
362 mnThumbPosition = ValidateThumbPosition(mnThumbPosition);
363 }
364
365
366
367
ValidateThumbPosition(double nPosition)368 double PresenterScrollBar::ValidateThumbPosition (double nPosition)
369 {
370 if (nPosition + mnThumbSize > mnTotalSize)
371 nPosition = mnTotalSize - mnThumbSize;
372 if (nPosition < 0)
373 nPosition = 0;
374 return nPosition;
375 }
376
377
378
379
Paint(const awt::Rectangle & rUpdateBox,const bool bNoClip)380 void PresenterScrollBar::Paint (
381 const awt::Rectangle& rUpdateBox,
382 const bool bNoClip)
383 {
384 if ( ! mxCanvas.is() || ! mxWindow.is())
385 {
386 OSL_ASSERT(mxCanvas.is());
387 OSL_ASSERT(mxWindow.is());
388 return;
389 }
390
391 if ( ! bNoClip)
392 {
393 if (PresenterGeometryHelper::AreRectanglesDisjoint (rUpdateBox, mxWindow->getPosSize()))
394 return;
395 }
396
397 PaintBackground(rUpdateBox);
398 PaintComposite(rUpdateBox, PagerUp,
399 mpPagerStartDescriptor, mpPagerCenterDescriptor, SharedBitmapDescriptor());
400 PaintComposite(rUpdateBox, PagerDown,
401 SharedBitmapDescriptor(), mpPagerCenterDescriptor, mpPagerEndDescriptor);
402 PaintComposite(rUpdateBox, Thumb,
403 mpThumbStartDescriptor, mpThumbCenterDescriptor, mpThumbEndDescriptor);
404 PaintBitmap(rUpdateBox, PrevButton, mpPrevButtonDescriptor);
405 PaintBitmap(rUpdateBox, NextButton, mpNextButtonDescriptor);
406
407 Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
408 if (xSpriteCanvas.is())
409 xSpriteCanvas->updateScreen(sal_False);
410 }
411
412
413
414
415
416
417 //----- XWindowListener -------------------------------------------------------
418
windowResized(const css::awt::WindowEvent & rEvent)419 void SAL_CALL PresenterScrollBar::windowResized (const css::awt::WindowEvent& rEvent)
420 {
421 (void)rEvent;
422 }
423
424
425
426
427
windowMoved(const css::awt::WindowEvent & rEvent)428 void SAL_CALL PresenterScrollBar::windowMoved (const css::awt::WindowEvent& rEvent)
429 {
430 (void)rEvent;
431 }
432
433
434
435
windowShown(const css::lang::EventObject & rEvent)436 void SAL_CALL PresenterScrollBar::windowShown (const css::lang::EventObject& rEvent)
437 {
438 (void)rEvent;
439 }
440
441
442
443
windowHidden(const css::lang::EventObject & rEvent)444 void SAL_CALL PresenterScrollBar::windowHidden (const css::lang::EventObject& rEvent)
445 {
446 (void)rEvent;
447 }
448
449
450
451
452 //----- XPaintListener --------------------------------------------------------
453
windowPaint(const css::awt::PaintEvent & rEvent)454 void SAL_CALL PresenterScrollBar::windowPaint (const css::awt::PaintEvent& rEvent)
455 {
456 if (mxWindow.is())
457 {
458 awt::Rectangle aRepaintBox (rEvent.UpdateRect);
459 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
460 aRepaintBox.X += aWindowBox.X;
461 aRepaintBox.Y += aWindowBox.Y;
462 Paint(aRepaintBox);
463
464 Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
465 if (xSpriteCanvas.is())
466 xSpriteCanvas->updateScreen(sal_False);
467 }
468 }
469
470
471
472
473 //----- XMouseListener --------------------------------------------------------
474
mousePressed(const css::awt::MouseEvent & rEvent)475 void SAL_CALL PresenterScrollBar::mousePressed (const css::awt::MouseEvent& rEvent)
476 {
477 maDragAnchor.X = rEvent.X;
478 maDragAnchor.Y = rEvent.Y;
479 meButtonDownArea = GetArea(rEvent.X, rEvent.Y);
480
481 mpMousePressRepeater->Start(meButtonDownArea);
482 }
483
484
485
486
mouseReleased(const css::awt::MouseEvent & rEvent)487 void SAL_CALL PresenterScrollBar::mouseReleased (const css::awt::MouseEvent& rEvent)
488 {
489 (void)rEvent;
490
491 mpMousePressRepeater->Stop();
492
493 if (mxPresenterHelper.is())
494 mxPresenterHelper->releaseMouse(mxWindow);
495 }
496
497
498
499
mouseEntered(const css::awt::MouseEvent & rEvent)500 void SAL_CALL PresenterScrollBar::mouseEntered (const css::awt::MouseEvent& rEvent)
501 {
502 (void)rEvent;
503 }
504
505
506
507
mouseExited(const css::awt::MouseEvent & rEvent)508 void SAL_CALL PresenterScrollBar::mouseExited (const css::awt::MouseEvent& rEvent)
509 {
510 (void)rEvent;
511 if (meMouseMoveArea != None)
512 {
513 const Area eOldMouseMoveArea (meMouseMoveArea);
514 meMouseMoveArea = None;
515 Repaint(GetRectangle(eOldMouseMoveArea), true);
516 }
517 meButtonDownArea = None;
518 meMouseMoveArea = None;
519
520 mpMousePressRepeater->Stop();
521 }
522
523
524
525
526
527 //----- XMouseMotionListener --------------------------------------------------
528
mouseMoved(const css::awt::MouseEvent & rEvent)529 void SAL_CALL PresenterScrollBar::mouseMoved (const css::awt::MouseEvent& rEvent)
530 {
531 const Area eArea (GetArea(rEvent.X, rEvent.Y));
532 if (eArea != meMouseMoveArea)
533 {
534 const Area eOldMouseMoveArea (meMouseMoveArea);
535 meMouseMoveArea = eArea;
536 if (eOldMouseMoveArea != None)
537 Repaint(GetRectangle(eOldMouseMoveArea), meMouseMoveArea==None);
538 if (meMouseMoveArea != None)
539 Repaint(GetRectangle(meMouseMoveArea), true);
540 }
541 mpMousePressRepeater->SetMouseArea(eArea);
542 }
543
544
545
546
mouseDragged(const css::awt::MouseEvent & rEvent)547 void SAL_CALL PresenterScrollBar::mouseDragged (const css::awt::MouseEvent& rEvent)
548 {
549 if (meButtonDownArea != Thumb)
550 return;
551
552 mpMousePressRepeater->Stop();
553
554 if (mxPresenterHelper.is())
555 mxPresenterHelper->captureMouse(mxWindow);
556
557 const double nDragDistance (GetDragDistance(rEvent.X,rEvent.Y));
558 UpdateDragAnchor(nDragDistance);
559 if (nDragDistance != 0)
560 {
561 SetThumbPosition(mnThumbPosition + nDragDistance, false, true, true);
562 }
563 }
564
565
566
567
568 //----- lang::XEventListener --------------------------------------------------
569
disposing(const css::lang::EventObject & rEvent)570 void SAL_CALL PresenterScrollBar::disposing (const css::lang::EventObject& rEvent)
571 {
572 if (rEvent.Source == mxWindow)
573 mxWindow = NULL;
574 }
575
576
577
578
579 //-----------------------------------------------------------------------------
580
GetRectangle(const Area eArea) const581 geometry::RealRectangle2D PresenterScrollBar::GetRectangle (const Area eArea) const
582 {
583 OSL_ASSERT(eArea>=0 && eArea<__AreaCount__);
584
585 return maBox[eArea];
586 }
587
588
589
590
Repaint(const geometry::RealRectangle2D aBox,const bool bAsynchronousUpdate)591 void PresenterScrollBar::Repaint (
592 const geometry::RealRectangle2D aBox,
593 const bool bAsynchronousUpdate)
594 {
595 if (mpPaintManager.get() != NULL)
596 mpPaintManager->Invalidate(
597 mxWindow,
598 PresenterGeometryHelper::ConvertRectangle(aBox),
599 bAsynchronousUpdate);
600 }
601
602
603
604
PaintBackground(const css::awt::Rectangle & rUpdateBox)605 void PresenterScrollBar::PaintBackground(
606 const css::awt::Rectangle& rUpdateBox)
607 {
608 if (mpBackgroundBitmap.get() == NULL)
609 return;
610
611 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
612 mpCanvasHelper->Paint(
613 mpBackgroundBitmap,
614 mxCanvas,
615 rUpdateBox,
616 aWindowBox,
617 awt::Rectangle());
618 }
619
620
621
622
PaintBitmap(const css::awt::Rectangle & rUpdateBox,const Area eArea,const SharedBitmapDescriptor & rpBitmaps)623 void PresenterScrollBar::PaintBitmap(
624 const css::awt::Rectangle& rUpdateBox,
625 const Area eArea,
626 const SharedBitmapDescriptor& rpBitmaps)
627 {
628 const geometry::RealRectangle2D aLocalBox (GetRectangle(eArea));
629 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
630 geometry::RealRectangle2D aBox (aLocalBox);
631 aBox.X1 += aWindowBox.X;
632 aBox.Y1 += aWindowBox.Y;
633 aBox.X2 += aWindowBox.X;
634 aBox.Y2 += aWindowBox.Y;
635
636 Reference<rendering::XBitmap> xBitmap (GetBitmap(eArea,rpBitmaps));
637
638 if (xBitmap.is())
639 {
640 Reference<rendering::XPolyPolygon2D> xClipPolygon (
641 PresenterGeometryHelper::CreatePolygon(
642 PresenterGeometryHelper::Intersection(rUpdateBox,
643 PresenterGeometryHelper::ConvertRectangle(aBox)),
644 mxCanvas->getDevice()));
645
646 const rendering::ViewState aViewState (
647 geometry::AffineMatrix2D(1,0,0, 0,1,0),
648 xClipPolygon);
649
650 const geometry::IntegerSize2D aBitmapSize (xBitmap->getSize());
651 rendering::RenderState aRenderState (
652 geometry::AffineMatrix2D(
653 1,0,aBox.X1 + (aBox.X2-aBox.X1 - aBitmapSize.Width)/2,
654 0,1,aBox.Y1 + (aBox.Y2-aBox.Y1 - aBitmapSize.Height)/2),
655 NULL,
656 Sequence<double>(4),
657 rendering::CompositeOperation::SOURCE);
658
659 mxCanvas->drawBitmap(
660 xBitmap,
661 aViewState,
662 aRenderState);
663 }
664 }
665
666
667
668
NotifyThumbPositionChange(void)669 void PresenterScrollBar::NotifyThumbPositionChange (void)
670 {
671 if ( ! mbIsNotificationActive)
672 {
673 mbIsNotificationActive = true;
674
675 try
676 {
677 maThumbMotionListener(mnThumbPosition);
678 }
679 catch (Exception&)
680 {
681 }
682
683 mbIsNotificationActive = false;
684 }
685 }
686
687
688
689
GetArea(const double nX,const double nY) const690 PresenterScrollBar::Area PresenterScrollBar::GetArea (const double nX, const double nY) const
691 {
692 const geometry::RealPoint2D aPoint(nX, nY);
693
694 if (PresenterGeometryHelper::IsInside(GetRectangle(Pager), aPoint))
695 {
696 if (PresenterGeometryHelper::IsInside(GetRectangle(Thumb), aPoint))
697 return Thumb;
698 else if (PresenterGeometryHelper::IsInside(GetRectangle(PagerUp), aPoint))
699 return PagerUp;
700 else if (PresenterGeometryHelper::IsInside(GetRectangle(PagerDown), aPoint))
701 return PagerDown;
702 }
703 else if (PresenterGeometryHelper::IsInside(GetRectangle(PrevButton), aPoint))
704 return PrevButton;
705 else if (PresenterGeometryHelper::IsInside(GetRectangle(NextButton), aPoint))
706 return NextButton;
707
708 return None;
709 }
710
711
712
713
UpdateWidthOrHeight(sal_Int32 & rSize,const SharedBitmapDescriptor & rpDescriptor)714 void PresenterScrollBar::UpdateWidthOrHeight (
715 sal_Int32& rSize,
716 const SharedBitmapDescriptor& rpDescriptor)
717 {
718 if (rpDescriptor.get() != NULL)
719 {
720 Reference<rendering::XBitmap> xBitmap (rpDescriptor->GetNormalBitmap());
721 if (xBitmap.is())
722 {
723 const geometry::IntegerSize2D aBitmapSize (xBitmap->getSize());
724 const sal_Int32 nBitmapSize = (sal_Int32)GetMinor(aBitmapSize.Width, aBitmapSize.Height);
725 if (nBitmapSize > rSize)
726 rSize = nBitmapSize;
727 }
728 }
729 }
730
731
732
733
GetBitmap(const Area eArea,const SharedBitmapDescriptor & rpBitmaps) const734 css::uno::Reference<css::rendering::XBitmap> PresenterScrollBar::GetBitmap (
735 const Area eArea,
736 const SharedBitmapDescriptor& rpBitmaps) const
737 {
738 if (rpBitmaps.get() == NULL)
739 return NULL;
740 else
741 return rpBitmaps->GetBitmap(GetBitmapMode(eArea));
742 }
743
744
745
746
GetBitmapMode(const Area eArea) const747 PresenterBitmapContainer::BitmapDescriptor::Mode PresenterScrollBar::GetBitmapMode (
748 const Area eArea) const
749 {
750 if (IsDisabled(eArea))
751 return PresenterBitmapContainer::BitmapDescriptor::Disabled;
752 else if (eArea == meMouseMoveArea)
753 return PresenterBitmapContainer::BitmapDescriptor::MouseOver;
754 else
755 return PresenterBitmapContainer::BitmapDescriptor::Normal;
756 }
757
758
759
760
IsDisabled(const Area eArea) const761 bool PresenterScrollBar::IsDisabled (const Area eArea) const
762 {
763 OSL_ASSERT(eArea>=0 && eArea<__AreaCount__);
764
765 return ! maEnabledState[eArea];
766 }
767
768
769
770
771 //===== PresenterVerticalScrollBar ============================================
772
PresenterVerticalScrollBar(const Reference<XComponentContext> & rxComponentContext,const Reference<awt::XWindow> & rxParentWindow,const::boost::shared_ptr<PresenterPaintManager> & rpPaintManager,const::boost::function<void (double)> & rThumbMotionListener)773 PresenterVerticalScrollBar::PresenterVerticalScrollBar (
774 const Reference<XComponentContext>& rxComponentContext,
775 const Reference<awt::XWindow>& rxParentWindow,
776 const ::boost::shared_ptr<PresenterPaintManager>& rpPaintManager,
777 const ::boost::function<void(double)>& rThumbMotionListener)
778 : PresenterScrollBar(rxComponentContext, rxParentWindow, rpPaintManager, rThumbMotionListener),
779 mnScrollBarWidth(0)
780 {
781 }
782
783
784
785
~PresenterVerticalScrollBar(void)786 PresenterVerticalScrollBar::~PresenterVerticalScrollBar (void)
787 {
788 }
789
790
791
792
GetDragDistance(const sal_Int32 nX,const sal_Int32 nY) const793 double PresenterVerticalScrollBar::GetDragDistance (const sal_Int32 nX, const sal_Int32 nY) const
794 {
795 (void)nX;
796 const double nDistance (nY - maDragAnchor.Y);
797 if (nDistance == 0)
798 return 0;
799 else
800 {
801 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
802 const double nBarWidth (aWindowBox.Width);
803 const double nPagerHeight (aWindowBox.Height - 2*nBarWidth);
804 const double nDragDistance (mnTotalSize / nPagerHeight * nDistance);
805 if (nDragDistance + mnThumbPosition < 0)
806 return -mnThumbPosition;
807 else if (mnThumbPosition + nDragDistance > mnTotalSize-mnThumbSize)
808 return mnTotalSize-mnThumbSize-mnThumbPosition;
809 else
810 return nDragDistance;
811 }
812 }
813
814
815
816
UpdateDragAnchor(const double nDragDistance)817 void PresenterVerticalScrollBar::UpdateDragAnchor (const double nDragDistance)
818 {
819 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
820 const double nBarWidth (aWindowBox.Width);
821 const double nPagerHeight (aWindowBox.Height - 2*nBarWidth);
822 maDragAnchor.Y += nDragDistance * nPagerHeight / mnTotalSize;
823 }
824
825
826
827
GetSize(void) const828 sal_Int32 PresenterVerticalScrollBar::GetSize (void) const
829 {
830 return mnScrollBarWidth;
831 }
832
833
834
835
GetPoint(const double nMajor,const double nMinor) const836 geometry::RealPoint2D PresenterVerticalScrollBar::GetPoint (
837 const double nMajor, const double nMinor) const
838 {
839 return geometry::RealPoint2D(nMinor, nMajor);
840 }
841
842
843
844
GetMajor(const double nX,const double nY) const845 double PresenterVerticalScrollBar::GetMajor (const double nX, const double nY) const
846 {
847 (void)nX;
848 return nY;
849 }
850
851
852
853
GetMinor(const double nX,const double nY) const854 double PresenterVerticalScrollBar::GetMinor (const double nX, const double nY) const
855 {
856 (void)nY;
857 return nX;
858 }
859
860
861
862
UpdateBorders(void)863 void PresenterVerticalScrollBar::UpdateBorders (void)
864 {
865 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
866 double nBottom = aWindowBox.Height;
867
868 if (mpNextButtonDescriptor.get() != NULL)
869 {
870 Reference<rendering::XBitmap> xBitmap (mpNextButtonDescriptor->GetNormalBitmap());
871 if (xBitmap.is())
872 {
873 geometry::IntegerSize2D aSize (xBitmap->getSize());
874 maBox[NextButton] = geometry::RealRectangle2D(
875 0, nBottom - aSize.Height, aWindowBox.Width, nBottom);
876 nBottom -= aSize.Height + gnScrollBarGap;
877 }
878 }
879 if (mpPrevButtonDescriptor.get() != NULL)
880 {
881 Reference<rendering::XBitmap> xBitmap (mpPrevButtonDescriptor->GetNormalBitmap());
882 if (xBitmap.is())
883 {
884 geometry::IntegerSize2D aSize (xBitmap->getSize());
885 maBox[PrevButton] = geometry::RealRectangle2D(
886 0, nBottom - aSize.Height, aWindowBox.Width, nBottom);
887 nBottom -= aSize.Height + gnScrollBarGap;
888 }
889 }
890 const double nPagerHeight (nBottom);
891 maBox[Pager] = geometry::RealRectangle2D(
892 0,0, aWindowBox.Width, nBottom);
893 if (mnTotalSize < 1)
894 {
895 maBox[Thumb] = maBox[Pager];
896
897 // Set up the enabled/disabled states.
898 maEnabledState[PrevButton] = false;
899 maEnabledState[PagerUp] = false;
900 maEnabledState[NextButton] = false;
901 maEnabledState[PagerDown] = false;
902 maEnabledState[Thumb] = false;
903 }
904 else
905 {
906 const double nThumbSize = ::std::min(mnThumbSize,mnTotalSize);
907 const double nThumbPosition = ::std::min(::std::max(0.0,mnThumbPosition), mnTotalSize - nThumbSize);
908 maBox[Thumb] = geometry::RealRectangle2D(
909 0, nThumbPosition / mnTotalSize * nPagerHeight,
910 aWindowBox.Width,
911 (nThumbPosition+nThumbSize) / mnTotalSize * nPagerHeight);
912
913 // Set up the enabled/disabled states.
914 maEnabledState[PrevButton] = nThumbPosition>0;
915 maEnabledState[PagerUp] = nThumbPosition>0;
916 maEnabledState[NextButton] = nThumbPosition+nThumbSize < mnTotalSize;
917 maEnabledState[PagerDown] = nThumbPosition+nThumbSize < mnTotalSize;
918 maEnabledState[Thumb] = nThumbSize < mnTotalSize;
919 }
920 maBox[PagerUp] = geometry::RealRectangle2D(
921 maBox[Pager].X1, maBox[Pager].Y1, maBox[Pager].X2, maBox[Thumb].Y1-1);
922 maBox[PagerDown] = geometry::RealRectangle2D(
923 maBox[Pager].X1, maBox[Thumb].Y2+1, maBox[Pager].X2, maBox[Pager].Y2);
924 maBox[Total] = PresenterGeometryHelper::Union(
925 PresenterGeometryHelper::Union(maBox[PrevButton], maBox[NextButton]),
926 maBox[Pager]);
927 }
928
929
930
931
UpdateBitmaps(void)932 void PresenterVerticalScrollBar::UpdateBitmaps (void)
933 {
934 if (mpBitmaps.get() != NULL)
935 {
936 mpPrevButtonDescriptor = mpBitmaps->GetBitmap(A2S("Up"));
937 mpNextButtonDescriptor = mpBitmaps->GetBitmap(A2S("Down"));
938 mpPagerStartDescriptor = mpBitmaps->GetBitmap(A2S("PagerTop"));
939 mpPagerCenterDescriptor = mpBitmaps->GetBitmap(A2S("PagerVertical"));
940 mpPagerEndDescriptor = mpBitmaps->GetBitmap(A2S("PagerBottom"));
941 mpThumbStartDescriptor = mpBitmaps->GetBitmap(A2S("ThumbTop"));
942 mpThumbCenterDescriptor = mpBitmaps->GetBitmap(A2S("ThumbVertical"));
943 mpThumbEndDescriptor = mpBitmaps->GetBitmap(A2S("ThumbBottom"));
944
945 mnScrollBarWidth = 0;
946 UpdateWidthOrHeight(mnScrollBarWidth, mpPrevButtonDescriptor);
947 UpdateWidthOrHeight(mnScrollBarWidth, mpNextButtonDescriptor);
948 UpdateWidthOrHeight(mnScrollBarWidth, mpPagerStartDescriptor);
949 UpdateWidthOrHeight(mnScrollBarWidth, mpPagerCenterDescriptor);
950 UpdateWidthOrHeight(mnScrollBarWidth, mpPagerEndDescriptor);
951 UpdateWidthOrHeight(mnScrollBarWidth, mpThumbStartDescriptor);
952 UpdateWidthOrHeight(mnScrollBarWidth, mpThumbCenterDescriptor);
953 UpdateWidthOrHeight(mnScrollBarWidth, mpThumbEndDescriptor);
954 if (mnScrollBarWidth == 0)
955 mnScrollBarWidth = 20;
956 }
957 }
958
959
960
961
PaintComposite(const css::awt::Rectangle & rUpdateBox,const Area eArea,const SharedBitmapDescriptor & rpStartBitmaps,const SharedBitmapDescriptor & rpCenterBitmaps,const SharedBitmapDescriptor & rpEndBitmaps)962 void PresenterVerticalScrollBar::PaintComposite(
963 const css::awt::Rectangle& rUpdateBox,
964 const Area eArea,
965 const SharedBitmapDescriptor& rpStartBitmaps,
966 const SharedBitmapDescriptor& rpCenterBitmaps,
967 const SharedBitmapDescriptor& rpEndBitmaps)
968 {
969 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
970 geometry::RealRectangle2D aBox (GetRectangle(eArea));
971 aBox.X1 += aWindowBox.X;
972 aBox.Y1 += aWindowBox.Y;
973 aBox.X2 += aWindowBox.X;
974 aBox.Y2 += aWindowBox.Y;
975
976 // Get bitmaps and sizes.
977
978 PresenterUIPainter::PaintVerticalBitmapComposite(
979 mxCanvas,
980 rUpdateBox,
981 (eArea == Thumb
982 ? PresenterGeometryHelper::ConvertRectangleWithConstantSize(aBox)
983 : PresenterGeometryHelper::ConvertRectangle(aBox)),
984 GetBitmap(eArea, rpStartBitmaps),
985 GetBitmap(eArea, rpCenterBitmaps),
986 GetBitmap(eArea, rpEndBitmaps));
987 }
988
989
990
991
992 //===== PresenterHorizontalScrollBar ============================================
993
PresenterHorizontalScrollBar(const Reference<XComponentContext> & rxComponentContext,const Reference<awt::XWindow> & rxParentWindow,const::boost::shared_ptr<PresenterPaintManager> & rpPaintManager,const::boost::function<void (double)> & rThumbMotionListener)994 PresenterHorizontalScrollBar::PresenterHorizontalScrollBar (
995 const Reference<XComponentContext>& rxComponentContext,
996 const Reference<awt::XWindow>& rxParentWindow,
997 const ::boost::shared_ptr<PresenterPaintManager>& rpPaintManager,
998 const ::boost::function<void(double)>& rThumbMotionListener)
999 : PresenterScrollBar(rxComponentContext, rxParentWindow, rpPaintManager, rThumbMotionListener),
1000 mnScrollBarHeight(0)
1001 {
1002 }
1003
1004
1005
1006
~PresenterHorizontalScrollBar(void)1007 PresenterHorizontalScrollBar::~PresenterHorizontalScrollBar (void)
1008 {
1009 }
1010
1011
1012
1013
GetDragDistance(const sal_Int32 nX,const sal_Int32 nY) const1014 double PresenterHorizontalScrollBar::GetDragDistance (const sal_Int32 nX, const sal_Int32 nY) const
1015 {
1016 (void)nY;
1017 const double nDistance (nX - maDragAnchor.X);
1018 if (nDistance == 0)
1019 return 0;
1020 else
1021 {
1022 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
1023 const double nBarHeight (aWindowBox.Height);
1024 const double nPagerWidth (aWindowBox.Width - 2*nBarHeight);
1025 const double nDragDistance (mnTotalSize / nPagerWidth * nDistance);
1026 if (nDragDistance + mnThumbPosition < 0)
1027 return -mnThumbPosition;
1028 else if (mnThumbPosition + nDragDistance > mnTotalSize-mnThumbSize)
1029 return mnTotalSize-mnThumbSize-mnThumbPosition;
1030 else
1031 return nDragDistance;
1032 }
1033 }
1034
1035
1036
1037
UpdateDragAnchor(const double nDragDistance)1038 void PresenterHorizontalScrollBar::UpdateDragAnchor (const double nDragDistance)
1039 {
1040 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
1041 const double nBarHeight (aWindowBox.Height);
1042 const double nPagerWidth (aWindowBox.Width - 2*nBarHeight);
1043 maDragAnchor.X += nDragDistance * nPagerWidth / mnTotalSize;
1044 }
1045
1046
1047
1048
GetSize(void) const1049 sal_Int32 PresenterHorizontalScrollBar::GetSize (void) const
1050 {
1051 return mnScrollBarHeight;
1052 }
1053
1054
1055
1056
1057
GetPoint(const double nMajor,const double nMinor) const1058 geometry::RealPoint2D PresenterHorizontalScrollBar::GetPoint (
1059 const double nMajor, const double nMinor) const
1060 {
1061 return geometry::RealPoint2D(nMajor, nMinor);
1062 }
1063
1064
1065
1066
GetMajor(const double nX,const double nY) const1067 double PresenterHorizontalScrollBar::GetMajor (const double nX, const double nY) const
1068 {
1069 (void)nY;
1070 return nX;
1071 }
1072
1073
1074
1075
GetMinor(const double nX,const double nY) const1076 double PresenterHorizontalScrollBar::GetMinor (const double nX, const double nY) const
1077 {
1078 (void)nX;
1079 return nY;
1080 }
1081
1082
1083
1084
UpdateBorders(void)1085 void PresenterHorizontalScrollBar::UpdateBorders (void)
1086 {
1087 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
1088 double nRight = aWindowBox.Width;
1089 const double nGap (2);
1090
1091 if (mpNextButtonDescriptor.get() != NULL)
1092 {
1093 Reference<rendering::XBitmap> xBitmap (mpNextButtonDescriptor->GetNormalBitmap());
1094 if (xBitmap.is())
1095 {
1096 geometry::IntegerSize2D aSize (xBitmap->getSize());
1097 maBox[NextButton] = geometry::RealRectangle2D(
1098 nRight - aSize.Width,0, nRight, aWindowBox.Height);
1099 nRight -= aSize.Width + nGap;
1100 }
1101 }
1102 if (mpPrevButtonDescriptor.get() != NULL)
1103 {
1104 Reference<rendering::XBitmap> xBitmap (mpPrevButtonDescriptor->GetNormalBitmap());
1105 if (xBitmap.is())
1106 {
1107 geometry::IntegerSize2D aSize (xBitmap->getSize());
1108 maBox[PrevButton] = geometry::RealRectangle2D(
1109 nRight - aSize.Width,0, nRight, aWindowBox.Height);
1110 nRight -= aSize.Width + nGap;
1111 }
1112 }
1113
1114 const double nPagerWidth (nRight);
1115 maBox[Pager] = geometry::RealRectangle2D(
1116 0,0, nRight, aWindowBox.Height);
1117 if (mnTotalSize == 0)
1118 {
1119 maBox[Thumb] = maBox[Pager];
1120
1121 // Set up the enabled/disabled states.
1122 maEnabledState[PrevButton] = false;
1123 maEnabledState[PagerUp] = false;
1124 maEnabledState[NextButton] = false;
1125 maEnabledState[PagerDown] = false;
1126 maEnabledState[Thumb] = false;
1127 }
1128 else
1129 {
1130 const double nThumbSize = ::std::min(mnThumbSize,mnTotalSize);
1131 const double nThumbPosition = ::std::min(::std::max(0.0,mnThumbPosition), mnTotalSize - nThumbSize);
1132 maBox[Thumb] = geometry::RealRectangle2D(
1133 (nThumbPosition) / mnTotalSize * nPagerWidth, 0,
1134 (nThumbPosition+nThumbSize) / mnTotalSize * nPagerWidth, aWindowBox.Height);
1135
1136 // Set up the enabled/disabled states.
1137 maEnabledState[PrevButton] = nThumbPosition>0;
1138 maEnabledState[PagerUp] = nThumbPosition>0;
1139 maEnabledState[NextButton] = nThumbPosition+nThumbSize < mnTotalSize;
1140 maEnabledState[PagerDown] = nThumbPosition+nThumbSize < mnTotalSize;
1141 maEnabledState[Thumb] = nThumbSize < mnTotalSize;
1142 }
1143 maBox[PagerUp] = geometry::RealRectangle2D(
1144 maBox[Pager].X1, maBox[Pager].Y1, maBox[Thumb].X1-1, maBox[Pager].Y2);
1145 maBox[PagerDown] = geometry::RealRectangle2D(
1146 maBox[Thumb].X2+1, maBox[Pager].Y1, maBox[Pager].X2, maBox[Pager].Y2);
1147 maBox[Total] = PresenterGeometryHelper::Union(
1148 PresenterGeometryHelper::Union(maBox[PrevButton], maBox[NextButton]),
1149 maBox[Pager]);
1150 }
1151
1152
1153
1154
UpdateBitmaps(void)1155 void PresenterHorizontalScrollBar::UpdateBitmaps (void)
1156 {
1157 if (mpBitmaps.get() != NULL)
1158 {
1159 mpPrevButtonDescriptor = mpBitmaps->GetBitmap(A2S("Left"));
1160 mpNextButtonDescriptor = mpBitmaps->GetBitmap(A2S("Right"));
1161 mpPagerStartDescriptor = mpBitmaps->GetBitmap(A2S("PagerLeft"));
1162 mpPagerCenterDescriptor = mpBitmaps->GetBitmap(A2S("PagerHorizontal"));
1163 mpPagerEndDescriptor = mpBitmaps->GetBitmap(A2S("PagerRight"));
1164 mpThumbStartDescriptor = mpBitmaps->GetBitmap(A2S("ThumbLeft"));
1165 mpThumbCenterDescriptor = mpBitmaps->GetBitmap(A2S("ThumbHorizontal"));
1166 mpThumbEndDescriptor = mpBitmaps->GetBitmap(A2S("ThumbRight"));
1167
1168 mnScrollBarHeight = 0;
1169 UpdateWidthOrHeight(mnScrollBarHeight, mpPrevButtonDescriptor);
1170 UpdateWidthOrHeight(mnScrollBarHeight, mpNextButtonDescriptor);
1171 UpdateWidthOrHeight(mnScrollBarHeight, mpPagerStartDescriptor);
1172 UpdateWidthOrHeight(mnScrollBarHeight, mpPagerCenterDescriptor);
1173 UpdateWidthOrHeight(mnScrollBarHeight, mpPagerEndDescriptor);
1174 UpdateWidthOrHeight(mnScrollBarHeight, mpThumbStartDescriptor);
1175 UpdateWidthOrHeight(mnScrollBarHeight, mpThumbCenterDescriptor);
1176 UpdateWidthOrHeight(mnScrollBarHeight, mpThumbEndDescriptor);
1177 if (mnScrollBarHeight == 0)
1178 mnScrollBarHeight = 20;
1179 }
1180 }
1181
1182
1183
PaintComposite(const css::awt::Rectangle & rUpdateBox,const Area eArea,const SharedBitmapDescriptor & rpStartBitmaps,const SharedBitmapDescriptor & rpCenterBitmaps,const SharedBitmapDescriptor & rpEndBitmaps)1184 void PresenterHorizontalScrollBar::PaintComposite(
1185 const css::awt::Rectangle& rUpdateBox,
1186 const Area eArea,
1187 const SharedBitmapDescriptor& rpStartBitmaps,
1188 const SharedBitmapDescriptor& rpCenterBitmaps,
1189 const SharedBitmapDescriptor& rpEndBitmaps)
1190 {
1191 const awt::Rectangle aWindowBox (mxWindow->getPosSize());
1192 geometry::RealRectangle2D aBox (GetRectangle(eArea));
1193 aBox.X1 += aWindowBox.X;
1194 aBox.Y1 += aWindowBox.Y;
1195 aBox.X2 += aWindowBox.X;
1196 aBox.Y2 += aWindowBox.Y;
1197
1198 PresenterUIPainter::PaintHorizontalBitmapComposite(
1199 mxCanvas,
1200 rUpdateBox,
1201 PresenterGeometryHelper::ConvertRectangle(aBox),
1202 GetBitmap(eArea, rpStartBitmaps),
1203 GetBitmap(eArea, rpCenterBitmaps),
1204 GetBitmap(eArea, rpEndBitmaps));
1205 }
1206
1207
1208
1209
1210 //===== PresenterScrollBar::MousePressRepeater ================================
1211
MousePressRepeater(const::rtl::Reference<PresenterScrollBar> & rpScrollBar)1212 PresenterScrollBar::MousePressRepeater::MousePressRepeater (
1213 const ::rtl::Reference<PresenterScrollBar>& rpScrollBar)
1214 : mnMousePressRepeaterTaskId(PresenterTimer::NotAValidTaskId),
1215 mpScrollBar(rpScrollBar),
1216 meMouseArea(PresenterScrollBar::None)
1217 {
1218 }
1219
1220
1221
1222
Dispose(void)1223 void PresenterScrollBar::MousePressRepeater::Dispose (void)
1224 {
1225 Stop();
1226 mpScrollBar = NULL;
1227 }
1228
1229
1230
1231
Start(const PresenterScrollBar::Area & reArea)1232 void PresenterScrollBar::MousePressRepeater::Start (const PresenterScrollBar::Area& reArea)
1233 {
1234 meMouseArea = reArea;
1235
1236 if (mnMousePressRepeaterTaskId == PresenterTimer::NotAValidTaskId)
1237 {
1238 // Execute key press operation at least this one time.
1239 Execute();
1240
1241 // Schedule repeated executions.
1242 mnMousePressRepeaterTaskId = PresenterTimer::ScheduleRepeatedTask (
1243 ::boost::bind(&PresenterScrollBar::MousePressRepeater::Callback, shared_from_this(), _1),
1244 500000000,
1245 250000000);
1246 }
1247 else
1248 {
1249 // There is already an active repeating task.
1250 }
1251 }
1252
1253
1254
1255
Stop(void)1256 void PresenterScrollBar::MousePressRepeater::Stop (void)
1257 {
1258 if (mnMousePressRepeaterTaskId != PresenterTimer::NotAValidTaskId)
1259 {
1260 const sal_Int32 nTaskId (mnMousePressRepeaterTaskId);
1261 mnMousePressRepeaterTaskId = PresenterTimer::NotAValidTaskId;
1262 PresenterTimer::CancelTask(nTaskId);
1263 }
1264 }
1265
1266
1267
1268
SetMouseArea(const PresenterScrollBar::Area & reArea)1269 void PresenterScrollBar::MousePressRepeater::SetMouseArea(const PresenterScrollBar::Area& reArea)
1270 {
1271 if (meMouseArea != reArea)
1272 {
1273 if (mnMousePressRepeaterTaskId != PresenterTimer::NotAValidTaskId)
1274 {
1275 Stop();
1276 }
1277 }
1278 }
1279
1280
1281
1282
Callback(const TimeValue & rCurrentTime)1283 void PresenterScrollBar::MousePressRepeater::Callback (const TimeValue& rCurrentTime)
1284 {
1285 (void)rCurrentTime;
1286
1287 if (mpScrollBar.get() == NULL)
1288 {
1289 Stop();
1290 return;
1291 }
1292
1293 Execute();
1294 }
1295
1296
1297
1298
Execute(void)1299 void PresenterScrollBar::MousePressRepeater::Execute (void)
1300 {
1301 const double nThumbPosition (mpScrollBar->GetThumbPosition());
1302 switch (meMouseArea)
1303 {
1304 case PrevButton:
1305 mpScrollBar->SetThumbPosition(nThumbPosition - mpScrollBar->GetLineHeight(), true);
1306 break;
1307
1308 case NextButton:
1309 mpScrollBar->SetThumbPosition(nThumbPosition + mpScrollBar->GetLineHeight(), true);
1310 break;
1311
1312 case PagerUp:
1313 mpScrollBar->SetThumbPosition(nThumbPosition - mpScrollBar->GetThumbSize()*0.8, true);
1314 break;
1315
1316 case PagerDown:
1317 mpScrollBar->SetThumbPosition(nThumbPosition + mpScrollBar->GetThumbSize()*0.8, true);
1318 break;
1319
1320 default:
1321 break;
1322 }
1323 }
1324
1325
1326
1327 } } // end of namespace ::sdext::presenter
1328