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

  1. /****************************************************************************
  2. ** $Id:  qt/qobject.h   3.0.0   edited Sep 20 15:33 $
  3. **
  4. ** Definition of QObject class
  5. **
  6. ** Created : 930418
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the kernel 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 QOBJECT_H
  39. #define QOBJECT_H
  40.  
  41. #ifndef QT_H
  42. #include "qobjectdefs.h"
  43. #include "qwindowdefs.h"
  44. #include "qstring.h"
  45. #include "qevent.h"
  46. #include "qnamespace.h"
  47. #endif // QT_H
  48.  
  49. #define QT_TR_NOOP(x) (x)
  50. #define QT_TRANSLATE_NOOP(scope,x) (x)
  51.  
  52. class QMetaObject;
  53. class QVariant;
  54. class QMetaProperty;
  55. class QPostEventList;
  56. class QObjectPrivate;
  57. struct QUObject;
  58.  
  59. class Q_EXPORT QObject: public Qt
  60. {
  61.     Q_OBJECT
  62.     Q_PROPERTY( QCString name READ name WRITE setName )
  63.  
  64. public:
  65.     QObject( QObject *parent=0, const char *name=0 );
  66.     virtual ~QObject();
  67.  
  68. #ifdef Q_QDOC
  69.     const char *className() const;
  70.     QString tr( const char *, const char * ) const;
  71.     QString trUtf8( const char *, const char * ) const;
  72.     QMetaObject *metaObject() const;
  73. #endif
  74.  
  75.     virtual bool event( QEvent * );
  76.     virtual bool eventFilter( QObject *, QEvent * );
  77.  
  78.     bool     isA( const char * )     const;
  79.     bool     inherits( const char * ) const;
  80.  
  81.     const char  *name() const;
  82.     const char  *name( const char * defaultName ) const;
  83.  
  84.     virtual void setName( const char *name );
  85.     bool     isWidgetType()      const { return isWidget; }
  86.     bool     highPriority()      const { return FALSE; }
  87.  
  88.     bool     signalsBlocked()  const { return blockSig; }
  89.     void     blockSignals( bool b );
  90.  
  91.     int         startTimer( int interval );
  92.     void     killTimer( int id );
  93.     void     killTimers();
  94.  
  95.     QObject           *child( const char *objName, const char *inheritsClass = 0, bool recursiveSearch = TRUE );
  96.     const QObjectList *children() const { return childObjects; }
  97.  
  98.     static const QObjectList *objectTrees();
  99.  
  100.     QObjectList          *queryList( const char *inheritsClass = 0,
  101.                   const char *objName = 0,
  102.                   bool regexpMatch = TRUE,
  103.                   bool recursiveSearch = TRUE ) const;
  104.  
  105.     virtual void insertChild( QObject * );
  106.     virtual void removeChild( QObject * );
  107.  
  108.     void     installEventFilter( const QObject * );
  109.     void     removeEventFilter( const QObject * );
  110.  
  111.     static bool  connect( const QObject *sender, const char *signal,
  112.               const QObject *receiver, const char *member );
  113.     bool     connect( const QObject *sender, const char *signal,
  114.               const char *member ) const;
  115.     static bool  disconnect( const QObject *sender, const char *signal,
  116.                  const QObject *receiver, const char *member );
  117.     bool     disconnect( const char *signal=0,
  118.                  const QObject *receiver=0, const char *member=0 );
  119.     bool     disconnect( const QObject *receiver, const char *member=0 );
  120.     static void      connectInternal( const QObject *sender, int signal_index, const QObject *receiver,
  121.                   int membcode, int member_index );
  122.  
  123.     void     dumpObjectTree();
  124.     void     dumpObjectInfo();
  125.  
  126. #ifndef QT_NO_PROPERTIES
  127.     virtual bool setProperty( const char *name, const QVariant& value );
  128.     virtual QVariant property( const char *name ) const;
  129. #endif // QT_NO_PROPERTIES
  130. #ifdef QT_NO_TRANSLATION
  131.     static QString tr( const char *sourceText, const char * = 0);
  132. #ifndef QT_NO_TEXTCODEC
  133.     static QString trUtf8( const char *sourceText, const char * = 0);
  134. #endif
  135. #endif //QT_NO_TRANSLATION
  136.  
  137. signals:
  138.     void     destroyed();
  139.     void     destroyed( QObject* obj );
  140.  
  141. public:
  142.     QObject    *parent() const { return parentObj; }
  143.  
  144. public slots:
  145.     void    deleteLater();
  146.  
  147. private slots:
  148.     void     cleanupEventFilter( QObject* );
  149.  
  150. protected:
  151.     bool    activate_filters( QEvent * );
  152.     QConnectionList *receivers( const char* signal ) const;
  153.     QConnectionList *receivers( int signal ) const;
  154.     void    activate_signal( int signal );
  155.     void    activate_signal( int signal, int );
  156.     void    activate_signal( int signal, double );
  157.     void    activate_signal( int signal, QString );
  158.     void    activate_signal_bool( int signal, bool );
  159.     void     activate_signal( QConnectionList *clist, QUObject *o );
  160.  
  161.     const QObject *sender();
  162.  
  163.     virtual void timerEvent( QTimerEvent * );
  164.     virtual void childEvent( QChildEvent * );
  165.     virtual void customEvent( QCustomEvent * );
  166.  
  167.     virtual void connectNotify( const char *signal );
  168.     virtual void disconnectNotify( const char *signal );
  169.     virtual bool checkConnectArgs( const char *signal, const QObject *receiver,
  170.                    const char *member );
  171.     static QCString normalizeSignalSlot( const char *signalSlot );
  172.  
  173. private:
  174.     uint    isSignal   : 1;
  175.     uint    isWidget   : 1;
  176.     uint    pendTimer  : 1;
  177.     uint    blockSig   : 1;
  178.     uint    wasDeleted : 1;
  179.     uint    isTree : 1;
  180.  
  181.     const char    *objname;
  182.     QObject    *parentObj;
  183.     QObjectList *childObjects;
  184.     QSignalVec *connections;
  185.     QObjectList *senderObjects;
  186.     QObjectList *eventFilters;
  187.     QPostEventList *postedEvents;
  188.     QObjectPrivate* d;
  189.  
  190.     static QMetaObject* staticQtMetaObject();
  191.  
  192.     friend class QApplication;
  193.     friend class QBaseApplication;
  194.     friend class QWidget;
  195.     friend class QSignal;
  196.     friend class QSenderObject;
  197.  
  198. private:    // Disabled copy constructor and operator=
  199. #if defined(Q_DISABLE_COPY)
  200.     QObject( const QObject & );
  201.     QObject &operator=( const QObject & );
  202. #endif
  203. };
  204.  
  205.  
  206. inline bool QObject::connect( const QObject *sender, const char *signal,
  207.                   const char *member ) const
  208. {
  209.     return connect( sender, signal, this, member );
  210. }
  211.  
  212.  
  213. inline bool QObject::disconnect( const char *signal,
  214.                  const QObject *receiver, const char *member )
  215. {
  216.     return disconnect( this, signal, receiver, member );
  217. }
  218.  
  219.  
  220. inline bool QObject::disconnect( const QObject *receiver, const char *member )
  221. {
  222.     return disconnect( this, 0, receiver, member );
  223. }
  224.  
  225.  
  226. class Q_EXPORT QSenderObject : public QObject        // object for sending signals
  227. {
  228. public:
  229.     void setSender( QObject *s );
  230. };
  231.  
  232. #ifdef QT_NO_TRANSLATION
  233. inline QString QObject::tr( const char *sourceText, const char * ) {
  234.     return QString::fromLatin1( sourceText );
  235. }
  236. #ifndef QT_NO_TEXTCODEC
  237. inline QString QObject::trUtf8( const char *sourceText, const char * ) {
  238.     return QString::fromUtf8( sourceText );
  239. }
  240. #endif
  241. #endif //QT_NO_TRANSLATION
  242.  
  243.  
  244.  
  245. #endif // QOBJECT_H
  246.