summaryrefslogtreecommitdiffstats
path: root/src/DragWidget.cpp
blob: d6e495c1cd76e92ef51912d4d321595e929d0b65 (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
#include "DragWidget.h"

DragWidget::DragWidget(TQWidget *parent, const char *name, WFlags f) : TQWidget(parent,name,f)
{
	dragP=TQPoint(0,0);
	drag=false;
	locked=false;
}

DragWidget::~DragWidget()
{
}

void DragWidget::mousePressEvent(TQMouseEvent *e)
{
	dragP=e->pos();
	gpress=e->globalPos();
	if (locked)
	{
		return;
	}
	drag=true;
}

void DragWidget::mouseReleaseEvent(TQMouseEvent *)
{
	drag=false;
}

void DragWidget::mouseMoveEvent(TQMouseEvent *e)
{
	if (!drag)
	{
		return;
	}
	TQPoint curr(e->globalPos().x()-dragP.x(),e->globalPos().y()-dragP.y());
	TQWidget::move(curr);
}

void DragWidget::setLocked(bool mode)
{
	locked=mode;
}

const bool DragWidget::isLocked() const
{
	return locked;
}

#include "DragWidget.moc"