~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/kernel/qwidget_p.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the gui module of the Qt Toolkit.
 
6
**
 
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.
 
10
**
 
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.
 
15
**
 
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.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
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.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QWIDGET_P_H
 
30
#define QWIDGET_P_H
 
31
 
 
32
//
 
33
//  W A R N I N G
 
34
//  -------------
 
35
//
 
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.
 
39
//
 
40
// We mean it.
 
41
//
 
42
 
 
43
#include <private/qobject_p.h>
 
44
 
 
45
#include <qrect.h>
 
46
#include <qregion.h>
 
47
#include <qsizepolicy.h>
 
48
#include <qwidget.h>
 
49
 
 
50
#ifdef Q_WS_WIN
 
51
#include <qt_windows.h>
 
52
#endif // Q_WS_WIN
 
53
 
 
54
#ifdef Q_WS_X11
 
55
#include <qx11info_x11.h>
 
56
#endif
 
57
 
 
58
#if defined(Q_WS_QWS)
 
59
#include <qinputcontext.h>
 
60
#endif
 
61
 
 
62
// Extra QWidget data
 
63
//  - to minimize memory usage for members that are seldom used.
 
64
//  - top-level widgets have extra extra data to reduce cost further
 
65
#if defined(Q_WS_QWS)
 
66
class QWSManager;
 
67
class QWSBackingStore;
 
68
#endif
 
69
#if defined(Q_WS_WIN)
 
70
class QOleDropTarget;
 
71
#endif
 
72
#if defined(Q_WS_MAC)
 
73
class QCoreGraphicsPaintEnginePrivate;
 
74
#endif
 
75
class QPaintEngine;
 
76
class QPixmap;
 
77
 
 
78
#ifndef QT_NO_STYLE
 
79
class QStyle;
 
80
#endif
 
81
 
 
82
struct QTLWExtra {
 
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
 
88
    QPixmap *iconPixmap;
 
89
#endif
 
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.
 
94
#endif
 
95
#if defined(Q_WS_WIN)
 
96
    ulong savedFlags; // Save window flags while showing fullscreen
 
97
#else
 
98
    Qt::WFlags savedFlags; // Save widget flags while showing fullscreen
 
99
#endif
 
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;
 
110
    QBitmap *iconMask;
 
111
#endif
 
112
#if defined(Q_WS_MAC)
 
113
    WindowGroupRef group;
 
114
    uint is_moved: 1;
 
115
    uint resizer : 4;
 
116
#endif
 
117
#if defined(Q_WS_QWS) && !defined (QT_NO_QWS_MANAGER)
 
118
//    QRegion decor_allocated_region; // decoration allocated region
 
119
    QWSManager *qwsManager;
 
120
#endif
 
121
#if defined Q_WS_QWS
 
122
    QWSBackingStore *backingStore;
 
123
    QPoint backingStoreOffset;
 
124
 
 
125
    QRegion dirtyRegion;
 
126
    bool inPaintTransaction;
 
127
#endif
 
128
#if defined(Q_WS_WIN)
 
129
    HICON winIconBig; // internal big Windows icon
 
130
    HICON winIconSmall; // internal small Windows icon
 
131
#endif
 
132
    QRect normalGeometry; // used by showMin/maximized/FullScreen
 
133
};
 
134
 
 
135
struct QWExtra {
 
136
    qint32 minw, minh; // minimum size
 
137
    qint32 maxw, maxh; // maximum size
 
138
    QPointer<QWidget> focus_proxy;
 
139
#ifndef QT_NO_CURSOR
 
140
    QCursor *curs;
 
141
#endif
 
142
    QTLWExtra *topextra; // only useful for TLWs
 
143
#if defined(Q_WS_WIN)
 
144
    QOleDropTarget *dropTarget; // drop target
 
145
#endif
 
146
#if defined(Q_WS_X11)
 
147
    WId xDndProxy; // XDND forwarding to embedded windows
 
148
#endif
 
149
    QRegion mask; // widget mask
 
150
#ifndef QT_NO_STYLE
 
151
    QStyle* style;
 
152
#endif
 
153
    QSizePolicy size_policy;
 
154
 
 
155
//bit flags at the end to improve packing
 
156
#if defined(Q_WS_WIN)
 
157
    uint shown_mode : 8; // widget show mode
 
158
#endif
 
159
#if defined(Q_WS_X11)
 
160
    uint children_use_dnd : 1;
 
161
    uint compress_events : 1;
 
162
#endif
 
163
    uint explicitMinSize : 2;
 
164
};
 
165
 
 
166
class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
 
