Ignore:
Timestamp:
Feb 6, 2006, 10:43:39 PM (20 years ago)
Author:
dmik
Message:

Implemented QRegion(..., QRegion::Eclipse) and QRegion(QPointArray &,...) constructors.
Improved Qt<->GPI region coordinates translation (it's now implicit), QRegion::handle() takes a height of the target devise as an argument (defaults to 0).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel/qwidget_pm.cpp

    r57 r61  
    973973        WinValidateRect( winId(), &rcl, FALSE );
    974974
    975         QRegion *pcrgn = 0;
     975        Q_ASSERT( !WinQueryWindowULong( winId(), QWL_QTCLIPRGN ) );
     976        QRegion reg;
    976977        if ( r != rect() ) {
    977             pcrgn = new QRegion( r );
    978             WinSetWindowULong( winId(), QWL_QTCLIPRGN, (ULONG) pcrgn );
     978            reg = QRegion( r );
     979            WinSetWindowULong( winId(), QWL_QTCLIPRGN, (ULONG) &reg );
    979980        }
    980981
     
    984985        QApplication::sendEvent( this, &e );
    985986
    986         if ( pcrgn ) {
    987             WinSetWindowULong( winId(), QWL_QTCLIPRGN, 0 );
    988             delete pcrgn;
    989         }
     987        WinSetWindowULong( winId(), QWL_QTCLIPRGN, 0 );
    990988    }
    991989}
     
    1000998#endif
    1001999        // convert region y coordinates from Qt to GPI (see qregion_pm.cpp)
    1002         POINTL ptl = { 0, height() };
    1003         GpiOffsetRegion( qt_display_ps(), reg.handle(), &ptl );
    1004         WinValidateRegion( winId(), reg.handle(), FALSE );
    1005         // convert region y coordinates back from GPI to Qt
    1006         ptl.y = -ptl.y;
    1007         GpiOffsetRegion( qt_display_ps(), reg.handle(), &ptl );
    1008 
    1009         QRegion *pcrgn = new QRegion( reg );
    1010         WinSetWindowULong( winId(), QWL_QTCLIPRGN, (ULONG) pcrgn );
     1000        WinValidateRegion( winId(), reg.handle( height() ), FALSE );
     1001
     1002        Q_ASSERT( !WinQueryWindowULong( winId(), QWL_QTCLIPRGN ) );
     1003        WinSetWindowULong( winId(), QWL_QTCLIPRGN, (ULONG) &reg );
    10111004
    10121005        QPaintEvent e( reg, erase );
     
    10161009
    10171010        WinSetWindowULong( winId(), QWL_QTCLIPRGN, 0 );
    1018         delete pcrgn;
    10191011    }
    10201012}
     
    14131405    } else if ( !hps ) {
    14141406        tmphps = TRUE;
    1415         lhps = WinGetPS( winId() );
     1407        lhps = getTargetPS();
    14161408    } else {
    14171409        tmphps = FALSE;
     
    14281420    );
    14291421
    1430     if ( tmphps ) {
     1422    if ( tmphps )
    14311423        WinReleasePS( lhps );
    1432         hps = 0;
    1433     }
    14341424}
    14351425
     
    14501440    } else if ( !hps ) {
    14511441        tmphps = TRUE;
    1452         lhps = WinGetPS( winId() );
     1442        lhps = getTargetPS();
    14531443    } else {
    14541444        tmphps = FALSE;
    14551445        lhps = hps;
    14561446    }
    1457 
    1458     // convert region y coordinates from Qt to GPI (see qregion_pm.cpp)
    1459     POINTL ptl = { 0, height() };
    1460     GpiOffsetRegion( lhps, rgn.handle(), &ptl );
    14611447
    14621448    HRGN oldRegion = GpiQueryClipRegion( lhps );
     
    14651451        GpiSetClipRegion( lhps, 0, NULL );
    14661452        newRegion = GpiCreateRegion( lhps, 0, NULL );
    1467         GpiCombineRegion( lhps, newRegion, oldRegion, rgn.handle(), CRGN_AND );
     1453        GpiCombineRegion( lhps, newRegion, oldRegion, rgn.handle( height() ),
     1454                          CRGN_AND );
    14681455    } else {
    1469         newRegion = rgn.handle();
     1456        newRegion = rgn.handle( height() );
    14701457    }
    14711458    GpiSetClipRegion( lhps, newRegion, &oldRegion );
     
    14821469    GpiSetClipRegion( lhps, oldRegion, NULL );
    14831470
    1484     // convert region y coordinates back from GPI to Qt
    1485     ptl.y = -ptl.y;
    1486     GpiOffsetRegion( lhps, rgn.handle(), &ptl );
    1487 
    14881471    if ( oldRegion )
    14891472        GpiDestroyRegion( lhps, newRegion );
    1490     if ( tmphps ) {
     1473    if ( tmphps )
    14911474        WinReleasePS( lhps );
    1492         hps = 0;
    1493     }
    14941475}
    14951476
     
    18821863}
    18831864
     1865/*!
     1866 *  \internal
     1867 *
     1868 *  Obtains a presentaiton space to draw on this widget, set up according
     1869 *  to widget flags. If \a m != Unclipped and WPaintUnclipped flag is not
     1870 *  set, a clip region is set on the returned PS according to \a m.
     1871 *
     1872 *  The returned handle must be freed using WinReleasePS() after usage.
     1873 */
     1874HPS QWidget::getTargetPS( ClipMode m /* = ClipAll */ )
     1875{
     1876    HPS widgetPS = 0;
     1877   
     1878    if ( isDesktop() ) {
     1879        widgetPS = WinGetScreenPS( HWND_DESKTOP );
     1880    } else {
     1881        if ( m == Unclipped || testWFlags( WPaintUnclipped ) ) {
     1882            widgetPS = WinGetClipPS( winId(), 0, PSF_PARENTCLIP );
     1883        } else {
     1884            widgetPS = WinGetPS( winId() );
     1885        }
     1886    }
     1887
     1888    return widgetPS;
     1889}
     1890
Note: See TracChangeset for help on using the changeset viewer.