Exemple #1
0
/*
 * RedrawPrevClip - redraw the area if a region has been selected and copied to the
 *                  clipboard OR if a region has been selected and then another is
 *                  selected (without a cut or copy in between)
 *                - the hwnd parameter indicates which window to draw the clip rect on
 *                - if the hwnd does not match the one associated with clipRect, we return
 */
void RedrawPrevClip( HWND hwnd )
{
    WPI_POINT   pointsize;
    int         prevROP2;
    HBRUSH      blackbrush;
    HBRUSH      oldbrush;
    HPEN        whitepen;
    HPEN        oldpen;
    WPI_PRES    pres;
    WPI_RECTDIM left;
    WPI_RECTDIM top;
    WPI_RECTDIM right;
    WPI_RECTDIM bottom;
    img_node    *node;

    if( !fEnableCutCopy || !_wpi_iswindow( Instance, hwnd ) || clipRect.hwnd != hwnd ) {
        return;
    }

    pointsize = GetPointSize( hwnd );

    pres = _wpi_getpres( hwnd );
    _wpi_torgbmode( pres );
    prevROP2 = _wpi_setrop2( pres, R2_XORPEN );
    blackbrush = _wpi_createsolidbrush( BLACK );
    oldbrush = _wpi_selectobject( pres, blackbrush );

    whitepen = _wpi_createpen( PS_SOLID, 0, WHITE );
    oldpen = _wpi_selectobject( pres, whitepen );

    _wpi_getrectvalues( clipRect.rect, &left, &top, &right, &bottom );

    node = SelectImage( hwnd );
#ifdef __OS2_PM__
    _wpi_rectangle( pres, left * pointsize.x + 1, bottom * pointsize.y + 1,
                    right * pointsize.x, top * pointsize.y );
#else
    _wpi_rectangle( pres, left * pointsize.x, top * pointsize.y,
                    right * pointsize.x, bottom * pointsize.y );
#endif
    _wpi_selectobject( pres, oldpen );
    _wpi_selectobject( pres, oldbrush );
    _wpi_setrop2( pres, prevROP2 );
    _wpi_releasepres( hwnd, pres );
    _wpi_deleteobject( whitepen );
    _wpi_deleteobject( blackbrush );

} /* RedrawPrevClip */
Exemple #2
0
/*
 * OutlineLine - outline the line before it is drawn
 */
void OutlineLine( HWND hwnd, WPI_POINT *start_pt, WPI_POINT *end_pt,
                  WPI_POINT *prev_pt, BOOL firsttime )
{
    WPI_POINT   startpt;
    WPI_POINT   endpt;
    WPI_POINT   prevpt;
    int         prevROP2;
    HPEN        holdpen;
    HPEN        hwhitepen;
    WPI_PRES    pres;

    CheckBounds( hwnd, start_pt );
    CheckBounds( hwnd, end_pt );
    startpt.x = MAKELOGPTX( start_pt->x ) + pointSize.x / 2;
    startpt.y = MAKELOGPTY( start_pt->y ) + pointSize.y / 2;
    endpt.x = MAKELOGPTX( end_pt->x ) + pointSize.x / 2;
    endpt.y = MAKELOGPTY( end_pt->y ) + pointSize.y / 2;

    pres = _wpi_getpres( hwnd );
    _wpi_torgbmode( pres );
    hwhitepen = _wpi_createpen( PS_SOLID, 0, WHITE );
    holdpen = _wpi_selectobject( pres, hwhitepen );

    prevROP2 = _wpi_setrop2( pres, R2_XORPEN );

    if( !firsttime ) {
        CheckBounds( hwnd, prev_pt );
        prevpt.x = MAKELOGPTX( prev_pt->x ) + pointSize.x / 2;
        prevpt.y = MAKELOGPTY( prev_pt->y ) + pointSize.y / 2;
        _wpi_movetoex( pres, &startpt, NULL );
        _wpi_lineto( pres, &prevpt );
    }

    _wpi_movetoex( pres, &startpt, NULL );
    _wpi_lineto( pres, &endpt );

    _wpi_setrop2( pres, prevROP2 );
    _wpi_selectobject( pres, holdpen );
    _wpi_deleteobject( hwhitepen );

    _wpi_releasepres( hwnd, pres );

}  /* OutlineLine */
Exemple #3
0
/*
 * DragClipBitmap - routine to show the clipped bitmap
 */
