/*************************************************************************** * Copyright (C) 2005 by Teppei Tamra * * TAM(tam-t@par.odn.ne.jp) * * * * 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; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef KEYBUTTON_H #define KEYBUTTON_H #include <qpushbutton.h> #include <qdom.h> #include <qstringlist.h> #include <qvaluelist.h> #include <qcolor.h> #include <qtimer.h> /** @author Teppei Tamra */ class KeyButton; class KeyGroup { public: friend class KeyButton; KeyGroup(); KeyGroup(const QString &_name,const QString &_label,const QString &_event,const QString &_modifier); ~KeyGroup(); void setValue(const QString &_name,const QString &_label,const QString &_event,const QString &_modifier); void setValue(const KeyGroup &g) { setValue(g.name,g.label,g.event,g.modifier); }; protected: QString name; QString label; QString event; QString modifier; }; typedef QValueList<KeyGroup> KeyGroupList; class KeyButton : public QPushButton { Q_OBJECT public: KeyButton(QWidget *parent, unsigned int pos_x,unsigned int pos_y, unsigned int width = 2, unsigned int height = 2,const QColor &keycolor = QColor("white"), bool toggled = false, const char *name = 0); ~KeyButton(); int getX(); int getY(); int getH(); int getW(); QDomElement getElement(QDomDocument &doc); void appendGroup(KeyGroup group); void updateLabel(); void changeGroup(const QString &name); public: static int buttonSize; protected: QTimer *timer; KeyGroupList list; KeyGroup current; QColor color; bool holded; int h; int w; int x; int y; signals: void pressed(const QString &event,const QString &modifier); void released(const QString &event,const QString &modifier); protected slots: void keyPressed(); void keyReleased(); void keyToggled(bool s); void hold(); }; #endif