Changeset 114


Ignore:
Timestamp:
Aug 14, 2009, 11:20:20 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Implemented QWidget::map[To|From]Global.

Location:
trunk/src/gui/kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qapplication_pm.cpp

    r112 r114  
    132132//  inline void showChildren(bool spontaneous) { d_func()->showChildren(spontaneous); }
    133133//  inline void hideChildren(bool spontaneous) { d_func()->hideChildren(spontaneous); }
     134
    134135//  inline uint testWindowState(uint teststate){ return dataPtr()->window_state & teststate; }
    135136//  inline void forceUpdate() {
     
    14461447    // qwidget_pm.cpp), we have to validate areas that intersect with our
    14471448    // children and siblings, taking their clip regions into account.
    1448 //    validateObstacles();
     1449    validateObstacles();
    14491450
    14501451    Q_ASSERT(testAttribute(Qt::WA_WState_Created));
     
    14731474    d_func()->hd = WinBeginPaint(internalWinId(), 0, &rcl);
    14741475
     1476
     1477
     1478
     1479
     1480
     1481
    14751482    // it's possible that the update rectangle is empty
    14761483    if (rcl.xRight <= rcl.xLeft || rcl.yTop <= rcl.yBottom) {
  • trunk/src/gui/kernel/qwidget_p.h

    r112 r114  
    633633
    634634    void setModal_sys();
     635
     636
     637
     638
     639
     640
     641
     642
     643
    635644    QSizePolicy size_policy;
    636645    QLocale locale;
  • trunk/src/gui/kernel/qwidget_pm.cpp

    r112 r114  
    107107}
    108108
    109 // Returns a QWidget pointer or 0 if there is no widget corresponding to the
    110 // given HWND. As opposed to QWidget::find(), correctly handles WC_FRAME windows
    111 // created for top level widgets. Used for debugging.
    112 static QWidget *widgetFromId(HWND hwnd)
    113 {
    114     char buf[10];
    115     if (WinQueryClassName(hwnd, sizeof(buf), buf)) {
    116         if (!strcmp(buf, "#1")) // WC_FRAME
    117             hwnd = WinWindowFromID(hwnd, FID_CLIENT);
    118         return QWidget::find(hwnd);
    119     }
    120     return 0;
    121 }
    122 
    123 // Returns a human readable widget name in the form "class/name".
    124 // Used for debugging.
    125 static QByteArray widgetName(QWidget *w)
    126 {
    127     if (w)
    128         return QString()
    129             .sprintf("%s/%s", w->metaObject()->className(),
    130                      w->objectName().toLocal8Bit().constData()).toLocal8Bit();
    131     return QByteArray("<no-widget>");
    132 }
    133 
    134109/*!
    135110    \internal
     
    170145    qDebug("qt_WinInvalidateRegionEx: hwnd=%08lX [%s] "
    171146           "hwndFrom=%08lX hwndTo=%08lX", hwnd,
    172            widgetName(widgetFromId(hwnd)).constData(),
     147           ).constData(),
    173148           hwndFrom, hwndTo);
    174149#endif
     
    200175#if defined(QT_DEBUGWIDGETMASK)
    201176        qDebug(" child=%08lX [fl=%08lX] [%s]", child, swp.fl,
    202                widgetName(widgetFromId(child)).constData());
     177               ).constData());
    203178#endif
    204179        // proceed only if not hidden
     
    286261    qDebug("qt_WinProcessWindowObstacles: hwnd=%08lX [%s], prcl=%p "
    287262           "hrgn=%08lX, op=%ld flags=%08lX", hwnd,
    288            widgetName(widgetFromId(hwnd)).constData(),
     263           ).constData(),
    289264           prcl, hrgn, op, flags);
    290265#endif
     
    339314#if defined(QT_DEBUGWIDGETMASK)
    340315                qDebug(" child=%08lX [fl=%08lX] [%s]", relative, swp.fl,
    341                        widgetName(widgetFromId(relative)).constData());
     316                       ).constData());
    342317#endif
    343318                // skip if hidden
     
    379354#if defined(QT_DEBUGWIDGETMASK)
    380355            qDebug(" sibling=%08lX [fl=%08lX] [%s]", relative, swp.fl,
    381                    widgetName(widgetFromId(relative)).constData());
     356                   ).constData());
    382357#endif
    383358            // skip if hidden
     
    429404#if defined(QT_DEBUGWIDGETMASK)
    430405            qDebug(" parent=%08lX [fl=%08lX] [%s]", parent, swp.fl,
    431                    widgetName(widgetFromId(parent)).constData());
     406                   ).constData());
    432407#endif
    433408            delta.x += swp.x;
     
    438413#if defined(QT_DEBUGWIDGETMASK)
    439414                qDebug(" ancestor=%08lX [fl=%08lX] [%s]", relative, swp.fl,
    440                        widgetName(widgetFromId(parent)).constData());
     415                       ).constData());
    441416#endif
    442417                // skip if hidden
     
    489464#if defined(QT_DEBUGWIDGETMASK)
    490465    qDebug("qt_WinSetWindowPos: hwnd=%08lX [%s] fl=%08lX", hwnd,
    491            widgetName(widgetFromId(hwnd)).constData(), fl);
     466           ).constData(), fl);
    492467#endif
    493468
     
    577552        qDebug(" moving up? %ld", up);
    578553        qDebug(" hwndFrom=%08lX [%s]", hwndFrom,
    579                widgetName(widgetFromId(hwndFrom)).constData());
     554               ).constData());
    580555        qDebug(" hwndTo=%08lX [%s]", hwndTo,
    581                widgetName(widgetFromId(hwndTo)).constData());
     556               ).constData());
    582557#endif
    583558
     
    593568#if defined(QT_DEBUGWIDGETMASK)
    594569                qDebug(" sibling=%08lX [fl=%08lX] [%s]", sibling, swp.fl,
    595                        widgetName(widgetFromId(sibling)).constData());
     570                       ).constData());
    596571#endif
    597572                // proceed only if not hidden
     
    624599#if defined(QT_DEBUGWIDGETMASK)
    625600                qDebug(" sibling=%08lX [fl=%08lX] [%s]", sibling, swp.fl,
    626                        widgetName(widgetFromId(sibling)).constData());
     601                       ).constData());
    627602#endif
    628603                // proceed only if not hidden
     
    904879                   "|  style = %08lX\n"
    905880                   "|  fcFlags = %08lX",
    906                    widgetName(q).constData(), ownerw, title.constData(), fStyle,
    907                    fcFlags);
     881                   ,
     882                   fcFlags);
    908883#endif
    909884            fId = WinCreateWindow(HWND_DESKTOP, WC_FRAME, title, fStyle,
     
    932907                   "|  title = '%s'\n"
    933908                   "|  style = %08lX",
    934                    widgetName(q).constData(), fId, className.constData(),
     909                   ame(q).constData(), fId, className.constData(),
    935910                   title.constData(), style);
    936911#endif
     
    945920                   "|  title = '%s'\n"
    946921                   "|  style = %08lX",
    947                    widgetName(q).constData(), className.constData(),
     922                   ame(q).constData(), className.constData(),
    948923                   title.constData(), style);
    949924#endif
     
    10591034               "|  title = '%s'\n"
    10601035               "|  style = %08lX",
    1061                widgetName(q).constData(), parentw, className.constData(),
     1036               ame(q).constData(), parentw, className.constData(),
    10621037               title.constData(), style);
    10631038#endif
     
    11331108#if defined(QT_DEBUGWINCREATEDESTROY)
    11341109            qDebug("|Destroying window [%s]:\n"
    1135                    "|  hwnd = %08lX", widgetName(this).constData(), id);
     1110                   "|  hwnd = %08lX", ame(this).constData(), id);
    11361111#endif
    11371112
     
    11491124QPoint QWidget::mapToGlobal(const QPoint &pos) const
    11501125{
    1151     // @todo implement
    1152     return QPoint();
     1126    Q_D(const QWidget);
     1127    QWidget *parentWindow = window();
     1128    if (!isVisible() || parentWindow->isMinimized() || !testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
     1129        QPoint toGlobal = mapTo(parentWindow, pos) + parentWindow->pos();
     1130        // Adjust for window decorations
     1131        toGlobal += parentWindow->geometry().topLeft() - parentWindow->frameGeometry().topLeft();
     1132        return toGlobal;
     1133    }
     1134    QPoint pos2 = d->mapToWS(pos);
     1135    POINTL ptl;
     1136    ptl.x = pos2.x();
     1137    // flip y (local) coordinate
     1138    ptl.y = height() - (pos2.y() + 1);
     1139    WinMapWindowPoints(internalWinId(), HWND_DESKTOP, &ptl, 1);
     1140    // flip y (global) coordinate
     1141    ptl.y = QApplication::desktop()->height() - (ptl.y + 1);
     1142    return QPoint(ptl.x, ptl.y);
    11531143}
    11541144
    11551145QPoint QWidget::mapFromGlobal(const QPoint &pos) const
    11561146{
    1157     // @todo implement
    1158     return QPoint();
     1147    Q_D(const QWidget);
     1148    QWidget *parentWindow = window();
     1149    if (!isVisible() || parentWindow->isMinimized() || !testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
     1150        QPoint fromGlobal = mapFrom(parentWindow, pos - parentWindow->pos());
     1151        // Adjust for window decorations
     1152        fromGlobal -= parentWindow->geometry().topLeft() - parentWindow->frameGeometry().topLeft();
     1153        return fromGlobal;
     1154    }
     1155    POINTL ptl;
     1156    ptl.x = pos.x();
     1157    // flip y (global) coordinate
     1158    ptl.y = QApplication::desktop()->height() - (pos.y() + 1);
     1159    WinMapWindowPoints(HWND_DESKTOP, internalWinId(), &ptl, 1);
     1160    // flip y (local) coordinate
     1161    ptl.y = height() - (ptl.y + 1);
     1162    return d->mapFromWS(QPoint(ptl.x, ptl.y));
    11591163}
    11601164
     
    15131517}
    15141518
     1519
     1520
     1521
     1522
     1523
     1524
     1525
     1526
     1527
     1528
     1529
     1530
     1531
     1532
     1533
     1534
     1535
     1536
     1537
     1538
     1539
     1540
     1541
     1542
     1543
     1544
     1545
     1546
     1547
     1548
     1549
     1550
     1551
     1552
     1553
     1554
     1555
     1556
     1557
     1558
     1559
     1560
     1561
     1562
     1563
     1564
     1565
     1566
     1567
     1568
     1569
     1570
     1571
     1572
     1573
     1574
     1575
    15151576QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.