Changeset 569 for trunk/src


Ignore:
Timestamp:
Feb 13, 2010, 6:36:55 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Adopted to 4.6.1 changes.

Location:
trunk/src/gui
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/gui.pro

    r561 r569  
    55win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000
    66
    7 !win32:!embedded:!mac:!symbian:!os2::CONFIG      += x11
     7!win32:!embedded:!mac:!symbian:!os2:CONFIG += x11
    88
    99unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
  • trunk/src/gui/image/qpixmap_pm.cpp

    r564 r569  
    128128    }
    129129
    130     QRasterPixmapData* d = static_cast<QRasterPixmapData*>(data);
     130    QRasterPixmapData* d = static_cast<QRasterPixmapData*>(data.data());
    131131    int w = d->image.width();
    132132    int h = d->image.height();
  • trunk/src/gui/kernel/qapplication_pm.cpp

    r564 r569  
    24252425}
    24262426
     2427void QApplicationPrivate::initializeMultitouch_sys()
     2428{
     2429}
     2430
     2431void QApplicationPrivate::cleanupMultitouch_sys()
     2432{
     2433}
     2434
    24272435/*****************************************************************************
    24282436  PM session management
  • trunk/src/gui/kernel/qguiplatformplugin.cpp

    r561 r569  
    151151#elif defined(Q_OS_SYMBIAN)
    152152    return QLatin1String("Windows");                    // default style for Symbian without S60
     153#elif defined(Q_OS_OS2)
     154    return QLatin1String("Windows");                    // default style for OS/2
    153155#elif defined(Q_WS_X11) && defined(Q_OS_IRIX)
    154156    return QLatin1String("SGI");                        // default style for X11 on IRIX
  • trunk/src/gui/kernel/qwidget.cpp

    r561 r569  
    72727272    // hidden.
    72737273    if (wasVisible) {
    7274 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_PM) 
     7274#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_PM)
    72757275        qApp->d_func()->sendSyntheticEnterLeave(q);
    72767276#endif
     
    90119011Qt::InputMethodHints QWidget::inputMethodHints() const
    90129012{
     9013#ifndef QT_NO_IM
    90139014    Q_D(const QWidget);
    9014 #ifndef QT_NO_IM
    90159015    return d->imHints;
    90169016#else //QT_NO_IM
     
    1040910409        if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
    1041010410            d->createWinId();
     10411#ifndef QT_NO_IM
    1041110412        if (ic && isEnabled())
    1041210413            ic->setFocusWidget(focusWidget);
  • trunk/src/gui/kernel/qwidget_p.h

    r561 r569  
    712712    HWND effectiveFrameWinId() const;
    713713    void validateObstacles();
     714    void reparentChildren();
    714715#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
    715716    uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
  • trunk/src/gui/kernel/qwidget_pm.cpp

    r564 r569  
    13761376    Q_D(QWidget);
    13771377    if (!isWindow() && parentWidget())
    1378         parentWidget()->d_func()->invalidateBuffer(geometry());
     1378        parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
    13791379    d->deactivateWidgetCleanup();
    13801380    if (testAttribute(Qt::WA_WState_Created)) {
     
    14121412            qt_WinDestroyWindow(id);
    14131413        }
    1414         d->setWinId(0);
     1414        QT_TRY {
     1415            d->setWinId(0);
     1416        } QT_CATCH (const std::bad_alloc &) {
     1417            // swallow - destructors must not throw
     1418        }
    14151419    }
    14161420}
     
    14581462    bool wasCreated = q->testAttribute(Qt::WA_WState_Created);
    14591463    if (q->isVisible() && q->parentWidget() && parent != q->parentWidget())
    1460         q->parentWidget()->d_func()->invalidateBuffer(q->geometry());
     1464        q->parentWidget()->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
    14611465
    14621466    WId old_fid = frameWinId();
     
    16411645}
    16421646
     1647#ifndef QT_NO_CURSOR
    16431648void QWidget::grabMouse(const QCursor &cursor)
    16441649{
     
    16541659    }
    16551660}
     1661#endif
    16561662
    16571663void QWidget::releaseMouse()
     
    19291935 */
    19301936
    1931 void QWidgetPrivate::setWSGeometry(bool dontShow)
     1937void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &)
    19321938{
    19331939    Q_Q(QWidget);
  • trunk/src/gui/painting/painting.pri

    r561 r569  
    110110        SOURCES += \
    111111                painting/qcolormap_pm.cpp \
    112                 painting/qpaintdevice_pm.cpp \
    113                 painting/qregion_pm.cpp
     112                painting/qpaintdevice_pm.cpp
    114113}
    115114
  • trunk/src/gui/painting/qpaintdevice_pm.cpp

    r564 r569  
    5050QT_BEGIN_NAMESPACE
    5151
    52 QPaintDevice::QPaintDevice()
    53 {
    54     painters = 0;
    55 }
    56 
    57 extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp
    58 
    59 QPaintDevice::~QPaintDevice()
    60 {
    61     if (paintingActive())
    62         qWarning("QPaintDevice: Cannot destroy paint device that is being "
    63                   "painted.  Be sure to QPainter::end() painters!");
    64     qt_painter_removePaintDevice(this);
    65 }
    66 
    67 int QPaintDevice::metric(PaintDeviceMetric) const
    68 {
    69     qWarning("QPaintDevice::metrics: Device has no metric information");
    70     return 0;
    71 }
     52// Nothing to be done here so far
    7253
    7354QT_END_NAMESPACE
  • trunk/src/gui/painting/qregion.cpp

    r561 r569  
    281281    }
    282282#endif
     283#if defined(Q_WS_PM)
     284    else {
     285        // cause a new HRGN to be created when necessary
     286        disposeHandle(d->rgn);
     287        d->height = 0;
     288    }
     289#endif
    283290}
    284291
     
    546553    \sa intersected()
    547554*/
    548 #if !defined (Q_OS_UNIX) && !defined (Q_WS_WIN)
     555#if !defined (Q_OS_UNIX) && !defined (Q_WS_WIN) && !defined (Q_WS_PM)
    549556QRegion& QRegion::operator+=(const QRect &r)
    550557{
     
    569576   \since 4.4
    570577 */
    571 #if defined (Q_OS_UNIX) || defined (Q_WS_WIN)
     578#if defined (Q_OS_UNIX) || defined (Q_WS_WIN) || defined (Q_WS_PM)
    572579QRegion& QRegion::operator&=(const QRect &r)
    573580{
     
    728735}
    729736
    730 #if !defined (Q_OS_UNIX) && !defined (Q_WS_WIN)
     737#if !defined (Q_OS_UNIX) && !defined (Q_WS_WIN) && !defined (Q_WS_PM)
    731738/*!
    732739    \overload
     
    10911098}
    10921099
    1093 #if defined(Q_OS_UNIX) || defined(Q_WS_WIN)
     1100#if defined(Q_OS_UNIX) || defined(Q_WS_WIN) || defined(Q_WS_PM)
    10941101
    10951102//#define QT_REGION_DEBUG
     
    16351642QT_BEGIN_INCLUDE_NAMESPACE
    16361643# include "qregion_win.cpp"
     1644QT_END_INCLUDE_NAMESPACE
     1645#elif defined(Q_WS_PM)
     1646QT_BEGIN_INCLUDE_NAMESPACE
     1647# include "qregion_pm.cpp"
    16371648QT_END_INCLUDE_NAMESPACE
    16381649#elif defined(Q_WS_QWS)
     
    38533864#elif defined(Q_WS_WIN)
    38543865        d->rgn = 0;
     3866#elif defined(Q_WS_PM)
     3867        d->rgn = 0;
     3868        d->height = 0;
    38553869#endif
    38563870        if (t == Rectangle) {
     
    38783892#elif defined(Q_WS_WIN)
    38793893            d->rgn = 0;
     3894#elif defined(Q_WS_PM)
     3895            d->rgn = 0;
     3896            d->height = 0;
    38803897#endif
    38813898            d->qt_rgn = qt_rgn;
     
    39103927#elif defined(Q_WS_WIN)
    39113928        d->rgn = 0;
     3929#elif defined(Q_WS_PM)
     3930        d->rgn = 0;
     3931        d->height = 0;
    39123932#endif
    39133933        d->qt_rgn = qt_bitmapToRegion(bm);
     
    39263946    if (x->rgn)
    39273947        qt_win_dispose_rgn(x->rgn);
     3948#elif defined(Q_WS_PM)
     3949    if (x->rgn)
     3950        disposeHandle(x->rgn);
    39283951#endif
    39293952    delete x;
     
    39603983#elif defined(Q_WS_WIN)
    39613984    x->rgn = 0;
     3985#elif defined(Q_WS_PM)
     3986    x->rgn = 0;
     3987    x->height = 0;
    39623988#endif
    39633989    if (d->qt_rgn)
  • trunk/src/gui/painting/qregion.h

    r561 r569  
    6060class QVariant;
    6161
    62 #if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
     62#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || defined(Q_WS_PM)
    6363struct QRegionPrivate;
    6464#endif
     
    184184#if defined(Q_WS_WIN)
    185185    void ensureHandle() const;
    186     QRegion winCombine(const QRegion &r, int num) const;
    187186#elif defined(Q_WS_PM)
    188     QRegion pmCombine(const QRegion &r, int op) const;
    189187    void updateHandle(int targetHeight) const;
     188    static void disposeHandle(HRGN hrgn);
    190189#elif defined(Q_WS_X11)
    191190    void updateX11Region() const;
     
    216215        mutable RgnHandle unused; // Here for binary compatability reasons. ### Qt 5 remove.
    217216#endif
    218 #if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
     217#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || defined(Q_WS_PM)
    219218        QRegionPrivate *qt_rgn;
    220219#endif
  • trunk/src/gui/painting/qregion_pm.cpp

    r564 r569  
    6868//  The handle() function, used for external access to the region, takes an
    6969//  argument that must be always set to the height of the target device to
    70 //  guarantee the correct coordinate space alignment.
    71 
    72 #if defined(__GNUC__) && defined(__INNOTEK_LIBC__)
    73 
    74 // Innotek GCC lacks some API functions in its version of OS/2 Toolkit headers
    75 
    76 extern "C" HRGN APIENTRY GpiCreateEllipticRegion(HPS hps,
    77                                                  PRECTL prclRect);
    78 
    79 extern "C" HRGN APIENTRY GpiCreatePolygonRegion(HPS hps,
    80                                                 ULONG ulCount,
    81                                                 PPOLYGON paplgn,
    82                                                 ULONG flOptions);
    83 #endif
     70//  guarantee the correct y axis alignment.
    8471
    8572QRegion::QRegionData QRegion::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1),
    8673                                               NULLHANDLE, 0 };
    8774
    88 QRegion::QRegion()
    89     : d(&shared_empty)
     75/*!
     76    \internal
     77
     78    Deletes the given region handle.
     79 */
     80void QRegion::disposeHandle(HRGN hrgn)
    9081{
    91     d->ref.ref();
    92 }
    93 
    94 QRegion::QRegion(const QRect &r, RegionType t)
    95 {
    96     if (r.isEmpty()) {
    97         d = &shared_empty;
    98         d->ref.ref();
    99     } else {
    100         d = new QRegionData;
    101         d->ref = 1;
    102         d->height = 0;
    103         HPS hps = qt_display_ps();
    104         if (t == Rectangle) {
    105             RECTL rcl = { r.left(), -(r.bottom()+1), r.right()+1, -r.top() };
    106             d->rgn = GpiCreateRegion(hps, 1, &rcl);
    107         } else if (t == Ellipse) {
    108             // if the width or height of the ellipse is odd, GPI always
    109             // converts it to a nearest even value, which is obviously stupid
    110             // So, we don't use GpiCreateEllipticRegion(), but create an array
    111             // of points to call GpiCreatePolygonRegion() instead.
    112             QPainterPath p(QPointF(r.x(), r.y()));
    113             p.arcTo(r.x(), r.y(), r.width(), r.height(), 0, 360);
    114             QPolygon a = p.toFillPolygon().toPolygon();
    115             for (int i = 0; i < a.size(); ++ i)
    116                 a[i].ry() = -(a[i].y() + 1);
    117             // GpiCreatePolygonRegion() is bogus and always starts a poligon from
    118             // the current position. Make the last point the current one and reduce
    119             // the number of points by one.
    120             GpiMove(hps, reinterpret_cast<PPOINTL>(&a[a.size() - 1]));
    121             POLYGON poly = { a.size() - 1, reinterpret_cast<PPOINTL>(a.data()) };
    122             d->rgn = GpiCreatePolygonRegion(hps, 1, &poly, POLYGON_ALTERNATE);
    123         }
    124     }
    125 }
    126 
    127 QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule)
    128 {
    129     if (a.size() < 3) {
    130         d = &shared_empty;
    131         d->ref.ref();
    132     } else {
    133         d = new QRegionData;
    134         d->ref = 1;
    135         d->height = 0;
    136         HPS hps = qt_display_ps();
    137         POINTL *pts = new POINTL[a.size()];
    138         for (int i = 0; i < a.size(); ++ i) {
    139             pts[i].x = a[i].x();
    140             pts[i].y = - (a[i].y() + 1);
    141         }
    142         // GpiCreatePolygonRegion() is bogus and always starts a poligon from
    143         // the current position. Make the last point the current one and reduce
    144         // the number of points by one.
    145         GpiMove(hps, &pts[a.size() - 1]);
    146         POLYGON poly = { a.size() - 1, pts };
    147         ULONG opts = Qt::OddEvenFill ? POLYGON_ALTERNATE : POLYGON_WINDING;
    148         d->rgn = GpiCreatePolygonRegion(hps, 1, &poly, opts);
    149         delete[] pts;
    150     }
    151 }
    152 
    153 QRegion::QRegion(const QRegion &r)
    154 {
    155     d = r.d;
    156     d->ref.ref();
    157 }
    158 
    159 static HRGN bitmapToRegion(const QBitmap& bitmap)
    160 {
    161     HRGN region = 0;
    162     QImage image = bitmap.toImage();
    163     const int maxrect = 256;
    164     RECTL rects[maxrect];
    165     HPS hps = qt_display_ps();
    166 
    167 #define FlushSpans \
    168     { \
    169         HRGN r = GpiCreateRegion(hps, n, rects); \
    170             if (region) { \
    171                 GpiCombineRegion(hps, region, region, r, CRGN_OR); \
    172                 GpiDestroyRegion(hps, r); \
    173         } else { \
    174             region = r; \
    175         } \
    176     }
    177 
    178 #define AddSpan \
    179     { \
    180         rects[n].xLeft = prev1; \
    181         rects[n].yBottom = -(y+1); \
    182         rects[n].xRight = x-1+1; \
    183         rects[n].yTop = -y; \
    184         n++; \
    185         if (n == maxrect) { \
    186             FlushSpans \
    187             n = 0; \
    188         } \
    189     }
    190 
    191     int n = 0;
    192     int zero = 0x00;
    193 
    194     int x, y;
    195     for (y = 0; y < image.height(); y++) {
    196         uchar *line = image.scanLine(y);
    197         int w = image.width();
    198         uchar all = zero;
    199         int prev1 = -1;
    200         for (x = 0; x < w;) {
    201             uchar byte = line[x/8];
    202             if (x > w-8 || byte != all) {
    203                 for (int b = 8; b > 0 && x < w; b--) {
    204                     if (!(byte & 0x80) == !all) {
    205                     // More of the same
    206                     } else {
    207                                 // A change.
    208                                 if (all != zero) {
    209                                     AddSpan;
    210                                     all = zero;
    211                                 } else {
    212                                     prev1 = x;
    213                                     all = ~zero;
    214                                 }
    215                     }
    216                     byte <<= 1;
    217                     x++;
    218                 }
    219             } else {
    220                 x += 8;
    221             }
    222         }
    223         if (all != zero) {
    224             AddSpan;
    225         }
    226     }
    227     if (n) {
    228         FlushSpans;
    229     }
    230 
    231     if (!region)
    232         region = GpiCreateRegion(hps, 0, NULL);
    233 
    234     return region;
    235 }
    236 
    237 QRegion::QRegion(const QBitmap &bm)
    238 {
    239     if (bm.isNull()) {
    240         d = &shared_empty;
    241         d->ref.ref();
    242     } else {
    243         d = new QRegionData;
    244         d->ref = 1;
    245         d->height = 0;
    246         d->rgn = bitmapToRegion(bm);
    247     }
    248 }
    249 
    250 void QRegion::cleanUp(QRegion::QRegionData *x)
    251 {
    252     if (x->rgn != NULLHANDLE)
    253         GpiDestroyRegion(qt_display_ps(), x->rgn);
    254     delete x;
    255 }
    256 
    257 QRegion::~QRegion()
    258 {
    259     if (!d->ref.deref())
    260         cleanUp(d);
    261 }
    262 
    263 QRegion &QRegion::operator=(const QRegion &r)
    264 {
    265     r.d->ref.ref();
    266     if (!d->ref.deref())
    267         cleanUp(d);
    268     d = r.d;
    269     return *this;
    270 }
    271 
    272 
    273 QRegion QRegion::copy() const
    274 {
    275     QRegion r;
    276     QRegionData *x = new QRegionData;
    277     x->ref = 1;
    278     if (d->rgn != NULLHANDLE) {
    279         x->height = d->height;
    280         HPS hps = qt_display_ps();
    281         x->rgn = GpiCreateRegion(hps, 0, NULL);
    282         GpiCombineRegion(hps, x->rgn, d->rgn, NULL, CRGN_COPY);
    283     } else {
    284         x->height = 0;
    285         x->rgn = NULLHANDLE;
    286     }
    287     if (!r.d->ref.deref())
    288         cleanUp(r.d);
    289     r.d = x;
    290     return r;
    291 }
    292 
    293 bool QRegion::isEmpty() const
    294 {
    295     return (d == &shared_empty || boundingRect().isEmpty());
    296 }
    297 
    298 bool QRegion::contains(const QPoint &p) const
    299 {
    300     LONG rc = PRGN_OUTSIDE;
    301     if (d->rgn != NULLHANDLE) {
    302         POINTL ptl = { p.x(), d->height - (p.y() + 1) };
    303         rc = GpiPtInRegion(qt_display_ps(), d->rgn, &ptl);
    304     }
    305     return rc == PRGN_INSIDE;
    306 }
    307 
    308 bool QRegion::contains(const QRect &r) const
    309 {
    310     LONG rc = PRGN_OUTSIDE;
    311     if (d->rgn != NULLHANDLE) {
    312         RECTL rcl = { r.left(), d->height - (r.bottom() + 1),
    313                       r.right() + 1, d->height - r.top() };
    314         rc = GpiRectInRegion(qt_display_ps(), d->rgn, &rcl);
    315     }
    316     return rc == RRGN_INSIDE || rc == RRGN_PARTIAL;
    317 }
    318 
    319 void QRegion::translate(int dx, int dy)
    320 {
    321     if (d->rgn == NULLHANDLE || (dx == 0 && dy == 0))
    322         return;
    323     detach();
    324     POINTL ptl = { dx, -dy };
    325     GpiOffsetRegion(qt_display_ps(), d->rgn, &ptl);
    326 }
    327 
    328 #define CRGN_NOP -1
    329 
    330 // Duplicates of those in qregion.cpp
    331 #define QRGN_OR               6
    332 #define QRGN_AND              7
    333 #define QRGN_SUB              8
    334 #define QRGN_XOR              9
    335 
    336 /*
    337   Performs the actual OR, AND, SUB and XOR operation between regions.
    338   Sets the resulting region handle to 0 to indicate an empty region.
    339 */
    340 
    341 QRegion QRegion::pmCombine(const QRegion &r, int op) const
    342 {
    343     LONG both = CRGN_NOP, left = CRGN_NOP, right = CRGN_NOP;
    344     switch (op) {
    345     case QRGN_OR:
    346         both = CRGN_OR;
    347         left = right = CRGN_COPY;
    348         break;
    349     case QRGN_AND:
    350         both = CRGN_AND;
    351         break;
    352     case QRGN_SUB:
    353         both = CRGN_DIFF;
    354         left = CRGN_COPY;
    355         break;
    356     case QRGN_XOR:
    357         both = CRGN_XOR;
    358         left = right = CRGN_COPY;
    359         break;
    360     default:
    361         qWarning( "QRegion: Internal error in pmCombine" );
    362     }
    363 
    364     QRegion result;
    365     if (d->rgn == NULLHANDLE && r.d->rgn == NULLHANDLE)
    366         return result;
    367     HPS hps = qt_display_ps();
    368     result.detach();
    369     result.d->rgn = GpiCreateRegion(hps, 0, NULL);
    370     LONG rc = RGN_NULL;
    371     if (d->rgn != NULLHANDLE && r.d->rgn != NULLHANDLE) {
    372         updateHandle(r.d->height); // bring to the same coordinate space
    373         rc = GpiCombineRegion(hps, result.d->rgn, d->rgn, r.d->rgn, both);
    374         result.d->height = r.d->height;
    375     } else if (d->rgn && left != CRGN_NOP) {
    376         rc = GpiCombineRegion(hps, result.d->rgn, d->rgn, 0, left);
    377         result.d->height = d->height;
    378     } else if (r.d->rgn != NULLHANDLE && right != CRGN_NOP) {
    379         rc = GpiCombineRegion(hps, result.d->rgn, r.d->rgn, 0, right);
    380         result.d->height = r.d->height;
    381     }
    382     if (rc == RGN_NULL || rc == RGN_ERROR) {
    383         result = QRegion(); // shared_empty
    384     }
    385     return result;
    386 }
    387 
    388 QRegion QRegion::unite(const QRegion &r) const
    389 {
    390     if (d->rgn == NULLHANDLE)
    391         return r;
    392     if (r.d->rgn == NULLHANDLE)
    393         return *this;
    394     return pmCombine(r, QRGN_OR);
    395 }
    396 
    397 QRegion QRegion::unite(const QRect &r) const
    398 {
    399     return unite(QRegion(r));
    400 }
    401 
    402 QRegion QRegion::intersect(const QRegion &r) const
    403 {
    404     if (r.d->rgn == NULLHANDLE || d->rgn == NULLHANDLE)
    405         return QRegion();
    406      return pmCombine(r, QRGN_AND);
    407 }
    408 
    409 QRegion QRegion::subtract(const QRegion &r) const
    410 {
    411     if (r.d->rgn == NULLHANDLE || d->rgn == NULLHANDLE)
    412         return *this;
    413     return pmCombine(r, QRGN_SUB);
    414 }
    415 
    416 QRegion QRegion::eor(const QRegion &r) const
    417 {
    418     if (d->rgn == NULLHANDLE)
    419         return r;
    420     if (r.d->rgn == NULLHANDLE)
    421         return *this;
    422     return pmCombine(r, QRGN_XOR);
    423 }
    424 
    425 QRect QRegion::boundingRect() const
    426 {
    427     if (!d->rgn)
    428         return QRect();
    429 
    430     RECTL rcl;
    431     LONG rc = RGN_NULL;
    432     if (d->rgn != NULLHANDLE)
    433         rc = GpiQueryRegionBox(qt_display_ps(), d->rgn, &rcl);
    434     if (rc == RGN_NULL || rc == RGN_ERROR)
    435         return QRect();
    436     else
    437         return QRect(rcl.xLeft, d->height - rcl.yTop,
    438                      rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom);
    439 }
    440 
    441 QVector<QRect> QRegion::rects() const
    442 {
    443     QVector<QRect> a;
    444 
    445     if (d->rgn == NULLHANDLE)
    446         return a;
    447 
    448     HPS hps = qt_display_ps();
    449     RGNRECT ctl = {1, 0, 0, RECTDIR_LFRT_TOPBOT};
    450     if (!GpiQueryRegionRects(hps, d->rgn, NULL, &ctl, NULL))
    451         return a;
    452 
    453     ctl.crc = ctl.crcReturned;
    454     PRECTL rcls = new RECTL[ctl.crcReturned];
    455     if (rcls == 0)
    456         return a;
    457     if (!GpiQueryRegionRects(hps, d->rgn, NULL, &ctl, rcls)) {
    458         delete [] rcls;
    459         return a;
    460     }
    461 
    462     a = QVector<QRect>(ctl.crcReturned);
    463     PRECTL r = rcls;
    464     for (int i = 0; i < a.size(); ++i) {
    465         a[i].setRect(r->xLeft, d->height - r->yTop,
    466                      r->xRight - r->xLeft, r->yTop - r->yBottom);
    467         ++r;
    468     }
    469 
    470     delete [] rcls;
    471     return a;
    472  }
    473 
    474 void QRegion::setRects(const QRect *rects, int num)
    475 {
    476     *this = QRegion();
    477     if (!rects || num == 0 || (num == 1 && rects->isEmpty()))
    478         return;
    479     for (int i = 0; i < num; ++i)
    480         *this |= rects[i];
    481 }
    482 
    483 int QRegion::numRects() const
    484 {
    485     if (d->rgn == NULLHANDLE)
    486         return 0;
    487 
    488     RGNRECT ctl = {1, 0, 0, RECTDIR_LFRT_TOPBOT};
    489     if (!GpiQueryRegionRects(qt_display_ps(), d->rgn, NULL, &ctl, NULL))
    490         return 0;
    491 
    492     return ctl.crcReturned;
    493 }
    494 
    495 bool QRegion::operator==(const QRegion &r) const
    496 {
    497     if (d == r.d)
    498         return true;
    499     if ((d->rgn == NULLHANDLE) ^ (r.d->rgn == NULLHANDLE)) // one is empty, not both
    500         return false;
    501     if (d->rgn == NULLHANDLE) // both empty
    502         return true;
    503     updateHandle(r.d->height); // bring to the same coordinate space
    504     return // both not empty
    505         GpiEqualRegion(qt_display_ps(), d->rgn, r.d->rgn) == EQRGN_EQUAL;
    506 }
    507 
    508 QRegion& QRegion::operator+=(const QRegion &r)
    509 {
    510     if (r.d->rgn == NULLHANDLE)
    511         return *this;
    512 
    513     if (d->rgn == NULLHANDLE) {
    514         *this = r;
    515         return *this;
    516     }
    517 
    518     *this = unite(r);
    519     return *this;
    520 }
    521 
    522 QRegion& QRegion::operator-=(const QRegion &r)
    523 {
    524     if (r.d->rgn == NULLHANDLE || d->rgn == NULLHANDLE)
    525         return *this;
    526 
    527     *this = subtract(r);
    528     return *this;
    529 }
    530 
    531 QRegion& QRegion::operator&=(const QRegion &r)
    532 {
    533     if (d->rgn == NULLHANDLE)
    534         return *this;
    535 
    536     if (r.d->rgn == NULLHANDLE) {
    537         *this = QRegion();
    538         return *this;
    539     }
    540 
    541     *this = intersect(r);
    542     return *this;
    543 }
    544 
    545 bool qt_region_strictContains(const QRegion &region, const QRect &rect)
    546 {
    547     Q_UNUSED(region);
    548     Q_UNUSED(rect);
    549     return false;
     82    if (hrgn != 0)
     83        GpiDestroyRegion(qt_display_ps(), hrgn);
    55084}
    55185
     
    55892void QRegion::updateHandle(int targetHeight) const
    55993{
    560     QRegion *that = const_cast<QRegion*>(this); // we're const here
    561     if (d->rgn == NULLHANDLE) {
    562         // a handle of a null region is requested, allocate an empty region
    563         that->detach();
    564         that->d->rgn = GpiCreateRegion(qt_display_ps(), 0, NULL);
    565         that->d->height = targetHeight;
    566     } else if (d->height != targetHeight) {
    567         // align region y axis to the top of the device
    568         that->detach();
    569         POINTL ptl = { 0, targetHeight - d->height };
    570         GpiOffsetRegion(qt_display_ps(), d->rgn, &ptl);
    571         that->d->height = targetHeight;
     94    QRegion *self = const_cast<QRegion*>(this); // we're const here
     95
     96    if (d->rgn != 0) {
     97        if (self->d->ref == 1) {
     98            // align region y axis to the top of the device
     99            POINTL ptl = { 0, targetHeight - d->height };
     100            GpiOffsetRegion(qt_display_ps(), d->rgn, &ptl);
     101            self->d->height = targetHeight;
     102            return;
     103        }
     104        // create a copy since the hande may be in use (this will reset d->rgn)
     105        *self = copy();
    572106    }
     107
     108    Q_ASSERT(d->rgn == 0);
     109
     110    // new/updated/copied Qt region data, create a new HRGN for it
     111    self->d->height = targetHeight;
     112    if (d->qt_rgn) {
     113        if (d->qt_rgn->numRects) {
     114            PRECTL rcls = new RECTL[d->qt_rgn->numRects];
     115            for (int i = 0; i < d->qt_rgn->numRects; ++i) {
     116                QRect r = d->qt_rgn->rects.at(i);
     117                // note RECTL is inclusive-exclusive here
     118                rcls[i].xLeft = r.left();
     119                rcls[i].yBottom = d->height - (r.bottom() + 1);
     120                rcls[i].xRight = r.right() + 1;
     121                rcls[i].yTop = d->height - r.top();
     122            }
     123            self->d->rgn = GpiCreateRegion(qt_display_ps(),
     124                                           d->qt_rgn->numRects, rcls);
     125            return;
     126        }
     127    }
     128
     129    // create an empty region
     130    self->d->rgn = GpiCreateRegion(qt_display_ps(), 0, NULL);
    573131}
    574132
  • trunk/src/gui/text/text.pri

    r561 r569  
    187187        DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB
    188188    } os2 {
    189         SOURCES +=
     189        SOURCES += \
    190190            ../3rdparty/freetype/src/base/ftsystem.c
    191         INCLUDEPATH +=
     191        INCLUDEPATH += \
    192192            ../3rdparty/freetype/builds/os2
    193193    } else {
     
    204204
    205205    DEFINES += FT2_BUILD_LIBRARY
    206    
     206
    207207    embedded:CONFIG += opentype
    208208} else:contains(QT_CONFIG, system-freetype) {
Note: See TracChangeset for help on using the changeset viewer.