Exemple #1
0
/*
 * BlowupImage - Stretches the view window into the window given by hwnd.
 */
void BlowupImage( HWND hmdiwnd, WPI_PRES pres )
{
    HDC         memdc;
    WPI_PRES    mempres;
    WPI_RECT    client;
    HBITMAP     oldbitmap;
    HBITMAP     newbitmap;
    HWND        hwnd;
    img_node    *node;
    BOOL        new_pres;

    if( hmdiwnd ) {
        hwnd = hmdiwnd;
    } else {
        node = GetCurrentNode();
        if( !node ) {
            return;
        }
        hwnd = node->hwnd;
    }

    newbitmap = EnlargeImage( hwnd );
    if (!newbitmap) return;

    new_pres = FALSE;
    if( pres == (WPI_PRES)NULL ) {
        pres = _wpi_getpres( hwnd );
        new_pres = TRUE;
    }
    mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
    oldbitmap = _wpi_selectobject( mempres, newbitmap );

    if (ImgedConfigInfo.grid_on) {
        showGrid( hwnd, mempres );
    } else {
        GetClientRect(hwnd, &client);
        _wpi_bitblt( pres, 0, 0, _wpi_getwidthrect(client),
                        _wpi_getheightrect(client), mempres, 0, 0, SRCCOPY );
        RedrawPrevClip(hwnd);   // Redraws if there was a clip region specified.
    }

    _wpi_selectobject( mempres, oldbitmap );
    _wpi_deletebitmap( newbitmap );
    _wpi_deletecompatiblepres( mempres, memdc );

    if( new_pres ) {
        _wpi_releasepres( hwnd, pres );
    }
} /* BlowupImage */
Exemple #2
0
/*
 * SetCurrentNumColors - set the number of colors for this module
 */
void SetCurrentNumColors( int color_count )
{
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HDC         memdc;
    HBITMAP     oldbitmap;

    numberOfColors = color_count;
    pres = _wpi_getpres( HWND_DESKTOP );
    _wpi_torgbmode( pres );

    if( lButton.bitmap != NULL ) {
        _wpi_deletebitmap( lButton.bitmap );
    }

    if( rButton.bitmap != NULL ) {
        _wpi_deletebitmap( rButton.bitmap );
    }

    if( color_count == 2 ) {
        lButton.bitmap = _wpi_createbitmap( CUR_SQR_SIZE + 1, 2 * CUR_SQR_SIZE + 1,
                                            1, 1, NULL );
        rButton.bitmap = _wpi_createbitmap( CUR_SQR_SIZE + 1, 2 * CUR_SQR_SIZE + 1,
                                            1, 1, NULL );
    //} else if( color_count == 16 ) {
    } else {
        lButton.bitmap = _wpi_createcompatiblebitmap( pres, CUR_SQR_SIZE + 1,
                                                      2 * CUR_SQR_SIZE + 1 );
        rButton.bitmap = _wpi_createcompatiblebitmap( pres, CUR_SQR_SIZE + 1,
                                                      2 * CUR_SQR_SIZE + 1 );

        if( firstTime ) {
            mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
            _wpi_torgbmode( mempres );

            oldbitmap = _wpi_selectobject( mempres, lButton.bitmap );
            _wpi_patblt( mempres, 0, 0, CUR_SQR_SIZE + 1, 2 * CUR_SQR_SIZE + 1, BLACKNESS );
            _wpi_selectobject( mempres, oldbitmap );

            oldbitmap = _wpi_selectobject( mempres, rButton.bitmap );
            _wpi_patblt( mempres, 0, 0, CUR_SQR_SIZE + 1, 2 * CUR_SQR_SIZE + 1, WHITENESS );
            _wpi_selectobject( mempres, oldbitmap );
            _wpi_deletecompatiblepres( mempres, memdc );
            firstTime = false;
        }
    }
    _wpi_releasepres( HWND_DESKTOP, pres );

} /* SetCurrentNumColors */
Exemple #3
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 #4
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 */
Exemple #5
0
/*
 * SetScreenClr - set the color to represent the screen
 */
void SetScreenClr( COLORREF screen_color )
{
    WPI_PRES    pres;

    pres = _wpi_getpres( HWND_DESKTOP );
    _wpi_torgbmode( pres );
    screenColor.color = _wpi_getnearestcolor( pres, screen_color );
    screenColor.solid_color = screenColor.color;
    _wpi_releasepres( HWND_DESKTOP, pres );

    inverseColor.color = GetInverseColor( screenColor.color );
    inverseColor.solid_color = inverseColor.color;

    VerifyCurrentClr( screenColor.color, inverseColor.color );
    _wpi_invalidaterect( hScreenWnd, NULL, FALSE );

} /* SetScreenClr */
Exemple #6
0
/*
 * writeDataInPieces - writes the xor data for the bitmap in chunks
 */
static bool writeDataInPieces( BITMAPINFO2 *bmi, FILE *fp, img_node *node )
{
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HDC         memdc;
    int         scanline_count;
    int         one_scanline_size;
    long        chunk_size;
    int         start;
    int         num_lines;
    long        byte_count;
    BYTE        *buffer;
    HBITMAP     oldbitmap;

    pres = _wpi_getpres( HWND_DESKTOP );
    mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
    _wpi_releasepres( HWND_DESKTOP, pres );
    oldbitmap = _wpi_selectobject( mempres, node->hxorbitmap );

    byte_count = BITS_TO_BYTES( node->bitcount * node->width, node->height );
    start = 0;
    num_lines = SCANLINE_SIZE;
    one_scanline_size = BITS_TO_BYTES( node->width*node->bitcount, 1 );
    scanline_count = node->height;
    chunk_size = one_scanline_size * num_lines;
    while( chunk_size > MAX_CHUNK ) {
        chunk_size >>= 1;
        num_lines = chunk_size / one_scanline_size;
    }

    buffer = calloc( chunk_size, sizeof( BYTE ) );
    while( scanline_count > num_lines ) {
        GpiQueryBitmapBits( mempres, start, num_lines, buffer, bmi );
        fwrite( buffer, sizeof( BYTE ), chunk_size, fp );
        scanline_count -= num_lines;
        start += num_lines;
        byte_count -= chunk_size;
    }
    GpiQueryBitmapBits( mempres, start, scanline_count, buffer, bmi );
    fwrite( buffer, sizeof( BYTE ), one_scanline_size * scanline_count, fp );
    free( buffer );
    _wpi_selectobject( mempres, oldbitmap );
    _wpi_deletecompatiblepres( mempres, memdc );
    return( true );
} /* writeDataInPieces */
Exemple #7
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 #8
0
bool GUIDrawStatusText( gui_window *wnd, const char *text )
{
    WPI_PRES    pres;
    const char  *out_text;

    if( !GUIHasStatus( wnd) ) {
        return( false );
    }
    pres = _wpi_getpres( wnd->status );
    if( ( text == NULL ) || ( *text == '\0' ) ) {
        out_text = LIT( Blank );
    } else {
        out_text = text;
    }
    StatusWndDrawLine( GUIStatusWnd, pres, wnd->font, out_text, DT_SINGLELINE | DT_VCENTER | DT_LEFT );
    _wpi_releasepres( wnd->status, pres );
    if( ( text == NULL ) || ( *text == '\0' ) ) {
        GUIEVENTWND( wnd, GUI_STATUS_CLEARED, NULL );
    }
    return( true );
}
Exemple #9
0
/*
 * displayColors - display the colors
 */
