1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SDEXT_PRESENTER_PRESENTER_BUTTON_HXX 29 #define SDEXT_PRESENTER_PRESENTER_BUTTON_HXX 30 31 #include "PresenterBitmapContainer.hxx" 32 #include "PresenterTheme.hxx" 33 #include <com/sun/star/awt/Rectangle.hpp> 34 #include <com/sun/star/awt/XWindow.hpp> 35 #include <com/sun/star/awt/XWindowListener.hpp> 36 #include <com/sun/star/awt/XPaintListener.hpp> 37 #include <com/sun/star/awt/XMouseListener.hpp> 38 #include <com/sun/star/awt/XMouseMotionListener.hpp> 39 #include <com/sun/star/rendering/XCanvas.hpp> 40 #include <com/sun/star/rendering/XBitmap.hpp> 41 #include <cppuhelper/basemutex.hxx> 42 #include <cppuhelper/compbase4.hxx> 43 #include <boost/noncopyable.hpp> 44 #include <rtl/ref.hxx> 45 46 namespace css = ::com::sun::star; 47 48 namespace sdext { namespace presenter { 49 50 class PresenterController; 51 52 namespace { 53 typedef ::cppu::WeakComponentImplHelper4 < 54 css::awt::XWindowListener, 55 css::awt::XPaintListener, 56 css::awt::XMouseListener, 57 css::awt::XMouseMotionListener 58 > PresenterButtonInterfaceBase; 59 } 60 61 /** Button for the presenter screen. It displays a text surrounded by a 62 frame. 63 */ 64 class PresenterButton 65 : private ::boost::noncopyable, 66 private ::cppu::BaseMutex, 67 public PresenterButtonInterfaceBase 68 { 69 public: 70 static ::rtl::Reference<PresenterButton> Create ( 71 const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext, 72 const ::rtl::Reference<PresenterController>& rpPresenterController, 73 const ::boost::shared_ptr<PresenterTheme>& rpTheme, 74 const css::uno::Reference<css::awt::XWindow>& rxParentWindow, 75 const css::uno::Reference<css::rendering::XCanvas>& rxParentCanvas, 76 const ::rtl::OUString& rsConfigurationName); 77 ~PresenterButton (void); 78 79 virtual void SAL_CALL disposing (void); 80 81 void SetCenter (const css::geometry::RealPoint2D& rLocation); 82 void SetCanvas ( 83 const css::uno::Reference<css::rendering::XCanvas>& rxParentCanvas, 84 const css::uno::Reference<css::awt::XWindow>& rxParentWindow); 85 css::geometry::IntegerSize2D GetSize (void); 86 87 // XWindowListener 88 89 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent) 90 throw (css::uno::RuntimeException); 91 92 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent) 93 throw (css::uno::RuntimeException); 94 95 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent) 96 throw (css::uno::RuntimeException); 97 98 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent) 99 throw (css::uno::RuntimeException); 100 101 102 // XPaintListener 103 104 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) 105 throw (css::uno::RuntimeException); 106 107 108 // XMouseListener 109 110 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) 111 throw(css::uno::RuntimeException); 112 113 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) 114 throw(css::uno::RuntimeException); 115 116 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) 117 throw(css::uno::RuntimeException); 118 119 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) 120 throw(css::uno::RuntimeException); 121 122 123 // XMouseMotionListener 124 125 virtual void SAL_CALL mouseMoved (const css::awt::MouseEvent& rEvent) 126 throw (css::uno::RuntimeException); 127 128 virtual void SAL_CALL mouseDragged (const css::awt::MouseEvent& rEvent) 129 throw (css::uno::RuntimeException); 130 131 132 // lang::XEventListener 133 virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) 134 throw (css::uno::RuntimeException); 135 136 private: 137 ::rtl::Reference<PresenterController> mpPresenterController; 138 ::boost::shared_ptr<PresenterTheme> mpTheme; 139 css::uno::Reference<css::awt::XWindow> mxWindow; 140 css::uno::Reference<css::rendering::XCanvas> mxCanvas; 141 css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper; 142 const ::rtl::OUString msText; 143 const PresenterTheme::SharedFontDescriptor mpFont; 144 const PresenterTheme::SharedFontDescriptor mpMouseOverFont; 145 const ::rtl::OUString msAction; 146 css::geometry::RealPoint2D maCenter; 147 css::geometry::IntegerSize2D maButtonSize; 148 PresenterBitmapDescriptor::Mode meState; 149 css::uno::Reference<css::rendering::XBitmap> mxNormalBitmap; 150 css::uno::Reference<css::rendering::XBitmap> mxMouseOverBitmap; 151 152 PresenterButton ( 153 const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext, 154 const ::rtl::Reference<PresenterController>& rpPresenterController, 155 const ::boost::shared_ptr<PresenterTheme>& rpTheme, 156 const css::uno::Reference<css::awt::XWindow>& rxParentWindow, 157 const PresenterTheme::SharedFontDescriptor& rFont, 158 const PresenterTheme::SharedFontDescriptor& rMouseOverFont, 159 const ::rtl::OUString& rxText, 160 const ::rtl::OUString& rxAction); 161 void RenderButton ( 162 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas, 163 const css::geometry::IntegerSize2D& rSize, 164 const PresenterTheme::SharedFontDescriptor& rFont, 165 const PresenterBitmapDescriptor::Mode eMode, 166 const SharedBitmapDescriptor& rpLeft, 167 const SharedBitmapDescriptor& rpCenter, 168 const SharedBitmapDescriptor& rpRight); 169 css::geometry::IntegerSize2D CalculateButtonSize (void); 170 void Invalidate (void); 171 css::uno::Reference<css::rendering::XBitmap> GetBitmap ( 172 const SharedBitmapDescriptor& mpIcon, 173 const PresenterBitmapDescriptor::Mode eMode); 174 void SetupButtonBitmaps (void); 175 static css::uno::Reference<css::beans::XPropertySet> GetConfigurationProperties ( 176 const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext, 177 const ::rtl::OUString& rsConfgurationName); 178 179 void ThrowIfDisposed (void) const 180 throw (::com::sun::star::lang::DisposedException); 181 }; 182 183 } } 184 185 #endif 186