xref: /aoo42x/main/sd/source/ui/inc/ViewTabBar.hxx (revision 67e470da)
1*c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c45d927aSAndrew Rist  * distributed with this work for additional information
6*c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9*c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c45d927aSAndrew Rist  *
11*c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c45d927aSAndrew Rist  *
13*c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15*c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c45d927aSAndrew Rist  * specific language governing permissions and limitations
18*c45d927aSAndrew Rist  * under the License.
19*c45d927aSAndrew Rist  *
20*c45d927aSAndrew Rist  *************************************************************/
21*c45d927aSAndrew Rist 
22*c45d927aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SD_VIEW_TAB_BAR_HXX
25cdf0e10cSrcweir #define SD_VIEW_TAB_BAR_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
28cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XPane.hpp>
29cdf0e10cSrcweir #include <com/sun/star/drawing/framework/TabBarButton.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XTabBar.hpp>
31cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XToolBar.hpp>
32cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
33cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
34cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
35cdf0e10cSrcweir #ifndef _VCL_TABCTRL_HXX_
36cdf0e10cSrcweir #include <vcl/tabctrl.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
39cdf0e10cSrcweir #include "MutexOwner.hxx"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <vector>
42cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
43cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir namespace sd { namespace tools {
46cdf0e10cSrcweir     class EventMultiplexerEvent;
47cdf0e10cSrcweir } }
48cdf0e10cSrcweir 
49cdf0e10cSrcweir namespace sd {
50cdf0e10cSrcweir     class ViewShellBase;
51cdf0e10cSrcweir     class PaneManagerEvent;
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir namespace {
55cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper4 <
56cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XToolBar,
57cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XTabBar,
58cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XConfigurationChangeListener,
59cdf0e10cSrcweir         ::com::sun::star::lang::XUnoTunnel
60cdf0e10cSrcweir         > ViewTabBarInterfaceBase;
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 
66cdf0e10cSrcweir namespace sd {
67cdf0e10cSrcweir 
68cdf0e10cSrcweir /** Tab control for switching between views in the center pane.
69cdf0e10cSrcweir */
70cdf0e10cSrcweir class ViewTabBar
71cdf0e10cSrcweir     : private sd::MutexOwner,
72cdf0e10cSrcweir       public ViewTabBarInterfaceBase
73cdf0e10cSrcweir {
74cdf0e10cSrcweir public:
75cdf0e10cSrcweir     ViewTabBar (
76cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
77cdf0e10cSrcweir             com::sun::star::drawing::framework::XResourceId>& rxViewTabBarId,
78cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
79cdf0e10cSrcweir         ::com::sun::star::frame::XController>& rxController);
80cdf0e10cSrcweir     virtual ~ViewTabBar (void);
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     ::boost::shared_ptr< ::TabControl> GetTabControl (void) const;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     bool ActivatePage (void);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     //----- drawing::framework::XConfigurationChangeListener ------------------
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     virtual void SAL_CALL
91cdf0e10cSrcweir         notifyConfigurationChange (
92cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
93cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     //----- XEventListener ----------------------------------------------------
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     virtual void SAL_CALL disposing(
99cdf0e10cSrcweir         const com::sun::star::lang::EventObject& rEvent)
100cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     //----- XTabBar -----------------------------------------------------------
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     virtual void
106cdf0e10cSrcweir         SAL_CALL addTabBarButtonAfter (
107cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::TabBarButton& rButton,
108cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::TabBarButton& rAnchor)
109cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     virtual void
112cdf0e10cSrcweir         SAL_CALL appendTabBarButton (
113cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::TabBarButton& rButton)
114cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     virtual void
117cdf0e10cSrcweir         SAL_CALL removeTabBarButton (
118cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::TabBarButton& rButton)
119cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     virtual sal_Bool
122cdf0e10cSrcweir         SAL_CALL hasTabBarButton (
123cdf0e10cSrcweir             const ::com::sun::star::drawing::framework::TabBarButton& rButton)
124cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence<com::sun::star::drawing::framework::TabBarButton>
127cdf0e10cSrcweir         SAL_CALL getTabBarButtons (void)
128cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     //----- XResource ---------------------------------------------------------
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
134cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XResourceId> SAL_CALL getResourceId (void)
135cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isAnchorOnly (void)
138cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 
141cdf0e10cSrcweir     //----- XUnoTunnel --------------------------------------------------------
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId)
144cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     // ------------------------------------------------------------------------
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     /** The returned value is calculated as the difference between the
149cdf0e10cSrcweir         total height of the control and the heigh of its first tab page.
150cdf0e10cSrcweir         This can be considered a hack.
151cdf0e10cSrcweir         This procedure works only when the control is visible.  Calling this
152cdf0e10cSrcweir         method when the control is not visible results in returning a
153cdf0e10cSrcweir         default value.
154cdf0e10cSrcweir         To be on the safe side wait for this control to become visible and
155cdf0e10cSrcweir         the call this method again.
156cdf0e10cSrcweir     */
157cdf0e10cSrcweir     int GetHeight (void);
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     void AddTabBarButton (
160cdf0e10cSrcweir         const ::com::sun::star::drawing::framework::TabBarButton& rButton,
161cdf0e10cSrcweir         const ::com::sun::star::drawing::framework::TabBarButton& rAnchor);
162cdf0e10cSrcweir     void AddTabBarButton (
163cdf0e10cSrcweir         const ::com::sun::star::drawing::framework::TabBarButton& rButton);
164cdf0e10cSrcweir     void RemoveTabBarButton (
165cdf0e10cSrcweir         const ::com::sun::star::drawing::framework::TabBarButton& rButton);
166cdf0e10cSrcweir     bool HasTabBarButton (
167cdf0e10cSrcweir         const ::com::sun::star::drawing::framework::TabBarButton& rButton);
168cdf0e10cSrcweir     ::com::sun::star::uno::Sequence<com::sun::star::drawing::framework::TabBarButton>
169cdf0e10cSrcweir         GetTabBarButtons (void);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir private:
172cdf0e10cSrcweir     ::boost::shared_ptr< ::TabControl> mpTabControl;
173cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
174cdf0e10cSrcweir         ::com::sun::star::frame::XController> mxController;
175cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
176cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XConfigurationController> mxConfigurationController;
177cdf0e10cSrcweir     typedef ::std::vector<com::sun::star::drawing::framework::TabBarButton> TabBarButtonList;
178cdf0e10cSrcweir     TabBarButtonList maTabBarButtons;
179cdf0e10cSrcweir     ::boost::scoped_ptr<TabPage> mpTabPage;
180cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
181cdf0e10cSrcweir         ::com::sun::star::drawing::framework::XResourceId> mxViewTabBarId;
182cdf0e10cSrcweir     ViewShellBase* mpViewShellBase;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir     void UpdateActiveButton (void);
185cdf0e10cSrcweir     void AddTabBarButton (
186cdf0e10cSrcweir         const ::com::sun::star::drawing::framework::TabBarButton& rButton,
187cdf0e10cSrcweir         sal_Int32 nPosition);
188cdf0e10cSrcweir     void UpdateTabBarButtons (void);
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     /** This method is called from the constructor to get the window for an
191cdf0e10cSrcweir         anchor ResourceId and pass it to our base class.  It has to be
192cdf0e10cSrcweir         static because it must not access any of the, not yet initialized
193cdf0e10cSrcweir         members.
194cdf0e10cSrcweir     */
195cdf0e10cSrcweir     static ::Window* GetAnchorWindow(
196cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
197cdf0e10cSrcweir             ::com::sun::star::drawing::framework::XResourceId>& rxViewTabBarId,
198cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
199cdf0e10cSrcweir             ::com::sun::star::frame::XController>& rxController);
200cdf0e10cSrcweir     const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
201cdf0e10cSrcweir };
202cdf0e10cSrcweir 
203cdf0e10cSrcweir } // end of namespace sd
204cdf0e10cSrcweir 
205cdf0e10cSrcweir #endif
206cdf0e10cSrcweir 
207