static void displayColors( HWND hwnd )
{
    short       i;
    WPI_PRES    pres;
    HWND        currentwnd;

    inverseColor.color = GetInverseColor( screenColor.color );

    currentwnd = _wpi_getdlgitem( hwnd, BK_CURRENT );

    pres = _wpi_getpres( currentwnd );
    _wpi_torgbmode( pres );
    DisplayColorBox( pres, &screenColor );
    DisplayColorBox( pres, &inverseColor );

    for( i = 0; i < 16; i++ ) {
        DisplayColorBox( pres, &availColor[i] );
    }
    _wpi_releasepres( currentwnd, pres );

} /* displayColors */
Exemple #10
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 #11
0
/*
 * DuplicateBitmap - produces a duplicate of the bitmap
 */
HBITMAP DuplicateBitmap( HBITMAP hbitmap )
{
    HDC         srcdc;
    WPI_PRES    srcpres;
    HDC         destdc;
    WPI_PRES    destpres;
    WPI_PRES    pres;
    int         width;
    int         height;
    int         planes;
    int         bitspixel;
    HBITMAP     newbitmap;
    HBITMAP     oldbitmap;
    HBITMAP     oldnewbitmap;

    _wpi_getbitmapparms( hbitmap, &width, &height, &planes, NULL, &bitspixel );
    pres = _wpi_getpres( HWND_DESKTOP );
    srcpres = _wpi_createcompatiblepres( pres, Instance, &srcdc );
    destpres = _wpi_createcompatiblepres( pres, Instance, &destdc );
    _wpi_releasepres( HWND_DESKTOP, pres );

    newbitmap = _wpi_createbitmap( width, height, planes, bitspixel, NULL );

    oldbitmap = _wpi_selectobject( srcpres, hbitmap );
    oldnewbitmap = _wpi_selectobject( destpres, newbitmap );

    _wpi_bitblt( destpres, 0, 0, width, height, srcpres, 0, 0, SRCCOPY );

    _wpi_selectobject( srcpres, oldbitmap );
    _wpi_selectobject( destpres, oldnewbitmap );

    _wpi_deletecompatiblepres( srcpres, srcdc );
    _wpi_deletecompatiblepres( destpres, destdc );
    return( newbitmap );

} /* DuplicateBitmap */
Exemple #12
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 */
Exemple #13
0
/*
 * copyImageToClipboard - copies the image to the clipboard
 */
static void copyImageToClipboard( short width, short height, img_node *node )
{
    HMENU       hmenu;
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HDC         memdc;
    WPI_PRES    clippres;
    HDC         clipdc;
    HBITMAP     hbitmap;
    HBITMAP     oldbitmap;
    HBITMAP     oldclipbitmap;
    HBITMAP     viewbitmap;
    WPI_RECTDIM left;
    WPI_RECTDIM top;
    WPI_RECTDIM right;
    WPI_RECTDIM bottom;
    int         clip_width, clip_height;

    CleanupClipboard();

    pres = _wpi_getpres( node->viewhwnd );
    mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
    clippres = _wpi_createcompatiblepres( pres, Instance, &clipdc );
    hbitmap = _wpi_createcompatiblebitmap( pres, width, height );

    viewbitmap = CreateViewBitmap( node );

    oldbitmap = _wpi_selectbitmap( mempres, viewbitmap );
    oldclipbitmap = _wpi_selectbitmap( clippres, hbitmap );

    clip_width = _wpi_getwidthrect( clipRect.rect );
    clip_height = _wpi_getheightrect( clipRect.rect );
    /*
     * use getwrectvalues because we want top and left to be our origins
     * (i.e. in PM the origin is the bottom)
     */
    _wpi_getwrectvalues( clipRect.rect, &left, &top, &right, &bottom );

    _wpi_bitblt( clippres, 0, 0, width, height, mempres, left, top, SRCCOPY );
    _wpi_openclipboard( Instance, HMainWindow );
    _wpi_emptyclipboard( Instance );
    _wpi_setclipboarddata( Instance, CF_BITMAP, hbitmap, TRUE );
    _wpi_closeclipboard( Instance );

    _wpi_getoldbitmap( clippres, oldclipbitmap );
    _wpi_deletecompatiblepres( clippres, clipdc );

    clippres = _wpi_createcompatiblepres( pres, Instance, &clipdc );
    hXorClipped = _wpi_createcompatiblebitmap( pres, width, height );

    _wpi_getoldbitmap( mempres, oldbitmap );
    oldbitmap = _wpi_selectbitmap( mempres, node->hxorbitmap );
    oldclipbitmap = _wpi_selectbitmap( clippres, hXorClipped );

    _wpi_bitblt( clippres, 0, 0, width, height, mempres, left, top, SRCCOPY );
    _wpi_getoldbitmap( mempres, oldbitmap );
    _wpi_getoldbitmap( clippres, oldclipbitmap );

    hAndClipped = _wpi_createcompatiblebitmap( pres, width, height );
    oldbitmap = _wpi_selectbitmap( mempres, node->handbitmap );
    oldclipbitmap = _wpi_selectbitmap( clippres, hAndClipped );

    _wpi_bitblt( clippres, 0, 0, width, height, mempres, left, top, SRCCOPY );
    _wpi_getoldbitmap( mempres, oldbitmap );
    _wpi_getoldbitmap( clippres, oldclipbitmap );
    _wpi_deletecompatiblepres( mempres, memdc );
    _wpi_deletecompatiblepres( clippres, clipdc );

    _wpi_deletebitmap( viewbitmap );
    _wpi_releasepres( node->viewhwnd, pres );

    hmenu = GetMenu( _wpi_getframe( HMainWindow ) );
    _wpi_enablemenuitem( hmenu, IMGED_PASTE, TRUE, FALSE );

} /* copyImageToClipboard */
Exemple #14
0
/*
 * CreateViewBitmap - create the bitmap on the screen (with the background
 *                    color as it should be, etc.)
 *                  - the caller is responsible for deleting the bitmap
 */
