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

  1. /****************************************************************************
  2. ** $Id:  qt/qmenubar.h   3.0.0   edited Sep 21 17:17 $
  3. **
  4. ** Definition of QMenuBar class
  5. **
  6. ** Created : 941209
  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 QMENUBAR_H
  39. #define QMENUBAR_H
  40.  
  41. #ifndef QT_H
  42. #include "qpopupmenu.h" // ### remove or keep for users' convenience?
  43. #include "qframe.h"
  44. #include "qmenudata.h"
  45. #endif // QT_H
  46.  
  47. #ifndef QT_NO_MENUBAR
  48.  
  49. class QPopupMenu;
  50.  
  51. class Q_EXPORT QMenuBar : public QFrame, public QMenuData
  52. {
  53.     Q_OBJECT
  54.     Q_ENUMS( Separator )
  55.     Q_PROPERTY( Separator separator READ separator WRITE setSeparator DESIGNABLE false )
  56.     Q_PROPERTY( bool defaultUp READ isDefaultUp WRITE setDefaultUp )
  57.     
  58. public:
  59.     QMenuBar( QWidget* parent=0, const char* name=0 );
  60.     ~QMenuBar();
  61.  
  62.     void    updateItem( int id );
  63.  
  64.     void    show();                // reimplemented show
  65.     void    hide();                // reimplemented hide
  66.  
  67.     bool    eventFilter( QObject *, QEvent * );
  68.  
  69.     int        heightForWidth(int) const;
  70.  
  71.     enum    Separator { Never=0, InWindowsStyle=1 };
  72.     Separator     separator() const;
  73.     virtual void    setSeparator( Separator when );
  74.  
  75.     void    setDefaultUp( bool );
  76.     bool    isDefaultUp() const;
  77.  
  78.     bool customWhatsThis() const;
  79.  
  80.     QSize sizeHint() const;
  81.     QSize minimumSize() const;
  82.     QSize minimumSizeHint() const;
  83.  
  84.     void activateItemAt( int index ); // ### virtual in QMenuData 3.0
  85.  
  86. #if defined(Q_WS_MAC) && !defined(QMAC_QMENUBAR_NO_NATIVE)
  87.     static void initialize();
  88.     static void cleanup();
  89. #endif
  90.  
  91. signals:
  92.     void    activated( int itemId );
  93.     void    highlighted( int itemId );
  94.  
  95. protected:
  96.     void    drawContents( QPainter * );
  97.     void    fontChange( const QFont & );
  98.     void    mousePressEvent( QMouseEvent * );
  99.     void    mouseReleaseEvent( QMouseEvent * );
  100.     void    mouseMoveEvent( QMouseEvent * );
  101.     void    keyPressEvent( QKeyEvent * );
  102.     void    focusInEvent( QFocusEvent * );
  103.     void    focusOutEvent( QFocusEvent * );
  104.     void    resizeEvent( QResizeEvent * );
  105.     void    leaveEvent( QEvent * );
  106.     void    menuContentsChanged();
  107.     void    menuStateChanged();
  108.     void     styleChange( QStyle& );
  109.     int        itemAtPos( const QPoint & );
  110.     void    hidePopups();
  111.     QRect    itemRect( int item );
  112.  
  113. private slots:
  114.     void    subActivated( int itemId );
  115.     void    subHighlighted( int itemId );
  116. #ifndef QT_NO_ACCEL
  117.     void    accelActivated( int itemId );
  118.     void    accelDestroyed();
  119. #endif
  120.  
  121. private:
  122.     void    menuInsPopup( QPopupMenu * );
  123.     void    menuDelPopup( QPopupMenu * );
  124.     void    frameChanged();
  125.  
  126.     bool    tryMouseEvent( QPopupMenu *, QMouseEvent * );
  127.     void    tryKeyEvent( QPopupMenu *, QKeyEvent * );
  128.     void    goodbye( bool cancelled = FALSE );
  129.     void    openActPopup();
  130.  
  131.     void setActiveItem( int index, bool show = TRUE, bool activate_first_item = TRUE );
  132.     void setAltMode( bool );
  133.  
  134.     int        calculateRects( int max_width = -1 );
  135.  
  136. #ifndef QT_NO_ACCEL
  137.     void    setupAccelerators();
  138.     QAccel     *autoaccel;
  139. #endif
  140.     QRect      *irects;
  141.     int        rightSide;
  142.  
  143.     uint    mseparator : 1;
  144.     uint    waitforalt : 1;
  145.     uint    popupvisible  : 1;
  146.     uint    hasmouse : 1;
  147.     uint     defaultup : 1;
  148.     uint     toggleclose : 1;
  149.  
  150.     friend class QPopupMenu;
  151.  
  152. #if defined(Q_WS_MAC) && !defined(QMAC_QMENUBAR_NO_NATIVE)
  153.     friend class QWidget;
  154.     friend class QApplication;
  155.  
  156.     void macCreateNativeMenubar();
  157.     void macRemoveNativeMenubar();
  158.     void macDirtyNativeMenubar();
  159.  
  160.     bool syncPopups(MenuRef ret, QPopupMenu *d);
  161.     MenuRef createMacPopup(QPopupMenu *d, bool, bool =FALSE);
  162.     bool updateMenuBar();
  163. #if !defined(QMAC_QMENUBAR_NO_MERGE)
  164.     uint isCommand(QMenuItem *);
  165. #endif
  166.  
  167.     uint mac_eaten_menubar : 1;
  168.     class MacPrivate;
  169.     MacPrivate *mac_d;
  170.     static bool activate(MenuRef, short, bool highlight=FALSE);
  171.     static bool activateCommand(uint cmd);
  172.     static void macUpdateMenuBar();
  173.     static void macUpdatePopup(MenuRef);
  174. #endif
  175.  
  176. private:    // Disabled copy constructor and operator=
  177.  
  178. #if defined(Q_DISABLE_COPY)
  179.     QMenuBar( const QMenuBar & );
  180.     QMenuBar &operator=( const QMenuBar & );
  181. #endif
  182. };
  183.  
  184.  
  185. #endif // QT_NO_MENUBAR
  186.  
  187. #endif // QMENUBAR_H
  188.