167
{
 
168
    Q_DECLARE_PUBLIC(QWidget)
 
169
 
 
170
public:
 
171
    explicit QWidgetPrivate(int version = QObjectPrivateVersion);
 
172
    ~QWidgetPrivate();
 
173
 
 
174
    QWExtra *extraData() const;
 
175
    QTLWExtra *topData() const;
 
176
 
 
177
    void init(Qt::WFlags f);
 
178
    void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
 
179
 
 
180
    void createTLExtra();
 
181
    void createExtra();
 
182
    void deleteExtra();
 
183
    void createSysExtra();
 
184
    void deleteSysExtra();
 
185
    void createTLSysExtra();
 
186
    void deleteTLSysExtra();
 
187
    void updateSystemBackground();
 
188
    void propagatePaletteChange();
 
189
 
 
190
#ifndef QT_NO_PALETTE
 
191
    void setPalette_helper(const QPalette &);
 
192
    void resolvePalette();
 
193
#endif
 
194
 
 
195
    void raise_sys();
 
196
    void lower_sys();
 
197
    void stackUnder_sys(QWidget *);
 
198
 
 
199
    void setFont_helper(const QFont &);
 
200
    void resolveFont();
 
201
 
 
202
    void setLayoutDirection_helper(Qt::LayoutDirection);
 
203
    void resolveLayoutDirection();
 
204
 
 
205
    bool isBackgroundInherited() const;
 
206
    void updateInheritedBackground();
 
207
    void updatePropagatedBackground(const QRegion * = 0);
 
208
 
 
209
    void setUpdatesEnabled_helper(bool );
 
210
 
 
211
    void composeBackground(const QRect &);
 
212
 
 
213
    QRect clipRect() const;
 
214
    bool hasComplexClipRegion() const;
 
215
    bool isFullyOpaque() const;
 
216
 
 
217
    enum CloseMode {
 
218
        CloseNoEvent,
 
219
        CloseWithEvent,
 
220
        CloseWithSpontaneousEvent
 
221
    };
 
222
    bool close_helper(CloseMode mode);
 
223
 
 
224
    bool compositeEvent(QEvent *e);
 
225
    void setWindowIcon_sys();
 
226
 
 
227
    void focusInputContext();
 
228
    void unfocusInputContext();
 
229
 
 
230
#if defined(Q_WS_X11)
 
231
    void checkChildrenDnd();
 
232
    QRegion invalidated_region;
 
233
 
 
234
    void setWindowRole(const char *role);
 
235
#endif
 
236
 
 
237
#if defined (Q_WS_WIN)
 
238
    void reparentChildren();
 
239
#endif
 
240
 
 
241
    void reparentFocusWidgets(QWidget *oldtlw);
 
242
 
 
243
    static int pointToRect(const QPoint &p, const QRect &r);
 
244
 
 
245
    void setWinId(WId);
 
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();
 
252
    void show_helper();
 
253
    void show_sys();
 
254
    void hide_sys();
 
255
    void hide_helper();
 
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);
 
263
#ifdef Q_WS_MAC
 
264
    void setWindowModified_sys(bool b);
 
265
#endif
 
266
    void setWindowTitle_helper(const QString &cap);
 
267
 
 
268
    void setConstraints_sys();
 
269
 
 
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);
 
275
 
 
276
    void doPaint(const QRegion &rgn);
 
277
 
 
278
    void bltToScreen(const QRegion &globalrgn);
 
279
    void paintHierarchy(const QRegion &rgn );
 
280
#ifndef QT_NO_CURSOR
 
281
    void updateCursor(const QRegion &r) const;
 
282
#endif
 
283
    friend class QWSManager;
 
284
    friend class QWSManagerPrivate;
 
285
    friend class QDecoration;
 
286
#endif
 
287
 
 
288
    static int instanceCounter; // Current number of widget instances
 
289
    static int maxInstances; // Maximum number of widget instances
 
290
 
 
291
    QWidgetData data;
 
292
 
 
293
    QWExtra *extra;
 
294
    QWidget *focus_next;
 
295
    QWidget *focus_child;
 
296
    QList<QAction*> actions;
 
297
#ifndef QT_NO_LAYOUT
 
298
    QLayout *layout;
 
299
#endif
 
300
#if !defined(QT_NO_IM)
 
301
    QPointer<QInputContext> ic;
 
302
#endif
 
303
    static QWidgetMapper *mapper;
 
304
 
 
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;
 
310
 
 
311
#ifndef QT_NO_PALETTE
 
312
    QPalette::ColorRole fg_role : 8;
 
313
    QPalette::ColorRole bg_role : 8;
 
314
#endif
 
315
    uint high_attributes[2]; // the low ones are in QWidget::widget_attributes
 
316
    Qt::HANDLE hd;
 
317
#if defined(Q_WS_X11)
 
318
    QX11Info xinfo;
 
319
    Qt::HANDLE picture;
 
320
#endif
 
321
#if defined(Q_WS_MAC)
 
322
    enum PaintChildrenOPs {
 
323
        PC_None = 0x00,
 
324
        PC_Now = 0x01,
 
325
        PC_NoPaint = 0x04,
 
326
        PC_Later = 0x10
 
327
    };
 
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);
 
339
 
 
340
    //these are here just for code compat (HIViews)
 
341
    QRegion clp;
 
342
    uint clp_serial : 8;
 
343
    inline QRegion clippedRegion(bool = true) { return clp; }
 
344
    inline uint clippedSerial(bool =true) { return clp_serial; }
 
345
    CGContextRef cg_hd;
 
346
#endif
 
347
 
 
348
#if defined(Q_WS_X11) || defined (Q_WS_WIN) || defined(Q_WS_MAC)
 
349
    void setWSGeometry(bool dontShow=false);
 
350
 
 
351
    inline QPoint mapToWS(const QPoint &p) const
 
352
    { return p - data.wrect.topLeft(); }
 
353
 
 
354
    inline QPoint mapFromWS(const QPoint &p) const
 
355
    { return p + data.wrect.topLeft(); }
 
356
 
 
357
    inline QRect mapToWS(const QRect &r) const
 
358
    { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
 
359
 
 
360
    inline QRect mapFromWS(const QRect &r) const
 
361
    { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
 
362
#endif
 
363
 
 
364
    QPaintEngine *extraPaintEngine;
 
365
 
 
366
    mutable const QMetaObject *polished;
 
367
};
 
368
 
 
369
inline QWExtra *QWidgetPrivate::extraData() const
 
370
{
 
371
    return extra;
 
372
}
 
373
 
 
374
inline QTLWExtra *QWidgetPrivate::topData() const
 
375
{
 
376
    const_cast<QWidgetPrivate *>(this)->createTLExtra();
 
377
    return extra->topextra;
 
378
}
 
379
 
 
380
#endif // QWIDGET_P_H