Branch libreoffice-5-0-4
[LibreOffice.git] / include / svtools / toolpanel / toolpaneldeck.hxx
blob211c099deb933bc223561402ba043517fd44fdf4
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 INCLUDED_SVTOOLS_TOOLPANEL_TOOLPANELDECK_HXX
21 #define INCLUDED_SVTOOLS_TOOLPANEL_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>
33 namespace svt
37 class ToolPanelCollection;
38 class ToolPanelDeck_Impl;
41 //= IToolPanelDeckListener
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() {}
75 //= IToolPanelDeck
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() {}
133 //= ToolPanelDeck
135 class SVT_DLLPUBLIC ToolPanelDeck :public Control
136 ,public IToolPanelDeck
138 public:
139 ToolPanelDeck( vcl::Window& i_rParent, const WinBits i_nStyle = WB_DIALOGCONTROL );
140 virtual ~ToolPanelDeck();
141 virtual void dispose() SAL_OVERRIDE;
143 // attributes
144 PDeckLayouter GetLayouter() const;
145 void SetLayouter( const PDeckLayouter& i_pNewLayouter );
147 /** returns the window which acts as anchor for the panel windows.
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.
152 vcl::Window& GetPanelWindowAnchor();
153 const vcl::Window& GetPanelWindowAnchor() const;
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;
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;
172 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >
173 GetComponentInterface( bool i_bCreate ) SAL_OVERRIDE;
175 private:
176 ::std::unique_ptr< ToolPanelDeck_Impl > m_pImpl;
180 } // namespace svt
183 #endif // INCLUDED_SVTOOLS_TOOLPANEL_TOOLPANELDECK_HXX
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */