menubutton.h
00001 /********************************************************************** 00002 ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 00003 ** 00004 ** This file is part of the Qtopia Environment. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 ** 00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00015 ** 00016 ** Contact info@trolltech.com if any conditions of this licensing are 00017 ** not clear to you. 00018 ** 00019 **********************************************************************/ 00020 #ifndef MENUBUTTON_H 00021 #define MENUBUTTON_H 00022 00023 #include <qpushbutton.h> 00024 #include <qstringlist.h> 00025 00026 class MenuButton : public QPushButton { 00027 Q_OBJECT 00028 public: 00029 MenuButton( QWidget* parent, const char* name=0); 00030 MenuButton( const QStringList& items, QWidget* parent, const char* name=0); 00031 00032 void clear(); 00033 00034 00035 int currentItem() const; 00036 QString currentText() const; 00037 00038 void insertItems( const QStringList& items ); 00039 void insertItem( const QIconSet& icon, const QString& text=QString::null ); 00040 void insertItem( const QString& text ); 00041 void insertSeparator(); 00042 00043 void setLabel(const QString& label); 00044 int count(); 00045 void remove(int id); 00046 QString text(int id); 00047 void setUseLabel(bool b); 00048 00049 signals: 00050 void selected(int); 00051 void selected(const QString&); 00052 00053 public slots: 00054 void select(int); 00055 void select(const QString&); 00056 00057 private: 00058 bool useLabel; 00059 void init(); 00060 QStringList txts; 00061 QPopupMenu* pop; 00062 int nitems; 00063 int cur; 00064 QString lab; 00065 void updateLabel(); 00066 }; 00067 00068 #endif 00069
