コード例 #1
0
ファイル: statwnd.c プロジェクト: Azarien/open-watcom-v2
/*
 * outlineRect - draw the outline of a rectangle
 */
static void outlineRect( statwnd *sw, WPI_PRES pres, WPI_RECT *r )
{
    WPI_POINT   pt;
    WPI_RECTDIM left;
    WPI_RECTDIM right;
    WPI_RECTDIM top;
    WPI_RECTDIM bottom;
    HPEN        oldpen;

    sw = sw;
    _wpi_getrectvalues( *r, &left, &top, &right, &bottom );

    _wpi_setpoint( &pt, left, bottom - 1 );
    _wpi_cvth_pt( &pt, sw->wndHeight );
    _wpi_movetoex( pres, &pt, NULL );

    oldpen = _wpi_selectobject( pres, penLight );
    pt.x = right - 1;
    _wpi_lineto( pres, &pt );
    pt.y = _wpi_cvth_y( top, sw->wndHeight );
    _wpi_lineto( pres, &pt );

    _wpi_selectobject( pres, penShade );

    pt.x = left;
    _wpi_lineto( pres, &pt );
    pt.y = _wpi_cvth_y( bottom - 1, sw->wndHeight );
    _wpi_lineto( pres, &pt );

    _wpi_selectobject( pres, oldpen );

} /* outlineRect */
コード例 #2
0
ファイル: ieviewin.c プロジェクト: Azarien/open-watcom-v2
/*
 * drawBorder - draw the border for the view window
 */
