LibreOffice Module vcl (master)  1
accel.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #include <config_options.h>
23 #include <tools/solar.h>
24 #include <tools/link.hxx>
25 #include <vcl/keycod.hxx>
26 #include <vcl/dllapi.h>
27 #include <memory>
28 #include <map>
29 #include <vector>
30 
31 class CommandEvent;
32 
33 class Accelerator;
34 
36 {
37 public:
41  sal_uInt16 mnId;
42  bool mbEnabled;
43 };
44 
45 typedef ::std::vector< std::unique_ptr<ImplAccelEntry> > ImplAccelList;
46 
48 {
49  friend class ImplAccelManager;
50 
51 private:
52  typedef ::std::map< sal_uLong, ImplAccelEntry* > ImplAccelMap;
53  ImplAccelMap maKeyMap; // for keycodes, generated with a code
54  ImplAccelList maIdList; // Id-List
57 
58  // Will be set by AcceleratorManager
59  sal_uInt16 mnCurId;
60  bool* mpDel;
61 
62  void ImplInit();
63  void ImplCopyData( const Accelerator& rAccelData );
64  void ImplDeleteData();
65  void ImplInsertAccel(sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode,
66  bool bEnable, Accelerator* pAutoAccel);
67 
68  ImplAccelEntry* ImplGetAccelData( const vcl::KeyCode& rKeyCode ) const;
69 
70 public:
71  Accelerator();
72  Accelerator( const Accelerator& rAccel );
73  ~Accelerator();
74 
75  void Activate();
76  void Select();
77 
78  void InsertItem( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode );
79 
80  sal_uInt16 GetCurItemId() const { return mnCurId; }
81 
82  sal_uInt16 GetItemCount() const;
83  sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
84 
85  Accelerator* GetAccel( sal_uInt16 nItemId ) const;
86 
87  void SetActivateHdl( const Link<Accelerator&,void>& rLink ) { maActivateHdl = rLink; }
88  void SetSelectHdl( const Link<Accelerator&,void>& rLink ) { maSelectHdl = rLink; }
89 
90  Accelerator& operator=( const Accelerator& rAccel );
91 };
92 
93 bool ImplGetKeyCode( KeyFuncType eFunc, sal_uInt16& rCode1, sal_uInt16& rCode2, sal_uInt16& rCode3, sal_uInt16& rCode4 );
94 
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::vector< std::unique_ptr< ImplAccelEntry > > ImplAccelList
Definition: accel.hxx:45
bool ImplGetKeyCode(KeyFuncType eFunc, sal_uInt16 &rCode1, sal_uInt16 &rCode2, sal_uInt16 &rCode3, sal_uInt16 &rCode4)
Definition: keycod.cxx:40
::std::map< sal_uLong, ImplAccelEntry * > ImplAccelMap
Definition: accel.hxx:52
Accelerator * mpAutoAccel
Definition: accel.hxx:39
void ImplCopyData(const Accelerator &rAccelData)
Definition: accel.cxx:121
bool mbEnabled
Definition: accel.hxx:42
sal_uInt16 mnId
Definition: accel.hxx:41
Accelerator()
Definition: accel.cxx:202
Link< Accelerator &, void > maSelectHdl
Definition: accel.hxx:56
KeyFuncType
Definition: keycod.hxx:27
void ImplInit()
Definition: accel.cxx:106
sal_uInt16 mnCurId
Definition: accel.hxx:59
void Select()
Definition: accel.cxx:228
sal_uInt16 GetCurItemId() const
Definition: accel.hxx:80
void SetSelectHdl(const Link< Accelerator &, void > &rLink)
Definition: accel.hxx:88
ImplAccelMap maKeyMap
Definition: accel.hxx:53
sal_uInt16 GetItemCount() const
Definition: accel.cxx:238
Accelerator * GetAccel(sal_uInt16 nItemId) const
Definition: accel.cxx:253
Accelerator * mpAccel
Definition: accel.hxx:38
sal_uInt16 GetItemId(sal_uInt16 nPos) const
Definition: accel.cxx:243
Accelerator & operator=(const Accelerator &rAccel)
Definition: accel.cxx:263
Link< Accelerator &, void > maActivateHdl
Definition: accel.hxx:55
ImplAccelEntry * ImplGetAccelData(const vcl::KeyCode &rKeyCode) const
Definition: accel.cxx:112
bool * mpDel
Definition: accel.hxx:60
void ImplInsertAccel(sal_uInt16 nItemId, const vcl::KeyCode &rKeyCode, bool bEnable, Accelerator *pAutoAccel)
Definition: accel.cxx:151
~Accelerator()
Definition: accel.cxx:213
void Activate()
Definition: accel.cxx:223
ImplAccelList maIdList
Definition: accel.hxx:54
vcl::KeyCode maKeyCode
Definition: accel.hxx:40
void SetActivateHdl(const Link< Accelerator &, void > &rLink)
Definition: accel.hxx:87
void ImplDeleteData()
Definition: accel.cxx:142
void InsertItem(sal_uInt16 nItemId, const vcl::KeyCode &rKeyCode)
Definition: accel.cxx:233