Example #1
0
/*
 * 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 */
Example #2
0
/*
 * 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 */
Example #3
0
/*
 * 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 */
Example #4
0
/*
 * 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 */