void QRegion::translate( int dx, int dy )
{
    if ( !data->rgn )
	return;
    detach();
    POINTL ptl = { dx, -dy };
    GpiOffsetRegion( qt_display_ps(), data->rgn, &ptl);
}
/*!
 *  \internal
 *  Updates the region handle so that it is suitable for selection to
 *  a device with the given \a height.
 */
void QRegion::updateHandle( int target_height ) const
{
    QRegion *that = const_cast< QRegion *>( this ); // we're const here
    if ( !data->rgn ) {
        // a handle of a null region is requested, allocate an empty region
        that->data->rgn = GpiCreateRegion( qt_display_ps(), 0, NULL );
        that->data->hgt = target_height;
    } else if ( data->hgt != target_height ) {
        // align region y axis to the top of the device
        POINTL ptl = { 0, target_height - data->hgt };
        GpiOffsetRegion( qt_display_ps(), data->rgn, &ptl );
        that->data->hgt = target_height;
    }
}
Example #3
0
/*!
    \internal

    Updates the region handle so that it is suitable for selection to
    a device with the given \a height.
 */
void QRegion::updateHandle(int targetHeight) const
{
    QRegion *self = const_cast<QRegion*>(this); // we're const here

    if (d->rgn != 0) {
        if (self->d->ref == 1) {
            // align region y axis to the top of the device
            POINTL ptl = { 0, targetHeight - d->height };
            GpiOffsetRegion(qt_display_ps(), d->rgn, &ptl);
            self->d->height = targetHeight;
            return;
        }
        // create a copy since the hande may be in use (this will reset d->rgn)
        *self = copy();
    }

    Q_ASSERT(d->rgn == 0);

    // new/updated/copied Qt region data, create a new HRGN for it
    self->d->height = targetHeight;
    if (d->qt_rgn) {
        if (d->qt_rgn->numRects > 0) {
            if (d->qt_rgn->numRects == 1) {
                // d->qt_rgn->rects is empty, use d->qt_rgn->extents instead
                const QRect r = d->qt_rgn->extents;
                RECTL rcl = { r.left(), d->height - (r.bottom() + 1),
                              r.right() + 1, d->height - r.top() };
                self->d->rgn = GpiCreateRegion(qt_display_ps(), 1, &rcl);
            } else {
                PRECTL rcls = new RECTL[d->qt_rgn->numRects];
                for (int i = 0; i < d->qt_rgn->numRects; ++i) {
                    QRect r = d->qt_rgn->rects.at(i);
                    // note RECTL is inclusive-exclusive here
                    rcls[i].xLeft = r.left();
                    rcls[i].yBottom = d->height - (r.bottom() + 1);
                    rcls[i].xRight = r.right() + 1;
                    rcls[i].yTop = d->height - r.top();
                }
                self->d->rgn = GpiCreateRegion(qt_display_ps(),
                                               d->qt_rgn->numRects, rcls);
                delete[] rcls;
            }
            return;
        }
    }

    // create an empty region
    self->d->rgn = GpiCreateRegion(qt_display_ps(), 0, NULL);
}