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 :
20 : #ifndef INCLUDED_SVTOOLS_TOOLPANEL_TOOLPANELDECK_HXX
21 : #define INCLUDED_SVTOOLS_TOOLPANEL_TOOLPANELDECK_HXX
22 :
23 : #include <svtools/svtdllapi.h>
24 : #include <svtools/toolpanel/toolpanel.hxx>
25 : #include <svtools/toolpanel/decklayouter.hxx>
26 :
27 : #include <vcl/ctrl.hxx>
28 :
29 : #include <boost/optional.hpp>
30 : #include <memory>
31 :
32 :
33 : namespace svt
34 : {
35 :
36 :
37 : class ToolPanelCollection;
38 : class ToolPanelDeck_Impl;
39 :
40 :
41 : //= IToolPanelDeckListener
42 :
43 0 : class SAL_NO_VTABLE IToolPanelDeckListener
44 : {
45 : public:
46 : /** called when a panel has been inserted into the deck
47 : */
48 : virtual void PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ) = 0;
49 :
50 : /** called when a panel has been removed from the deck
51 : */
52 : virtual void PanelRemoved( const size_t i_nPosition ) = 0;
53 :
54 : /** called when the active panel of the deck changed
55 : */
56 : virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) = 0;
57 :
58 : /** called when a new layouter has been set at a tool panel deck.
59 :
60 : The method is called after the old layouter has been disposed (i.e. its Destroy method has been
61 : invoked), and after the complete deck has been re-layouter.
62 : */
63 : virtual void LayouterChanged( const PDeckLayouter& i_rNewLayouter ) = 0;
64 :
65 : /** called when the tool panel deck which the listener registered at is dying. The listener is required to
66 : release all references to the deck then.
67 : */
68 : virtual void Dying() = 0;
69 :
70 : protected:
71 0 : ~IToolPanelDeckListener() {}
72 : };
73 :
74 :
75 : //= IToolPanelDeck
76 :
77 0 : class SVT_DLLPUBLIC IToolPanelDeck
78 : {
79 : public:
80 : /** returns the number of panels in the container
81 : */
82 : virtual size_t GetPanelCount() const = 0;
83 :
84 : /** retrieves the panel with the given index. Invalid indexes will be reported via an assertion in the
85 : non-product version, and silently ignored in the product version, with a NULL panel being returned.
86 : */
87 : virtual PToolPanel GetPanel( const size_t i_nPos ) const = 0;
88 :
89 : /** returns the number of the currently active panel.
90 : */
91 : virtual ::boost::optional< size_t >
92 : GetActivePanel() const = 0;
93 :
94 : /** activates the panel with the given number. If the given number is larger or equal to the number of panels
95 : in the deck, this will be reported via an assertion in non-product builds, and otherwise ignored.
96 : @param i_rPanel
97 : the number of the panel to activate. If this is not set, the currently active panel is de-activated,
98 : and no new panel is activated at all. Whether or not this makes sense for your application is at
99 : your own discretion.
100 : */
101 : virtual void ActivatePanel( const ::boost::optional< size_t >& i_rPanel ) = 0;
102 :
103 : /** inserts a new panel into the container. NULL panels are not allowed, as are positions greater than the
104 : current panel count. Violations of this will be reported via an assertion in the non-product version, and
105 : silently ignored in the product version.
106 : */
107 : virtual size_t InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ) = 0;
108 :
109 : /** removes a panel specified by its position.
110 :
111 : Note: It is the responsibility of the caller to ensure that the panel is destroyed appropriately. That is,
112 : the tool panel deck will <em>not</em> invoke <member>IToolPanel::Dispose</member> on the removed panel.
113 : The advantage is that the panel might be re-used later, with the disadvantage that the owner of the panel
114 : deck must know whether Dispose must be invoked after removal, or whether the panel will properly
115 : dispose itself when its ref count drops to 0.
116 : */
117 : virtual PToolPanel RemovePanel( const size_t i_nPosition ) = 0;
118 :
119 : /** adds a new listener to be notified when the container content changes. The caller is responsible
120 : for life time control, i.e. removing the listener before it actually dies.
121 : */
122 : virtual void AddListener( IToolPanelDeckListener& i_rListener ) = 0;
123 :
124 : /** removes a container listener previously added via addListener.
125 : */
126 : virtual void RemoveListener( IToolPanelDeckListener& i_rListener ) = 0;
127 :
128 : protected:
129 0 : ~IToolPanelDeck() {}
130 : };
131 :
132 :
133 : //= ToolPanelDeck
134 :
135 : class SVT_DLLPUBLIC ToolPanelDeck :public Control
136 : ,public IToolPanelDeck
137 : {
138 : public:
139 : ToolPanelDeck( vcl::Window& i_rParent, const WinBits i_nStyle = WB_DIALOGCONTROL );
140 : virtual ~ToolPanelDeck();
141 : virtual void dispose() SAL_OVERRIDE;
142 :
143 : // attributes
144 : PDeckLayouter GetLayouter() const;
145 : void SetLayouter( const PDeckLayouter& i_pNewLayouter );
146 :
147 : /** returns the window which acts as anchor for the panel windows.
148 :
149 : This is a single dedicated window, which is passed to the IToolPanel::ActivatePanel method
150 : whenever a panel is activated, to act as parent window for the panel's VCL-Window.
151 : */
152 : vcl::Window& GetPanelWindowAnchor();
153 : const vcl::Window& GetPanelWindowAnchor() const;
154 :
155 : // IToolPanelDeck
156 : virtual size_t GetPanelCount() const SAL_OVERRIDE;
157 : virtual PToolPanel GetPanel( const size_t i_nPos ) const SAL_OVERRIDE;
158 : virtual ::boost::optional< size_t >
159 : GetActivePanel() const SAL_OVERRIDE;
160 : virtual void ActivatePanel( const ::boost::optional< size_t >& i_rPanel ) SAL_OVERRIDE;
161 : virtual size_t InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ) SAL_OVERRIDE;
162 : virtual PToolPanel RemovePanel( const size_t i_nPosition ) SAL_OVERRIDE;
163 : virtual void AddListener( IToolPanelDeckListener& i_rListener ) SAL_OVERRIDE;
164 : virtual void RemoveListener( IToolPanelDeckListener& i_rListener ) SAL_OVERRIDE;
165 :
166 : protected:
167 : // Window overridables
168 : virtual void Resize() SAL_OVERRIDE;
169 : virtual bool Notify( NotifyEvent& i_rNotifyEvent ) SAL_OVERRIDE;
170 : virtual void GetFocus() SAL_OVERRIDE;
171 :
172 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
173 : GetComponentInterface( bool i_bCreate ) SAL_OVERRIDE;
174 :
175 : private:
176 : ::std::unique_ptr< ToolPanelDeck_Impl > m_pImpl;
177 : };
178 :
179 :
180 : } // namespace svt
181 :
182 :
183 : #endif // INCLUDED_SVTOOLS_TOOLPANEL_TOOLPANELDECK_HXX
184 :
185 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|