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