kpushbutton.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2000 Carsten Pfeiffer <pfeiffer@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KPUSHBUTTON_H 00021 #define KPUSHBUTTON_H 00022 00023 #include <tqpoint.h> 00024 #include <tqpushbutton.h> 00025 #include <kguiitem.h> 00026 #include <kstdguiitem.h> 00027 00028 class TQDragObject; 00037 class KDEUI_EXPORT KPushButton : public TQPushButton 00038 { 00039 Q_OBJECT 00040 Q_PROPERTY(int stdItem READ guiItm WRITE setGuiItm ) 00041 Q_PROPERTY(bool isDragEnabled READ isDragEnabled WRITE setDragEnabled) 00042 00043 public: 00044 00048 KPushButton( TQWidget *parent, const char *name=0 ); 00049 00053 KPushButton( const TQString &text, TQWidget *parent, const char *name=0); 00054 00058 KPushButton( const TQIconSet &icon, const TQString &text, 00059 TQWidget *parent, const char *name=0 ); 00060 00065 KPushButton( const KGuiItem &item, TQWidget *parent, const char *name = 0 ); 00066 00070 ~KPushButton(); 00071 00075 void setDragEnabled( bool enable ); 00076 00080 bool isDragEnabled() const { return m_dragEnabled; } 00081 00085 void setGuiItem( const KGuiItem& item ); 00086 00091 void setGuiItem( KStdGuiItem::StdItem item ); 00092 00097 KStdGuiItem::StdItem guiItem() const; 00098 00099 // Hack for Qt designer 00100 void setGuiItm(int itm ) { setGuiItem( (KStdGuiItem::StdItem)itm );} 00101 int guiItm() const { return (int)guiItem(); } 00102 00107 void setIconSet( const TQIconSet &iconSet ); 00108 00112 void setText( const TQString &text ); 00113 00114 protected: 00120 virtual TQDragObject * dragObject(); 00121 00125 virtual void mousePressEvent( TQMouseEvent * ); 00129 virtual void mouseMoveEvent( TQMouseEvent * ); 00130 00134 virtual void startDrag(); 00135 00136 private: 00137 bool m_dragEnabled; 00138 TQPoint startPos; 00139 00140 private slots: 00141 void slotSettingsChanged( int category ); 00142 00143 private: 00148 void init( const KGuiItem &item ); 00149 00150 void readSettings(); 00151 static bool s_useIcons; 00152 00153 protected: 00154 virtual void virtual_hook( int id, void* data ); 00155 private: 00156 class KPushButtonPrivate; 00157 KPushButtonPrivate *d; 00158 00159 }; 00160 00161 #endif // KPUSHBUTTON_H