xref: /aoo42x/main/sd/source/ui/inc/ViewTabBar.hxx (revision cdf0e10c)
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_VIEW_TAB_BAR_HXX
29 #define SD_VIEW_TAB_BAR_HXX
30 
31 #include <com/sun/star/frame/XController.hpp>
32 #include <com/sun/star/drawing/framework/XPane.hpp>
33 #include <com/sun/star/drawing/framework/TabBarButton.hpp>
34 #include <com/sun/star/drawing/framework/XTabBar.hpp>
35 #include <com/sun/star/drawing/framework/XToolBar.hpp>
36 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
37 #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
38 #include <com/sun/star/lang/XUnoTunnel.hpp>
39 #ifndef _VCL_TABCTRL_HXX_
40 #include <vcl/tabctrl.hxx>
41 #endif
42 #include <cppuhelper/compbase4.hxx>
43 #include "MutexOwner.hxx"
44 
45 #include <vector>
46 #include <boost/scoped_ptr.hpp>
47 #include <boost/shared_ptr.hpp>
48 
49 namespace sd { namespace tools {
50     class EventMultiplexerEvent;
51 } }
52 
53 namespace sd {
54     class ViewShellBase;
55     class PaneManagerEvent;
56 }
57 
58 namespace {
59     typedef ::cppu::WeakComponentImplHelper4 <
60         ::com::sun::star::drawing::framework::XToolBar,
61         ::com::sun::star::drawing::framework::XTabBar,
62         ::com::sun::star::drawing::framework::XConfigurationChangeListener,
63         ::com::sun::star::lang::XUnoTunnel
64         > ViewTabBarInterfaceBase;
65 }
66 
67 
68 
69 
70 namespace sd {
71 
72 /** Tab control for switching between views in the center pane.
73 */
74 class ViewTabBar
75     : private sd::MutexOwner,
76       public ViewTabBarInterfaceBase
77 {
78 public:
79     ViewTabBar (
80         const ::com::sun::star::uno::Reference<
81             com::sun::star::drawing::framework::XResourceId>& rxViewTabBarId,
82         const ::com::sun::star::uno::Reference<
83         ::com::sun::star::frame::XController>& rxController);
84     virtual ~ViewTabBar (void);
85 
86     virtual void SAL_CALL disposing (void);
87 
88     ::boost::shared_ptr< ::TabControl> GetTabControl (void) const;
89 
90     bool ActivatePage (void);
91 
92     //----- drawing::framework::XConfigurationChangeListener ------------------
93 
94     virtual void SAL_CALL
95         notifyConfigurationChange (
96             const ::com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
97         throw (::com::sun::star::uno::RuntimeException);
98 
99 
100     //----- XEventListener ----------------------------------------------------
101 
102     virtual void SAL_CALL disposing(
103         const com::sun::star::lang::EventObject& rEvent)
104         throw (com::sun::star::uno::RuntimeException);
105 
106 
107     //----- XTabBar -----------------------------------------------------------
108 
109     virtual void
110         SAL_CALL addTabBarButtonAfter (
111             const ::com::sun::star::drawing::framework::TabBarButton& rButton,
112             const ::com::sun::star::drawing::framework::TabBarButton& rAnchor)
113         throw (::com::sun::star::uno::RuntimeException);
114 
115     virtual void
116         SAL_CALL appendTabBarButton (
117             const ::com::sun::star::drawing::framework::TabBarButton& rButton)
118         throw (::com::sun::star::uno::RuntimeException);
119 
120     virtual void
121         SAL_CALL removeTabBarButton (
122             const ::com::sun::star::drawing::framework::TabBarButton& rButton)
123         throw (::com::sun::star::uno::RuntimeException);
124 
125     virtual sal_Bool
126         SAL_CALL hasTabBarButton (
127             const ::com::sun::star::drawing::framework::TabBarButton& rButton)
128         throw (::com::sun::star::uno::RuntimeException);
129 
130     virtual ::com::sun::star::uno::Sequence<com::sun::star::drawing::framework::TabBarButton>
131         SAL_CALL getTabBarButtons (void)
132         throw (::com::sun::star::uno::RuntimeException);
133 
134 
135     //----- XResource ---------------------------------------------------------
136 
137     virtual ::com::sun::star::uno::Reference<
138         ::com::sun::star::drawing::framework::XResourceId> SAL_CALL getResourceId (void)
139         throw (::com::sun::star::uno::RuntimeException);
140 
141     virtual sal_Bool SAL_CALL isAnchorOnly (void)
142         throw (com::sun::star::uno::RuntimeException);
143 
144 
145     //----- XUnoTunnel --------------------------------------------------------
146 
147     virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId)
148         throw (com::sun::star::uno::RuntimeException);
149 
150     // ------------------------------------------------------------------------
151 
152     /** The returned value is calculated as the difference between the
153         total height of the control and the heigh of its first tab page.
154         This can be considered a hack.
155         This procedure works only when the control is visible.  Calling this
156         method when the control is not visible results in returning a
157         default value.
158         To be on the safe side wait for this control to become visible and
159         the call this method again.
160     */
161     int GetHeight (void);
162 
163     void AddTabBarButton (
164         const ::com::sun::star::drawing::framework::TabBarButton& rButton,
165         const ::com::sun::star::drawing::framework::TabBarButton& rAnchor);
166     void AddTabBarButton (
167         const ::com::sun::star::drawing::framework::TabBarButton& rButton);
168     void RemoveTabBarButton (
169         const ::com::sun::star::drawing::framework::TabBarButton& rButton);
170     bool HasTabBarButton (
171         const ::com::sun::star::drawing::framework::TabBarButton& rButton);
172     ::com::sun::star::uno::Sequence<com::sun::star::drawing::framework::TabBarButton>
173         GetTabBarButtons (void);
174 
175 private:
176     ::boost::shared_ptr< ::TabControl> mpTabControl;
177     ::com::sun::star::uno::Reference<
178         ::com::sun::star::frame::XController> mxController;
179     ::com::sun::star::uno::Reference<
180         ::com::sun::star::drawing::framework::XConfigurationController> mxConfigurationController;
181     typedef ::std::vector<com::sun::star::drawing::framework::TabBarButton> TabBarButtonList;
182     TabBarButtonList maTabBarButtons;
183     ::boost::scoped_ptr<TabPage> mpTabPage;
184     ::com::sun::star::uno::Reference<
185         ::com::sun::star::drawing::framework::XResourceId> mxViewTabBarId;
186     ViewShellBase* mpViewShellBase;
187 
188     void UpdateActiveButton (void);
189     void AddTabBarButton (
190         const ::com::sun::star::drawing::framework::TabBarButton& rButton,
191         sal_Int32 nPosition);
192     void UpdateTabBarButtons (void);
193 
194     /** This method is called from the constructor to get the window for an
195         anchor ResourceId and pass it to our base class.  It has to be
196         static because it must not access any of the, not yet initialized
197         members.
198     */
199     static ::Window* GetAnchorWindow(
200         const ::com::sun::star::uno::Reference<
201             ::com::sun::star::drawing::framework::XResourceId>& rxViewTabBarId,
202         const ::com::sun::star::uno::Reference<
203             ::com::sun::star::frame::XController>& rxController);
204     const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
205 };
206 
207 } // end of namespace sd
208 
209 #endif
210 
211