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., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 #ifndef _KPOPUP_H 00019 #define _KPOPUP_H "$Id$" 00020 00021 #define INCLUDE_MENUITEM_DEF 00022 00023 #include <tqpopupmenu.h> 00024 #include <kpixmapeffect.h> 00025 #include <kpixmap.h> 00026 #include <kdelibs_export.h> 00038 class KDEUI_EXPORT KPopupTitle : public TQWidget 00039 { 00040 Q_OBJECT 00041 00042 public: 00047 KPopupTitle(TQWidget *parent=0, const char *name=0); 00052 KPopupTitle(KPixmapEffect::GradientType gradient, const TQColor &color, 00053 const TQColor &textColor, TQWidget *parent=0, 00054 const char *name=0) KDE_DEPRECATED; 00059 KPopupTitle(const KPixmap &background, const TQColor &color, 00060 const TQColor &textColor, TQWidget *parent=0, 00061 const char *name=0) KDE_DEPRECATED; 00067 void setTitle(const TQString &text, const TQPixmap *icon=0); 00071 TQString title() const { return titleStr; } 00075 TQPixmap icon() const { return miniicon; } 00076 00077 TQSize sizeHint() const; 00078 00079 public slots: 00081 void setText( const TQString &text ); 00083 void setIcon( const TQPixmap &pix ); 00084 00085 protected: 00086 void calcSize(); 00087 void paintEvent(TQPaintEvent *ev); 00088 00089 // Remove in KDE4 00090 KPixmapEffect::GradientType grType; 00091 TQString titleStr; 00092 // Remove in KDE4 00093 KPixmap fill; 00094 TQPixmap miniicon; 00095 TQColor 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 TQPopupMenu { 00124 Q_OBJECT 00125 TQ_OBJECT 00126 public: 00130 KPopupMenu(TQWidget *parent=0, const char *name=0); 00131 00135 ~KPopupMenu(); 00136 00140 int insertTitle(const TQString &text, int id=-1, int index=-1); 00144 int insertTitle(const TQPixmap &icon, const TQString &text, int id=-1, 00145 int index=-1); 00150 void changeTitle(int id, const TQString &text); 00154 void changeTitle(int id, const TQPixmap &icon, const TQString &text); 00160 TQString title(int id=-1) const; 00164 TQPixmap titlePixmap(int id) const; 00165 00180 void setKeyboardShortcutsEnabled(bool enable); 00181 00187 void setKeyboardShortcutsExecute(bool enable); 00188 00194 KPopupMenu(const TQString &title, TQWidget *parent=0, const char *name=0) KDE_DEPRECATED; 00195 00201 void setTitle(const TQString &title) KDE_DEPRECATED; 00202 00207 TQPopupMenu* contextMenu(); 00208 00213 const TQPopupMenu* contextMenu() const; 00214 00219 void hideContextMenu(); 00220 00225 static KPopupMenu* contextMenuFocus(); 00226 00231 static int contextMenuFocusItem(); 00232 00237 virtual void activateItemAt(int index); 00243 TQt::ButtonState state() const; 00244 00245 signals: 00253 void aboutToShowContextMenu(KPopupMenu* menu, int menuItem, TQPopupMenu* ctxMenu); 00254 00255 protected: 00256 virtual void closeEvent(TQCloseEvent *); 00257 virtual void keyPressEvent(TQKeyEvent* e); 00259 virtual void mouseReleaseEvent(TQMouseEvent* e); 00260 virtual void mousePressEvent(TQMouseEvent* e); 00261 virtual bool focusNextPrevChild( bool next ); 00262 virtual void contextMenuEvent(TQContextMenuEvent *e); 00263 virtual void hideEvent(TQHideEvent*); 00264 00265 virtual void virtual_hook( int id, void* data ); 00266 00267 protected slots: 00269 TQString underlineText(const TQString& text, uint length); 00271 void resetKeyboardVars(bool noMatches = false); 00272 void itemHighlighted(int whichItem); 00273 void showCtxMenu(TQPoint pos); 00274 void ctxMenuHiding(); 00275 void ctxMenuHideShowingMenu(); 00276 00277 private: 00278 class KPopupMenuPrivate; 00279 KPopupMenuPrivate *d; 00280 }; 00281 00282 #endif