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 SVT_DRAWERLAYOUTER_HXX
25 #define SVT_DRAWERLAYOUTER_HXX
26 
27 #include "svtools/svtdllapi.h"
28 #include "svtools/toolpanel/refbase.hxx"
29 #include "svtools/toolpanel/toolpaneldeck.hxx"
30 #include "svtools/toolpanel/decklayouter.hxx"
31 
32 #include <boost/shared_ptr.hpp>
33 
34 //......................................................................................................................
35 namespace svt
36 {
37 //......................................................................................................................
38 
39     class ToolPanelViewShell;
40     class ToolPanelDrawer;
41     typedef ::boost::shared_ptr< ToolPanelDrawer >  PToolPanelDrawer;
42 
43 	//==================================================================================================================
44 	//= ToolPanelDrawer
45 	//==================================================================================================================
46     /** a class which implements a tool panel selector in the form of the classical drawers
47     */
48     class SVT_DLLPUBLIC DrawerDeckLayouter  :public RefBase
49                                             ,public IDeckLayouter
50                                             ,public IToolPanelDeckListener
51 	{
52     public:
53         DrawerDeckLayouter(
54             ::Window& i_rParentWindow,
55             IToolPanelDeck& i_rPanels
56         );
57         ~DrawerDeckLayouter();
58 
59         // IReference
60         DECLARE_IREFERENCE()
61 
62         // IDeckLayouter
63         virtual Rectangle   Layout( const Rectangle& i_rDeckPlayground );
64         virtual void        Destroy();
65         virtual void        SetFocusToPanelSelector();
66         virtual size_t      GetAccessibleChildCount() const;
67         virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
68                             GetAccessibleChild(
69                                 const size_t i_nChildIndex,
70                                 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& i_rParentAccessible
71                             );
72 
73         // IToolPanelDeckListener
74         virtual void PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition );
75         virtual void PanelRemoved( const size_t i_nPosition );
76         virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive );
77         virtual void LayouterChanged( const PDeckLayouter& i_rNewLayouter );
78         virtual void Dying();
79 
80     private:
81         // triggers a re-arrance of the panel deck elements
82         void    impl_triggerRearrange() const;
83         size_t  impl_getPanelPositionFromWindow( const Window* i_pDrawerWindow ) const;
84         void    impl_removeDrawer( const size_t i_nPosition );
85 
86         DECL_LINK( OnWindowEvent, VclSimpleEvent* );
87 
88 private:
89         Window&                             m_rParentWindow;
90         IToolPanelDeck&                     m_rPanelDeck;
91         ::std::vector< PToolPanelDrawer >   m_aDrawers;
92         ::boost::optional< size_t >         m_aLastKnownActivePanel;
93 	};
94 
95 //......................................................................................................................
96 } // namespace svt
97 //......................................................................................................................
98 
99 #endif // SVT_DRAWERLAYOUTER_HXX
100