diff options
Diffstat (limited to 'tqtinterface/qt4/src/kernel/tqobjectdefs.h')
-rw-r--r-- | tqtinterface/qt4/src/kernel/tqobjectdefs.h | 277 |
1 files changed, 277 insertions, 0 deletions
diff --git a/tqtinterface/qt4/src/kernel/tqobjectdefs.h b/tqtinterface/qt4/src/kernel/tqobjectdefs.h new file mode 100644 index 0000000..794d1f0 --- /dev/null +++ b/tqtinterface/qt4/src/kernel/tqobjectdefs.h @@ -0,0 +1,277 @@ +/**************************************************************************** +** +** Macros and definitions related to TQObject +** +** Created : 930419 +** +** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQOBJECTDEFS_H +#define TQOBJECTDEFS_H + +#include "tqtglobaldefines.h" + +#ifndef TQT_H +#include "tqglobal.h" +#endif // TQT_H + +#ifdef USE_QT4 + +#include <Qt/qobject.h> +#include <Qt/qmetaobject.h> +#undef TQT_H +#include "tqvariant.h" + +#endif + + +#ifndef TQT_NO_TRANSLATION +# ifndef TQT_NO_TEXTCODEC +// full set of tr functions +# define TQT_TR_FUNCTIONS \ + static TQString tr( const char *, const char * = 0 ); \ + static TQString trUtf8( const char *, const char * = 0 ); +# else +// no TQTextCodec, no utf8 +# define TQT_TR_FUNCTIONS \ + static TQString tr( const char *, const char * = 0 ); +# endif +#else +// inherit the ones from TQObject +# define TQT_TR_FUNCTIONS +#endif + +#ifdef USE_QT4 + +#ifndef TQT_NO_PROPERTIES +# define TQT_PROP_FUNCTIONS \ + inline virtual bool qt_property( int id, int f, TQVariant* v) { \ + /* f==0 is write and f==1 is read */ \ + QMetaProperty p = metaObject()->property(id); \ + switch (f) { \ + case 0: \ + p.write(this, *v); \ + break; \ + case 1: \ + *static_cast<QVariant*>(v) = p.read(this); \ + break; \ + } \ + return true; /* Always assume success */ \ + } \ + //static bool qt_static_property( TQObject* , int, int, TQVariant* ); +#else +# define TQT_PROP_FUNCTIONS +#endif + +#else // USE_QT4 + +#ifndef TQT_NO_PROPERTIES +# define TQT_PROP_FUNCTIONS \ + virtual bool qt_property( int id, int f, TQVariant* v); \ + static bool qt_static_property( TQObject* , int, int, TQVariant* ); +#else +# define TQT_PROP_FUNCTIONS +#endif + +#endif // USE_QT4 + +// The following macros are our "extensions" to C++ +// They are used, strictly speaking, only by the tqmoc. +struct TQUObject; + +#ifdef TQT_TQMOC_CPP +#define Q_SLOTS Q_SLOTS +#define Q_SIGNALS Q_SIGNALS +#define TQ_CLASSINFO( name, value ) TQ_CLASSINFO( name, value ) +#define TQ_PROPERTY( text ) TQ_PROPERTY( text ) +#define TQ_OVERRIDE( text ) TQ_OVERRIDE( text ) +#define TQ_ENUMS( x ) TQ_ENUMS( x ) +#define TQ_SETS( x ) TQ_SETS( x ) + +#ifdef USE_QT4 +// /* tmake ignore TQ_OBJECT */ +#define TQ_OBJECT // +// /* tmake ignore TQ_OBJECT */ +#define TQ_OBJECT_FAKE // +#else // USE_QT4 + /* tmake ignore TQ_OBJECT */ +#define TQ_OBJECT TQ_OBJECT + /* tmake ignore TQ_OBJECT */ +#define TQ_OBJECT_FAKE TQ_OBJECT_FAKE +#endif // USE_QT4 + +#else +#define Q_SLOTS // Q_SLOTS: in class +#define Q_SIGNALS protected // Q_SIGNALS: in class +#ifndef TQT_NO_EMIT +#define emit // emit signal +#endif +#define TQ_CLASSINFO( name, value ) // class info +#define TQ_PROPERTY( text ) // property +#define TQ_OVERRIDE( text ) // override property +#define TQ_ENUMS( x ) +#define TQ_SETS( x ) + +#ifdef USE_QT4 + +# ifndef TQT_NO_TEXTCODEC +// full set of tr functions +# define TQT_TR_FUNCTIONS_QT4 \ + inline static TQString tqtr( const char *ch1, const char *ch2 = 0 ) { return TQT_TQSTRING(tr(ch1, ch2)); } \ + inline static TQString tqtrUtf8( const char *ch1, const char *ch2 = 0 ) { return TQT_TQSTRING(tr(ch1, ch2)); } +# else +// no TQTextCodec, no utf8 +# define TQT_TR_FUNCTIONS_QT4 \ + inline static TQString tqtr( const char *ch1, const char *ch2 = 0 ) { return TQT_TQSTRING(tr(ch1, ch2)); } +# endif + +#define TQ_OBJECT \ +public: \ + inline static TQMetaObject* tqstaticMetaObject() \ + { return tqstaticMetaObject_helper(&staticMetaObject); } \ + inline virtual const char *className() const \ + { return metaObject()->className(); } \ + inline virtual void* tqqt_cast( const char* ctname ) \ + { if (inherits(ctname)) \ + return const_cast<TQT_BASE_OBJECT_NAME *>(reinterpret_cast<TQT_BASE_OBJECT_NAME *>(0)->staticMetaObject.cast(const_cast<QObject *>(static_cast<const QObject*>(TQT_TQOBJECT_CONST(this))))); \ + return 0; } /* [FIXME] VERIFY THIS!!! */ \ + inline void* qt_cast( const char* ctname ) \ + { if (inherits(ctname)) \ + return const_cast<TQT_BASE_OBJECT_NAME *>(reinterpret_cast<TQT_BASE_OBJECT_NAME *>(0)->staticMetaObject.cast(const_cast<QObject *>(static_cast<const QObject*>(TQT_TQOBJECT_CONST(this))))); \ + return 0; } /* [FIXME] VERIFY THIS!!! */ \ + inline virtual bool qt_invoke( int, TQUObject* ) \ + { printf("[WARNING] qt_invoke unimplemented\n\r"); return false; } \ + inline virtual bool qt_emit( int, TQUObject* ) \ + { printf("[WARNING] qt_emit unimplemented\n\r"); return false; } \ + TQT_PROP_FUNCTIONS \ + TQT_TR_FUNCTIONS_QT4 + +#else // USE_QT4 +/* tmake ignore TQ_OBJECT */ +#define TQ_OBJECT \ +public: \ + virtual TQMetaObject *tqmetaObject() const { \ + return staticMetaObject(); \ + } \ + virtual const char *className() const; \ + virtual void* tqqt_cast( const char* ); \ + virtual bool qt_invoke( int, TQUObject* ); \ + virtual bool qt_emit( int, TQUObject* ); \ + TQT_PROP_FUNCTIONS \ + static TQMetaObject* staticMetaObject(); \ + TQObject* qObject() { return (TQObject*)this; } \ + TQT_TR_FUNCTIONS \ +private: \ + static TQMetaObject *metaObj; + +#endif // USE_QT4 + +/* tmake ignore TQ_OBJECT */ +#define TQ_OBJECT_FAKE TQ_OBJECT + +#endif + +// macro for naming members +#ifdef TQT_METHOD +#undef TQT_METHOD +#endif +#ifdef TQT_SLOT +#undef TQT_SLOT +#endif +#ifdef TQT_SIGNAL +#undef TQT_SIGNAL +#endif + +#if defined(_OLD_CPP_) +#define TQT_METHOD(a) "0""a" +#define TQT_SLOT(a) "1""a" +#define TQT_SIGNAL(a) "2""a" +#else +#define TQT_METHOD(a) "0"#a +#define TQT_SLOT(a) "1"#a +#define TQT_SIGNAL(a) "2"#a +#endif + +#ifndef TQT_CLEAN_NAMESPACE +#define METHOD_CODE 0 // member type codes +#define SLOT_CODE 1 +#define SIGNAL_CODE 2 +#endif + +#define TQMETHOD_CODE 0 // member type codes +#define TQSLOT_CODE 1 +#define TQSIGNAL_CODE 2 + +class TQObject; +class TQMetaObject; +class TQSignal; +class TQConnection; +class TQEvent; +struct TQMetaData; +class TQConnectionList; +class TQConnectionListIt; +class TQSignalVec; +class TQObjectList; +class TQObjectListIt; +class TQMemberDict; + +TQ_EXPORT void *qt_tqfind_obj_child( TQObject *, const char *, const char * ); +#define TQ_CHILD(tqparent,type,name) \ + ((type*)qt_tqfind_obj_child(tqparent,#type,name)) + +TQ_EXPORT void *qt_inheritedBy( TQMetaObject *super, const TQObject *cls ); + +// template <typename T> +// TQ_INLINE_TEMPLATES T tqqt_cast(const TQObject *object) +// { return (T)qt_inheritedBy( ((T)0)->staticMetaObject(), object ); } + +// template <typename T> +// TQ_INLINE_TEMPLATES T tqqt_cast(const TQT_BASE_OBJECT_NAME *object) +// { return (T)qt_inheritedBy( ((T)0)->staticMetaObject(), TQT_TQOBJECT_CONST(object) ); } + +template <typename T> +TQ_INLINE_TEMPLATES T tqqt_cast(const TQT_BASE_OBJECT_NAME *object) +//{ return (const T)qobject_cast<const T>(object); } +{ +// // this will cause a compilation error if T is not const +// register T ptr = static_cast<T>(object); +// Q_UNUSED(ptr); + +#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK) + reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<TQT_BASE_OBJECT_NAME *>(object))); +#endif + return static_cast<T>(const_cast<TQT_BASE_OBJECT_NAME *>(reinterpret_cast<T>(0)->staticMetaObject.cast(const_cast<TQT_BASE_OBJECT_NAME *>(object)))); +} +#endif // TQOBJECTDEFS_H |