1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TaskPaneFocusManager.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_TOOLPANEL_FOCUS_MANAGER_HXX
32 #define SD_TOOLPANEL_FOCUS_MANAGER_HXX
34 #include <tools/link.hxx>
42 namespace sd
{ namespace toolpanel
{
44 /** On certain key presses the focus is moved from one window to another.
45 For this to work every window that wants its focus managed has to
46 register or be registered and tell where to put the focus on what key
52 /** Return an instance of the focus manager.
54 static FocusManager
& Instance (void);
56 /** Register a link from one window to another so that any time the
57 specified key is pressed while the source window is focused, the
58 focus is transferred to the target window.
60 The window from which the focus will be transferred.
62 The window to which the focus will be transferred.
64 The key for which the focus is transferred from the source
65 window to the target window.
72 /** Register a link that will move the focus from the source window to
73 the target window when the source window is focused and KEY_ESCAPE
76 The window from which the focus will be transferred.
78 The window to which the focus will be transferred.
80 void RegisterUpLink (::Window
* pSource
, ::Window
* pTarget
);
82 /** Register a link that will move the focus from the source window to
83 the target window when the source window is focused and KEY_RETURN
86 The window from which the focus will be transferred.
88 The window to which the focus will be transferred.
90 void RegisterDownLink (::Window
* pSource
, ::Window
* pTarget
);
92 /** Remove all links from the source window to the target window. When
93 there are links from the target window to the source window then
100 /** Let the focus manager transfer the focus from the specified source
101 window to a target window that is determined according the the
102 registered links and the given key code.
103 When there is no rule for this combination of source window and key
104 code then the focus stays where it is.
106 bool TransferFocus (::Window
* pSource
, const KeyCode
& rCode
);
109 static FocusManager
* spInstance
;
111 ::std::auto_ptr
<LinkMap
> mpLinks
;
114 ~FocusManager (void);
116 /** Clear the list of focus transfer links. This removes all window
121 /** Remove all links from or to the given window.
123 void RemoveLinks (::Window
* pWindow
);
125 /** Unregister as event listener from the given window when there are no
126 links from this window anymore.
128 void RemoveUnusedEventListener (::Window
* pWindow
);
130 /** Listen for key events and on KEY_RETURN go down and on
133 DECL_LINK(WindowEventListener
, VclSimpleEvent
*);
136 } } // end of namespace ::sd::toolpanel