xref: /trunk/main/sd/source/ui/inc/ViewTabBar.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 
94 
95     //----- XEventListener ----------------------------------------------------
96 
97     virtual void SAL_CALL disposing(
98         const com::sun::star::lang::EventObject& rEvent);
99 
100 
101     //----- XTabBar -----------------------------------------------------------
102 
103     virtual void
104         SAL_CALL addTabBarButtonAfter (
105             const ::com::sun::star::drawing::framework::TabBarButton& rButton,
106             const ::com::sun::star::drawing::framework::TabBarButton& rAnchor);
107 
108     virtual void
109         SAL_CALL appendTabBarButton (
110             const ::com::sun::star::drawing::framework::TabBarButton& rButton);
111 
112     virtual void
113         SAL_CALL removeTabBarButton (
114             const ::com::sun::star::drawing::framework::TabBarButton& rButton);
115 
116     virtual sal_Bool
117         SAL_CALL hasTabBarButton (
118             const ::com::sun::star::drawing::framework::TabBarButton& rButton);
119 
120     virtual ::com::sun::star::uno::Sequence<com::sun::star::drawing::framework::TabBarButton>
121         SAL_CALL getTabBarButtons (void);
122 
123 
124     //----- XResource ---------------------------------------------------------
125 
126     virtual ::com::sun::star::uno::Reference<
127         ::com::sun::star::drawing::framework::XResourceId> SAL_CALL getResourceId (void);
128 
129     virtual sal_Bool SAL_CALL isAnchorOnly (void);
130 
131 
132     //----- XUnoTunnel --------------------------------------------------------
133 
134     virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId);
135 
136     // ------------------------------------------------------------------------
137 
138     /** The returned value is calculated as the difference between the
139         total height of the control and the heigh of its first tab page.
140         This can be considered a hack.
141         This procedure works only when the control is visible.  Calling this
142         method when the control is not visible results in returning a
143         default value.
144         To be on the safe side wait for this control to become visible and
145         the call this method again.
146     */
147     int GetHeight (void);
148 
149     void AddTabBarButton (
150         const ::com::sun::star::drawing::framework::TabBarButton& rButton,
151         const ::com::sun::star::drawing::framework::TabBarButton& rAnchor);
152     void AddTabBarButton (
153         const ::com::sun::star::drawing::framework::TabBarButton& rButton);
154     void RemoveTabBarButton (
155         const ::com::sun::star::drawing::framework::TabBarButton& rButton);
156     bool HasTabBarButton (
157         const ::com::sun::star::drawing::framework::TabBarButton& rButton);
158     ::com::sun::star::uno::Sequence<com::sun::star::drawing::framework::TabBarButton>
159         GetTabBarButtons (void);
160 
161 private:
162     ::boost::shared_ptr< ::TabControl> mpTabControl;
163     ::com::sun::star::uno::Reference<
164         ::com::sun::star::frame::XController> mxController;
165     ::com::sun::star::uno::Reference<
166         ::com::sun::star::drawing::framework::XConfigurationController> mxConfigurationController;
167     typedef ::std::vector<com::sun::star::drawing::framework::TabBarButton> TabBarButtonList;
168     TabBarButtonList maTabBarButtons;
169     ::boost::scoped_ptr<TabPage> mpTabPage;
170     ::com::sun::star::uno::Reference<
171         ::com::sun::star::drawing::framework::XResourceId> mxViewTabBarId;
172     ViewShellBase* mpViewShellBase;
173 
174     void UpdateActiveButton (void);
175     void AddTabBarButton (
176         const ::com::sun::star::drawing::framework::TabBarButton& rButton,
177         sal_Int32 nPosition);
178     void UpdateTabBarButtons (void);
179 
180     /** This method is called from the constructor to get the window for an
181         anchor ResourceId and pass it to our base class.  It has to be
182         static because it must not access any of the, not yet initialized
183         members.
184     */
185     static ::Window* GetAnchorWindow(
186         const ::com::sun::star::uno::Reference<
187             ::com::sun::star::drawing::framework::XResourceId>& rxViewTabBarId,
188         const ::com::sun::star::uno::Reference<
189             ::com::sun::star::frame::XController>& rxController);
190     const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
191 };
192 
193 } // end of namespace sd
194 
195 #endif
196