コード例 #1
0
ファイル: ieclrpal.c プロジェクト: Azarien/open-watcom-v2
/*
 * paintPalette - repaint the color palette
 */
static void paintPalette( HWND hwnd )
{
    WPI_PRES            hdc;
    WPI_POINT           pt;
    HPEN                holdpen;
    HPEN                hgraypen;
    HPEN                hwhitepen;
    PAINTSTRUCT         rect;
    WPI_RECT            client;
    int                 height;

    hdc = _wpi_beginpaint( hwnd, NULL, &rect );
#ifdef __OS2_PM__
    WinFillRect( hdc, &rect, CLR_PALEGRAY );
#endif
    _wpi_torgbmode( hdc );
    GetClientRect( hwnd, &client );
    height = _wpi_getheightrect( client );
#if defined( __NT__ )
    FillRect( (HDC)hdc, (CONST RECT*)&client, hbrush );
#endif

#if defined( __NT__ )
    hgraypen = _wpi_createpen( PS_SOLID, 0, GetSysColor( COLOR_BTNSHADOW ) );
#else
    hgraypen = _wpi_createpen( PS_SOLID, 0, DKGRAY );
#endif
    holdpen = _wpi_selectobject( hdc, hgraypen );
    pt.x = 2;
    pt.y = 50;
    _wpi_cvth_pt( &pt, height );
    _wpi_movetoex( hdc, &pt, NULL );

    pt.y = 6;
    _wpi_cvth_pt( &pt, height );
    _wpi_lineto( hdc, &pt );
    pt.x = 90;
    _wpi_lineto( hdc, &pt );

    _wpi_selectobject( hdc, holdpen );
    _wpi_deleteobject( hgraypen );

#if defined( __NT__ )
    hwhitepen = _wpi_createpen( PS_SOLID, 0, GetSysColor( COLOR_BTNHIGHLIGHT ) );
#else
    hwhitepen = _wpi_createpen( PS_SOLID, 0, WHITE );
#endif
    holdpen = _wpi_selectobject( hdc, hwhitepen );
    pt.y = 50;
    _wpi_cvth_pt( &pt, height );
    _wpi_lineto( hdc, &pt );
    pt.x = 2;
    _wpi_lineto( hdc, &pt );

    _wpi_selectobject( hdc, holdpen );
    _wpi_deleteobject( hwhitepen );
    _wpi_endpaint( hwnd, hdc, &rect );

} /* paintPalette */
コード例 #2
0
/*
 * LineXorAnd - draw the line on the XOR and the AND bitmaps
 */
void LineXorAnd( COLORREF xorcolor, COLORREF andcolor,
                 WPI_POINT *startpt, WPI_POINT *endpt )
{
    HPEN        oldpen;
    HPEN        hpen;
    HDC         memdc;
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HBITMAP     oldbitmap;
    HDC         anddc;

    anddc = anddc;
    pres = _wpi_getpres( HWND_DESKTOP );
    mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
    _wpi_releasepres( HWND_DESKTOP, pres );

    _wpi_torgbmode( mempres );
    hpen = _wpi_createpen( PS_SOLID, 0, xorcolor );
    oldpen = _wpi_selectobject( mempres, hpen );
    oldbitmap = _wpi_selectobject( mempres, activeImage->hxorbitmap );

    _wpi_movetoex( mempres, startpt, NULL );
    _wpi_lineto( mempres, endpt );
    _wpi_setpixel( mempres, endpt->x, endpt->y, xorcolor );

    _wpi_selectobject( mempres, oldpen );
    _wpi_deleteobject( hpen );
    _wpi_selectobject( mempres, oldbitmap );

    if( activeImage->imgtype == BITMAP_IMG ) {
        _wpi_deletecompatiblepres( mempres, memdc );
        return;
    }

    hpen = _wpi_createpen( PS_SOLID, 0, andcolor );
    oldpen = _wpi_selectobject( mempres, hpen );
    oldbitmap = _wpi_selectobject( mempres, activeImage->handbitmap );

    _wpi_movetoex( mempres, startpt, NULL );
    _wpi_lineto( mempres, endpt );
    _wpi_setpixel( mempres, endpt->x, endpt->y, andcolor );

    _wpi_selectobject( mempres, oldpen );
    _wpi_deleteobject( hpen );
    _wpi_selectobject( mempres, oldbitmap );
    _wpi_deletecompatiblepres( mempres, anddc );

} /* LineXorAnd */
コード例 #3
0
ファイル: colors.c プロジェクト: ABratovic/open-watcom-v2
/*
 * DisplayColorBox - display the colors on the given device context
 *                 - PM Note: we assume the presentation space is already in RGB mode
 */
