author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 10:37:55 +0300 | |
changeset 33 | 3e2da88830cd |
parent 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifdef Q_WS_WINCE |
|
43 |
||
44 |
#include "qguifunctions_wince.h" |
|
45 |
||
46 |
QT_BEGIN_NAMESPACE |
|
47 |
||
48 |
const QString qt_reg_winclass(QWidget *w); // defined in qapplication_win.cpp |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
49 |
extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM); |
0 | 50 |
|
51 |
//#define TABLET_DEBUG |
|
52 |
#define PACKETDATA (PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE \ |
|
53 |
| PK_ORIENTATION | PK_CURSOR | PK_Z) |
|
54 |
#define PACKETMODE 0 |
|
55 |
||
56 |
typedef HCTX (API *PtrWTOpen)(HWND, LPLOGCONTEXT, BOOL); |
|
57 |
typedef BOOL (API *PtrWTClose)(HCTX); |
|
58 |
typedef UINT (API *PtrWTInfo)(UINT, UINT, LPVOID); |
|
59 |
typedef BOOL (API *PtrWTEnable)(HCTX, BOOL); |
|
60 |
typedef BOOL (API *PtrWTOverlap)(HCTX, BOOL); |
|
61 |
typedef int (API *PtrWTPacketsGet)(HCTX, int, LPVOID); |
|
62 |
typedef BOOL (API *PtrWTGet)(HCTX, LPLOGCONTEXT); |
|
63 |
typedef int (API *PtrWTQueueSizeGet)(HCTX); |
|
64 |
typedef BOOL (API *PtrWTQueueSizeSet)(HCTX, int); |
|
65 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
66 |
#ifndef QT_NO_TABLETEVENT |
0 | 67 |
static void qt_tablet_init_wce(); |
68 |
static void qt_tablet_cleanup_wce(); |
|
69 |
||
70 |
static void qt_tablet_init_wce() { |
|
71 |
static bool firstTime = true; |
|
72 |
if (!firstTime) |
|
73 |
return; |
|
74 |
firstTime = false; |
|
75 |
qt_tablet_widget = new QWidget(0); |
|
76 |
qt_tablet_widget->createWinId(); |
|
77 |
qt_tablet_widget->setObjectName(QLatin1String("Qt internal tablet widget")); |
|
78 |
LOGCONTEXT lcMine; |
|
79 |
qAddPostRoutine(qt_tablet_cleanup_wce); |
|
80 |
struct tagAXIS tpOri[3]; |
|
81 |
if (ptrWTInfo && ptrWTOpen && ptrWTQueueSizeGet && ptrWTQueueSizeSet) { |
|
82 |
// make sure we have WinTab |
|
83 |
if (!ptrWTInfo(0, 0, NULL)) { |
|
84 |
#ifdef TABLET_DEBUG |
|
85 |
qWarning("QWidget: Wintab services not available"); |
|
86 |
#endif |
|
87 |
return; |
|
88 |
} |
|
89 |
||
90 |
// some tablets don't support tilt, check if it is possible, |
|
91 |
qt_tablet_tilt_support = ptrWTInfo(WTI_DEVICES, DVC_ORIENTATION, &tpOri); |
|
92 |
if (qt_tablet_tilt_support) { |
|
93 |
// check for azimuth and altitude |
|
94 |
qt_tablet_tilt_support = tpOri[0].axResolution && tpOri[1].axResolution; |
|
95 |
} |
|
96 |
// build our context from the default context |
|
97 |
ptrWTInfo(WTI_DEFSYSCTX, 0, &lcMine); |
|
98 |
// Go for the raw coordinates, the tablet event will return good stuff |
|
99 |
lcMine.lcOptions |= CXO_MESSAGES | CXO_CSRMESSAGES; |
|
100 |
lcMine.lcPktData = PACKETDATA; |
|
101 |
lcMine.lcPktMode = PACKETMODE; |
|
102 |
lcMine.lcMoveMask = PACKETDATA; |
|
103 |
lcMine.lcOutOrgX = 0; |
|
104 |
lcMine.lcOutExtX = lcMine.lcInExtX; |
|
105 |
lcMine.lcOutOrgY = 0; |
|
106 |
lcMine.lcOutExtY = -lcMine.lcInExtY; |
|
107 |
qt_tablet_context = ptrWTOpen(qt_tablet_widget->winId(), &lcMine, true); |
|
108 |
#ifdef TABLET_DEBUG |
|
109 |
qDebug("Tablet is %p", qt_tablet_context); |
|
110 |
#endif |
|
111 |
if (!qt_tablet_context) { |
|
112 |
#ifdef TABLET_DEBUG |
|
113 |
qWarning("QWidget: Failed to open the tablet"); |
|
114 |
#endif |
|
115 |
return; |
|
116 |
} |
|
117 |
// Set the size of the Packet Queue to the correct size... |
|
118 |
int currSize = ptrWTQueueSizeGet(qt_tablet_context); |
|
119 |
if (!ptrWTQueueSizeSet(qt_tablet_context, QT_TABLET_NPACKETQSIZE)) { |
|
120 |
// Ideally one might want to use a smaller |
|
121 |
// multiple, but for now, since we managed to destroy |
|
122 |
// the existing Q with the previous call, set it back |
|
123 |
// to the other size, which should work. If not, |
|
124 |
// there will be trouble. |
|
125 |
if (!ptrWTQueueSizeSet(qt_tablet_context, currSize)) { |
|
126 |
Q_ASSERT_X(0, "Qt::Internal", "There is no packet queue for" |
|
127 |
" the tablet. The tablet will not work"); |
|
128 |
} |
|
129 |
} |
|
130 |
} |
|
131 |
} |
|
132 |
||
133 |
static void qt_tablet_cleanup_wce() { |
|
134 |
if (ptrWTClose) |
|
135 |
ptrWTClose(qt_tablet_context); |
|
136 |
delete qt_tablet_widget; |
|
137 |
qt_tablet_widget = 0; |
|
138 |
} |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
139 |
#endif // QT_NO_TABLETEVENT |
0 | 140 |
|
141 |
||
142 |
// The internal qWinRequestConfig, defined in qapplication_win.cpp, stores move, |
|
143 |
// resize and setGeometry requests for a widget that is already |
|
144 |
// processing a config event. The purpose is to avoid recursion. |
|
145 |
// |
|
146 |
void qWinRequestConfig(WId, int, int, int, int, int); |
|
147 |
||
148 |
void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) { |
|
149 |
Q_Q(QWidget); |
|
150 |
static int sw = -1, sh = -1; |
|
151 |
||
152 |
Qt::WindowType type = q->windowType(); |
|
153 |
Qt::WindowFlags flags = data.window_flags; |
|
154 |
||
155 |
bool topLevel = (flags & Qt::Window); |
|
156 |
bool popup = (type == Qt::Popup); |
|
157 |
bool dialog = (type == Qt::Dialog |
|
158 |
|| type == Qt::Sheet |
|
159 |
|| (flags & Qt::MSWindowsFixedSizeDialogHint)); |
|
160 |
bool desktop = (type == Qt::Desktop); |
|
161 |
bool tool = (type == Qt::Tool || type == Qt::Drawer); |
|
162 |
||
163 |
HINSTANCE appinst = qWinAppInst(); |
|
164 |
HWND parentw, destroyw = 0; |
|
165 |
WId id; |
|
166 |
||
167 |
QString windowClassName = qt_reg_winclass(q); |
|
168 |
||
169 |
if (!window) // always initialize |
|
170 |
initializeWindow = true; |
|
171 |
||
172 |
if (popup) |
|
173 |
flags |= Qt::WindowStaysOnTopHint; // a popup stays on top |
|
174 |
||
175 |
if (flags & (Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowContextHelpButtonHint)) { |
|
176 |
flags |= Qt::WindowSystemMenuHint; |
|
177 |
flags |= Qt::WindowTitleHint; |
|
178 |
flags &= ~Qt::FramelessWindowHint; |
|
179 |
} |
|
180 |
||
181 |
if (sw < 0) { // get the (primary) screen size |
|
182 |
sw = GetSystemMetrics(SM_CXSCREEN); |
|
183 |
sh = GetSystemMetrics(SM_CYSCREEN); |
|
184 |
} |
|
185 |
||
186 |
if (desktop) { // desktop widget |
|
187 |
popup = false; // force this flags off |
|
188 |
data.crect.setRect(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); |
|
189 |
} |
|
190 |
||
191 |
parentw = q->parentWidget() ? q->parentWidget()->effectiveWinId() : 0; |
|
192 |
||
193 |
QString title; |
|
194 |
int style = WS_CHILD; |
|
195 |
int exsty = WS_EX_NOPARENTNOTIFY; |
|
196 |
||
197 |
if (topLevel) { |
|
198 |
if (!(flags & Qt::FramelessWindowHint) && !tool && !q->testAttribute(Qt::WA_DontShowOnScreen)) |
|
199 |
style = (WS_OVERLAPPED) | WS_SYSMENU; |
|
200 |
else |
|
201 |
style = WS_POPUP; |
|
202 |
if ((type == Qt::ToolTip) || (type == Qt::SplashScreen)) { |
|
203 |
style = WS_POPUP; |
|
204 |
exsty |= WS_EX_NOANIMATION; |
|
205 |
} else { |
|
206 |
if (flags & Qt::WindowTitleHint) |
|
207 |
style |= WS_CAPTION; |
|
208 |
if (flags & Qt::WindowSystemMenuHint) |
|
209 |
style |= WS_SYSMENU; |
|
210 |
if (flags & Qt::WindowContextHelpButtonHint) |
|
211 |
exsty |= WS_EX_CONTEXTHELP; |
|
212 |
#ifndef Q_WS_WINCE_WM |
|
213 |
if (flags & Qt::WindowMinimizeButtonHint) |
|
214 |
style |= WS_MINIMIZEBOX; |
|
215 |
if (shouldShowMaximizeButton()) |
|
216 |
style |= WS_MAXIMIZEBOX; |
|
217 |
#endif |
|
218 |
if (tool) |
|
219 |
exsty |= WS_EX_TOOLWINDOW; |
|
220 |
} |
|
221 |
} |
|
222 |
if (dialog) { |
|
223 |
style = WS_BORDER | WS_CAPTION; |
|
224 |
if (flags & Qt::WindowOkButtonHint) |
|
225 |
exsty |= WS_EX_CAPTIONOKBTN; |
|
226 |
if (flags & Qt::WindowCancelButtonHint || flags & Qt::WA_DeleteOnClose) |
|
227 |
style |= WS_SYSMENU; |
|
228 |
if (flags & Qt::WindowContextHelpButtonHint) |
|
229 |
exsty |= WS_EX_CONTEXTHELP; |
|
230 |
} |
|
231 |
if (popup) { |
|
232 |
style = WS_POPUP; |
|
233 |
exsty |= WS_EX_NOANIMATION; |
|
234 |
} |
|
235 |
||
236 |
if (flags & Qt::WindowTitleHint) { |
|
237 |
title = q->isWindow() ? qAppName() : q->objectName(); |
|
238 |
} |
|
239 |
||
240 |
// The Qt::WA_WState_Created flag is checked by translateConfigEvent() in |
|
241 |
// qapplication_win.cpp. We switch it off temporarily to avoid move |
|
242 |
// and resize events during creationt |
|
243 |
q->setAttribute(Qt::WA_WState_Created, false); |
|
244 |
||
245 |
if (window) { // override the old window |
|
246 |
if (destroyOldWindow) |
|
247 |
destroyw = data.winid; |
|
248 |
id = window; |
|
249 |
setWinId(window); |
|
250 |
LONG res = SetWindowLong(window, GWL_STYLE, style); |
|
251 |
if (!res) |
|
252 |
qErrnoWarning("QWidget::create: Failed to set window style"); |
|
253 |
||
254 |
res = SetWindowLong( window, GWL_WNDPROC, (LONG)QtWndProc ); |
|
255 |
||
256 |
if (!res) |
|
257 |
qErrnoWarning("QWidget::create: Failed to set window procedure"); |
|
258 |
} else if (desktop) { // desktop widget |
|
259 |
id = GetDesktopWindow(); |
|
260 |
if (!id) { //Create a dummy desktop |
|
261 |
RECT r; |
|
262 |
SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0); |
|
263 |
id = CreateWindow(reinterpret_cast<const wchar_t *>(windowClassName.utf16()), |
|
264 |
reinterpret_cast<const wchar_t *>(title.utf16()), style, |
|
265 |
r.left, r.top, r.right - r.left, r.bottom - r.top, |
|
266 |
0, 0, appinst, 0); |
|
267 |
} |
|
268 |
setWinId(id); |
|
269 |
} else if (topLevel) { // create top-level widget |
|
270 |
const bool wasMoved = q->testAttribute(Qt::WA_Moved); |
|
271 |
||
272 |
int x, y; |
|
273 |
if (qt_wince_is_mobile()) { |
|
274 |
x = wasMoved ? data.crect.left() : CW_USEDEFAULT; |
|
275 |
y = wasMoved ? data.crect.top() : CW_USEDEFAULT; |
|
276 |
} else { |
|
277 |
x = wasMoved ? data.crect.left() : 100; |
|
278 |
y = wasMoved ? data.crect.top() : 100; |
|
279 |
} |
|
280 |
||
281 |
int w = CW_USEDEFAULT; |
|
282 |
int h = CW_USEDEFAULT; |
|
283 |
||
284 |
// Adjust for framestrut when needed |
|
285 |
RECT rect = {0,0,0,0}; |
|
286 |
if (AdjustWindowRectEx(&rect, style, FALSE, exsty)) { |
|
287 |
QTLWExtra *td = maybeTopData(); |
|
288 |
if (wasMoved && (td && !td->posFromMove)) { |
|
289 |
x = data.crect.x() + rect.left; |
|
290 |
y = data.crect.y() + rect.top; |
|
291 |
} |
|
292 |
||
293 |
if (q->testAttribute(Qt::WA_Resized)) { |
|
294 |
w = data.crect.width() + (rect.right - rect.left); |
|
295 |
h = data.crect.height() + (rect.bottom - rect.top); |
|
296 |
} |
|
297 |
} |
|
298 |
||
299 |
id = CreateWindowEx(exsty, reinterpret_cast<const wchar_t *>(windowClassName.utf16()), |
|
300 |
reinterpret_cast<const wchar_t *>(title.utf16()), style, |
|
301 |
x, y, w, h, |
|
302 |
0, 0, appinst, 0); |
|
303 |
||
304 |
if (!id) |
|
305 |
qErrnoWarning("QWidget::create: Failed to create window"); |
|
306 |
setWinId(id); |
|
307 |
if ((flags & Qt::WindowStaysOnTopHint) || (type == Qt::ToolTip)) |
|
308 |
SetWindowPos(id, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); |
|
309 |
} else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create child widget |
|
310 |
id = CreateWindowEx(exsty, (wchar_t*)windowClassName.utf16(), (wchar_t*)title.utf16(), style, |
|
311 |
data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(), |
|
312 |
parentw, NULL, appinst, NULL); |
|
313 |
if (!id) |
|
314 |
qErrnoWarning("QWidget::create: Failed to create window"); |
|
315 |
SetWindowPos(id, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); |
|
316 |
setWinId(id); |
|
317 |
} |
|
318 |
||
319 |
if (desktop) { |
|
320 |
q->setAttribute(Qt::WA_WState_Visible); |
|
321 |
} else if (topLevel && !q->testAttribute(Qt::WA_DontShowOnScreen)) { |
|
322 |
RECT cr; |
|
323 |
GetClientRect(id, &cr); |
|
324 |
// one cannot trust cr.left and cr.top, use a correction POINT instead |
|
325 |
POINT pt; |
|
326 |
pt.x = 0; |
|
327 |
pt.y = 0; |
|
328 |
if (!q->testAttribute(Qt::WA_DontShowOnScreen) || q->testAttribute(Qt::WA_Moved)) |
|
329 |
ClientToScreen(id, &pt); |
|
330 |
data.crect = QRect(QPoint(pt.x, pt.y), |
|
331 |
QPoint(pt.x + cr.right - 1, pt.y + cr.bottom - 1)); |
|
332 |
||
333 |
if (data.fstrut_dirty) { |
|
334 |
// be nice to activeqt |
|
335 |
updateFrameStrut(); |
|
336 |
} |
|
337 |
} |
|
338 |
||
339 |
q->setAttribute(Qt::WA_WState_Created); // accept move/resize events |
|
340 |
hd = 0; // no display context |
|
341 |
||
342 |
if (window) { // got window from outside |
|
343 |
if (IsWindowVisible(window)) |
|
344 |
q->setAttribute(Qt::WA_WState_Visible); |
|
345 |
else |
|
346 |
q->setAttribute(Qt::WA_WState_Visible, false); |
|
347 |
} |
|
348 |
||
349 |
if (extra && !extra->mask.isEmpty()) |
|
350 |
setMask_sys(extra->mask); |
|
351 |
||
352 |
#if defined(QT_NON_COMMERCIAL) |
|
353 |
QT_NC_WIDGET_CREATE |
|
354 |
#endif |
|
355 |
||
356 |
if (q->hasFocus() && q->testAttribute(Qt::WA_InputMethodEnabled)) |
|
357 |
q->inputContext()->setFocusWidget(q); |
|
358 |
||
359 |
if (destroyw) { |
|
360 |
DestroyWindow(destroyw); |
|
361 |
} |
|
362 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
363 |
#ifndef QT_NO_TABLETEVENT |
0 | 364 |
if (q != qt_tablet_widget && QWidgetPrivate::mapper) |
365 |
qt_tablet_init_wce(); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
366 |
#endif // QT_NO_TABLETEVENT |
0 | 367 |
|
368 |
if (q->testAttribute(Qt::WA_DropSiteRegistered)) |
|
369 |
registerDropSite(true); |
|
370 |
||
371 |
if (maybeTopData() && maybeTopData()->opacity != 255) |
|
372 |
q->setWindowOpacity(maybeTopData()->opacity/255.); |
|
373 |
||
374 |
if (!topLevel && q->testAttribute(Qt::WA_NativeWindow) && q->testAttribute(Qt::WA_Mapped)) { |
|
375 |
Q_ASSERT(q->internalWinId()); |
|
376 |
ShowWindow(q->internalWinId(), SW_SHOW); |
|
377 |
} |
|
378 |
} |
|
379 |
||
380 |
/* |
|
381 |
\internal |
|
382 |
Platform-specific part of QWidget::show(). |
|
383 |
*/ |
|
384 |
void QWidgetPrivate::show_sys() { |
|
385 |
Q_Q(QWidget); |
|
386 |
#if defined(QT_NON_COMMERCIAL) |
|
387 |
QT_NC_SHOW_WINDOW |
|
388 |
#endif |
|
389 |
if (q->testAttribute(Qt::WA_OutsideWSRange)) |
|
390 |
return; |
|
391 |
||
392 |
q->setAttribute(Qt::WA_Mapped); |
|
393 |
||
394 |
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); |
|
395 |
||
396 |
if (q->testAttribute(Qt::WA_DontShowOnScreen)) { |
|
397 |
invalidateBuffer(q->rect()); |
|
398 |
return; |
|
399 |
} |
|
400 |
||
401 |
||
402 |
int sm = SW_SHOW; |
|
403 |
bool fakedMaximize = false; |
|
404 |
if (q->isWindow()) { |
|
405 |
#ifndef Q_WS_WINCE_WM |
|
406 |
if (q->isMinimized()) { |
|
407 |
sm = SW_SHOWMINIMIZED; |
|
408 |
} else if (q->isMaximized()) { |
|
409 |
sm = SW_SHOWMAXIMIZED; |
|
410 |
// Windows will not behave correctly when we try to maximize a window which does not |
|
411 |
// have minimize nor maximize buttons in the window frame. Windows would then ignore |
|
412 |
// non-available geometry, and rather maximize the widget to the full screen, minus the |
|
413 |
// window frame (caption). So, we do a trick here, by adding a maximize button before |
|
414 |
// maximizing the widget, and then remove the maximize button afterwards. |
|
415 |
Qt::WindowFlags &flags = data.window_flags; |
|
416 |
if (flags & Qt::WindowTitleHint && |
|
417 |
!(flags & (Qt::WindowMinMaxButtonsHint | Qt::FramelessWindowHint))) { |
|
418 |
fakedMaximize = TRUE; |
|
419 |
int style = GetWindowLong(q->internalWinId(), GWL_STYLE); |
|
420 |
SetWindowLong(q->internalWinId(), GWL_STYLE, style | WS_MAXIMIZEBOX); |
|
421 |
} |
|
422 |
} else |
|
423 |
#else |
|
424 |
// Imitate minimizing on Windows mobile by hiding the widget. |
|
425 |
if (q->isMinimized()) |
|
426 |
sm = SW_HIDE; |
|
427 |
#endif |
|
428 |
if (q->isHidden()) { |
|
429 |
sm = SW_HIDE; |
|
430 |
} |
|
431 |
} |
|
432 |
if (q->testAttribute(Qt::WA_ShowWithoutActivating) |
|
433 |
|| (q->windowType() == Qt::Popup) |
|
434 |
|| (q->windowType() == Qt::ToolTip) |
|
435 |
|| (q->windowType() == Qt::Tool)) { |
|
436 |
sm = SW_SHOWNOACTIVATE; |
|
437 |
} |
|
438 |
||
439 |
ShowWindow(q->internalWinId(), sm); |
|
440 |
||
441 |
if (q->isMaximized() && q->isWindow()) |
|
442 |
qt_wince_maximize(q); |
|
443 |
||
444 |
#ifndef Q_WS_WINCE_WM |
|
445 |
if (!qt_wince_is_mobile() && q->isFullScreen()) { |
|
446 |
HWND handle = FindWindow(L"HHTaskBar", L""); |
|
447 |
if (handle) { |
|
448 |
ShowWindow(handle, SW_HIDE); |
|
449 |
EnableWindow(handle, false); |
|
450 |
} |
|
451 |
} |
|
452 |
||
453 |
if (fakedMaximize) { |
|
454 |
int style = GetWindowLong(q->internalWinId(), GWL_STYLE); |
|
455 |
SetWindowLong(q->internalWinId(), GWL_STYLE, style & ~WS_MAXIMIZEBOX); |
|
456 |
SetWindowPos(q->internalWinId(), 0, 0, 0, 0, 0, |
|
457 |
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER |
|
458 |
| SWP_FRAMECHANGED); |
|
459 |
} |
|
460 |
#else |
|
461 |
Q_UNUSED(fakedMaximize); |
|
462 |
#endif |
|
463 |
||
464 |
if (q->isWindow() && sm == SW_SHOW) |
|
465 |
SetForegroundWindow(q->internalWinId()); |
|
466 |
||
467 |
invalidateBuffer(q->rect()); |
|
468 |
} |
|
469 |
||
470 |
void QWidget::setWindowState(Qt::WindowStates newstate) |
|
471 |
{ |
|
472 |
Q_D(QWidget); |
|
473 |
Qt::WindowStates oldstate = windowState(); |
|
474 |
if (oldstate == newstate) |
|
475 |
return; |
|
476 |
||
477 |
int max = SW_SHOWNORMAL; |
|
478 |
int normal = SW_SHOWNOACTIVATE; |
|
479 |
||
480 |
if ((oldstate & Qt::WindowMinimized) && !(newstate & Qt::WindowMinimized)) |
|
481 |
newstate |= Qt::WindowActive; |
|
482 |
if (newstate & Qt::WindowActive) |
|
483 |
normal = SW_SHOWNORMAL; |
|
484 |
if (isWindow()) { |
|
485 |
createWinId(); |
|
486 |
Q_ASSERT(testAttribute(Qt::WA_WState_Created)); |
|
487 |
// Ensure the initial size is valid, since we store it as normalGeometry below. |
|
488 |
if ((!testAttribute(Qt::WA_Resized) && !isVisible())) |
|
489 |
adjustSize(); |
|
490 |
if (!d->topData()->normalGeometry.isValid()) { |
|
491 |
if (newstate & Qt::WindowMaximized && !(oldstate & Qt::WindowFullScreen)) |
|
492 |
d->topData()->normalGeometry = geometry(); |
|
493 |
if (newstate & Qt::WindowMinimized && !(oldstate & Qt::WindowFullScreen)) |
|
494 |
d->topData()->normalGeometry = geometry(); |
|
495 |
} |
|
496 |
if ((oldstate & Qt::WindowMaximized) != (newstate & Qt::WindowMaximized)) { |
|
497 |
if (!(newstate & Qt::WindowMaximized)) { |
|
498 |
int style = GetWindowLong(internalWinId(), GWL_STYLE) | WS_BORDER | WS_POPUP | WS_CAPTION; |
|
499 |
SetWindowLong(internalWinId(), GWL_STYLE, style); |
|
500 |
SetWindowLong(internalWinId(), GWL_EXSTYLE, GetWindowLong (internalWinId(), GWL_EXSTYLE) & ~ WS_EX_NODRAG); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
501 |
qt_wince_unmaximize(this); |
0 | 502 |
} |
503 |
if (isVisible() && newstate & Qt::WindowMaximized) |
|
504 |
qt_wince_maximize(this); |
|
505 |
if (isVisible() && !(newstate & Qt::WindowMinimized)) { |
|
506 |
ShowWindow(internalWinId(), (newstate & Qt::WindowMaximized) ? max : normal); |
|
507 |
if (!(newstate & Qt::WindowFullScreen)) { |
|
508 |
QRect r = d->topData()->normalGeometry; |
|
509 |
if (!(newstate & Qt::WindowMaximized) && r.width() >= 0) { |
|
510 |
if (pos() != r.topLeft() || size() !=r.size()) { |
|
511 |
d->topData()->normalGeometry = QRect(0,0,-1,-1); |
|
512 |
setGeometry(r); |
|
513 |
} |
|
514 |
} |
|
515 |
} else { |
|
516 |
d->updateFrameStrut(); |
|
517 |
} |
|
518 |
} |
|
519 |
} |
|
520 |
if ((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen)) { |
|
521 |
if (newstate & Qt::WindowFullScreen) { |
|
522 |
if (d->topData()->normalGeometry.width() < 0 && !(oldstate & Qt::WindowMaximized)) |
|
523 |
d->topData()->normalGeometry = geometry(); |
|
524 |
d->topData()->savedFlags = (Qt::WindowFlags)GetWindowLong(internalWinId(), GWL_STYLE); |
|
525 |
UINT style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP; |
|
526 |
if (isVisible()) |
|
527 |
style |= WS_VISIBLE; |
|
528 |
SetWindowLong(internalWinId(), GWL_STYLE, style); |
|
529 |
QRect r = qApp->desktop()->screenGeometry(this); |
|
530 |
UINT swpf = SWP_FRAMECHANGED; |
|
531 |
if (newstate & Qt::WindowActive) |
|
532 |
swpf |= SWP_NOACTIVATE; |
|
533 |
qt_wince_full_screen(internalWinId(), true, swpf); |
|
534 |
d->updateFrameStrut(); |
|
535 |
} else { |
|
536 |
UINT style = d->topData()->savedFlags; |
|
537 |
if (isVisible()) |
|
538 |
style |= WS_VISIBLE; |
|
539 |
SetWindowLong(internalWinId(), GWL_STYLE, style); |
|
540 |
UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE; |
|
541 |
if (newstate & Qt::WindowActive) |
|
542 |
swpf |= SWP_NOACTIVATE; |
|
543 |
qt_wince_full_screen(internalWinId(), false, swpf); |
|
544 |
d->updateFrameStrut(); |
|
545 |
||
546 |
// preserve maximized state |
|
547 |
if (isVisible()) { |
|
548 |
ShowWindow(internalWinId(), (newstate & Qt::WindowMaximized) ? max : normal); |
|
549 |
if (newstate & Qt::WindowMaximized) |
|
550 |
qt_wince_maximize(this); |
|
551 |
} |
|
552 |
if (!(newstate & Qt::WindowMaximized)) { |
|
553 |
QRect r = d->topData()->normalGeometry; |
|
554 |
d->topData()->normalGeometry = QRect(0,0,-1,-1); |
|
555 |
if (r.isValid()) |
|
556 |
setGeometry(r); |
|
557 |
} |
|
558 |
} |
|
559 |
} |
|
560 |
if ((oldstate & Qt::WindowMinimized) != (newstate & Qt::WindowMinimized)) { |
|
561 |
if (newstate & Qt::WindowMinimized) |
|
562 |
qt_wince_minimize(internalWinId()); |
|
563 |
else if (newstate & Qt::WindowMaximized) { |
|
564 |
ShowWindow(internalWinId(), max); |
|
565 |
qt_wince_maximize(this); |
|
566 |
} else { |
|
567 |
ShowWindow(internalWinId(), normal); |
|
568 |
} |
|
569 |
} |
|
570 |
} |
|
571 |
data->window_state = newstate; |
|
572 |
QWindowStateChangeEvent e(oldstate); |
|
573 |
QApplication::sendEvent(this, &e); |
|
574 |
} |
|
575 |
||
576 |
void QWidgetPrivate::deleteSysExtra() |
|
577 |
{ |
|
578 |
Q_Q(QWidget); |
|
579 |
if (!qt_wince_is_mobile() && q->isFullScreen()) { |
|
580 |
HWND handle = FindWindow(L"HHTaskBar", L""); |
|
581 |
if (handle) { |
|
582 |
ShowWindow(handle, SW_SHOWNORMAL); |
|
583 |
EnableWindow(handle, true); |
|
584 |
} |
|
585 |
} |
|
586 |
} |
|
587 |
||
588 |
void QWidgetPrivate::setWindowOpacity_sys(qreal level) { |
|
589 |
Q_UNUSED(level); |
|
590 |
return; |
|
591 |
} |
|
592 |
||
593 |
// The procedure does nothing, but is required for mousegrabbing to work |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
594 |
LRESULT QT_WIN_CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam) { |
0 | 595 |
Q_UNUSED(nCode); |
596 |
Q_UNUSED(wParam); |
|
597 |
Q_UNUSED(lParam); |
|
598 |
return 0; |
|
599 |
} |
|
600 |
||
601 |
void QWidget::grabMouse() { |
|
602 |
if (!qt_nograb()) { |
|
603 |
if (mouseGrb) |
|
604 |
mouseGrb->releaseMouse(); |
|
605 |
Q_ASSERT(testAttribute(Qt::WA_WState_Created)); |
|
606 |
SetCapture(internalWinId()); |
|
607 |
mouseGrb = this; |
|
608 |
} |
|
609 |
} |
|
610 |
||
611 |
#ifndef QT_NO_CURSOR |
|
612 |
void QWidget::grabMouse(const QCursor &cursor) { |
|
613 |
if (!qt_nograb()) { |
|
614 |
if (mouseGrb) |
|
615 |
mouseGrb->releaseMouse(); |
|
616 |
Q_ASSERT(testAttribute(Qt::WA_WState_Created)); |
|
617 |
SetCapture(internalWinId()); |
|
618 |
mouseGrbCur = new QCursor(cursor); |
|
619 |
SetCursor(mouseGrbCur->handle()); |
|
620 |
mouseGrb = this; |
|
621 |
} |
|
622 |
} |
|
623 |
#endif |
|
624 |
||
625 |
void QWidget::releaseMouse() { |
|
626 |
if (!qt_nograb() && mouseGrb == this) { |
|
627 |
ReleaseCapture(); |
|
628 |
if (journalRec) { |
|
629 |
journalRec = 0; |
|
630 |
} |
|
631 |
if (mouseGrbCur) { |
|
632 |
delete mouseGrbCur; |
|
633 |
mouseGrbCur = 0; |
|
634 |
} |
|
635 |
mouseGrb = 0; |
|
636 |
} |
|
637 |
} |
|
638 |
||
639 |
void QWidget::show() |
|
640 |
{ |
|
641 |
Qt::WindowFlags flags = windowFlags() & 0xff; |
|
642 |
int threshold = qApp->autoMaximizeThreshold(); |
|
643 |
if ((threshold < 0) || (windowState() & Qt::WindowFullScreen) || (windowState() & Qt::WindowMaximized)) { |
|
644 |
setVisible(true); |
|
645 |
return; |
|
646 |
} |
|
647 |
int height = sizeHint().height(); |
|
648 |
int screenHeight = (qreal(threshold) / 100.0f * qApp->desktop()->screenGeometry(this).height()); |
|
649 |
bool maximize = height > screenHeight; |
|
650 |
if (!maximize) { |
|
651 |
// If we do not maximize yet we check the widget and its child widgets whether they are |
|
652 |
//vertically expanding. If one of the widgets is expanding we maximize. |
|
653 |
QList<QWidget *> list = findChildren<QWidget *>(); |
|
654 |
bool expandingChild = sizePolicy().verticalPolicy () == QSizePolicy::Expanding; |
|
655 |
for (int i = 0; (i < list.size()) && !expandingChild; ++i) { |
|
656 |
expandingChild = list.at(i)->sizePolicy().verticalPolicy () == QSizePolicy::Expanding; |
|
657 |
} |
|
658 |
maximize = expandingChild; |
|
659 |
} |
|
660 |
if ((minimumSizeHint().height() > qApp->desktop()->screenGeometry(this).height()) || (minimumSizeHint().width() > qApp->desktop()->screenGeometry(this).width())) |
|
661 |
maximize = false; |
|
662 |
||
663 |
if ((flags == Qt::Window || flags == Qt::Dialog) && maximize) { |
|
664 |
setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen)) |
|
665 |
| Qt::WindowMaximized); |
|
666 |
setVisible(true); |
|
667 |
} |
|
668 |
else { |
|
669 |
setVisible(true); |
|
670 |
} |
|
671 |
} |
|
672 |
||
673 |
QT_END_NAMESPACE |
|
674 |
||
675 |
#endif // Q_WS_WINCE |