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 23 24 #ifndef _AQUA11YFOCUSTRACKER_HXX_ 25 #define _AQUA11YFOCUSTRACKER_HXX_ 26 27 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_HPP_ 28 #include <com/sun/star/accessibility/XAccessible.hpp> 29 #endif 30 31 #include "keyboardfocuslistener.hxx" 32 33 #include <rtl/instance.hxx> 34 35 #include <tools/link.hxx> 36 #include <vcl/vclevent.hxx> 37 #include <set> 38 39 class Window; 40 class ToolBox; 41 class DocumentFocusListener; 42 43 // ------------------------ 44 // - AquaA11yFocusTracker - 45 // ------------------------ 46 47 class AquaA11yFocusTracker : public rtl::Static< AquaA11yFocusTracker, AquaA11yFocusTracker> 48 { 49 50 public: 51 AquaA11yFocusTracker(); 52 getFocusedObject()53 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getFocusedObject() { return m_xFocusedObject; }; 54 55 // sets the currently focus object and notifies the FocusEventListener (if any) 56 void setFocusedObject(const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& xAccessible); 57 58 // may evolve to add/remove later setFocusListener(const rtl::Reference<KeyboardFocusListener> & aFocusListener)59 void setFocusListener(const rtl::Reference< KeyboardFocusListener >& aFocusListener) { m_aFocusListener = aFocusListener; }; 60 61 protected: 62 63 // received a WINDOW_GETFOCUS event for this window 64 virtual void window_got_focus(Window *pWindow); 65 66 // received a TOOLBOX_HIGHLIGHT event for this window 67 virtual void toolbox_highlight_on(Window *pWindow); 68 69 // received a TOOLBOX_HIGHLIGHTOFF event for this window 70 virtual void toolbox_highlight_off(Window *pWindow); 71 72 // received a TABPAGE_ACTIVATE event for this window 73 virtual void tabpage_activated(Window *pWindow); 74 75 // received a MENU_HIGHLIGHT event for this window 76 virtual void menu_highlighted(const ::VclMenuEvent *pEvent); 77 78 // toolbox items are widgets in gtk+ and Cocoa 79 virtual void notify_toolbox_item_focus(ToolBox *pToolBox); 80 81 // toolbox item opened a floating window (e.g. color chooser) 82 virtual void toolbox_open_floater(Window *pWindow); 83 84 // callback function for Application::addEventListener 85 static long WindowEventHandler(AquaA11yFocusTracker *pFocusTracker, ::VclSimpleEvent const *pEvent); 86 87 private: 88 // the accessible object that has the keyboard focus (if any) 89 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xFocusedObject; 90 91 // the listener for focus events 92 rtl::Reference< KeyboardFocusListener > m_aFocusListener; 93 94 // the list of Windows that need deeper (focus) investigation 95 std::set< Window *> m_aDocumentWindowList; 96 97 // the link object needed for Application::addEventListener 98 Link m_aWindowEventLink; 99 100 // the UNO XAccessibilityEventListener for Documents and other non VCL objects 101 const ::com::sun::star::uno::Reference< DocumentFocusListener > m_xDocumentFocusListener; 102 }; 103 104 #endif // _AQUA11YFOCUSTRACKER_HXX_ 105