void DisplayColorBox( WPI_PRES pres, palette_box *box )
{
    int                 top;
    int                 bottom;
    HBRUSH              hcolorbrush;
    HBRUSH              holdbrush;
    HPEN                holdpen;
    HPEN                blackpen;
    int                 height;

    blackpen = _wpi_createpen( PS_SOLID, 0, BLACK );
    holdpen = _wpi_selectobject( pres, blackpen );
    hcolorbrush = _wpi_createsolidbrush( box->color );
    holdbrush = _wpi_selectobject( pres, hcolorbrush );

    height = 2 * SQR_SIZE + 1;
    top = _wpi_cvth_y( box->box.top, height );
    bottom = _wpi_cvth_y( box->box.bottom, height );
    _wpi_rectangle( pres, box->box.left, top, box->box.right, bottom );

    _wpi_selectobject( pres, holdbrush );
    _wpi_deleteobject( hcolorbrush );
    _wpi_selectobject( pres, holdpen );
    _wpi_deleteobject( blackpen );

} /* DisplayColorBox */
コード例 #4
0
ファイル: window.c プロジェクト: ABratovic/open-watcom-v2
static void get_obj_settings(
/***************************/
/* set brush and pen based on fill type, for normal objects (polys, pies)  */

    int                 fill_type,
    HPEN                *pen,
    HBRUSH              *brush
) {

    switch( fill_type ) {

    case FILL_BORDER:           // border only: interior not touched (pen)
        *pen = _wpi_createpen( Set_pen_style, 1, Set_color );
        *brush = _wpi_createnullbrush();
        Old_pen = _wpi_selectpen( Win_dc, *pen );
        Old_brush = _wpi_selectbrush( Win_dc, *brush );
        break;

    case FILL_INTERIOR:         // interior only: border not touched (brush)
        /* Windows has a nasty bug. NULL_PEN generates a 'non-written'
           border. 'Width' = 0 doesn't help either. With NULL_PEN,
           behaviour depends on the primitive: rectangles goof, polygons
           are OK. Anyway, gist is that we gotta live with it! */
        //*pen = CreatePen( PS_SOLID, 0, _wpi_getrgb( 0, 0, 0 ) );
        *pen = _wpi_createnullpen();
        *brush = cgr_make_brush( Set_color, Set_fill_style );
        Old_pen = _wpi_selectpen( Win_dc, *pen );
        Old_brush = _wpi_selectbrush( Win_dc, *brush );
        break;

    case FILL_BORDER_CLEAR:             // border WITH interior erased to bkgd (pen)
        *pen = _wpi_createpen( Set_pen_style, 1, Set_color );
        *brush = cgr_make_brush( GetBkColor( Win_dc ), FILL_SOLID );
        Old_pen = _wpi_selectpen( Win_dc, *pen );
        Old_brush = _wpi_selectbrush( Win_dc, *brush );
        break;

    case FILL_BORDER_FILL:              // border and interior (pen & brush)
        *pen = _wpi_createpen( Set_pen_style, 1, Set_color );
        *brush = cgr_make_brush( Set_color, Set_fill_style );
        Old_pen = _wpi_selectpen( Win_dc, *pen );
        Old_brush = _wpi_selectbrush( Win_dc, *brush );
        break;
    }
}
コード例 #5
0
ファイル: clrcntls.c プロジェクト: Ukusbobra/open-watcom-v2
/*
 * ShowNewColor - replace the color of the color box and redisplay the boxes
 */
void ShowNewColor( int index, COLORREF newcolor, BOOL repaint )
{
    WPI_POINT   topleft;
    WPI_POINT   bottomright;
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HDC         hdc;
    HBITMAP     oldbitmap;
    HBRUSH      brush;
    HBRUSH      oldbrush;
    HPEN        blackpen;
    HPEN        oldpen;

    pres = _wpi_getpres( HWND_DESKTOP );
    _wpi_torgbmode( pres );
    paletteBox[index].color = newcolor;
    paletteBox[index].solid_color = _wpi_getnearestcolor( pres, newcolor );
    _wpi_releasepres( HWND_DESKTOP, pres );

    if( numberOfColors != 2 ) {
        topleft.x = (index / 2) * SQR_SIZE;
        bottomright.x = topleft.x + SQR_SIZE + 1;
        if( index / 2 == (index + 1) / 2 ) {
            topleft.y = 0;
            bottomright.y = SQR_SIZE + 1;
        } else {
            topleft.y = SQR_SIZE;
            bottomright.y = 2 * SQR_SIZE + 1;
        }
        pres = _wpi_getpres( HWND_DESKTOP );
        mempres = _wpi_createcompatiblepres( pres, Instance, &hdc );
        _wpi_releasepres( HWND_DESKTOP, pres );
        _wpi_torgbmode( mempres );

        brush = _wpi_createsolidbrush( newcolor );
        oldbrush = _wpi_selectobject( mempres, brush );
        blackpen = _wpi_createpen( PS_SOLID, 0, BLACK );
        oldpen = _wpi_selectobject( mempres, blackpen );
        oldbitmap = _wpi_selectbitmap( mempres, hColorBitmap );

        _wpi_cvth_pt( &topleft, colorsHeight );
        _wpi_cvth_pt( &bottomright, colorsHeight );

        _wpi_rectangle( mempres, topleft.x, topleft.y, bottomright.x, bottomright.y );
        _wpi_selectobject( mempres, oldpen );
        _wpi_selectobject( mempres, oldbrush );
        _wpi_deleteobject( blackpen );
        _wpi_deleteobject( brush );
        _wpi_getoldbitmap( mempres, oldbitmap );
        _wpi_deletecompatiblepres( mempres, hdc );
    }

    if( repaint ) {
        _wpi_invalidaterect( hColorsWnd, NULL, FALSE );
    }

} /* ShowNewColor */
コード例 #6
0
ファイル: statwnd.c プロジェクト: Azarien/open-watcom-v2
/*
 * StatusWndChangeSysColors - fiddle with what StatusWnd believes
 *                            are the system colors
 */
