merge the formfield patch from ooo-build
[ooovba.git] / sdext / source / presenter / PresenterWindowManager.hxx
blobec94f26aa25d532704b684225c38938a2f3d9cfa
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: PresenterWindowManager.hxx,v $
11 * $Revision: 1.4 $
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_PRESENTER_WINDOW_MANAGER_HXX
33 #define SDEXT_PRESENTER_PRESENTER_WINDOW_MANAGER_HXX
35 #include "PresenterPaneContainer.hxx"
36 #include "PresenterTheme.hxx"
37 #include <com/sun/star/awt/Point.hpp>
38 #include <com/sun/star/awt/XFocusListener.hpp>
39 #include <com/sun/star/awt/XGraphics.hpp>
40 #include <com/sun/star/awt/XMouseMotionListener.hpp>
41 #include <com/sun/star/awt/XPaintListener.hpp>
42 #include <com/sun/star/awt/XWindow.hpp>
43 #include <com/sun/star/awt/XWindowListener.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <com/sun/star/document/XEventListener.hpp>
46 #include <com/sun/star/drawing/framework/XPane.hpp>
47 #include <com/sun/star/rendering/XBitmap.hpp>
48 #include <com/sun/star/rendering/XSprite.hpp>
49 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
50 #include <com/sun/star/uno/XComponentContext.hpp>
51 #include <cppuhelper/basemutex.hxx>
52 #include <cppuhelper/compbase4.hxx>
53 #include <tools/gen.hxx>
54 #include <rtl/ref.hxx>
55 #include <boost/noncopyable.hpp>
56 #include <boost/shared_ptr.hpp>
58 namespace css = ::com::sun::star;
60 namespace sdext { namespace presenter {
62 class PresenterController;
63 class PresenterPaneBorderPainter;
64 class PresenterTheme;
66 namespace {
67 typedef ::cppu::WeakComponentImplHelper4<
68 css::awt::XWindowListener,
69 css::awt::XPaintListener,
70 css::awt::XMouseListener,
71 css::awt::XFocusListener
72 > PresenterWindowManagerInterfaceBase;
76 /** A simple manager of the positions of the panes of the presenter screen.
77 Uses relative coordinates of the four sides of each pane. Allows panes
78 to be moved or resized with the mouse.
80 class PresenterWindowManager
81 : private ::boost::noncopyable,
82 protected ::cppu::BaseMutex,
83 public PresenterWindowManagerInterfaceBase
85 public:
86 PresenterWindowManager (
87 const ::css::uno::Reference<css::uno::XComponentContext>& rxContext,
88 const ::rtl::Reference<PresenterPaneContainer>& rpPaneContainer,
89 const ::rtl::Reference<PresenterController>& rpPresenterController);
90 virtual ~PresenterWindowManager (void);
92 void SAL_CALL disposing (void);
94 void SetParentPane (const css::uno::Reference<css::drawing::framework::XPane>& rxPane);
95 void SetTheme (const ::boost::shared_ptr<PresenterTheme>& rpTheme);
96 void NotifyPaneCreation (const PresenterPaneContainer::SharedPaneDescriptor& rpDescriptor);
97 void NotifyViewCreation (const css::uno::Reference<css::drawing::framework::XView>& rxView);
98 void SetPanePosSizeRelative (
99 const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,
100 const double nRelativeX,
101 const double nRelativeY,
102 const double nRelativeWidth,
103 const double nRelativeHeight);
104 void SetPanePosSizeAbsolute (
105 const ::rtl::OUString& rsPaneURL,
106 const double nX,
107 const double nY,
108 const double nWidth,
109 const double nHeight);
110 void SetPaneBorderPainter (const ::rtl::Reference<PresenterPaneBorderPainter>& rPainter);
111 css::uno::Reference<css::awt::XWindow> GetParentWindow (void) const;
112 css::uno::Reference<css::rendering::XCanvas> GetParentCanvas (void) const;
113 void Update (void);
114 void Layout (void);
116 void SetSlideSorterState (bool bIsActive);
117 void SetHelpViewState (bool bIsActive);
119 enum LayoutMode { LM_Standard, LM_Notes, LM_Generic };
120 private:
121 void SetLayoutMode (const LayoutMode eMode);
122 LayoutMode GetLayoutMode (void) const;
124 bool IsSlideSorterActive (void) const;
125 bool IsHelpViewActive (void) const;
126 public:
127 enum ViewMode { VM_Standard, VM_Notes, VM_SlideOverview, VM_Help };
128 /** The high-level method to switch the view mode. Use this instead of
129 SetLayoutMode and Set(Help|SlideSorter)State when possible.
131 void SetViewMode (const ViewMode eMode);
133 ViewMode GetViewMode (void) const;
135 /** Restore the layout mode (or slide sorter state) from the
136 configuration.
138 void RestoreViewMode (void);
140 void AddLayoutListener (
141 const css::uno::Reference<css::document::XEventListener>& rxListener);
142 void RemoveLayoutListener (
143 const css::uno::Reference<css::document::XEventListener>& rxListener);
145 // XWindowListener
147 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
148 throw (css::uno::RuntimeException);
150 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
151 throw (css::uno::RuntimeException);
153 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
154 throw (css::uno::RuntimeException);
156 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
157 throw (css::uno::RuntimeException);
160 // XPaintListener
162 virtual void SAL_CALL windowPaint (const css::awt::PaintEvent& rEvent)
163 throw (css::uno::RuntimeException);
166 // XMouseListener
168 virtual void SAL_CALL mousePressed (const css::awt::MouseEvent& rEvent)
169 throw(css::uno::RuntimeException);
171 virtual void SAL_CALL mouseReleased (const css::awt::MouseEvent& rEvent)
172 throw(css::uno::RuntimeException);
174 virtual void SAL_CALL mouseEntered (const css::awt::MouseEvent& rEvent)
175 throw(css::uno::RuntimeException);
177 virtual void SAL_CALL mouseExited (const css::awt::MouseEvent& rEvent)
178 throw(css::uno::RuntimeException);
181 // XFocusListener
183 virtual void SAL_CALL focusGained (const css::awt::FocusEvent& rEvent)
184 throw (css::uno::RuntimeException);
186 virtual void SAL_CALL focusLost (const css::awt::FocusEvent& rEvent)
187 throw (css::uno::RuntimeException);
190 // XEventListener
192 virtual void SAL_CALL disposing (
193 const com::sun::star::lang::EventObject& rEvent)
194 throw (com::sun::star::uno::RuntimeException);
196 private:
197 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
198 ::rtl::Reference<PresenterController> mpPresenterController;
199 css::uno::Reference<css::awt::XWindow> mxParentWindow;
200 css::uno::Reference<css::rendering::XCanvas> mxParentCanvas;
201 css::uno::Reference<css::uno::XInterface> mxPaneBorderManager;
202 ::rtl::Reference<PresenterPaneBorderPainter> mpPaneBorderPainter;
203 ::rtl::Reference<PresenterPaneContainer> mpPaneContainer;
204 bool mbIsLayoutPending;
205 /** This flag is set to <TRUE/> while the Layout() method is being
206 executed. Prevents windowMoved() and windowResized() from changing
207 the window sizes.
209 bool mbIsLayouting;
210 ::boost::shared_ptr<PresenterTheme> mpTheme;
211 SharedBitmapDescriptor mpBackgroundBitmap;
212 css::uno::Reference<css::rendering::XBitmap> mxScaledBackgroundBitmap;
213 css::util::Color maPaneBackgroundColor;
214 css::uno::Reference<css::rendering::XPolyPolygon2D> mxClipPolygon;
215 LayoutMode meLayoutMode;
216 bool mbIsSlideSorterActive;
217 bool mbIsHelpViewActive;
218 typedef ::std::vector<css::uno::Reference<css::document::XEventListener> >
219 LayoutListenerContainer;
220 LayoutListenerContainer maLayoutListeners;
221 bool mbIsMouseClickPending;
223 bool PaintChildren (const css::awt::PaintEvent& rEvent) const;
224 void UpdateWindowSize (const css::uno::Reference<css::awt::XWindow>& rxBorderWindow);
225 void PaintBackground (const css::awt::Rectangle& rUpdateBox);
226 void ProvideBackgroundBitmap (void);
227 css::uno::Reference<css::rendering::XPolyPolygon2D> CreateClipPolyPolygon (void) const;
228 void ToTop ();
230 void UpdateWindowList (void);
231 bool ChildNeedsRepaint (
232 const css::uno::Reference<css::drawing::framework::XPane>& rxPane) const;
234 void Invalidate (void);
236 void StoreViewMode (const ViewMode eViewMode);
238 void LayoutStandardMode (void);
239 void LayoutNotesMode (void);
240 void LayoutUnknownMode (void);
241 void LayoutSlideSorterMode (void);
242 void LayoutHelpMode (void);
244 /** Layout the tool bar and return its outer bounding box.
246 css::geometry::RealRectangle2D LayoutToolBar (void);
248 css::awt::Size CalculatePaneSize (
249 const double nOuterWidth,
250 const ::rtl::OUString& rsPaneURL);
252 /** Notify changes of the layout mode and of the slide sorter state.
254 void NotifyLayoutModeChange (void);
256 void NotifyDisposing (void);
258 void ThrowIfDisposed (void) const throw (::com::sun::star::lang::DisposedException);
263 #endif