Changeset 134 for trunk/src


Ignore:
Timestamp:
Aug 27, 2009, 2:02:17 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Implemented QDesktopWidget.

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

Legend:

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

    r133 r134  
    519519
    520520        switch(msg) {
     521
     522        case WM_SYSVALUECHANGED: {
     523            // This message is sent to all top-level widgets, handle only once
     524            QWidgetList list = QApplication::topLevelWidgets();
     525            bool firstWidget = list.first()->winId() == hwnd;
     526            if (!firstWidget)
     527                break;
     528            LONG from = (LONG) mp1;
     529            LONG to = (LONG) mp2;
     530            #define MY_IS_SV(sv) (from >= (sv) && to <= (sv))
     531            if (MY_IS_SV(SV_WORKAREA_XLEFT) || MY_IS_SV(SV_WORKAREA_XRIGHT) ||
     532                MY_IS_SV(SV_WORKAREA_YBOTTOM) || MY_IS_SV(SV_WORKAREA_YTOP)) {
     533                 // send a special invalid resize event to QDesktopWidget
     534                 QApplication::sendEvent(qt_desktopWidget, 0);
     535                 // @todo enumerate all top-level widgets and
     536                 // remaximize those that are maximized
     537            } else {
     538                 /// @todo call qt_set_pm_resources() in the way it is
     539                 //  done in WM_SYSCOLORCHANGE for relevant SV_ values.
     540            }
     541            #undef MY_IS_SV
     542            break;
     543        }
    521544
    522545        case WM_BUTTON1DOWN:
  • trunk/src/gui/kernel/qdesktopwidget_pm.cpp

    r95 r134  
    4747#include "qwidget_p.h"
    4848
     49#include "qdebug.h"
     50
    4951QT_BEGIN_NAMESPACE
     52
     53// stolen from xWorkplace sources
     54static
     55APIRET qt_DosQueryProcAddr(PCSZ pcszModuleName, ULONG ulOrdinal, PFN *ppfn)
     56{
     57    HMODULE hmod = NULL;
     58    APIRET rc = 0;
     59    if (!(rc = DosQueryModuleHandle( (PSZ)pcszModuleName, &hmod))) {
     60        if ((rc = DosQueryProcAddr( hmod, ulOrdinal, NULL, ppfn))) {
     61            // the CP programming guide and reference says use
     62            // DosLoadModule if DosQueryProcAddr fails with this error
     63            if (rc == ERROR_INVALID_HANDLE) {
     64                if (!(rc = DosLoadModule(NULL, 0, (PSZ) pcszModuleName,
     65                                         &hmod))) {
     66                    rc = DosQueryProcAddr(hmod, ulOrdinal, NULL, ppfn);
     67                }
     68            }
     69        }
     70    }
     71    return rc;
     72}
    5073
    5174class QDesktopWidgetPrivate : public QWidgetPrivate
    5275{
    5376public:
     77    QRect workArea;
    5478};
    5579
     
    7195QDesktopWidget::QDesktopWidget()
    7296    : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop)
    73   {
     97{
    7498    setObjectName(QLatin1String("desktop"));
    75     // @todo implement
    7699}
    77100
     
    87110int QDesktopWidget::primaryScreen() const
    88111{
    89     // @todo implement
    90112    return 0;
    91113}
     
    93115int QDesktopWidget::numScreens() const
    94116{
    95     // @todo implement
    96     return 0;
     117    return 1;
    97118}
    98119
     
    105126const QRect QDesktopWidget::availableGeometry(int screen) const
    106127{
    107     // @todo implement
    108     return QRect();
     128    Q_D(const QDesktopWidget);
     129
     130    if (!d->workArea.isValid())
     131        const_cast<QDesktopWidget *>(this)->resizeEvent(0);
     132    if (d->workArea.isValid())
     133        return d->workArea;
     134
     135    return geometry();
    109136}
    110137
    111138const QRect QDesktopWidget::screenGeometry(int screen) const
    112139{
    113     // @todo implement
    114     return QRect();
     140    return geometry();
    115141}
    116142
    117 int QDesktopWidget::screenNumber(const QWidget *widget) const
     143int QDesktopWidget::screenNumber(const QWidget * /* widget */) const
    118144{
    119     // @todo implement
    120145    return 0;
    121146}
    122147
    123 int QDesktopWidget::screenNumber(const QPoint &point) const
     148int QDesktopWidget::screenNumber(const QPoint & /* point */) const
    124149{
    125     // @todo implement
    126150    return 0;
    127151}
    128152
    129 void QDesktopWidget::resizeEvent(QResizeEvent *)
     153void QDesktopWidget::resizeEvent(QResizeEvent *e)
    130154{
    131     // @todo implement
     155    Q_D(QDesktopWidget);
     156
     157    if (e == 0) {
     158        // this is a Work Area Changed notification, see WM_SYSVALUECHANGED
     159        // in qapplication_pm.cpp
     160        typedef
     161        BOOL (APIENTRY *WinQueryDesktopWorkArea_T) (HWND hwndDesktop,
     162                                                    PRECTL pwrcWorkArea);
     163        static WinQueryDesktopWorkArea_T WinQueryDesktopWorkArea =
     164            (WinQueryDesktopWorkArea_T) ~0;
     165
     166        if ((ULONG) WinQueryDesktopWorkArea == (ULONG) ~0) {
     167            if (qt_DosQueryProcAddr("PMMERGE", 5469,
     168                                    (PFN *) &WinQueryDesktopWorkArea))
     169                WinQueryDesktopWorkArea = NULL;
     170        }
     171
     172        if (WinQueryDesktopWorkArea) {
     173            RECTL rcl;
     174            if (WinQueryDesktopWorkArea(HWND_DESKTOP, &rcl)) {
     175                // flip y coordinates
     176                d->workArea.setCoords(rcl.xLeft, height() - rcl.yTop,
     177                                      rcl.xRight - 1,
     178                                      height() - (rcl.yBottom + 1));
     179            }
     180        }
     181
     182        emit workAreaResized(0);
     183        return;
     184    }
     185
     186    // otherwise nothing to do, the desktop cannot be dynamically resized
     187    // on OS/2
    132188}
    133189
Note: See TracChangeset for help on using the changeset viewer.