fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / vcl / mnemonicengine.hxx
blobe1def2d8d98e83f7681394f000b51264791723c4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 VCL_MNEMONICENGINE_HXX
21 #define VCL_MNEMONICENGINE_HXX
23 #include "dllapi.h"
25 #include <sal/config.h>
26 #include <sal/types.h>
28 #include <memory>
30 class String;
31 class KeyEvent;
33 //........................................................................
34 namespace vcl
36 //........................................................................
38 //====================================================================
39 //= IMnemonicEntryList
40 //====================================================================
41 /// callback for a MnemonicEngine
42 class SAL_NO_VTABLE VCL_DLLPUBLIC IMnemonicEntryList
44 public:
45 /** returns the first list entry for the mnemonic search
47 @return
48 a pointer which can be used to unuquely identify the entry.
49 The MenomonicEngine itself does not use this value, it
50 is only passed to other methods of this callback interface.
52 If this value is <NULL/>, searching stops.
54 virtual const void* FirstSearchEntry( String& _rEntryText ) const = 0;
56 /** returns the next list entry for the mnemonic search
58 @return
59 a pointer which can be used to unuquely identify the entry.
60 The MenomonicEngine itself does not use this value, it
61 is only passed to other methods of this callback interface.
63 If this value is <NULL/>, searching stops.
65 If this value is the same as returned by the previous call
66 to <member>FirstSearchEntry</member> (i.e. you cycled
67 around), then searching stops, too.
69 virtual const void* NextSearchEntry( const void* _pCurrentSearchEntry, String& _rEntryText ) const = 0;
71 /** "selects" a given entry.
73 Note: The semantics of "select" depends on your implementation. You
74 might actually really select the entry (in the sense of a selected
75 list box entry, for example), you might make it the current entry,
76 if your implementation supports this - whatever.
78 @param _pEntry
79 the entry to select. This is the return value of a previous call
80 to <member>FirstSearchEntry</member> or <member>NextSearchEntry</member>.
82 virtual void SelectSearchEntry( const void* _pEntry ) = 0;
84 /** "executes" the current search entry, i.e. the one returned
85 in the previous <member>NextSearchEntry</member> call.
87 Note: The semantics of "execute" depends on your implementation. You
88 might even have a list of entries which cannot be executed at all.
90 This method is called after <member>SelectSearchEntry</member>,
91 if and only if the current entry's mnemonic is unambiguous.
93 For instance, imagine a list which has two entries with the same mnemonic
94 character, say "c". Now if the user presses <code>Alt-C</code>, the MnemonicEngine
95 will call <member>SelectCurrentEntry</member> as soon as it encounters
96 the first entry, but it'll never call <member>ExecuteSearchEntry</member>.
98 If, however, "c" is a unique mnemonic character in your entry list, then the
99 call of <member>SelectSearchEntry</member> will be followed by a
100 call to <member>ExecuteSearchEntry</member>.
102 This way, you can implement cyclic selection of entries: In
103 <member>FirstSearchEntry</member>, return the entry which was previously
104 selected, and in <member>NextSearchEntry</member>, interlly cycle around
105 in your list. Then, multiple user inputs of <code>Alt-C</code> will
106 cycle through all entries with the mnemonic being "c".
108 @param _pEntry
109 the entry to select. This is the return value of a previous call
110 to <member>FirstSearchEntry</member> or <member>NextSearchEntry</member>.
112 virtual void ExecuteSearchEntry( const void* _pEntry ) const = 0;
114 protected:
115 ~IMnemonicEntryList() {}
118 //====================================================================
119 //= MnemonicEngine
120 //====================================================================
121 struct MnemonicEngine_Data;
122 class VCL_DLLPUBLIC MnemonicEngine
124 ::std::auto_ptr< MnemonicEngine_Data > m_pData;
126 public:
127 MnemonicEngine( IMnemonicEntryList& _rEntryList );
128 ~MnemonicEngine();
130 /** handles a key event
132 If the key event denotes pressing an accelerator key, then the
133 entry list is searched for a matching entry. If such an entry is
134 found, <member>IMnemonicEntryList::SelectSearchEntry</member>
135 is called.
137 If the entry is the only one with the given mnemonic character, then
138 also <member>IMnemonicEntryList::ExecuteSearchEntry</member>
139 is called.
141 @return
142 if the key event has been handled, and should thus not be processed
143 further.
145 bool HandleKeyEvent( const KeyEvent& _rKEvt );
148 //........................................................................
149 } // namespace vcl
150 //........................................................................
152 #endif // VCL_MNEMONICENGINE_HXX
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */