kwidgetlistbox.h
00001 /* 00002 * Copyright (C) 2005 Petri Damstén <petri.damsten@iki.fi> 00003 * 00004 * This file is part of SuperKaramba. 00005 * 00006 * SuperKaramba is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * SuperKaramba is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with SuperKaramba; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 ****************************************************************************/ 00020 #ifndef KWIDGETLISTBOX_H 00021 #define KWIDGETLISTBOX_H 00022 00023 #include <tqtable.h> 00024 00029 typedef bool (*show_callback) (int index, TQWidget* widget, void* data); 00030 00031 class KWidgetListbox : public TQTable 00032 { 00033 Q_OBJECT 00034 00035 00036 public: 00037 KWidgetListbox(TQWidget *parent = 0, const char *name = 0); 00038 ~KWidgetListbox(); 00039 00040 int insertItem(TQWidget* item, int index = -1); 00041 void setSelected(TQWidget* item); 00042 void setSelected(int index); 00043 void removeItem(TQWidget* item); 00044 void removeItem(int index); 00045 void clear(); 00046 int selected() const; 00047 TQWidget* selectedItem() const; 00048 TQWidget* item(int index) const; 00049 int index(TQWidget* itm) const; 00050 uint count() const { return numRows(); }; 00051 00052 void showItems(show_callback func = 0, void* data = 0); 00053 00054 void paintCell(TQPainter* p, int row, int col, const TQRect& cr, 00055 bool selected, const TQColorGroup& cg); 00056 protected: 00057 void setItemColors(int index, bool even); 00058 void updateColors(); 00059 bool even(int index); 00060 virtual void showEvent(TQShowEvent* e); 00061 00062 protected slots: 00063 void selectionChanged(int row, int col); 00064 00065 signals: 00066 void selected(int index); 00067 }; 00068 00069 #endif