source: trunk/src/kernel/qwidget_pm.cpp@ 56

Last change on this file since 56 was 53, checked in by dmik, 20 years ago

Fixed: QWidget::create() didn't set default WStyle_NormalBorder | WStyle_Title | WStyle_MinMax | WStyle_SysMenu flags; as a result, MDI windows had incorrect appearance.

  • Property svn:keywords set to Id
File size: 61.2 KB
Line 
1/****************************************************************************
2** $Id: qwidget_pm.cpp 53 2006-01-15 22:06:23Z dmik $
3**
4** Implementation of QWidget and QWindow classes for OS/2
5**
6** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
7** Copyright (C) 2004 Norman ASA. Initial OS/2 Port.
8** Copyright (C) 2005 netlabs.org. Further OS/2 Development.
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#include "qapplication.h"
39#include "qapplication_p.h"
40#include "qpainter.h"
41#include "qbitmap.h"
42#include "qwidgetlist.h"
43#include "qwidgetintdict.h"
44#include "qobjectlist.h"
45#include "qaccel.h"
46#include "qimage.h"
47#include "qfocusdata.h"
48#include "qlayout.h"
49#include "qt_os2.h"
50#include "qpaintdevicemetrics.h"
51#include "qcursor.h"
52#include <private/qapplication_p.h>
53//@@TODO (dmik): remove?
54//#include <private/qinputcontext_p.h>
55
56const QString qt_reg_winclass( int ); // defined in qapplication_pm.cpp
57//@@TODO (dmik): later?
58//void qt_olednd_unregister( QWidget* widget, QOleDropTarget *dst ); // dnd_win
59//QOleDropTarget* qt_olednd_register( QWidget* widget );
60
61
62extern bool qt_nograb();
63//@@TODO (dmik): later (qregion_pm.cpp)
64//extern HRGN qt_win_bitmapToRegion(const QBitmap& bitmap);
65
66// defined in qapplication_pm.cpp
67extern void qt_sendBlocked( QObject *obj, QWidget *modal, QEvent *e, bool override );
68
69static QWidget *mouseGrb = 0;
70static QCursor *mouseGrbCur = 0;
71static QWidget *keyboardGrb = 0;
72
73extern "C" MRESULT EXPENTRY QtWndProc( HWND, ULONG, MPARAM, MPARAM );
74extern PFNWP QtOldFrameProc;
75extern "C" MRESULT EXPENTRY QtFrameProc( HWND, ULONG, MPARAM, MPARAM );
76
77PFNWP QtOldSysMenuProc;
78extern "C" MRESULT EXPENTRY QtSysMenuProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
79{
80 if ( msg == WM_MENUEND ) {
81 // the pull-down menu is closed, always dismiss the system menu itself
82 WinPostMsg( hwnd, MM_ENDMENUMODE, MPFROMSHORT(TRUE), 0 );
83 }
84 return QtOldSysMenuProc( hwnd, msg, mp1, mp2 );
85}
86
87static void removeSysMenuAccels( HWND frame )
88{
89 HWND sysMenu = WinWindowFromID( frame, FID_SYSMENU );
90 if ( !sysMenu )
91 return;
92
93 SHORT subId = SHORT1FROMMR( WinSendMsg( sysMenu, MM_ITEMIDFROMPOSITION, 0, 0 ) );
94 if ( subId != MIT_ERROR ) {
95 MENUITEM item;
96 WinSendMsg( sysMenu, MM_QUERYITEM, MPFROM2SHORT(subId, FALSE), MPFROMP(&item) );
97 HWND subMenu = item.hwndSubMenu;
98 if ( subMenu ) {
99 USHORT cnt = SHORT1FROMMR( WinSendMsg( subMenu, MM_QUERYITEMCOUNT, 0, 0 ) );
100 for ( int i = 0; i < cnt; i++ ) {
101 USHORT id = SHORT1FROMMR(
102 WinSendMsg( subMenu, MM_ITEMIDFROMPOSITION, MPFROMSHORT(i), 0 ) );
103 if ( id == SC_TASKMANAGER || id == SC_CLOSE ) {
104 // accels for these entries always work in Qt, skip them
105 continue;
106 }
107 USHORT len = SHORT1FROMMR(
108 WinSendMsg( subMenu, MM_QUERYITEMTEXTLENGTH, MPFROMSHORT(id), 0 ) );
109 if ( len++ ) {
110 char *text = new char[len];
111 WinSendMsg( subMenu, MM_QUERYITEMTEXT,
112 MPFROM2SHORT(id, len), MPFROMP(text) );
113 char *tab = strrchr( text, '\t' );
114 if ( tab ) {
115 *tab = 0;
116 WinSendMsg( subMenu, MM_SETITEMTEXT,
117 MPFROMSHORT(id), MPFROMP(text) );
118 }
119 delete[] text;
120 }
121 }
122 // sublclass the system menu to leave the menu mode completely
123 // when the user presses the ESC key. by default, pressing ESC
124 // while the pull-down menu is showing brings us to the menu bar,
125 // which is confusing in the case of the system menu, because
126 // there is only one item on the menu bar, and we cannot see
127 // that it is active when the frame window has an icon.
128 PFNWP oldProc = WinSubclassWindow( sysMenu, QtSysMenuProc );
129 // set QtOldSysMenuProc only once: it must be the same for
130 // all FID_SYSMENU windows.
131 if ( !QtOldSysMenuProc )
132 QtOldSysMenuProc = oldProc;
133 }
134 }
135}
136
137/*****************************************************************************
138 QWidget member functions
139 *****************************************************************************/
140
141//#define QT_DEBUGWINCREATEDESTROY
142
143void QWidget::create( WId window, bool initializeWindow, bool destroyOldWindow )
144{
145 // When window is not zero, it represents an existing (external) window
146 // handle we should create a QWidget "wrapper" for to incorporate it to the
147 // Qt widget hierarchy. But so far I have never seen this method called
148 // with window != 0, so we ignore this argument (as well as the other two
149 // that make sense only together with it) for now and will not implement
150 // this functionality until there's a real need.
151
152 Q_ASSERT( window == 0 );
153 Q_UNUSED( initializeWindow );
154 Q_UNUSED( destroyOldWindow );
155
156 if ( testWState(WState_Created) && window == 0 )
157 return;
158 setWState( WState_Created ); // set created flag
159
160 if ( !parentWidget() || parentWidget()->isDesktop() )
161 setWFlags( WType_TopLevel ); // top-level widget
162
163 static int sw = -1, sh = -1;
164
165 bool topLevel = testWFlags(WType_TopLevel);
166 bool popup = testWFlags(WType_Popup);
167 bool dialog = testWFlags(WType_Dialog);
168 bool desktop = testWFlags(WType_Desktop);
169 WId id = 0;
170
171 if ( popup ) {
172 /// @todo (dmik) WStyle_StaysOnTop is ignored for now (does nothing)
173 setWFlags(WStyle_StaysOnTop); // a popup stays on top
174 }
175
176 if ( sw < 0 ) { // get the screen size
177 sw = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
178 sh = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
179 }
180
181 if ( dialog || popup || desktop ) { // these are top-level, too
182 topLevel = TRUE;
183 setWFlags( WType_TopLevel );
184 }
185
186 if ( desktop ) { // desktop widget
187 popup = FALSE; // force this flags off
188 /// @todo (dmik)
189 // use WinGetMaxPosition () to take into account such things as XCenter?
190 crect.setRect( 0, 0, sw, sh );
191 }
192
193 PCSZ title = NULL;
194 ULONG style = 0;
195 ULONG fId = 0, fStyle = 0, fcFlags = 0;
196
197 if ( popup ) {
198 style |= WS_SAVEBITS;
199 } else if ( !topLevel ) {
200 if ( !testWFlags(WStyle_Customize) )
201 setWFlags( WStyle_NormalBorder | WStyle_Title | WStyle_MinMax | WStyle_SysMenu );
202 } else if (!desktop ) {
203 if ( !testWFlags(WStyle_Customize) ) {
204 if ( testWFlags(WStyle_Tool) ) {
205 // a special case for WStyle_Tool w/o WStyle_Customize.
206 // it violates the Qt docs but it is used by QPopupMenu
207 // to create torn-off menus.
208 setWFlags( WStyle_Title );
209 } else {
210 if ( dialog )
211 setWFlags( WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu );
212 else
213 setWFlags( WStyle_NormalBorder | WStyle_Title | WStyle_MinMax | WStyle_SysMenu );
214 }
215 }
216 }
217 if ( !desktop ) {
218 /// @todo (dmik)
219 // this is temporarily commented out because QSplitter sets
220 // WPaintUnclipped which causes terrible flicker in QFileDialog's list
221 // box and list view. This needs to be investigated. Qt/Win32 does also
222 // comment this out...
223 /* if ( !testWFlags( WPaintUnclipped ) ) */
224 style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
225 // for all top-level windows except popups we create a WC_FRAME
226 // as a parent and owner.
227 if ( topLevel && !popup ) {
228 if ( !testWFlags(WStyle_NoBorder) ) {
229 if ( testWFlags(WStyle_NormalBorder) ) {
230 fcFlags |= FCF_SIZEBORDER;
231 } else if ( testWFlags(WStyle_DialogBorder) ) {
232 fcFlags |= FCF_DLGBORDER;
233 } else if ( testWFlags(WStyle_Tool) ) {
234 fcFlags |= FCF_BORDER;
235 }
236 }
237 if ( testWFlags(WStyle_Title) )
238 fcFlags |= FCF_TITLEBAR;
239 if ( testWFlags(WStyle_SysMenu) )
240 fcFlags |= FCF_SYSMENU | FCF_CLOSEBUTTON;
241 if ( testWFlags(WStyle_Minimize) )
242 fcFlags |= FCF_MINBUTTON;
243 if ( testWFlags(WStyle_Maximize) )
244 fcFlags |= FCF_MAXBUTTON;
245 fStyle |= FS_NOMOVEWITHOWNER | FS_NOBYTEALIGN;
246 fStyle |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
247 }
248 }
249 if ( testWFlags(WStyle_Title) ) {
250 title = topLevel ? qAppName() : name();
251 }
252
253 // The WState_Created flag is checked by translateConfigEvent() in
254 // qapplication_pm.cpp. We switch it off temporarily to avoid move
255 // and resize events during creation
256 clearWState( WState_Created );
257
258 QString className = qt_reg_winclass( getWFlags() );
259 PCSZ pszClassName = className.latin1();
260
261 if ( desktop ) { // desktop widget
262 id = WinQueryDesktopWindow( 0, 0 );
263 QWidget *otherDesktop = find( id ); // is there another desktop?
264 if ( otherDesktop && otherDesktop->testWFlags(WPaintDesktop) ) {
265 otherDesktop->setWinId( 0 ); // remove id from widget mapper
266 setWinId( id ); // make sure otherDesktop is
267 otherDesktop->setWinId( id ); // found first
268 } else {
269 setWinId( id );
270 }
271 } else if ( topLevel ) {
272 // create top-level widget
273 HWND ownerw = 0;
274 if ( !popup ) {
275 QWidget *p = parentWidget();
276 if ( p && !p->isDesktop() )
277 ownerw = p->topLevelWidget()->winFId();
278 }
279
280 if ( !popup ) {
281 // create WC_FRAME
282 FRAMECDATA fcData;
283 fcData.cb = sizeof(FRAMECDATA);
284 fcData.flCreateFlags = fcFlags;
285 fcData.hmodResources = NULL;
286 fcData.idResources = 0;
287#if !defined(QT_NO_DEBUG) && defined(QT_DEBUGWINCREATEDESTROY)
288 qDebug(
289 "|Creating top level window [%s] (frame):\n"
290 "| owner = %08lX\n"
291 "| title = '%s'\n"
292 "| style = %08lX\n"
293 "| fcFlags = %08lX",
294 name(), ownerw, title, fStyle, fcFlags
295 );
296#endif
297 fId = WinCreateWindow(
298 HWND_DESKTOP, WC_FRAME, title, fStyle, 0, 0, 0, 0,
299 ownerw, HWND_TOP, 0, &fcData, NULL
300 );
301#ifndef QT_NO_DEBUG
302#ifdef QT_DEBUGWINCREATEDESTROY
303 qDebug( "| hwnd = %08lX", fId );
304#endif
305 if ( fId == 0 )
306 qSystemWarning( "QWidget: Failed to create frame window" );
307#endif
308 PFNWP oldProc = WinSubclassWindow( fId, QtFrameProc );
309 // set QtOldFrameProc only once: it must be the same for
310 // all WC_FRAME windows.
311 if ( !QtOldFrameProc )
312 QtOldFrameProc = oldProc;
313
314 removeSysMenuAccels( fId );
315
316 // create client
317#if !defined(QT_NO_DEBUG) && defined(QT_DEBUGWINCREATEDESTROY)
318 qDebug(
319 "|Creating top level window [%s] (client):\n"
320 "| owner & parent = %08lX\n"
321 "| class = '%s'\n"
322 "| title = '%s'\n"
323 "| style = %08lX",
324 name(), fId, pszClassName, title, style
325 );
326#endif
327 id = WinCreateWindow(
328 fId, pszClassName, title, style, 0, 0, 0, 0,
329 fId, HWND_BOTTOM, FID_CLIENT, NULL, NULL
330 );
331 } else {
332#if !defined(QT_NO_DEBUG) && defined(QT_DEBUGWINCREATEDESTROY)
333 qDebug(
334 "|Creating top level window [%s]:\n"
335 "| owner = %08lX\n"
336 "| class = '%s'\n"
337 "| title = '%s'\n"
338 "| style = %08lX",
339 name(), ownerw, pszClassName, title, style
340 );
341#endif
342 id = WinCreateWindow(
343 HWND_DESKTOP, pszClassName, title, style, 0, 0, 0, 0,
344 ownerw, HWND_TOP, 0, NULL, NULL
345 );
346 }
347#ifndef QT_NO_DEBUG
348#ifdef QT_DEBUGWINCREATEDESTROY
349 qDebug( "| hwnd = %08lX", id );
350#endif
351 if ( id == 0 )
352 qSystemWarning( "QWidget: Failed to create window" );
353#endif
354 setWinId( id );
355 /// @todo (dmik) WStyle_StaysOnTop is ignored for now (does nothing)
356/*
357 if ( testWFlags( WStyle_StaysOnTop) )
358 SetWindowPos( id, HWND_TOPMOST, 0, 0, 100, 100, SWP_NOACTIVATE );
359*/
360
361 // When the FS_SHELLPOSITION flag is specified during WC_FRAME window
362 // creation its size and position remains zero until it is shown
363 // for the first time. So, we don't use FS_SHELLPOSITION but emulate
364 // its functionality here.
365 SWP swp;
366 WinQueryTaskSizePos( 0, 0, &swp );
367 WinSetWindowPos( fId, 0, swp.x, swp.y, swp.cx, swp.cy, SWP_SIZE | SWP_MOVE );
368 } else {
369 // create child widget
370 HWND parentw = parentWidget()->winId();
371#if !defined(QT_NO_DEBUG) && defined(QT_DEBUGWINCREATEDESTROY)
372 qDebug(
373 "|Creating child window [%s]:\n"
374 "| owner & parent = %08lX\n"
375 "| class = '%s'\n"
376 "| title = '%s'\n"
377 "| style = %08lX",
378 name(), parentw, pszClassName, title, style
379 );
380#endif
381 id = WinCreateWindow(
382 parentw, pszClassName, title, style,
383 0, parentWidget()->crect.height() - 30, 100, 30,
384 parentw, HWND_TOP, 0, NULL, NULL
385 );
386#ifndef QT_NO_DEBUG
387#ifdef QT_DEBUGWINCREATEDESTROY
388 qDebug( "| hwnd = %08lX", id );
389#endif
390 if ( id == 0 )
391 qSystemWarning( "QWidget: Failed to create window" );
392#endif
393 setWinId( id );
394 }
395
396 if ( desktop ) {
397 setWState( WState_Visible );
398 } else {
399 SWP cswp;
400 WinQueryWindowPos( id, &cswp );
401 if ( topLevel ) {
402 QTLWExtra *top = topData();
403 if ( fId ) {
404 SWP fswp;
405 WinQueryWindowPos( fId, &fswp );
406 // flip y coordinates
407 fswp.y = sh - (fswp.y + fswp.cy);
408 cswp.y = fswp.cy - (cswp.y + cswp.cy);
409 crect.setRect(
410 fswp.x + cswp.x, fswp.y + cswp.y,
411 cswp.cx, cswp.cy
412 );
413
414 top->fleft = cswp.x;
415 top->ftop = cswp.y;
416 top->fright = fswp.cx - cswp.x - cswp.cx;
417 top->fbottom = fswp.cy - cswp.y - cswp.cy;
418 top->fId = fId;
419 } else {
420 // flip y coordinate
421 cswp.y = sh - (cswp.y + cswp.cy);
422 crect.setRect( cswp.x, cswp.y, cswp.cx, cswp.cy );
423 }
424 fstrut_dirty = FALSE;
425 } else {
426 int cy = parentWidget()->crect.height();
427 // flip y coordinate
428 cswp.y = cy - (cswp.y + cswp.cy);
429 crect.setRect( cswp.x, cswp.y, cswp.cx, cswp.cy );
430 }
431 }
432
433 setWState( WState_Created ); // accept move/resize events
434 hps = 0; // no presentation space
435
436 setFontSys();
437
438/// @todo (dmik) remove?
439// QInputContext::enable( this, im_enabled & !((bool)testWState(WState_Disabled)) );
440}
441
442
443void QWidget::destroy( bool destroyWindow, bool destroySubWindows )
444{
445 deactivateWidgetCleanup();
446 if ( testWState(WState_Created) ) {
447 clearWState( WState_Created );
448 if ( children() ) {
449 QObjectListIt it(*children());
450 register QObject *obj;
451 while ( (obj=it.current()) ) { // destroy all widget children
452 ++it;
453 if ( obj->isWidgetType() )
454 ((QWidget*)obj)->destroy(destroySubWindows,
455 destroySubWindows);
456 }
457 }
458 if ( mouseGrb == this )
459 releaseMouse();
460 if ( keyboardGrb == this )
461 releaseKeyboard();
462 if ( testWFlags(WShowModal) ) // just be sure we leave modal
463 qt_leave_modal( this );
464 else if ( testWFlags(WType_Popup) )
465 qApp->closePopup( this );
466 if ( destroyWindow && !testWFlags(WType_Desktop) ) {
467 HWND id = winId();
468 if ( isTopLevel() && !testWFlags(WType_Popup) ) {
469 // extra data including extra->topextra has been already
470 // deleted at this point by deleteExtra() and therefore
471 // calling winFId() useless -- it will always return the
472 // client window handle. Use WinQueryWindow() instead.
473 id = WinQueryWindow( id, QW_PARENT );
474 }
475#if !defined(QT_NO_DEBUG) && defined(QT_DEBUGWINCREATEDESTROY)
476 qDebug(
477 "|Destroying window:\n"
478 "| hwnd = %08lX",
479 id
480 );
481#endif
482 WinDestroyWindow( id );
483 }
484 setWinId( 0 );
485 }
486}
487
488void QWidget::reparentSys( QWidget *parent, WFlags f, const QPoint &p,
489 bool showIt )
490{
491 QWidget* oldtlw = topLevelWidget();
492 WId old_winfid = winFId();
493
494 // hide and reparent our own window away. Otherwise we might get
495 // destroyed when emitting the child remove event below. See QWorkspace.
496 // this is also necessary for modal windows to leave the modal state
497 // correctly.
498 if ( isVisible() ) {
499 hide();
500 WinSetParent( old_winfid, HWND_OBJECT, FALSE );
501 WinSetOwner( old_winfid, 0 );
502 }
503
504 // unblock the widget if blocked
505 QWidget *blockedBy = 0;
506 if ( isTopLevel() )
507 blockedBy = (QWidget*) WinQueryWindowULong( winId(), QWL_QTMODAL );
508 if ( !blockedBy && parentWidget() )
509 blockedBy = (QWidget*) WinQueryWindowULong(
510 parentWidget()->topLevelWidget()->winId(), QWL_QTMODAL );
511 if ( blockedBy ) {
512 QEvent e( QEvent::WindowUnblocked );
513 qt_sendBlocked( this, blockedBy, &e, FALSE );
514 }
515
516 bool accept_drops = acceptDrops();
517 if ( accept_drops )
518 setAcceptDrops( FALSE ); // ole dnd unregister (we will register again below)
519 if ( testWFlags(WType_Desktop) )
520 old_winfid = 0;
521 setWinId( 0 );
522 if ( isTopLevel() ) {
523 QTLWExtra *top = topData();
524 if ( top->swEntry ) {
525 WinRemoveSwitchEntry( top->swEntry );
526 top->swEntry = 0;
527 }
528 top->fId = 0;
529 }
530
531 if ( parent != parentObj ) {
532 if ( parentObj ) // remove from parent
533 parentObj->removeChild( this );
534 if ( parent ) // insert into new parent
535 parent->insertChild( this );
536 }
537
538 bool enable = isEnabled(); // remember status
539 FocusPolicy fp = focusPolicy();
540 QSize s = size();
541 QString capt = caption();
542 widget_flags = f;
543 clearWState( WState_Created | WState_Visible | WState_ForceHide );
544 create();
545 if ( isTopLevel() || (!parent || parent->isVisible() ) )
546 setWState( WState_ForceHide ); // new widgets do not show up in already visible parents
547 const QObjectList *chlist = children();
548 if ( chlist ) { // reparent children
549 SWP swp;
550 QObjectListIt it( *chlist );
551 QObject *obj;
552 while ( (obj=it.current()) ) {
553 if ( obj->isWidgetType() ) {
554 QWidget *w = (QWidget *)obj;
555 if ( w->isPopup() )
556 ;
557 else if ( w->isTopLevel() ) {
558 w->reparent( this, w->getWFlags(), w->pos(), !w->isHidden() );
559 } else {
560 WinSetParent( w->winId(), winId(), FALSE );
561 WinSetOwner( w->winId(), winId() );
562 // bring PM coords into accordance with Qt coords,
563 // otherwise setGeometry() below will wrongly position
564 // children if this widget manages their layout.
565 int hd = height() - s.height();
566 WinQueryWindowPos( w->winId(), &swp );
567 swp.y += hd;
568 WinSetWindowPos( w->winId(), 0, swp.x, swp.y, 0, 0, SWP_MOVE );
569 }
570 }
571 ++it;
572 }
573 }
574
575 // block the widget if it should be blocked
576 blockedBy = 0;
577 if ( parentWidget() )
578 blockedBy = (QWidget*) WinQueryWindowULong(
579 parentWidget()->topLevelWidget()->winId(), QWL_QTMODAL );
580 if ( blockedBy ) {
581 if ( isTopLevel() && testWFlags( WGroupLeader ) )
582 blockedBy = 0;
583 } else {
584 QWidget *topModal = qApp->activeModalWidget();
585 if (
586 topModal && this != topModal && parentWidget() != topModal &&
587 isTopLevel() && !testWFlags( WGroupLeader )
588 )
589 blockedBy = topModal;
590 }
591 if ( blockedBy ) {
592 QEvent e( QEvent::WindowBlocked );
593 qt_sendBlocked( this, blockedBy, &e, FALSE );
594 }
595
596 setGeometry( p.x(), p.y(), s.width(), s.height() );
597 setEnabled( enable );
598 setFocusPolicy( fp );
599 if ( !capt.isNull() ) {
600 extra->topextra->caption = QString::null;
601 setCaption( capt );
602 }
603 if ( showIt )
604 show();
605 if ( old_winfid )
606 WinDestroyWindow( old_winfid );
607
608 reparentFocusWidgets( oldtlw ); // fix focus chains
609
610 if ( accept_drops )
611 setAcceptDrops( TRUE );
612
613//@@TODO (dmik): remove?
614//#ifdef Q_OS_TEMP
615// // Show borderless toplevel windows in tasklist & NavBar
616// if ( !parent ) {
617// QString txt = caption().isEmpty()?qAppName():caption();
618// SetWindowText( winId(), (TCHAR*)txt.ucs2() );
619// }
620//#endif
621}
622
623QPoint QWidget::mapToGlobal( const QPoint &pos ) const
624{
625 if ( !isVisible() || isMinimized() )
626 return mapTo( topLevelWidget(), pos ) + topLevelWidget()->pos() +
627 (topLevelWidget()->geometry().topLeft() - topLevelWidget()->frameGeometry().topLeft());
628 POINTL ptl;
629 ptl.x = pos.x();
630 // flip y (local) coordinate
631 ptl.y = height() - (pos.y() + 1);
632 WinMapWindowPoints( winId(), HWND_DESKTOP, &ptl, 1 );
633 // flip y (global) coordinate
634 ptl.y = QApplication::desktop()->height() - (ptl.y + 1);
635 return QPoint( ptl.x, ptl.y );
636}
637
638QPoint QWidget::mapFromGlobal( const QPoint &pos ) const
639{
640 if ( !isVisible() || isMinimized() )
641 return mapFrom( topLevelWidget(), pos - topLevelWidget()->pos() );
642 POINTL ptl;
643 ptl.x = pos.x();
644 // flip y (global) coordinate
645 ptl.y = QApplication::desktop()->height() - (pos.y() + 1);
646 WinMapWindowPoints( HWND_DESKTOP, winId(), &ptl, 1 );
647 // flip y (local) coordinate
648 ptl.y = height() - (ptl.y + 1);
649 return QPoint( ptl.x, ptl.y );
650}
651
652void QWidget::setFontSys( QFont *f )
653{
654//@@TODO (dmik): should this do something on OS/2?
655//@@TODO (dmik): remove?
656// QInputContext::setFont( this, (f ? *f : font()) );
657}
658
659void QWidget::setMicroFocusHint(int x, int y, int width, int height, bool text, QFont *f)
660{
661//@@TODO (dmik): do we need to create a caret (cursor) in OS/2 also?
662// currently, try to do so (which can be useful for 3rd-party apps
663// that are interested in the current cursor position, i.e. where the user
664// input is now taking place.
665 // flip y coordinate
666 int fy = crect.height() - (y + height);
667 WinCreateCursor( winId(), x, fy, width, height, CURSOR_SOLID, NULL );
668
669//@@TODO (dmik): remove?
670// if ( text )
671// QInputContext::setFocusHint( x, y, width, height, this );
672 setFontSys( f );
673
674 if ( QRect( x, y, width, height ) != microFocusHint() )
675 extraData()->micro_focus_hint.setRect( x, y, width, height );
676}
677
678void QWidget::resetInputContext()
679{
680//@@TODO (dmik): remove?
681// QInputContext::accept();
682}
683
684void QWidget::setBackgroundColorDirect( const QColor &color )
685{
686 bg_col = color;
687 if ( extra && extra->bg_pix ) { // kill the background pixmap
688 delete extra->bg_pix;
689 extra->bg_pix = 0;
690 }
691}
692
693
694static int allow_null_pixmaps = 0;
695
696
697void QWidget::setBackgroundPixmapDirect( const QPixmap &pixmap )
698{
699 QPixmap old;
700 if ( extra && extra->bg_pix )
701 old = *extra->bg_pix;
702 if ( !allow_null_pixmaps && pixmap.isNull() ) {
703 if ( extra && extra->bg_pix ) {
704 delete extra->bg_pix;
705 extra->bg_pix = 0;
706 }
707 } else {
708 if ( extra && extra->bg_pix )
709 delete extra->bg_pix;
710 else
711 createExtra();
712 extra->bg_pix = new QPixmap( pixmap );
713 }
714}
715
716
717void QWidget::setBackgroundEmpty()
718{
719 allow_null_pixmaps++;
720 setErasePixmap(QPixmap());
721 allow_null_pixmaps--;
722}
723
724extern void qt_set_cursor( QWidget *, const QCursor & ); // qapplication_pm.cpp
725
726void QWidget::setCursor( const QCursor &cursor )
727{
728 if ( cursor.handle() != arrowCursor.handle()
729 || (extra && extra->curs) ) {
730 createExtra();
731 delete extra->curs;
732 extra->curs = new QCursor(cursor);
733 }
734 setWState( WState_OwnCursor );
735 qt_set_cursor( this, QWidget::cursor() );
736}
737
738void QWidget::unsetCursor()
739{
740 if ( extra ) {
741 delete extra->curs;
742 extra->curs = 0;
743 }
744 if ( !isTopLevel() )
745 clearWState( WState_OwnCursor );
746 qt_set_cursor( this, cursor() );
747}
748
749void QWidget::setCaption( const QString &caption )
750{
751 if ( QWidget::caption() == caption )
752 return; // for less flicker
753 topData()->caption = caption;
754
755 QCString cap = caption.local8Bit();
756 WinSetWindowText( winFId(), cap );
757
758 HSWITCH swEntry = topData()->swEntry;
759 if ( swEntry ) {
760 SWCNTRL swc;
761 WinQuerySwitchEntry( swEntry, &swc );
762 strncpy( swc.szSwtitle, cap, sizeof(swc.szSwtitle)-1 );
763 swc.szSwtitle [sizeof(swc.szSwtitle)-1] = 0;
764 WinChangeSwitchEntry( swEntry, &swc );
765 }
766
767 QEvent e( QEvent::CaptionChange );
768 QApplication::sendEvent( this, &e );
769}
770
771//@@TODO (dmik): later
772///*
773// Create an icon mask the way Windows wants it using CreateBitmap.
774//*/
775//
776//HBITMAP qt_createIconMask( const QBitmap &bitmap )
777//{
778// QImage bm = bitmap.convertToImage();
779// int w = bm.width();
780// int h = bm.height();
781// int bpl = ((w+15)/16)*2; // bpl, 16 bit alignment
782// uchar *bits = new uchar[bpl*h];
783// bm.invertPixels();
784// for ( int y=0; y<h; y++ )
785// memcpy( bits+y*bpl, bm.scanLine(y), bpl );
786// HBITMAP hbm = CreateBitmap( w, h, 1, 1, bits );
787// delete [] bits;
788// return hbm;
789//}
790
791void QWidget::setIcon( const QPixmap &pixmap )
792{
793 qWarning( "QWidget::setIcon() is not yet implemented on OS/2" );
794//@@TODO (dmik): later
795// QTLWExtra* x = topData();
796// delete x->icon;
797// x->icon = 0;
798// if ( x->winIcon ) {
799// DestroyIcon( x->winIcon );
800// x->winIcon = 0;
801// }
802// if ( !pixmap.isNull() ) { // valid icon
803// QPixmap pm( pixmap.size(), pixmap.depth(), QPixmap::NormalOptim );
804// QBitmap mask( pixmap.size(), FALSE, QPixmap::NormalOptim );
805// if ( pixmap.mask() ) {
806// pm.fill( black ); // make masked area black
807// bitBlt( &mask, 0, 0, pixmap.mask() );
808// } else {
809// mask.fill( color1 );
810// }
811// bitBlt( &pm, 0, 0, &pixmap );
812// HBITMAP im = qt_createIconMask(mask);
813// ICONINFO ii;
814// ii.fIcon = TRUE;
815// ii.hbmMask = im;
816// ii.hbmColor = pm.hbm();
817// ii.xHotspot = 0;
818// ii.yHotspot = 0;
819// x->icon = new QPixmap( pixmap );
820// x->winIcon = CreateIconIndirect( &ii );
821// DeleteObject( im );
822// }
823// SendMessageA( winId(), WM_SETICON, 0, /* ICON_SMALL */
824// (long)x->winIcon );
825// SendMessageA( winId(), WM_SETICON, 1, /* ICON_BIG */
826// (long)x->winIcon );
827//
828// QEvent e( QEvent::IconChange );
829// QApplication::sendEvent( this, &e );
830}
831
832
833void QWidget::setIconText( const QString &iconText )
834{
835 topData()->iconText = iconText;
836}
837
838QCursor *qt_grab_cursor()
839{
840 return mouseGrbCur;
841}
842
843void QWidget::grabMouse()
844{
845 if ( !qt_nograb() ) {
846 if ( mouseGrb )
847 mouseGrb->releaseMouse();
848 WinSetCapture( HWND_DESKTOP, winFId() );
849 mouseGrb = this;
850 }
851}
852
853void QWidget::grabMouse( const QCursor &cursor )
854{
855 if ( !qt_nograb() ) {
856 if ( mouseGrb )
857 mouseGrb->releaseMouse();
858 WinSetCapture( HWND_DESKTOP, winFId() );
859 mouseGrbCur = new QCursor( cursor );
860 WinSetPointer( HWND_DESKTOP, mouseGrbCur->handle() );
861 mouseGrb = this;
862 }
863}
864
865void QWidget::releaseMouse()
866{
867 if ( !qt_nograb() && mouseGrb == this ) {
868 WinSetCapture( HWND_DESKTOP, 0 );
869 if ( mouseGrbCur ) {
870 delete mouseGrbCur;
871 mouseGrbCur = 0;
872 }
873 mouseGrb = 0;
874 }
875}
876
877void QWidget::grabKeyboard()
878{
879 if ( !qt_nograb() ) {
880 if ( keyboardGrb )
881 keyboardGrb->releaseKeyboard();
882 keyboardGrb = this;
883 }
884}
885
886void QWidget::releaseKeyboard()
887{
888 if ( !qt_nograb() && keyboardGrb == this )
889 keyboardGrb = 0;
890}
891
892
893QWidget *QWidget::mouseGrabber()
894{
895 return mouseGrb;
896}
897
898QWidget *QWidget::keyboardGrabber()
899{
900 return keyboardGrb;
901}
902
903void QWidget::setActiveWindow()
904{
905 WinSetActiveWindow( HWND_DESKTOP, topLevelWidget()->winFId() );
906}
907
908void QWidget::update()
909{
910 update( 0, 0, -1, -1 );
911}
912
913void QWidget::update( int x, int y, int w, int h )
914{
915 if ( w && h &&
916 (widget_state & (WState_Visible|WState_BlockUpdates)) == WState_Visible ) {
917 if ( w < 0 )
918 w = crect.width() - x;
919 if ( h < 0 )
920 h = crect.height() - y;
921
922 // flip y coordinate
923 y = crect.height() - (y + h);
924 RECTL rcl = { x, y, x + w, y + h };
925
926 // WinInvalidateRect() has such a "feature" that children are not
927 // actually extracted from the window's update region when it has
928 // the WS_CLIPCHILDREN flag, meaning that every child will anyway
929 // receive a WM_PAINT message if its visible region intersects with
930 // the update region of its parent, with its update region set to
931 // that intersection. This in turn means that if we invalidate the
932 // window completely, all its visible children wil completely repaint
933 // themselves, what is not we want. The solution is to manually
934 // substract children from the region we want to be updated.
935 ULONG wstyle = WinQueryWindowULong( winId(), QWL_STYLE );
936 if ( (wstyle & WS_CLIPCHILDREN) && children() ) {
937 HPS lhps = hps;
938 if ( !lhps ) lhps = qt_display_ps();
939 HRGN hrgn = GpiCreateRegion( lhps, 1, &rcl );
940 HRGN whrgn = GpiCreateRegion( lhps, 0, NULL );
941 int hgt = crect.height();
942
943 QObjectListIt it(*children());
944 register QObject *object;
945 QWidget *w;
946 while ( it ) {
947 object = it.current();
948 ++it;
949 if ( object->isWidgetType() ) {
950 w = (QWidget*)object;
951 if ( !w->isTopLevel() && w->isShown() ) {
952//@@TODO (dmik): later: substract the region of the child window
953// (WinQueryClipRegion()) instead of the window rectangle.
954 const QRect &r = w->crect;
955 rcl.xLeft = r.left();
956 rcl.yBottom = hgt - (r.bottom() + 1);
957 rcl.xRight = r.right() + 1;
958 rcl.yTop = hgt - r.top();
959 GpiSetRegion( lhps, whrgn, 1, &rcl );
960 GpiCombineRegion( lhps, hrgn, hrgn, whrgn, CRGN_DIFF );
961 }
962 }
963 }
964 GpiDestroyRegion( lhps, whrgn );
965 WinInvalidateRegion( winId(), hrgn, FALSE );
966 GpiDestroyRegion( lhps, hrgn );
967 } else {
968 WinInvalidateRect( winId(), &rcl, FALSE );
969 }
970 }
971}
972
973void QWidget::repaint( int x, int y, int w, int h, bool erase )
974{
975 if ( (widget_state & (WState_Visible|WState_BlockUpdates)) == WState_Visible ) {
976#if defined (DEBUG_REPAINTRESIZE)
977 qDebug( "repaint(): [%s/%s/%08X] %d,%d; %d,%d erase: %d resizeNoErase: %d",
978 name(), className(), widget_flags, x, y, w, h, erase,
979 (testWFlags( WResizeNoErase ) != 0) );
980#endif
981 if ( w < 0 )
982 w = crect.width() - x;
983 if ( h < 0 )
984 h = crect.height() - y;
985 QRect r( x, y, w, h );
986 if ( r.isEmpty() )
987 return; // nothing to do
988
989 // flip y coordinate
990 int fy = crect.height() - (y + h);
991 RECTL rcl = { x, fy, x + w, fy + h };
992 WinValidateRect( winId(), &rcl, FALSE );
993
994 QRegion *pcrgn = 0;
995 if ( r != rect() ) {
996 pcrgn = new QRegion( r );
997 WinSetWindowULong( winId(), QWL_QTCLIPRGN, (ULONG) pcrgn );
998 }
999
1000 QPaintEvent e( r, erase );
1001 if ( erase )
1002 this->erase( x, y, w, h );
1003 QApplication::sendEvent( this, &e );
1004
1005 if ( pcrgn ) {
1006 WinSetWindowULong( winId(), QWL_QTCLIPRGN, 0 );
1007 delete pcrgn;
1008 }
1009 }
1010}
1011
1012void QWidget::repaint( const QRegion& reg, bool erase )
1013{
1014 if ( (widget_state & (WState_Visible|WState_BlockUpdates)) == WState_Visible ) {
1015#if defined (DEBUG_REPAINTRESIZE)
1016 qDebug( "repaint(): [%s/%s/%08X] <region> erase: %d resizeNoErase: %d",
1017 name(), className(), widget_flags,
1018 (testWFlags( WResizeNoErase ) != 0) );
1019#endif
1020 // convert region y coordinates from Qt to GPI (see qregion_pm.cpp)
1021 POINTL ptl = { 0, height() };
1022 GpiOffsetRegion( qt_display_ps(), reg.handle(), &ptl );
1023 WinValidateRegion( winId(), reg.handle(), FALSE );
1024 // convert region y coordinates back from GPI to Qt
1025 ptl.y = -ptl.y;
1026 GpiOffsetRegion( qt_display_ps(), reg.handle(), &ptl );
1027
1028 QRegion *pcrgn = new QRegion( reg );
1029 WinSetWindowULong( winId(), QWL_QTCLIPRGN, (ULONG) pcrgn );
1030
1031 QPaintEvent e( reg, erase );
1032 if ( erase )
1033 this->erase( reg );
1034 QApplication::sendEvent( this, &e );
1035
1036 WinSetWindowULong( winId(), QWL_QTCLIPRGN, 0 );
1037 delete pcrgn;
1038 }
1039}
1040
1041void QWidget::setWindowState(uint newstate)
1042{
1043 uint oldstate = windowState();
1044
1045 //@@TODO (dmik): should we deactivate the widget when no WindowActive
1046 // is specified? Guess no, because such behavior can be seen in Win32
1047 // (the only exception is when WindowMinimized is set w/o WindowActive).
1048 // As well as nothing is done in Win32 when only WindowActive is
1049 // specified.
1050 ULONG fl = (newstate & WindowActive) ?
1051 SWP_ACTIVATE :
1052 // mimic Win32 behavior
1053 (newstate & WindowMinimized) ? SWP_DEACTIVATE :
1054 // mimic Win32 behavior
1055 ((oldstate & WindowMinimized) &&
1056 (newstate & WindowMaximized)) ? SWP_ACTIVATE :
1057 0;
1058
1059 if (isTopLevel()) {
1060 WId id = winFId();
1061 QTLWExtra *top = topData();
1062
1063 if ((oldstate & WindowMaximized) != (newstate & WindowMaximized)) {
1064 if (isVisible() && !(newstate & WindowMinimized)) {
1065 ULONG f = (newstate & WindowMaximized) ? SWP_MAXIMIZE : SWP_RESTORE;
1066 WinSetWindowPos( id, 0, 0, 0, 0, 0, fl | f );
1067 QRect r = topData()->normalGeometry;
1068 if (!(newstate & WindowMaximized) && r.width() >= 0) {
1069 if (pos() != r.topLeft() || size() !=r.size()) {
1070 top->normalGeometry = QRect( 0, 0, -1, -1 );
1071 r.addCoords( top->fleft, top->ftop, top->fleft, top->ftop);
1072 setGeometry( r );
1073 }
1074 }
1075 }
1076 }
1077
1078 if ((oldstate & WindowFullScreen) != (newstate & WindowFullScreen)) {
1079 if (newstate & WindowFullScreen) {
1080 if ( top->normalGeometry.width() < 0 && !(oldstate & WindowMaximized) )
1081 top->normalGeometry = QRect( pos(), size() );
1082 QRect r = QApplication::desktop()->screenGeometry(this);
1083 r.addCoords( -top->fleft, -top->fbottom, top->fright, top->ftop );
1084 WinSetWindowPos(
1085 id, 0, r.x(), r.y(), r.width(), r.height(),
1086 fl | SWP_SIZE | SWP_MOVE
1087 );
1088//@@TODO (dmik): we do not need to call updateFrameStrut() because the frame
1089// is not changed, but who will update our crect?..
1090// updateFrameStrut();
1091 } else {
1092 ULONG f = fl;
1093 // the widget is still maximized
1094 if ( newstate & WindowMaximized ) {
1095 if (isVisible())
1096 f |= SWP_MAXIMIZE;
1097 }
1098 if ( f ) WinSetWindowPos( id, 0, 0, 0, 0, 0, f );
1099 if ( !(newstate & WindowMaximized) ) {
1100 QRect r = top->normalGeometry;
1101 top->normalGeometry = QRect( 0, 0, -1, -1 );
1102 r.addCoords( top->fleft, top->ftop, top->fleft, top->ftop);
1103 setGeometry( r );
1104 }
1105//@@TODO (dmik): we do not need to call updateFrameStrut() because the frame
1106// is not changed, but who will update our crect?..
1107// else {
1108// updateFrameStrut();
1109// }
1110 }
1111 }
1112
1113 if ((oldstate & WindowMinimized) != (newstate & WindowMinimized)) {
1114 if (isVisible()) {
1115 ULONG f =
1116 (newstate & WindowMinimized) ? SWP_MINIMIZE :
1117 (newstate & WindowMaximized) ? SWP_MAXIMIZE : SWP_RESTORE;
1118 WinSetWindowPos( id, 0, 0, 0, 0, 0, fl | f );
1119 }
1120 }
1121 }
1122
1123 widget_state &= ~(WState_Minimized | WState_Maximized | WState_FullScreen);
1124 if (newstate & WindowMinimized)
1125 widget_state |= WState_Minimized;
1126 if (newstate & WindowMaximized)
1127 widget_state |= WState_Maximized;
1128 if (newstate & WindowFullScreen)
1129 widget_state |= WState_FullScreen;
1130
1131 QEvent e(QEvent::WindowStateChange);
1132 QApplication::sendEvent(this, &e);
1133}
1134
1135
1136/*
1137 \internal
1138 Platform-specific part of QWidget::hide().
1139*/
1140
1141void QWidget::hideWindow()
1142{
1143 deactivateWidgetCleanup();
1144 HWND id = winFId();
1145 WinShowWindow( id, FALSE );
1146 if ( isTopLevel() )
1147 WinSetWindowPos( id, 0, 0, 0, 0, 0, SWP_DEACTIVATE );
1148
1149 HSWITCH swEntry = topData()->swEntry;
1150 if ( swEntry ) {
1151 SWCNTRL swc;
1152 WinQuerySwitchEntry( swEntry, &swc );
1153 swc.uchVisibility = SWL_INVISIBLE;
1154 WinChangeSwitchEntry( swEntry, &swc );
1155 }
1156}
1157
1158
1159/*
1160 \internal
1161 Platform-specific part of QWidget::show().
1162*/
1163
1164void QWidget::showWindow()
1165{
1166 WinShowWindow( winFId(), TRUE );
1167 ULONG fl = 0;
1168 if ( isTopLevel() ) {
1169 // we do this check here bevause setWindowState() does not actually
1170 // change the window state when the window is not visible, assuming
1171 // it will be done here.
1172 if (testWState(WState_Minimized))
1173 fl |= SWP_MINIMIZE;
1174 else if (testWState(WState_Maximized))
1175 fl |= SWP_MAXIMIZE;
1176
1177 if (
1178 !testWFlags(WType_Popup | WStyle_Tool) &&
1179 (!testWFlags(WType_Dialog) || !parentWidget())
1180 ) {
1181 HSWITCH &swEntry = topData()->swEntry;
1182 if ( !swEntry ) {
1183 // lazily create a new window list entry
1184 HWND id = winFId(); // frame handle, if any
1185 PID pid;
1186 WinQueryWindowProcess( id, &pid, NULL );
1187 SWCNTRL swc;
1188 memset( &swc, 0, sizeof(SWCNTRL) );
1189 swc.hwnd = id;
1190 swc.idProcess = pid;
1191 swc.uchVisibility = SWL_VISIBLE;
1192 swc.fbJump = SWL_JUMPABLE;
1193 WinQueryWindowText( id, sizeof(swc.szSwtitle), swc.szSwtitle );
1194 swEntry = WinAddSwitchEntry( &swc );
1195 } else {
1196 SWCNTRL swc;
1197 WinQuerySwitchEntry( swEntry, &swc );
1198 swc.uchVisibility = SWL_VISIBLE;
1199 WinChangeSwitchEntry( swEntry, &swc );
1200 }
1201 }
1202 }
1203 if (!testWFlags(WStyle_Tool) && !isPopup())
1204 fl |= SWP_ACTIVATE;
1205 if ( fl )
1206 WinSetWindowPos( winFId(), 0, 0, 0, 0, 0, fl );
1207
1208//@@TODO (dmik): remove? in OS/2 WinShowWindow() does not influence
1209// any other state flags of the window (such as maximized/minimized, active),
1210// so, the window is always shown at its current state (i.e. if its state was
1211// not changed while it was hidden it will be restored to that state upon
1212// unhiding; if the state was changed, it will be restored to that new state).
1213// int sm = SW_SHOWNORMAL;
1214// if ( isTopLevel() ) {
1215// if (testWState(WState_Minimized))
1216// sm = SW_SHOWMINIMIZED;
1217// else if (testWState(WState_Maximized))
1218// sm = SW_SHOWMAXIMIZED;
1219// }
1220// if (testWFlags(WStyle_Tool) || isPopup())
1221// sm = SW_SHOWNOACTIVATE;
1222//
1223// ShowWindow( winId(), sm );
1224// UpdateWindow( winId() );
1225}
1226
1227void QWidget::raise()
1228{
1229 QWidget *p = parentWidget();
1230 if ( p && p->childObjects && p->childObjects->findRef(this) >= 0 )
1231 p->childObjects->append( p->childObjects->take() );
1232//@@TODO (dmik): remove? SWP_ZORDER doesn't cause activation in OS/2...
1233// uint f = ( isPopup() || testWFlags(WStyle_Tool) ) ? SWP_NOACTIVATE : 0;
1234 WinSetWindowPos( winFId(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
1235}
1236
1237void QWidget::lower()
1238{
1239 QWidget *p = parentWidget();
1240 if ( p && p->childObjects && p->childObjects->findRef(this) >= 0 )
1241 p->childObjects->insert( 0, p->childObjects->take() );
1242//@@TODO (dmik): remove? SWP_ZORDER doesn't cause activation in OS/2...
1243// uint f = ( isPopup() || testWFlags(WStyle_Tool) ) ? SWP_NOACTIVATE : 0;
1244 WinSetWindowPos( winFId(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER );
1245}
1246
1247void QWidget::stackUnder( QWidget* w )
1248{
1249 QWidget *p = parentWidget();
1250 if ( !w || isTopLevel() || p != w->parentWidget() || this == w )
1251 return;
1252 if ( p && p->childObjects && p->childObjects->findRef(w) >= 0 && p->childObjects->findRef(this) >= 0 ) {
1253 p->childObjects->take();
1254 p->childObjects->insert( p->childObjects->findRef(w), this );
1255 }
1256 WinSetWindowPos( winId(), w->winId(), 0, 0, 0, 0, SWP_ZORDER );
1257}
1258
1259//
1260// The internal qPMRequestConfig, defined in qeventloop_pm.cpp, stores move,
1261// resize and setGeometry requests for a widget that is already
1262// processing a config event. The purpose is to avoid recursion.
1263//
1264void qPMRequestConfig( WId, int, int, int, int, int );
1265
1266void QWidget::internalSetGeometry( int x, int y, int w, int h, bool isMove )
1267{
1268 if ( extra ) { // any size restrictions?
1269 w = QMIN(w,extra->maxw);
1270 h = QMIN(h,extra->maxh);
1271 w = QMAX(w,extra->minw);
1272 h = QMAX(h,extra->minh);
1273 }
1274 if ( w < 1 ) // invalid size
1275 w = 1;
1276 if ( h < 1 )
1277 h = 1;
1278 QSize oldSize( size() );
1279 QPoint oldPos( pos() );
1280 if ( !isTopLevel() )
1281 isMove = (crect.topLeft() != QPoint( x, y ));
1282 if ( isMove == FALSE && oldSize.width()==w && oldSize.height()==h )
1283 return;
1284 clearWState(WState_Maximized);
1285 clearWState(WState_FullScreen);
1286 if (isTopLevel())
1287 topData()->normalGeometry = QRect(0, 0, -1, -1);
1288 if ( testWState(WState_ConfigPending) ) { // processing config event
1289 qPMRequestConfig( winId(), isMove ? 2 : 1, x, y, w, h );
1290 } else {
1291 setWState( WState_ConfigPending );
1292 if ( isTopLevel() ) {
1293//@@TODO (dmik): remove, no need to check for extra...
1294// QRect fr( frameGeometry() );
1295// if ( extra ) {
1296// fr.setLeft( fr.left() + x - crect.left() );
1297// fr.setTop( fr.top() + y - crect.top() );
1298// fr.setRight( fr.right() + ( x + w - 1 ) - crect.right() );
1299// fr.setBottom( fr.bottom() + ( y + h - 1 ) - crect.bottom() );
1300// }
1301// MoveWindow( winId(), fr.x(), fr.y(), fr.width(), fr.height(), TRUE );
1302// crect.setRect( x, y, w, h );
1303
1304//@@TODO (dmik): optimize: use extra->topextra directly (after updating fstrut
1305// if necessary) instead of calling frameGeometry()
1306 QRect fr( frameGeometry() );
1307 int fx = fr.left() + x - crect.left();
1308 int fy = fr.top() + y - crect.top();
1309 int fw = fr.width() + w - crect.width();
1310 int fh = fr.height() + h - crect.height();
1311 // flip y coordinate
1312 fy = QApplication::desktop()->height() - (fy + fh);
1313 crect.setRect( x, y, w, h );
1314 WinSetWindowPos( winFId(), 0, fx, fy, fw, fh, SWP_MOVE | SWP_SIZE );
1315 } else {
1316 // flip y coordinate
1317 int fy = parentWidget()->height() - (y + h);
1318 crect.setRect( x, y, w, h );
1319 WinSetWindowPos( winId(), 0, x, fy, w, h, SWP_MOVE | SWP_SIZE );
1320 }
1321 clearWState( WState_ConfigPending );
1322 }
1323
1324 bool isResize = w != oldSize.width() || h != oldSize.height();
1325 if ( isVisible() ) {
1326 if ( isMove && pos() != oldPos ) {
1327 QMoveEvent e( pos(), oldPos );
1328 QApplication::sendEvent( this, &e );
1329 }
1330 if ( isResize ) {
1331 QResizeEvent e( size(), oldSize );
1332 QApplication::sendEvent( this, &e );
1333 if ( !testWFlags( WStaticContents ) )
1334 repaint( !testWFlags(WResizeNoErase) );
1335 }
1336 } else {
1337 if ( isMove && pos() != oldPos )
1338 QApplication::postEvent( this,
1339 new QMoveEvent( pos(), oldPos ) );
1340 if ( isResize )
1341 QApplication::postEvent( this,
1342 new QResizeEvent( size(), oldSize ) );
1343 }
1344}
1345
1346void QWidget::setMinimumSize( int minw, int minh )
1347{
1348#if defined(QT_CHECK_RANGE)
1349 if ( minw < 0 || minh < 0 )
1350 qWarning("QWidget::setMinimumSize: The smallest allowed size is (0,0)");
1351#endif
1352 createExtra();
1353 if ( extra->minw == minw && extra->minh == minh )
1354 return;
1355 extra->minw = minw;
1356 extra->minh = minh;
1357 if ( minw > width() || minh > height() ) {
1358 bool resized = testWState( WState_Resized );
1359 resize( QMAX(minw,width()), QMAX(minh,height()) );
1360 if ( !resized )
1361 clearWState( WState_Resized ); //not a user resize
1362 }
1363 updateGeometry();
1364}
1365
1366void QWidget::setMaximumSize( int maxw, int maxh )
1367{
1368#if defined(QT_CHECK_RANGE)
1369 if ( maxw > QWIDGETSIZE_MAX || maxh > QWIDGETSIZE_MAX ) {
1370 qWarning("QWidget::setMaximumSize: The largest allowed size is (%d,%d)",
1371 QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
1372 maxw = QMIN( maxw, QWIDGETSIZE_MAX );
1373 maxh = QMIN( maxh, QWIDGETSIZE_MAX );
1374 }
1375 if ( maxw < 0 || maxh < 0 ) {
1376 qWarning("QWidget::setMaximumSize: (%s/%s) Negative sizes (%d,%d) "
1377 "are not possible",
1378 name( "unnamed" ), className(), maxw, maxh );
1379 maxw = QMAX( maxw, 0 );
1380 maxh = QMAX( maxh, 0 );
1381 }
1382#endif
1383 createExtra();
1384 if ( extra->maxw == maxw && extra->maxh == maxh )
1385 return;
1386 extra->maxw = maxw;
1387 extra->maxh = maxh;
1388 if ( maxw < width() || maxh < height() ) {
1389 bool resized = testWState( WState_Resized );
1390 resize( QMIN(maxw,width()), QMIN(maxh,height()) );
1391 if ( !resized )
1392 clearWState( WState_Resized ); //not a user resize
1393 }
1394 updateGeometry();
1395}
1396
1397void QWidget::setSizeIncrement( int w, int h )
1398{
1399 createTLExtra();
1400 extra->topextra->incw = w;
1401 extra->topextra->inch = h;
1402}
1403
1404void QWidget::setBaseSize( int w, int h )
1405{
1406 createTLExtra();
1407 extra->topextra->basew = w;
1408 extra->topextra->baseh = h;
1409}
1410
1411extern void qt_erase_background( HPS, int, int, int, int,
1412 const QColor &, const QPixmap *, int, int, int );
1413
1414void QWidget::erase( int x, int y, int w, int h )
1415{
1416 // SIMILAR TO region ERASE BELOW
1417
1418 if ( backgroundMode()==NoBackground )
1419 return;
1420 if ( w < 0 )
1421 w = crect.width() - x;
1422 if ( h < 0 )
1423 h = crect.height() - y;
1424
1425 HPS lhps;
1426 bool tmphps;
1427
1428 if( QPainter::redirect( this ) ) {
1429 tmphps = FALSE;
1430 lhps = QPainter::redirect( this )->handle();
1431 Q_ASSERT( lhps );
1432 } else if ( !hps ) {
1433 tmphps = TRUE;
1434 lhps = WinGetPS( winId() );
1435 } else {
1436 tmphps = FALSE;
1437 lhps = hps;
1438 }
1439
1440 QPoint offset = backgroundOffset();
1441 int ox = offset.x();
1442 int oy = offset.y();
1443
1444 qt_erase_background(
1445 lhps, x, y, w, h, bg_col, backgroundPixmap(),
1446 ox, oy, crect.height()
1447 );
1448
1449 if ( tmphps ) {
1450 WinReleasePS( lhps );
1451 hps = 0;
1452 }
1453}
1454
1455void QWidget::erase( const QRegion& rgn )
1456{
1457 // SIMILAR TO rect ERASE ABOVE
1458
1459 if ( backgroundMode()==NoBackground )
1460 return;
1461
1462 HPS lhps;
1463 bool tmphps;
1464
1465 if( QPainter::redirect( this ) ) {
1466 tmphps = FALSE;
1467 lhps = QPainter::redirect( this )->handle();
1468 Q_ASSERT( lhps );
1469 } else if ( !hps ) {
1470 tmphps = TRUE;
1471 lhps = WinGetPS( winId() );
1472 } else {
1473 tmphps = FALSE;
1474 lhps = hps;
1475 }
1476
1477 // convert region y coordinates from Qt to GPI (see qregion_pm.cpp)
1478 POINTL ptl = { 0, height() };
1479 GpiOffsetRegion( lhps, rgn.handle(), &ptl );
1480
1481 HRGN oldRegion = GpiQueryClipRegion( lhps );
1482 HRGN newRegion = 0;
1483 if ( oldRegion ) {
1484 GpiSetClipRegion( lhps, 0, NULL );
1485 newRegion = GpiCreateRegion( lhps, 0, NULL );
1486 GpiCombineRegion( lhps, newRegion, oldRegion, rgn.handle(), CRGN_AND );
1487 } else {
1488 newRegion = rgn.handle();
1489 }
1490 GpiSetClipRegion( lhps, newRegion, &oldRegion );
1491
1492 QPoint offset = backgroundOffset();
1493 int ox = offset.x();
1494 int oy = offset.y();
1495
1496 qt_erase_background(
1497 lhps, 0, 0, crect.width(), crect.height(),
1498 bg_col, backgroundPixmap(), ox, oy, crect.height()
1499 );
1500
1501 GpiSetClipRegion( lhps, oldRegion, NULL );
1502
1503 // convert region y coordinates back from GPI to Qt
1504 ptl.y = -ptl.y;
1505 GpiOffsetRegion( lhps, rgn.handle(), &ptl );
1506
1507 if ( oldRegion )
1508 GpiDestroyRegion( lhps, newRegion );
1509 if ( tmphps ) {
1510 WinReleasePS( lhps );
1511 hps = 0;
1512 }
1513}
1514
1515
1516// helper function to extract regions of all windows that overlap the given
1517// hwnd subject to their z-order (excluding children of hwnd) from the given
1518// hrgn. hps is the presentation space of hrgn.
1519void qt_WinExcludeOverlappingWindows( HWND hwnd, HPS hps, HRGN hrgn )
1520{
1521 HRGN vr = GpiCreateRegion( hps, 0, NULL );
1522 RECTL r;
1523
1524 // enumerate all windows that are on top of this hwnd
1525 HWND id = hwnd, deskId = QApplication::desktop()->winId();
1526 do {
1527 HWND i = id;
1528 while( (i = WinQueryWindow( i, QW_PREV )) ) {
1529 if ( WinIsWindowShowing( i ) ) {
1530//@@TODO (dmik): probably we should use WinQueryClipRegion() here to
1531// handle non-rectangular windows properly
1532 WinQueryWindowRect( i, &r );
1533 WinMapWindowPoints( i, hwnd, (PPOINTL) &r, 2 );
1534 GpiSetRegion( hps, vr, 1, &r );
1535 GpiCombineRegion( hps, hrgn, hrgn, vr, CRGN_DIFF );
1536 }
1537 }
1538 id = WinQueryWindow( id, QW_PARENT );
1539 } while( id != deskId );
1540
1541 GpiDestroyRegion( hps, vr );
1542}
1543
1544// helper function to scroll window contents. WinScrollWindow() is a bit
1545// buggy and corrupts update regions sometimes (which leaves some outdated
1546// areas unpainted after scrolling), so we reimplement its functionality in
1547// this function. dy and clip->yBottom/yTop should be GPI coordinates, not Qt.
1548// all clip coordinates are inclusive.
1549void qt_WinScrollWindowWell( HWND hwnd, LONG dx, LONG dy, const PRECTL clip = NULL )
1550{
1551 WinLockVisRegions( HWND_DESKTOP, TRUE );
1552
1553 HPS lhps = WinGetClipPS(
1554 hwnd, HWND_TOP,
1555 PSF_LOCKWINDOWUPDATE | PSF_CLIPSIBLINGS
1556 );
1557 if ( clip )
1558 GpiIntersectClipRectangle( lhps, clip );
1559
1560 // remember the update region and validate it. it will be shifted and
1561 // invalidated again later
1562 HRGN update = GpiCreateRegion( lhps, 0, NULL );
1563 WinQueryUpdateRegion( hwnd, update );
1564 WinValidateRegion( hwnd, update, TRUE );
1565
1566 POINTL ptls[4];
1567 RECTL &sr = *(PRECTL) &ptls[2];
1568 RECTL &tr = *(PRECTL) &ptls[0];
1569
1570 // get the source rect for scrolling
1571 GpiQueryClipBox( lhps, &sr );
1572 sr.xRight++; sr.yTop++; // inclusive -> exclusive
1573
1574 // get the visible region ignoring areas covered by children
1575 HRGN visible = GpiCreateRegion( lhps, 1, &sr );
1576 qt_WinExcludeOverlappingWindows( hwnd, lhps, visible );
1577
1578 // scroll visible region rectangles separately to avoid the flicker
1579 // that could be produced by scrolling parts of overlapping windows
1580 RGNRECT ctl;
1581 ctl.ircStart = 1;
1582 ctl.crc = 0;
1583 ctl.crcReturned = 0;
1584 if ( dx >= 0 ) {
1585 if ( dy >= 0 ) ctl.ulDirection = RECTDIR_RTLF_TOPBOT;
1586 else ctl.ulDirection = RECTDIR_RTLF_BOTTOP;
1587 } else {
1588 if ( dy >= 0 ) ctl.ulDirection = RECTDIR_LFRT_TOPBOT;
1589 else ctl.ulDirection = RECTDIR_LFRT_BOTTOP;
1590 }
1591 GpiQueryRegionRects( lhps, visible, NULL, &ctl, NULL );
1592 ctl.crc = ctl.crcReturned;
1593 int rclcnt = ctl.crcReturned;
1594 PRECTL rcls = new RECTL[rclcnt];
1595 GpiQueryRegionRects( lhps, visible, NULL, &ctl, rcls );
1596 PRECTL r = rcls;
1597 for ( int i = 0; i < rclcnt; i++, r++ ) {
1598 // source rect
1599 sr = *r;
1600 // target rect
1601 tr.xLeft = sr.xLeft + dx;
1602 tr.xRight = sr.xRight + dx;
1603 tr.yBottom = sr.yBottom + dy;
1604 tr.yTop = sr.yTop + dy;
1605 GpiBitBlt( lhps, lhps, 3, ptls, ROP_SRCCOPY, BBO_IGNORE );
1606 }
1607 delete [] rcls;
1608
1609 // make the scrolled version of the visible region
1610 HRGN scrolled = GpiCreateRegion( lhps, 0, NULL );
1611 GpiCombineRegion( lhps, scrolled, visible, 0, CRGN_COPY );
1612 // invalidate the initial update region
1613 GpiCombineRegion( lhps, scrolled, scrolled, update, CRGN_DIFF );
1614 // shift the region
1615 POINTL dp = { dx, dy };
1616 GpiOffsetRegion( lhps, scrolled, &dp );
1617 // substract scrolled from visible to get invalid areas
1618 GpiCombineRegion( lhps, scrolled, visible, scrolled, CRGN_DIFF );
1619
1620 WinInvalidateRegion( hwnd, scrolled, TRUE );
1621
1622 GpiDestroyRegion( lhps, scrolled );
1623 GpiDestroyRegion( lhps, visible );
1624 GpiDestroyRegion( lhps, update );
1625
1626 WinReleasePS( lhps );
1627
1628 WinLockVisRegions( HWND_DESKTOP, FALSE );
1629
1630 WinUpdateWindow( hwnd );
1631}
1632
1633void QWidget::scroll( int dx, int dy )
1634{
1635 if ( testWState( WState_BlockUpdates ) && !children() )
1636 return;
1637
1638 // move non-toplevel children
1639 if ( children() ) {
1640 QObjectListIt it(*children());
1641 register QObject *obj;
1642 int h = crect.height();
1643 while ( (obj=it.current()) ) {
1644 ++it;
1645 if ( obj->isWidgetType() ) {
1646 QWidget *w = (QWidget*)obj;
1647 if ( !w->isTopLevel() ) {
1648 WinSetWindowPos(
1649 w->winId(), 0,
1650 w->crect.left() + dx,
1651 // flip y coordinate
1652 h - (w->crect.bottom() + dy + 1),
1653 0, 0,
1654 SWP_MOVE | SWP_NOADJUST | SWP_NOREDRAW
1655 );
1656 // WinSetWindowPos() doesn't send WM_MOVE to windows w/o
1657 // CS_MOVENOTIFY, but having this style for non-toplevel
1658 // widgets is unwanted, so we send them WM_MOVE manually
1659 // to let their geometry to be properly updated by
1660 // QETWidget::translateConfigEvent().
1661 WinSendMsg( w->winId(), WM_MOVE, 0, 0 );
1662 }
1663 }
1664 }
1665 }
1666
1667 qt_WinScrollWindowWell( winId(), dx, -dy, NULL );
1668}
1669
1670void QWidget::scroll( int dx, int dy, const QRect& r )
1671{
1672 if ( testWState( WState_BlockUpdates ) )
1673 return;
1674
1675 int h = crect.height();
1676 // flip y coordinate (all coordinates are inclusive)
1677 RECTL rcl = { r.left(), h - (r.bottom() + 1), r.right(), h - (r.top() + 1) };
1678 qt_WinScrollWindowWell( winId(), dx, -dy, &rcl );
1679}
1680
1681void QWidget::drawText( int x, int y, const QString &str )
1682{
1683 if ( testWState(WState_Visible) ) {
1684 QPainter paint;
1685 paint.begin( this );
1686 paint.drawText( x, y, str );
1687 paint.end();
1688 }
1689}
1690
1691
1692int QWidget::metric( int m ) const
1693{
1694 LONG val;
1695 if ( m == QPaintDeviceMetrics::PdmWidth ) {
1696 val = crect.width();
1697 } else if ( m == QPaintDeviceMetrics::PdmHeight ) {
1698 val = crect.height();
1699 } else {
1700 HDC hdc = GpiQueryDevice( qt_display_ps() );
1701 switch ( m ) {
1702 case QPaintDeviceMetrics::PdmDpiX:
1703 case QPaintDeviceMetrics::PdmPhysicalDpiX:
1704 DevQueryCaps( hdc, CAPS_HORIZONTAL_FONT_RES, 1, &val );
1705 break;
1706 case QPaintDeviceMetrics::PdmDpiY:
1707 case QPaintDeviceMetrics::PdmPhysicalDpiY:
1708 DevQueryCaps( hdc, CAPS_VERTICAL_FONT_RES, 1, &val );
1709 break;
1710 case QPaintDeviceMetrics::PdmWidthMM:
1711 DevQueryCaps( hdc, CAPS_HORIZONTAL_RESOLUTION, 1, &val );
1712 val = width() * 1000 / val;
1713 break;
1714 case QPaintDeviceMetrics::PdmHeightMM:
1715 DevQueryCaps( hdc, CAPS_VERTICAL_RESOLUTION, 1, &val );
1716 val = width() * 1000 / val;
1717 break;
1718 case QPaintDeviceMetrics::PdmNumColors:
1719 DevQueryCaps( hdc, CAPS_COLORS, 1, &val );
1720 break;
1721 case QPaintDeviceMetrics::PdmDepth:
1722 LONG colorInfo [2];
1723 DevQueryCaps( hdc, CAPS_COLOR_PLANES, 2, colorInfo );
1724 val = colorInfo [0] * colorInfo [1];
1725 break;
1726 default:
1727 val = 0;
1728#if defined(QT_CHECK_RANGE)
1729 qWarning( "QWidget::metric: Invalid metric command" );
1730#endif
1731 }
1732 }
1733 return val;
1734}
1735
1736void QWidget::createSysExtra()
1737{
1738//@@TODO (dmik): later
1739// extra->dropTarget = 0;
1740}
1741
1742void QWidget::deleteSysExtra()
1743{
1744 setAcceptDrops( FALSE );
1745}
1746
1747void QWidget::createTLSysExtra()
1748{
1749//@@TODO (dmik): remove?
1750// extra->topextra->winIcon = 0;
1751 extra->topextra->fId = 0;
1752 extra->topextra->swEntry = 0;
1753}
1754
1755void QWidget::deleteTLSysExtra()
1756{
1757 if ( extra->topextra->swEntry ) {
1758 WinRemoveSwitchEntry( extra->topextra->swEntry );
1759 }
1760 // frame window (extra->topextra->fId) is destroyed in
1761 // destroy() if it exists
1762//@@TODO (dmik): remove?
1763// if ( extra->topextra->winIcon )
1764// DestroyIcon( extra->topextra->winIcon );
1765}
1766
1767bool QWidget::acceptDrops() const
1768{
1769 return 0;
1770//@@TODO (dmik): later
1771// return ( extra && extra->dropTarget );
1772}
1773
1774void QWidget::setAcceptDrops( bool on )
1775{
1776//@@TODO (dmik): later
1777// // Enablement is defined by extra->dropTarget != 0.
1778//
1779// if ( on ) {
1780// // Turn on.
1781// createExtra();
1782// QWExtra *extra = extraData();
1783// if ( !extra->dropTarget )
1784// extra->dropTarget = qt_olednd_register( this );
1785// } else {
1786// // Turn off.
1787// QWExtra *extra = extraData();
1788// if ( extra && extra->dropTarget ) {
1789// qt_olednd_unregister(this, extra->dropTarget);
1790// extra->dropTarget = 0;
1791// }
1792// }
1793}
1794
1795void QWidget::setMask( const QRegion &region )
1796{
1797 qWarning( "QWidget::setMask() is not yet implemented on OS/2" );
1798//@@TODO (dmik): later (don't forget to offset region, see qregion_pm.cpp)
1799// // Since SetWindowRegion takes ownership, and we need to translate,
1800// // we take a copy.
1801// HRGN wr = CreateRectRgn(0,0,1,1);
1802// CombineRgn(wr, region.handle(), 0, RGN_COPY);
1803//
1804// int fleft = 0, ftop = 0;
1805// if (isTopLevel()) {
1806// ftop = topData()->ftop;
1807// fleft = topData()->fleft;
1808// }
1809// OffsetRgn(wr, fleft, ftop );
1810// SetWindowRgn( winId(), wr, TRUE );
1811}
1812
1813void QWidget::setMask( const QBitmap &bitmap )
1814{
1815 qWarning( "QWidget::setMask() is not yet implemented on OS/2" );
1816//@@TODO (dmik): later
1817// HRGN wr = qt_win_bitmapToRegion(bitmap);
1818//
1819// int fleft = 0, ftop = 0;
1820// if (isTopLevel()) {
1821// ftop = topData()->ftop;
1822// fleft = topData()->fleft;
1823// }
1824// OffsetRgn(wr, fleft, ftop );
1825// SetWindowRgn( winId(), wr, TRUE );
1826}
1827
1828void QWidget::clearMask()
1829{
1830 qWarning( "QWidget::clearMask() is not yet implemented on OS/2" );
1831//@@TODO (dmik): later
1832// SetWindowRgn( winId(), 0, TRUE );
1833}
1834
1835void QWidget::setName( const char *name )
1836{
1837 QObject::setName( name );
1838}
1839
1840void QWidget::updateFrameStrut() const
1841{
1842 QWidget *that = (QWidget *) this;
1843
1844 if ( !isVisible() || isDesktop() ) {
1845 that->fstrut_dirty = isVisible();
1846 return;
1847 }
1848
1849 QTLWExtra *top = that->topData();
1850 if ( top->fId ) {
1851 // this widget has WC_FRAME
1852 SWP cswp;
1853 WinQueryWindowPos( winId(), &cswp );
1854 SWP fswp;
1855 WinQueryWindowPos( top->fId, &fswp );
1856 // flip y coordinates
1857 fswp.y = QApplication::desktop()->height() - (fswp.y + fswp.cy);
1858 cswp.y = fswp.cy - (cswp.y + cswp.cy);
1859 that->crect.setRect(
1860 fswp.x + cswp.x, fswp.y + cswp.y,
1861 cswp.cx, cswp.cy
1862 );
1863
1864 top->fleft = cswp.x;
1865 top->ftop = cswp.y;
1866 top->fright = fswp.cx - cswp.x - cswp.cx;
1867 top->fbottom = fswp.cy - cswp.y - cswp.cy;
1868 }
1869 that->fstrut_dirty = FALSE;
1870}
1871
1872void QWidget::setMouseTracking( bool enable )
1873{
1874 if ( enable )
1875 setWState( WState_MouseTracking );
1876 else
1877 clearWState( WState_MouseTracking );
1878}
1879
1880void QWidget::setWindowOpacity(double)
1881{
1882}
1883
1884double QWidget::windowOpacity() const
1885{
1886 return 1.0;
1887}
1888
1889/*
1890 \internal
1891 Returns the frame wihdow handle if this widget is a top-level widget and
1892 has the standard WC_FRAME as its parent/owner (where it is FID_CLIENT).
1893 If the widget does not have the standard frame or it is not top-level, this
1894 function simply retuns the winId() value.
1895*/
1896WId QWidget::winFId()
1897{
1898 HWND fId = 0;
1899 if ( isTopLevel() )
1900 fId = topData()->fId;
1901 if ( !fId )
1902 fId = winId();
1903 return fId;
1904}
1905
Note: See TracBrowser for help on using the repository browser.