HBITMAP CreateViewBitmap( img_node *mdi_node )
{
    WPI_PRES    pres;
    WPI_PRES    xorandpres;
    WPI_PRES    mempres;
    WPI_PRES    freehandpres;
    HDC         xoranddc;
    HDC         memdc;
    HBITMAP     newbitmap;
    HBITMAP     oldxorandbitmap;
    HBITMAP     oldbitmap;
    HBRUSH      brush;
    HBRUSH      oldbrush;
    img_node    *node;
    COLORREF    bkcolor;

    if( mdi_node != NULL ) {
        node = mdi_node;
    } else {
        node = GetCurrentNode();
        if( node == NULL ) {
            return( NULL );
        }
    }

    pres = _wpi_getpres( HWND_DESKTOP );
    xorandpres = _wpi_createcompatiblepres( pres, Instance, &xoranddc );
    mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
    newbitmap = _wpi_createcompatiblebitmap( pres, node->width, node->height );
    _wpi_releasepres( HWND_DESKTOP, pres );

    _wpi_torgbmode( mempres );
    _wpi_torgbmode( xorandpres );
    bkcolor = GetViewBkColor();

#ifdef __OS2_PM__
    _wpi_preparemono( mempres, BLACK, bkcolor );
#endif
    oldbitmap = _wpi_selectobject( mempres, newbitmap );

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

    _wpi_patblt( mempres, 0, 0, node->width, node->height, PATCOPY );
    _wpi_selectobject( mempres, oldbrush );
    _wpi_deletebrush( brush );

    GetFreeHandPresentationSpaces( NULL, &freehandpres, NULL );
    if( freehandpres == (WPI_PRES)NULL ) {
        oldxorandbitmap = _wpi_selectobject( xorandpres, node->handbitmap );
        _wpi_bitblt( mempres, 0, 0, node->width, node->height,
                     xorandpres, 0, 0, SRCAND );
        _wpi_selectobject( xorandpres, oldxorandbitmap );
    } else {
        _wpi_bitblt( mempres, 0, 0, node->width, node->height,
                     freehandpres, 0, 0, SRCAND );
    }

    GetFreeHandPresentationSpaces( NULL, NULL, &freehandpres );
    if( freehandpres == (WPI_PRES)NULL ) {
        oldxorandbitmap = _wpi_selectobject( xorandpres, node->hxorbitmap );
        _wpi_bitblt( mempres, 0, 0, node->width, node->height,
                     xorandpres, 0, 0, SRCINVERT );
        _wpi_selectobject( xorandpres, oldxorandbitmap );
    } else {
        _wpi_bitblt( mempres, 0, 0, node->width, node->height,
                     freehandpres, 0, 0, SRCINVERT );
    }

    _wpi_deletecompatiblepres( xorandpres, xoranddc );
    _wpi_selectobject( mempres, oldbitmap );
    _wpi_deletecompatiblepres( mempres, memdc );

    return( newbitmap );

} /* CreateViewBitmap */
Exemple #15
0
/*
 * EnlargeImage - take an MDI window handle and enlarge the view bitmap
 *                that goes with it
 *              - returns a handle to the bitmap
 *              - the bitmap must be deleted by the calling routine
 */
HBITMAP EnlargeImage( HWND hwnd )
{
    WPI_PRES    pres;
    WPI_PRES    srcpres;
    WPI_PRES    destpres;
    HDC         srcdc;
    HDC         destdc;
    HBITMAP     oldbitmap;
    HBITMAP     newbitmap;
    HBITMAP     olddestbitmap;
    HBITMAP     viewbitmap;
    img_node    *node;
    WPI_RECT    rc;
    short       width;
    short       height;
    int         window_width;
    int         window_height;
    BITMAP      bm;

    node = SelectImage( hwnd );
    if( node == NULL ) {
        return( NULL );
    }

    viewbitmap = CreateViewBitmap( node );
    _wpi_getclientrect( hwnd, &rc );
    /*
     * I add this so that if the window's client rect doesn't fit on the
     * screen, it will still enlarge to the right size.
     */
    window_width = _wpi_getwidthrect( rc );
    window_height = _wpi_getheightrect( rc );
    if( window_width < node->width ) {
        window_width = node->width;
    }
    if( window_height < node->height ) {
        window_height = node->height;
    }

    pres = _wpi_getpres( HWND_DESKTOP );
    srcpres = _wpi_createcompatiblepres( pres, Instance, &srcdc );
    destpres = _wpi_createcompatiblepres( pres, Instance, &destdc );
    newbitmap = _wpi_createcompatiblebitmap( pres, _wpi_getwidthrect( rc ),
                                                   _wpi_getheightrect( rc ) );
    _wpi_releasepres( HWND_DESKTOP, pres );
    GetObject( newbitmap, sizeof( BITMAP ), &bm );

    _wpi_torgbmode( destpres );
    _wpi_torgbmode( srcpres );
    olddestbitmap = _wpi_selectobject( destpres, newbitmap );
    oldbitmap = _wpi_selectobject( srcpres, viewbitmap );
    height = node->height;
    width = node->width;

    IEStretchBlt( destpres, 0, 0, _wpi_getwidthrect( rc ),
                  _wpi_getheightrect( rc ), srcpres, 0, 0, width, height,
                  SRCCOPY, bm.bmBitsPixel );

    _wpi_selectobject( srcpres, oldbitmap );
    _wpi_deletecompatiblepres( srcpres, srcdc );
    _wpi_deleteobject( viewbitmap );

    _wpi_selectobject( destpres, olddestbitmap );
    _wpi_deletecompatiblepres( destpres, destdc );

    return( newbitmap );

} /* EnlargeImage */
Exemple #16
0
/*
 * simpleRotate - simply rotate the image around the center of the given rectangle
 */
static void simpleRotate( img_node *node, WPI_RECT *rect, HBITMAP rotxorbmp,
                          HBITMAP rotandbmp, BOOL rectexists )
{
    WPI_POINT   topleft;
    WPI_POINT   centre_pt;
    WPI_PRES    pres;
    HDC         xordc;
    WPI_PRES    xorpres;
    HDC         anddc;
    WPI_PRES    andpres;
    HDC         rotxordc;
    WPI_PRES    rotxorpres;
    HDC         rotanddc;
    WPI_PRES    rotandpres;
    HBITMAP     oldxor;
    HBITMAP     oldand;
    HBITMAP     oldxorrot;
    HBITMAP     oldandrot;
    short       width;
    short       height;
    WPI_RECT    new_rect;
    IMGED_DIM   left;
    IMGED_DIM   top;
    IMGED_DIM   right;
    IMGED_DIM   bottom;

    width = (short)_wpi_getwidthrect( *rect );
    height = (short)_wpi_getheightrect( *rect );

    /*
     * PM NOTE:  The rectangle comes in with bottom = yTop and top = yBottom.
     * To use the same formula to calculate the center point and top left, we
     * use getwrectvalues.
     */
    _wpi_getwrectvalues( *rect, &left, &top, &right, &bottom );
    centre_pt.x = (width / 2) + left;
    centre_pt.y = (height / 2) + top;
    topleft.x = centre_pt.x - centre_pt.y + top;
    topleft.y = centre_pt.y - centre_pt.x + left;

    pres = _wpi_getpres( HWND_DESKTOP );
    xorpres = _wpi_createcompatiblepres( pres, Instance, &xordc );
    andpres = _wpi_createcompatiblepres( pres, Instance, &anddc );
    rotxorpres = _wpi_createcompatiblepres( pres, Instance, &rotxordc );
    rotandpres = _wpi_createcompatiblepres( pres, Instance, &rotanddc );
    _wpi_releasepres( HWND_DESKTOP, pres );

    _wpi_torgbmode( xorpres );
    _wpi_torgbmode( andpres );
    _wpi_torgbmode( rotxorpres );
    _wpi_torgbmode( rotandpres );

    oldxor = _wpi_selectobject( xorpres, node->hxorbitmap );
    oldand = _wpi_selectobject( andpres, node->handbitmap );
    oldxorrot = _wpi_selectobject( rotxorpres, rotxorbmp );
    oldandrot = _wpi_selectobject( rotandpres, rotandbmp );

    _wpi_getwrectvalues( *rect, &left, &top, &right, &bottom );
    _wpi_patblt( xorpres, left, top, width, height, WHITENESS );
    _wpi_patblt( andpres, left, top, width, height, BLACKNESS );

    _wpi_bitblt( xorpres, topleft.x, topleft.y, height, width, rotxorpres, 0, 0, SRCCOPY );
    _wpi_bitblt( andpres, topleft.x, topleft.y, height, width, rotandpres, 0, 0, SRCCOPY );

    _wpi_selectobject( xorpres, oldxor );
    _wpi_selectobject( andpres, oldand );
    _wpi_selectobject( rotxorpres, oldxorrot );
    _wpi_selectobject( rotandpres, oldandrot );
    _wpi_deletecompatiblepres( xorpres, xordc );
    _wpi_deletecompatiblepres( andpres, anddc );
    _wpi_deletecompatiblepres( rotxorpres, rotxordc );
    _wpi_deletecompatiblepres( rotandpres, rotanddc );

    InvalidateRect( node->viewhwnd, NULL, TRUE );
    RecordImage( node->hwnd );
    if( DoKeepRect() ) {
        if( rectexists ) {
            _wpi_setwrectvalues( &new_rect, topleft.x, topleft.y,
                                 topleft.x+height, topleft.y + width );
            SetDeviceClipRect( &new_rect );
        }
    } else {
        rectexists = rectexists;
        new_rect = new_rect;
        SetRectExists( FALSE );
    }

    BlowupImage( node->hwnd, NULL );

} /* simpleRotate */
Exemple #17
0
/*
 * OutlineClip - displays the potential region to be clipped to the clip board
 */
