source: trunk/src/gui/kernel/qapplication_pm.cpp@ 95

Last change on this file since 95 was 95, checked in by Dmitry A. Kuminov, 16 years ago

gui: Added OS/2 stubs for platform-specific parts of all key GUI classes. Non-key classes are temporarily disabled with QT_NO_ defines.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Date Revision Author Id
File size: 13.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** Copyright (C) 2009 netlabs.org. OS/2 parts.
7**
8** This file is part of the QtGui module of the Qt Toolkit.
9**
10** $QT_BEGIN_LICENSE:LGPL$
11** Commercial Usage
12** Licensees holding valid Qt Commercial licenses may use this file in
13** accordance with the Qt Commercial License Agreement provided with the
14** Software or, alternatively, in accordance with the terms contained in
15** a written agreement between you and Nokia.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Nokia gives you certain
26** additional rights. These rights are described in the Nokia Qt LGPL
27** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
28** package.
29**
30** GNU General Public License Usage
31** Alternatively, this file may be used under the terms of the GNU
32** General Public License version 3.0 as published by the Free Software
33** Foundation and appearing in the file LICENSE.GPL included in the
34** packaging of this file. Please review the following information to
35** ensure the GNU General Public License version 3.0 requirements will be
36** met: http://www.gnu.org/copyleft/gpl.html.
37**
38** If you are unsure which license is appropriate for your use, please
39** contact the sales department at [email protected].
40** $QT_END_LICENSE$
41**
42****************************************************************************/
43
44#include "qt_os2.h"
45
46#include "qapplication.h"
47#include "qapplication_p.h"
48
49#include "qwidget.h"
50#include "qpointer.h"
51#include "qcolormap.h"
52#include "qpixmapcache.h"
53
54#include "qset.h"
55
56#include "qwidget_p.h"
57#include "qkeymapper_p.h"
58#include "qcursor_p.h"
59
60QT_BEGIN_NAMESPACE
61
62/*****************************************************************************
63 Internal variables and functions
64 *****************************************************************************/
65
66static HWND curWin = 0; // current window
67static HPS displayPS = 0; // display presentation space
68
69static bool replayPopupMouseEvent = false; // replay handling when popups close
70
71// ignore the next release event if return from a modal widget
72static bool ignoreNextMouseReleaseEvent = false;
73
74#if defined(QT_DEBUG)
75static bool appNoGrab = false; // mouse/keyboard grabbing
76#endif
77
78static bool app_do_modal = false; // modal mode
79extern QWidgetList *qt_modal_stack;
80extern QDesktopWidget *qt_desktopWidget;
81static QPointer<QWidget> popupButtonFocus;
82static bool qt_try_modal(QWidget *, QMSG *, int& ret);
83
84QWidget *qt_button_down = 0; // widget got last button-down
85QPointer<QWidget> qt_last_mouse_receiver = 0;
86
87static HWND autoCaptureWnd = NULLHANDLE;
88static void setAutoCapture(HWND); // automatic capture
89static void releaseAutoCapture();
90
91static void unregWinClasses();
92
93extern QCursor *qt_grab_cursor();
94
95extern "C" MRESULT EXPENTRY QtWndProc(HWND, ULONG, MPARAM, MPARAM);
96
97class QETWidget : public QWidget // event translator widget
98{
99public:
100 QWExtra *xtra() { return d_func()->extraData(); }
101 QTLWExtra *topData() { return d_func()->topData(); }
102// @todo later
103// QTLWExtra *maybeTopData() { return d_func()->maybeTopData(); }
104// void syncBackingStore(const QRegion &rgn) { d_func()->syncBackingStore(rgn); }
105// void syncBackingStore() { d_func()->syncBackingStore(); }
106// QWidgetData *dataPtr() { return data; }
107// QWidgetPrivate *dptr() { return d_func(); }
108// QRect frameStrut() const { return d_func()->frameStrut(); }
109// bool winEvent(QMSG *m, long *r) { return QWidget::winEvent(m, r); }
110// void markFrameStrutDirty() { data->fstrut_dirty = 1; }
111// bool translateMouseEvent(const MSG &msg);
112// bool translateWheelEvent(const MSG &msg);
113// bool translatePaintEvent(const MSG &msg);
114// bool translateConfigEvent(const MSG &msg);
115// bool translateCloseEvent(const MSG &msg);
116// void repolishStyle(QStyle &style);
117// inline void showChildren(bool spontaneous) { d_func()->showChildren(spontaneous); }
118// inline void hideChildren(bool spontaneous) { d_func()->hideChildren(spontaneous); }
119// inline uint testWindowState(uint teststate){ return dataPtr()->window_state & teststate; }
120// inline void forceUpdate() {
121// QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
122// if (tlwExtra && tlwExtra->backingStore)
123// tlwExtra->backingStore->markDirty(rect(), this, true, true);
124// }
125};
126
127static void qt_set_pm_resources()
128{
129 // @todo later: take colors, fonts, etc. from the system theme
130};
131
132/*****************************************************************************
133 qt_init() - initializes Qt for PM
134 *****************************************************************************/
135
136void qt_init(QApplicationPrivate *priv, int)
137{
138
139 int argc = priv->argc;
140 char **argv = priv->argv;
141 int i, j;
142
143 // Get command line params
144
145 j = argc ? 1 : 0;
146 for (i=1; i<argc; i++) {
147 if (argv[i] && *argv[i] != '-') {
148 argv[j++] = argv[i];
149 continue;
150 }
151#if defined(QT_DEBUG)
152 if (qstrcmp(argv[i], "-nograb") == 0)
153 appNoGrab = !appNoGrab;
154 else
155#endif // QT_DEBUG
156 argv[j++] = argv[i];
157 }
158 if(j < priv->argc) {
159 priv->argv[j] = 0;
160 priv->argc = j;
161 }
162
163 // initialize key mapper
164 QKeyMapper::changeKeyboard();
165
166 QColormap::initialize();
167 QFont::initialize();
168#ifndef QT_NO_CURSOR
169 QCursorData::initialize();
170#endif
171 qApp->setObjectName(priv->appName());
172
173 // default font
174 QApplicationPrivate::setSystemFont(
175 QFont(QLatin1String("System Proportional"), 10));
176
177 // QFont::locale_init(); ### Uncomment when it does something on OS/2
178
179 if (QApplication::desktopSettingsAware())
180 qt_set_pm_resources();
181}
182
183/*****************************************************************************
184 qt_cleanup() - cleans up when the application is finished
185 *****************************************************************************/
186
187void qt_cleanup()
188{
189 unregWinClasses();
190 QPixmapCache::clear();
191
192#ifndef QT_NO_CURSOR
193 QCursorData::cleanup();
194#endif
195 QFont::cleanup();
196 QColormap::cleanup();
197
198 if (displayPS) {
199 WinReleasePS(displayPS);
200 displayPS = 0;
201 }
202}
203
204/*****************************************************************************
205 Platform specific global and internal functions
206 *****************************************************************************/
207
208Q_GUI_EXPORT HPS qt_display_dc()
209{
210 Q_ASSERT(qApp && qApp->thread() == QThread::currentThread());
211 if (!displayPS)
212 displayPS = WinGetScreenPS(HWND_DESKTOP);
213 return displayPS;
214}
215
216// application no-grab option
217bool qt_nograb()
218{
219#if defined(QT_DEBUG)
220 return appNoGrab;
221#else
222 return false;
223#endif
224}
225
226typedef QSet<QString> WinClassNameHash;
227Q_GLOBAL_STATIC(WinClassNameHash, winclassNames)
228
229// register window class
230const QString qt_reg_winclass(QWidget *w)
231{
232 int flags = w->windowFlags();
233 int type = flags & Qt::WindowType_Mask;
234
235 QString cname;
236 ULONG style = 0;
237
238 if (type == Qt::Window) {
239 // this class is for frame window clients when WC_FRAME is used.
240 cname = QLatin1String("QWindow");
241 style |= CS_MOVENOTIFY;
242 } else if (type == Qt::Popup || type == Qt::Tool || type == Qt::ToolTip) {
243 cname = QLatin1String("QPopup");
244 // @todo do we really want SAVEBITS here?
245 style |= CS_SAVEBITS;
246 } else {
247 cname = QLatin1String("QWidget");
248 }
249
250 if (winclassNames()->contains(cname)) // already registered in our list
251 return cname;
252
253 // QT_EXTRAWINDATASIZE is defined in qwindowdefs_pm.h
254 WinRegisterClass(0, cname.toLatin1(), QtWndProc, style, QT_EXTRAWINDATASIZE);
255
256 winclassNames()->insert(cname);
257 return cname;
258}
259
260static void unregWinClasses()
261{
262 // there is no need to unregister private window classes -- it is done
263 // automatically upon process termination.
264 winclassNames()->clear();
265}
266
267/*****************************************************************************
268 Safe configuration (move,resize,setGeometry) mechanism to avoid
269 recursion when processing messages.
270 *****************************************************************************/
271
272/*****************************************************************************
273 GUI event dispatcher
274 *****************************************************************************/
275
276void QApplicationPrivate::createEventDispatcher()
277{
278 // @todo implement
279}
280
281/*****************************************************************************
282 Platform specific QApplication members
283 *****************************************************************************/
284
285void QApplicationPrivate::initializeWidgetPaletteHash()
286{
287}
288
289QString QApplicationPrivate::appName() const
290{
291 return QCoreApplicationPrivate::appName();
292}
293
294void QApplication::setCursorFlashTime(int msecs)
295{
296 // @todo implement
297}
298
299
300int QApplication::cursorFlashTime()
301{
302 // @todo implement
303 return 0;
304}
305
306void QApplication::setDoubleClickInterval(int ms)
307{
308 // @todo implement
309}
310
311int QApplication::doubleClickInterval()
312{
313 // @todo implement
314 return 0;
315}
316
317
318void QApplication::setKeyboardInputInterval(int ms)
319{
320 // @todo implement
321}
322
323int QApplication::keyboardInputInterval()
324{
325 // @todo implement
326 return 0;
327}
328
329#ifndef QT_NO_WHEELEVENT
330void QApplication::setWheelScrollLines(int n)
331{
332 // @todo implement
333}
334
335int QApplication::wheelScrollLines()
336{
337 // @todo implement
338 return 0;
339}
340#endif //QT_NO_WHEELEVENT
341
342void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
343{
344 // @todo implement
345}
346
347bool QApplication::isEffectEnabled(Qt::UIEffect effect)
348{
349 // @todo implement
350 return false;
351}
352
353void QApplication::beep()
354{
355 // @todo implement
356}
357
358void QApplication::alert(QWidget *widget, int duration)
359{
360 // @todo implement
361}
362
363/*****************************************************************************
364 QApplication cursor stack
365 *****************************************************************************/
366
367#ifndef QT_NO_CURSOR
368
369void QApplication::setOverrideCursor(const QCursor &cursor)
370{
371 // @todo implement
372}
373
374void QApplication::restoreOverrideCursor()
375{
376 // @todo implement
377}
378
379#endif
380
381/*****************************************************************************
382 Routines to find a Qt widget from a screen position
383 *****************************************************************************/
384
385QWidget *QApplication::topLevelAt(const QPoint &pos)
386{
387 // @todo implement
388 return 0;
389}
390
391/*****************************************************************************
392 Main event loop
393 *****************************************************************************/
394
395// QtWndProc() receives all messages from the main event loop
396
397extern "C"
398MRESULT EXPENTRY QtWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
399{
400 // @todo implement
401 return FALSE;
402}
403
404/*****************************************************************************
405 Modal widgets; We have implemented our own modal widget mechanism
406 to get total control.
407 A modal widget without a parent becomes application-modal.
408 A modal widget with a parent becomes modal to its parent and grandparents..
409
410 QApplicationPrivate::enterModal()
411 Enters modal state
412 Arguments:
413 QWidget *widget A modal widget
414
415 QApplicationPrivate::leaveModal()
416 Leaves modal state for a widget
417 Arguments:
418 QWidget *widget A modal widget
419 *****************************************************************************/
420
421bool QApplicationPrivate::modalState()
422{
423 // @todo implement
424 return false;
425}
426
427void QApplicationPrivate::enterModal_sys(QWidget *widget)
428{
429 // @todo implement
430}
431
432void QApplicationPrivate::leaveModal_sys(QWidget *widget)
433{
434 // @todo implement
435}
436
437/*****************************************************************************
438 Popup widget mechanism
439
440 openPopup()
441 Adds a widget to the list of popup widgets
442 Arguments:
443 QWidget *widget The popup widget to be added
444
445 closePopup()
446 Removes a widget from the list of popup widgets
447 Arguments:
448 QWidget *widget The popup widget to be removed
449 *****************************************************************************/
450
451void QApplicationPrivate::openPopup(QWidget *popup)
452{
453 // @todo implement
454}
455
456void QApplicationPrivate::closePopup(QWidget *popup)
457{
458 // @todo implement
459}
460
461/*****************************************************************************
462 Event translation; translates PM events to Qt events
463 *****************************************************************************/
464
465QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.