xref: /aoo42x/main/sd/source/ui/inc/ViewTabBar.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SD_VIEW_TAB_BAR_HXX
29*cdf0e10cSrcweir #define SD_VIEW_TAB_BAR_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XPane.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/TabBarButton.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XTabBar.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XToolBar.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
39*cdf0e10cSrcweir #ifndef _VCL_TABCTRL_HXX_
40*cdf0e10cSrcweir #include <vcl/tabctrl.hxx>
41*cdf0e10cSrcweir #endif
42*cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
43*cdf0e10cSrcweir #include "MutexOwner.hxx"
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #include <vector>
46*cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
47*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir namespace sd { namespace tools {
50*cdf0e10cSrcweir     class EventMultiplexerEvent;
51*cdf0e10cSrcweir } }
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir namespace sd {
54*cdf0e10cSrcweir     class ViewShellBase;
55*cdf0e10cSrcweir     class PaneManagerEvent;
56*cdf0e10cSrcweir }
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir namespace {
59*cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper4 <
60*cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XToolBar,
61*cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XTabBar,
62*cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XConfigurationChangeListener,
63*cdf0e10cSrcweir         ::com::sun::star::lang::XUnoTunnel
64*cdf0e10cSrcweir         > ViewTabBarInterfaceBase;
65*cdf0e10cSrcweir }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir namespace sd {
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir /** Tab control for switching between views in the center pane.
73*cdf0e10cSrcweir */
74*cdf0e10cSrcweir class ViewTabBar
75*cdf0e10cSrcweir     : private sd::MutexOwner,
76*cdf0e10cSrcweir       public ViewTabBarInterfaceBase
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir public:
79*cdf0e10cSrcweir     ViewTabBar (
80*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
81*cdf0e10cSrcweir             com::sun::star::drawing::framework::XResourceId>& rxViewTabBarId,
82*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
83*cdf0e10cSrcweir         ::com::sun::star::frame::XController>& rxController);
84*cdf0e10cSrcweir     virtual ~ViewTabBar (void);
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     ::boost::shared_ptr< ::TabControl> GetTabControl (void) const;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     bool ActivatePage (void);
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     //----- drawing::framework::XConfigurationChangeListener ------------------
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     virtual void SAL_CALL
95*cdf0e10cSrcweir         notifyConfigurationChange (
96*cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
97*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir     //----- XEventListener ----------------------------------------------------
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     virtual void SAL_CALL disposing(
103*cdf0e10cSrcweir         const com::sun::star::lang::EventObject& rEvent)
104*cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir     //----- XTabBar -----------------------------------------------------------
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     virtual void
110*cdf0e10cSrcweir         SAL_CALL addTabBarButtonAfter (
111*cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::TabBarButton& rButton,
112*cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::TabBarButton& rAnchor)
113*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     virtual void
116*cdf0e10cSrcweir         SAL_CALL appendTabBarButton (
117*cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::TabBarButton& rButton)
118*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     virtual void
121*cdf0e10cSrcweir         SAL_CALL removeTabBarButton (
122*cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::TabBarButton& rButton)
123*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir     virtual sal_Bool
126*cdf0e10cSrcweir         SAL_CALL hasTabBarButton (
127*cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::TabBarButton& rButton)
128*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence<com::sun::star::drawing::framework::TabBarButton>
131*cdf0e10cSrcweir         SAL_CALL getTabBarButtons (void)
132*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     //----- XResource ---------------------------------------------------------
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
138*cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XResourceId> SAL_CALL getResourceId (void)
139*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isAnchorOnly (void)
142*cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     //----- XUnoTunnel --------------------------------------------------------
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId)
148*cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     // ------------------------------------------------------------------------
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     /** The returned value is calculated as the difference between the
153*cdf0e10cSrcweir         total height of the control and the heigh of its first tab page.
154*cdf0e10cSrcweir         This can be considered a hack.
155*cdf0e10cSrcweir         This procedure works only when the control is visible.  Calling this
156*cdf0e10cSrcweir         method when the control is not visible results in returning a
157*cdf0e10cSrcweir         default value.
158*cdf0e10cSrcweir         To be on the safe side wait for this control to become visible and
159*cdf0e10cSrcweir         the call this method again.
160*cdf0e10cSrcweir     */
161*cdf0e10cSrcweir     int GetHeight (void);
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir     void AddTabBarButton (
164*cdf0e10cSrcweir         const ::com::sun::star::drawing::framework::TabBarButton& rButton,
165*cdf0e10cSrcweir         const ::com::sun::star::drawing::framework::TabBarButton& rAnchor);
166*cdf0e10cSrcweir     void AddTabBarButton (
167*cdf0e10cSrcweir         const ::com::sun::star::drawing::framework::TabBarButton& rButton);
168*cdf0e10cSrcweir     void RemoveTabBarButton (
169*cdf0e10cSrcweir         const ::com::sun::star::drawing::framework::TabBarButton& rButton);
170*cdf0e10cSrcweir     bool HasTabBarButton (
171*cdf0e10cSrcweir         const ::com::sun::star::drawing::framework::TabBarButton& rButton);
172*cdf0e10cSrcweir     ::com::sun::star::uno::Sequence<com::sun::star::drawing::framework::TabBarButton>
173*cdf0e10cSrcweir         GetTabBarButtons (void);
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir private:
176*cdf0e10cSrcweir     ::boost::shared_ptr< ::TabControl> mpTabControl;
177*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
178*cdf0e10cSrcweir         ::com::sun::star::frame::XController> mxController;
179*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
180*cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XConfigurationController> mxConfigurationController;
181*cdf0e10cSrcweir     typedef ::std::vector<com::sun::star::drawing::framework::TabBarButton> TabBarButtonList;
182*cdf0e10cSrcweir     TabBarButtonList maTabBarButtons;
183*cdf0e10cSrcweir     ::boost::scoped_ptr<TabPage> mpTabPage;
184*cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
185*cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XResourceId> mxViewTabBarId;
186*cdf0e10cSrcweir     ViewShellBase* mpViewShellBase;
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     void UpdateActiveButton (void);
189*cdf0e10cSrcweir     void AddTabBarButton (
190*cdf0e10cSrcweir         const ::com::sun::star::drawing::framework::TabBarButton& rButton,
191*cdf0e10cSrcweir         sal_Int32 nPosition);
192*cdf0e10cSrcweir     void UpdateTabBarButtons (void);
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir     /** This method is called from the constructor to get the window for an
195*cdf0e10cSrcweir         anchor ResourceId and pass it to our base class.  It has to be
196*cdf0e10cSrcweir         static because it must not access any of the, not yet initialized
197*cdf0e10cSrcweir         members.
198*cdf0e10cSrcweir     */
199*cdf0e10cSrcweir     static ::Window* GetAnchorWindow(
200*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
201*cdf0e10cSrcweir             ::com::sun::star::drawing::framework::XResourceId>& rxViewTabBarId,
202*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
203*cdf0e10cSrcweir             ::com::sun::star::frame::XController>& rxController);
204*cdf0e10cSrcweir     const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
205*cdf0e10cSrcweir };
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir } // end of namespace sd
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir #endif
210*cdf0e10cSrcweir 
211