1 /************************************************************************* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * Copyright 2000, 2010 Oracle and/or its affiliates. 5 * 6 * OpenOffice.org - a multi-platform office productivity suite 7 * 8 * This file is part of OpenOffice.org. 9 * 10 * OpenOffice.org is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License version 3 12 * only, as published by the Free Software Foundation. 13 * 14 * OpenOffice.org is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Lesser General Public License version 3 for more details 18 * (a copy is included in the LICENSE file that accompanied this code). 19 * 20 * You should have received a copy of the GNU Lesser General Public License 21 * version 3 along with OpenOffice.org. If not, see 22 * <http://www.openoffice.org/license.html> 23 * for a copy of the LGPLv3 License. 24 * 25 ************************************************************************/ 26 27 #ifndef SVT_TOOLPANELDECK_HXX 28 #define SVT_TOOLPANELDECK_HXX 29 30 #include "svtools/svtdllapi.h" 31 #include "svtools/toolpanel/toolpanel.hxx" 32 #include "svtools/toolpanel/decklayouter.hxx" 33 34 #include <vcl/ctrl.hxx> 35 36 #include <boost/optional.hpp> 37 #include <memory> 38 39 //........................................................................ 40 namespace svt 41 { 42 //........................................................................ 43 44 class ToolPanelCollection; 45 class ToolPanelDeck_Impl; 46 47 //==================================================================== 48 //= IToolPanelDeckListener 49 //==================================================================== 50 class SAL_NO_VTABLE IToolPanelDeckListener 51 { 52 public: 53 /** called when a panel has been inserted into the deck 54 */ 55 virtual void PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ) = 0; 56 57 /** called when a panel has been removed from the deck 58 */ 59 virtual void PanelRemoved( const size_t i_nPosition ) = 0; 60 61 /** called when the active panel of the deck changed 62 */ 63 virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) = 0; 64 65 /** called when a new layouter has been set at a tool panel deck. 66 67 The method is called after the old layouter has been disposed (i.e. its Destroy method has been 68 invoked), and after the complete deck has been re-layouter. 69 */ 70 virtual void LayouterChanged( const PDeckLayouter& i_rNewLayouter ) = 0; 71 72 /** called when the tool panel deck which the listener registered at is dying. The listener is required to 73 release all references to the deck then. 74 */ 75 virtual void Dying() = 0; 76 }; 77 78 //==================================================================== 79 //= IToolPanelDeck 80 //==================================================================== 81 class SVT_DLLPUBLIC IToolPanelDeck 82 { 83 public: 84 /** returns the number of panels in the container 85 */ 86 virtual size_t GetPanelCount() const = 0; 87 88 /** retrieves the panel with the given index. Invalid indexes will be reported via an assertion in the 89 non-product version, and silently ignored in the product version, with a NULL panel being returned. 90 */ 91 virtual PToolPanel GetPanel( const size_t i_nPos ) const = 0; 92 93 /** returns the number of the currently active panel. 94 */ 95 virtual ::boost::optional< size_t > 96 GetActivePanel() const = 0; 97 98 /** activates the panel with the given number. If the given number is larger or equal to the number of panels 99 in the deck, this will be reported via an assertion in non-product builds, and otherwise ignored. 100 @param i_rPanel 101 the number of the panel to activate. If this is not set, the currently active panel is de-activated, 102 and no new panel is activated at all. Whether or not this makes sense for your application is at 103 your own discretion. 104 */ 105 virtual void ActivatePanel( const ::boost::optional< size_t >& i_rPanel ) = 0; 106 107 /** inserts a new panel into the container. NULL panels are not allowed, as are positions greater than the 108 current panel count. Violations of this will be reported via an assertion in the non-product version, and 109 silently ignored in the product version. 110 */ 111 virtual size_t InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ) = 0; 112 113 /** removes a panel specified by its position. 114 115 Note: It is the responsibility of the caller to ensure that the panel is destroyed appropriately. That is, 116 the tool panel deck will <em>not</em> invoke <member>IToolPanel::Dispose</member> on the removed panel. 117 The advantage is that the panel might be re-used later, with the disadvantage that the owner of the panel 118 deck must know whether Dispose must be invoked after removal, or whether the panel will properly 119 dispose itself when its ref count drops to 0. 120 */ 121 virtual PToolPanel RemovePanel( const size_t i_nPosition ) = 0; 122 123 /** adds a new listener to be notified when the container content changes. The caller is responsible 124 for life time control, i.e. removing the listener before it actually dies. 125 */ 126 virtual void AddListener( IToolPanelDeckListener& i_rListener ) = 0; 127 128 /** removes a container listener previously added via addListener. 129 */ 130 virtual void RemoveListener( IToolPanelDeckListener& i_rListener ) = 0; 131 }; 132 133 //==================================================================== 134 //= ToolPanelDeck 135 //==================================================================== 136 class SVT_DLLPUBLIC ToolPanelDeck :public Control 137 ,public IToolPanelDeck 138 { 139 public: 140 ToolPanelDeck( Window& i_rParent, const WinBits i_nStyle = WB_DIALOGCONTROL ); 141 ~ToolPanelDeck(); 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 ::Window& GetPanelWindowAnchor(); 153 const ::Window& GetPanelWindowAnchor() const; 154 155 /** sets the window which should act as parent in the A11Y object hierarchy. 156 157 Calling this method has no effect if CreateAccessible had always been called. 158 */ 159 void SetAccessibleParentWindow( ::Window* i_pAccessibleParent ); 160 ::Window* GetAccessibleParentWindow() const; 161 162 // IToolPanelDeck 163 virtual size_t GetPanelCount() const; 164 virtual PToolPanel GetPanel( const size_t i_nPos ) const; 165 virtual ::boost::optional< size_t > 166 GetActivePanel() const; 167 virtual void ActivatePanel( const ::boost::optional< size_t >& i_rPanel ); 168 virtual size_t InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ); 169 virtual PToolPanel RemovePanel( const size_t i_nPosition ); 170 virtual void AddListener( IToolPanelDeckListener& i_rListener ); 171 virtual void RemoveListener( IToolPanelDeckListener& i_rListener ); 172 173 protected: 174 // Window overridables 175 virtual void Resize(); 176 virtual long Notify( NotifyEvent& i_rNotifyEvent ); 177 virtual void GetFocus(); 178 179 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > 180 GetComponentInterface( sal_Bool i_bCreate ); 181 182 private: 183 ::std::auto_ptr< ToolPanelDeck_Impl > m_pImpl; 184 185 private: 186 using Window::GetAccessibleParentWindow; 187 }; 188 189 //........................................................................ 190 } // namespace svt 191 //........................................................................ 192 193 #endif // SVT_TOOLPANELDECK_HXX 194