File indexing completed on 2024-05-12 15:54:16

0001 /*
0002  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
0003  *
0004  * This file is part of the KD Chart library.
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License as
0008  * published by the Free Software Foundation; either version 2 of
0009  * the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
0018  */
0019 /** \file KChartGlobal.h
0020 \brief Contains KChart macros.
0021 
0022 Contains KChart macros.  */
0023 
0024 #ifndef __KCHARTGLOBAL_H__
0025 #define __KCHARTGLOBAL_H__
0026 
0027 #include <qglobal.h>
0028 
0029 #include "kchart_export.h"
0030 
0031 #ifndef KDAB_SET_OBJECT_NAME
0032 template <typename T>
0033 inline T & __kdab__dereference_for_methodcall( T & o ) {
0034     return o;
0035 }
0036 
0037 template <typename T>
0038 inline T & __kdab__dereference_for_methodcall( T * o ) {
0039     return *o;
0040 }
0041 
0042 #define KDAB_SET_OBJECT_NAME( x ) __kdab__dereference_for_methodcall( x ).setObjectName( QLatin1String( #x ) )
0043 #endif
0044 
0045 #define KCHART_DECLARE_PRIVATE_DERIVED( X )      \
0046 public:                                           \
0047     class Private;                                \
0048 protected:                                        \
0049     inline Private * d_func();                    \
0050     inline const Private * d_func() const;        \
0051     explicit inline X( Private * );               \
0052 private:                                          \
0053     void init();
0054 
0055 #define KCHART_DECLARE_PRIVATE_DERIVED_PARENT( X, ParentType )      \
0056 public:                                           \
0057     class Private;                                \
0058 protected:                                        \
0059     inline Private * d_func();                    \
0060     inline const Private * d_func() const;        \
0061     explicit inline X( Private *, ParentType );   \
0062 private:                                          \
0063     void init();
0064 
0065 #define KCHART_DECLARE_PRIVATE_DERIVED_QWIDGET( X )         \
0066     KCHART_DECLARE_PRIVATE_DERIVED_PARENT( X, QWidget* )
0067 
0068 #define KCHART_DECLARE_PRIVATE_BASE_VALUE( X )              \
0069 public:                                                      \
0070     inline void swap( X & other ) { qSwap( _d, other._d ); } \
0071 protected:                                                   \
0072     class Private;                                           \
0073     Private * d_func() { return _d; }                        \
0074     const Private * d_func() const { return _d; }            \
0075 private:                                                     \
0076     void init();                                             \
0077     Private * _d;
0078 
0079 #define KCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC( X ) \
0080 public:                                           \
0081     class Private;                                    \
0082 protected:                                        \
0083     Private * d_func() { return _d; }                 \
0084     const Private * d_func() const { return _d; }     \
0085     explicit inline X( Private * );                   \
0086 private:                                              \
0087     void init();                                      \
0088     Private * _d;
0089 
0090 #define KCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( X ) \
0091 public:                                           \
0092     class Private;                                    \
0093 protected:                                        \
0094     Private * d_func() { return _d; }                 \
0095     const Private * d_func() const { return _d; }     \
0096     explicit inline X( Private *, QWidget* );                  \
0097 private:                                              \
0098     void init();                                      \
0099     Private * _d;
0100 
0101 #define KCHART_DERIVED_PRIVATE_FOOTER( CLASS, PARENT )     \
0102 inline CLASS::CLASS( Private * p )                          \
0103   : PARENT( p ) { init(); }                                 \
0104 inline CLASS::Private * CLASS::d_func()                     \
0105 { return static_cast<Private*>( PARENT::d_func() ); }       \
0106 inline const CLASS::Private * CLASS::d_func() const         \
0107 { return static_cast<const Private*>( PARENT::d_func() ); }
0108 
0109 
0110 #define KCHART_DECLARE_DERIVED_DIAGRAM( X, PLANE )     \
0111 public:                                                 \
0112     class Private;                                      \
0113 protected:                                              \
0114     inline Private * d_func();                          \
0115     inline const Private * d_func() const;              \
0116     explicit inline X( Private * );                     \
0117     explicit inline X( Private *, QWidget *, PLANE * ); \
0118 private:                                                \
0119     void init();
0120 
0121 #define KCHART_IMPL_DERIVED_DIAGRAM( CLASS, PARENT, PLANE ) \
0122 inline CLASS::CLASS( Private * p )                           \
0123     : PARENT( p ) { init(); }                                \
0124 inline CLASS::CLASS(                            \
0125     Private * p, QWidget* parent, PLANE * plane )            \
0126     : PARENT( p, parent, plane ) { init(); }                 \
0127 inline CLASS::Private * CLASS::d_func()                      \
0128     { return static_cast<Private *>( PARENT::d_func() ); }   \
0129 inline const CLASS::Private * CLASS::d_func() const          \
0130     { return static_cast<const Private *>( PARENT::d_func() ); }
0131 
0132 
0133 #define KCHART_IMPL_DERIVED_PLANE( CLASS, BASEPLANE )        \
0134 inline CLASS::CLASS( Private * p, Chart* parent )           \
0135     : BASEPLANE( p, parent ) { init(); }                      \
0136 inline CLASS::Private * CLASS::d_func()                       \
0137     { return static_cast<Private *>( BASEPLANE::d_func() ); } \
0138 inline const CLASS::Private * CLASS::d_func() const           \
0139     { return static_cast<const Private *>( BASEPLANE::d_func() ); }
0140 
0141 
0142 #include <QtAlgorithms> // qSwap
0143 #ifndef QT_NO_STL
0144 #include <algorithm>
0145 #define KCHART_DECLARE_SWAP_SPECIALISATION( X )            \
0146 QT_BEGIN_NAMESPACE                                          \
0147     template <> inline void qSwap<X>( X & lhs, X & rhs )    \
0148     { lhs.swap( rhs ); }                                    \
0149 QT_END_NAMESPACE                                            \
0150     namespace std {                                         \
0151         template <> inline void swap<X>( X & lhs, X & rhs ) \
0152         { lhs.swap( rhs ); }                                \
0153     }
0154 #else
0155 #define KCHART_DECLARE_SWAP_SPECIALISATION( X )            \
0156 QT_BEGIN_NAMESPACE                                          \
0157     template <> inline void qSwap<X>( X & lhs, X & rhs )    \
0158     { lhs.swap( rhs ); }                                    \
0159 QT_END_NAMESPACE
0160 #endif
0161 
0162 #define KCHART_DECLARE_SWAP_SPECIALISATION_DERIVED( X )    \
0163     KCHART_DECLARE_SWAP_SPECIALISATION( X )
0164 
0165 #define KCHART_DECLARE_SWAP_BASE( X ) \
0166 protected: \
0167     void doSwap( X& other ) \
0168     { qSwap( _d, other._d); }
0169 
0170 #define KCHART_DECLARE_SWAP_DERIVED( X ) \
0171     void swap( X& other ) { doSwap( other ); }
0172 
0173 #if defined(Q_OS_WIN) && defined(QT_DLL)
0174 #if defined(_MSC_VER) && _MSC_VER >= 1300
0175 // workaround http://support.microsoft.com/default.aspx?scid=kb;en-us;309801
0176 #include <QPointF>
0177 #include <QVector>
0178 template class Q_DECL_IMPORT QVector<QPointF>;
0179 #endif
0180 #endif
0181 
0182 #include <Qt>
0183 
0184 /**
0185   \namespace KChart
0186   \brief Global namespace
0187   */
0188 namespace KChart {
0189 
0190 enum DisplayRoles {
0191   DatasetPenRole = 0x0A79EF95,
0192   DatasetBrushRole,
0193   DataValueLabelAttributesRole,
0194   ThreeDAttributesRole,
0195   LineAttributesRole,
0196   ThreeDLineAttributesRole,
0197   BarAttributesRole,
0198   StockBarAttributesRole,
0199   ThreeDBarAttributesRole,
0200   PieAttributesRole,
0201   ThreeDPieAttributesRole,
0202   DataHiddenRole,
0203   ValueTrackerAttributesRole,
0204   CommentRole
0205 };
0206 }
0207 
0208 #endif // __KCHARTGLOBAL_H__