void DragClipBitmap( HWND hwnd, WPI_POINT *newpt, WPI_POINT pointsize )
{
    int         prevROP2;
    HBRUSH      hbrush;
    HBRUSH      holdbrush;
    HPEN        hwhitepen;
    HPEN        holdpen;
    WPI_PRES    pres;

    pres = _wpi_getpres( hwnd );
    if( pres == (HDC)NULL ) {
        return;
    }
    prevROP2 = _wpi_setrop2( pres, R2_XORPEN );
    hbrush = _wpi_createsolidbrush( CLR_BLACK );
    holdbrush = _wpi_selectobject( pres, hbrush );
    hwhitepen = _wpi_createpen( PS_SOLID, 0, CLR_WHITE );
    holdpen = _wpi_selectobject( pres, hwhitepen );

    if( !firstTime ) {
        _wpi_rectangle( pres, prevPoint.x * pointsize.x, prevPoint.y * pointsize.y,
                        prevPoint.x * pointsize.x + dragWidth,
                        prevPoint.y * pointsize.y + dragHeight );
    }

    _wpi_rectangle( pres, newpt->x * pointsize.x, newpt->y * pointsize.y,
                          newpt->x * pointsize.x + dragWidth,
                          newpt->y * pointsize.y + dragHeight );

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

    _wpi_setrop2( pres, prevROP2 );
    _wpi_releasepres( hwnd, pres );
    memcpy( &prevPoint, newpt, sizeof( WPI_POINT ) );
    firstTime = false;

} /* DragClipBitmap */
Exemple #4
0
/*
 * OutlineRectangle - outline a rectangle with the XOR pen
 */