void OutlineClip( HWND hwnd, WPI_POINT *start_pt, WPI_POINT *end_pt,
                                        WPI_POINT *prev_pt, BOOL firsttime )
{
    WPI_RECT    newpos;
    WPI_RECT    oldpos;
    short       temp;
    WPI_PRES    pres;
    IMGED_DIM   left;
    IMGED_DIM   top;
    IMGED_DIM   right;
    IMGED_DIM   bottom;

    CheckBounds( hwnd, start_pt );
    CheckBounds( hwnd, end_pt );
    CheckBounds( hwnd, prev_pt );
    left = (IMGED_DIM)MAKELOGPTX(start_pt->x);
    top = (IMGED_DIM)MAKELOGPTY(start_pt->y);
    right = (IMGED_DIM)MAKELOGPTX(end_pt->x);
    bottom = (IMGED_DIM)MAKELOGPTY(end_pt->y);

    if (left > right) {
        temp = right;
        right = left + pointSize.x;
        left = temp;
    } else {
        right += pointSize.x;
    }
    if (top > bottom) {
        temp = bottom;
        bottom = top + pointSize.y;
        top = temp;
    } else {
        bottom += pointSize.y;
    }
    _wpi_setrectvalues( &newpos, left, top, right, bottom );

    left = (IMGED_DIM)MAKELOGPTX( start_pt->x );
    top = (IMGED_DIM)MAKELOGPTY( start_pt->y );
    right = (IMGED_DIM)MAKELOGPTX( prev_pt->x );
    bottom = (IMGED_DIM)MAKELOGPTY( prev_pt->y );

    if (left > right) {
        temp = right;
        right = left + pointSize.x;
        left = temp;
    } else {
        right += pointSize.x;
    }
    if (top > bottom) {
        temp = bottom;
        bottom = top + pointSize.y;
        top = temp;
    } else {
        bottom += pointSize.y;
    }
    _wpi_setrectvalues( &oldpos, left, top, right, bottom );

    pres = _wpi_getpres( hwnd );
    OutlineRectangle( firsttime, pres, &oldpos, &newpos );
    _wpi_releasepres( hwnd, pres );
} /* OutlineClip */
Exemple #18
0
/*
 * InitStatusLine - initializes the status line ...
 */
BOOL InitStatusLine( HWND parent )
{
    WPI_RECT            client;
    WPI_RECT            rcsize;
    status_block_desc   sbd[4];
    WPI_PRES            pres;
    char                *text;
    char                next_block[3];
    int                 len;

    CreateStatusFont();

    sprintf( leftBlock, "%c%c", STATUS_ESC_CHAR, STATUS_FORMAT_LEFT );
    sprintf( next_block, "%c%c", STATUS_ESC_CHAR, STATUS_NEXT_BLOCK );
    strcpy( nextBlock, next_block );
    strcat( nextBlock, leftBlock );

    strcpy( hotspotPosition, next_block );
    strcat( hotspotPosition, next_block );
    strcat( hotspotPosition, leftBlock );

    PosText = IEAllocRCString( WIE_STATUSPOSTEXT );
    SizeText = IEAllocRCString( WIE_STATUSSIZETEXT );
    SetPosText = IEAllocRCString( WIE_STATUSPOSINFO );

    if( SetPosText != NULL ) {
        PositionText = (char *)MemAlloc( strlen( leftBlock ) +
                                         strlen( SetPosText ) + 20 + 1 );
        text = IEAllocRCString( WIE_STATUSSIZEINFO );
        if( text != NULL ) {
            SetSizeText = (char *)MemAlloc( strlen( SetPosText ) + strlen( text ) + 1 );
            if( SetSizeText != NULL ) {
                strcpy( SetSizeText, SetPosText );
                strcat( SetSizeText, text );
                PositionSizeText = (char *)MemAlloc( strlen( leftBlock ) +
                    strlen( SetSizeText ) + strlen( nextBlock ) + 40 + 1 );
            }
            IEFreeRCString( text );
        }
    }

    SetHotSpotText = IEAllocRCString( WIE_STATUSHOTSPOTINFO );
    if( SetHotSpotText != NULL ) {
        HotSpotText = (char *)MemAlloc( strlen( hotspotPosition ) +
                                        strlen( SetHotSpotText ) + 20 + 1 );
    }

    SetBitmapText = IEAllocRCString( WIE_BITMAPIMAGETEXT );
    SetCursorText = IEAllocRCString( WIE_CURSORIMAGETEXT );
    SetIconText = IEAllocRCString( WIE_ICONIMAGETEXT );
    if( SetBitmapText != NULL && SetCursorText != NULL && SetIconText != NULL ) {
        len = max( strlen( SetBitmapText ), strlen( SetCursorText ) );
        len = max( len, strlen( SetIconText ) );
        len += strlen( imgSizePosition ) + 30 + 1;
        ImageText = (char *)MemAlloc( len );
    }

    StatusWndInit( Instance, (statushook)NULL, sizeof( LPVOID ), NULL );
    statusBar = StatusWndStart();

    GetClientRect( parent, &client );

#ifdef __OS2_PM__
    rcsize.xLeft = -1;
    rcsize.xRight = client.xRight + 1;
    rcsize.yBottom = -1;
    rcsize.yTop = INIT_STATUS_WIDTH - 1;
#else
    rcsize.left = -1;
    rcsize.right = client.right + 1;
    rcsize.bottom = client.bottom + 1;
    rcsize.top = client.bottom - INIT_STATUS_WIDTH + 1;
#endif

    sbd[0].separator_width = 5;
    sbd[0].width = 82;
    sbd[0].width_is_percent = 0;
    sbd[0].width_is_pixels = 1;

    sbd[1].separator_width = 5;
    sbd[1].width = 168;
    sbd[1].width_is_percent = 0;
    sbd[1].width_is_pixels = 1;

    sbd[2].separator_width = 5;
    sbd[2].width = 255;
    sbd[2].width_is_percent = 0;
    sbd[2].width_is_pixels = 1;

    sbd[3].separator_width = 5;
    sbd[3].width = 400;
    sbd[3].width_is_percent = 0;
    sbd[3].width_is_pixels = 1;

    StatusWndSetSeparators( statusBar, 4, &sbd );

    strcpy( imgSizePosition, next_block );
    strcat( imgSizePosition, next_block );
    strcat( imgSizePosition, next_block );
    strcat( imgSizePosition, leftBlock );

    strcpy( hintTextPosition, next_block );
    strcat( hintTextPosition, next_block );
    strcat( hintTextPosition, next_block );
    strcat( hintTextPosition, next_block );
    strcat( hintTextPosition, leftBlock );

    statusBarWnd = StatusWndCreate( statusBar, parent, &rcsize, Instance, (LPVOID)NULL );

    text = NULL;
    if( PosText != NULL && SizeText != NULL ) {
        text = (char *)MemAlloc( strlen( PosText ) + strlen( SizeText ) +
                                 strlen( leftBlock ) + strlen( nextBlock ) + 1 );
    }

    if( text != NULL ) {
        sprintf( text, "%s%s%s%s", leftBlock, PosText, nextBlock, SizeText );
        pres = _wpi_getpres( statusBarWnd );
        StatusWndDrawLine( statusBar, pres, SmallFont, text, -1 );
        _wpi_releasepres( statusBarWnd, pres );
        MemFree( text );
    }

    GetWindowRect( statusBarWnd, &rcsize );
    StatusWidth = rcsize.bottom - rcsize.top;

    return( TRUE );

} /* InitStatusLine */
Exemple #19
0
/*
 * clipIntoArea - clip the bitmaps into the area when rotating
 */
