xref: /trunk/main/toolkit/source/awt/vclxtabcontrol.hxx (revision 45c5a00162811bd03b87fcb4fe9996782f2b59ec)
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 LAYOUT_AWT_VCLXTABCONTROLLER_HXX
25 #define LAYOUT_AWT_VCLXTABCONTROLLER_HXX
26 
27 #include <com/sun/star/awt/XSimpleTabController.hpp>
28 #include <comphelper/uno3.hxx>
29 #include <layout/core/box-base.hxx>
30 #include <map>
31 #include <toolkit/awt/vclxwindow.hxx>
32 
33 class TabControl;
34 
35 namespace layoutimpl
36 {
37 
38 typedef ::cppu::ImplHelper1 <   ::com::sun::star::awt::XSimpleTabController
39                                 >   VCLXTabControl_Base;
40 
41 class VCLXTabControl :public VCLXWindow
42                      ,public VCLXTabControl_Base
43                      ,public Box_Base
44 {
45     int mTabId;
46     bool bRealized;
47 
48 public:
49     VCLXTabControl();
50 
51     void AddChild (css::uno::Reference <css::awt::XLayoutConstrains> const &);
52 
53 protected:
54     ~VCLXTabControl();
55 
56     // XInterface
57     DECLARE_XINTERFACE()
58 
59     // XTypeProvider
60     DECLARE_XTYPEPROVIDER()
61 
62     // XComponent
63     void SAL_CALL dispose();
64 
65     virtual void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY );
66 
67     // XSimpleTabController
68     virtual ::sal_Int32 SAL_CALL insertTab();
69     virtual void SAL_CALL removeTab( ::sal_Int32 ID );
70 
71     virtual void SAL_CALL setTabProps( ::sal_Int32 ID, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Properties );
72     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > SAL_CALL getTabProps( ::sal_Int32 ID );
73 
74     virtual void SAL_CALL activateTab( ::sal_Int32 ID );
75     virtual ::sal_Int32 SAL_CALL getActiveTabID();
76 
77     virtual void SAL_CALL addTabListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabListener >& Listener );
78     virtual void SAL_CALL removeTabListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabListener >& Listener );
79 
80     // ::com::sun::star::awt::XLayoutContainer
81     virtual void SAL_CALL addChild(
82         const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains >& Child );
83     virtual void SAL_CALL removeChild( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains >& Child );
84 
85     virtual void SAL_CALL allocateArea( const ::com::sun::star::awt::Rectangle &rArea );
86 
87     virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize();
88 
89     // unimplemented:
90     virtual sal_Bool SAL_CALL hasHeightForWidth()
91     { return false; }
92     virtual sal_Int32 SAL_CALL getHeightForWidth( sal_Int32 /*nWidth*/ )
93     { return maRequisition.Height; }
94 
95     // VclWindowPeer
96     virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value );
97     virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName );
98 
99     // VCLXWindow
100     void ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent );
101 
102 public:
103     // Maps page ids to child references
104     struct ChildData : public Box_Base::ChildData
105     {
106         rtl::OUString maTitle;
107         ChildData( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild );
108     };
109 
110     struct ChildProps : public Box_Base::ChildProps
111     {
112         ChildProps( VCLXTabControl::ChildData *pData );
113     };
114 
115 protected:
116     ChildData *createChild( css::uno::Reference< css::awt::XLayoutConstrains > const& xChild );
117     ChildProps *createChildProps( Box_Base::ChildData* pData );
118 
119 
120     std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains >, sal_Int32 > mIdMap;
121     // FIXME: we might want to use a Multiplexer
122     std::list< ::com::sun::star::uno::Reference
123                < ::com::sun::star::awt::XTabListener > > mxTabListeners;
124 
125     inline TabControl *getTabControl() const;
126 
127 private:
128     VCLXTabControl( const VCLXTabControl& );            // never implemented
129     VCLXTabControl& operator=( const VCLXTabControl& ); // never implemented
130 };
131 
132 } // namespace layoutimpl
133 
134 #endif /* LAYOUT_AWT_VCLXTABCONTROLLER_HXX */
135