Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages   Examples  

qdbtutil.h

00001 #ifndef _QDBTUTIL_H
00002 #define _QDBTUTIL_H
00003 
00004 #include <qobject.h>
00005 #include <qguardedptr.h>
00006 #include <qmap.h>
00007 #include <qrect.h>
00008 #include <qstring.h>
00009 #include <qvaluelist.h>
00010 #include <qwidget.h>
00011 
00012 #include <qdbt/qdbtbasetabular.h>
00013 #include <qdbt/qdbtglobal.h>
00014 
00015 #ifdef TABULAR_TRACE_FUNCTIONS
00016 #define QDBT_CHECK_TABULAR( ptr ) \
00017   qdbt::checker_c cm( ptr, __PRETTY_FUNCTION__, __FILE__, __LINE__ );
00018 #endif
00019 
00020 class QdbtBaseCell;
00021 class QdbtSection;
00022 
00023 class QFont;
00024 class QEvent;
00025 class QPainter;
00026 class QPoint;
00027 class QString;
00028 class QPixmap;
00029 
00030 namespace qdbt
00031 {
00032   class QDBT_EXPORT traceObject_c
00033   {
00034     static QMap< int, int >      _indent;
00035     QGuardedPtr<QdbtBaseTabular> _tab;
00036     QString                      _str;
00037   public:
00039     traceObject_c( const QdbtBaseTabular * t, const QString & str ) :
00040       _tab( const_cast< QdbtBaseTabular * >( t ) ),
00041       _str( str )
00042       {
00043         traceEntry();
00044       }
00048     template < typename A >
00049     traceObject_c( const QdbtBaseTabular * t, const QString & str, A a ) :
00050       _tab( const_cast< QdbtBaseTabular * >( t ) ),
00051       _str( str.arg( interpret( a ) ) )
00052       {
00053         traceEntry();
00054       }
00058     template < typename A, typename B >
00059     traceObject_c( const QdbtBaseTabular * t, const QString & str, A a, B b ) :
00060       _tab( const_cast< QdbtBaseTabular * >( t ) ),
00061       _str( str.arg( interpret( a ) ).arg( interpret( b ) ) )
00062       {
00063         traceEntry();
00064       }
00068     template < typename A, typename B, typename C >
00069     traceObject_c( const QdbtBaseTabular * t, const QString & str, A a, B b,
00070                    C c ) :
00071       _tab( const_cast< QdbtBaseTabular * >( t ) ),
00072       _str( str.arg( interpret( a ) ).arg( interpret( b ) ).
00073             arg( interpret( c ) ) )
00074       {
00075         traceEntry();
00076       }
00080     template < typename A, typename B, typename C, typename D >
00081     traceObject_c( const QdbtBaseTabular * t, const QString & str, A a, B b,
00082                    C c, D d ) :
00083       _tab( const_cast< QdbtBaseTabular * >( t ) ),
00084       _str( str.arg( interpret( a ) ).arg( interpret( b ) ).
00085             arg( interpret( c ) ).arg( interpret( d ) ) )
00086       {
00087         traceEntry();
00088       }
00092     template < typename A, typename B, typename C, typename D, typename E >
00093     traceObject_c( const QdbtBaseTabular * t, const QString & str, A a, B b,
00094                     C c, D d, E e ) :
00095       _tab( const_cast< QdbtBaseTabular * >( t ) ),
00096       _str( str.arg( interpret( a ) ).arg( interpret( b ) ).
00097             arg( interpret( c ) ).arg( interpret( d ) ).arg( interpret( e ) ) )
00098       {
00099         traceEntry();
00100       }
00104     template < typename A, typename B, typename C, typename D, typename E,
00105                typename F >
00106     traceObject_c( const QdbtBaseTabular * t, const QString & str, A a, B b,
00107                     C c, D d, E e, F f ) :
00108       _tab( const_cast< QdbtBaseTabular * >( t ) ),
00109       _str( str.arg( interpret( a ) ).arg( interpret( b ) ).
00110             arg( interpret( c ) ).arg( interpret( d ) ).
00111             arg( interpret( e ) ).arg( interpret( f ) ) )
00112       {
00113         traceEntry();
00114       }
00118     template < typename A, typename B, typename C, typename D, typename E,
00119                typename F, typename G  >
00120     traceObject_c( const QdbtBaseTabular * t, const QString & str, A a, B b,
00121                     C c, D d, E e, F f, G g ) :
00122       _tab( const_cast< QdbtBaseTabular * >( t ) ),
00123       _str( str.arg( interpret( a ) ).arg( interpret( b ) ).
00124             arg( interpret( c ) ).arg( interpret( d ) ).
00125             arg( interpret( e ) ).arg( interpret( f ) ).arg( interpret( g ) ) )
00126       {
00127         traceEntry();
00128       }
00129 
00133     ~traceObject_c()
00134       {
00135         traceExit();
00136       }
00137   private:
00138     int indent( int modifyBy = 0 );
00139     void traceEntry();
00140     void traceExit();
00141 
00142     /* @{ \name Interpretation Layer */
00143     QString interpret( QEvent * const );
00144     QString interpret( QWidget * const wid )
00145       {
00146         return interpret( const_cast< const QWidget * const >( wid ) );
00147       }
00148     QString interpret( const QWidget * const );
00149     QString interpret( QPainter * const );
00150     QString interpret( QdbtPImpl * const );
00151     QString interpret( const QColor & );
00152     QString interpret( const QCursor & );
00153     QString interpret( const QFont & );
00154     QString interpret( const QPalette & );
00155     QString interpret( const QPixmap * );
00156     QString interpret( const QPoint & );
00157     QString interpret( const QdbtBaseCell * const );
00158 
00160     template < typename T > const T & interpret( const T & t ) { return t; }
00161     /* @} */
00162 
00163   };
00164 
00165   // Stuff being exported even on Windows platforms w/ dlls
00166   class QDBT_EXPORT eventFilter_c : public QObject
00167   {
00168   public:
00169     eventFilter_c( QObject * );
00170     virtual bool eventFilter( QObject *, QEvent * );
00171   };
00172   
00173   bool QDBT_EXPORT checkColumnWidths( const QdbtBaseTabular *tab );
00174 
00175   // Stuff that will remain privatly owned on Windows platforms
00176   // when using dlls
00177   class checker_c
00178   {
00179     QGuardedPtr< QdbtBaseTabular > _tab;
00180     QString                        _functionName;
00181     QString                        _fileName;
00182     int                            _line;
00183 
00184     static QMap< int, int >        _indent;
00185 
00186   public:
00187     checker_c( const QdbtBaseTabular * tab, const char * functionName,
00188                const char * fileName, int line );
00189 
00190     virtual ~checker_c();
00191   protected:
00192     int tabPtr();
00193     int indent( int modifyBy = 0 );
00194     virtual void write( const QString & text );
00195   };
00196 
00197   /* @{ \name String-Processing Functions */
00198   QString truncateSimpleString( QPainter *p, const QString text,
00199                                 int width, int align );
00200   QString truncateString( QPainter *p, const QString text, int width,
00201                           int align );
00202   /* @} */
00203 
00204 
00205   /* @{ \name Style-Releated Functions */
00206   QRect computeTextRect( const QRect &, int enlarge = 0 );
00207   inline QRect computeTextRect( int w, int h, int enlarge = 0 )
00208   {
00209     return computeTextRect( QRect( 0, 0, w, h ), enlarge );
00210   }
00211   QRect computeButtonRect( const QRect &, int enlarge = 0 );
00212   inline QRect computeButtonRect( int w, int h, int enlarge = 0 )
00213   {
00214     return computeButtonRect( QRect( 0, 0, w, h ), enlarge );
00215   }
00216   /* @} */
00217   
00218   QRect shrinkRect( QRect i, int shrink );
00219   void snapshot( QWidget *wid, QString filename = QString::null,
00220                  QString format = "PNG" );
00221 };
00222 
00223 class QdbtPermutationArray
00224 {
00225   QValueList<int> _permutation;
00226   
00227 public:
00228   QdbtPermutationArray();
00229   ~QdbtPermutationArray();
00230 
00231   void clear();
00232   bool insertElement( int id, int position = -1 );
00233   int position( int id ) const;
00234   const int &operator[]( int i ) const;
00235 
00236   void dump() const;
00237 };
00238 
00239 #ifndef QDBT_CHECK_TABULAR
00240 #define QDBT_CHECK_TABULAR( ptr )
00241 #endif
00242 
00243 #ifdef QDBT_FUNCTION_TRACING
00244 
00245 #define QDBT_TRACE_TABULAR_0( tab, str ) \
00246         qdbt::traceObject_c _trace( tab, str );
00247 #define QDBT_TRACE_TABULAR_1( tab, str, a ) \
00248         qdbt::traceObject_c _trace( tab, str, a );
00249 #define QDBT_TRACE_TABULAR_2( tab, str, a, b ) \
00250         qdbt::traceObject_c _trace( tab, str, a, b );
00251 #define QDBT_TRACE_TABULAR_3( tab, str, a, b, c ) \
00252         qdbt::traceObject_c _trace( tab, str, a, b, c );
00253 #define QDBT_TRACE_TABULAR_4( tab, str, a, b, c, d ) \
00254         qdbt::traceObject_c _trace( tab, str, a, b, c, d );
00255 #define QDBT_TRACE_TABULAR_5( tab, str, a, b, c, d, e ) \
00256         qdbt::traceObject_c _trace( tab, str, a, b, c, d, e );
00257 #define QDBT_TRACE_TABULAR_6( tab, str, a, b, c, d, e, f ) \
00258         qdbt::traceObject_c _trace( tab, str, a, b, c, d, e, f );
00259 #define QDBT_TRACE_TABULAR_7( tab, str, a, b, c, d, e, f, g ) \
00260         qdbt::traceObject_c _trace( tab, str, a, b, c, d, e, f, g );
00261 
00262 #else
00263 
00264 #define QDBT_TRACE_TABULAR_0( tab, str ) {}
00265 #define QDBT_TRACE_TABULAR_1( tab, str, a ) {}
00266 #define QDBT_TRACE_TABULAR_2( tab, str, a, b ) {}
00267 #define QDBT_TRACE_TABULAR_3( tab, str, a, b, c ) {}
00268 #define QDBT_TRACE_TABULAR_4( tab, str, a, b, c, d ) {}
00269 #define QDBT_TRACE_TABULAR_5( tab, str, a, b, c, d, e ) {}
00270 #define QDBT_TRACE_TABULAR_6( tab, str, a, b, c, d, e, f ) {}
00271 #define QDBT_TRACE_TABULAR_7( tab, str, a, b, c, d, e, f, g ) {}
00272 
00273 #endif
00274 
00275 
00276 #endif

Generated on Mon Apr 22 12:21:54 2002 for QdbtTabular by doxygen1.2.15-20020421