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 SD_PRESENTER_PRESENTER_PANE_BASE_HXX
29 #define SD_PRESENTER_PRESENTER_PANE_BASE_HXX
30 
31 #include "PresenterTheme.hxx"
32 #include <cppuhelper/basemutex.hxx>
33 #include <cppuhelper/compbase4.hxx>
34 #include <com/sun/star/awt/Point.hpp>
35 #include <com/sun/star/awt/XMouseListener.hpp>
36 #include <com/sun/star/awt/XMouseMotionListener.hpp>
37 #include <com/sun/star/awt/XWindowListener.hpp>
38 #include <com/sun/star/container/XChild.hpp>
39 #include <com/sun/star/drawing/XPresenterHelper.hpp>
40 #include <com/sun/star/drawing/framework/XPane.hpp>
41 #include <com/sun/star/drawing/framework/XPaneBorderPainter.hpp>
42 #include <com/sun/star/lang/XInitialization.hpp>
43 #include <com/sun/star/uno/XComponentContext.hpp>
44 #include <com/sun/star/util/Color.hpp>
45 #include <com/sun/star/rendering/XCanvas.hpp>
46 #include <rtl/ref.hxx>
47 #include <boost/noncopyable.hpp>
48 
49 namespace css = ::com::sun::star;
50 namespace cssu = ::com::sun::star::uno;
51 
52 
53 namespace sdext { namespace presenter {
54 
55 class PresenterController;
56 class PresenterTextView;
57 
58 namespace {
59     typedef ::cppu::WeakComponentImplHelper4 <
60         css::drawing::framework::XPane,
61         css::lang::XInitialization,
62         css::awt::XWindowListener,
63         css::awt::XPaintListener
64     > PresenterPaneBaseInterfaceBase;
65 }
66 
67 
68 /** Base class of the panes used by the presenter screen.  Pane objects are
69     stored in the PresenterPaneContainer.  Sizes and positions are
70     controlled by the PresenterWindowManager.  Interactive positioning and
71     resizing is managed by the PresenterPaneBorderManager.  Borders around
72     panes are painted by the PresenterPaneBorderPainter.
73 */
74 class PresenterPaneBase
75     : protected ::cppu::BaseMutex,
76       private ::boost::noncopyable,
77       public PresenterPaneBaseInterfaceBase
78 {
79 public:
80     PresenterPaneBase (
81         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
82         const ::rtl::Reference<PresenterController>& rpPresenterController);
83     virtual ~PresenterPaneBase (void);
84 
85     virtual void SAL_CALL disposing (void);
86 
87     css::uno::Reference<css::awt::XWindow> GetBorderWindow (void) const;
88     void SetBackground (const SharedBitmapDescriptor& rpBackground);
89     void SetTitle (const ::rtl::OUString& rsTitle);
90     ::rtl::OUString GetTitle (void) const;
91     css::uno::Reference<css::drawing::framework::XPaneBorderPainter> GetPaneBorderPainter (void) const;
92     void SetCalloutAnchor (const css::awt::Point& rAnchorPosition);
93     css::awt::Point GetCalloutAnchor (void) const;
94 
95     ::boost::shared_ptr<PresenterTextView> GetTextViewForTitle (void);
96 
97     // XInitialization
98 
99     virtual void SAL_CALL initialize (const css::uno::Sequence<css::uno::Any>& rArguments)
100         throw (css::uno::Exception, css::uno::RuntimeException);
101 
102 
103     // XResourceId
104 
105     virtual css::uno::Reference<css::drawing::framework::XResourceId> SAL_CALL getResourceId (void)
106         throw (css::uno::RuntimeException);
107 
108     virtual sal_Bool SAL_CALL isAnchorOnly (void)
109         throw (com::sun::star::uno::RuntimeException);
110 
111 
112     // XWindowListener
113 
114     virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
115         throw (css::uno::RuntimeException);
116 
117     virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
118         throw (css::uno::RuntimeException);
119 
120     virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
121         throw (css::uno::RuntimeException);
122 
123     virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
124         throw (css::uno::RuntimeException);
125 
126 
127     // lang::XEventListener
128 
129     virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
130         throw (css::uno::RuntimeException);
131 
132 
133 protected:
134     ::rtl::Reference<PresenterController> mpPresenterController;
135     css::uno::Reference<css::awt::XWindow> mxParentWindow;
136     css::uno::Reference<css::awt::XWindow> mxBorderWindow;
137     css::uno::Reference<css::rendering::XCanvas> mxBorderCanvas;
138     css::uno::Reference<css::awt::XWindow> mxContentWindow;
139     css::uno::Reference<css::rendering::XCanvas> mxContentCanvas;
140     css::uno::Reference<css::drawing::framework::XResourceId> mxPaneId;
141     css::uno::Reference<css::drawing::framework::XPaneBorderPainter> mxBorderPainter;
142     css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper;
143     ::rtl::OUString msTitle;
144     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
145     SharedBitmapDescriptor mpViewBackground;
146     bool mbHasCallout;
147     css::awt::Point maCalloutAnchor;
148 
149     virtual void CreateCanvases (
150         const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
151         const css::uno::Reference<css::rendering::XSpriteCanvas>& rxParentCanvas) = 0;
152 
153     void CreateWindows (
154         const css::uno::Reference<css::awt::XWindow>& rxParentWindow,
155         const bool bIsWindowVisibleOnCreation);
156     void PaintBorderBackground (
157         const css::awt::Rectangle& rCenterBox,
158         const css::awt::Rectangle& rUpdateBox);
159     void PaintBorder (const css::awt::Rectangle& rUpdateRectangle);
160     void ToTop (void);
161     void LayoutContextWindow (void);
162     bool IsVisible (void) const;
163 
164     /** This method throws a DisposedException when the object has already been
165         disposed.
166     */
167     void ThrowIfDisposed (void)
168         throw (css::lang::DisposedException);
169 };
170 
171 } } // end of namespace ::sd::presenter
172 
173 #endif
174