kdeui
kpopupmenu.h
Go to the documentation of this file. 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., 51 Franklin Street, Fifth Floor,
00016 Boston, MA 02110-1301, USA.
00017 */
00018 #ifndef _KPOPUP_H
00019 #define _KPOPUP_H "$Id: kpopupmenu.h 465272 2005年09月29日 09:47:40Z mueller $"
00020
00021 #define INCLUDE_MENUITEM_DEF
00022
00023 #include <qpopupmenu.h>
00024 #include <kpixmapeffect.h>
00025 #include <kpixmap.h>
00026 #include <kdelibs_export.h>
00038 class KDEUI_EXPORT 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=0);
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
00123 class KDEUI_EXPORT KPopupMenu : public QPopupMenu {
00124 Q_OBJECT
00125 public:
00129 KPopupMenu(QWidget *parent=0, const char *name=0);
00130
00134 ~KPopupMenu();
00135
00139 int insertTitle(const QString &text, int id=-1, int index=-1);
00143 int insertTitle(const QPixmap &icon, const QString &text, int id=-1,
00144 int index=-1);
00149 void changeTitle(int id, const QString &text);
00153 void changeTitle(int id, const QPixmap &icon, const QString &text);
00159 QString title(int id=-1) const;
00163 QPixmap titlePixmap(int id) const;
00164
00179 void setKeyboardShortcutsEnabled(bool enable);
00180
00186 void setKeyboardShortcutsExecute(bool enable);
00187
00193 KPopupMenu(const QString &title, QWidget *parent=0, const char *name=0) KDE_DEPRECATED;
00194
00200 void setTitle(const QString &title) KDE_DEPRECATED;
00201
00206 QPopupMenu* contextMenu();
00207
00212 const QPopupMenu* contextMenu() const;
00213
00218 void hideContextMenu();
00219
00224 static KPopupMenu* contextMenuFocus();
00225
00230 static int contextMenuFocusItem();
00231
00236 virtual void activateItemAt(int index);
00242 Qt::ButtonState state() const;
00243
00244 signals:
00252 void aboutToShowContextMenu(KPopupMenu* menu, int menuItem, QPopupMenu* ctxMenu);
00253
00254 protected:
00255 virtual void closeEvent(QCloseEvent *);
00256 virtual void keyPressEvent(QKeyEvent* e);
00258 virtual void mouseReleaseEvent(QMouseEvent* e);
00259 virtual void mousePressEvent(QMouseEvent* e);
00260 virtual bool focusNextPrevChild( bool next );
00261 virtual void contextMenuEvent(QContextMenuEvent *e);
00262 virtual void hideEvent(QHideEvent*);
00263
00264 virtual void virtual_hook( int id, void* data );
00265
00266 protected slots:
00268 QString underlineText(const QString& text, uint length);
00270 void resetKeyboardVars(bool noMatches = false);
00271 void itemHighlighted(int whichItem);
00272 void showCtxMenu(QPoint pos);
00273 void ctxMenuHiding();
00274 void ctxMenuHideShowingMenu();
00275
00276 private:
00277 class KPopupMenuPrivate;
00278 KPopupMenuPrivate *d;
00279 };
00280
00281 #endif