1*5900e8ecSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5900e8ecSAndrew Rist * distributed with this work for additional information 6*5900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5900e8ecSAndrew Rist * "License"); you may not use this file except in compliance 9*5900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at 10*5900e8ecSAndrew Rist * 11*5900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5900e8ecSAndrew Rist * 13*5900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5900e8ecSAndrew Rist * software distributed under the License is distributed on an 15*5900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5900e8ecSAndrew Rist * KIND, either express or implied. See the License for the 17*5900e8ecSAndrew Rist * specific language governing permissions and limitations 18*5900e8ecSAndrew Rist * under the License. 19*5900e8ecSAndrew Rist * 20*5900e8ecSAndrew Rist *************************************************************/ 21*5900e8ecSAndrew Rist 22*5900e8ecSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "precompiled_svtools.hxx" 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "dummypanel.hxx" 27cdf0e10cSrcweir #include "toolpanelcollection.hxx" 28cdf0e10cSrcweir #include "paneldecklisteners.hxx" 29cdf0e10cSrcweir #include "toolpaneldeckpeer.hxx" 30cdf0e10cSrcweir #include "svtools/toolpanel/toolpaneldeck.hxx" 31cdf0e10cSrcweir #include "svtools/toolpanel/tablayouter.hxx" 32cdf0e10cSrcweir #include "svtools/toolpanel/drawerlayouter.hxx" 33cdf0e10cSrcweir 34cdf0e10cSrcweir /** === begin UNO includes === **/ 35cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp> 36cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 37cdf0e10cSrcweir /** === end UNO includes === **/ 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <tools/diagnose_ex.h> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <boost/optional.hpp> 42cdf0e10cSrcweir 43cdf0e10cSrcweir //........................................................................ 44cdf0e10cSrcweir namespace svt 45cdf0e10cSrcweir { 46cdf0e10cSrcweir //........................................................................ 47cdf0e10cSrcweir 48cdf0e10cSrcweir /** === begin UNO using === **/ 49cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 50cdf0e10cSrcweir using ::com::sun::star::accessibility::XAccessible; 51cdf0e10cSrcweir using ::com::sun::star::awt::XWindowPeer; 52cdf0e10cSrcweir using ::com::sun::star::uno::UNO_SET_THROW; 53cdf0e10cSrcweir /** === end UNO using === **/ 54cdf0e10cSrcweir namespace AccessibleRole = ::com::sun::star::accessibility::AccessibleRole; 55cdf0e10cSrcweir 56cdf0e10cSrcweir enum DeckAction 57cdf0e10cSrcweir { 58cdf0e10cSrcweir /// activates the first panel 59cdf0e10cSrcweir ACTION_ACTIVATE_FIRST, 60cdf0e10cSrcweir // activates the panel after the currently active panel 61cdf0e10cSrcweir ACTION_ACTIVATE_NEXT, 62cdf0e10cSrcweir // activates the panel before the currently active panel 63cdf0e10cSrcweir ACTION_ACTIVATE_PREV, 64cdf0e10cSrcweir // activates the last panel 65cdf0e10cSrcweir ACTION_ACTIVATE_LAST, 66cdf0e10cSrcweir 67cdf0e10cSrcweir // toggles the focus between the active panel and the panel selector 68cdf0e10cSrcweir ACTION_TOGGLE_FOCUS, 69cdf0e10cSrcweir }; 70cdf0e10cSrcweir 71cdf0e10cSrcweir //==================================================================== 72cdf0e10cSrcweir //= ToolPanelDeck_Impl 73cdf0e10cSrcweir //==================================================================== 74cdf0e10cSrcweir class ToolPanelDeck_Impl : public IToolPanelDeckListener 75cdf0e10cSrcweir { 76cdf0e10cSrcweir public: 77cdf0e10cSrcweir ToolPanelDeck_Impl( ToolPanelDeck& i_rDeck ) 78cdf0e10cSrcweir :m_rDeck( i_rDeck ) 79cdf0e10cSrcweir ,m_aPanelAnchor( &i_rDeck, WB_DIALOGCONTROL | WB_CHILDDLGCTRL ) 80cdf0e10cSrcweir ,m_aPanels() 81cdf0e10cSrcweir ,m_pDummyPanel( new DummyPanel ) 82cdf0e10cSrcweir ,m_pLayouter() 83cdf0e10cSrcweir ,m_bInDtor( false ) 84cdf0e10cSrcweir ,m_pAccessibleParent( NULL ) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir m_aPanels.AddListener( *this ); 87cdf0e10cSrcweir m_aPanelAnchor.Show(); 88cdf0e10cSrcweir m_aPanelAnchor.SetAccessibleRole( AccessibleRole::PANEL ); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir ~ToolPanelDeck_Impl() 92cdf0e10cSrcweir { 93cdf0e10cSrcweir m_bInDtor = true; 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir PDeckLayouter GetLayouter() const { return m_pLayouter; } 97cdf0e10cSrcweir void SetLayouter( const PDeckLayouter& i_pNewLayouter ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir Window& GetPanelWindowAnchor() { return m_aPanelAnchor; } 100cdf0e10cSrcweir const Window& GetPanelWindowAnchor() const { return m_aPanelAnchor; } 101cdf0e10cSrcweir 102cdf0e10cSrcweir bool IsDead() const { return m_bInDtor; } 103cdf0e10cSrcweir 104cdf0e10cSrcweir /// notifies our listeners that we're going to die. Only to be called from with our anti-impl's destructor 105cdf0e10cSrcweir void NotifyDying() 106cdf0e10cSrcweir { 107cdf0e10cSrcweir m_aPanels.RemoveListener( *this ); 108cdf0e10cSrcweir m_aListeners.Dying(); 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir // IToolPanelDeck equivalents 112cdf0e10cSrcweir size_t GetPanelCount() const; 113cdf0e10cSrcweir PToolPanel GetPanel( const size_t i_nPos ) const; 114cdf0e10cSrcweir ::boost::optional< size_t > 115cdf0e10cSrcweir GetActivePanel() const; 116cdf0e10cSrcweir void ActivatePanel( const ::boost::optional< size_t >& i_rPanel ); 117cdf0e10cSrcweir size_t InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ); 118cdf0e10cSrcweir PToolPanel RemovePanel( const size_t i_nPosition ); 119cdf0e10cSrcweir void AddListener( IToolPanelDeckListener& i_rListener ); 120cdf0e10cSrcweir void RemoveListener( IToolPanelDeckListener& i_rListener ); 121cdf0e10cSrcweir 122cdf0e10cSrcweir /// re-layouts everything 123cdf0e10cSrcweir void LayoutAll() { ImplDoLayout(); } 124cdf0e10cSrcweir 125cdf0e10cSrcweir void DoAction( const DeckAction i_eAction ); 126cdf0e10cSrcweir 127cdf0e10cSrcweir bool FocusActivePanel(); 128cdf0e10cSrcweir 129cdf0e10cSrcweir void SetAccessibleParentWindow( Window* i_pAccessibleParent ); 130cdf0e10cSrcweir Window* GetAccessibleParentWindow() const { return m_pAccessibleParent; } 131cdf0e10cSrcweir 132cdf0e10cSrcweir protected: 133cdf0e10cSrcweir // IToolPanelDeckListener 134cdf0e10cSrcweir virtual void PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ); 135cdf0e10cSrcweir virtual void PanelRemoved( const size_t i_nPosition ); 136cdf0e10cSrcweir virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ); 137cdf0e10cSrcweir virtual void LayouterChanged( const PDeckLayouter& i_rNewLayouter ); 138cdf0e10cSrcweir virtual void Dying(); 139cdf0e10cSrcweir 140cdf0e10cSrcweir private: 141cdf0e10cSrcweir void ImplDoLayout(); 142cdf0e10cSrcweir PToolPanel GetActiveOrDummyPanel_Impl(); 143cdf0e10cSrcweir 144cdf0e10cSrcweir private: 145cdf0e10cSrcweir ToolPanelDeck& m_rDeck; 146cdf0e10cSrcweir Window m_aPanelAnchor; 147cdf0e10cSrcweir ToolPanelCollection m_aPanels; 148cdf0e10cSrcweir PToolPanel m_pDummyPanel; 149cdf0e10cSrcweir PanelDeckListeners m_aListeners; 150cdf0e10cSrcweir PDeckLayouter m_pLayouter; 151cdf0e10cSrcweir bool m_bInDtor; 152cdf0e10cSrcweir Window* m_pAccessibleParent; 153cdf0e10cSrcweir }; 154cdf0e10cSrcweir 155cdf0e10cSrcweir //-------------------------------------------------------------------- 156cdf0e10cSrcweir PToolPanel ToolPanelDeck_Impl::GetActiveOrDummyPanel_Impl() 157cdf0e10cSrcweir { 158cdf0e10cSrcweir ::boost::optional< size_t > aActivePanel( m_aPanels.GetActivePanel() ); 159cdf0e10cSrcweir if ( !aActivePanel ) 160cdf0e10cSrcweir return m_pDummyPanel; 161cdf0e10cSrcweir return m_aPanels.GetPanel( *aActivePanel ); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir //-------------------------------------------------------------------- 165cdf0e10cSrcweir void ToolPanelDeck_Impl::SetLayouter( const PDeckLayouter& i_pNewLayouter ) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( i_pNewLayouter.get(), "invalid layouter" ); 168cdf0e10cSrcweir 169cdf0e10cSrcweir if ( m_pLayouter.get() ) 170cdf0e10cSrcweir m_pLayouter->Destroy(); 171cdf0e10cSrcweir 172cdf0e10cSrcweir m_pLayouter = i_pNewLayouter; 173cdf0e10cSrcweir 174cdf0e10cSrcweir ImplDoLayout(); 175cdf0e10cSrcweir 176cdf0e10cSrcweir m_aListeners.LayouterChanged( m_pLayouter ); 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir //-------------------------------------------------------------------- 180cdf0e10cSrcweir size_t ToolPanelDeck_Impl::GetPanelCount() const 181cdf0e10cSrcweir { 182cdf0e10cSrcweir return m_aPanels.GetPanelCount(); 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir //-------------------------------------------------------------------- 186cdf0e10cSrcweir PToolPanel ToolPanelDeck_Impl::GetPanel( const size_t i_nPos ) const 187cdf0e10cSrcweir { 188cdf0e10cSrcweir return m_aPanels.GetPanel( i_nPos ); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir //-------------------------------------------------------------------- 192cdf0e10cSrcweir ::boost::optional< size_t > ToolPanelDeck_Impl::GetActivePanel() const 193cdf0e10cSrcweir { 194cdf0e10cSrcweir return m_aPanels.GetActivePanel(); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir //-------------------------------------------------------------------- 198cdf0e10cSrcweir void ToolPanelDeck_Impl::ActivatePanel( const ::boost::optional< size_t >& i_rPanel ) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir m_aPanels.ActivatePanel( i_rPanel ); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir //-------------------------------------------------------------------- 204cdf0e10cSrcweir size_t ToolPanelDeck_Impl::InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir return m_aPanels.InsertPanel( i_pPanel, i_nPosition ); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir //-------------------------------------------------------------------- 210cdf0e10cSrcweir PToolPanel ToolPanelDeck_Impl::RemovePanel( const size_t i_nPosition ) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir return m_aPanels.RemovePanel( i_nPosition ); 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir //-------------------------------------------------------------------- 216cdf0e10cSrcweir void ToolPanelDeck_Impl::ImplDoLayout() 217cdf0e10cSrcweir { 218cdf0e10cSrcweir const Rectangle aDeckPlayground( Point(), m_rDeck.GetOutputSizePixel() ); 219cdf0e10cSrcweir 220cdf0e10cSrcweir // ask the layouter what is left for our panel, and position the panel container window appropriately 221cdf0e10cSrcweir Rectangle aPlaygroundArea( aDeckPlayground ); 222cdf0e10cSrcweir OSL_ENSURE( m_pLayouter.get(), "ToolPanelDeck_Impl::ImplDoLayout: no layouter!" ); 223cdf0e10cSrcweir if ( m_pLayouter.get() ) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir aPlaygroundArea = m_pLayouter->Layout( aDeckPlayground ); 226cdf0e10cSrcweir } 227cdf0e10cSrcweir m_aPanelAnchor.SetPosSizePixel( aPlaygroundArea.TopLeft(), aPlaygroundArea.GetSize() ); 228cdf0e10cSrcweir 229cdf0e10cSrcweir // position the active panel 230cdf0e10cSrcweir const PToolPanel pActive( GetActiveOrDummyPanel_Impl() ); 231cdf0e10cSrcweir pActive->SetSizePixel( m_aPanelAnchor.GetOutputSizePixel() ); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 234cdf0e10cSrcweir //-------------------------------------------------------------------- 235cdf0e10cSrcweir void ToolPanelDeck_Impl::AddListener( IToolPanelDeckListener& i_rListener ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir m_aListeners.AddListener( i_rListener ); 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir //-------------------------------------------------------------------- 241cdf0e10cSrcweir void ToolPanelDeck_Impl::RemoveListener( IToolPanelDeckListener& i_rListener ) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir m_aListeners.RemoveListener( i_rListener ); 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246cdf0e10cSrcweir //-------------------------------------------------------------------- 247cdf0e10cSrcweir void ToolPanelDeck_Impl::DoAction( const DeckAction i_eAction ) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir const size_t nPanelCount( m_aPanels.GetPanelCount() ); 250cdf0e10cSrcweir ::boost::optional< size_t > aActivatePanel; 251cdf0e10cSrcweir ::boost::optional< size_t > aCurrentPanel( GetActivePanel() ); 252cdf0e10cSrcweir 253cdf0e10cSrcweir switch ( i_eAction ) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir case ACTION_ACTIVATE_FIRST: 256cdf0e10cSrcweir if ( nPanelCount > 0 ) 257cdf0e10cSrcweir aActivatePanel = 0; 258cdf0e10cSrcweir break; 259cdf0e10cSrcweir case ACTION_ACTIVATE_PREV: 260cdf0e10cSrcweir if ( !aCurrentPanel && ( nPanelCount > 0 ) ) 261cdf0e10cSrcweir aActivatePanel = nPanelCount - 1; 262cdf0e10cSrcweir else 263cdf0e10cSrcweir if ( !!aCurrentPanel && ( *aCurrentPanel > 0 ) ) 264cdf0e10cSrcweir aActivatePanel = *aCurrentPanel - 1; 265cdf0e10cSrcweir break; 266cdf0e10cSrcweir case ACTION_ACTIVATE_NEXT: 267cdf0e10cSrcweir if ( !aCurrentPanel && ( nPanelCount > 0 ) ) 268cdf0e10cSrcweir aActivatePanel = 0; 269cdf0e10cSrcweir else 270cdf0e10cSrcweir if ( !!aCurrentPanel && ( *aCurrentPanel < nPanelCount - 1 ) ) 271cdf0e10cSrcweir aActivatePanel = *aCurrentPanel + 1; 272cdf0e10cSrcweir break; 273cdf0e10cSrcweir case ACTION_ACTIVATE_LAST: 274cdf0e10cSrcweir if ( nPanelCount > 0 ) 275cdf0e10cSrcweir aActivatePanel = nPanelCount - 1; 276cdf0e10cSrcweir break; 277cdf0e10cSrcweir case ACTION_TOGGLE_FOCUS: 278cdf0e10cSrcweir { 279cdf0e10cSrcweir PToolPanel pActivePanel( GetActiveOrDummyPanel_Impl() ); 280cdf0e10cSrcweir if ( !m_aPanelAnchor.HasChildPathFocus() ) 281cdf0e10cSrcweir pActivePanel->GrabFocus(); 282cdf0e10cSrcweir else 283cdf0e10cSrcweir GetLayouter()->SetFocusToPanelSelector(); 284cdf0e10cSrcweir } 285cdf0e10cSrcweir break; 286cdf0e10cSrcweir } 287cdf0e10cSrcweir 288cdf0e10cSrcweir if ( !!aActivatePanel ) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir ActivatePanel( aActivatePanel ); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir } 293cdf0e10cSrcweir 294cdf0e10cSrcweir //-------------------------------------------------------------------- 295cdf0e10cSrcweir bool ToolPanelDeck_Impl::FocusActivePanel() 296cdf0e10cSrcweir { 297cdf0e10cSrcweir ::boost::optional< size_t > aActivePanel( m_aPanels.GetActivePanel() ); 298cdf0e10cSrcweir if ( !aActivePanel ) 299cdf0e10cSrcweir return false; 300cdf0e10cSrcweir 301cdf0e10cSrcweir PToolPanel pActivePanel( m_aPanels.GetPanel( *aActivePanel ) ); 302cdf0e10cSrcweir pActivePanel->GrabFocus(); 303cdf0e10cSrcweir return true; 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir //-------------------------------------------------------------------- 307cdf0e10cSrcweir void ToolPanelDeck_Impl::PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir // multiplex to our own listeners 310cdf0e10cSrcweir m_aListeners.PanelInserted( i_pPanel, i_nPosition ); 311cdf0e10cSrcweir } 312cdf0e10cSrcweir 313cdf0e10cSrcweir //-------------------------------------------------------------------- 314cdf0e10cSrcweir void ToolPanelDeck_Impl::PanelRemoved( const size_t i_nPosition ) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir // multiplex to our own listeners 317cdf0e10cSrcweir m_aListeners.PanelRemoved( i_nPosition ); 318cdf0e10cSrcweir } 319cdf0e10cSrcweir 320cdf0e10cSrcweir //-------------------------------------------------------------------- 321cdf0e10cSrcweir void ToolPanelDeck_Impl::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) 322cdf0e10cSrcweir { 323cdf0e10cSrcweir // hide the old panel 324cdf0e10cSrcweir if ( !!i_rOldActive ) 325cdf0e10cSrcweir { 326cdf0e10cSrcweir const PToolPanel pOldActive( m_aPanels.GetPanel( *i_rOldActive ) ); 327cdf0e10cSrcweir pOldActive->Deactivate(); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir // position and show the new panel 331cdf0e10cSrcweir const PToolPanel pNewActive( !i_rNewActive ? m_pDummyPanel : m_aPanels.GetPanel( *i_rNewActive ) ); 332cdf0e10cSrcweir pNewActive->Activate( m_aPanelAnchor ); 333cdf0e10cSrcweir pNewActive->GrabFocus(); 334cdf0e10cSrcweir 335cdf0e10cSrcweir // resize the panel (cannot guarantee it has ever been resized before 336cdf0e10cSrcweir pNewActive->SetSizePixel( m_aPanelAnchor.GetOutputSizePixel() ); 337cdf0e10cSrcweir 338cdf0e10cSrcweir // multiplex to our own listeners 339cdf0e10cSrcweir m_aListeners.ActivePanelChanged( i_rOldActive, i_rNewActive ); 340cdf0e10cSrcweir } 341cdf0e10cSrcweir 342cdf0e10cSrcweir //-------------------------------------------------------------------- 343cdf0e10cSrcweir void ToolPanelDeck_Impl::LayouterChanged( const PDeckLayouter& i_rNewLayouter ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir // not interested in 346cdf0e10cSrcweir (void)i_rNewLayouter; 347cdf0e10cSrcweir } 348cdf0e10cSrcweir 349cdf0e10cSrcweir //-------------------------------------------------------------------- 350cdf0e10cSrcweir void ToolPanelDeck_Impl::Dying() 351cdf0e10cSrcweir { 352cdf0e10cSrcweir // not interested in. Since the ToolPanelCollection is our member, this just means we ourself 353cdf0e10cSrcweir // are dying, and we already sent this notification in our dtor. 354cdf0e10cSrcweir } 355cdf0e10cSrcweir 356cdf0e10cSrcweir //-------------------------------------------------------------------- 357cdf0e10cSrcweir void ToolPanelDeck_Impl::SetAccessibleParentWindow( Window* i_pAccessibleParent ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir m_pAccessibleParent = i_pAccessibleParent; 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir //==================================================================== 363cdf0e10cSrcweir //= ToolPanelDeck 364cdf0e10cSrcweir //==================================================================== 365cdf0e10cSrcweir //-------------------------------------------------------------------- 366cdf0e10cSrcweir ToolPanelDeck::ToolPanelDeck( Window& i_rParent, const WinBits i_nStyle ) 367cdf0e10cSrcweir :Control( &i_rParent, i_nStyle ) 368cdf0e10cSrcweir ,m_pImpl( new ToolPanelDeck_Impl( *this ) ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir // use a default layouter 371cdf0e10cSrcweir // SetLayouter( PDeckLayouter( new TabDeckLayouter( *this, *this, TABS_RIGHT, TABITEM_IMAGE_AND_TEXT ) ) ); 372cdf0e10cSrcweir SetLayouter( PDeckLayouter( new DrawerDeckLayouter( *this, *this ) ) ); 373cdf0e10cSrcweir } 374cdf0e10cSrcweir 375cdf0e10cSrcweir //-------------------------------------------------------------------- 376cdf0e10cSrcweir ToolPanelDeck::~ToolPanelDeck() 377cdf0e10cSrcweir { 378cdf0e10cSrcweir m_pImpl->NotifyDying(); 379cdf0e10cSrcweir GetLayouter()->Destroy(); 380cdf0e10cSrcweir 381cdf0e10cSrcweir Hide(); 382cdf0e10cSrcweir for ( size_t i=0; i<GetPanelCount(); ++i ) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir PToolPanel pPanel( GetPanel( i ) ); 385cdf0e10cSrcweir pPanel->Dispose(); 386cdf0e10cSrcweir } 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389cdf0e10cSrcweir //-------------------------------------------------------------------- 390cdf0e10cSrcweir size_t ToolPanelDeck::GetPanelCount() const 391cdf0e10cSrcweir { 392cdf0e10cSrcweir return m_pImpl->GetPanelCount(); 393cdf0e10cSrcweir } 394cdf0e10cSrcweir 395cdf0e10cSrcweir //-------------------------------------------------------------------- 396cdf0e10cSrcweir PToolPanel ToolPanelDeck::GetPanel( const size_t i_nPos ) const 397cdf0e10cSrcweir { 398cdf0e10cSrcweir return m_pImpl->GetPanel( i_nPos ); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir 401cdf0e10cSrcweir //-------------------------------------------------------------------- 402cdf0e10cSrcweir ::boost::optional< size_t > ToolPanelDeck::GetActivePanel() const 403cdf0e10cSrcweir { 404cdf0e10cSrcweir return m_pImpl->GetActivePanel(); 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir //-------------------------------------------------------------------- 408cdf0e10cSrcweir void ToolPanelDeck::ActivatePanel( const ::boost::optional< size_t >& i_rPanel ) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir m_pImpl->ActivatePanel( i_rPanel ); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir //-------------------------------------------------------------------- 414cdf0e10cSrcweir size_t ToolPanelDeck::InsertPanel( const PToolPanel& i_pPanel, const size_t i_nPosition ) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir return m_pImpl->InsertPanel( i_pPanel, i_nPosition ); 417cdf0e10cSrcweir } 418cdf0e10cSrcweir 419cdf0e10cSrcweir //-------------------------------------------------------------------- 420cdf0e10cSrcweir PToolPanel ToolPanelDeck::RemovePanel( const size_t i_nPosition ) 421cdf0e10cSrcweir { 422cdf0e10cSrcweir return m_pImpl->RemovePanel( i_nPosition ); 423cdf0e10cSrcweir } 424cdf0e10cSrcweir 425cdf0e10cSrcweir //-------------------------------------------------------------------- 426cdf0e10cSrcweir PDeckLayouter ToolPanelDeck::GetLayouter() const 427cdf0e10cSrcweir { 428cdf0e10cSrcweir return m_pImpl->GetLayouter(); 429cdf0e10cSrcweir } 430cdf0e10cSrcweir 431cdf0e10cSrcweir //-------------------------------------------------------------------- 432cdf0e10cSrcweir void ToolPanelDeck::SetLayouter( const PDeckLayouter& i_pNewLayouter ) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir return m_pImpl->SetLayouter( i_pNewLayouter ); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir //-------------------------------------------------------------------- 438cdf0e10cSrcweir void ToolPanelDeck::AddListener( IToolPanelDeckListener& i_rListener ) 439cdf0e10cSrcweir { 440cdf0e10cSrcweir m_pImpl->AddListener( i_rListener ); 441cdf0e10cSrcweir } 442cdf0e10cSrcweir 443cdf0e10cSrcweir //-------------------------------------------------------------------- 444cdf0e10cSrcweir void ToolPanelDeck::RemoveListener( IToolPanelDeckListener& i_rListener ) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir m_pImpl->RemoveListener( i_rListener ); 447cdf0e10cSrcweir } 448cdf0e10cSrcweir 449cdf0e10cSrcweir //-------------------------------------------------------------------- 450cdf0e10cSrcweir Window& ToolPanelDeck::GetPanelWindowAnchor() 451cdf0e10cSrcweir { 452cdf0e10cSrcweir return m_pImpl->GetPanelWindowAnchor(); 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir //-------------------------------------------------------------------- 456cdf0e10cSrcweir const Window& ToolPanelDeck::GetPanelWindowAnchor() const 457cdf0e10cSrcweir { 458cdf0e10cSrcweir return m_pImpl->GetPanelWindowAnchor(); 459cdf0e10cSrcweir } 460cdf0e10cSrcweir 461cdf0e10cSrcweir //-------------------------------------------------------------------- 462cdf0e10cSrcweir void ToolPanelDeck::Resize() 463cdf0e10cSrcweir { 464cdf0e10cSrcweir Control::Resize(); 465cdf0e10cSrcweir m_pImpl->LayoutAll(); 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468cdf0e10cSrcweir //-------------------------------------------------------------------- 469cdf0e10cSrcweir long ToolPanelDeck::Notify( NotifyEvent& i_rNotifyEvent ) 470cdf0e10cSrcweir { 471cdf0e10cSrcweir bool bHandled = false; 472cdf0e10cSrcweir if ( i_rNotifyEvent.GetType() == EVENT_KEYINPUT ) 473cdf0e10cSrcweir { 474cdf0e10cSrcweir const KeyEvent* pEvent = i_rNotifyEvent.GetKeyEvent(); 475cdf0e10cSrcweir const KeyCode& rKeyCode = pEvent->GetKeyCode(); 476cdf0e10cSrcweir if ( rKeyCode.GetModifier() == KEY_MOD1 ) 477cdf0e10cSrcweir { 478cdf0e10cSrcweir bHandled = true; 479cdf0e10cSrcweir switch ( rKeyCode.GetCode() ) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir case KEY_HOME: 482cdf0e10cSrcweir m_pImpl->DoAction( ACTION_ACTIVATE_FIRST ); 483cdf0e10cSrcweir break; 484cdf0e10cSrcweir case KEY_PAGEUP: 485cdf0e10cSrcweir m_pImpl->DoAction( ACTION_ACTIVATE_PREV ); 486cdf0e10cSrcweir break; 487cdf0e10cSrcweir case KEY_PAGEDOWN: 488cdf0e10cSrcweir m_pImpl->DoAction( ACTION_ACTIVATE_NEXT ); 489cdf0e10cSrcweir break; 490cdf0e10cSrcweir case KEY_END: 491cdf0e10cSrcweir m_pImpl->DoAction( ACTION_ACTIVATE_LAST ); 492cdf0e10cSrcweir break; 493cdf0e10cSrcweir default: 494cdf0e10cSrcweir bHandled = false; 495cdf0e10cSrcweir break; 496cdf0e10cSrcweir } 497cdf0e10cSrcweir } 498cdf0e10cSrcweir else if ( rKeyCode.GetModifier() == ( KEY_MOD1 | KEY_SHIFT ) ) 499cdf0e10cSrcweir { 500cdf0e10cSrcweir if ( rKeyCode.GetCode() == KEY_E ) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir m_pImpl->DoAction( ACTION_TOGGLE_FOCUS ); 503cdf0e10cSrcweir bHandled = true; 504cdf0e10cSrcweir } 505cdf0e10cSrcweir } 506cdf0e10cSrcweir } 507cdf0e10cSrcweir 508cdf0e10cSrcweir if ( bHandled ) 509cdf0e10cSrcweir return 1; 510cdf0e10cSrcweir 511cdf0e10cSrcweir return Control::Notify( i_rNotifyEvent ); 512cdf0e10cSrcweir } 513cdf0e10cSrcweir 514cdf0e10cSrcweir //-------------------------------------------------------------------- 515cdf0e10cSrcweir void ToolPanelDeck::GetFocus() 516cdf0e10cSrcweir { 517cdf0e10cSrcweir Control::GetFocus(); 518cdf0e10cSrcweir if ( m_pImpl->IsDead() ) 519cdf0e10cSrcweir return; 520cdf0e10cSrcweir if ( !m_pImpl->FocusActivePanel() ) 521cdf0e10cSrcweir { 522cdf0e10cSrcweir PDeckLayouter pLayouter( GetLayouter() ); 523cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( pLayouter.get(), "ToolPanelDeck::GetFocus: no layouter?!" ); 524cdf0e10cSrcweir pLayouter->SetFocusToPanelSelector(); 525cdf0e10cSrcweir } 526cdf0e10cSrcweir } 527cdf0e10cSrcweir 528cdf0e10cSrcweir //-------------------------------------------------------------------- 529cdf0e10cSrcweir void ToolPanelDeck::SetAccessibleParentWindow( Window* i_pAccessibleParent ) 530cdf0e10cSrcweir { 531cdf0e10cSrcweir m_pImpl->SetAccessibleParentWindow( i_pAccessibleParent ); 532cdf0e10cSrcweir } 533cdf0e10cSrcweir 534cdf0e10cSrcweir //-------------------------------------------------------------------- 535cdf0e10cSrcweir Window* ToolPanelDeck::GetAccessibleParentWindow() const 536cdf0e10cSrcweir { 537cdf0e10cSrcweir Window* pAccessibleParent( m_pImpl->GetAccessibleParentWindow() ); 538cdf0e10cSrcweir if ( !pAccessibleParent ) 539cdf0e10cSrcweir pAccessibleParent = Window::GetAccessibleParentWindow(); 540cdf0e10cSrcweir return pAccessibleParent; 541cdf0e10cSrcweir } 542cdf0e10cSrcweir 543cdf0e10cSrcweir //-------------------------------------------------------------------- 544cdf0e10cSrcweir Reference< XWindowPeer > ToolPanelDeck::GetComponentInterface( sal_Bool i_bCreate ) 545cdf0e10cSrcweir { 546cdf0e10cSrcweir Reference< XWindowPeer > xWindowPeer( Control::GetComponentInterface( sal_False ) ); 547cdf0e10cSrcweir if ( !xWindowPeer.is() && i_bCreate ) 548cdf0e10cSrcweir { 549cdf0e10cSrcweir xWindowPeer.set( new ToolPanelDeckPeer( *this ) ); 550cdf0e10cSrcweir SetComponentInterface( xWindowPeer ); 551cdf0e10cSrcweir } 552cdf0e10cSrcweir return xWindowPeer; 553cdf0e10cSrcweir } 554cdf0e10cSrcweir 555cdf0e10cSrcweir //........................................................................ 556cdf0e10cSrcweir } // namespace svt 557cdf0e10cSrcweir //........................................................................ 558