2000-04-10 17:18:21 +00:00
|
|
|
/*
|
2000-07-15 11:27:55 +00:00
|
|
|
RISC OS KWin client
|
2000-04-10 17:18:21 +00:00
|
|
|
|
|
|
|
Copyright 2000
|
|
|
|
Rik Hemsley <rik@kde.org>
|
|
|
|
|
|
|
|
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; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; see the file COPYING. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
#include "StickyButton.h"
|
2000-04-10 17:18:21 +00:00
|
|
|
|
2000-07-15 11:27:55 +00:00
|
|
|
namespace RiscOS
|
2000-04-10 17:18:21 +00:00
|
|
|
{
|
|
|
|
|
2000-09-27 22:51:57 +00:00
|
|
|
/* XPM */
|
|
|
|
static const char * const unsticky_xpm[] = {
|
|
|
|
"12 12 3 1",
|
|
|
|
" c None",
|
|
|
|
". c #000000",
|
|
|
|
"+ c #FFFFFF",
|
|
|
|
" ... ",
|
2000-10-01 15:30:04 +00:00
|
|
|
" .+++. ",
|
|
|
|
" .+++. ",
|
|
|
|
" .+++. ",
|
|
|
|
" .+++. ",
|
|
|
|
" .+++++. ",
|
|
|
|
" .+++++++. ",
|
|
|
|
".+++++++++. ",
|
|
|
|
".....+..... ",
|
|
|
|
" .+. ",
|
|
|
|
" .+. ",
|
2000-10-02 03:07:38 +00:00
|
|
|
" . "};
|
2000-09-27 22:51:57 +00:00
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
/* XPM */
|
|
|
|
static const char * const sticky_xpm[] = {
|
|
|
|
"12 12 3 1",
|
|
|
|
" c None",
|
|
|
|
". c #000000",
|
|
|
|
"+ c #FFFFFF",
|
|
|
|
" . ",
|
2000-10-01 15:30:04 +00:00
|
|
|
" .+. ",
|
|
|
|
" .+++. ",
|
|
|
|
" .+++++.",
|
|
|
|
" ....+++++. ",
|
|
|
|
" .++++++. ",
|
|
|
|
" .++++. ",
|
|
|
|
" .+++. ",
|
|
|
|
" .+..+. ",
|
|
|
|
" .+. .. ",
|
|
|
|
".+. . ",
|
|
|
|
".. "};
|
2000-04-10 17:18:21 +00:00
|
|
|
|
2000-09-27 22:51:57 +00:00
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
StickyButton::StickyButton(QWidget * parent)
|
|
|
|
: Button(parent),
|
|
|
|
on_(false)
|
2000-04-10 17:18:21 +00:00
|
|
|
{
|
2000-09-27 21:33:15 +00:00
|
|
|
setPixmap(QPixmap((const char **)sticky_xpm));
|
2000-10-11 17:21:49 +00:00
|
|
|
connect(this, SIGNAL(setSticky(bool)), parent, SLOT(slotSetSticky(bool)));
|
|
|
|
connect(parent, SIGNAL(stickyChanged(bool)), this, SLOT(setOn(bool)));
|
2000-04-10 17:18:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-09-27 21:33:15 +00:00
|
|
|
StickyButton::setOn(bool on)
|
2000-04-10 17:18:21 +00:00
|
|
|
{
|
2000-09-27 21:33:15 +00:00
|
|
|
on_ = on;
|
2000-09-27 22:51:57 +00:00
|
|
|
setPixmap(
|
|
|
|
on_ ?
|
|
|
|
QPixmap((const char **)unsticky_xpm) :
|
|
|
|
QPixmap((const char **)sticky_xpm)
|
|
|
|
);
|
2000-09-27 21:33:15 +00:00
|
|
|
repaint();
|
2000-04-10 17:18:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-09-27 21:33:15 +00:00
|
|
|
StickyButton::mouseReleaseEvent(QMouseEvent * e)
|
2000-04-10 17:18:21 +00:00
|
|
|
{
|
2000-09-27 21:33:15 +00:00
|
|
|
Button::mouseReleaseEvent(e);
|
2000-04-10 17:18:21 +00:00
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
if (!rect().contains(e->pos()))
|
|
|
|
return;
|
2000-04-10 17:18:21 +00:00
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
switch (e->button())
|
|
|
|
{
|
|
|
|
default:
|
2000-10-11 17:21:49 +00:00
|
|
|
emit(setSticky(!on_));
|
2000-09-27 21:33:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-04-10 17:18:21 +00:00
|
|
|
}
|
|
|
|
} // End namespace
|
|
|
|
|
|
|
|
// vim:ts=2:sw=2:tw=78
|
2000-09-27 21:33:15 +00:00
|
|
|
#include "StickyButton.moc"
|