1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _AQUA11YFOCUSTRACKER_HXX_
29 #define _AQUA11YFOCUSTRACKER_HXX_
30 
31 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_HPP_
32 #include <com/sun/star/accessibility/XAccessible.hpp>
33 #endif
34 
35 #include "keyboardfocuslistener.hxx"
36 
37 #include <rtl/instance.hxx>
38 
39 #include <tools/link.hxx>
40 #include <vcl/vclevent.hxx>
41 #include <set>
42 
43 class Window;
44 class ToolBox;
45 class DocumentFocusListener;
46 
47 // ------------------------
48 // - AquaA11yFocusTracker -
49 // ------------------------
50 
51 class AquaA11yFocusTracker : public rtl::Static< AquaA11yFocusTracker, AquaA11yFocusTracker>
52 {
53 
54 public:
55     AquaA11yFocusTracker();
56 
57 	::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getFocusedObject() { return m_xFocusedObject; };
58 
59     // sets the currently focus object and notifies the FocusEventListener (if any)
60     void setFocusedObject(const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& xAccessible);
61 
62 	// may evolve to add/remove later
63 	void setFocusListener(const rtl::Reference< KeyboardFocusListener >& aFocusListener) { m_aFocusListener = aFocusListener; };
64 
65 protected:
66 
67     // received a WINDOW_GETFOCUS event for this window
68     virtual void window_got_focus(Window *pWindow);
69 
70     // received a TOOLBOX_HIGHLIGHT event for this window
71     virtual void toolbox_highlight_on(Window *pWindow);
72 
73     // received a TOOLBOX_HIGHLIGHTOFF event for this window
74     virtual void toolbox_highlight_off(Window *pWindow);
75 
76     // received a TABPAGE_ACTIVATE event for this window
77     virtual void tabpage_activated(Window *pWindow);
78 
79     // received a MENU_HIGHLIGHT event for this window
80     virtual void menu_highlighted(const ::VclMenuEvent *pEvent);
81 
82     // toolbox items are widgets in gtk+ and Cocoa
83     virtual void notify_toolbox_item_focus(ToolBox *pToolBox);
84 
85     // toolbox item opened a floating window (e.g. color chooser)
86     virtual void toolbox_open_floater(Window *pWindow);
87 
88     // callback function for Application::addEventListener
89 	static long WindowEventHandler(AquaA11yFocusTracker *pFocusTracker, ::VclSimpleEvent const *pEvent);
90 
91 private:
92     // the accessible object that has the keyboard focus (if any)
93     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xFocusedObject;
94 
95 	// the listener for focus events
96 	rtl::Reference< KeyboardFocusListener > m_aFocusListener;
97 
98 	// the list of Windows that need deeper (focus) investigation
99 	std::set< Window *> m_aDocumentWindowList;
100 
101 	// the link object needed for Application::addEventListener
102 	Link m_aWindowEventLink;
103 
104     // the UNO XAccessibilityEventListener for Documents and other non VCL objects
105     const ::com::sun::star::uno::Reference< DocumentFocusListener > m_xDocumentFocusListener;
106 };
107 
108 #endif	// _AQUA11YFOCUSTRACKER_HXX_
109