void StatusWndChangeSysColors( COLORREF btnFace, COLORREF btnText,
                               COLORREF btnHighlight, COLORREF btnShadow )
{
#ifdef __NT__
    if( !IsCommCtrlLoaded() ) {
#endif
        if( hasGDIObjects ) {
            _wpi_deleteobject( penLight );
            _wpi_deleteobject( penShade );
            _wpi_deleteobject( brushButtonFace );
        }

        colorButtonFace = btnFace;
        colorTextFace = btnText;
        brushButtonFace = _wpi_createsolidbrush( btnFace );
        penLight = _wpi_createpen( PS_SOLID, 1, btnHighlight );
        penShade = _wpi_createpen( PS_SOLID, 1, btnShadow );
        hasGDIObjects = true;
#ifdef __NT__
    }
#endif
}
コード例 #7
0
ファイル: clip.c プロジェクト: Azarien/open-watcom-v2
/*
 * 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 */
コード例 #8
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 */
コード例 #9
0
ファイル: clip.c プロジェクト: Azarien/open-watcom-v2
/*
 * 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 */
コード例 #10
0
ファイル: ieutil.c プロジェクト: Azarien/open-watcom-v2
/*
 * 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 */
コード例 #11
0
/*
 * drawPt - Actually draws the point on the drawing region. (uses LineDDA)
 */
void CALLBACK drawPt( int xpos, int ypos, WPI_PARAM2 lparam )
{
    HBRUSH      colourbrush;
    HBRUSH      oldbrush;
    HPEN        colourpen;
    HPEN        oldpen;
    COLORREF    selected_colour;
    COLORREF    dithered;
    short       mousebutton;
    WPI_PRES    pres;
    HWND        hwnd;
    short       area_x;
    short       area_y;
    short       width;
    short       height;
    short       i;
    short       j;
    WPI_POINT   pt;
    WPI_RECT    rcclient;
    wie_clrtype type;
    int         brushsize;
    BOOL        gridvisible;

    hwnd = (HWND)GET_HWND_PARAM2( lparam );
    mousebutton = currentMouseButton;
    _wpi_getclientrect( hwnd, &rcclient );
    brushsize = ImgedConfigInfo.brush_size;

    gridvisible = ImgedConfigInfo.grid_on && (pointSize.x >= POINTSIZE_MIN &&
                                                pointSize.y >= POINTSIZE_MIN);
    if ((!gridvisible) && (toolType == IMGED_FREEHAND)) {
        area_x = xpos * pointSize.x;
        area_y = ypos * pointSize.y;
        width = (short)pointSize.x;
        height = (short)pointSize.y;
    } else if ((!gridvisible) && (toolType == IMGED_BRUSH)) {
        area_x = max(0, xpos-brushsize/2) * pointSize.x;
        area_y = max(0, ypos-brushsize/2) * pointSize.y;
        width = (short)(brushsize * pointSize.x);
        height = (short)(brushsize * pointSize.y);
        /*
         * We just have to check that we don't spill over the image dimensions
         */
        area_x = min( area_x, _wpi_getwidthrect(rcclient)-width );
        area_y = min( area_y, _wpi_getheightrect(rcclient)-width );
    } else if ((gridvisible) && (toolType == IMGED_FREEHAND)) {
        area_x = xpos * pointSize.x+1;
        area_y = ypos * pointSize.y+1;
        width = (short)(pointSize.x-1);
        height = (short)(pointSize.y-1);
    } else {
        area_x = max(0, xpos-brushsize/2) * pointSize.x+1;
        area_y = max(0, ypos-brushsize/2) * pointSize.y+1;
        width = (short)(pointSize.x - 1);
        height = (short)(pointSize.y - 1);
        /*
         * We just have to check that we don't spill over the image dimensions
         */
        area_x = min( area_x, _wpi_getwidthrect(rcclient) - pointSize.x *
                                                                brushsize+1 );
        area_y = min( area_y, _wpi_getheightrect(rcclient) - pointSize.y *
                                                                brushsize+1 );
    }

    pres = _wpi_getpres( hwnd );
    _wpi_torgbmode( pres );
    dithered = GetSelectedColour( mousebutton, &selected_colour, &type );

    colourbrush = _wpi_createsolidbrush( selected_colour );
    oldbrush = _wpi_selectobject(pres, colourbrush);
    colourpen = _wpi_createpen(PS_SOLID, 0, selected_colour);
    oldpen = _wpi_selectobject(pres, colourpen);

    if (gridvisible && (toolType == IMGED_BRUSH)) {
        for (i=0; i < brushsize; ++i) {
            for (j=0; j < brushsize; ++j) {
                _wpi_patblt(pres, area_x+i*pointSize.x, area_y+j*pointSize.y,
                                                width, height, PATCOPY);
            }
        }
    } else {
        _wpi_patblt(pres, area_x, area_y, width, height, PATCOPY);
    }

    _wpi_selectobject(pres, oldbrush);
    _wpi_selectobject(pres, oldpen);
    _wpi_releasepres( hwnd, pres );

    _wpi_deleteobject( colourbrush );
    _wpi_deleteobject( colourpen );

    pt.x = area_x / pointSize.x;
    pt.y = area_y / pointSize.y;
    if (toolType == IMGED_BRUSH) {
        if (type == SCREEN_CLR) {
            BrushThePoints(selected_colour, BLACK, WHITE, &pt, brushsize);
        } else if (type == INVERSE_CLR) {
            BrushThePoints(selected_colour, WHITE, WHITE, &pt, brushsize);
        } else {
            BrushThePoints(selected_colour, selected_colour, BLACK, &pt,
                                                                brushsize);
        }
    } else {
        if (type == SCREEN_CLR) {
            DrawThePoints(selected_colour, BLACK, WHITE, &pt);
        } else if (type == INVERSE_CLR) {
            DrawThePoints(selected_colour, WHITE, WHITE, &pt);
        } else {
            DrawThePoints(selected_colour, selected_colour, BLACK, &pt);
        }
    }
} /* drawPt */
コード例 #12
0
/*
 * DrawSinglePoint - needed for when the mouse button is initially pressed.
 */
void DrawSinglePoint( HWND hwnd, WPI_POINT *pt, short mousebutton )
{
    HBRUSH      colourbrush;
    HBRUSH      oldbrush;
    HPEN        colourpen;
    HPEN        oldpen;
    COLORREF    selected_colour;
    COLORREF    dithered;
    short       truncated_x;
    short       truncated_y;
    short       i;
    short       j;
    WPI_POINT   logical_pt;
    WPI_RECT    rcclient;
    short       width;
    short       height;
    short       wndwidth;
    short       wndheight;
    wie_clrtype type;
    WPI_PRES    pres;
    int         brushsize;
    BOOL        gridvisible;

    GetClientRect( hwnd, &rcclient );
    wndwidth = _wpi_getwidthrect( rcclient );
    wndheight = _wpi_getheightrect( rcclient );
    brushsize = ImgedConfigInfo.brush_size;

    CheckBounds( hwnd, pt );

    gridvisible = ImgedConfigInfo.grid_on && (pointSize.x >= POINTSIZE_MIN &&
                                                pointSize.y >= POINTSIZE_MIN);
    if (gridvisible) {
        if (toolType == IMGED_BRUSH) {
            truncated_x = max(0, (pt->x/pointSize.x - brushsize/2)) * pointSize.x+1;
            truncated_y = max(0, (pt->y/pointSize.y - brushsize/2)) * pointSize.y+1;
            width = (short)(pointSize.x - 1);
            height = (short)(pointSize.y - 1);
            /*
             * We just have to check that we don't spill over the image dimensions
             */
            truncated_x = min(truncated_x, wndwidth-pointSize.x*brushsize+1);
            truncated_y = min(truncated_y, wndheight-pointSize.y*brushsize+1);
        } else {
            truncated_x = ( pt->x / pointSize.x) * pointSize.x + 1;
            truncated_y = ( pt->y / pointSize.y) * pointSize.y + 1;
            width = (short)(pointSize.x - 1);
            height = (short)(pointSize.y - 1);
        }
    } else {
        if (toolType == IMGED_BRUSH) {
            truncated_x = max(0, (pt->x / pointSize.x - brushsize/2)) * pointSize.x;
            truncated_y = max(0, (pt->y / pointSize.y - brushsize/2)) * pointSize.y;
            width = (short)(pointSize.x * brushsize);
            height = (short)(pointSize.y * brushsize);
            /*
             * We just have to check that we don't spill over the image dimensions
             */
            truncated_x = min( truncated_x, wndwidth-width );
            truncated_y = min( truncated_y, wndheight-width );
        } else {
            truncated_x = ( pt->x / pointSize.x) * pointSize.x;
            truncated_y = ( pt->y / pointSize.y) * pointSize.y;
            width = (short)pointSize.x;
            height = (short)pointSize.y;
        }
    }
    logical_pt.x = truncated_x / pointSize.x;
    logical_pt.y = truncated_y / pointSize.y;

    pres = _wpi_getpres( hwnd );
    _wpi_torgbmode( pres );
    dithered = GetSelectedColour(mousebutton, &selected_colour, &type);
    colourbrush = _wpi_createsolidbrush( selected_colour );
    oldbrush = _wpi_selectobject( pres, colourbrush );
    colourpen = _wpi_createpen( PS_SOLID, 0, selected_colour );
    oldpen = _wpi_selectobject( pres, colourpen );

    if (gridvisible && (toolType == IMGED_BRUSH)) {
        for (i=0; i < brushsize; ++i) {
            for (j=0; j < brushsize; ++j) {
                _wpi_patblt(pres, truncated_x+i*pointSize.x,
                                  truncated_y+j*pointSize.y,
                                  width, height, PATCOPY);
            }
        }
    } else {
        _wpi_patblt(pres, truncated_x, truncated_y, width, height, PATCOPY);
    }

    _wpi_selectobject( pres, oldbrush );
    _wpi_selectobject( pres, oldpen );
    _wpi_releasepres( hwnd, pres );

    _wpi_deleteobject( colourbrush );
    _wpi_deleteobject( colourpen );

    /*
     * draws the points in the view window
     */
    if (toolType == IMGED_BRUSH) {
        if (type == SCREEN_CLR) {
            BrushThePoints(selected_colour, BLACK, WHITE, &logical_pt,
                                                                brushsize);
        } else if (type == INVERSE_CLR) {
            BrushThePoints(selected_colour, WHITE, WHITE, &logical_pt,
                                                                brushsize);
        } else {
            BrushThePoints(selected_colour, selected_colour, BLACK,
                                                    &logical_pt, brushsize);
        }
    } else {
        if (type == SCREEN_CLR) {
            DrawThePoints(selected_colour, BLACK, WHITE, &logical_pt);
        } else if (type == INVERSE_CLR) {
            DrawThePoints(selected_colour, WHITE, WHITE, &logical_pt);
        } else {
            DrawThePoints(selected_colour, selected_colour, BLACK, &logical_pt);
        }
    }
} /* DrawSinglePoint */
コード例 #13
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 */
コード例 #14
0
ファイル: statwnd.c プロジェクト: Azarien/open-watcom-v2
/*
 * StatusWndInit - initialize for using the status window
 */
