home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qpopupmenu.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  5KB  |  187 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qpopupmenu.h   3.0.0   edited Sep 21 17:17 $
  3. **
  4. ** Definition of QPopupMenu class
  5. **
  6. ** Created : 941128
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the widgets module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QPOPUPMENU_H
  39. #define QPOPUPMENU_H
  40.  
  41. #ifndef QT_H
  42. #include "qframe.h"
  43. #include "qmenudata.h"
  44. #endif // QT_H
  45.  
  46. #ifndef QT_NO_POPUPMENU
  47.  
  48.  
  49. class Q_EXPORT QPopupMenu : public QFrame, public QMenuData
  50. {
  51.     Q_OBJECT
  52.     Q_PROPERTY( bool checkable READ isCheckable WRITE setCheckable )
  53. public:
  54.     QPopupMenu( QWidget* parent=0, const char* name=0 );
  55.     ~QPopupMenu();
  56.  
  57.     void    popup( const QPoint & pos, int indexAtPoint = 0 ); // open
  58.     void    updateItem( int id );
  59.  
  60.     virtual void    setCheckable( bool );
  61.     bool    isCheckable() const;
  62.  
  63.     void    setFont( const QFont & );
  64.     void    show();
  65.     void    hide();
  66.  
  67.     int        exec();
  68.     int     exec( const QPoint & pos, int indexAtPoint = 0 ); // modal
  69.  
  70.     virtual void    setActiveItem( int );
  71.     QSize    sizeHint() const;
  72.  
  73.     int     idAt( int index ) const { return QMenuData::idAt( index ); }
  74.     int     idAt( const QPoint& pos ) const;
  75.  
  76.     bool     customWhatsThis() const;
  77.  
  78.     int        insertTearOffHandle( int id=-1, int index=-1 );
  79.  
  80.     void    activateItemAt( int index );
  81.     QRect    itemGeometry( int index );
  82.  
  83.  
  84. signals:
  85.     void    activated( int itemId );
  86.     void    highlighted( int itemId );
  87.     void    activatedRedirect( int itemId ); // to parent menu
  88.     void    highlightedRedirect( int itemId );
  89.     void    aboutToShow();
  90.     void    aboutToHide();
  91.  
  92. protected:
  93.     int     itemHeight( int ) const;
  94.     int     itemHeight( QMenuItem* mi ) const;
  95.     void     drawItem( QPainter* p, int tab, QMenuItem* mi,
  96.            bool act, int x, int y, int w, int h);
  97.  
  98.     void     drawContents( QPainter * );
  99.  
  100.     void     closeEvent( QCloseEvent *e );
  101.     void    paintEvent( QPaintEvent * );
  102.     void    mousePressEvent( QMouseEvent * );
  103.     void    mouseReleaseEvent( QMouseEvent * );
  104.     void    mouseMoveEvent( QMouseEvent * );
  105.     void    keyPressEvent( QKeyEvent * );
  106.     void    focusInEvent( QFocusEvent * );
  107.     void    focusOutEvent( QFocusEvent * );
  108.     void    timerEvent( QTimerEvent * );
  109.     void    leaveEvent( QEvent * );
  110.     void     styleChange( QStyle& );
  111.     int     columns() const;
  112.  
  113.     bool    focusNextPrevChild( bool next );
  114.  
  115.     int        itemAtPos( const QPoint &, bool ignoreSeparator = TRUE ) const;
  116.  
  117. private slots:
  118.     void    subActivated( int itemId );
  119.     void    subHighlighted( int itemId );
  120. #ifndef QT_NO_ACCEL
  121.     void    accelActivated( int itemId );
  122.     void    accelDestroyed();
  123. #endif
  124.     void    modalActivation( int );
  125.  
  126.     void    subMenuTimer();
  127.     void    allowAnimation();
  128.     void     toggleTearOff();
  129.  
  130. private:
  131.     void    menuContentsChanged();
  132.     void    menuStateChanged();
  133.     void    menuInsPopup( QPopupMenu * );
  134.     void    menuDelPopup( QPopupMenu * );
  135.     void    frameChanged();
  136.  
  137.     void    actSig( int, bool = FALSE );
  138.     void    hilitSig( int );
  139.     virtual void setFirstItemActive();
  140.     void    hideAllPopups();
  141.     void    hidePopups();
  142.     bool    tryMenuBar( QMouseEvent * );
  143.     void    byeMenuBar();
  144.  
  145.     void    updateSize();
  146.     void    updateRow( int row );
  147. #ifndef QT_NO_ACCEL
  148.     void    updateAccel( QWidget * );
  149.     void    enableAccel( bool );
  150. #endif
  151.     QMenuItem  *selfItem;
  152. #ifndef QT_NO_ACCEL
  153.     QAccel     *autoaccel;
  154. #endif
  155.  
  156. #if defined(Q_WS_MAC) && !defined(QMAC_QMENUBAR_NO_NATIVE)
  157.     uint mac_dirty_popup : 1;
  158. #endif
  159.  
  160.     int popupActive;
  161.     int tab;
  162.     uint accelDisabled : 1;
  163.     uint checkable : 1;
  164.     uint connectModalRecursionSafety : 1;
  165.     uint tornOff : 1;
  166.     int maxPMWidth;
  167.     int ncols;
  168.     bool    snapToMouse;
  169.     bool    tryMouseEvent( QPopupMenu *, QMouseEvent * );
  170.  
  171.     friend class QMenuData;
  172.     friend class QMenuBar;
  173.  
  174.     void connectModal(QPopupMenu* receiver, bool doConnect);
  175.  
  176. private:    // Disabled copy constructor and operator=
  177. #if defined(Q_DISABLE_COPY)
  178.     QPopupMenu( const QPopupMenu & );
  179.     QPopupMenu &operator=( const QPopupMenu & );
  180. #endif
  181. };
  182.  
  183.  
  184. #endif // QT_NO_POPUPMENU
  185.  
  186. #endif // QPOPUPMENU_H
  187.