~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/winskin/waTitleBar.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  standard Button for winamp Skin
 
3
  Copyright (C) 1999  Martin Vogt
 
4
 
 
5
  This program is free software; you can redistribute it and/or modify
 
6
  it under the terms of the GNU General Public License as published by
 
7
  the Free Software Foundation.
 
8
 
 
9
  For more information look at the file COPYRIGHT in this package
 
10
 
 
11
 */
 
12
 
 
13
 
 
14
#include <waTitleBar.h>
 
15
#include <qwidget.h>
 
16
#include <qpixmap.h>
 
17
#include <kstddirs.h>
 
18
#include <kglobal.h>
 
19
 
 
20
WaTitleBar::WaTitleBar(WaSkinModell* waSkinModell,QWidget* parent,char* name):
 
21
QWidget(parent,name){
 
22
        moving = false;
 
23
  this->waSkinModell=waSkinModell;
 
24
  waParent = parent;
 
25
  titlePixmap=new QPixmap();
 
26
  QSize size=sizeHint();
 
27
  titlePixmap->resize(size.width(),size.height());
 
28
  connect(waSkinModell,SIGNAL(event_WA_SKIN_TITLE()),
 
29
          this,SLOT(pixmapChange()));
 
30
  WaSkinDesc* waSkinDesc=
 
31
    waSkinModell->getWaSkinMapDesc(_WA_MAPPING_TITLE);
 
32
  setGeometry((*waSkinDesc->getGeometry()));
 
33
  pixmapChange();
 
34
}
 
35
 
 
36
WaTitleBar::~WaTitleBar() {
 
37
}
 
38
 
 
39
 
 
40
 
 
41
 
 
42
QSize WaTitleBar::sizeHint() const {
 
43
  WaSkinDesc* waSkinDesc=
 
44
    waSkinModell->getWaSkinMapDesc(_WA_MAPPING_TITLE);
 
45
  return QSize(waSkinDesc->getWidgetWidth(),waSkinDesc->getWidgetHeight());
 
46
}
 
47
 
 
48
 
 
49
void WaTitleBar::paintEvent ( QPaintEvent * paintEvent ) {
 
50
        QPainter paint;
 
51
        paint.begin( this );
 
52
        paint.drawPixmap(0,0,*titlePixmap);
 
53
        paint.end();
 
54
}
 
55
 
 
56
void WaTitleBar::pixmapChange() {
 
57
 
 
58
  titlePixmap=waSkinModell->get(_WA_SKIN_TITLE);
 
59
  repaint(false);
 
60
}
 
61
 
 
62
void WaTitleBar::mousePressEvent(QMouseEvent *e)
 
63
{
 
64
        if (e->x() >= 255 && e->x() < 263 && e->y() >= 3 && e->y() < 12)
 
65
        {
 
66
/*              cout << "\nShade Clicked\n";
 
67
                QPainter p;
 
68
                QStringList rd = KGlobal::dirs()->findDirs("data", "noatun/winskin/winamp");
 
69
                QStringList::Iterator it = rd.begin();
 
70
                QString filename = (*it).latin1();
 
71
                filename.append("TITLEBAR.BMP");
 
72
                QPixmap titlebarPixmap(filename, QPixmap::imageFormat(filename));
 
73
                p.begin(this);
 
74
                p.drawPixmap(255,3, titlebarPixmap, 9, 9, 8, 8);
 
75
                p.end();
 
76
*/
 
77
        }
 
78
        if (e->button()!=RightButton)
 
79
        {
 
80
                if (!moving) {
 
81
                        moving=true;
 
82
                        mDragStart = e->pos();
 
83
                        mLastPos = e->globalPos();
 
84
                }
 
85
                return;
 
86
 
 
87
        }
 
88
}
 
89
 
 
90
void WaTitleBar::mouseReleaseEvent(QMouseEvent *e)
 
91
{
 
92
        if (e->button()!=RightButton)
 
93
        {
 
94
                moving = false;
 
95
                return;
 
96
        }
 
97
}
 
98
 
 
99
void WaTitleBar::mouseMoveEvent(QMouseEvent *e)
 
100
{
 
101
    QPoint diff = e->globalPos() - mLastPos;
 
102
    if ( abs(diff.x()) > 10 || abs(diff.y()) > 10) {
 
103
        // Moving starts only, when passing a drag border
 
104
        moving = true;
 
105
    }
 
106
 
 
107
    if ( moving == true ) {
 
108
        waParent->move( e->globalPos() - mDragStart );
 
109
    }
 
110
}