bool StatusWndInit( WPI_INST hinstance, statushook hook, int extra, HCURSOR hDefaultCursor )
{
    bool        rc;
#ifdef __OS2_PM__
    /* OS/2 PM version of the initialization */

    colorButtonFace = CLR_PALEGRAY;

    if( !hasGDIObjects ) {
        brushButtonFace = _wpi_createsolidbrush( colorButtonFace );
        penLight = _wpi_createpen( PS_SOLID, 1, CLR_WHITE );
        penShade = _wpi_createpen( PS_SOLID, 1, CLR_DARKGRAY );
        hasGDIObjects = true;
    }

    statusWndHookFunc = hook;

    rc = true;
    if( !classRegistered ) {
        memcpy( &classHandle, &hinstance, sizeof( WPI_INST ) );
        rc = WinRegisterClass( hinstance.hab, className, (PFNWP)StatusWndCallback,
                               CS_SIZEREDRAW | CS_CLIPSIBLINGS,
                               extra + sizeof( statwnd * ) );
        classWinExtra = extra;
        classRegistered = true;
    }
#else
    /* Win16 and Win32 version of the initialization */
    WNDCLASS    wc;

  #ifdef __NT__
    if( LoadCommCtrl() ) {
        rc = true;
    } else {
  #endif
        if( !hasGDIObjects ) {
            colorButtonFace = GetSysColor( COLOR_BTNFACE );
            colorTextFace = GetSysColor( COLOR_BTNTEXT );
            brushButtonFace = CreateSolidBrush( colorButtonFace );
            penLight = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) );
            penShade = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) );
            hasGDIObjects = true;
        }

        statusWndHookFunc = hook;

        rc = true;
        if( !GetClassInfo( hinstance, className, &wc ) ) {
            classHandle = hinstance;
            classWinExtra = extra;
            wc.style = CS_HREDRAW | CS_VREDRAW;
            wc.lpfnWndProc = GetWndProc( StatusWndCallback );
            wc.cbClsExtra = 0;
            wc.cbWndExtra = extra + sizeof( statwnd * );
            wc.hInstance = hinstance;
            wc.hIcon = LoadIcon( (HINSTANCE)NULL, IDI_APPLICATION );
            wc.hCursor = hDefaultCursor;
            if( wc.hCursor == NULL ) {
                wc.hCursor = LoadCursor( (HINSTANCE)NULL, IDC_ARROW );
            }
            wc.hbrBackground = (HBRUSH)0;
            wc.lpszMenuName = NULL;
            wc.lpszClassName = className;
            rc = ( RegisterClass( &wc ) != 0 );
            classRegistered = true;
        }
  #ifdef __NT__
    }
  #endif
#endif
    return( rc );

} /* StatusWndInit */
コード例 #15
0
ファイル: curclr.c プロジェクト: ABratovic/open-watcom-v2
/*
 * SetColor - set the current colors
 */