static void clipIntoArea( img_node *node, WPI_RECT *rect,
                          HBITMAP rotxorbmp, HBITMAP rotandbmp )
{
    WPI_PRES    pres;
    WPI_PRES    xorpres;
    HDC         xordc;
    WPI_PRES    andpres;
    HDC         anddc;
    WPI_PRES    rotxorpres;
    HDC         rotxordc;
    WPI_PRES    rotandpres;
    HDC         rotanddc;
    HBITMAP     oldxor;
    HBITMAP     oldand;
    HBITMAP     oldxorrot;
    HBITMAP     oldandrot;
    short       width;
    short       height;
    WPI_POINT   centre_pt;
    WPI_POINT   topleft;
    short       start_x;
    short       start_y;
    short       new_width;
    short       new_height;
    IMGED_DIM   left;
    IMGED_DIM   right;
    IMGED_DIM   top;
    IMGED_DIM   bottom;

    width = (short)_wpi_getwidthrect( *rect );
    height = (short)_wpi_getheightrect( *rect );

    /*
     * PM NOTE:  We use getwrectvalues so that 'topleft' can really be
     * replace with 'bottomleft' (which is our origin for blitting in PM).
     * Hence the value of 'top' is really the bottom of our rectangle.
     */
    _wpi_getwrectvalues( *rect, &left, &top, &right, &bottom );
    centre_pt.x = (width / 2) + left;
    centre_pt.y = (height / 2) + top;

    topleft.x = __max( left, centre_pt.x - centre_pt.y + top );
    topleft.y = __max( top, centre_pt.y - centre_pt.x + left );

    if( topleft.x == left ) {
        start_x = (short)(left - (centre_pt.x - centre_pt.y + top));
        new_width = width;
    } else {
        start_x = 0;
        new_width = height;
    }
    if( topleft.y == top ) {
        start_y = (short)(top - (centre_pt.y - centre_pt.x + left));
        new_height = height;
    } else {
        start_y = 0;
        new_height = width;
    }

    pres = _wpi_getpres( HWND_DESKTOP );
    xorpres = _wpi_createcompatiblepres( pres, Instance, &xordc );
    andpres = _wpi_createcompatiblepres( pres, Instance, &anddc );
    rotxorpres = _wpi_createcompatiblepres( pres, Instance, &rotxordc );
    rotandpres = _wpi_createcompatiblepres( pres, Instance, &rotanddc );
    _wpi_releasepres( HWND_DESKTOP, pres );

    _wpi_torgbmode( xorpres );
    _wpi_torgbmode( andpres );
    _wpi_torgbmode( rotxorpres );
    _wpi_torgbmode( rotandpres );

    oldxor = _wpi_selectobject( xorpres, node->hxorbitmap );
    oldand = _wpi_selectobject( andpres, node->handbitmap );
    oldxorrot = _wpi_selectobject( rotxorpres, rotxorbmp );
    oldandrot = _wpi_selectobject( rotandpres, rotandbmp );

    _wpi_patblt( xorpres, left, top, width, height, WHITENESS );
    _wpi_patblt( andpres, left, top, width, height, BLACKNESS );

    _wpi_bitblt( xorpres, topleft.x, topleft.y, new_width, new_height,
                 rotxorpres, start_x, start_y, SRCCOPY );
    _wpi_bitblt( andpres, topleft.x, topleft.y, new_width, new_height,
                 rotandpres, start_x, start_y, SRCCOPY );

    _wpi_selectobject( xorpres, oldxor );
    _wpi_selectobject( andpres, oldand );
    _wpi_selectobject( rotxorpres, oldxorrot );
    _wpi_selectobject( rotandpres, oldandrot );
    _wpi_deletecompatiblepres( xorpres, xordc );
    _wpi_deletecompatiblepres( andpres, anddc );
    _wpi_deletecompatiblepres( rotxorpres, rotxordc );
    _wpi_deletecompatiblepres( rotandpres, rotanddc );

    InvalidateRect( node->viewhwnd, NULL, TRUE );
    RecordImage( node->hwnd );
    BlowupImage( node->hwnd, NULL );

} /* clipIntoArea */
Exemple #20
0
/*
 * ShiftImage - shift the image in the given direction
 */
