update dev300-m58
[ooovba.git] / sd / source / ui / toolpanel / TaskPaneFocusManager.hxx
blobd4ec12a921171c0971a32b9fc5b350e6d723c459
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TaskPaneFocusManager.hxx,v $
10 * $Revision: 1.6 $
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>
36 #include <memory>
38 class KeyCode;
39 class VclSimpleEvent;
40 class Window;
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
47 press.
49 class FocusManager
51 public:
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.
59 @param pSource
60 The window from which the focus will be transferred.
61 @param pTarget
62 The window to which the focus will be transferred.
63 @param rKey
64 The key for which the focus is transferred from the source
65 window to the target window.
67 void RegisterLink (
68 ::Window* pSource,
69 ::Window* pTarget,
70 const KeyCode& rKey);
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
74 is pressed.
75 @param pSource
76 The window from which the focus will be transferred.
77 @param pTarget
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
84 is pressed.
85 @param pSource
86 The window from which the focus will be transferred.
87 @param pTarget
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
94 these are not touced.
96 void RemoveLinks (
97 ::Window* pSource,
98 ::Window* pTarget);
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);
108 private:
109 static FocusManager* spInstance;
110 class LinkMap;
111 ::std::auto_ptr<LinkMap> mpLinks;
113 FocusManager (void);
114 ~FocusManager (void);
116 /** Clear the list of focus transfer links. This removes all window
117 listeners.
119 void Clear (void);
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
131 KEY_ESCAPE go up.
133 DECL_LINK(WindowEventListener, VclSimpleEvent*);
136 } } // end of namespace ::sd::toolpanel
138 #endif