165908a7eSAndre Fischer /************************************************************** 265908a7eSAndre Fischer * 365908a7eSAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 465908a7eSAndre Fischer * or more contributor license agreements. See the NOTICE file 565908a7eSAndre Fischer * distributed with this work for additional information 665908a7eSAndre Fischer * regarding copyright ownership. The ASF licenses this file 765908a7eSAndre Fischer * to you under the Apache License, Version 2.0 (the 865908a7eSAndre Fischer * "License"); you may not use this file except in compliance 965908a7eSAndre Fischer * with the License. You may obtain a copy of the License at 1065908a7eSAndre Fischer * 1165908a7eSAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 1265908a7eSAndre Fischer * 1365908a7eSAndre Fischer * Unless required by applicable law or agreed to in writing, 1465908a7eSAndre Fischer * software distributed under the License is distributed on an 1565908a7eSAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1665908a7eSAndre Fischer * KIND, either express or implied. See the License for the 1765908a7eSAndre Fischer * specific language governing permissions and limitations 1865908a7eSAndre Fischer * under the License. 1965908a7eSAndre Fischer * 2065908a7eSAndre Fischer *************************************************************/ 2165908a7eSAndre Fischer 2265908a7eSAndre Fischer #ifndef SFX_SIDEBAR_FOCUS_MANAGER_HXX 2365908a7eSAndre Fischer #define SFX_SIDEBAR_FOCUS_MANAGER_HXX 2465908a7eSAndre Fischer 2565908a7eSAndre Fischer #include "Panel.hxx" 2665908a7eSAndre Fischer #include <tools/link.hxx> 2765908a7eSAndre Fischer 2865908a7eSAndre Fischer class Button; 2965908a7eSAndre Fischer class KeyCode; 3065908a7eSAndre Fischer class VclSimpleEvent; 3165908a7eSAndre Fischer 3252d13b84SAndre Fischer 3365908a7eSAndre Fischer namespace sfx2 { namespace sidebar { 3465908a7eSAndre Fischer 3552d13b84SAndre Fischer class DeckTitleBar; 3652d13b84SAndre Fischer 3765908a7eSAndre Fischer /** Concentrate all focus handling in this class. 3852d13b84SAndre Fischer 3952d13b84SAndre Fischer There is one ring of windows that accept the input focus which are 4052d13b84SAndre Fischer cycled through with the arrow keys: 4152d13b84SAndre Fischer - the closer in the deck title (present only when docked) 4252d13b84SAndre Fischer - the panel title bars 4352d13b84SAndre Fischer - the tab bar items 4452d13b84SAndre Fischer 4552d13b84SAndre Fischer When the focus is in a panel title then focus travels over 4652d13b84SAndre Fischer - the panel title 4752d13b84SAndre Fischer - the panel closer 4852d13b84SAndre Fischer - the panel content 4952d13b84SAndre Fischer 5052d13b84SAndre Fischer Once the focus is in the panel content then focus cycles through 5152d13b84SAndre Fischer all controls inside the panel but not back to the title bar of 5252d13b84SAndre Fischer the panel. Escape places the focus back in the panel title. 5365908a7eSAndre Fischer */ 5465908a7eSAndre Fischer class FocusManager 5565908a7eSAndre Fischer { 5665908a7eSAndre Fischer public: 5752d13b84SAndre Fischer FocusManager (const ::boost::function<void(const Panel&)>& rShowPanelFunctor); 5865908a7eSAndre Fischer ~FocusManager (void); 5965908a7eSAndre Fischer 6065908a7eSAndre Fischer /** Forget all panels and buttons. Remove all window listeners. 6165908a7eSAndre Fischer */ 6265908a7eSAndre Fischer void Clear (void); 6365908a7eSAndre Fischer 6465908a7eSAndre Fischer /** Transfer the focus into the sidebar tree of windows. This is 6565908a7eSAndre Fischer typically called from the SidebarChildWindow as result of 6665908a7eSAndre Fischer pressing the F6 key. 6765908a7eSAndre Fischer */ 6865908a7eSAndre Fischer void GrabFocus (void); 6965908a7eSAndre Fischer 7052d13b84SAndre Fischer void SetDeckTitle (DeckTitleBar* pDeckTitleBar); 7165908a7eSAndre Fischer void SetPanels (const SharedPanelContainer& rPanels); 7265908a7eSAndre Fischer void SetButtons (const ::std::vector<Button*>& rButtons); 7365908a7eSAndre Fischer 7465908a7eSAndre Fischer private: 7552d13b84SAndre Fischer DeckTitleBar* mpDeckTitleBar; 7665908a7eSAndre Fischer ::std::vector<Panel*> maPanels; 7765908a7eSAndre Fischer ::std::vector<Button*> maButtons; 7852d13b84SAndre Fischer const ::boost::function<void(const Panel&)> maShowPanelFunctor; 79*441705dbSAndre Fischer bool mbObservingContentControlFocus; 80*441705dbSAndre Fischer Window* mpFirstFocusedContentControl; 81*441705dbSAndre Fischer Window* mpLastFocusedWindow; 82*441705dbSAndre Fischer 8352d13b84SAndre Fischer enum PanelComponent 8452d13b84SAndre Fischer { 8552d13b84SAndre Fischer PC_DeckTitle, 8652d13b84SAndre Fischer PC_DeckToolBox, 8752d13b84SAndre Fischer PC_PanelTitle, 8852d13b84SAndre Fischer PC_PanelToolBox, 8952d13b84SAndre Fischer PC_PanelContent, 9052d13b84SAndre Fischer PC_TabBar, 9152d13b84SAndre Fischer PC_None 9252d13b84SAndre Fischer }; 9352d13b84SAndre Fischer class FocusLocation 9452d13b84SAndre Fischer { 9552d13b84SAndre Fischer public: 9652d13b84SAndre Fischer PanelComponent meComponent; 9752d13b84SAndre Fischer sal_Int32 mnIndex; 9852d13b84SAndre Fischer FocusLocation (const PanelComponent eComponent, const sal_Int32 nIndex); 9952d13b84SAndre Fischer }; 10052d13b84SAndre Fischer 10165908a7eSAndre Fischer /** Listen for key events for panels and buttons. 10265908a7eSAndre Fischer */ 10365908a7eSAndre Fischer DECL_LINK(WindowEventListener, VclSimpleEvent*); 10452d13b84SAndre Fischer DECL_LINK(ChildEventListener, VclSimpleEvent*); 10565908a7eSAndre Fischer 10665908a7eSAndre Fischer void ClearPanels (void); 10765908a7eSAndre Fischer void ClearButtons (void); 10865908a7eSAndre Fischer 10965908a7eSAndre Fischer /** Let the focus manager listen for window events for the given 11065908a7eSAndre Fischer window. 11165908a7eSAndre Fischer */ 11265908a7eSAndre Fischer void RegisterWindow (Window& rWindow); 11365908a7eSAndre Fischer void UnregisterWindow (Window& rWindow); 11465908a7eSAndre Fischer 11565908a7eSAndre Fischer /** Remove the window from the panel or the button container. 11665908a7eSAndre Fischer */ 11765908a7eSAndre Fischer void RemoveWindow (Window& rWindow); 11865908a7eSAndre Fischer 11965908a7eSAndre Fischer bool IsAnyPanelFocused (void) const; 12065908a7eSAndre Fischer bool IsAnyButtonFocused (void) const; 12165908a7eSAndre Fischer 12252d13b84SAndre Fischer void FocusDeckTitle (void); 12352d13b84SAndre Fischer bool IsDeckTitleVisible (void) const; 124*441705dbSAndre Fischer bool IsPanelTitleVisible (const sal_Int32 nPanelIndex) const; 12552d13b84SAndre Fischer 12665908a7eSAndre Fischer /** Set the focus to the title bar of the panel or, if the the 12765908a7eSAndre Fischer title bar is not visible, directly to the panel. 128*441705dbSAndre Fischer @param nPanelIndex 129*441705dbSAndre Fischer Index of the panel to focus. 130*441705dbSAndre Fischer @param bFallbackToDeckTitle 131*441705dbSAndre Fischer When the panel title bar is not visible then The fallback 132*441705dbSAndre Fischer bias defines whether to focus the deck (true) or the panel 133*441705dbSAndre Fischer content (false) will be focused instead. 13465908a7eSAndre Fischer */ 135*441705dbSAndre Fischer void FocusPanel ( 136*441705dbSAndre Fischer const sal_Int32 nPanelIndex, 137*441705dbSAndre Fischer const bool bFallbackToDeckTitle); 138*441705dbSAndre Fischer 13965908a7eSAndre Fischer void FocusPanelContent (const sal_Int32 nPanelIndex); 14065908a7eSAndre Fischer void FocusButton (const sal_Int32 nButtonIndex); 14165908a7eSAndre Fischer void ClickButton (const sal_Int32 nButtonIndex); 14265908a7eSAndre Fischer bool MoveFocusInsidePanel ( 14352d13b84SAndre Fischer const FocusLocation aLocation, 14465908a7eSAndre Fischer const sal_Int32 nDirection); 145*441705dbSAndre Fischer bool MoveFocusInsideDeckTitle ( 146*441705dbSAndre Fischer const FocusLocation aLocation, 147*441705dbSAndre Fischer const sal_Int32 nDirection); 14865908a7eSAndre Fischer 14965908a7eSAndre Fischer void HandleKeyEvent ( 15065908a7eSAndre Fischer const KeyCode& rKeyCode, 15165908a7eSAndre Fischer const Window& rWindow); 15265908a7eSAndre Fischer 15352d13b84SAndre Fischer FocusLocation GetFocusLocation (const Window& rWindow) const; 15452d13b84SAndre Fischer 15565908a7eSAndre Fischer }; 15665908a7eSAndre Fischer 15765908a7eSAndre Fischer } } // end of namespace sfx2::sidebar 15865908a7eSAndre Fischer 15965908a7eSAndre Fischer #endif 160