Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qinternal_p.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** $Id: qinternal_p.h,v 1.2 2003/07/10 02:40:11 llornkcor Exp $
00003 **
00004 ** Definition of some shared interal classes
00005 **
00006 ** Created : 010427
00007 **
00008 ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
00009 **
00010 ** This file is part of the kernel module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech AS of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QINTERNAL_P_H
00039 #define QINTERNAL_P_H
00040 
00041 //
00042 //  W A R N I N G
00043 //  -------------
00044 //
00045 // This file is not part of the Qt API.  It exists for the convenience
00046 // of a number of Qt sources files.  This header file may change from
00047 // version to version without notice, or even be removed.
00048 //
00049 // We mean it.
00050 //
00051 //
00052 #ifndef QT_H
00053 #include <qnamespace.h>
00054 #include <qrect.h>
00055 #endif // QT_H
00056 
00057 class QWidget;
00058 class QPainter;
00059 class QPixmap;
00060 
00061 class Q_EXPORT QSharedDoubleBuffer
00062 {
00063 public:
00064     enum DoubleBufferFlags {
00065         NoFlags         = 0x00,
00066         InitBG          = 0x01,
00067         Force           = 0x02,
00068         Default         = InitBG | Force
00069     };
00070     typedef uint DBFlags;
00071 
00072     QSharedDoubleBuffer( DBFlags f = Default );
00073     QSharedDoubleBuffer( QWidget* widget,
00074                          int x = 0, int y = 0, int w = -1, int h = -1,
00075                          DBFlags f = Default );
00076     QSharedDoubleBuffer( QPainter* painter,
00077                          int x = 0, int y = 0, int w = -1, int h = -1,
00078                          DBFlags f = Default );
00079     QSharedDoubleBuffer( QWidget *widget, const QRect &r, DBFlags f = Default );
00080     QSharedDoubleBuffer( QPainter *painter, const QRect &r, DBFlags f = Default );
00081     ~QSharedDoubleBuffer();
00082 
00083     bool begin( QWidget* widget, int x = 0, int y = 0, int w = -1, int h = -1 );
00084     bool begin( QPainter* painter, int x = 0, int y = 0, int w = -1, int h = -1);
00085     bool begin( QWidget* widget, const QRect &r );
00086     bool begin( QPainter* painter, const QRect &r );
00087     bool end();
00088 
00089     QPainter* painter() const;
00090 
00091     bool isActive() const;
00092     bool isBuffered() const;
00093     void flush();
00094 
00095     static bool isDisabled() { return !dblbufr; }
00096     static void setDisabled( bool off ) { dblbufr = !off; }
00097 
00098     static void cleanup();
00099 
00100 private:
00101     enum DoubleBufferState {
00102         Active          = 0x0100,
00103         BufferActive    = 0x0200,
00104         ExternalPainter = 0x0400
00105     };
00106     typedef uint DBState;
00107 
00108     QPixmap *getPixmap();
00109     void releasePixmap();
00110 
00111     QWidget *wid;
00112     int rx, ry, rw, rh;
00113     DBFlags flags;
00114     DBState state;
00115 
00116     QPainter *p, *external_p;
00117     QPixmap *pix;
00118 
00119     static bool dblbufr;
00120 };
00121 
00122 inline bool QSharedDoubleBuffer::begin( QWidget* widget, const QRect &r )
00123 { return begin( widget, r.x(), r.y(), r.width(), r.height() ); }
00124 
00125 inline bool QSharedDoubleBuffer::begin( QPainter *painter, const QRect &r )
00126 { return begin( painter, r.x(), r.y(), r.width(), r.height() ); }
00127 
00128 inline QPainter* QSharedDoubleBuffer::painter() const
00129 { return p; }
00130 
00131 inline bool QSharedDoubleBuffer::isActive() const
00132 { return ( state & Active ); }
00133 
00134 inline bool QSharedDoubleBuffer::isBuffered() const
00135 { return ( state & BufferActive ); }
00136 
00137 
00138 class QVirtualDestructor {
00139 public:
00140     virtual ~QVirtualDestructor() {}
00141 };
00142 
00143 template <class T>
00144 class QAutoDeleter : public QVirtualDestructor {
00145 public:
00146     QAutoDeleter( T* p ) : ptr( p ) {}
00147     ~QAutoDeleter() { delete ptr; }
00148 private:
00149     T* ptr;
00150 };
00151 
00152 template <class T>
00153 QAutoDeleter<T>* qAutoDeleter( T* p )
00154 {
00155     return new QAutoDeleter<T>( p );
00156 }
00157 #endif // QINTERNAL_P_H

Generated on Sat Nov 5 16:18:23 2005 for OPIE by  doxygen 1.4.2