update credits
[LibreOffice.git] / include / svtools / toolpanel / toolpaneldeck.hxx
blobd293aca8d0173b804c7003c1e69c5566b8a300ee
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef SVT_TOOLPANELDECK_HXX
21 #define SVT_TOOLPANELDECK_HXX
23 #include "svtools/svtdllapi.h"
24 #include "svtools/toolpanel/toolpanel.hxx"
25 #include "svtools/toolpanel/decklayouter.hxx"
27 #include <vcl/ctrl.hxx>
29 #include <boost/optional.hpp>
30 #include <memory>
32 //........................................................................
33 namespace svt
35 //........................................................................
37 class ToolPanelCollection;
38 class ToolPanelDeck_Impl;
40 //====================================================================
41 //= IToolPanelDeckListener
42 //====================================================================
43 class SAL_NO_VTABLE IToolPanelDeckListener
45 public:
46 /** called when a panel has been inserted into the deck
48 virtual void PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ) = 0;
50 /** called when a panel has been removed from the deck
52 virtual void PanelRemoved( const size_t i_nPosition ) = 0;
54 /** called when the active panel of the deck changed
56 virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) = 0;
58 /** called when a new layouter has been set at a tool panel deck.
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.
63 virtual void LayouterChanged( const PDeckLayouter& i_rNewLayouter ) = 0;
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.
68 virtual void Dying() = 0;
70 protected:
71 ~IToolPanelDeckListener() {}
74 //====================================================================
75 //= IToolPanelDeck
76 //====================================================================
77 class SVT_DLLPUBLIC IToolPanelDeck
79 public:
80 /** returns the number of panels in the container
82 virtual size_t GetPanelCount() const = 0;
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.
87 virtual PToolPanel GetPanel( const size_t i_nPos ) const = 0;
89 /** returns the number of the currently active panel.
91 virtual ::boost::optional< size_t >
92 GetActivePanel() const = 0;
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.
101 virtual void ActivatePanel( const ::boost::optional< size_t >& i_rPanel ) = 0;
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.
107 virtual size_t InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ) = 0;
109 /** removes a panel specified by its position.
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.
117 virtual PToolPanel RemovePanel( const size_t i_nPosition ) = 0;
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.
122 virtual void AddListener( IToolPanelDeckListener& i_rListener ) = 0;
124 /** removes a container listener previously added via addListener.
126 virtual void RemoveListener( IToolPanelDeckListener& i_rListener ) = 0;
128 protected:
129 ~IToolPanelDeck() {}
132 //====================================================================
133 //= ToolPanelDeck
134 //====================================================================
135 class SVT_DLLPUBLIC ToolPanelDeck :public Control
136 ,public IToolPanelDeck
138 public:
139 ToolPanelDeck( Window& i_rParent, const WinBits i_nStyle = WB_DIALOGCONTROL );
140 ~ToolPanelDeck();
142 // attributes
143 PDeckLayouter GetLayouter() const;
144 void SetLayouter( const PDeckLayouter& i_pNewLayouter );
146 /** returns the window which acts as anchor for the panel windows.
148 This is a single dedicated window, which is passed to the IToolPanel::ActivatePanel method
149 whenever a panel is activated, to act as parent window for the panel's VCL-Window.
151 ::Window& GetPanelWindowAnchor();
152 const ::Window& GetPanelWindowAnchor() const;
154 /** sets the window which should act as parent in the A11Y object hierarchy.
156 Calling this method has no effect if CreateAccessible had always been called.
158 void SetAccessibleParentWindow( ::Window* i_pAccessibleParent );
159 ::Window* GetAccessibleParentWindow() const;
161 // IToolPanelDeck
162 virtual size_t GetPanelCount() const;
163 virtual PToolPanel GetPanel( const size_t i_nPos ) const;
164 virtual ::boost::optional< size_t >
165 GetActivePanel() const;
166 virtual void ActivatePanel( const ::boost::optional< size_t >& i_rPanel );
167 virtual size_t InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition );
168 virtual PToolPanel RemovePanel( const size_t i_nPosition );
169 virtual void AddListener( IToolPanelDeckListener& i_rListener );
170 virtual void RemoveListener( IToolPanelDeckListener& i_rListener );
172 protected:
173 // Window overridables
174 virtual void Resize();
175 virtual long Notify( NotifyEvent& i_rNotifyEvent );
176 virtual void GetFocus();
178 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
179 GetComponentInterface( sal_Bool i_bCreate );
181 private:
182 ::std::auto_ptr< ToolPanelDeck_Impl > m_pImpl;
184 private:
185 using Window::GetAccessibleParentWindow;
188 //........................................................................
189 } // namespace svt
190 //........................................................................
192 #endif // SVT_TOOLPANELDECK_HXX
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */