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