122de8995SAndre Fischer /**************************************************************
222de8995SAndre Fischer  *
322de8995SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
422de8995SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
522de8995SAndre Fischer  * distributed with this work for additional information
622de8995SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
722de8995SAndre Fischer  * to you under the Apache License, Version 2.0 (the
822de8995SAndre Fischer  * "License"); you may not use this file except in compliance
922de8995SAndre Fischer  * with the License.  You may obtain a copy of the License at
1022de8995SAndre Fischer  *
1122de8995SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
1222de8995SAndre Fischer  *
1322de8995SAndre Fischer  * Unless required by applicable law or agreed to in writing,
1422de8995SAndre Fischer  * software distributed under the License is distributed on an
1522de8995SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1622de8995SAndre Fischer  * KIND, either express or implied.  See the License for the
1722de8995SAndre Fischer  * specific language governing permissions and limitations
1822de8995SAndre Fischer  * under the License.
1922de8995SAndre Fischer  *
2022de8995SAndre Fischer  *************************************************************/
2122de8995SAndre Fischer 
2222de8995SAndre Fischer #ifndef SFX_SIDEBAR_CONTROLLER_HXX
2322de8995SAndre Fischer #define SFX_SIDEBAR_CONTROLLER_HXX
2422de8995SAndre Fischer 
25ff12d537SAndre Fischer #include "ResourceManager.hxx"
2695a18594SAndre Fischer #include "AsynchronousCall.hxx"
2795a18594SAndre Fischer #include "TabBar.hxx"
28*7a32b0c8SAndre Fischer #include "Context.hxx"
2995a18594SAndre Fischer 
3095a18594SAndre Fischer #include <vcl/menu.hxx>
3122de8995SAndre Fischer 
32b9e67834SAndre Fischer #include <com/sun/star/awt/XWindowPeer.hpp>
33b9e67834SAndre Fischer #include <com/sun/star/beans/XPropertyChangeListener.hpp>
3422de8995SAndre Fischer #include <com/sun/star/ui/XContextChangeEventListener.hpp>
3595a18594SAndre Fischer #include <com/sun/star/ui/XUIElement.hpp>
36*7a32b0c8SAndre Fischer #include <com/sun/star/ui/XSidebar.hpp>
3795a18594SAndre Fischer 
3822de8995SAndre Fischer #include <boost/noncopyable.hpp>
39*7a32b0c8SAndre Fischer #include <cppuhelper/compbase3.hxx>
4022de8995SAndre Fischer #include <cppuhelper/basemutex.hxx>
4122de8995SAndre Fischer 
4222de8995SAndre Fischer namespace css = ::com::sun::star;
4322de8995SAndre Fischer namespace cssu = ::com::sun::star::uno;
4422de8995SAndre Fischer 
45*7a32b0c8SAndre Fischer 
4622de8995SAndre Fischer namespace
4722de8995SAndre Fischer {
48*7a32b0c8SAndre Fischer     typedef ::cppu::WeakComponentImplHelper3 <
49b9e67834SAndre Fischer         css::ui::XContextChangeEventListener,
50*7a32b0c8SAndre Fischer         css::beans::XPropertyChangeListener,
51*7a32b0c8SAndre Fischer         css::ui::XSidebar
5222de8995SAndre Fischer         > SidebarControllerInterfaceBase;
5322de8995SAndre Fischer }
5422de8995SAndre Fischer 
55ff12d537SAndre Fischer namespace sfx2 { namespace sidebar {
5622de8995SAndre Fischer 
5795a18594SAndre Fischer class ContentPanelDescriptor;
5895a18594SAndre Fischer class Deck;
5995a18594SAndre Fischer class DeckConfiguration;
6095a18594SAndre Fischer class DeckDescriptor;
61b9e67834SAndre Fischer class Panel;
62*7a32b0c8SAndre Fischer class SidebarDockingWindow;
6322de8995SAndre Fischer class TabBar;
64ff12d537SAndre Fischer class TabBarConfiguration;
6522de8995SAndre Fischer 
6622de8995SAndre Fischer class SidebarController
6722de8995SAndre Fischer     : private ::boost::noncopyable,
6822de8995SAndre Fischer       private ::cppu::BaseMutex,
6922de8995SAndre Fischer       public SidebarControllerInterfaceBase
7022de8995SAndre Fischer {
7122de8995SAndre Fischer public:
7222de8995SAndre Fischer     SidebarController(
73*7a32b0c8SAndre Fischer         SidebarDockingWindow* pParentWindow,
7422de8995SAndre Fischer         const cssu::Reference<css::frame::XFrame>& rxFrame);
7522de8995SAndre Fischer     virtual ~SidebarController (void);
7622de8995SAndre Fischer 
77b9e67834SAndre Fischer     // ui::XContextChangeEventListener
7822de8995SAndre Fischer     virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent)
7922de8995SAndre Fischer         throw(cssu::RuntimeException);
8022de8995SAndre Fischer 
81b9e67834SAndre Fischer     // XEventListener
8222de8995SAndre Fischer     virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject)
8322de8995SAndre Fischer         throw(cssu::RuntimeException);
8422de8995SAndre Fischer 
85b9e67834SAndre Fischer     // beans::XPropertyChangeListener
86b9e67834SAndre Fischer     virtual void SAL_CALL propertyChange (const css::beans::PropertyChangeEvent& rEvent)
87b9e67834SAndre Fischer         throw(cssu::RuntimeException);
88*7a32b0c8SAndre Fischer 
89*7a32b0c8SAndre Fischer     // ui::XSidebar
90*7a32b0c8SAndre Fischer     virtual void SAL_CALL requestLayout (void)
91*7a32b0c8SAndre Fischer         throw(cssu::RuntimeException);
92b9e67834SAndre Fischer 
9322de8995SAndre Fischer     void NotifyResize (void);
9422de8995SAndre Fischer 
95ff12d537SAndre Fischer     void SwitchToDeck (
9695a18594SAndre Fischer         const ::rtl::OUString& rsDeckId);
97ff12d537SAndre Fischer 
98*7a32b0c8SAndre Fischer     /** Show only the tab bar, not the deck.
99*7a32b0c8SAndre Fischer     */
100*7a32b0c8SAndre Fischer     void CloseDeck (void);
101*7a32b0c8SAndre Fischer 
102*7a32b0c8SAndre Fischer     /** Open the deck area and restore the parent window to its old width.
103*7a32b0c8SAndre Fischer     */
104*7a32b0c8SAndre Fischer     void OpenDeck (void);
105*7a32b0c8SAndre Fischer 
10622de8995SAndre Fischer private:
107ff12d537SAndre Fischer     ::boost::shared_ptr<DeckConfiguration> mpCurrentConfiguration;
108*7a32b0c8SAndre Fischer     SidebarDockingWindow* mpParentWindow;
109*7a32b0c8SAndre Fischer     ::boost::scoped_ptr<TabBar> mpTabBar;
11022de8995SAndre Fischer     cssu::Reference<css::frame::XFrame> mxFrame;
111*7a32b0c8SAndre Fischer     Context maCurrentContext;
11295a18594SAndre Fischer     ::rtl::OUString msCurrentDeckId;
11395a18594SAndre Fischer     AsynchronousCall maPropertyChangeForwarder;
114*7a32b0c8SAndre Fischer     bool mbIsDeckClosed;
115*7a32b0c8SAndre Fischer     /** Before the deck is closed the sidebar width is saved into this variable,
116*7a32b0c8SAndre Fischer         so that it can be restored when the deck is reopended.
117*7a32b0c8SAndre Fischer     */
118*7a32b0c8SAndre Fischer     sal_Int32 mnSavedSidebarWidth;
11995a18594SAndre Fischer 
12022de8995SAndre Fischer     DECL_LINK(WindowEventHandler, VclWindowEvent*);
121*7a32b0c8SAndre Fischer     void UpdateConfigurations (const Context& rContext);
122ff12d537SAndre Fischer     cssu::Reference<css::ui::XUIElement> CreateUIElement (
123ff12d537SAndre Fischer         const cssu::Reference<css::awt::XWindowPeer>& rxWindow,
124b9e67834SAndre Fischer         const ::rtl::OUString& rsImplementationURL,
125*7a32b0c8SAndre Fischer         Panel* pPanel);
12695a18594SAndre Fischer     Panel* CreatePanel (
12795a18594SAndre Fischer         const ::rtl::OUString& rsPanelId,
128*7a32b0c8SAndre Fischer         ::Window* pParentWindow);
129ff12d537SAndre Fischer     void SwitchToDeck (
130ff12d537SAndre Fischer         const DeckDescriptor& rDeckDescriptor,
131*7a32b0c8SAndre Fischer         const Context& rContext);
13295a18594SAndre Fischer     void ShowPopupMenu (
13395a18594SAndre Fischer         const Rectangle& rButtonBox,
13495a18594SAndre Fischer         const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData,
13595a18594SAndre Fischer         const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const;
13695a18594SAndre Fischer     ::boost::shared_ptr<PopupMenu> CreatePopupMenu (
13795a18594SAndre Fischer         const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData,
13895a18594SAndre Fischer         const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const;
139ff12d537SAndre Fischer     DECL_LINK(OnMenuItemSelected, Menu*);
14095a18594SAndre Fischer     void BroadcastPropertyChange (void);
14122de8995SAndre Fischer 
142*7a32b0c8SAndre Fischer     /** The close of the deck changes the width of the child window.
143*7a32b0c8SAndre Fischer         That is only possible if there is no other docking window docked above or below the sidebar.
144*7a32b0c8SAndre Fischer         Return whether the width of the child window can be modified.
145*7a32b0c8SAndre Fischer     */
146*7a32b0c8SAndre Fischer     bool CanModifyChildWindowWidth (void) const;
147*7a32b0c8SAndre Fischer 
148*7a32b0c8SAndre Fischer     /** Set the child window container to a new width.
149*7a32b0c8SAndre Fischer         Return the old width.
150*7a32b0c8SAndre Fischer     */
151*7a32b0c8SAndre Fischer     sal_Int32 SetChildWindowWidth (const sal_Int32 nNewWidth);
152*7a32b0c8SAndre Fischer 
153*7a32b0c8SAndre Fischer     void RestrictWidth (void);
154*7a32b0c8SAndre Fischer 
15522de8995SAndre Fischer     virtual void SAL_CALL disposing (void);
15622de8995SAndre Fischer };
15722de8995SAndre Fischer 
15822de8995SAndre Fischer 
159ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
16022de8995SAndre Fischer 
16122de8995SAndre Fischer #endif
162