diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch) | |
tree | 9047cf9e6b5c43878d5bf82660adae77ceee097a /noatun/modules/winskin/waButton.cpp | |
download | tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'noatun/modules/winskin/waButton.cpp')
-rw-r--r-- | noatun/modules/winskin/waButton.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/noatun/modules/winskin/waButton.cpp b/noatun/modules/winskin/waButton.cpp new file mode 100644 index 00000000..cac0275a --- /dev/null +++ b/noatun/modules/winskin/waButton.cpp @@ -0,0 +1,101 @@ +/* + standard Button fo winamp Skin + Copyright (C) 1999 Martin Vogt + + 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 <qbitmap.h> + +#include "waButton.h" + +WaButton::WaButton(int mapId) : WaWidget(mapId) +{ + _togglable = false; + _toggled = false; + pressed = false; +} + + +WaButton::~WaButton() { +} + +void WaButton::setPixmapUp(int pixId) { + nUpId=pixId; +} + + +void WaButton::setPixmapDown(int pixId) { + nDownId=pixId; +} + + +void WaButton::setPixmapUpSelected(int pixId) { + nUpIdSelected=pixId; +} + + +void WaButton::setPixmapDownSelected(int pixId) { + nDownIdSelected=pixId; +} + +void WaButton::paintEvent(QPaintEvent *) { + paintPixmap(getPixmapId()); +} + + +void WaButton::mousePressEvent(QMouseEvent* e) { + if (e->button() != LeftButton) { + // We can't deal with it, but maybe the widget can do something clever + WaWidget::mousePressEvent(e); + } + else { + pressed = true; + update(); + } +} + +void WaButton::mouseReleaseEvent(QMouseEvent* e) { + if (!pressed) { + // We're not pressed, so just pass along the mouse event, it's not ours + WaWidget::mouseReleaseEvent(e); + } + else { + pressed = false; + + if (this->rect().contains(e->pos())){ + if (_togglable) { + _toggled = !_toggled; + emit(toggleEvent(_toggled)); + } + + emit(clicked()); + } + } + + update(); +} + +int WaButton::getPixmapId() { + if (_toggled == true) { + if (pressed) + return nDownIdSelected; + else + return nUpIdSelected; + } + else { + if (pressed) + return nDownId; + else + return nUpId; + } + + return -1; +} + +#include "waButton.moc" |