Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/qinternal_p.h 3.3.8 edited Jan 11 14:38 $ 00003 ** 00004 ** Definition of some shared interal classes 00005 ** 00006 ** Created : 010427 00007 ** 00008 ** Copyright (C) 1992-2007 Trolltech ASA. 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 ASA 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 #include "qptrlist.h" 00056 #include "qcstring.h" 00057 #include "qiodevice.h" 00058 #endif // QT_H 00059 00060 class QWidget; 00061 class QPainter; 00062 class QPixmap; 00063 00064 class Q_EXPORT QSharedDoubleBuffer 00065 { 00066 public: 00067 enum DoubleBufferFlags { 00068 NoFlags = 0x00, 00069 InitBG = 0x01, 00070 Force = 0x02, 00071 Default = InitBG | Force 00072 }; 00073 typedef uint DBFlags; 00074 00075 QSharedDoubleBuffer( DBFlags f = Default ); 00076 QSharedDoubleBuffer( QWidget* widget, 00077 int x = 0, int y = 0, int w = -1, int h = -1, 00078 DBFlags f = Default ); 00079 QSharedDoubleBuffer( QPainter* painter, 00080 int x = 0, int y = 0, int w = -1, int h = -1, 00081 DBFlags f = Default ); 00082 QSharedDoubleBuffer( QWidget *widget, const QRect &r, DBFlags f = Default ); 00083 QSharedDoubleBuffer( QPainter *painter, const QRect &r, DBFlags f = Default ); 00084 ~QSharedDoubleBuffer(); 00085 00086 bool begin( QWidget* widget, int x = 0, int y = 0, int w = -1, int h = -1 ); 00087 bool begin( QPainter* painter, int x = 0, int y = 0, int w = -1, int h = -1); 00088 bool begin( QWidget* widget, const QRect &r ); 00089 bool begin( QPainter* painter, const QRect &r ); 00090 bool end(); 00091 00092 QPainter* painter() const; 00093 00094 bool isActive() const; 00095 bool isBuffered() const; 00096 void flush(); 00097 00098 static bool isDisabled() { return !dblbufr; } 00099 static void setDisabled( bool off ) { dblbufr = !off; } 00100 00101 static void cleanup(); 00102 00103 private: 00104 enum DoubleBufferState { 00105 Active = 0x0100, 00106 BufferActive = 0x0200, 00107 ExternalPainter = 0x0400 00108 }; 00109 typedef uint DBState; 00110 00111 QPixmap *getPixmap(); 00112 void releasePixmap(); 00113 00114 QWidget *wid; 00115 int rx, ry, rw, rh; 00116 DBFlags flags; 00117 DBState state; 00118 00119 QPainter *p, *external_p; 00120 QPixmap *pix; 00121 00122 static bool dblbufr; 00123 }; 00124 00125 inline bool QSharedDoubleBuffer::begin( QWidget* widget, const QRect &r ) 00126 { return begin( widget, r.x(), r.y(), r.width(), r.height() ); } 00127 00128 inline bool QSharedDoubleBuffer::begin( QPainter *painter, const QRect &r ) 00129 { return begin( painter, r.x(), r.y(), r.width(), r.height() ); } 00130 00131 inline QPainter* QSharedDoubleBuffer::painter() const 00132 { return p; } 00133 00134 inline bool QSharedDoubleBuffer::isActive() const 00135 { return ( state & Active ); } 00136 00137 inline bool QSharedDoubleBuffer::isBuffered() const 00138 { return ( state & BufferActive ); } 00139 00140 00141 class QVirtualDestructor { 00142 public: 00143 virtual ~QVirtualDestructor() {} 00144 }; 00145 00146 template <class T> 00147 class QAutoDeleter : public QVirtualDestructor { 00148 public: 00149 QAutoDeleter( T* p ) : ptr( p ) {} 00150 ~QAutoDeleter() { delete ptr; } 00151 T* data() const { return ptr; } 00152 private: 00153 T* ptr; 00154 }; 00155 00156 template <class T> 00157 T* qAutoDeleterData( QAutoDeleter<T>* ad ) 00158 { 00159 if ( !ad ) 00160 return 0; 00161 return ad->data(); 00162 } 00163 00164 template <class T> 00165 QAutoDeleter<T>* qAutoDeleter( T* p ) 00166 { 00167 return new QAutoDeleter<T>( p ); 00168 } 00169 00170 class Q_EXPORT QMembuf 00171 { 00172 public: 00173 QMembuf(); 00174 ~QMembuf(); 00175 00176 void append( QByteArray *ba ); 00177 void clear(); 00178 00179 bool consumeBytes( Q_ULONG nbytes, char *sink ); 00180 QByteArray readAll(); 00181 bool scanNewline( QByteArray *store ); 00182 bool canReadLine() const; 00183 00184 int ungetch( int ch ); 00185 00186 QIODevice::Offset size() const; 00187 00188 private: 00189 00190 QPtrList<QByteArray> *buf; 00191 QIODevice::Offset _size; 00192 QIODevice::Offset _index; 00193 }; 00194 00195 inline void QMembuf::append( QByteArray *ba ) 00196 { buf->append( ba ); _size += ba->size(); } 00197 00198 inline void QMembuf::clear() 00199 { buf->clear(); _size=0; _index=0; } 00200 00201 inline QByteArray QMembuf::readAll() 00202 { QByteArray ba(_size); consumeBytes(_size,ba.data()); return ba; } 00203 00204 inline bool QMembuf::canReadLine() const 00205 { return ((QMembuf*)this)->scanNewline( 0 ); } 00206 00207 inline QIODevice::Offset QMembuf::size() const 00208 { return _size; } 00209 00210 #endif // QINTERNAL_P_H