void ShiftImage( WORD shiftdirection )
{
    HBITMAP     dup_and;
    HBITMAP     dup_xor;
    HBITMAP     oldbitmap;
    HBITMAP     oldsrcbitmap;
    WPI_PRES    pres;
    HDC         memdc;
    WPI_PRES    mempres;
    HDC         srcdc;
    WPI_PRES    srcpres;
    short       x_src;
    short       y_src;
    short       x_dest;
    short       y_dest;
    short       width;
    short       height;
    short       min_width;
    short       min_height;
    short       rgn_width;
    short       rgn_height;
    img_node    *node;
    WPI_RECT    rect;
    IMGED_DIM   left;
    IMGED_DIM   right;
    IMGED_DIM   top;
    IMGED_DIM   bottom;
    DWORD       message;

    node = GetCurrentNode();
    if( node == NULL ) {
        return;
    }

    dup_and = DuplicateBitmap( node->handbitmap );
    dup_xor = DuplicateBitmap( node->hxorbitmap );

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

    _wpi_torgbmode( mempres );
    _wpi_torgbmode( srcpres );

    if( DoesRectExist( &rect ) ) {
        width = (short)_wpi_getwidthrect( rect );
        height = (short)_wpi_getheightrect( rect );
    } else {
        _wpi_setwrectvalues( &rect, 0, 0, node->width, node->height );
        width = node->width;
        height = node->height;
    }

    _wpi_getwrectvalues( rect, &left, &top, &right, &bottom );

    oldbitmap = _wpi_selectobject( mempres, node->handbitmap );
    _wpi_patblt( mempres, left, top, width, height, BLACKNESS );
    _wpi_selectobject( mempres, oldbitmap );
    oldbitmap = _wpi_selectobject( mempres, node->hxorbitmap );
    _wpi_patblt( mempres, left, top, width, height, WHITENESS );

    oldsrcbitmap = _wpi_selectobject( srcpres, dup_xor );

    x_src = (short)left;
    y_src = (short)top;
    x_dest =(short)left;
    y_dest = (short)top;
    min_width = (short)min( ImgedConfigInfo.shift, width );
    min_height = (short)min( ImgedConfigInfo.shift, height );
    rgn_width = width;
    rgn_height = height;

    switch( shiftdirection ) {
    case IMGED_LEFT:
        width -= min_width;
        x_src = x_src + min_width;
        message = WIE_IMAGESHIFTEDLEFT;
        break;

    case IMGED_RIGHT:
        width -= min_width;
        x_dest = x_dest + min_width;
        message = WIE_IMAGESHIFTEDRIGHT;
        break;

    case IMGED_UP:
#ifndef __OS2_PM__
        height -= min_height;
        y_src = y_src + min_height;
#else
        height += min_height;
        y_src = y_src - min_height;
#endif
        message = WIE_IMAGESHIFTEDUP;
        break;

    case IMGED_DOWN:
#ifndef __OS2_PM__
        height -= min_height;
        y_dest = y_dest + min_height;
#else
        height += min_height;
        y_dest = y_dest - min_height;
#endif
        message = WIE_IMAGESHIFTEDDOWN;
        break;

    default:
        break;
    }

    _wpi_bitblt( mempres, x_dest, y_dest, width, height, srcpres, x_src, y_src, SRCCOPY );
    _wpi_selectobject( srcpres, oldsrcbitmap );
    oldsrcbitmap = _wpi_selectobject( srcpres, dup_and );
    _wpi_selectobject( mempres, oldbitmap );
    oldbitmap = _wpi_selectobject( mempres, node->handbitmap );
    _wpi_bitblt( mempres, x_dest, y_dest, width, height, srcpres, x_src, y_src, SRCCOPY );

    if( IsShiftWrap() ) {
        switch( shiftdirection ) {
        case IMGED_LEFT:
            width = min_width;
            x_src = (short)left;
            x_dest = (short)(right - width);
            break;

        case IMGED_RIGHT:
            width = min_width;
            x_dest = (short)left;
            x_src = (short)(right - width);
            break;

        case SHIFT_UP:
            height = min_height;
            y_src = (short)top;
            y_dest = (short)(bottom - height);
            break;

        case SHIFT_DOWN:
            height = min_height;
            y_dest = (short)top;
            y_src = (short)(bottom - height);
            break;

        default:
            break;
        }

        _wpi_bitblt( mempres, x_dest, y_dest, width, height, srcpres,
                     x_src, y_src, SRCCOPY );
        _wpi_selectobject( srcpres, oldsrcbitmap );
        _wpi_selectobject( mempres, oldbitmap );
        oldsrcbitmap = _wpi_selectobject( srcpres, dup_xor );
        oldbitmap = _wpi_selectobject( mempres, node->hxorbitmap );
        _wpi_bitblt( mempres, x_dest, y_dest, width, height, srcpres,
                     x_src, y_src, SRCCOPY );
    }
    _wpi_selectobject( srcpres, oldsrcbitmap );
    _wpi_selectobject( mempres, oldbitmap );
    _wpi_deletecompatiblepres( srcpres, srcdc );
    _wpi_deletecompatiblepres( mempres, memdc );

    _wpi_deleteobject( dup_xor );
    _wpi_deleteobject( dup_and );

    RecordImage( node->hwnd );
    BlowupImage( node->hwnd, NULL );
    InvalidateRect( node->viewhwnd, NULL, FALSE );

    IEPrintAmtText( message, ImgedConfigInfo.shift );

} /* ShiftImage */
Exemple #21
0
/*
 * RotateImage - rotate the image either clockwise or counterclockwise
 */
void RotateImage( WORD whichway )
{
    img_node    *node;
    HBITMAP     rotxorbmp;
    HBITMAP     rotandbmp;
    HCURSOR     prevcursor;
    int         rotate_type;
    WPI_RECT    rotate_rect;
    BOOL        rectexists;
    short       new_width;
    short       new_height;
    WPI_PRES    pres;

    node = GetCurrentNode();
    if( node == NULL ) {
        return;
    }

    prevcursor = _wpi_setcursor( _wpi_getsyscursor( IDC_WAIT ) );

    PrintHintTextByID( WIE_ROTATINGIMAGE, NULL );

    if( DoesRectExist( &rotate_rect ) ) {
        rectexists = TRUE;
        new_width = (short)_wpi_getheightrect( rotate_rect );
        new_height = (short)_wpi_getwidthrect( rotate_rect );
    } else {
        rectexists = FALSE;
        _wpi_setwrectvalues( &rotate_rect, 0, 0,
                             (IMGED_DIM)node->width, (IMGED_DIM)node->height );
        new_width = node->height;
        new_height = node->width;
    }

    if( node->bitcount == 1 ) {
        rotxorbmp = _wpi_createbitmap( new_width, new_height, 1, 1, NULL );
    } else {
#if 1
        pres = _wpi_getpres( HWND_DESKTOP );
        rotxorbmp = _wpi_createcompatiblebitmap( pres, new_width, new_height );
        _wpi_releasepres( HWND_DESKTOP, pres );
#else
        rotxorbmp = _wpi_createbitmap( new_width, new_height, ColorPlanes,
                                       BitsPerPixel, NULL );
#endif
    }
    rotandbmp = _wpi_createbitmap( new_width, new_height, 1, 1, NULL );

    rotateTheImage( node, whichway, &rotate_rect, rotxorbmp, rotandbmp );

    rotate_type = GetRotateType();
    if( rotate_type == SIMPLE_ROTATE ) {
        simpleRotate( node, &rotate_rect, rotxorbmp, rotandbmp, rectexists );
    } else if( rotate_type == CLIP_ROTATE ) {
        clipIntoArea( node, &rotate_rect, rotxorbmp, rotandbmp );
    } else {
        stretchIntoArea( node, &rotate_rect, rotxorbmp, rotandbmp );
    }

    _wpi_deleteobject( rotxorbmp );
    _wpi_deleteobject( rotandbmp );

    if( whichway == IMGED_ROTATECC ) {
        PrintHintTextByID( WIE_IMAGEROTATEDCCW, NULL );
    } else {
        PrintHintTextByID( WIE_IMAGEROTATEDCW, NULL );
    }
    _wpi_setcursor( prevcursor );

} /* RotateImage */
Exemple #22
0
/*
 * rotateTheImage - create the rotated bitmaps
 */
