Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXAccelTable.h
1 /********************************************************************************
2 * *
3 * A c c e l e r a t o r T a b l e C l a s s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2022 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXACCELTABLE_H
22 #define FXACCELTABLE_H
23 
24 #ifndef FXOBJECT_H
25 #include "FXObject.h"
26 #endif
27 
28 namespace FX {
29 
30 
36 class FXAPI FXAccelTable : public FXObject {
37  FXDECLARE(FXAccelTable)
38 protected:
39  struct FXAccelKey {
40  FXObject *target; // Target object of message
41  FXSelector messagedn; // Message being sent
42  FXSelector messageup; // Message being sent
43  FXHotKey code; // Keysym and modifier mask to match
44  };
45 private:
46  FXAccelKey *key; // Accelerator table
47  FXuint max; // Largest table index
48  FXuint num; // Number of entries
49 private:
50  void resize(FXuint m);
51 private:
52  FXAccelTable(const FXAccelTable&);
53  FXAccelTable &operator=(const FXAccelTable&);
54 public:
55  long onKeyPress(FXObject*,FXSelector,void*);
56  long onKeyRelease(FXObject*,FXSelector,void*);
57 public:
58 
62  FXAccelTable();
63 
67  void addAccel(FXHotKey hotkey,FXObject* target=nullptr,FXSelector seldn=0,FXSelector selup=0);
68 
72  void addAccel(const FXchar* string,FXObject* target=nullptr,FXSelector seldn=0,FXSelector selup=0);
73  void addAccel(const FXString& string,FXObject* target=nullptr,FXSelector seldn=0,FXSelector selup=0);
74 
78  void removeAccel(FXHotKey hotkey);
79 
83  void removeAccel(const FXchar* string);
84  void removeAccel(const FXString& string);
85 
89  FXbool hasAccel(FXHotKey hotkey) const;
90 
94  FXbool hasAccel(const FXchar* string) const;
95  FXbool hasAccel(const FXString& string) const;
96 
100  FXObject* targetOfAccel(FXHotKey hotkey) const;
101 
105  FXObject* targetOfAccel(const FXchar* string) const;
106  FXObject* targetOfAccel(const FXString& string) const;
107 
133  static FXHotKey parseAccel(const FXchar* string);
134  static FXHotKey parseAccel(const FXString& string);
135 
142  static FXString unparseAccel(FXHotKey key);
143 
145  virtual void save(FXStream& store) const;
146 
148  virtual void load(FXStream& store);
149 
153  virtual ~FXAccelTable();
154  };
155 
156 
163 extern FXAPI FXHotKey parseHotKey(const FXString& string);
164 
171 extern FXAPI FXint findHotKey(const FXString& string);
172 
178 extern FXAPI FXString stripHotKey(const FXString& string);
179 
180 }
181 
182 #endif
The accelerator table sends a message to a specific target object when the indicated key and modifier...
Definition: FXAccelTable.h:36
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
Definition: FX4Splitter.h:28
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
Definition: FXAccelTable.h:39
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp