Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_FRAMEWORK_INC_CLASSES_FWKTABWINDOW_HXX
20 : #define INCLUDED_FRAMEWORK_INC_CLASSES_FWKTABWINDOW_HXX
21 :
22 : #include <general.h>
23 :
24 : #include <vector>
25 :
26 : #include <com/sun/star/uno/Reference.h>
27 : #include <vcl/tabctrl.hxx>
28 : #include <vcl/tabdlg.hxx>
29 : #include <vcl/tabpage.hxx>
30 : #include <vcl/button.hxx>
31 :
32 : namespace com { namespace sun { namespace star {
33 : namespace awt {
34 : class XWindow;
35 : class XContainerWindowProvider;
36 : class XContainerWindowEventHandler; }
37 : namespace beans {
38 : struct NamedValue; }
39 : } } }
40 :
41 : namespace framework
42 : {
43 :
44 0 : class FwkTabControl : public TabControl
45 : {
46 : public:
47 : FwkTabControl(vcl::Window* pParent);
48 :
49 : void BroadcastEvent( sal_uLong nEvent );
50 : };
51 :
52 : class FwkTabPage : public TabPage
53 : {
54 : private:
55 : OUString m_sPageURL;
56 : css::uno::Reference< css::awt::XWindow > m_xPage;
57 : css::uno::Reference< css::awt::XContainerWindowEventHandler > m_xEventHdl;
58 : css::uno::Reference< css::awt::XContainerWindowProvider > m_xWinProvider;
59 :
60 : void CreateDialog();
61 : bool CallMethod( const OUString& rMethod );
62 :
63 : public:
64 : FwkTabPage(
65 : vcl::Window* pParent,
66 : const OUString& rPageURL,
67 : const css::uno::Reference< css::awt::XContainerWindowEventHandler >& rEventHdl,
68 : const css::uno::Reference< css::awt::XContainerWindowProvider >& rProvider );
69 :
70 : virtual ~FwkTabPage();
71 : virtual void dispose() SAL_OVERRIDE;
72 :
73 : virtual void ActivatePage() SAL_OVERRIDE;
74 : virtual void DeactivatePage() SAL_OVERRIDE;
75 : virtual void Resize() SAL_OVERRIDE;
76 : };
77 :
78 : struct TabEntry
79 : {
80 : sal_Int32 m_nIndex;
81 : ScopedVclPtr<FwkTabPage> m_pPage;
82 : OUString m_sPageURL;
83 : css::uno::Reference< css::awt::XContainerWindowEventHandler > m_xEventHdl;
84 :
85 : TabEntry() :
86 : m_nIndex( -1 ), m_pPage( NULL ) {}
87 :
88 0 : TabEntry( sal_Int32 nIndex, const OUString& sURL, const css::uno::Reference< css::awt::XContainerWindowEventHandler > & rEventHdl ) :
89 0 : m_nIndex( nIndex ), m_pPage( NULL ), m_sPageURL( sURL ), m_xEventHdl( rEventHdl ) {}
90 0 : ~TabEntry() { m_pPage.disposeAndClear(); }
91 : };
92 :
93 : typedef std::vector< TabEntry* > TabEntryList;
94 :
95 : class FwkTabWindow : public vcl::Window
96 : {
97 : private:
98 : VclPtr<FwkTabControl> m_aTabCtrl;
99 : TabEntryList m_TabList;
100 :
101 : css::uno::Reference< css::awt::XContainerWindowProvider > m_xWinProvider;
102 :
103 : void ClearEntryList();
104 : TabEntry* FindEntry( sal_Int32 nIndex ) const;
105 : bool RemoveEntry( sal_Int32 nIndex );
106 :
107 : DECL_DLLPRIVATE_LINK(ActivatePageHdl, void *);
108 : DECL_DLLPRIVATE_LINK_TYPED(DeactivatePageHdl, TabControl *, bool);
109 :
110 : public:
111 : FwkTabWindow( vcl::Window* pParent );
112 : virtual ~FwkTabWindow();
113 : virtual void dispose() SAL_OVERRIDE;
114 :
115 : void AddEventListener( const Link<>& rEventListener );
116 : void RemoveEventListener( const Link<>& rEventListener );
117 : FwkTabPage* AddTabPage( sal_Int32 nIndex, const css::uno::Sequence< css::beans::NamedValue >& rProperties );
118 : void ActivatePage( sal_Int32 nIndex );
119 : void RemovePage( sal_Int32 nIndex );
120 : virtual void Resize() SAL_OVERRIDE;
121 : };
122 :
123 : } // namespace framework
124 :
125 : #endif
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|