static void rotateTheImage( img_node *node, int whichway, WPI_RECT *rect,
                            HBITMAP rotxorbmp, HBITMAP rotandbmp )
{
    WPI_PRES    pres;
    WPI_PRES    rotxorpres;
    HDC         rotxordc;
    WPI_PRES    xorpres;
    HDC         xordc;
    WPI_PRES    rotandpres;
    HDC         rotanddc;
    HBITMAP     oldandrot;
    HBITMAP     oldxorrot;
    HBITMAP     oldxor;
    short       new_height;
    short       new_width;
    long        i;
    long        amt_done;
    long        prev_amt;
    long        total_amt;
    long        temp;
    IMGED_DIM   left;
    IMGED_DIM   top;
    IMGED_DIM   right;
    IMGED_DIM   bottom;
    int         x;
    int         y;
    COLORREF    color;
    bitmap_bits *xorbits;
    bitmap_bits *andbits;
    bitmap_bits *rotxorbits;
    bitmap_bits *rotandbits;

    new_height = (short)_wpi_getwidthrect( *rect );
    new_width = (short)_wpi_getheightrect( *rect );
    oldxor = NULL;

    amt_done = prev_amt = 0L;
    total_amt = (long)new_height * (long)new_width;
    i = 0L;
    _wpi_getwrectvalues( *rect, &left, &top, &right, &bottom );

    if( node->imgtype == BITMAP_IMG ) {
        pres = _wpi_getpres( HWND_DESKTOP );
        xorpres = _wpi_createcompatiblepres( pres, Instance, &xordc );
        rotxorpres = _wpi_createcompatiblepres( pres, Instance, &rotxordc );
        rotandpres = _wpi_createcompatiblepres( pres, Instance, &rotanddc );
        _wpi_releasepres( HWND_DESKTOP, pres );

        _wpi_torgbmode( rotxorpres );
        _wpi_torgbmode( rotandpres );
        oldxorrot = _wpi_selectobject( rotxorpres, rotxorbmp );
        oldandrot = _wpi_selectobject( rotandpres, rotandbmp );

        _wpi_patblt( rotxorpres, 0, 0, new_width, new_height, WHITENESS );
        _wpi_patblt( rotandpres, 0, 0, new_width, new_height, BLACKNESS );
        _wpi_selectobject( rotxorpres, oldxorrot );
        _wpi_selectobject( rotandpres, oldandrot );
        _wpi_deletecompatiblepres( rotandpres, rotanddc );

        _imged_getthebits( xorbits, xorpres, node->hxorbitmap, oldxor );
        _imged_getthebits( rotxorbits, rotxorpres, rotxorbmp, oldxorrot );
        if( whichway == ROTATE_COUNTERCLOCKWISE ) {
            for( y = 0; y < new_height; y++ ) {
                for( x = 0; x < new_width; x++ ) {
                    color = _imged_getpixel( xorbits, xorpres, right - y - 1, top + x );
                    _imged_setpixel( rotxorbits, rotxorpres, x, y, color );

                    i++;
                    temp = i * 100;
                    amt_done = temp / total_amt;
                    if( amt_done - prev_amt >= 2 ) {
                        IEPrintRotateAmt( amt_done );
                        prev_amt = amt_done;
                    }
                }
            }
        } else {
            for( y = 0; y < new_height; y++ ) {
                for( x = 0; x < new_width; x++ ) {
                    color = _imged_getpixel( xorbits, xorpres, left + y, bottom - x - 1 );
                    _imged_setpixel( rotxorbits, rotxorpres, x, y, color );
                    i++;
                    temp = i * 100;
                    amt_done = temp / total_amt;
                    if( amt_done - prev_amt >= 2 ) {
                        IEPrintRotateAmt( amt_done );
                        prev_amt = amt_done;
                    }
                }
            }
        }
        _imged_freethebits( xorbits, xorpres, node->hxorbitmap, FALSE, oldxor );
        _imged_freethebits( rotxorbits, rotxorpres, rotxorbmp, TRUE, oldxorrot );
        _wpi_deletecompatiblepres( xorpres, xordc );
        _wpi_deletecompatiblepres( rotxorpres, rotxordc );

    } else {
        // We can use the bits.c routines for icons and cursors.
        xorbits = GetTheBits( node->hxorbitmap );
        andbits = GetTheBits( node->handbitmap );
        rotxorbits = GetTheBits( rotxorbmp );
        rotandbits = GetTheBits( rotandbmp );

        if( whichway != IMGED_ROTATECC ) {
            for( y = 0; y < new_height; y++ ) {
                for( x = 0; x < new_width; x++ ) {
                    color = MyGetPixel( xorbits, right - y - 1, top + x );
                    MySetPixel( rotxorbits, x, y, color );

                    color = MyGetPixel( andbits, right - y - 1, top + x );
                    MySetPixel( rotandbits, x, y, color );
                    i++;
                    temp = i * 100;
                    amt_done = temp / total_amt;
                    if( amt_done - prev_amt >= 2 ) {
                        IEPrintRotateAmt( amt_done );
                        prev_amt = amt_done;
                    }
                }
            }
        } else {
            for( y = 0; y < new_height; y++ ) {
                for( x = 0; x < new_width; x++ ) {
                    color = MyGetPixel( xorbits, left + y, bottom - x - 1 );
                    MySetPixel( rotxorbits, x, y, color );

                    color = MyGetPixel( andbits, left + y, bottom - x - 1 );
                    MySetPixel( rotandbits, x, y, color );
                    i++;
                    temp = i * 100;
                    amt_done = temp / total_amt;
                    if( amt_done - prev_amt >= 2 ) {
                        IEPrintRotateAmt( amt_done );
                        prev_amt = amt_done;
                    }
                }
            }
        }
        FreeTheBits( xorbits, node->hxorbitmap, FALSE );
        FreeTheBits( andbits, node->handbitmap, FALSE );
        FreeTheBits( rotxorbits, rotxorbmp, TRUE );
        FreeTheBits( rotandbits, rotandbmp, TRUE );
    }

} /* rotateTheImage */
Exemple #23
0
/*
 * FlipImage - flip the image along either the x-axis or the y-axis
 */
