KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWEventMap.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWEventMap.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWEventMap - map between mouse/keyboard event and actions
15 // .SECTION Description
16 // vtkKWEventMap maintains 3 lists of events -- for mouse, keyboard, and
17 // keysym events. The mouse event list maps between mouse button + modifier
18 // keys and actions. The keyboard event list maps between keys + modifier
19 // keys and actions. The keysym event list maps between keysyms and actions.
20 
21 #ifndef __vtkKWEventMap_h
22 #define __vtkKWEventMap_h
23 
24 #include "vtkObject.h"
25 #include "vtkKWWidgets.h" // Needed for export symbols directives
26 
27 class KWWidgets_EXPORT vtkKWEventMap : public vtkObject
28 {
29 public:
30  static vtkKWEventMap *New();
31  vtkTypeRevisionMacro(vtkKWEventMap, vtkObject);
32  void PrintSelf(ostream& os, vtkIndent indent);
33 
34  // In the following code:
35  // button: 0 = Left, 1 = Middle, 2 = Right
36  // modifier: 0 = button only, 1 = button + shift, 2 = button + control
37 
38  //BTX
39  enum
40  {
41  LeftButton = 0,
42  MiddleButton = 1,
43  RightButton = 2
44  };
45 
46  enum
47  {
48  NoModifier = 0,
49  ShiftModifier = 1,
50  ControlModifier = 2,
51  ControlShiftModifier = 3
52  };
53  //ETX
54 
55 
56  //BTX
57  // @cond nested_class
58  class MouseEvent
59  {
60  public:
61  int Button;
62  int Modifier;
63  char *Action;
64  char *Context;
65  char *Description;
66  };
67  // @endcond
68 
69  // @cond nested_class
70  class KeyEvent
71  {
72  public:
73  char Key;
74  int Modifier;
75  char *Action;
76  char *Context;
77  char *Description;
78  };
79  // @endcond
80 
81  // @cond nested_class
82  class KeySymEvent
83  {
84  public:
85  char *KeySym;
86  int Modifier;
87  char *Action;
88  char *Context;
89  char *Description;
90  };
91  // @endcond
92  //ETX
93 
94  // ---------------------------------------------------------
95 
96  // Description:
97  // Add a unique action with a specific mouse button and modifier key to
98  // the list of mouse events.
99  //BTX
100  void AddMouseEvent(vtkKWEventMap::MouseEvent *me);
101  //ETX
102  void AddMouseEvent(int button, int modifier, const char *action);
103  void AddMouseEvent(int button, int modifier, const char *action,
104  const char *context, const char *description);
105 
106  // Description:
107  // Change the action to associate with a specific mouse button and modifier
108  // key. A mouse event with this button and modifier must have already have
109  // been added.
110  //BTX
111  void SetMouseEvent(vtkKWEventMap::MouseEvent *me);
112  //ETX
113  void SetMouseEvent(int button, int modifier, const char *action);
114  void SetMouseEvent(int button, int modifier, const char *action,
115  const char *context, const char *description);
116 
117  // Description:
118  // Get the mouse event at the specified index.
119  //BTX
120  vtkKWEventMap::MouseEvent* GetMouseEvent(int index);
121  //ETX
122 
123  // Description:
124  // Remove the action associated with this mouse button and modifier key from
125  // the list of mouse events (or all actions if action is NULL).
126  //BTX
127  void RemoveMouseEvent(vtkKWEventMap::MouseEvent *me);
128  //ETX
129  void RemoveMouseEvent(int button, int modifier, const char *action = NULL);
130  void RemoveAllMouseEvents();
131 
132  // Description:
133  // Return the string for the action of the mouse event indicated by this
134  // button and modifier.
135  const char* FindMouseAction(int button, int modifier);
136 
137  // Description:
138  // Return the total number of mouse events.
139  vtkGetMacro(NumberOfMouseEvents, int);
140 
141  // ---------------------------------------------------------
142 
143  // Description:
144  // Add a unique action with a specific key and modifier key to
145  // the list of key events.
146  //BTX
147  void AddKeyEvent(vtkKWEventMap::KeyEvent *me);
148  //ETX
149  void AddKeyEvent(char key, int modifier, const char *action);
150  void AddKeyEvent(char key, int modifier, const char *action,
151  const char *context, const char *description);
152 
153  // Description:
154  // Change the action to associate with a specific key and modifier key.
155  // A key event with this key and modifier must have already been added.
156  void SetKeyEvent(char key, int modifier, const char *action);
157  void SetKeyEvent(char key, int modifier, const char *action,
158  const char *context, const char *description);
159 
160  // Description:
161  // Get the key event at the specified index.
162  //BTX
163  vtkKWEventMap::KeyEvent* GetKeyEvent(int index);
164  //ETX
165 
166  // Description:
167  // Remove the action associated with this key and modifier key from the list
168  // of key events (or all actions if action is NULL)..
169  void RemoveKeyEvent(char key, int modifier, const char *action = NULL);
170  void RemoveAllKeyEvents();
171 
172  // Description:
173  // Return the string for the action of the key event indicated by this key
174  // and modifier.
175  const char* FindKeyAction(char key, int modifier);
176 
177  // Description:
178  // Return the total number of key events.
179  vtkGetMacro(NumberOfKeyEvents, int);
180 
181  // ---------------------------------------------------------
182 
183  // Description:
184  // Add a unique action with a specific keysym to the list of keysym events.
185  //BTX
186  void AddKeySymEvent(vtkKWEventMap::KeySymEvent *me);
187  //ETX
188  void AddKeySymEvent(const char *keySym, int modifier, const char *action);
189  void AddKeySymEvent(const char *keySym, int modifier, const char *action,
190  const char *context, const char *description);
191 
192  // Description:
193  // Change the action to associate with a specific keysym. A keysym event
194  // with this keysym must have already been added.
195  void SetKeySymEvent(const char *keySym, int modifier, const char *action);
196  void SetKeySymEvent(const char *keySym, int modifier, const char *action,
197  const char *context, const char *description);
198 
199  // Description:
200  // Get the keysym event at the specified index.
201  //BTX
202  vtkKWEventMap::KeySymEvent* GetKeySymEvent(int index);
203  //ETX
204 
205  // Description:
206  // Remove the action assiciated with this keysym from the list of keysym
207  // events (or all actions if action is NULL)..
208  void RemoveKeySymEvent(const char *keySym, int modifier, const char *action = NULL);
209  void RemoveAllKeySymEvents();
210 
211  // Description:
212  // Return the string for the action of the keysym event indicated by this
213  // keysym.
214  const char* FindKeySymAction(const char *keySym, int modifier);
215 
216  // Description:
217  // Return the total number of keysym events.
218  vtkGetMacro(NumberOfKeySymEvents, int);
219 
220  // Description:
221  // Shallow copy.
222  void ShallowCopy(vtkKWEventMap *tprop);
223 
224 protected:
225  vtkKWEventMap();
226  ~vtkKWEventMap();
227 
228  MouseEvent *MouseEvents;
229  KeyEvent *KeyEvents;
230  KeySymEvent *KeySymEvents;
231 
235 
236 private:
237  vtkKWEventMap(const vtkKWEventMap&); // Not implemented
238  void operator=(const vtkKWEventMap&); // Not implemented
239 };
240 
241 #endif
242