00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _OPOPUP_H
00022 #define _OPOPUP_H
00023
00024 #define INCLUDE_MENUITEM_DEF
00025
00026
00027
00028 #include <qpopupmenu.h>
00029
00030
00031
00032 #include <opie2/opixmapeffect.h>
00033
00034 namespace Opie {
00035 namespace Ui {
00046 class OPopupTitle : public QWidget
00047 {
00048 Q_OBJECT
00049
00050 public:
00055 OPopupTitle(QWidget *parent=0, const char *name=0);
00060 OPopupTitle(OPixmapEffect::GradientType gradient, const QColor &color,
00061 const QColor &textColor, QWidget *parent=0,
00062 const char *name=0);
00067 OPopupTitle(const OPixmap &background, const QColor &color,
00068 const QColor &textColor, QWidget *parent=0,
00069 const char *name=0);
00075 void setTitle(const QString &text, const QPixmap *icon=NULL);
00079 QString title() const { return(titleStr); }
00083 QPixmap icon() const { return(miniicon); }
00084
00085 QSize sizeHint() const;
00086
00087 public slots:
00089 void setText( const QString &text );
00091 void setIcon( const QPixmap &pix );
00092
00093 protected:
00094 void paintEvent(QPaintEvent *ev);
00095
00096 QString titleStr;
00097 QPixmap miniicon;
00098
00099
00100 OPixmapEffect::GradientType grType;
00101 QPixmap fill;
00102 QColor fgColor, bgColor, grHigh, grLow;
00103 bool useGradient;
00104
00105 protected:
00106 virtual void virtual_hook( int id, void* data );
00107 private:
00108 class OPopupTitlePrivate;
00109 OPopupTitlePrivate *d;
00110 };
00111
00129 class OPopupMenu : public QPopupMenu {
00130 Q_OBJECT
00131 public:
00135 OPopupMenu(QWidget *parent=0, const char *name=0);
00136
00140 ~OPopupMenu();
00141
00145 int insertTitle(const QString &text, int id=-1, int index=-1);
00149 int insertTitle(const QPixmap &icon, const QString &text, int id=-1,
00150 int index=-1);
00155 void changeTitle(int id, const QString &text);
00159 void changeTitle(int id, const QPixmap &icon, const QString &text);
00165 QString title(int id=-1) const;
00169 QPixmap titlePixmap(int id) const;
00170
00185 void setKeyboardShortcutsEnabled(bool enable);
00186
00192 void setKeyboardShortcutsExecute(bool enable);
00193
00198 OPopupMenu(const QString &title, QWidget *parent=0, const char *name=0);
00203 void setTitle(const QString &title);
00204
00209 QPopupMenu* contextMenu();
00210
00215 void cancelContextMenuShow();
00216
00221 static OPopupMenu* contextMenuFocus();
00222
00227 static int contextMenuFocusItem();
00228
00229 signals:
00237 void aboutToShowContextMenu(Opie::Ui::OPopupMenu* menu, int menuItem, QPopupMenu* ctxMenu);
00238
00239 protected:
00240 virtual void closeEvent(QCloseEvent *);
00241 virtual void keyPressEvent(QKeyEvent* e);
00242 virtual bool eventFilter(QObject* obj, QEvent* event);
00243 virtual void hideEvent(QHideEvent*);
00244
00245 virtual void virtual_hook( int id, void* data );
00246
00247 protected slots:
00249 QString underlineText(const QString& text, uint length);
00251 void resetKeyboardVars(bool noMatches = false);
00252 void itemHighlighted(int whichItem);
00253 void showCtxMenu(QPoint pos);
00254 void ctxMenuHiding();
00255
00256 private:
00257 class OPopupMenuPrivate;
00258 OPopupMenuPrivate *d;
00259 };
00260
00261 }
00262 }
00263
00264 #endif