void FlipImage( WORD whichway )
{
    img_node    *node;
    short       width;
    short       height;
    short       destwidth;
    short       destheight;
    short       new_left;
    short       new_top;
    WPI_RECT    dims;
    HBITMAP     xorflip;
    HBITMAP     oldflip;
    HBITMAP     oldbitmap;
    HBITMAP     andflip;
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HDC         memdc;
    WPI_PRES    flippres;
    HDC         flipdc;
    HCURSOR     prevcursor;
    IMGED_DIM   bottom;
    IMGED_DIM   left;
    IMGED_DIM   right;
    IMGED_DIM   top;

    node = GetCurrentNode();
    if( node == NULL ) {
        return;
    }

    PrintHintTextByID( WIE_FLIPPINGIMAGE, NULL );
    prevcursor = _wpi_setcursor( _wpi_getsyscursor( IDC_WAIT ) );

    if( !DoesRectExist( &dims ) ) {
        _wpi_setwrectvalues( &dims, 0, 0, (IMGED_DIM)node->width, (IMGED_DIM)node->height );
    }
    width = (short)_wpi_getwidthrect( dims );
    height = (short)_wpi_getheightrect( dims );

    pres = _wpi_getpres( HWND_DESKTOP );
    if( node->bitcount == 1 ) {
        xorflip = _wpi_createbitmap( width, height, 1, 1, NULL );
    } else {
#if 1
        xorflip = _wpi_createcompatiblebitmap( pres, width, height );
#else
        xorflip = _wpi_createbitmap( width, height, ColorPlanes, BitsPerPixel, NULL );
#endif
    }
    andflip = _wpi_createbitmap( width, height, 1, 1, NULL );

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

    _wpi_getrectvalues( dims, &left, &top, &right, &bottom );
    _wpi_preparemono( flippres, BLACK, WHITE );

    oldbitmap = _wpi_selectobject( mempres, node->hxorbitmap );
    oldflip = _wpi_selectobject( flippres, xorflip );
    _wpi_bitblt( flippres, 0, 0, width, height, mempres, left, top, SRCCOPY );
    _wpi_selectobject( mempres, oldbitmap );
    _wpi_selectobject( flippres, oldflip );

    oldbitmap = _wpi_selectobject( mempres, node->handbitmap );
    oldflip = _wpi_selectobject( flippres, andflip );
    _wpi_bitblt( flippres, 0, 0, width, height, mempres, left, top, SRCCOPY );

    if( whichway == IMGED_FLIPVERT ) {
        destwidth = -1 * width;
        new_left = right - 1;
        new_top = top;
        destheight = height;
    } else {
        destwidth = width;
        new_left = left;
        new_top = bottom - 1;
        destheight = -1 * height;
    }

    _wpi_stretchblt( mempres, new_left, new_top, destwidth, destheight,
                     flippres, 0, 0, width, height, SRCCOPY );
    _wpi_selectobject( mempres, oldbitmap );
    oldbitmap = _wpi_selectobject( mempres, node->hxorbitmap );
    _wpi_selectobject( flippres, oldflip );
    oldflip = _wpi_selectobject( flippres, xorflip );
    _wpi_stretchblt( mempres, new_left, new_top, destwidth, destheight,
                     flippres, 0, 0, width, height, SRCCOPY );
    _wpi_selectobject( mempres, oldbitmap );
    _wpi_selectobject( flippres, oldflip );

    _wpi_deleteobject( xorflip );
    _wpi_deleteobject( andflip );
    _wpi_deletecompatiblepres( mempres, memdc );
    _wpi_deletecompatiblepres( flippres, flipdc );

    InvalidateRect( node->viewhwnd, NULL, TRUE );

    if( !DoKeepRect() ) {
        SetRectExists( FALSE );
    }
    RecordImage( node->hwnd );
    BlowupImage( node->hwnd, NULL );
    if( whichway == IMGED_FLIPHORZ ) {
        PrintHintTextByID( WIE_IMAGEREFLECTEDH, NULL );
    } else {
        PrintHintTextByID( WIE_IMAGEREFLECTEDV, NULL );
    }
    _wpi_setcursor( prevcursor );

} /* FlipImage */
Exemple #24
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 */
Exemple #25
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 */
void GUIFreeWindowMemory( gui_window *wnd, bool from_parent, bool dialog )
{
    gui_window  *root;
    HWND        capture;

    from_parent = from_parent;
    if( ( wnd->hwnd != NULLHANDLE ) && ( GUICurrWnd == wnd ) ) {
        capture = _wpi_getcapture();
        if( capture == wnd->hwnd ) {
            _wpi_releasecapture();
        }
    }
    if( wnd->font != NULL ) {
        _wpi_deletefont( wnd->font );
        wnd->font = NULL;
    }
    if( wnd->icon != (WPI_HICON)NULL ) {
        _wpi_destroyicon( wnd->icon );
    }
    GUIFreeColours( wnd );
    GUIFreeBKBrush( wnd );
    GUIControlDeleteAll( wnd );
    GUICloseToolBar( wnd );
    GUIFreeHint( wnd );
    _wpi_setwindowlongptr( wnd->hwnd, GUI_EXTRA_WORD * EXTRA_SIZE, 0 );
    if( wnd->root != NULLHANDLE ) {
        _wpi_setwindowlongptr( wnd->root, GUI_EXTRA_WORD * EXTRA_SIZE, 0 );
    }
    if( !dialog ) {
        GUIMDIDelete( wnd );
        if( GUICurrWnd == wnd ) {
            GUICurrWnd = NULL;
        }
        GUIFreePopupList( wnd );
    }
    GUIDeleteFromList( wnd );
    /* If the window being deleted was the current window, choose a new
     * window to bring to front.  Don't do this if the window that's being
     * destroyed is being destroyed because it's parent is being destroyed
     * (ie never got WM_CLOSE so DOING_CLOSE isn't set).
     */
    if( !dialog && ( wnd->flags & DOING_CLOSE ) && ( GUICurrWnd == NULL ) &&
        !GUIIsParentADialog( wnd ) ) {
        // if the root window has received a WM_DESTROY then just run away
        root = GUIGetRootWindow();
        if( root && !( root->flags & DOING_DESTROY ) ) {
            GUIBringNewToFront( wnd );
        }
    }
    if( wnd->hdc != (WPI_PRES)NULL ) {
        _wpi_releasepres( wnd->hwnd, wnd->hdc );
        wnd->hdc = NULLHANDLE;
    }
#ifdef __OS2_PM__
    GUIFreeWndPaintHandles( wnd, true );
    if( wnd->root_pinfo.normal_pres != (WPI_PRES)NULL ) {
        _wpi_deleteos2normpres( wnd->root_pinfo.normal_pres );
        wnd->root_pinfo.normal_pres = (WPI_PRES)NULL;
    }
    if( wnd->hwnd_pinfo.normal_pres != (WPI_PRES)NULL ) {
        _wpi_deleteos2normpres( wnd->hwnd_pinfo.normal_pres );
        wnd->hwnd_pinfo.normal_pres = (WPI_PRES)NULL;
    }
#endif
    GUIMemFree( wnd );
}
Exemple #27
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 #28
0
/*
 * stretchIntoArea - stretch the rotated image into the area specified
 */
static void stretchIntoArea( img_node *node, WPI_RECT *rect,
                             HBITMAP rotxorbmp, HBITMAP rotandbmp )
{
    WPI_PRES    pres;
    WPI_PRES    xorpres;
    HDC         xordc;
    WPI_PRES    andpres;
    HDC         anddc;
    WPI_PRES    rotxorpres;
    HDC         rotxordc;
    WPI_PRES    rotandpres;
    HDC         rotanddc;
    HBITMAP     oldxor;
    HBITMAP     oldand;
    HBITMAP     oldxorrot;
    HBITMAP     oldandrot;
    short       width;
    short       height;
    IMGED_DIM   left;
    IMGED_DIM   right;
    IMGED_DIM   bottom;
    IMGED_DIM   top;

    width = (short)_wpi_getwidthrect( *rect );
    height = (short)_wpi_getheightrect( *rect );

    _wpi_getwrectvalues( *rect, &left, &top, &right, &bottom );

    pres = _wpi_getpres( HWND_DESKTOP );
    xorpres = _wpi_createcompatiblepres( pres, Instance, &xordc );
    andpres = _wpi_createcompatiblepres( pres, Instance, &anddc );
    rotxorpres = _wpi_createcompatiblepres( pres, Instance, &rotxordc );
    rotandpres = _wpi_createcompatiblepres( pres, Instance, &rotanddc );
    _wpi_releasepres( HWND_DESKTOP, pres );

    _wpi_torgbmode( xorpres );
    _wpi_torgbmode( andpres );
    _wpi_torgbmode( rotxorpres );
    _wpi_torgbmode( rotandpres );

    oldxor = _wpi_selectobject( xorpres, node->hxorbitmap );
    oldand = _wpi_selectobject( andpres, node->handbitmap );
    oldxorrot = _wpi_selectobject( rotxorpres, rotxorbmp );
    oldandrot = _wpi_selectobject( rotandpres, rotandbmp );

    _wpi_setstretchbltmode( xorpres, STRETCH_COLOR );
    _wpi_stretchblt( xorpres, left, top, width, height, rotxorpres, 0, 0,
                     height, width, SRCCOPY );

    _wpi_setstretchbltmode( andpres, STRETCH_COLOR );
    _wpi_stretchblt( andpres, left, top, width, height, rotandpres, 0, 0,
                     height, width, SRCCOPY );
    _wpi_selectobject( xorpres, oldxor );
    _wpi_selectobject( andpres, oldand );
    _wpi_selectobject( rotxorpres, oldxorrot );
    _wpi_selectobject( rotandpres, oldandrot );
    _wpi_deletecompatiblepres( xorpres, xordc );
    _wpi_deletecompatiblepres( andpres, anddc );
    _wpi_deletecompatiblepres( rotxorpres, rotxordc );
    _wpi_deletecompatiblepres( rotandpres, rotanddc );

    InvalidateRect( node->viewhwnd, NULL, TRUE );
    RecordImage( node->hwnd );
    BlowupImage( node->hwnd, NULL );

} /* stretchIntoArea */
Exemple #29
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 */
Exemple #30
0
/*
 * 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 */