1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef VCL_QUICKSELECTIONENGINE_HXX
25 #define VCL_QUICKSELECTIONENGINE_HXX
26 
27 #include "dllapi.h"
28 
29 #include <tools/string.hxx>
30 
31 #include <memory>
32 
33 class KeyEvent;
34 
35 //........................................................................
36 namespace vcl
37 {
38 //........................................................................
39 
40     typedef const void* StringEntryIdentifier;
41 
42     //====================================================================
43     //= ISearchableStringList
44     //====================================================================
45     // TODO: consolidate this with ::vcl::IMnemonicEntryList
46     class SAL_NO_VTABLE VCL_DLLPUBLIC ISearchableStringList
47     {
48     public:
49         /** returns the current entry in the list of searchable strings.
50 
51             Search operations will start with this entry.
52         */
53         virtual StringEntryIdentifier   CurrentEntry( String& _out_entryText ) const = 0;
54 
55         /** returns the next entry in the list.
56 
57             The implementation is expected to wrap around. That is, if the given entry denotes the last
58             entry in the list, then NextEntry should return the first entry.
59         */
60         virtual StringEntryIdentifier   NextEntry( StringEntryIdentifier _currentEntry, String& _out_entryText ) const = 0;
61 
62         /** selects a given entry
63         */
64         virtual void                    SelectEntry( StringEntryIdentifier _entry ) = 0;
65     };
66 
67     //====================================================================
68     //= QuickSelectionEngine
69     //====================================================================
70     struct QuickSelectionEngine_Data;
71     class VCL_DLLPUBLIC QuickSelectionEngine
72     {
73     public:
74         QuickSelectionEngine( ISearchableStringList& _entryList );
75         ~QuickSelectionEngine();
76 
77         bool    HandleKeyEvent( const KeyEvent& _rKEvt );
78         void    Reset();
79 
80     private:
81         ::std::auto_ptr< QuickSelectionEngine_Data >    m_pData;
82 
83     private:
84         QuickSelectionEngine();                                         // never implemented
85         QuickSelectionEngine( const QuickSelectionEngine& );            // never implemented
86         QuickSelectionEngine& operator=( const QuickSelectionEngine& ); // never implemented
87     };
88 
89 //........................................................................
90 } // namespace vcl
91 //........................................................................
92 
93 #endif // VCL_QUICKSELECTIONENGINE_HXX
94