void SetColor( int mousebutton, COLORREF color, COLORREF solid, wie_clrtype type )
{
    HDC         hdc;
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HBITMAP     oldbitmap;
    HPEN        blackpen;
    HPEN        oldpen;
    HBRUSH      brush;
    HBRUSH      oldbrush;
    int         top;
    int         bottom;

    blackpen = _wpi_createpen( PS_SOLID, 0, BLACK );
    if( mousebutton == LMOUSEBUTTON ) {
        lButton.color = color;
        lButton.solid = solid;
        lButton.type = type;
        if( lButton.bitmap != NULL ) {
            _wpi_deletebitmap( lButton.bitmap );
            pres = _wpi_getpres( HWND_DESKTOP );
            if( numberOfColors == 2 && type == NORMAL_CLR ) {
                lButton.bitmap = _wpi_createbitmap( CUR_SQR_SIZE + 1, 2 * CUR_SQR_SIZE + 1,
                                                    1, 1, NULL );
            } else {
                lButton.bitmap = _wpi_createcompatiblebitmap( pres, CUR_SQR_SIZE + 1,
                                                              2 * CUR_SQR_SIZE + 1 );
            }
            mempres = _wpi_createcompatiblepres( pres, Instance, &hdc );
            _wpi_torgbmode( mempres );
            oldbitmap = _wpi_selectobject( mempres, lButton.bitmap );
            _wpi_releasepres( HWND_DESKTOP, pres );

            oldpen = _wpi_selectobject( mempres, blackpen );
            brush = _wpi_createsolidbrush( solid );
            oldbrush = _wpi_selectobject( mempres, brush );

            top = _wpi_cvth_y( 0, currentHeight );
            bottom = _wpi_cvth_y( CUR_SQR_SIZE + 1, currentHeight );

            _wpi_rectangle( mempres, 0, top, CUR_SQR_SIZE + 1, bottom );
            _wpi_selectobject( mempres, oldbrush );
            _wpi_deleteobject( brush );

            brush = _wpi_createsolidbrush( color );
            oldbrush = _wpi_selectobject( mempres, brush );

            top = _wpi_cvth_y( CUR_SQR_SIZE, currentHeight );
            bottom = _wpi_cvth_y( 2 * CUR_SQR_SIZE + 1, currentHeight );

            _wpi_rectangle( mempres, 0, top, CUR_SQR_SIZE + 1, bottom );
            _wpi_selectobject( mempres, oldbrush );
            _wpi_deleteobject( brush );
            _wpi_selectobject( mempres, oldbitmap );
            _wpi_selectobject( mempres, oldpen );
            _wpi_deletecompatiblepres( mempres, hdc );
        }
    } else {
        rButton.color = color;
        rButton.solid = solid;
        rButton.type = type;
        if( rButton.bitmap != NULL ) {
            _wpi_deletebitmap( rButton.bitmap );
            pres = _wpi_getpres( HWND_DESKTOP );
            if( numberOfColors == 2 && type == NORMAL_CLR ) {
                rButton.bitmap = _wpi_createbitmap( CUR_SQR_SIZE + 1, 2 * CUR_SQR_SIZE + 1,
                                                    1, 1, NULL );
            } else {
                rButton.bitmap = _wpi_createcompatiblebitmap( pres, CUR_SQR_SIZE + 1,
                                                              2 * CUR_SQR_SIZE + 1 );
            }
            mempres = _wpi_createcompatiblepres( pres, Instance, &hdc );
            _wpi_torgbmode( mempres );

            oldbitmap = _wpi_selectobject( mempres, rButton.bitmap );
            _wpi_releasepres( HWND_DESKTOP, pres );
            oldpen = _wpi_selectobject( mempres, blackpen );
            brush = _wpi_createsolidbrush( solid );
            oldbrush = _wpi_selectobject( mempres, brush );

            top = _wpi_cvth_y( 0, currentHeight );
            bottom = _wpi_cvth_y( CUR_SQR_SIZE + 1, currentHeight );
            _wpi_rectangle( mempres, 0, top, CUR_SQR_SIZE + 1, bottom );
            _wpi_selectobject( mempres, oldbrush );
            _wpi_deleteobject( brush );

            brush = _wpi_createsolidbrush( color );
            oldbrush = _wpi_selectobject( mempres, brush );

            top = _wpi_cvth_y( CUR_SQR_SIZE, currentHeight );
            bottom = _wpi_cvth_y( 2 * CUR_SQR_SIZE + 1, currentHeight );

            _wpi_rectangle( mempres, 0, top, CUR_SQR_SIZE + 1, bottom );
            _wpi_selectobject( mempres, oldbrush );
            _wpi_deleteobject( brush );
            _wpi_selectobject( mempres, oldbitmap );
            _wpi_selectobject( mempres, oldpen );
            _wpi_deletecompatiblepres( mempres, hdc );
        }
    }
    _wpi_deleteobject( blackpen );
    InvalidateRect( hCurrentWnd, NULL, TRUE );

} /* SetColor */
コード例 #16
0
ファイル: guidrawr.c プロジェクト: Azarien/open-watcom-v2
static bool DrawLine( gui_window *wnd, gui_point *start, gui_point *end,
                      gui_line_styles style, gui_ord thickness,
                      WPI_COLOUR colour )
{
    gui_point   my_start;
    gui_point   my_end;
    HPEN        pen;
    int         win_style;
    gui_coord   coord;
    HPEN        old_pen;
    int         hscroll;
    int         vscroll;
    WPI_POINT   pt;
    int         win_height;

    my_start = *start;
    my_end = *end;
    GUIScaleToScreenRPt( &my_start );
    GUIScaleToScreenRPt( &my_end );
    if( GUI_DO_VSCROLL( wnd ) ) {
        vscroll = GUIGetScrollPos( wnd, SB_VERT );
    } else {
        vscroll = 0;
    }
    if( GUI_DO_HSCROLL( wnd ) ) {
        hscroll = GUIGetScrollPos( wnd, SB_HORZ );
    } else {
        hscroll = 0;
    }
    switch( style ) {
    case GUI_PEN_SOLID :
        win_style = PS_SOLID;
        coord.x = thickness;
        GUIScaleToScreenR( &coord );
        break;
    case GUI_PEN_DASH :
        coord.x = 1;
        win_style = PS_DASH;
        break;
    case GUI_PEN_DOT :
        coord.x = 1;
        win_style = PS_DOT;
        break;
    case GUI_PEN_DASHDOT :
        coord.x = 1;
        win_style = PS_DASHDOT;
        break;
    case GUI_PEN_DASHDOTDOT :
        coord.x = 1;
        win_style = PS_DASHDOTDOT;
        break;
    default:
        coord.x = 0;
        win_style = 0;
        break;
    }
    pen = _wpi_createpen( win_style, coord.x, colour );

    old_pen = _wpi_selectpen( wnd->hdc, pen );

    win_height = _wpi_getheightrect( wnd->hwnd_client_rect );

    pt.x = my_start.x - hscroll;
    pt.y = my_start.y - vscroll;
    pt.y = _wpi_cvth_y_plus1( pt.y, win_height );
    _wpi_movetoex( wnd->hdc, &pt, &pt );

    pt.x = my_end.x - hscroll;
    pt.y = my_end.y - vscroll;
    pt.y = _wpi_cvth_y_plus1( pt.y, win_height );
    _wpi_lineto( wnd->hdc, &pt );

    if( old_pen != NULLHANDLE ) {
        _wpi_getoldpen( wnd->hdc, old_pen );
    }

    _wpi_deletepen( pen );

    return( true );
}
コード例 #17
0
ファイル: colors.c プロジェクト: ABratovic/open-watcom-v2
/*
 * InitPaletteBitmaps - initialize the available color bitmaps
 */
