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 #ifndef FRAMEWORK_TABWINDOW_HXX
24 #define FRAMEWORK_TABWINDOW_HXX
25 
26 #include <general.h>
27 
28 #include <vector>
29 
30 #include <com/sun/star/uno/Reference.h>
31 #include <vcl/tabctrl.hxx>
32 #include <vcl/tabdlg.hxx>
33 #include <vcl/tabpage.hxx>
34 #include <vcl/button.hxx>
35 
36 namespace com { namespace sun { namespace star {
37     namespace awt {
38         class XWindow;
39         class XContainerWindowProvider;
40         class XContainerWindowEventHandler; }
41     namespace beans {
42         struct NamedValue; }
43 } } }
44 
45 namespace framework
46 {
47 
48 class FwkTabControl : public TabControl
49 {
50 public:
51     FwkTabControl( Window* pParent, const ResId& rResId );
52 
53     void    BroadcastEvent( sal_uLong nEvent );
54 };
55 
56 class FwkTabPage : public TabPage
57 {
58 private:
59     rtl::OUString                                                   m_sPageURL;
60     rtl::OUString                                                   m_sEventHdl;
61     css::uno::Reference< css::awt::XWindow >                        m_xPage;
62     css::uno::Reference< css::awt::XContainerWindowEventHandler >   m_xEventHdl;
63     css::uno::Reference< css::awt::XContainerWindowProvider >       m_xWinProvider;
64 
65     void            CreateDialog();
66     sal_Bool        CallMethod( const rtl::OUString& rMethod );
67 
68 public:
69     FwkTabPage(
70         Window* pParent,
71         const rtl::OUString& rPageURL,
72 	const css::uno::Reference< css::awt::XContainerWindowEventHandler >& rEventHdl,
73         const css::uno::Reference< css::awt::XContainerWindowProvider >& rProvider );
74 
75     virtual ~FwkTabPage();
76 
77     virtual void    ActivatePage();
78     virtual void    DeactivatePage();
79 	virtual void	Resize();
80 };
81 
82 struct TabEntry
83 {
84     sal_Int32           m_nIndex;
85     FwkTabPage*         m_pPage;
86     ::rtl::OUString     m_sPageURL;
87     css::uno::Reference< css::awt::XContainerWindowEventHandler > m_xEventHdl;
88 
TabEntryframework::TabEntry89     TabEntry() :
90         m_nIndex( -1 ), m_pPage( NULL ) {}
91 
TabEntryframework::TabEntry92     TabEntry( sal_Int32 nIndex, ::rtl::OUString sURL, const css::uno::Reference< css::awt::XContainerWindowEventHandler > & rEventHdl ) :
93         m_nIndex( nIndex ), m_pPage( NULL ), m_sPageURL( sURL ), m_xEventHdl( rEventHdl ) {}
94 
~TabEntryframework::TabEntry95     ~TabEntry() { delete m_pPage; }
96 };
97 
98 typedef std::vector< TabEntry* > TabEntryList;
99 
100 class FwkTabWindow : public Window
101 {
102 private:
103     FwkTabControl   m_aTabCtrl;
104     TabEntryList    m_TabList;
105 
106     css::uno::Reference< css::awt::XContainerWindowProvider >   m_xWinProvider;
107 
108     void            ClearEntryList();
109     TabEntry*       FindEntry( sal_Int32 nIndex ) const;
110     bool            RemoveEntry( sal_Int32 nIndex );
111 
112     DECL_DLLPRIVATE_LINK( ActivatePageHdl, TabControl * );
113     DECL_DLLPRIVATE_LINK( DeactivatePageHdl, TabControl * );
114     DECL_DLLPRIVATE_LINK( CloseHdl, PushButton * );
115 
116 public:
117     FwkTabWindow( Window* pParent );
118     ~FwkTabWindow();
119 
120     void            AddEventListener( const Link& rEventListener );
121     void            RemoveEventListener( const Link& rEventListener );
122     FwkTabPage*     AddTabPage( sal_Int32 nIndex, const css::uno::Sequence< css::beans::NamedValue >& rProperties );
123     void            ActivatePage( sal_Int32 nIndex );
124     void            RemovePage( sal_Int32 nIndex );
125     virtual void        Resize();
126 };
127 
128 } // namespace framework
129 
130 #endif
131 
132