void OutlineRectangle( bool firsttime, WPI_PRES pres, WPI_RECT *prevrc, WPI_RECT *newrc )
{
    int         prevrop2;
    HBRUSH      holdbrush;
    HBRUSH      nullbrush;
    HPEN        holdpen;
    HPEN        whitepen;
    int         left, top, right, bottom;

    _wpi_torgbmode( pres );

    nullbrush = _wpi_createnullbrush();
    whitepen = _wpi_createpen( PS_SOLID, 0, WHITE );
    holdbrush = _wpi_selectobject( pres, nullbrush );
    holdpen = _wpi_selectobject( pres, whitepen );

    prevrop2 = _wpi_setrop2( pres, R2_XORPEN );
    if( !firsttime ) {
        _wpi_getintrectvalues( *prevrc, &left, &top, &right, &bottom );
        /*
         * In this case don't call _wpi_convertheight because of the
         * way the rectangle values are set in iedraw.c
         */
        _wpi_rectangle( pres, left, top, right, bottom );
    }

    _wpi_getintrectvalues( *newrc, &left, &top, &right, &bottom );
    _wpi_rectangle( pres, left, top, right, bottom );

    _wpi_selectobject( pres, holdbrush );
    _wpi_selectobject( pres, holdpen );
    _wpi_setrop2( pres, prevrop2 );
    _wpi_deleteobject( whitepen );
    _wpi_deletenullbrush( nullbrush );

} /* OutlineRectangle */
Exemple #5
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 */
Exemple #6
0
void GUIDrawTextBitmapRGB( gui_window *wnd, const char *text,
                            size_t length, int height, gui_coord *pos,
                            WPI_COLOUR fore, WPI_COLOUR back, gui_ord extentx,
                            bool draw_extent, int bitmap )
{
    int         nDrawX, nDrawY;
    UINT        lenx;
    HBRUSH      brush;
    HBRUSH      old_brush;
    HPEN        pen;
    HPEN        old_pen;
    int         old_rop;
    size_t      num_chars;
    WPI_RECT    rect;
    gui_coord   indent;
    int         hscroll_pos;
    gui_coord   extent;
    WPI_COLOUR  colour;
    GUI_RECTDIM left, top, right, bottom;
    GUI_RECTDIM paint_left, paint_top, paint_right, paint_bottom;
    WPI_RECT    paint_rect;
    WPI_RECT    draw_rect;
    //draw_cache        dcache;

    if( ( wnd->hdc == NULLHANDLE ) || ( wnd->ps == NULL ) ||
        ( ( text == NULL ) && ( bitmap == 0 ) ) ||
        ( ( bitmap != 0 ) && ( height == 0 ) ) ) {
        return;
    }
    old_rop = 0;
    old_brush = (HBRUSH)NULL;
    brush = (HBRUSH)NULL;
    old_pen = (HPEN)NULL;
    pen = (HPEN)NULL;
    GUIGetMetrics( wnd );
    if( !bitmap ) {
        height = AVGYCHAR(GUItm);
    }
    rect = wnd->hwnd_client;
    _wpi_getrectvalues( rect, &left, &top, &right, &bottom);
    _wpi_getpaintrect( wnd->ps, &paint_rect );
    _wpi_getwrectvalues( paint_rect, &paint_left, &paint_top, &paint_right,
                         &paint_bottom );
    top = paint_top / height * height;
    bottom = ( paint_bottom + height - 1) / height * height;

    if( GUI_DO_HSCROLL( wnd ) ) {
        hscroll_pos = GUIGetScrollPos( wnd, SB_HORZ );
    } else {
        hscroll_pos = 0;
    }

    if( bitmap == 0 ) {
        num_chars = strlen( text );
        if( num_chars > length ) {
            num_chars = length;
        }
    }

    indent.x = pos->x;
    indent.y = pos->y;
    GUIScaleToScreenR( &indent );
    nDrawY = indent.y;
    if( GUI_DO_VSCROLL( wnd ) ) {
        nDrawY -= GUIGetScrollPos( wnd, SB_VERT );
    }
    nDrawX = left;
    nDrawX += ( indent.x - hscroll_pos );

    if( bitmap > 0 ) {
        lenx = length ;
    } else {
        lenx = GUIGetTextExtentX( wnd, text, num_chars );
    }

    if( draw_extent ) {
        /* blanks out some portion of rest of the line */
        if( extentx != GUI_NO_COLUMN ) {
            extent.x = extentx;
            GUIScaleToScreen( &extent );
            right = nDrawX + extent.x;
        }
    } else {
        right = nDrawX + lenx;
    }
    nDrawY = _wpi_cvth_y_size( nDrawY, _wpi_getheightrect(wnd->hwnd_client), height );

    _wpi_setrectvalues( &draw_rect, nDrawX, nDrawY, right, nDrawY+height );
    if( GUIIsRectInUpdateRect( wnd, &draw_rect ) ) {
        colour = _wpi_getnearestcolor( wnd->hdc, back );
        brush = _wpi_createsolidbrush( colour );
        pen = _wpi_createpen( PS_SOLID, 1, colour );
        if( pen == NULLHANDLE ) {
            GUIError(LIT( Pen_Failed ));
        }
        old_brush = _wpi_selectbrush( wnd->hdc, brush );
        old_pen = _wpi_selectpen( wnd->hdc, pen );
#ifdef __OS2_PM__
        _wpi_rectangle( wnd->hdc, nDrawX, nDrawY+1, right, nDrawY + height - 1 );
#else
        _wpi_rectangle( wnd->hdc, nDrawX, nDrawY, right, nDrawY + height);
#endif

        /* if visible even with scrolling */
        if( nDrawX < ( paint_right + hscroll_pos ) ) {
            if( bitmap > 0 ) {
                GUIDrawBitmap( bitmap, wnd->hdc, nDrawX, nDrawY, colour);
            } else {
#ifdef __OS2_PM__
                nDrawY += _wpi_metricdescent( GUItm );
#endif
                old_rop = _wpi_setrop2( wnd->hdc, R2_COPYPEN );
                SetText( wnd, fore, back );
                _wpi_textout( wnd->hdc, nDrawX, nDrawY, text, num_chars );
            }
        }
        /* restore old resources */
        if( old_rop != 0 ) {
            _wpi_setrop2( wnd->hdc, old_rop );
        }
        if( old_brush != (HBRUSH)NULL ) {
            _wpi_getoldbrush( wnd->hdc, old_brush );
        }
        if( brush != (HBRUSH)NULL ) {
            _wpi_deletebrush( brush );
        }
        if( old_pen != (HPEN)NULL ) {
            _wpi_getoldpen( wnd->hdc, old_pen );
        }
        if( pen != (HPEN)NULL ) {
            _wpi_deletepen( pen );
        }
    }
}