void InitPaletteBitmaps( HWND hwnd, HBITMAP *colorbitmap, HBITMAP *monobitmap )
{
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HDC         hdc;
    HBITMAP     oldbitmap;
    COLORREF    color;
    int         i;
    int         left_sqr;
    HBRUSH      colorbrush;
    HBRUSH      oldbrush;
    HPEN        blackpen;
    HPEN        oldpen;
    int         top;
    int         bottom;
    int         height;

    pres = _wpi_getpres( hwnd );

    *colorbitmap = _wpi_createcompatiblebitmap( pres, CUR_BMP_WIDTH, CUR_BMP_HEIGHT );
    *monobitmap = _wpi_createbitmap( CUR_BMP_WIDTH, CUR_BMP_HEIGHT, 1, 1, NULL );
    mempres = _wpi_createcompatiblepres( pres, Instance, &hdc );

    _wpi_releasepres( hwnd, pres );
    _wpi_torgbmode( mempres );

    blackpen = _wpi_createpen( PS_SOLID, 0, BLACK );
    oldpen = _wpi_selectobject( mempres, blackpen );
    oldbitmap = _wpi_selectobject( mempres, *colorbitmap );

    /*
     * PM NOTE: All box coordinates are relative to the window's origin
     * of top left.  So we convert the height for PM.
     */
    left_sqr = 0;
    height = 2 * SQR_SIZE + 1;
    for( i = 0; i < PALETTE_SIZE; i += 2 ) {
        color = RGB( palette[COLOR_16][i].rgbRed, palette[COLOR_16][i].rgbGreen,
                     palette[COLOR_16][i].rgbBlue );
        colorbrush = _wpi_createsolidbrush( color );
        oldbrush = _wpi_selectobject( mempres, colorbrush );

        top = _wpi_cvth_y( 0, height );
        bottom = _wpi_cvth_y( SQR_SIZE + 1, height );

        _wpi_rectangle( mempres, left_sqr, top, left_sqr + SQR_SIZE + 1, bottom );
        _wpi_selectobject( mempres, oldbrush );
        _wpi_deleteobject( colorbrush );
        color = RGB( palette[COLOR_16][i + 1].rgbRed, palette[COLOR_16][i + 1].rgbGreen,
                     palette[COLOR_16][i + 1].rgbBlue );
        colorbrush = _wpi_createsolidbrush( color );
        oldbrush = _wpi_selectobject( mempres, colorbrush );

        top = _wpi_cvth_y( SQR_SIZE, height );
        bottom = _wpi_cvth_y( 2 * SQR_SIZE + 1, height );

        _wpi_rectangle( mempres, left_sqr, top, left_sqr + SQR_SIZE + 1, bottom );
        _wpi_selectobject( mempres, oldbrush );
        _wpi_deleteobject( colorbrush );

        left_sqr += SQR_SIZE;
    }

    _wpi_selectobject( mempres, oldbitmap );
    oldbitmap = _wpi_selectobject( mempres, *monobitmap );

    left_sqr = 0;
    for( i = 0; i < PALETTE_SIZE; i += 2 ) {
        color = RGB( palette[COLOR_2][i].rgbRed, palette[COLOR_2][i].rgbGreen,
                     palette[COLOR_2][i].rgbBlue );
        colorbrush = _wpi_createsolidbrush( color );
        oldbrush = _wpi_selectobject( mempres, colorbrush );

        top = _wpi_cvth_y( 0, height );
        bottom = _wpi_cvth_y( SQR_SIZE + 1, height );

        _wpi_rectangle( mempres, left_sqr, top, left_sqr + SQR_SIZE + 1, bottom );
        _wpi_selectobject( mempres, oldbrush );
        _wpi_deleteobject( colorbrush );

        color = RGB( palette[COLOR_2][i + 1].rgbRed, palette[COLOR_2][i + 1].rgbGreen,
                     palette[COLOR_2][i + 1].rgbBlue );
        colorbrush = _wpi_createsolidbrush( color );
        oldbrush = _wpi_selectobject( mempres, colorbrush );

        top = _wpi_cvth_y( SQR_SIZE, height );
        bottom = _wpi_cvth_y( 2 * SQR_SIZE + 1, height );

        _wpi_rectangle( mempres, left_sqr, top, left_sqr + SQR_SIZE + 1, bottom );
        _wpi_selectobject( mempres, oldbrush );
        _wpi_deleteobject( colorbrush );

        left_sqr += SQR_SIZE;
    }
    _wpi_selectobject( mempres, oldbitmap );
    _wpi_selectobject( mempres, oldpen );
    _wpi_deletecompatiblepres( mempres, hdc );
    _wpi_deleteobject( blackpen );

} /* InitPaletteBitmaps */
コード例 #18
0
/*
 * RegionXorAnd - Draws a filled or framed region (ellipse or rectangle) in
 *               the View window.
 */