static void drawBorder( img_node *node )
{
    WPI_PRES    presborder;
    HPEN        hgraypen;
    HPEN        hwhitepen;
    HPEN        hblackpen;
    HPEN        holdpen;
    WPI_RECT    rcclient;
    HBRUSH      hnewbrush;
    HBRUSH      holdbrush;
    HBRUSH      nullbrush;
    int         width;
    int         height;
#ifndef __NT__
    WPI_POINT   pt;
#endif
    int         top;
    int         bottom;

    presborder = _wpi_getpres( node->viewhwnd );
#if defined( __NT__ )
    hwhitepen = _wpi_createpen( PS_SOLID, 0, GetSysColor( COLOR_BTNHIGHLIGHT ) );
    hblackpen = _wpi_createpen( PS_SOLID, 0, GetSysColor( COLOR_BTNTEXT ) );
#else
    hwhitepen = _wpi_createpen( PS_SOLID, 0, CLR_WHITE );
    hblackpen = _wpi_createpen( PS_SOLID, 0, CLR_BLACK );
#endif

    GetClientRect( node->viewhwnd, &rcclient );
    width = _wpi_getwidthrect( rcclient );
    height = _wpi_getheightrect( rcclient );

    if( node->imgtype != BITMAP_IMG ) {
#if defined( __NT__ )
        hgraypen = _wpi_createpen( PS_SOLID, 0, GetSysColor( COLOR_BTNSHADOW ) );
#else
        hgraypen = _wpi_createpen( PS_SOLID, 0, CLR_DARKGRAY );
#endif
        holdpen = _wpi_selectobject( presborder, hgraypen );

#if defined( __NT__ )
        hnewbrush = _wpi_createsolidbrush( GetSysColor( COLOR_BTNFACE ) );
#else
        hnewbrush = _wpi_createsolidbrush( CLR_PALEGRAY );
#endif
        holdbrush = _wpi_selectobject( presborder, hnewbrush );

        top = 0;
        bottom = height;
        top = _wpi_cvth_y( top, height );
        bottom = _wpi_cvth_y( bottom, height );
        _wpi_rectangle( presborder, 0, top, width, bottom );

        /*
         * Draw black border and selected background color in the view window.
         */
        _wpi_selectobject( presborder, hblackpen );
        _wpi_selectobject( presborder, holdbrush );
        _wpi_deleteobject( hnewbrush );
        hnewbrush = _wpi_createsolidbrush( bkgroundColor );
        _wpi_selectobject( presborder, hnewbrush );

        top = BORDER_WIDTH - 1;
        bottom = height - BORDER_WIDTH + 1;
        top = _wpi_cvth_y( top, height );
        bottom = _wpi_cvth_y( bottom, height );
#ifndef __NT__
        /*
         * Draw the border relative to the size of the object being displayed,
         * not the window containing it.
         */
        _wpi_rectangle( presborder, BORDER_WIDTH - 1, top,
                        node->width + BORDER_WIDTH + 1, top + node->height + 2 );
#endif
        _wpi_selectobject( presborder, holdbrush );
        _wpi_selectobject( presborder, holdpen );
        _wpi_deleteobject( hnewbrush );
    } else {
#ifdef __OS2_PM__
        // I can't seem to get the thick pen to work so I'm using this
        // method.
        hgraypen = _wpi_createpen( PS_SOLID, 0, CLR_PALEGRAY );
        holdpen = _wpi_selectobject( presborder, hgraypen );
        hnewbrush = _wpi_createsolidbrush( CLR_PALEGRAY );
        holdbrush = _wpi_selectobject( presborder, hnewbrush );

        _wpi_rectangle( presborder, 0, 0, width + 1, BORDER_WIDTH + 1 );
        _wpi_rectangle( presborder, 0, 0, BORDER_WIDTH + 1, height + 1 );
        _wpi_rectangle( presborder, 0, height - BORDER_WIDTH, width + 1, height + 1 );
        _wpi_rectangle( presborder, width - BORDER_WIDTH, 0, width + 1, height + 1 );

        _wpi_selectobject( presborder, holdbrush );
        _wpi_deleteobject( hnewbrush );
        _wpi_selectobject( presborder, holdpen );
        _wpi_deleteobject( hgraypen );
#else
#if defined( __NT__ )
        hgraypen = _wpi_createpen( PS_INSIDEFRAME, BORDER_WIDTH,
                                   GetSysColor( COLOR_BTNFACE ) );
#else
        hgraypen = _wpi_createpen( PS_INSIDEFRAME, BORDER_WIDTH, CLR_PALEGRAY );
#endif
        holdpen = _wpi_selectobject( presborder, hgraypen );
        nullbrush = _wpi_createnullbrush();
        holdbrush = _wpi_selectbrush( presborder, nullbrush );

        _wpi_rectangle( presborder, 0, 0, rcclient.right, rcclient.bottom );
        _wpi_getoldbrush( presborder, holdbrush );
        _wpi_selectobject( presborder, holdpen );
        _wpi_deleteobject( hgraypen );
        _wpi_deletenullbrush( nullbrush );
#endif

        nullbrush = _wpi_createnullbrush();
#if defined( __NT__ )
        hgraypen = _wpi_createpen( PS_SOLID, 0, GetSysColor( COLOR_BTNSHADOW ) );
#else
        hgraypen = _wpi_createpen( PS_SOLID, 0, CLR_DARKGRAY );
#endif
        holdbrush = _wpi_selectbrush( presborder, nullbrush );
        holdpen = _wpi_selectobject( presborder, hgraypen );
        top = 0;
        bottom = height;
        top = _wpi_cvth_y( top, height );
        bottom = _wpi_cvth_y( bottom, height );
        _wpi_rectangle( presborder, 0, top, width, bottom );

        _wpi_selectobject( presborder, hblackpen );
        top = BORDER_WIDTH - 1;
        bottom = height - BORDER_WIDTH + 1;
        top = _wpi_cvth_y( top, height );
        bottom = _wpi_cvth_y( bottom, height );
#ifndef __NT__
        /*
         * Draw the border relative to the size of the object being displayed,
         * not the window containing it.
         */
        _wpi_rectangle( presborder, BORDER_WIDTH - 1, top,
                        node->width + BORDER_WIDTH + 1, top + node->height + 2 );
#endif

        _wpi_selectobject( presborder, holdpen );
        _wpi_selectbrush( presborder, holdbrush );
        _wpi_deletenullbrush( nullbrush );
    }

    /*
     * Give the view window the 3D effect.
     */
#ifndef __NT__
    holdpen = _wpi_selectobject( presborder, hwhitepen );

    _wpi_setpoint( &pt, 0, height - 1 );
    _wpi_cvth_pt( &pt, height );
    _wpi_movetoex( presborder, &pt, NULL );

    _wpi_setpoint( &pt, 0, 0 );
    _wpi_cvth_pt( &pt, height );
    _wpi_lineto( presborder, &pt );
    pt.x = width;
    _wpi_lineto( presborder, &pt );

    _wpi_setpoint( &pt, width - BORDER_WIDTH + 1, BORDER_WIDTH - 2 );
    _wpi_cvth_pt( &pt, height );
    _wpi_movetoex( presborder, &pt, NULL );

    pt.y = height - BORDER_WIDTH + 1;
    _wpi_cvth_pt( &pt, height );
    _wpi_lineto( presborder, &pt );
    pt.x = BORDER_WIDTH - 2;
    _wpi_lineto( presborder, &pt );

    _wpi_selectobject( presborder, hgraypen );

    _wpi_setpoint( &pt, BORDER_WIDTH - 2, BORDER_WIDTH - 2 );
    _wpi_cvth_pt( &pt, height );
    _wpi_lineto( presborder, &pt );
    pt.x = width - BORDER_WIDTH + 1;
    _wpi_lineto( presborder, &pt );

    _wpi_selectobject( presborder, holdpen );
#endif
    _wpi_deleteobject( hgraypen );
    _wpi_deleteobject( hwhitepen );
    _wpi_deleteobject( hblackpen );
    _wpi_releasepres( node->viewhwnd, presborder );

} /* drawBorder */
コード例 #3
0
/*
 * OutlineRegion - displays the potential region (rectangle or ellipse)
 *                 on the draw area.
 */
