Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/qmenubar.h 3.3.8 edited Jan 16 10:55 $ 00003 ** 00004 ** Definition of QMenuBar class 00005 ** 00006 ** Created : 941209 00007 ** 00008 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 00009 ** 00010 ** This file is part of the widgets module of the Qt GUI Toolkit. 00011 ** 00012 ** This file may be distributed under the terms of the Q Public License 00013 ** as defined by Trolltech ASA of Norway and appearing in the file 00014 ** LICENSE.QPL included in the packaging of this file. 00015 ** 00016 ** This file may be distributed and/or modified under the terms of the 00017 ** GNU General Public License version 2 as published by the Free Software 00018 ** Foundation and appearing in the file LICENSE.GPL included in the 00019 ** packaging of this file. 00020 ** 00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00022 ** licenses may use this file in accordance with the Qt Commercial License 00023 ** Agreement provided with the Software. 00024 ** 00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00027 ** 00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00029 ** information about Qt Commercial License Agreements. 00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00032 ** 00033 ** Contact info@trolltech.com if any conditions of this licensing are 00034 ** not clear to you. 00035 ** 00036 **********************************************************************/ 00037 00038 #ifndef QMENUBAR_H 00039 #define QMENUBAR_H 00040 00041 #ifndef QT_H 00042 #include "qpopupmenu.h" // ### remove or keep for users' convenience? 00043 #include "qframe.h" 00044 #include "qmenudata.h" 00045 #endif // QT_H 00046 00047 #ifndef QT_NO_MENUBAR 00048 00049 class QPopupMenu; 00050 00051 class Q_EXPORT QMenuBar : public QFrame, public QMenuData 00052 { 00053 Q_OBJECT 00054 Q_ENUMS( Separator ) 00055 Q_PROPERTY( Separator separator READ separator WRITE setSeparator DESIGNABLE false ) 00056 Q_PROPERTY( bool defaultUp READ isDefaultUp WRITE setDefaultUp ) 00057 00058 public: 00059 QMenuBar( QWidget* parent=0, const char* name=0 ); 00060 ~QMenuBar(); 00061 00062 void updateItem( int id ); 00063 00064 void show(); // reimplemented show 00065 void hide(); // reimplemented hide 00066 00067 bool eventFilter( QObject *, QEvent * ); 00068 00069 int heightForWidth(int) const; 00070 00071 enum Separator { Never=0, InWindowsStyle=1 }; 00072 Separator separator() const; 00073 virtual void setSeparator( Separator when ); 00074 00075 void setDefaultUp( bool ); 00076 bool isDefaultUp() const; 00077 00078 bool customWhatsThis() const; 00079 00080 QSize sizeHint() const; 00081 QSize minimumSize() const; 00082 QSize minimumSizeHint() const; 00083 00084 void activateItemAt( int index ); 00085 00086 #if defined(Q_WS_MAC) && !defined(QMAC_QMENUBAR_NO_NATIVE) 00087 static void initialize(); 00088 static void cleanup(); 00089 #endif 00090 00091 signals: 00092 void activated( int itemId ); 00093 void highlighted( int itemId ); 00094 00095 protected: 00096 void drawContents( QPainter * ); 00097 void fontChange( const QFont & ); 00098 void mousePressEvent( QMouseEvent * ); 00099 void mouseReleaseEvent( QMouseEvent * ); 00100 void mouseMoveEvent( QMouseEvent * ); 00101 void keyPressEvent( QKeyEvent * ); 00102 void focusInEvent( QFocusEvent * ); 00103 void focusOutEvent( QFocusEvent * ); 00104 void resizeEvent( QResizeEvent * ); 00105 void leaveEvent( QEvent * ); 00106 void menuContentsChanged(); 00107 void menuStateChanged(); 00108 void styleChange( QStyle& ); 00109 int itemAtPos( const QPoint & ); 00110 void hidePopups(); 00111 QRect itemRect( int item ); 00112 00113 private slots: 00114 void subActivated( int itemId ); 00115 void subHighlighted( int itemId ); 00116 #ifndef QT_NO_ACCEL 00117 void accelActivated( int itemId ); 00118 void accelDestroyed(); 00119 #endif 00120 void popupDestroyed( QObject* ); 00121 void performDelayedChanges(); 00122 00123 void languageChange(); 00124 00125 private: 00126 void performDelayedContentsChanged(); 00127 void performDelayedStateChanged(); 00128 void menuInsPopup( QPopupMenu * ); 00129 void menuDelPopup( QPopupMenu * ); 00130 void frameChanged(); 00131 00132 bool tryMouseEvent( QPopupMenu *, QMouseEvent * ); 00133 void tryKeyEvent( QPopupMenu *, QKeyEvent * ); 00134 void goodbye( bool cancelled = FALSE ); 00135 void openActPopup(); 00136 00137 void setActiveItem( int index, bool show = TRUE, bool activate_first_item = TRUE ); 00138 void setAltMode( bool ); 00139 00140 int calculateRects( int max_width = -1 ); 00141 00142 #ifndef QT_NO_ACCEL 00143 void setupAccelerators(); 00144 QAccel *autoaccel; 00145 #endif 00146 QRect *irects; 00147 int rightSide; 00148 00149 uint mseparator : 1; 00150 uint waitforalt : 1; 00151 uint popupvisible : 1; 00152 uint hasmouse : 1; 00153 uint defaultup : 1; 00154 uint toggleclose : 1; 00155 uint pendingDelayedContentsChanges : 1; 00156 uint pendingDelayedStateChanges : 1; 00157 00158 friend class QPopupMenu; 00159 00160 #if defined(Q_WS_MAC) && !defined(QMAC_QMENUBAR_NO_NATIVE) 00161 friend class QWidget; 00162 friend class QApplication; 00163 friend void qt_mac_set_modal_state(bool, QMenuBar *); 00164 00165 void macCreateNativeMenubar(); 00166 void macRemoveNativeMenubar(); 00167 void macDirtyNativeMenubar(); 00168 00169 #if !defined(QMAC_QMENUBAR_NO_EVENT) 00170 static void qt_mac_install_menubar_event(MenuRef); 00171 static OSStatus qt_mac_menubar_event(EventHandlerCallRef, EventRef, void *); 00172 #endif 00173 virtual void macWidgetChangedWindow(); 00174 bool syncPopups(MenuRef ret, QPopupMenu *d); 00175 MenuRef createMacPopup(QPopupMenu *d, int id, bool =FALSE); 00176 bool updateMenuBar(); 00177 #if !defined(QMAC_QMENUBAR_NO_MERGE) 00178 uint isCommand(QMenuItem *, bool just_check=FALSE); 00179 #endif 00180 00181 uint mac_eaten_menubar : 1; 00182 class MacPrivate; 00183 MacPrivate *mac_d; 00184 static bool activate(MenuRef, short, bool highlight=FALSE, bool by_accel=FALSE); 00185 static bool activateCommand(uint cmd); 00186 static bool macUpdateMenuBar(); 00187 static bool macUpdatePopupVisible(MenuRef, bool); 00188 static bool macUpdatePopup(MenuRef); 00189 #endif 00190 00191 private: // Disabled copy constructor and operator= 00192 00193 #if defined(Q_DISABLE_COPY) 00194 QMenuBar( const QMenuBar & ); 00195 QMenuBar &operator=( const QMenuBar & ); 00196 #endif 00197 }; 00198 00199 00200 #endif // QT_NO_MENUBAR 00201 00202 #endif // QMENUBAR_H