blob: df5cf8940f684062dd59ce7d0db2ce259987d7c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/****************************************************************************
KHotKeys
Copyright (C) 2003 Mike Pilone <[email protected]>
Copyright (C) 2003 Lubos Lunak <[email protected]>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#include <tqcolor.h>
#include <tqevent.h>
#include "gesturerecorder.h"
namespace KHotKeys
{
GestureRecorder::GestureRecorder(TQWidget *parent, const char *name)
: TQFrame(parent, name), _mouseButtonDown(false)
{
setBackgroundColor( tqcolorGroup().base());
setFrameStyle(TQFrame::Sunken | TQFrame::Panel);
setLineWidth(2);
setMidLineWidth(0);
}
GestureRecorder::~GestureRecorder()
{
}
void GestureRecorder::mousePressEvent(TQMouseEvent *ev)
{
if (ev->button() == TQMouseEvent::LeftButton)
{
_mouseButtonDown = true;
stroke.reset();
TQPoint pos = ev->pos();
stroke.record(pos.x(), pos.y());
}
}
void GestureRecorder::mouseReleaseEvent(TQMouseEvent *ev)
{
if ((ev->button() == TQMouseEvent::LeftButton) && (_mouseButtonDown))
{
TQPoint pos = ev->pos();
stroke.record(pos.x(), pos.y());
TQString data( stroke.translate());
if( !data.isEmpty())
emit recorded(data);
}
}
void GestureRecorder::mouseMoveEvent(TQMouseEvent *ev)
{
if (_mouseButtonDown)
{
TQPoint pos = ev->pos();
stroke.record(pos.x(), pos.y());
}
}
} // namespace KHotKeys
#include "gesturerecorder.moc"
|