| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: qpopupmenu.h 2 2005-11-16 15:49:26Z dmik $
|
|---|
| 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 | class QPopupMenuPrivate;
|
|---|
| 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 = -1 ); // 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 | void enabledChange( bool );
|
|---|
| 112 | int columns() const;
|
|---|
| 113 |
|
|---|
| 114 | bool focusNextPrevChild( bool next );
|
|---|
| 115 |
|
|---|
| 116 | int itemAtPos( const QPoint &, bool ignoreSeparator = TRUE ) const;
|
|---|
| 117 |
|
|---|
| 118 | private slots:
|
|---|
| 119 | void subActivated( int itemId );
|
|---|
| 120 | void subHighlighted( int itemId );
|
|---|
| 121 | #ifndef QT_NO_ACCEL
|
|---|
| 122 | void accelActivated( int itemId );
|
|---|
| 123 | void accelDestroyed();
|
|---|
| 124 | #endif
|
|---|
| 125 | void popupDestroyed( QObject* );
|
|---|
| 126 | void modalActivation( int );
|
|---|
| 127 |
|
|---|
| 128 | void subMenuTimer();
|
|---|
| 129 | void subScrollTimer();
|
|---|
| 130 | void allowAnimation();
|
|---|
| 131 | void toggleTearOff();
|
|---|
| 132 |
|
|---|
| 133 | void performDelayedChanges();
|
|---|
| 134 |
|
|---|
| 135 | private:
|
|---|
| 136 | void updateScrollerState();
|
|---|
| 137 | void menuContentsChanged();
|
|---|
| 138 | void menuStateChanged();
|
|---|
| 139 | void performDelayedContentsChanged();
|
|---|
| 140 | void performDelayedStateChanged();
|
|---|
| 141 | void menuInsPopup( QPopupMenu * );
|
|---|
| 142 | void menuDelPopup( QPopupMenu * );
|
|---|
| 143 | void frameChanged();
|
|---|
| 144 |
|
|---|
| 145 | void actSig( int, bool = FALSE );
|
|---|
| 146 | void hilitSig( int );
|
|---|
| 147 | virtual void setFirstItemActive();
|
|---|
| 148 | void hideAllPopups();
|
|---|
| 149 | void hidePopups();
|
|---|
| 150 | bool tryMenuBar( QMouseEvent * );
|
|---|
| 151 | void byeMenuBar();
|
|---|
| 152 |
|
|---|
| 153 | QSize updateSize(bool force_recalc=FALSE, bool do_resize=TRUE);
|
|---|
| 154 | void updateRow( int row );
|
|---|
| 155 | #ifndef QT_NO_ACCEL
|
|---|
| 156 | void updateAccel( QWidget * );
|
|---|
| 157 | void enableAccel( bool );
|
|---|
| 158 | #endif
|
|---|
| 159 | QPopupMenuPrivate *d;
|
|---|
| 160 | #ifndef QT_NO_ACCEL
|
|---|
| 161 | QAccel *autoaccel;
|
|---|
| 162 | #endif
|
|---|
| 163 |
|
|---|
| 164 | #if defined(Q_WS_MAC) && !defined(QMAC_QMENUBAR_NO_NATIVE)
|
|---|
| 165 | bool macPopupMenu(const QPoint &, int);
|
|---|
| 166 | uint mac_dirty_popup : 1;
|
|---|
| 167 | #endif
|
|---|
| 168 |
|
|---|
| 169 | int popupActive;
|
|---|
| 170 | int tab;
|
|---|
| 171 | uint accelDisabled : 1;
|
|---|
| 172 | uint checkable : 1;
|
|---|
| 173 | uint connectModalRecursionSafety : 1;
|
|---|
| 174 | uint tornOff : 1;
|
|---|
| 175 | uint pendingDelayedContentsChanges : 1;
|
|---|
| 176 | uint pendingDelayedStateChanges : 1;
|
|---|
| 177 | int maxPMWidth;
|
|---|
| 178 | int ncols;
|
|---|
| 179 | bool snapToMouse;
|
|---|
| 180 | bool tryMouseEvent( QPopupMenu *, QMouseEvent * );
|
|---|
| 181 |
|
|---|
| 182 | friend class QMenuData;
|
|---|
| 183 | friend class QMenuBar;
|
|---|
| 184 |
|
|---|
| 185 | void connectModal(QPopupMenu* receiver, bool doConnect);
|
|---|
| 186 |
|
|---|
| 187 | private: // Disabled copy constructor and operator=
|
|---|
| 188 | #if defined(Q_DISABLE_COPY)
|
|---|
| 189 | QPopupMenu( const QPopupMenu & );
|
|---|
| 190 | QPopupMenu &operator=( const QPopupMenu & );
|
|---|
| 191 | #endif
|
|---|
| 192 | };
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 | #endif // QT_NO_POPUPMENU
|
|---|
| 196 |
|
|---|
| 197 | #endif // QPOPUPMENU_H
|
|---|