Eneboo - Documentación para desarrolladores
src/qt/include/qmenudata.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qmenudata.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of QMenuData class
00005 **
00006 ** Created : 941128
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 QMENUDATA_H
00039 #define QMENUDATA_H
00040 
00041 #ifndef QT_H
00042 #include "qglobal.h"
00043 #include "qiconset.h" // conversion QPixmap->QIconset
00044 #include "qkeysequence.h"
00045 #include "qstring.h"
00046 #include "qsignal.h"
00047 #include "qfont.h"
00048 #endif // QT_H
00049 
00050 #ifndef QT_NO_MENUDATA
00051 
00052 class QPopupMenu;
00053 class QMenuDataData;
00054 class QObject;
00055 
00056 class QCustomMenuItem;
00057 class QMenuItemData;
00058 
00059 class Q_EXPORT QMenuItem                        // internal menu item class
00060 {
00061 friend class QMenuData;
00062 public:
00063     QMenuItem();
00064    ~QMenuItem();
00065 
00066     int         id()            const   { return ident; }
00067     QIconSet   *iconSet()       const   { return iconset_data; }
00068     QString     text()          const   { return text_data; }
00069     QString     whatsThis()     const   { return whatsthis_data; }
00070     QPixmap    *pixmap()        const   { return pixmap_data; }
00071     QPopupMenu *popup()         const   { return popup_menu; }
00072     QWidget *widget()           const   { return widget_item; }
00073     QCustomMenuItem *custom()   const;
00074 #ifndef QT_NO_ACCEL
00075     QKeySequence key()          const   { return accel_key; }
00076 #endif
00077     QSignal    *signal()        const   { return signal_data; }
00078     bool        isSeparator()   const   { return is_separator; }
00079     bool        isEnabled()     const   { return is_enabled; }
00080     bool        isChecked()     const   { return is_checked; }
00081     bool        isDirty()       const   { return is_dirty; }
00082     bool        isVisible()     const   { return is_visible; }
00083     bool        isEnabledAndVisible() const { return is_enabled && is_visible; }
00084 
00085     void        setText( const QString &text ) { text_data = text; }
00086     void        setDirty( bool dirty )         { is_dirty = dirty; }
00087     void        setVisible( bool visible )             { is_visible = visible; }
00088     void        setWhatsThis( const QString &text ) { whatsthis_data = text; }
00089 
00090 private:
00091     int         ident;                          // item identifier
00092     QIconSet   *iconset_data;                   // icons
00093     QString     text_data;                      // item text
00094     QString     whatsthis_data;                 // item Whats This help text
00095     QPixmap    *pixmap_data;                    // item pixmap
00096     QPopupMenu *popup_menu;                     // item popup menu
00097     QWidget    *widget_item;                    // widget menu item
00098 #ifndef QT_NO_ACCEL
00099     QKeySequence        accel_key;              // accelerator key (state|ascii)
00100 #endif
00101     QSignal    *signal_data;                    // connection
00102     uint        is_separator : 1;               // separator flag
00103     uint        is_enabled   : 1;               // disabled flag
00104     uint        is_checked   : 1;               // checked flag
00105     uint        is_dirty     : 1;               // dirty (update) flag
00106     uint        is_visible     : 1;             // visibility flag
00107     QMenuItemData* d;
00108 
00109     QMenuItemData* extra();
00110 
00111 private:        // Disabled copy constructor and operator=
00112 #if defined(Q_DISABLE_COPY)
00113     QMenuItem( const QMenuItem & );
00114     QMenuItem &operator=( const QMenuItem & );
00115 #endif
00116 };
00117 
00118 #include "qptrlist.h"
00119 typedef QPtrList<QMenuItem>      QMenuItemList;
00120 typedef QPtrListIterator<QMenuItem> QMenuItemListIt;
00121 
00122 
00123 class Q_EXPORT QCustomMenuItem : public Qt
00124 {
00125 public:
00126     QCustomMenuItem();
00127     virtual ~QCustomMenuItem();
00128     virtual bool fullSpan() const;
00129     virtual bool isSeparator() const;
00130     virtual void setFont( const QFont& font );
00131     virtual void paint( QPainter* p, const QColorGroup& cg, bool act,
00132                         bool enabled, int x, int y, int w, int h ) = 0;
00133     virtual QSize sizeHint() = 0;
00134 };
00135 
00136 
00137 class Q_EXPORT QMenuData                        // menu data class
00138 {
00139 friend class QMenuBar;
00140 friend class QPopupMenu;
00141 public:
00142     QMenuData();
00143     virtual ~QMenuData();
00144 
00145     uint        count() const;
00146 
00147 
00148     int         insertItem( const QString &text,
00149                             const QObject *receiver, const char* member,
00150                             const QKeySequence& accel = 0, int id = -1, int index = -1 );
00151     int         insertItem( const QIconSet& icon,
00152                             const QString &text,
00153                             const QObject *receiver, const char* member,
00154                             const QKeySequence& accel = 0, int id = -1, int index = -1 );
00155     int         insertItem( const QPixmap &pixmap,
00156                             const QObject *receiver, const char* member,
00157                             const QKeySequence& accel = 0, int id = -1, int index = -1 );
00158     int         insertItem( const QIconSet& icon,
00159                             const QPixmap &pixmap,
00160                             const QObject *receiver, const char* member,
00161                             const QKeySequence& accel = 0, int id = -1, int index = -1 );
00162 
00163     int         insertItem( const QString &text, int id=-1, int index=-1 );
00164     int         insertItem( const QIconSet& icon,
00165                             const QString &text, int id=-1, int index=-1 );
00166 
00167     int         insertItem( const QString &text, QPopupMenu *popup,
00168                             int id=-1, int index=-1 );
00169     int         insertItem( const QIconSet& icon,
00170                             const QString &text, QPopupMenu *popup,
00171                             int id=-1, int index=-1 );
00172 
00173 
00174     int         insertItem( const QPixmap &pixmap, int id=-1, int index=-1 );
00175     int         insertItem( const QIconSet& icon,
00176                             const QPixmap &pixmap, int id=-1, int index=-1 );
00177     int         insertItem( const QPixmap &pixmap, QPopupMenu *popup,
00178                             int id=-1, int index=-1 );
00179     int         insertItem( const QIconSet& icon,
00180                             const QPixmap &pixmap, QPopupMenu *popup,
00181                             int id=-1, int index=-1 );
00182 
00183     int         insertItem( QWidget* widget, int id=-1, int index=-1 );
00184 
00185     int         insertItem( const QIconSet& icon, QCustomMenuItem* custom, int id=-1, int index=-1 );
00186     int         insertItem( QCustomMenuItem* custom, int id=-1, int index=-1 );
00187 
00188 
00189     int         insertSeparator( int index=-1 );
00190 
00191     void        removeItem( int id );
00192     void        removeItemAt( int index );
00193     void        clear();
00194 
00195 #ifndef QT_NO_ACCEL
00196     QKeySequence accel( int id )        const;
00197     void        setAccel( const QKeySequence& key, int id );
00198 #endif
00199 
00200     QIconSet    *iconSet( int id )      const;
00201     QString text( int id )              const;
00202     QPixmap    *pixmap( int id )        const;
00203 
00204     void setWhatsThis( int id, const QString& );
00205     QString whatsThis( int id ) const;
00206 
00207 
00208     void        changeItem( int id, const QString &text );
00209     void        changeItem( int id, const QPixmap &pixmap );
00210     void        changeItem( int id, const QIconSet &icon, const QString &text );
00211     void        changeItem( int id, const QIconSet &icon, const QPixmap &pixmap );
00212 
00213     void        changeItem( const QString &text, int id ) { changeItem( id, text); } // obsolete
00214     void        changeItem( const QPixmap &pixmap, int id ) { changeItem( id, pixmap ); } // obsolete
00215     void        changeItem( const QIconSet &icon, const QString &text, int id ) {       // obsolete
00216         changeItem( id, icon, text );
00217     }
00218 
00219     bool        isItemActive( int id ) const;
00220 
00221     bool        isItemEnabled( int id ) const;
00222     void        setItemEnabled( int id, bool enable );
00223 
00224     bool        isItemChecked( int id ) const;
00225     void        setItemChecked( int id, bool check );
00226 
00227     bool        isItemVisible( int id ) const;
00228     void        setItemVisible( int id, bool visible );
00229 
00230     virtual void updateItem( int id );
00231 
00232     int         indexOf( int id )       const;
00233     int         idAt( int index )       const;
00234     virtual void        setId( int index, int id );
00235 
00236     bool        connectItem( int id,
00237                              const QObject *receiver, const char* member );
00238     bool        disconnectItem( int id,
00239                                 const QObject *receiver, const char* member );
00240 
00241     bool        setItemParameter( int id, int param );
00242     int itemParameter( int id ) const;
00243 
00244     QMenuItem  *findItem( int id )      const;
00245     QMenuItem  *findItem( int id, QMenuData ** parent ) const;
00246     QMenuItem * findPopup( QPopupMenu *, int *index = 0 );
00247 
00248     virtual void activateItemAt( int index );
00249 
00250 protected:
00251     int            actItem;
00252     QMenuItemList *mitems;
00253     QMenuData     *parentMenu;
00254     uint           isPopupMenu  : 1;
00255     uint           isMenuBar    : 1;
00256     uint           badSize      : 1;
00257     uint           mouseBtDn    : 1;
00258     uint        avoid_circularity : 1;
00259     uint        actItemDown : 1;
00260     virtual void   menuContentsChanged();
00261     virtual void   menuStateChanged();
00262     virtual void   menuInsPopup( QPopupMenu * );
00263     virtual void   menuDelPopup( QPopupMenu * );
00264 
00265 private:
00266     int         insertAny( const QString *, const QPixmap *, QPopupMenu *,
00267                            const QIconSet*, int, int, QWidget* = 0, QCustomMenuItem* = 0);
00268     void        removePopup( QPopupMenu * );
00269     void        changeItemIconSet( int id, const QIconSet &icon );
00270 
00271     QMenuDataData *d;
00272 
00273 private:        // Disabled copy constructor and operator=
00274 #if defined(Q_DISABLE_COPY)
00275     QMenuData( const QMenuData & );
00276     QMenuData &operator=( const QMenuData & );
00277 #endif
00278 };
00279 
00280 
00281 #endif // QT_NO_MENUDATA
00282 
00283 #endif // QMENUDATA_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'