summaryrefslogtreecommitdiffstats
path: root/noatun/modules/winskin/waTitleBar.cpp
blob: b3b4917cffb0bfe88d66b3114a6305226370a7bd (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
68
69
70
71
72
73
74
75
76
77
78
79
/*
  Titlebar for winamp Skin
  Copyright (C) 1999  Martin Vogt
  Copyright (C) 2001  Ryan Cumming

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation.

  For more information look at the file COPYRIGHT in this package

 */


#include <tqwidget.h>
#include <tqpixmap.h>

#include "waTitleBar.h"
#include "waSkinModel.h"

#include <stdlib.h>

#include <iostream>

WaTitleBar::WaTitleBar() : WaIndicator(_WA_MAPPING_TITLE, _WA_SKIN_TITLE_ACTIVE, _WA_SKIN_TITLE_INACTIVE)
{
    moving = false;
    setState(tqparentWidget()->isActiveWindow());
}

WaTitleBar::~WaTitleBar()
{
}

void WaTitleBar::mousePressEvent(TQMouseEvent * e)
{
    if (e->button() != Qt::RightButton) {
	if (!moving) {
	    moving = true;
	    mDragStart = e->pos();
	    mLastPos = e->globalPos();
	}

        setState(true);
	update();
	return;
    }
    else
        WaWidget::mousePressEvent(e);
}

void WaTitleBar::mouseDoubleClickEvent(TQMouseEvent *) {
    emit(shaded());
}

void WaTitleBar::mouseReleaseEvent(TQMouseEvent * e)
{
    if (e->button() != Qt::RightButton) {
	moving = false;
	update();
	return;
    }
    else
        WaWidget::mouseReleaseEvent(e);
}

void WaTitleBar::mouseMoveEvent(TQMouseEvent * e)
{
    TQPoint diff = e->globalPos() - mLastPos;
    if (abs(diff.x()) > 10 || abs(diff.y()) > 10) {
	// Moving starts only, when passing a drag border
	moving = true;
    }

    if (moving) 
	tqparentWidget()->move(e->globalPos() - mDragStart);
}

#include <waTitleBar.moc>