1*06bcd5d2SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*06bcd5d2SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*06bcd5d2SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*06bcd5d2SAndrew Rist * distributed with this work for additional information 6*06bcd5d2SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*06bcd5d2SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*06bcd5d2SAndrew Rist * "License"); you may not use this file except in compliance 9*06bcd5d2SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*06bcd5d2SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*06bcd5d2SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*06bcd5d2SAndrew Rist * software distributed under the License is distributed on an 15*06bcd5d2SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*06bcd5d2SAndrew Rist * KIND, either express or implied. See the License for the 17*06bcd5d2SAndrew Rist * specific language governing permissions and limitations 18*06bcd5d2SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*06bcd5d2SAndrew Rist *************************************************************/ 21*06bcd5d2SAndrew Rist 22*06bcd5d2SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_CLOCK_HXX 25cdf0e10cSrcweir #define SDEXT_PRESENTER_CLOCK_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "PresenterController.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx> 30cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx> 31cdf0e10cSrcweir #include <com/sun/star/awt/XMouseListener.hpp> 32cdf0e10cSrcweir #include <com/sun/star/awt/XPaintListener.hpp> 33cdf0e10cSrcweir #include <com/sun/star/awt/XWindowListener.hpp> 34cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 35cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XPane.hpp> 36cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceId.hpp> 37cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XView.hpp> 38cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 39cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvas.hpp> 40cdf0e10cSrcweir #include <com/sun/star/rendering/XPolyPolygon2D.hpp> 41cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 42cdf0e10cSrcweir #include <osl/thread.hxx> 43cdf0e10cSrcweir #include <rtl/ref.hxx> 44cdf0e10cSrcweir #include <boost/scoped_ptr.hpp> 45cdf0e10cSrcweir 46cdf0e10cSrcweir namespace css = ::com::sun::star; 47cdf0e10cSrcweir 48cdf0e10cSrcweir namespace { 49cdf0e10cSrcweir typedef cppu::WeakComponentImplHelper4< 50cdf0e10cSrcweir css::awt::XPaintListener, 51cdf0e10cSrcweir css::awt::XWindowListener, 52cdf0e10cSrcweir css::awt::XMouseListener, 53cdf0e10cSrcweir css::drawing::framework::XView 54cdf0e10cSrcweir > PresenterClockInterfaceBase; 55cdf0e10cSrcweir } 56cdf0e10cSrcweir 57cdf0e10cSrcweir namespace sdext { namespace presenter { 58cdf0e10cSrcweir 59cdf0e10cSrcweir 60cdf0e10cSrcweir /** A clock that displays the current time. This class is work in 61cdf0e10cSrcweir progress. Future extensions may include 62cdf0e10cSrcweir other times like time since presentation started or remaining time. 63cdf0e10cSrcweir Painting of the clock is done by the inner Painer class which includes 64cdf0e10cSrcweir at the moment a simple analog and a simple digital clock. 65cdf0e10cSrcweir */ 66cdf0e10cSrcweir class PresenterClock 67cdf0e10cSrcweir : private ::cppu::BaseMutex, 68cdf0e10cSrcweir public PresenterClockInterfaceBase 69cdf0e10cSrcweir { 70cdf0e10cSrcweir public: 71cdf0e10cSrcweir static ::rtl::Reference<PresenterClock> Create ( 72cdf0e10cSrcweir const css::uno::Reference<css::uno::XComponentContext>& rxContext, 73cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId, 74cdf0e10cSrcweir const css::uno::Reference<css::frame::XController>& rxController, 75cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController); 76cdf0e10cSrcweir 77cdf0e10cSrcweir virtual void SAL_CALL disposing (void); 78cdf0e10cSrcweir 79cdf0e10cSrcweir /** Callback for an external timer or thread that initiates updates when 80cdf0e10cSrcweir the time changes (seconds or minutes). 81cdf0e10cSrcweir */ 82cdf0e10cSrcweir void UpdateTime (void); 83cdf0e10cSrcweir 84cdf0e10cSrcweir /** An internally used base class for different painters. 85cdf0e10cSrcweir */ 86cdf0e10cSrcweir class Painter; 87cdf0e10cSrcweir 88cdf0e10cSrcweir 89cdf0e10cSrcweir // lang::XEventListener 90cdf0e10cSrcweir 91cdf0e10cSrcweir virtual void SAL_CALL 92cdf0e10cSrcweir disposing (const css::lang::EventObject& rEventObject) 93cdf0e10cSrcweir throw (css::uno::RuntimeException); 94cdf0e10cSrcweir 95cdf0e10cSrcweir 96cdf0e10cSrcweir // XPaintListener 97cdf0e10cSrcweir 98cdf0e10cSrcweir virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent) 99cdf0e10cSrcweir throw (css::uno::RuntimeException); 100cdf0e10cSrcweir 101cdf0e10cSrcweir 102cdf0e10cSrcweir // XWindowListener 103cdf0e10cSrcweir 104cdf0e10cSrcweir virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent) 105cdf0e10cSrcweir throw (css::uno::RuntimeException); 106cdf0e10cSrcweir 107cdf0e10cSrcweir virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent) 108cdf0e10cSrcweir throw (css::uno::RuntimeException); 109cdf0e10cSrcweir 110cdf0e10cSrcweir virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent) 111cdf0e10cSrcweir throw (css::uno::RuntimeException); 112cdf0e10cSrcweir 113cdf0e10cSrcweir virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent) 114cdf0e10cSrcweir throw (css::uno::RuntimeException); 115cdf0e10cSrcweir 116cdf0e10cSrcweir 117cdf0e10cSrcweir // XMouseListener 118cdf0e10cSrcweir 119cdf0e10cSrcweir virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent) 120cdf0e10cSrcweir throw (css::uno::RuntimeException); 121cdf0e10cSrcweir 122cdf0e10cSrcweir virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent) 123cdf0e10cSrcweir throw (css::uno::RuntimeException); 124cdf0e10cSrcweir 125cdf0e10cSrcweir virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent) 126cdf0e10cSrcweir throw (css::uno::RuntimeException); 127cdf0e10cSrcweir 128cdf0e10cSrcweir virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent) 129cdf0e10cSrcweir throw (css::uno::RuntimeException); 130cdf0e10cSrcweir 131cdf0e10cSrcweir 132cdf0e10cSrcweir // XResourceId 133cdf0e10cSrcweir 134cdf0e10cSrcweir virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void) 135cdf0e10cSrcweir throw (css::uno::RuntimeException); 136cdf0e10cSrcweir 137cdf0e10cSrcweir virtual sal_Bool SAL_CALL isAnchorOnly (void) 138cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException); 139cdf0e10cSrcweir 140cdf0e10cSrcweir private: 141cdf0e10cSrcweir css::uno::Reference<css::uno::XComponentContext> mxComponentContext; 142cdf0e10cSrcweir css::uno::Reference<css::drawing::framework::XResourceId> mxViewId; 143cdf0e10cSrcweir css::uno::Reference<css::awt::XWindow> mxWindow; 144cdf0e10cSrcweir css::uno::Reference<css::rendering::XCanvas> mxCanvas; 145cdf0e10cSrcweir css::uno::Reference<css::drawing::framework::XPane> mxPane; 146cdf0e10cSrcweir ::rtl::Reference<PresenterController> mpPresenterController; 147cdf0e10cSrcweir bool mbIsResizePending; 148cdf0e10cSrcweir css::rendering::ViewState maViewState; 149cdf0e10cSrcweir css::rendering::RenderState maRenderState; 150cdf0e10cSrcweir /** A Timer is used for sampling the current time and schedule repaints 151cdf0e10cSrcweir when the minute or second (when these are displayed) values have changed. 152cdf0e10cSrcweir */ 153cdf0e10cSrcweir class Timer; 154cdf0e10cSrcweir Timer* mpTimer; 155cdf0e10cSrcweir ::boost::scoped_ptr<Painter> mpClockPainter; 156cdf0e10cSrcweir /** 157cdf0e10cSrcweir This is used for debugging to show one clock atop another to compare 158cdf0e10cSrcweir the output of the painters. 159cdf0e10cSrcweir */ 160cdf0e10cSrcweir ::boost::scoped_ptr<Painter> mpClockPainter2; 161cdf0e10cSrcweir int mnMode; 162cdf0e10cSrcweir sal_Int32 mnHour; 163cdf0e10cSrcweir sal_Int32 mnMinute; 164cdf0e10cSrcweir sal_Int32 mnSecond; 165cdf0e10cSrcweir 166cdf0e10cSrcweir bool mbIsShowSeconds; 167cdf0e10cSrcweir 168cdf0e10cSrcweir /** Use the static Create() method for creating a new PresenterClock 169cdf0e10cSrcweir object. 170cdf0e10cSrcweir */ 171cdf0e10cSrcweir PresenterClock ( 172cdf0e10cSrcweir const css::uno::Reference<css::uno::XComponentContext>& rxContext, 173cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId, 174cdf0e10cSrcweir const css::uno::Reference<css::frame::XController>& rxController, 175cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController); 176cdf0e10cSrcweir virtual ~PresenterClock (void); 177cdf0e10cSrcweir 178cdf0e10cSrcweir void LateInit (void); 179cdf0e10cSrcweir void Resize (void); 180cdf0e10cSrcweir void Paint (const css::awt::Rectangle& rUpdateRectangle); 181cdf0e10cSrcweir css::uno::Reference<css::rendering::XPolyPolygon2D> CreatePolygon ( 182cdf0e10cSrcweir const css::awt::Rectangle& rBox); 183cdf0e10cSrcweir void Clear (const css::uno::Reference<css::rendering::XPolyPolygon2D>& rxUpdatePolygon); 184cdf0e10cSrcweir void SetMode (sal_Int32 nMode); 185cdf0e10cSrcweir 186cdf0e10cSrcweir /** This method throws a DisposedException when the object has already been 187cdf0e10cSrcweir disposed. 188cdf0e10cSrcweir */ 189cdf0e10cSrcweir void ThrowIfDisposed (void) 190cdf0e10cSrcweir throw (css::lang::DisposedException); 191cdf0e10cSrcweir }; 192cdf0e10cSrcweir 193cdf0e10cSrcweir } } // end of namespace ::sdext::presenter 194cdf0e10cSrcweir 195cdf0e10cSrcweir #endif 196