1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #ifndef SFX_SIDEBAR_FOCUS_MANAGER_HXX 23 #define SFX_SIDEBAR_FOCUS_MANAGER_HXX 24 25 #include "Panel.hxx" 26 #include <tools/link.hxx> 27 28 class Button; 29 class KeyCode; 30 class VclSimpleEvent; 31 32 namespace sfx2 { namespace sidebar { 33 34 /** Concentrate all focus handling in this class. 35 There are two rings of windows that accept the input focus: panels 36 and tab bar buttons. 37 Arrow keys move the focus between them. Tab moves focus between rings. 38 */ 39 class FocusManager 40 { 41 public: 42 FocusManager (void); 43 ~FocusManager (void); 44 45 /** Forget all panels and buttons. Remove all window listeners. 46 */ 47 void Clear (void); 48 49 /** Transfer the focus into the sidebar tree of windows. This is 50 typically called from the SidebarChildWindow as result of 51 pressing the F6 key. 52 */ 53 void GrabFocus (void); 54 55 /** Handle the key event that was sent to the docking window. 56 */ 57 long NotifyDockingWindowEvent (const KeyEvent& rKeyEvent); 58 59 void SetPanels (const SharedPanelContainer& rPanels); 60 61 void SetButtons (const ::std::vector<Button*>& rButtons); 62 63 private: 64 ::std::vector<Panel*> maPanels; 65 ::std::vector<Button*> maButtons; 66 Window* mpTopLevelWindow; 67 68 /** Listen for key events for panels and buttons. 69 */ 70 DECL_LINK(WindowEventListener, VclSimpleEvent*); 71 72 void ClearPanels (void); 73 void ClearButtons (void); 74 75 /** Let the focus manager listen for window events for the given 76 window. 77 */ 78 void RegisterWindow (Window& rWindow); 79 void UnregisterWindow (Window& rWindow); 80 void RegisterTopLevelListener (void); 81 82 /** Remove the window from the panel or the button container. 83 */ 84 void RemoveWindow (Window& rWindow); 85 86 sal_Int32 GetPanelIndex (const Window& rWindow) const; 87 sal_Int32 GetButtonIndex (const Window& rWindow) const; 88 bool IsAnyPanelFocused (void) const; 89 bool IsAnyButtonFocused (void) const; 90 91 /** Set the focus to the title bar of the panel or, if the the 92 title bar is not visible, directly to the panel. 93 */ 94 void FocusPanel (const sal_Int32 nPanelIndex); 95 void FocusPanelContent (const sal_Int32 nPanelIndex); 96 void FocusButton (const sal_Int32 nButtonIndex); 97 void ClickButton (const sal_Int32 nButtonIndex); 98 bool MoveFocusInsidePanel ( 99 const sal_Int32 nPanelIndex, 100 const sal_Int32 nDirection); 101 102 void HandleKeyEvent ( 103 const KeyCode& rKeyCode, 104 const Window& rWindow); 105 106 void SetTopLevelWindow (Window* pWindow); 107 void HandleTopLevelEvent (VclWindowEvent& rEvent); 108 }; 109 110 } } // end of namespace sfx2::sidebar 111 112 #endif 113