KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVKeyHandler.cpp
1//Created by KVClassFactory on Fri Feb 17 17:47:35 2012
2//Author: dgruyer
3
4#include "KVKeyHandler.h"
5#include "TROOT.h"
6#include "TRootCanvas.h"
7#include "TGWindow.h"
8#include <KeySymbols.h>
9#include "TVirtualX.h"
10#include <Riostream.h>
11
12using namespace std;
13
15
16
17
18
20
21KVKeyHandler::KVKeyHandler(KVCanvas* Canvas) : TGFrame(gClient->GetRoot(), 0, 0)
22{
23 // Key handler constructor.
24 if (!Canvas) {
25 cout << "WARNING: KVKeyHandler::KVKeyHandler(): invalid canvas!" << endl;
26 return;
27 }
28
29 fCanvas = Canvas;
30
31 TRootCanvas* main_frame = (TRootCanvas*)(fCanvas->GetCanvasImp());
32
33 // bind arrow keys and space-bar key
34 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_Up), 0);
35 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_Left), 0);
36 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_Right), 0);
37 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_Down), 0);
38 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_Space), 0);
39
40 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_F1), 0);
41 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_F2), 0);
42 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_F3), 0);
43 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_F4), 0);
44 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_F5), 0);
45 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_F6), 0);
46 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_F7), 0);
47 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_F8), 0);
48 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_F9), 0);
49 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_F10), 0);
50 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_F11), 0);
51 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_F12), 0);
52
53 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_a), 0);
54 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_b), 0);
55 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_c), 0);
56 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_d), 0);
57 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_e), 0);
58 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_f), 0);
59 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_g), 0);
60 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_h), 0);
61 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_i), 0);
62 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_j), 0);
63 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_k), 0);
64 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_l), 0);
65 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_m), 0);
66 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_n), 0);
67 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_o), 0);
68 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_p), 0);
69 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_q), 0);
70 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_r), 0);
71 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_s), 0);
72 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_t), 0);
73 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_u), 0);
74 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_v), 0);
75 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_w), 0);
76 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_x), 0);
77 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_y), 0);
78 main_frame->BindKey((const TGWindow*)this, gVirtualX->KeysymToKeycode(kKey_z), 0);
79
80 gVirtualX->SetKeyAutoRepeat(kTRUE);
81}
82
83
84
88
90{
91 // Cleanup key handler.
92
93 // get main frame of fCanvas
94 TRootCanvas* main_frame = (TRootCanvas*)(fCanvas->GetCanvasImp());
95
96 // remove binding of arrow keys and space-bar key
97 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_Up), 0);
98 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_Left), 0);
99 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_Right), 0);
100 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_Down), 0);
101 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_Space), 0);
102
103 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_F1), 0);
104 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_F2), 0);
105 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_F3), 0);
106 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_F4), 0);
107 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_F5), 0);
108 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_F6), 0);
109 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_F7), 0);
110 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_F8), 0);
111 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_F9), 0);
112 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_F10), 0);
113 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_F11), 0);
114 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_F12), 0);
115
116 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_a), 0);
117 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_b), 0);
118 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_c), 0);
119 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_d), 0);
120 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_e), 0);
121 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_f), 0);
122 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_g), 0);
123 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_h), 0);
124 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_i), 0);
125 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_j), 0);
126 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_k), 0);
127 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_l), 0);
128 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_m), 0);
129 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_n), 0);
130 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_o), 0);
131 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_p), 0);
132 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_q), 0);
133 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_r), 0);
134 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_s), 0);
135 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_t), 0);
136 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_u), 0);
137 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_v), 0);
138 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_w), 0);
139 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_x), 0);
140 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_y), 0);
141 main_frame->RemoveBind(this, gVirtualX->KeysymToKeycode(kKey_z), 0);
142
143 gVirtualX->SetKeyAutoRepeat(kTRUE);
144}
145
146
147
148
152
154{
155 // Handle keys
156// if(fCanvas) fCanvas->HandleKey(event);
157 return kTRUE;
158}
159
160
kKey_Right
kKey_Down
kKey_o
kKey_Space
kKey_F1
kKey_f
kKey_F9
kKey_F4
kKey_F5
kKey_F12
kKey_F6
kKey_F8
kKey_Up
kKey_r
kKey_v
kKey_l
kKey_j
kKey_x
kKey_p
kKey_F3
kKey_Left
kKey_y
kKey_z
kKey_s
kKey_e
kKey_w
kKey_g
kKey_c
kKey_k
kKey_u
kKey_t
kKey_i
kKey_a
kKey_F2
kKey_q
kKey_h
kKey_d
kKey_F11
kKey_b
kKey_F7
kKey_m
kKey_n
kKey_F10
bool Bool_t
constexpr Bool_t kTRUE
#define gVirtualX
TCanvas with mouse-controlled dynamic zoom and pan & scan.
Definition KVCanvas.h:54
Utility class to redirect keyboard events to KVCanvas.
Bool_t HandleKey(Event_t *event)
void SetCanvas(KVCanvas* Canvas){};
KVCanvas * fCanvas
TCanvasImp * GetCanvasImp() const override
virtual Bool_t BindKey(const TGWindow *w, Int_t keycode, Int_t modifier) const
virtual void RemoveBind(const TGWindow *w, Int_t keycode, Int_t modifier) const
ClassImp(TPyArg)