kdeui Library API Documentation

kiconview.h

00001 /* This file is part of the KDE libraries
00002    Copyright (C) 1999 Torben Weis <weis@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 version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, USA.
00017 */
00018 #ifndef KICONVIEW_H
00019 #define KICONVIEW_H
00020 
00021 #include <qcursor.h>
00022 #include <qiconview.h>
00023 
00024 #include <kdelibs_export.h>
00025 
00042 class KDEUI_EXPORT KIconView : public QIconView
00043 {
00044   friend class KIconViewItem;
00045   Q_OBJECT
00046   Q_ENUMS( Mode )
00047   Q_PROPERTY( Mode mode READ mode WRITE setMode )
00048 
00049 public:
00050   KIconView( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
00051 
00052   ~KIconView();
00053 
00062   enum Mode { Execute, Select };
00063 
00073   void setMode( Mode m );
00074 
00078   Mode mode() const;
00079 
00083   virtual void setFont( const QFont & );
00084 
00092   void setIconTextHeight( int n );
00093 
00098   int iconTextHeight() const;
00099 
00100 signals:
00101 
00111   void executed( QIconViewItem *item );
00112 
00123   void executed( QIconViewItem *item, const QPoint &pos );
00124 
00133   void held( QIconViewItem *item );
00134 
00148   void doubleClicked( QIconViewItem *item, const QPoint &pos );
00149 
00150 protected slots:
00151   void slotOnItem( QIconViewItem *item );
00152   void slotOnViewport();
00153   void slotSettingsChanged(int);
00154 
00158   void slotAutoSelect();
00159 
00160 protected:
00161   void emitExecute( QIconViewItem *item, const QPoint &pos );
00162 
00163   virtual void focusOutEvent( QFocusEvent *fe );
00164   virtual void leaveEvent( QEvent *e );
00165   virtual void contentsMousePressEvent( QMouseEvent *e );
00166   virtual void contentsMouseDoubleClickEvent ( QMouseEvent * e );
00167   virtual void contentsMouseReleaseEvent( QMouseEvent *e );
00168   virtual void contentsDragEnterEvent( QDragEnterEvent *e );
00169   virtual void contentsDragMoveEvent( QDragMoveEvent *e );
00170   virtual void contentsDropEvent( QDropEvent* e );
00171   virtual void wheelEvent( QWheelEvent *e );
00172 
00173 private slots:
00174   void slotMouseButtonClicked( int btn, QIconViewItem *item, const QPoint &pos );
00175   void slotDragHoldTimeout();
00176 
00177 private:
00181   QFontMetrics *itemFontMetrics() const;
00185   QPixmap selectedIconPixmap( QPixmap *pix, const QColor &col ) const;
00186 
00187   bool m_bUseSingle;
00188   bool m_bChangeCursorOverItem;
00189 
00190   QIconViewItem* m_pCurrentItem;
00191 
00192   QTimer* m_pAutoSelect;
00193   int m_autoSelectDelay;
00194 
00195 protected:
00196   virtual void virtual_hook( int id, void* data );
00197 private:
00198   class KIconViewPrivate;
00199   KIconViewPrivate *d;
00200 };
00201 
00202 class KWordWrap;
00211 class KDEUI_EXPORT KIconViewItem : public QIconViewItem
00212 {
00213 public:
00214     // Need to redefine all the constructors - I want Java !
00215     KIconViewItem( QIconView *parent )
00216         : QIconViewItem( parent ) { init(); } // We need to call it because the parent ctor won't call our reimplementation :(((
00217     KIconViewItem( QIconView *parent, QIconViewItem *after )
00218         : QIconViewItem( parent, after ) { init(); }
00219     KIconViewItem( QIconView *parent, const QString &text )
00220         : QIconViewItem( parent, text ) { init(); }
00221     KIconViewItem( QIconView *parent, QIconViewItem *after, const QString &text )
00222         : QIconViewItem( parent, after, text ) { init(); }
00223     KIconViewItem( QIconView *parent, const QString &text, const QPixmap &icon )
00224         : QIconViewItem( parent, text, icon ) { init(); }
00225     KIconViewItem( QIconView *parent, QIconViewItem *after, const QString &text, const QPixmap &icon )
00226         : QIconViewItem( parent, after, text, icon ) { init(); }
00227     KIconViewItem( QIconView *parent, const QString &text, const QPicture &picture )
00228         : QIconViewItem( parent, text, picture ) { init(); }
00229     KIconViewItem( QIconView *parent, QIconViewItem *after, const QString &text, const QPicture &picture )
00230         : QIconViewItem( parent, after, text, picture ) { init(); }
00231     virtual ~KIconViewItem();
00232 
00244     void setPixmapSize( const QSize& size );
00245 
00250     QSize pixmapSize() const;
00251 
00252 protected:
00253     void init();
00254     virtual void calcRect( const QString& text_ = QString::null );
00255     virtual void paintItem( QPainter *p, const QColorGroup &c );
00256     KWordWrap *wordWrap();
00257     void paintPixmap( QPainter *p, const QColorGroup &c );
00258     void paintText( QPainter *p, const QColorGroup &c );
00259 
00260 private:
00261     KWordWrap* m_wordWrap;
00262     struct KIconViewItemPrivate;
00263     KIconViewItemPrivate *d;
00264 };
00265 
00266 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:12:00 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003