1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef SD_TOOLPANEL_FOCUS_MANAGER_HXX
21 #define SD_TOOLPANEL_FOCUS_MANAGER_HXX
23 #include <tools/link.hxx>
31 namespace sd
{ namespace toolpanel
{
33 /** On certain key presses the focus is moved from one window to another.
34 For this to work every window that wants its focus managed has to
35 register or be registered and tell where to put the focus on what key
41 /** Return an instance of the focus manager.
43 static FocusManager
& Instance (void);
45 /** Register a link from one window to another so that any time the
46 specified key is pressed while the source window is focused, the
47 focus is transferred to the target window.
49 The window from which the focus will be transferred.
51 The window to which the focus will be transferred.
53 The key for which the focus is transferred from the source
54 window to the target window.
61 /** Register a link that will move the focus from the source window to
62 the target window when the source window is focused and KEY_ESCAPE
65 The window from which the focus will be transferred.
67 The window to which the focus will be transferred.
69 void RegisterUpLink (::Window
* pSource
, ::Window
* pTarget
);
71 /** Register a link that will move the focus from the source window to
72 the target window when the source window is focused and KEY_RETURN
75 The window from which the focus will be transferred.
77 The window to which the focus will be transferred.
79 void RegisterDownLink (::Window
* pSource
, ::Window
* pTarget
);
81 /** Remove all links from the source window to the target window. When
82 there are links from the target window to the source window then
89 /** Let the focus manager transfer the focus from the specified source
90 window to a target window that is determined according the the
91 registered links and the given key code.
92 When there is no rule for this combination of source window and key
93 code then the focus stays where it is.
95 bool TransferFocus (::Window
* pSource
, const KeyCode
& rCode
);
98 friend struct FocusManagerCreator
;
101 ::std::auto_ptr
<LinkMap
> mpLinks
;
104 ~FocusManager (void);
106 /** Clear the list of focus transfer links. This removes all window
111 /** Remove all links from or to the given window.
113 void RemoveLinks (::Window
* pWindow
);
115 /** Unregister as event listener from the given window when there are no
116 links from this window anymore.
118 void RemoveUnusedEventListener (::Window
* pWindow
);
120 /** Listen for key events and on KEY_RETURN go down and on
123 DECL_LINK(WindowEventListener
, VclSimpleEvent
*);
126 } } // end of namespace ::sd::toolpanel
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */