KDChartGlobal.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB.  All rights reserved.
00003 **
00004 ** This file is part of the KD Chart library.
00005 **
00006 ** Licensees holding valid commercial KD Chart licenses may use this file in
00007 ** accordance with the KD Chart Commercial License Agreement provided with
00008 ** the Software.
00009 **
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 and version 3 as published by the
00013 ** Free Software Foundation and appearing in the file LICENSE.GPL included.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** Contact info@kdab.com if any conditions of this licensing are not
00019 ** clear to you.
00020 **
00021 **********************************************************************/
00022 
00023 #ifndef __KDCHARTGLOBAL_H__
00024 #define __KDCHARTGLOBAL_H__
00025 
00026 #include <qglobal.h>
00027 
00028 #include "kdchart_export.h"
00029 
00030 #ifndef KDAB_SET_OBJECT_NAME
00031 template <typename T>
00032 inline T & __kdab__dereference_for_methodcall( T & o ) {
00033     return o;
00034 }
00035 
00036 template <typename T>
00037 inline T & __kdab__dereference_for_methodcall( T * o ) {
00038     return *o;
00039 }
00040 
00041 #define KDAB_SET_OBJECT_NAME( x ) __kdab__dereference_for_methodcall( x ).setObjectName( QLatin1String( #x ) )
00042 #endif
00043 
00044 /* vc.net2002 is 1300, vc.net2003 is 1310 */
00045 #if defined(_MSC_VER) && _MSC_VER <= 1300
00046 #define KDCHART_DECLARE_PRIVATE_DERIVED( X )      \
00047 public:                                           \
00048     class Private;                                \
00049 protected:                                        \
00050     inline Private * d_func();                    \
00051     inline const Private * d_func() const;        \
00052     explicit inline X( Private * );               \
00053 private:                                          \
00054     void init();
00055 #else
00056 #define KDCHART_DECLARE_PRIVATE_DERIVED( X )      \
00057 protected:                                        \
00058     class Private;                                \
00059     inline Private * d_func();                    \
00060     inline const Private * d_func() const;        \
00061     explicit inline X( Private * );               \
00062 private:                                          \
00063     void init();
00064 #endif
00065 
00066 #if defined(_MSC_VER) && _MSC_VER <= 1300
00067 #define KDCHART_DECLARE_PRIVATE_DERIVED_PARENT( X, ParentType )      \
00068 public:                                           \
00069     class Private;                                \
00070 protected:                                        \
00071     inline Private * d_func();                    \
00072     inline const Private * d_func() const;        \
00073     explicit inline X( Private *, ParentType );   \
00074 private:                                          \
00075     void init();
00076 #else
00077 #define KDCHART_DECLARE_PRIVATE_DERIVED_PARENT( X, ParentType )      \
00078 protected:                                        \
00079     class Private;                                \
00080     inline Private * d_func();                    \
00081     inline const Private * d_func() const;        \
00082     explicit inline X( Private *, ParentType );   \
00083 private:                                          \
00084     void init();
00085 #endif
00086 
00087 #define KDCHART_DECLARE_PRIVATE_DERIVED_QWIDGET( X )         \
00088     KDCHART_DECLARE_PRIVATE_DERIVED_PARENT( X, QWidget* )
00089 
00090 #define KDCHART_DECLARE_PRIVATE_BASE_VALUE( X )              \
00091 public:                                                      \
00092     inline void swap( X & other ) { qSwap( _d, other._d ); } \
00093 protected:                                                   \
00094     class Private;                                           \
00095     Private * d_func() { return _d; }                        \
00096     const Private * d_func() const { return _d; }            \
00097 private:                                                     \
00098     void init();                                             \
00099     Private * _d;
00100 
00101 #if defined(_MSC_VER) && _MSC_VER <= 1300
00102 #define KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC( X ) \
00103 public:                                           \
00104     class Private;                                    \
00105 protected:                                        \
00106     Private * d_func() { return _d; }                 \
00107     const Private * d_func() const { return _d; }     \
00108     explicit inline X( Private * );                   \
00109 private:                                              \
00110     void init();                                      \
00111     Private * _d;
00112 #else
00113 #define KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC( X ) \
00114 protected:                                        \
00115     class Private;                                    \
00116     Private * d_func() { return _d; }                 \
00117     const Private * d_func() const { return _d; }     \
00118     explicit inline X( Private * );                   \
00119 private:                                              \
00120     void init();                                      \
00121     Private * _d;
00122 #endif
00123 
00124 #if defined(_MSC_VER) && _MSC_VER <= 1300
00125 #define KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( X ) \
00126 public:                                           \
00127     class Private;                                    \
00128 protected:                                        \
00129     Private * d_func() { return _d; }                 \
00130     const Private * d_func() const { return _d; }     \
00131     explicit inline X( Private *, QWidget* );                  \
00132 private:                                              \
00133     void init();                                      \
00134     Private * _d;
00135 #else
00136 #define KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( X ) \
00137 protected:                                        \
00138     class Private;                                    \
00139     Private * d_func() { return _d; }                 \
00140     const Private * d_func() const { return _d; }     \
00141     explicit inline X( Private *, QWidget* );                  \
00142 private:                                              \
00143     void init();                                      \
00144     Private * _d;
00145 #endif
00146 
00147 
00148 #define KDCHART_DERIVED_PRIVATE_FOOTER( CLASS, PARENT )     \
00149 inline CLASS::CLASS( Private * p )                          \
00150   : PARENT( p ) { init(); }                                 \
00151 inline CLASS::Private * CLASS::d_func()                     \
00152 { return static_cast<Private*>( PARENT::d_func() ); }       \
00153 inline const CLASS::Private * CLASS::d_func() const         \
00154 { return static_cast<const Private*>( PARENT::d_func() ); }
00155 
00156 
00157 #if defined(_MSC_VER) && _MSC_VER <= 1300
00158 #define KDCHART_DECLARE_DERIVED_DIAGRAM( X, PLANE )     \
00159 public:                                                 \
00160     class Private;                                      \
00161 protected:                                              \
00162     inline Private * d_func();                          \
00163     inline const Private * d_func() const;              \
00164     explicit inline X( Private * );                     \
00165     explicit inline X( Private *, QWidget *, PLANE * ); \
00166 private:                                                \
00167     void init();
00168 #else
00169 #define KDCHART_DECLARE_DERIVED_DIAGRAM( X, PLANE )     \
00170 protected:                                              \
00171     class Private;                                      \
00172     inline Private * d_func();                          \
00173     inline const Private * d_func() const;              \
00174     explicit inline X( Private * );                     \
00175     explicit inline X( Private *, QWidget *, PLANE * ); \
00176 private:                                                \
00177     void init();
00178 #endif
00179 
00180 #define KDCHART_IMPL_DERIVED_DIAGRAM( CLASS, PARENT, PLANE ) \
00181 inline CLASS::CLASS( Private * p )                           \
00182     : PARENT( p ) { init(); }                                \
00183 inline CLASS::CLASS(                                         \
00184     Private * p, QWidget* parent, PLANE * plane )            \
00185     : PARENT( p, parent, plane ) { init(); }                 \
00186 inline CLASS::Private * CLASS::d_func()                      \
00187     { return static_cast<Private *>( PARENT::d_func() ); }   \
00188 inline const CLASS::Private * CLASS::d_func() const          \
00189     { return static_cast<const Private *>( PARENT::d_func() ); }
00190 
00191 
00192 #define KDCHART_IMPL_DERIVED_PLANE( CLASS, BASEPLANE )        \
00193 inline CLASS::CLASS( Private * p, Chart* parent )           \
00194     : BASEPLANE( p, parent ) { init(); }                      \
00195 inline CLASS::Private * CLASS::d_func()                       \
00196     { return static_cast<Private *>( BASEPLANE::d_func() ); } \
00197 inline const CLASS::Private * CLASS::d_func() const           \
00198     { return static_cast<const Private *>( BASEPLANE::d_func() ); }
00199 
00200 
00201 #include <QtAlgorithms> // qSwap
00202 #ifndef QT_NO_STL
00203 #include <algorithm>
00204 #define KDCHART_DECLARE_SWAP_SPECIALISATION( X )            \
00205     template <> inline void qSwap<X>( X & lhs, X & rhs )    \
00206     { lhs.swap( rhs ); }                                    \
00207     namespace std {                                         \
00208         template <> inline void swap<X>( X & lhs, X & rhs ) \
00209         { lhs.swap( rhs ); }                                \
00210     }
00211 #else
00212 #define KDCHART_DECLARE_SWAP_SPECIALISATION( X )            \
00213     template <> inline void qSwap<X>( X & lhs, X & rhs )    \
00214     { lhs.swap( rhs ); }
00215 #endif
00216 
00217 #define KDCHART_DECLARE_SWAP_SPECIALISATION_DERIVED( X )    \
00218     KDCHART_DECLARE_SWAP_SPECIALISATION( X )
00219 
00220 #define KDCHART_DECLARE_SWAP_BASE( X ) \
00221 protected: \
00222     void doSwap( X& other ) \
00223     { qSwap( _d, other._d); }
00224 
00225 #define KDCHART_DECLARE_SWAP_DERIVED( X ) \
00226     void swap( X& other ) { doSwap( other ); }
00227 
00228 #if defined(Q_OS_WIN) && defined(QT_DLL)
00229 #if defined(_MSC_VER) && _MSC_VER >= 1300
00230 // workaround http://support.microsoft.com/default.aspx?scid=kb;en-us;309801
00231 #include <QPointF>
00232 #include <QVector>
00233 template class Q_DECL_IMPORT QVector<QPointF>;
00234 #endif
00235 #endif
00236 
00237 #include <Qt>
00238 
00239 namespace KDChart {
00240 
00241 enum DisplayRoles {
00242   DatasetPenRole = 0x0A79EF95,
00243   DatasetBrushRole,
00244   DataValueLabelAttributesRole,
00245   ThreeDAttributesRole,
00246   LineAttributesRole,
00247   ThreeDLineAttributesRole,
00248   BarAttributesRole,
00249   StockBarAttributesRole,
00250   ThreeDBarAttributesRole,
00251   PieAttributesRole,
00252   ThreeDPieAttributesRole,
00253   DataHiddenRole,
00254   ValueTrackerAttributesRole,
00255   CommentRole,
00256   ColumnDataRole
00257 };
00258 }
00259 
00260 #endif // __KDCHARTGLOBAL_H__