void OutlineRegion( HWND hwnd, WPI_POINT *start_pt, WPI_POINT *end_pt,
                                        WPI_POINT *prev_pt, BOOL firsttime )
{
    WPI_POINT   topleft;
    WPI_POINT   bottomright;
    WPI_POINT   prevtl;                 // previous top left point
    WPI_POINT   prevbr;                 // previous bottom right point
    int         prevROP2;
    HBRUSH      hbrush;
    HBRUSH      holdbrush;
    HPEN        hwhitepen;
    HPEN        holdpen;
    int         temp;
    WPI_PRES    pres;

    CheckBounds( hwnd, start_pt );
    CheckBounds( hwnd, end_pt );
    CheckBounds( hwnd, prev_pt );
    _wpi_setpoint(&topleft, MAKELOGPTX(start_pt->x), MAKELOGPTY(start_pt->y));
    _wpi_setpoint(&bottomright, MAKELOGPTX(end_pt->x), MAKELOGPTY(end_pt->y));

    if (topleft.x > bottomright.x) {
        temp = (short)bottomright.x;
        bottomright.x = topleft.x + pointSize.x;
        topleft.x = temp;
    } else {
        bottomright.x += pointSize.x;
    }
    if (topleft.y > bottomright.y) {
        temp = (int)bottomright.y;
        bottomright.y = topleft.y + pointSize.y;
        topleft.y = temp;
    } else {
        bottomright.y += pointSize.y;
    }

    prevtl.x = MAKELOGPTX( start_pt->x );
    prevtl.y = MAKELOGPTY( start_pt->y );
    prevbr.x = MAKELOGPTX( prev_pt->x );
    prevbr.y = MAKELOGPTY( prev_pt->y );

    if (prevtl.x > prevbr.x) {
        temp = (int)prevbr.x;
        prevbr.x = prevtl.x + pointSize.x;
        prevtl.x = temp;
    } else {
        prevbr.x += pointSize.x;
    }

    if (prevtl.y > prevbr.y) {
        temp = (int)prevbr.y;
        prevbr.y = prevtl.y + pointSize.y;
        prevtl.y = temp;
    } else {
        prevbr.y += pointSize.y;
    }

    ++prevtl.x;
    ++prevtl.y;
    ++topleft.x;
    ++topleft.y;

    pres = _wpi_getpres( hwnd );
    _wpi_torgbmode( pres );
    prevROP2 = _wpi_setrop2( pres, R2_XORPEN );
    hbrush = _wpi_createsolidbrush( BLACK );
    hwhitepen = _wpi_createpen( PS_SOLID, 0, WHITE );

    holdbrush = _wpi_selectobject( pres, hbrush );
    holdpen = _wpi_selectobject( pres, hwhitepen );

    if (!firsttime) {
        if ((toolType == IMGED_CIRCLEO) || (toolType == IMGED_CIRCLEF)) {
            _wpi_ellipse( pres, prevtl.x, prevtl.y, prevbr.x, prevbr.y );
        } else {
            _wpi_rectangle( pres, prevtl.x, prevtl.y, prevbr.x, prevbr.y );
        }
    }

    if ((toolType == IMGED_CIRCLEO) || (toolType == IMGED_CIRCLEF)) {
        _wpi_ellipse( pres, topleft.x, topleft.y, bottomright.x, bottomright.y );
    } else {
        _wpi_rectangle( pres, topleft.x, topleft.y, bottomright.x, bottomright.y );
    }
    _wpi_selectobject( pres, holdpen );
    _wpi_selectobject( pres, holdbrush );

    _wpi_deleteobject( hwhitepen );
    _wpi_deleteobject( hbrush );
    _wpi_setrop2( pres, prevROP2 );
    _wpi_releasepres( hwnd, pres );
} /* OutlineRegion */
コード例 #4
0
/*
 * showGrid - Display the grid on the draw area.
 */
