kdeui Library API Documentation

kpopupmenu.h

00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2000 Daniel M. Duley <mosfet@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 _KPOPUP_H
00019 #define _KPOPUP_H "$Id: kpopupmenu.h,v 1.28 2003/12/02 20:35:07 aseigo Exp $"
00020 
00021 #define INCLUDE_MENUITEM_DEF
00022 
00023 #include <qpopupmenu.h>
00024 #include <kpixmapeffect.h>
00025 #include <kpixmap.h>
00026 #include <kdemacros.h>
00027 
00038 class KPopupTitle : public QWidget
00039 {
00040     Q_OBJECT
00041 
00042 public:
00047     KPopupTitle(QWidget *parent=0, const char *name=0);
00052     KPopupTitle(KPixmapEffect::GradientType gradient, const QColor &color,
00053                 const QColor &textColor, QWidget *parent=0,
00054                 const char *name=0) KDE_DEPRECATED;
00059     KPopupTitle(const KPixmap &background, const QColor &color,
00060                 const QColor &textColor, QWidget *parent=0,
00061                 const char *name=0) KDE_DEPRECATED;
00067     void setTitle(const QString &text, const QPixmap *icon=NULL);
00071     QString title() const { return(titleStr); }
00075     QPixmap icon() const { return(miniicon); }
00076 
00077     QSize sizeHint() const;
00078 
00079 public slots:
00081     void setText( const QString &text );
00083     void setIcon( const QPixmap &pix );
00084 
00085 protected:
00086     void calcSize();
00087     void paintEvent(QPaintEvent *ev);
00088 
00089     // Remove in KDE4
00090     KPixmapEffect::GradientType grType;
00091     QString titleStr;
00092     // Remove in KDE4
00093     KPixmap fill;
00094     QPixmap miniicon;
00095     QColor fgColor, bgColor, grHigh, grLow;
00096     bool useGradient;
00097 
00098 protected:
00099     virtual void virtual_hook( int id, void* data );
00100 private:
00101     class KPopupTitlePrivate;
00102     KPopupTitlePrivate *d;
00103 };
00104 
00122 class KPopupMenu : public QPopupMenu {
00123     Q_OBJECT
00124 public:
00128     KPopupMenu(QWidget *parent=0, const char *name=0);
00129 
00133     ~KPopupMenu();
00134 
00138     int insertTitle(const QString &text, int id=-1, int index=-1);
00142     int insertTitle(const QPixmap &icon, const QString &text, int id=-1,
00143                     int index=-1);
00148     void changeTitle(int id, const QString &text);
00152     void changeTitle(int id, const QPixmap &icon, const QString &text);
00158     QString title(int id=-1) const;
00162     QPixmap titlePixmap(int id) const;
00163 
00178     void setKeyboardShortcutsEnabled(bool enable);
00179 
00185     void setKeyboardShortcutsExecute(bool enable);
00186 
00192     KPopupMenu(const QString &title, QWidget *parent=0, const char *name=0) KDE_DEPRECATED;
00193 
00199     void setTitle(const QString &title) KDE_DEPRECATED;
00200 
00205     QPopupMenu* contextMenu();
00206 
00211     const QPopupMenu* contextMenu() const;
00212 
00217     void hideContextMenu();
00218 
00223     static KPopupMenu* contextMenuFocus();
00224 
00229     static int contextMenuFocusItem();
00230 
00231 signals:
00239     void aboutToShowContextMenu(KPopupMenu* menu, int menuItem, QPopupMenu* ctxMenu);
00240 
00241 protected:
00242     virtual void closeEvent(QCloseEvent *);
00243     virtual void keyPressEvent(QKeyEvent* e);
00244     virtual void mousePressEvent(QMouseEvent* e);
00245     virtual bool focusNextPrevChild( bool next );
00246     virtual void contextMenuEvent(QContextMenuEvent *e);
00247     virtual void hideEvent(QHideEvent*);
00248 
00249     virtual void virtual_hook( int id, void* data );
00250 
00251 protected slots:
00253     QString underlineText(const QString& text, uint length);
00255     void resetKeyboardVars(bool noMatches = false);
00256     void itemHighlighted(int whichItem);
00257     void showCtxMenu(QPoint pos);
00258     void ctxMenuHiding();
00259     void ctxMenuHideShowingMenu();
00260 
00261 private:
00262     class KPopupMenuPrivate;
00263     KPopupMenuPrivate *d;
00264 };
00265 
00266 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Jan 21 09:57:28 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003