kcompletionbox.h
00001 /* This file is part of the KDE libraries 00002 00003 Copyright (c) 2000 Carsten Pfeiffer <pfeiffer@kde.org> 00004 2000 Stefan Schimanski <1Stein@gmx.de> 00005 2000,2001,2002,2003,2004 Dawit Alemayehu <adawit@kde.org> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License (LGPL) as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef KCOMPLETIONBOX_H 00024 #define KCOMPLETIONBOX_H 00025 00026 class TQEvent; 00027 #include <tqstringlist.h> 00028 #include <klistbox.h> 00029 00043 class KDEUI_EXPORT KCompletionBox : public KListBox 00044 { 00045 Q_OBJECT 00046 Q_PROPERTY( bool isTabHandling READ isTabHandling WRITE setTabHandling ) 00047 Q_PROPERTY(TQString cancelledText READ cancelledText WRITE setCancelledText) 00048 Q_PROPERTY( bool activateOnSelect READ activateOnSelect WRITE setActivateOnSelect ) 00049 00050 public: 00057 KCompletionBox( TQWidget *parent, const char *name = 0 ); 00058 00062 ~KCompletionBox(); 00063 00064 virtual TQSize sizeHint() const; 00065 00071 bool activateOnSelect() const; 00072 00073 public slots: 00077 TQStringList items() const; 00078 00084 void insertItems( const TQStringList& items, int index = -1 ); 00085 00089 void setItems( const TQStringList& items ); 00090 00102 virtual void popup(); 00103 00113 void setTabHandling( bool enable ); 00114 00123 bool isTabHandling() const; 00124 00135 void setCancelledText( const TQString& txt); 00136 00140 TQString cancelledText() const; 00141 00149 void setActivateOnSelect(bool state); 00150 00151 00155 void down(); 00156 00160 void up(); 00161 00165 void pageDown(); 00166 00170 void pageUp(); 00171 00175 void home(); 00176 00180 void end(); 00181 00185 virtual void show(); 00186 00190 virtual void hide(); 00191 00192 signals: 00197 void activated( const TQString& ); 00198 00203 void userCancelled( const TQString& ); 00204 00205 protected: 00211 TQRect calculateGeometry() const; 00212 00216 void sizeAndPosition(); 00217 00222 virtual bool eventFilter( TQObject *, TQEvent * ); 00223 00224 protected slots: 00229 virtual void slotActivated( TQListBoxItem * ); 00230 00231 private slots: 00232 void slotSetCurrentItem( TQListBoxItem *i ) { setCurrentItem( i ); } // grrr 00233 void slotCurrentChanged(); 00234 void canceled(); 00235 void slotItemClicked( TQListBoxItem * ); 00236 00237 protected: 00238 virtual void virtual_hook( int id, void* data ); 00239 00240 private: 00241 class KCompletionBoxPrivate; 00242 KCompletionBoxPrivate* const d; 00243 }; 00244 00245 00246 #endif // KCOMPLETIONBOX_H