static void showGrid( HWND hwnd, WPI_PRES mempres )
{
    short       i;
    short       psx;
    short       psy;
    WPI_RECT    rcclient;
    HPEN        hblackpen;
    HPEN        holdpen;
    img_node    *node;
    short       width;
    short       height;
    IMGED_DIM   left;
    IMGED_DIM   right;
    IMGED_DIM   top;
    IMGED_DIM   bottom;
    WPI_PRES    pres;
    WPI_POINT   startpt;
    WPI_POINT   endpt;

    node = SelectImage( hwnd );

    _wpi_torgbmode( mempres );
    GetClientRect( hwnd, &rcclient );
    width = (short)( _wpi_getwidthrect(rcclient) );
    height = (short)( _wpi_getheightrect(rcclient) );

    if (((width / node->width) < POINTSIZE_MIN) ||
                                ((height / node->height) < POINTSIZE_MIN)) {
        psx = 0;
        psy = 0;
    } else {
        psx = width / node->width;
        psy = height / node->height;

        hblackpen = _wpi_createpen( PS_SOLID, 0, BLACK );
        holdpen = _wpi_selectobject( mempres, hblackpen );

        _wpi_getrectvalues( rcclient, &left, &top, &right, &bottom );

        for (i=0; i < width; i = i + psx) {
            _wpi_setpoint( &startpt, i, top );
            _wpi_setpoint( &endpt, i, bottom );
            _wpi_movetoex( mempres, &startpt, NULL );
            _wpi_lineto( mempres, &endpt );
        }
        for (i=0; i <= height; i = i + psy) {
            _wpi_setpoint( &startpt, left, i );
            _wpi_setpoint( &endpt, right, i );
            _wpi_movetoex( mempres, &startpt, NULL );
            _wpi_lineto( mempres, &endpt );
        }

        _wpi_selectobject( mempres, holdpen );
        _wpi_deleteobject( hblackpen );
    }

    pres = _wpi_getpres( hwnd );
    _wpi_bitblt( pres, 0, 0, width, height, mempres, 0, 0, SRCCOPY );
    _wpi_releasepres( hwnd, pres );
    RedrawPrevClip(hwnd);  // Redraws if there was a clip region specified.
} /* showGrid */