summaryrefslogtreecommitdiff
path: root/qmake/include/private/qinternal_p.h
Unidiff
Diffstat (limited to 'qmake/include/private/qinternal_p.h') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/include/private/qinternal_p.h157
1 files changed, 157 insertions, 0 deletions
diff --git a/qmake/include/private/qinternal_p.h b/qmake/include/private/qinternal_p.h
new file mode 100644
index 0000000..ae38695
--- a/dev/null
+++ b/qmake/include/private/qinternal_p.h
@@ -0,0 +1,157 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of some shared interal classes
5**
6** Created : 010427
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the kernel module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#ifndef QINTERNAL_P_H
39#define QINTERNAL_P_H
40
41//
42// W A R N I N G
43// -------------
44//
45// This file is not part of the Qt API. It exists for the convenience
46// of a number of Qt sources files. This header file may change from
47// version to version without notice, or even be removed.
48//
49// We mean it.
50//
51//
52#ifndef QT_H
53#include <qnamespace.h>
54#include <qrect.h>
55#endif // QT_H
56
57class QWidget;
58class QPainter;
59class QPixmap;
60
61class Q_EXPORT QSharedDoubleBuffer
62{
63public:
64 enum DoubleBufferFlags {
65 NoFlags = 0x00,
66 InitBG = 0x01,
67 Force = 0x02,
68 Default = InitBG | Force
69 };
70 typedef uint DBFlags;
71
72 QSharedDoubleBuffer( DBFlags f = Default );
73 QSharedDoubleBuffer( QWidget* widget,
74 int x = 0, int y = 0, int w = -1, int h = -1,
75 DBFlags f = Default );
76 QSharedDoubleBuffer( QPainter* painter,
77 int x = 0, int y = 0, int w = -1, int h = -1,
78 DBFlags f = Default );
79 QSharedDoubleBuffer( QWidget *widget, const QRect &r, DBFlags f = Default );
80 QSharedDoubleBuffer( QPainter *painter, const QRect &r, DBFlags f = Default );
81 ~QSharedDoubleBuffer();
82
83 bool begin( QWidget* widget, int x = 0, int y = 0, int w = -1, int h = -1 );
84 bool begin( QPainter* painter, int x = 0, int y = 0, int w = -1, int h = -1);
85 bool begin( QWidget* widget, const QRect &r );
86 bool begin( QPainter* painter, const QRect &r );
87 bool end();
88
89 QPainter* painter() const;
90
91 bool isActive() const;
92 bool isBuffered() const;
93 void flush();
94
95 static bool isDisabled() { return !dblbufr; }
96 static void setDisabled( bool off ) { dblbufr = !off; }
97
98 static void cleanup();
99
100private:
101 enum DoubleBufferState {
102 Active = 0x0100,
103 BufferActive= 0x0200,
104 ExternalPainter= 0x0400
105 };
106 typedef uint DBState;
107
108 QPixmap *getPixmap();
109 void releasePixmap();
110
111 QWidget *wid;
112 int rx, ry, rw, rh;
113 DBFlags flags;
114 DBState state;
115
116 QPainter *p, *external_p;
117 QPixmap *pix;
118
119 static bool dblbufr;
120};
121
122inline bool QSharedDoubleBuffer::begin( QWidget* widget, const QRect &r )
123{ return begin( widget, r.x(), r.y(), r.width(), r.height() ); }
124
125inline bool QSharedDoubleBuffer::begin( QPainter *painter, const QRect &r )
126{ return begin( painter, r.x(), r.y(), r.width(), r.height() ); }
127
128inline QPainter* QSharedDoubleBuffer::painter() const
129{ return p; }
130
131inline bool QSharedDoubleBuffer::isActive() const
132{ return ( state & Active ); }
133
134inline bool QSharedDoubleBuffer::isBuffered() const
135{ return ( state & BufferActive ); }
136
137
138class QVirtualDestructor {
139public:
140 virtual ~QVirtualDestructor() {}
141};
142
143template <class T>
144class QAutoDeleter : public QVirtualDestructor {
145public:
146 QAutoDeleter( T* p ) : ptr( p ) {}
147 ~QAutoDeleter() { delete ptr; }
148private:
149 T* ptr;
150};
151
152template <class T>
153QAutoDeleter<T>* qAutoDeleter( T* p )
154{
155 return new QAutoDeleter<T>( p );
156}
157#endif // QINTERNAL_P_H