1*f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f8e07b45SAndrew Rist  * distributed with this work for additional information
6*f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9*f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f8e07b45SAndrew Rist  *
11*f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f8e07b45SAndrew Rist  *
13*f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15*f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18*f8e07b45SAndrew Rist  * under the License.
19*f8e07b45SAndrew Rist  *
20*f8e07b45SAndrew Rist  *************************************************************/
21*f8e07b45SAndrew Rist 
22*f8e07b45SAndrew Rist 
23cdf0e10cSrcweir #ifndef FRAMEWORK_TABWINDOW_HXX
24cdf0e10cSrcweir #define FRAMEWORK_TABWINDOW_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <general.h>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <vector>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
31cdf0e10cSrcweir #include <vcl/tabctrl.hxx>
32cdf0e10cSrcweir #include <vcl/tabdlg.hxx>
33cdf0e10cSrcweir #include <vcl/tabpage.hxx>
34cdf0e10cSrcweir #include <vcl/button.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace com { namespace sun { namespace star {
37cdf0e10cSrcweir     namespace awt {
38cdf0e10cSrcweir         class XWindow;
39cdf0e10cSrcweir         class XContainerWindowProvider;
40cdf0e10cSrcweir         class XContainerWindowEventHandler; }
41cdf0e10cSrcweir     namespace beans {
42cdf0e10cSrcweir         struct NamedValue; }
43cdf0e10cSrcweir } } }
44cdf0e10cSrcweir 
45cdf0e10cSrcweir namespace framework
46cdf0e10cSrcweir {
47cdf0e10cSrcweir 
48cdf0e10cSrcweir class FwkTabControl : public TabControl
49cdf0e10cSrcweir {
50cdf0e10cSrcweir public:
51cdf0e10cSrcweir     FwkTabControl( Window* pParent, const ResId& rResId );
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     void    BroadcastEvent( sal_uLong nEvent );
54cdf0e10cSrcweir };
55cdf0e10cSrcweir 
56cdf0e10cSrcweir class FwkTabPage : public TabPage
57cdf0e10cSrcweir {
58cdf0e10cSrcweir private:
59cdf0e10cSrcweir     rtl::OUString                                                   m_sPageURL;
60cdf0e10cSrcweir     rtl::OUString                                                   m_sEventHdl;
61cdf0e10cSrcweir     css::uno::Reference< css::awt::XWindow >                        m_xPage;
62cdf0e10cSrcweir     css::uno::Reference< css::awt::XContainerWindowEventHandler >   m_xEventHdl;
63cdf0e10cSrcweir     css::uno::Reference< css::awt::XContainerWindowProvider >       m_xWinProvider;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     void            CreateDialog();
66cdf0e10cSrcweir     sal_Bool        CallMethod( const rtl::OUString& rMethod );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir public:
69cdf0e10cSrcweir     FwkTabPage(
70cdf0e10cSrcweir         Window* pParent,
71cdf0e10cSrcweir         const rtl::OUString& rPageURL,
72cdf0e10cSrcweir 	const css::uno::Reference< css::awt::XContainerWindowEventHandler >& rEventHdl,
73cdf0e10cSrcweir         const css::uno::Reference< css::awt::XContainerWindowProvider >& rProvider );
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     virtual ~FwkTabPage();
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     virtual void    ActivatePage();
78cdf0e10cSrcweir     virtual void    DeactivatePage();
79cdf0e10cSrcweir 	virtual void	Resize();
80cdf0e10cSrcweir };
81cdf0e10cSrcweir 
82cdf0e10cSrcweir struct TabEntry
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     sal_Int32           m_nIndex;
85cdf0e10cSrcweir     FwkTabPage*         m_pPage;
86cdf0e10cSrcweir     ::rtl::OUString     m_sPageURL;
87cdf0e10cSrcweir     css::uno::Reference< css::awt::XContainerWindowEventHandler > m_xEventHdl;
88cdf0e10cSrcweir 
TabEntryframework::TabEntry89cdf0e10cSrcweir     TabEntry() :
90cdf0e10cSrcweir         m_nIndex( -1 ), m_pPage( NULL ) {}
91cdf0e10cSrcweir 
TabEntryframework::TabEntry92cdf0e10cSrcweir     TabEntry( sal_Int32 nIndex, ::rtl::OUString sURL, const css::uno::Reference< css::awt::XContainerWindowEventHandler > & rEventHdl ) :
93cdf0e10cSrcweir         m_nIndex( nIndex ), m_pPage( NULL ), m_sPageURL( sURL ), m_xEventHdl( rEventHdl ) {}
94cdf0e10cSrcweir 
~TabEntryframework::TabEntry95cdf0e10cSrcweir     ~TabEntry() { delete m_pPage; }
96cdf0e10cSrcweir };
97cdf0e10cSrcweir 
98cdf0e10cSrcweir typedef std::vector< TabEntry* > TabEntryList;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir class FwkTabWindow : public Window
101cdf0e10cSrcweir {
102cdf0e10cSrcweir private:
103cdf0e10cSrcweir     FwkTabControl   m_aTabCtrl;
104cdf0e10cSrcweir     TabEntryList    m_TabList;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     css::uno::Reference< css::awt::XContainerWindowProvider >   m_xWinProvider;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     void            ClearEntryList();
109cdf0e10cSrcweir     TabEntry*       FindEntry( sal_Int32 nIndex ) const;
110cdf0e10cSrcweir     bool            RemoveEntry( sal_Int32 nIndex );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     DECL_DLLPRIVATE_LINK( ActivatePageHdl, TabControl * );
113cdf0e10cSrcweir     DECL_DLLPRIVATE_LINK( DeactivatePageHdl, TabControl * );
114cdf0e10cSrcweir     DECL_DLLPRIVATE_LINK( CloseHdl, PushButton * );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir public:
117cdf0e10cSrcweir     FwkTabWindow( Window* pParent );
118cdf0e10cSrcweir     ~FwkTabWindow();
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     void            AddEventListener( const Link& rEventListener );
121cdf0e10cSrcweir     void            RemoveEventListener( const Link& rEventListener );
122cdf0e10cSrcweir     FwkTabPage*     AddTabPage( sal_Int32 nIndex, const css::uno::Sequence< css::beans::NamedValue >& rProperties );
123cdf0e10cSrcweir     void            ActivatePage( sal_Int32 nIndex );
124cdf0e10cSrcweir     void            RemovePage( sal_Int32 nIndex );
125cdf0e10cSrcweir     virtual void        Resize();
126cdf0e10cSrcweir };
127cdf0e10cSrcweir 
128cdf0e10cSrcweir } // namespace framework
129cdf0e10cSrcweir 
130cdf0e10cSrcweir #endif
131cdf0e10cSrcweir 
132