update dev300-m58
[ooovba.git] / sdext / source / presenter / PresenterClock.hxx
blobcdca1e371d69ba3a1f717dbb1f2c06f0d8a3310e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterClock.hxx,v $
11 * $Revision: 1.3 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef SDEXT_PRESENTER_CLOCK_HXX
33 #define SDEXT_PRESENTER_CLOCK_HXX
35 #include "PresenterController.hxx"
37 #include <cppuhelper/basemutex.hxx>
38 #include <cppuhelper/compbase4.hxx>
39 #include <com/sun/star/awt/XMouseListener.hpp>
40 #include <com/sun/star/awt/XPaintListener.hpp>
41 #include <com/sun/star/awt/XWindowListener.hpp>
42 #include <com/sun/star/beans/XPropertySet.hpp>
43 #include <com/sun/star/drawing/framework/XPane.hpp>
44 #include <com/sun/star/drawing/framework/XResourceId.hpp>
45 #include <com/sun/star/drawing/framework/XView.hpp>
46 #include <com/sun/star/frame/XController.hpp>
47 #include <com/sun/star/rendering/XCanvas.hpp>
48 #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
49 #include <com/sun/star/uno/XComponentContext.hpp>
50 #include <osl/thread.hxx>
51 #include <rtl/ref.hxx>
52 #include <boost/scoped_ptr.hpp>
54 namespace css = ::com::sun::star;
56 namespace {
57 typedef cppu::WeakComponentImplHelper4<
58 css::awt::XPaintListener,
59 css::awt::XWindowListener,
60 css::awt::XMouseListener,
61 css::drawing::framework::XView
62 > PresenterClockInterfaceBase;
65 namespace sdext { namespace presenter {
68 /** A clock that displays the current time. This class is work in
69 progress. Future extensions may include
70 other times like time since presentation started or remaining time.
71 Painting of the clock is done by the inner Painer class which includes
72 at the moment a simple analog and a simple digital clock.
74 class PresenterClock
75 : private ::cppu::BaseMutex,
76 public PresenterClockInterfaceBase
78 public:
79 static ::rtl::Reference<PresenterClock> Create (
80 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
81 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
82 const css::uno::Reference<css::frame::XController>& rxController,
83 const ::rtl::Reference<PresenterController>& rpPresenterController);
85 virtual void SAL_CALL disposing (void);
87 /** Callback for an external timer or thread that initiates updates when
88 the time changes (seconds or minutes).
90 void UpdateTime (void);
92 /** An internally used base class for different painters.
94 class Painter;
97 // lang::XEventListener
99 virtual void SAL_CALL
100 disposing (const css::lang::EventObject& rEventObject)
101 throw (css::uno::RuntimeException);
104 // XPaintListener
106 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
107 throw (css::uno::RuntimeException);
110 // XWindowListener
112 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
113 throw (css::uno::RuntimeException);
115 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
116 throw (css::uno::RuntimeException);
118 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
119 throw (css::uno::RuntimeException);
121 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
122 throw (css::uno::RuntimeException);
125 // XMouseListener
127 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
128 throw (css::uno::RuntimeException);
130 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
131 throw (css::uno::RuntimeException);
133 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
134 throw (css::uno::RuntimeException);
136 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
137 throw (css::uno::RuntimeException);
140 // XResourceId
142 virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void)
143 throw (css::uno::RuntimeException);
145 virtual sal_Bool SAL_CALL isAnchorOnly (void)
146 throw (com::sun::star::uno::RuntimeException);
148 private:
149 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
150 css::uno::Reference<css::drawing::framework::XResourceId> mxViewId;
151 css::uno::Reference<css::awt::XWindow> mxWindow;
152 css::uno::Reference<css::rendering::XCanvas> mxCanvas;
153 css::uno::Reference<css::drawing::framework::XPane> mxPane;
154 ::rtl::Reference<PresenterController> mpPresenterController;
155 bool mbIsResizePending;
156 css::rendering::ViewState maViewState;
157 css::rendering::RenderState maRenderState;
158 /** A Timer is used for sampling the current time and schedule repaints
159 when the minute or second (when these are displayed) values have changed.
161 class Timer;
162 Timer* mpTimer;
163 ::boost::scoped_ptr<Painter> mpClockPainter;
164 /**
165 This is used for debugging to show one clock atop another to compare
166 the output of the painters.
168 ::boost::scoped_ptr<Painter> mpClockPainter2;
169 int mnMode;
170 sal_Int32 mnHour;
171 sal_Int32 mnMinute;
172 sal_Int32 mnSecond;
174 bool mbIsShowSeconds;
176 /** Use the static Create() method for creating a new PresenterClock
177 object.
179 PresenterClock (
180 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
181 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
182 const css::uno::Reference<css::frame::XController>& rxController,
183 const ::rtl::Reference<PresenterController>& rpPresenterController);
184 virtual ~PresenterClock (void);
186 void LateInit (void);
187 void Resize (void);
188 void Paint (const css::awt::Rectangle& rUpdateRectangle);
189 css::uno::Reference<css::rendering::XPolyPolygon2D> CreatePolygon (
190 const css::awt::Rectangle& rBox);
191 void Clear (const css::uno::Reference<css::rendering::XPolyPolygon2D>& rxUpdatePolygon);
192 void SetMode (sal_Int32 nMode);
194 /** This method throws a DisposedException when the object has already been
195 disposed.
197 void ThrowIfDisposed (void)
198 throw (css::lang::DisposedException);
201 } } // end of namespace ::sdext::presenter
203 #endif