1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the gui module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
36
// This file is not part of the Qt API. It exists for the convenience
37
// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
38
// file may change from version to version without notice, or even be removed.
43
#include <private/qobject_p.h>
47
#include <qsizepolicy.h>
51
#include <qt_windows.h>
55
#include <qx11info_x11.h>
59
#include <qinputcontext.h>
63
// - to minimize memory usage for members that are seldom used.
64
// - top-level widgets have extra extra data to reduce cost further
67
class QWSBackingStore;
73
class QCoreGraphicsPaintEnginePrivate;
83
#ifndef QT_NO_WIDGET_TOPEXTRA
84
QString caption; // widget caption
85
QString iconText; // widget icon text
86
QString role; // widget role
87
QIcon *icon; // widget icon
90
short incw, inch; // size increments
91
ulong fleft, fright, ftop, fbottom; // frame strut
92
#if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
93
uint opacity : 8; // Stores opacity level on Windows/Mac OS X.
96
ulong savedFlags; // Save window flags while showing fullscreen
98
Qt::WFlags savedFlags; // Save widget flags while showing fullscreen
100
short basew, baseh; // base sizes
101
#if defined(Q_WS_X11)
102
WId parentWinId; // parent window Id (valid after reparenting)
103
uint embedded : 1; // window is embedded in another Qt application
104
uint spont_unmapped: 1; // window was spontaneously unmapped
105
uint reserved: 1; // reserved
106
uint dnd : 1; // DND properties installed
107
uint uspos : 1; // User defined position
108
uint ussize : 1; // User defined size
109
QPoint fullScreenOffset;
112
#if defined(Q_WS_MAC)
113
WindowGroupRef group;
117
#if defined(Q_WS_QWS) && !defined (QT_NO_QWS_MANAGER)
118
// QRegion decor_allocated_region; // decoration allocated region
119
QWSManager *qwsManager;
122
QWSBackingStore *backingStore;
123
QPoint backingStoreOffset;
126
bool inPaintTransaction;
128
#if defined(Q_WS_WIN)
129
HICON winIconBig; // internal big Windows icon
130
HICON winIconSmall; // internal small Windows icon
132
QRect normalGeometry; // used by showMin/maximized/FullScreen
136
qint32 minw, minh; // minimum size
137
qint32 maxw, maxh; // maximum size
138
QPointer<QWidget> focus_proxy;
142
QTLWExtra *topextra; // only useful for TLWs
143
#if defined(Q_WS_WIN)
144
QOleDropTarget *dropTarget; // drop target
146
#if defined(Q_WS_X11)
147
WId xDndProxy; // XDND forwarding to embedded windows
149
QRegion mask; // widget mask
153
QSizePolicy size_policy;
155
//bit flags at the end to improve packing
156
#if defined(Q_WS_WIN)
157
uint shown_mode : 8; // widget show mode
159
#if defined(Q_WS_X11)
160
uint children_use_dnd : 1;
161
uint compress_events : 1;
163
uint explicitMinSize : 2;
166
class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
168
Q_DECLARE_PUBLIC(QWidget)
171
explicit QWidgetPrivate(int version = QObjectPrivateVersion);
174
QWExtra *extraData() const;
175
QTLWExtra *topData() const;
177
void init(Qt::WFlags f);
178
void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
180
void createTLExtra();
183
void createSysExtra();
184
void deleteSysExtra();
185
void createTLSysExtra();
186
void deleteTLSysExtra();
187
void updateSystemBackground();
188
void propagatePaletteChange();
190
#ifndef QT_NO_PALETTE
191
void setPalette_helper(const QPalette &);
192
void resolvePalette();
197
void stackUnder_sys(QWidget *);
199
void setFont_helper(const QFont &);
202
void setLayoutDirection_helper(Qt::LayoutDirection);
203
void resolveLayoutDirection();
205
bool isBackgroundInherited() const;
206
void updateInheritedBackground();
207
void updatePropagatedBackground(const QRegion * = 0);
209
void setUpdatesEnabled_helper(bool );
211
void composeBackground(const QRect &);
213
QRect clipRect() const;
214
bool hasComplexClipRegion() const;
215
bool isFullyOpaque() const;
220
CloseWithSpontaneousEvent
222
bool close_helper(CloseMode mode);
224
bool compositeEvent(QEvent *e);
225
void setWindowIcon_sys();
227
void focusInputContext();
228
void unfocusInputContext();
230
#if defined(Q_WS_X11)
231
void checkChildrenDnd();
232
QRegion invalidated_region;
234
void setWindowRole(const char *role);
237
#if defined (Q_WS_WIN)
238
void reparentChildren();
241
void reparentFocusWidgets(QWidget *oldtlw);
243
static int pointToRect(const QPoint &p, const QRect &r);
246
void showChildren(bool spontaneous);
247
void hideChildren(bool spontaneous);
248
void setParent_sys(QWidget *parent, Qt::WFlags);
249
void deactivateWidgetCleanup();
250
void setGeometry_sys(int, int, int, int, bool);
251
void show_recursive();
256
void setEnabled_helper(bool);
257
bool setAcceptDrops_sys(bool);
258
void setAcceptDrops_helper(bool);
259
void updateFrameStrut() const;
260
void setWindowIconText_sys(const QString &cap);
261
void setWindowIconText_helper(const QString &cap);
262
void setWindowTitle_sys(const QString &cap);
264
void setWindowModified_sys(bool b);
266
void setWindowTitle_helper(const QString &cap);
268
void setConstraints_sys();
270
#if defined(Q_WS_QWS)
271
// void updateRequestedRegion(const QPoint &gpos);
272
// QRegion requestedRegion() const;
273
QRegion localRequestedRegion() const;
274
void requestWindowRegion(const QRegion &r);
276
void doPaint(const QRegion &rgn);
278
void bltToScreen(const QRegion &globalrgn);
279
void paintHierarchy(const QRegion &rgn );
281
void updateCursor(const QRegion &r) const;
283
friend class QWSManager;
284
friend class QWSManagerPrivate;
285
friend class QDecoration;
288
static int instanceCounter; // Current number of widget instances
289
static int maxInstances; // Maximum number of widget instances
295
QWidget *focus_child;
296
QList<QAction*> actions;
300
#if !defined(QT_NO_IM)
301
QPointer<QInputContext> ic;
303
static QWidgetMapper *mapper;
305
int leftmargin, topmargin, rightmargin, bottommargin;
306
// ### TODO: reorganize private/extra/topextra to save memory
307
QPointer<QWidget> compositeChildGrab;
308
QString toolTip, statusTip, whatsThis;
309
QString accessibleName, accessibleDescription;
311
#ifndef QT_NO_PALETTE
312
QPalette::ColorRole fg_role : 8;
313
QPalette::ColorRole bg_role : 8;
315
uint high_attributes[2]; // the low ones are in QWidget::widget_attributes
317
#if defined(Q_WS_X11)
321
#if defined(Q_WS_MAC)
322
enum PaintChildrenOPs {
328
EventHandlerRef window_event;
329
bool qt_mac_dnd_event(uint, DragRef);
330
void toggleDrawers(bool);
331
//mac event functions
332
static bool qt_create_root_win();
333
static void qt_clean_root_win();
334
static bool qt_recreate_root_win();
335
static bool qt_mac_update_sizer(QWidget *, int);
336
static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
337
static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
338
static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
340
//these are here just for code compat (HIViews)
343
inline QRegion clippedRegion(bool = true) { return clp; }
344
inline uint clippedSerial(bool =true) { return clp_serial; }
348
#if defined(Q_WS_X11) || defined (Q_WS_WIN) || defined(Q_WS_MAC)
349
void setWSGeometry(bool dontShow=false);
351
inline QPoint mapToWS(const QPoint &p) const
352
{ return p - data.wrect.topLeft(); }
354
inline QPoint mapFromWS(const QPoint &p) const
355
{ return p + data.wrect.topLeft(); }
357
inline QRect mapToWS(const QRect &r) const
358
{ QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
360
inline QRect mapFromWS(const QRect &r) const
361
{ QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
364
QPaintEngine *extraPaintEngine;
366
mutable const QMetaObject *polished;
369
inline QWExtra *QWidgetPrivate::extraData() const
374
inline QTLWExtra *QWidgetPrivate::topData() const
376
const_cast<QWidgetPrivate *>(this)->createTLExtra();
377
return extra->topextra;
380
#endif // QWIDGET_P_H