void RegionXorAnd( COLORREF xorcolour, COLORREF andcolour, BOOL fFillRgn,
                                                WPI_RECT *r, BOOL is_rect )
{
    HBRUSH      oldbrush;
    HBRUSH      hbrush;
    HPEN        oldpen;
    HPEN        hpen;
    WPI_PRES    mempres;
    HDC         memdc;
    WPI_PRES    pres;
    HBITMAP     oldbitmap;
    int         left;
    int         top;
    int         right;
    int         bottom;

    pres = _wpi_getpres( HWND_DESKTOP );
    mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
    _wpi_releasepres( HWND_DESKTOP, pres );

    _wpi_torgbmode( mempres );

    hpen = _wpi_createpen( PS_SOLID, 0, xorcolour );
    oldpen = _wpi_selectobject( mempres, hpen );
    oldbitmap = _wpi_selectobject( mempres, activeImage->hxorbitmap );

    if ( fFillRgn ) {
        hbrush = _wpi_createsolidbrush( xorcolour );
    } else {
        hbrush = _wpi_createnullbrush();
    }

    oldbrush = _wpi_selectobject( mempres, hbrush );
    _wpi_getintrectvalues( *r, &left, &top, &right, &bottom );
    if (is_rect) {
        _wpi_rectangle( mempres, left, top, right, bottom );
    } else {
        _wpi_ellipse( mempres, left, top, right, bottom );
    }

    _wpi_selectobject( mempres, oldpen );
    _wpi_deletepen( hpen );
    _wpi_selectobject( mempres, oldbrush );
    _wpi_selectobject( mempres, oldbitmap );
    if (fFillRgn) {
        _wpi_deleteobject( hbrush );
    } else {
        _wpi_deletenullbrush( hbrush );
    }

    if( activeImage->imgtype == BITMAP_IMG ) {
        _wpi_deletecompatiblepres( mempres, memdc );
        return;
    }

    hpen = _wpi_createpen( PS_SOLID, 0, andcolour );
    oldpen = _wpi_selectobject( mempres, hpen );
    oldbitmap = _wpi_selectobject( mempres, activeImage->handbitmap );

    if ( fFillRgn ) {
        hbrush = _wpi_createsolidbrush( andcolour );
    } else {
        hbrush = _wpi_createnullbrush();
    }
    oldbrush = _wpi_selectobject( mempres, hbrush );

    if (is_rect) {
        _wpi_rectangle( mempres, left, top, right, bottom );
    } else {
        _wpi_ellipse( mempres, left, top, right, bottom );
    }
    _wpi_selectobject( mempres, oldpen );
    _wpi_deletepen( hpen );
    _wpi_selectobject( mempres, oldbrush );
    _wpi_selectobject( mempres, oldbitmap );
    if (fFillRgn) {
        _wpi_deleteobject( hbrush );
    } else {
        _wpi_deletenullbrush( hbrush );
    }

    _wpi_deletecompatiblepres( mempres, memdc );
} /* RegionXorAnd */
コード例 #19
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 */
コード例 #20
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 */
コード例 #21
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 );
        }
    }
}