Exemple #1
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 #2
0
/*
 * redrawViewWnd - process the WM_PAINT message for the view windows
 */
static void redrawViewWnd( HWND hwnd )
{
    WPI_PRES    pres;
    WPI_PRES    hps;
    WPI_PRES    mempres;
    HDC         memdc;
    HBITMAP     bitmap;
    HBITMAP     oldbitmap;
    img_node    *node;
    PAINTSTRUCT ps;

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

    hps = _wpi_beginpaint( hwnd, NULL, &ps );

    drawBorder( node );
    pres = _wpi_getpres( hwnd );

    bitmap = CreateViewBitmap( node );
    mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
    oldbitmap = _wpi_selectbitmap( mempres, bitmap );

    _wpi_bitblt( pres, BORDER_WIDTH, BORDER_WIDTH, node->width, node->height,
                 mempres, 0, 0, SRCCOPY );
    _wpi_getoldbitmap( mempres, oldbitmap );
    _wpi_deletebitmap( bitmap );
    _wpi_deletecompatiblepres( mempres, memdc );

    _wpi_releasepres( hwnd, pres );
    _wpi_endpaint( hwnd, hps, &ps );

} /* redrawViewWnd */
Exemple #3
0
void GUIFreePaintHandles( gui_paint_info *pinfo, int force )
{
    if( pinfo == NULL ) {
        return;
    }

    if( !force && pinfo->in_use ) {
        pinfo->delete_when_done = TRUE;
        return;
    }

#ifdef __OS2_PM__
    //bmp = _wpi_selectbitmap( pinfo->compatible_pres, pinfo->old_bmp );
    _wpi_getoldbitmap( pinfo->compatible_pres, pinfo->old_bmp );
    pinfo->old_bmp = (WPI_HANDLE)NULL;
    if( pinfo->draw_bmp != (WPI_HANDLE)NULL ) {
        _wpi_deletebitmap( pinfo->draw_bmp );
        pinfo->draw_bmp = (WPI_HANDLE)NULL;
    }
    if( pinfo->compatible_pres != (WPI_PRES)NULL ) {
        _wpi_deletecompatiblepres( pinfo->compatible_pres,
                                   pinfo->compatible_hdc );
        pinfo->compatible_pres = (WPI_PRES)NULL;
        pinfo->compatible_hdc = (HDC)NULL;
    }
    pinfo->in_use = 0;
    pinfo->delete_when_done = FALSE;
#endif
}
Exemple #4
0
/*
 * MDIClearMaximizedMenuConfig - done with maximized menu configuration
 */
void MDIClearMaximizedMenuConfig( void )
{
    updatedMenu = FALSE;
    if( closeBitmap != NULLHANDLE ) {
        _wpi_deletebitmap( closeBitmap );
        closeBitmap = NULLHANDLE;
    }
    if( restoreBitmap != NULLHANDLE ) {
        _wpi_deletebitmap( restoreBitmap );
        restoreBitmap = NULLHANDLE;
    }
    if( restoredBitmap != NULLHANDLE ) {
        _wpi_deletebitmap( restoredBitmap );
        restoredBitmap = NULLHANDLE;
    }

} /* MDIClearMaximizedMenuConfig */
Exemple #5
0
/*
 * ColorsWndProc - handle messages for the available color selection window
 */
WPI_MRESULT CALLBACK ColorsWndProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    static WPI_POINT            pt;

    switch( msg ) {
    case WM_CREATE:
        numberOfColors = 16;
        initPaletteBoxes( TRUE );
        InitPaletteBitmaps( hwnd, &hColorBitmap, &hMonoBitmap );
        break;

    case WM_PAINT:
        paintColors( hwnd );
        break;

    case WM_LBUTTONDOWN:
        IMGED_MAKEPOINT( wparam, lparam, pt );
        selectColor( &pt, LMOUSEBUTTON );
        break;

    case WM_LBUTTONDBLCLK:
        IMGED_MAKEPOINT( wparam, lparam, pt );
        editCurrentColor( &pt );
        break;

    case WM_RBUTTONDOWN:
        IMGED_MAKEPOINT( wparam, lparam, pt );
        selectColor( &pt, RMOUSEBUTTON );
        break;

    case WM_DESTROY:
        _wpi_deletebitmap( hColorBitmap );
        _wpi_deletebitmap( hMonoBitmap );
        break;

    default:
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
    }
    return( 0 );

} /* ColorsWndProc */
Exemple #6
0
_WCRTLINK void _WCI86FAR _CGRAPH _freeimage( char _WCI86HUGE *image )
//===============================================

/* This function frees the dc used by _getimage and _putimage */

{
    struct picture _WCI86FAR *picture;

    picture = (struct picture _WCI86FAR *) image;
    _wpi_deletepres( picture->buffer, picture->pdc );
    _wpi_deletebitmap( picture->bmp );
}
Exemple #7
0
/*
 * BlowupImage - stretch 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 != NULL ) {
        hwnd = hmdiwnd;
    } else {
        node = GetCurrentNode();
        if( node == NULL ) {
            return;
        }
        hwnd = node->hwnd;
    }

    newbitmap = EnlargeImage( hwnd );
    if( newbitmap == NULL ) {
        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 );   // Redraw 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 #8
0
bool GUIXCloseToolBar( gui_window *wnd )
{
    toolbarinfo         *toolbar;
    int                 i;

    if( ( wnd->toolbar != NULL ) && ( wnd->toolbar->hdl != NULL ) ) {
        toolbar = wnd->toolbar;
        wnd->toolbar = NULL;
        ToolBarFini( toolbar->hdl );
        for( i=0; i < toolbar->num; i++ ) {
            _wpi_deletebitmap( toolbar->bitmaps[i] );
        }
        GUIMemFree( toolbar->bitmaps );
        GUIMemFree( toolbar );
        GUIResizeBackground( wnd, TRUE );
        GUIEVENTWND( wnd, GUI_TOOLBAR_DESTROYED, NULL );
    }
    return( TRUE );
}
Exemple #9
0
bool GUIXCloseToolBar( gui_window *wnd )
{
    toolbarinfo     *tbar;
    int             i;

    tbar = wnd->tbinfo;
    if( tbar != NULL ) {
        wnd->tbinfo = NULL;
        if( tbar->hdl != NULL ) {
            ToolBarFini( tbar->hdl );
            for( i = 0; i < tbar->num; i++ ) {
                _wpi_deletebitmap( tbar->bitmaps[i] );
            }
            GUIMemFree( tbar->bitmaps );
        }
        GUIMemFree( tbar );
        if( (wnd->flags & DOING_DESTROY) == 0 ) {
            GUIResizeBackground( wnd, true );
        }
        GUIEVENTWND( wnd, GUI_TOOLBAR_DESTROYED, NULL );
    }
    return( true );
}
Exemple #10
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 */
Exemple #11
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 #12
0
/*
 * PasteImage - paste the image in the clipboard at the current point
 *            - first check to see if the image was cut/copied from our program
 *            - if it was, then we use the hXorClipped and hAndClipped bitmaps
 *              we created in order to preserve the screen colors if ther were used
 *            - otherwise, just copy from the clipboard
 */
void PasteImage( WPI_POINT *pt, WPI_POINT pointsize, HWND hwnd )
{
    HBITMAP     hbitmap;
    HBITMAP     hbitmapdup;
    HBITMAP     holddup;
    HBITMAP     oldbitmap;
    HBITMAP     oldbitmap2;
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HDC         memdc;
    WPI_PRES    clippres;
    HDC         clipdc;
    WPI_RECT    client;
    WPI_POINT   truept;
    short       width;
    short       height;
    short       clipwidth;
    short       clipheight;
    img_node    *node;
    int         fstretchbmp;
    int         bm_width, bm_height;
    WPI_RECTDIM left;
    WPI_RECTDIM right;
    WPI_RECTDIM top;
    WPI_RECTDIM bottom;
    WPI_RECTDIM client_l;
    WPI_RECTDIM client_r;
    WPI_RECTDIM client_t;
    WPI_RECTDIM client_b;
#ifdef __OS2_PM__
    int         src_y, dest_y;
#endif

    if( fEnableCutCopy ) {
        _wpi_getwrectvalues( clipRect.rect, &left, &top, &right, &bottom );
        truept.x = left;
        truept.y = top;
        fstretchbmp = StretchPastedImage();
    } else {
        truept.x = pt->x / pointsize.x;
        truept.y = pt->y / pointsize.y;
        fstretchbmp = -1;
    }

    node = SelectImage( hwnd );
    pres = _wpi_getpres( node->viewhwnd );

    if( _wpi_getclipboardowner( Instance ) == HMainWindow && node->imgtype != BITMAP_IMG ) {
        _wpi_getbitmapdim( hAndClipped, &bm_width, &bm_height );
        GetClientRect( node->hwnd, &client );
        if( fEnableCutCopy ) {
            width = (short)_wpi_getwidthrect( clipRect.rect );
            height = (short)_wpi_getheightrect( clipRect.rect );
        } else {
            _wpi_getrectvalues( client, &client_l, &client_t, &client_r, &client_b );
            width = (short)( client_r / pointsize.x - truept.x );
            if( width > (short)bm_width )
                width = (short)bm_width;
            height = (short)( client_b / pointsize.y - truept.y );
            if( height > (short)bm_height ) {
                height = (short)bm_height;
            }
        }

        mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
        _wpi_setstretchbltmode( mempres, COLORONCOLOR );
        clippres = _wpi_createcompatiblepres( pres, Instance, &clipdc );

        oldbitmap = _wpi_selectbitmap( mempres, node->handbitmap );
        oldbitmap2 = _wpi_selectbitmap( clippres, hAndClipped );

        if( fstretchbmp == FALSE ) {
            clipwidth = (short)bm_width;
            if( clipwidth > (short)width )
                clipwidth = (short)width;
            clipheight = (short)bm_height;
            if( clipheight > (short)height )
                clipheight = (short)height;

            _wpi_patblt( mempres, truept.x, truept.y, width, height, BLACKNESS );
            _wpi_bitblt( mempres, truept.x, truept.y, clipwidth, clipheight,
                         clippres, 0, 0, SRCCOPY );
        } else if( fstretchbmp == TRUE ) {
            _wpi_stretchblt( mempres, truept.x, truept.y, width, height,
                             clippres, 0, 0, bm_width, bm_height, SRCCOPY);
        } else {
            _wpi_bitblt( mempres, truept.x, truept.y, width, height, clippres,
                         0, 0, SRCCOPY );
        }
        _wpi_getoldbitmap( mempres, oldbitmap );
        oldbitmap = _wpi_selectbitmap( mempres, node->hxorbitmap );

        hbitmapdup = DuplicateBitmap( hXorClipped );
        _wpi_getoldbitmap( clippres, oldbitmap2 );
        oldbitmap2 = _wpi_selectbitmap( clippres, hbitmapdup );

        if( fstretchbmp == FALSE ) {
            clipwidth = (short)bm_width;
            if( clipwidth > (short)width )
                clipwidth = (short)width;
            clipheight = (short)bm_height;
            if( clipheight > (short)height )
                clipheight = (short)height;

            _wpi_patblt( mempres, truept.x, truept.y, width, height, WHITENESS );
#ifdef __OS2_PM__
            if( bm_height > height ) {
                src_y = bm_height - height;
                dest_y = truept.y;
            } else {
                src_y = 0;
                dest_y = truept.y + (height - bm_height);
            }
            _wpi_bitblt( mempres, truept.x, dest_y, clipwidth, clipheight,
                         clippres, 0, src_y, SRCCOPY );
#else
            _wpi_bitblt( mempres, truept.x, truept.y, clipwidth, clipheight,
                         clippres, 0, 0, SRCCOPY );
#endif
        } else if( fstretchbmp == TRUE ) {
            _wpi_stretchblt( mempres, truept.x, truept.y, width, height,
                             clippres, 0, 0, bm_width, bm_height, SRCCOPY );
        } else {
            _wpi_bitblt( mempres, truept.x, truept.y, width, height, clippres,
                         0, 0, SRCCOPY );
        }
        _wpi_getoldbitmap( mempres, oldbitmap );
        _wpi_getoldbitmap( clippres, oldbitmap2 );
        _wpi_deletebitmap( hbitmapdup );
        _wpi_deletecompatiblepres( mempres, memdc );
        _wpi_deletecompatiblepres( clippres, clipdc );
    } else {
        if( node->imgtype != BITMAP_IMG ) {
            CleanupClipboard();
        }
        _wpi_openclipboard( Instance, HMainWindow );
        hbitmap = _wpi_getclipboarddata( Instance, CF_BITMAP );
        hbitmapdup = DuplicateBitmap( hbitmap );
        _wpi_closeclipboard( Instance );

        _wpi_getbitmapdim( hbitmapdup, &bm_width, &bm_height );
        GetClientRect( node->hwnd, &client );

        if( fEnableCutCopy ) {
            width = (short)_wpi_getwidthrect( clipRect.rect );
            height = (short)_wpi_getheightrect( clipRect.rect );
        } else {
            _wpi_getrectvalues( client, &client_l, &client_t, &client_r, &client_b );
            width = (short)( client_r / pointsize.x - truept.x );
            if( width > (short)bm_width )
                width = (short)bm_width;
            height = (short)( client_b / pointsize.y - truept.y );
            if( height > (short)bm_height ) {
                height = (short)bm_height;
            }
        }

        clippres = _wpi_createcompatiblepres( pres, Instance, &clipdc );
        mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
        _wpi_setstretchbltmode( mempres, COLORONCOLOR );

        holddup = _wpi_selectbitmap( clippres, hbitmapdup );
        oldbitmap = _wpi_selectbitmap( mempres, node->hxorbitmap );

        if( fstretchbmp == FALSE ) {
            clipwidth = (short)bm_width;
            if( clipwidth > (short)width )
                clipwidth = (short)width;
            clipheight = (short)bm_height;
            if( clipheight > (short)height )
                clipheight = (short)height;

            _wpi_patblt( mempres, truept.x, truept.y, width, height, WHITENESS );
#ifdef __OS2_PM__
            if( bm_height > height ) {
                src_y = bm_height - height;
                dest_y = truept.y;
            } else {
                src_y = 0;
                dest_y = truept.y + (height - bm_height);
            }
            _wpi_bitblt( mempres, truept.x, dest_y, clipwidth, clipheight,
                         clippres, 0, src_y, SRCCOPY );
#else
            _wpi_bitblt( mempres, truept.x, truept.y, clipwidth, clipheight,
                         clippres, 0, 0, SRCCOPY );
#endif
        } else if( fstretchbmp == TRUE ) {
            _wpi_stretchblt( mempres, truept.x, truept.y, width, height,
                             clippres, 0, 0, bm_width, bm_height, SRCCOPY );
        } else {
            _wpi_bitblt( mempres, truept.x, truept.y, width, height, clippres,
                         0, 0, SRCCOPY );
        }
        _wpi_getoldbitmap( clippres, holddup );
        _wpi_deletebitmap( hbitmapdup );
        _wpi_deletecompatiblepres( clippres, clipdc );

        _wpi_getoldbitmap( mempres, oldbitmap );
        oldbitmap = _wpi_selectbitmap( mempres, node->handbitmap );
        _wpi_patblt( mempres, truept.x, truept.y, width, height, BLACKNESS );

        _wpi_getoldbitmap( mempres, oldbitmap );
        _wpi_deletecompatiblepres( mempres, memdc );
    }

    ReleaseCapture();
    _wpi_releasepres( node->viewhwnd, pres );

    InvalidateRect( node->viewhwnd, NULL, TRUE );
    if( !fEnableCutCopy ) {
        _wpi_setcursor( prevCursor );
        _wpi_destroycursor( pointCursor );
        SetToolType( prevToolType );
    }

    fEnableCutCopy = FALSE;
    RecordImage( hwnd );
    BlowupImage( NULL, NULL );

    PrintHintTextByID( WIE_BITMAPPASTED, NULL );

} /* PasteImage */
Exemple #13
0
WPI_MRESULT CALLBACK GraphWndProc( HWND         Wnd,
                                   WPI_MSG      message,
                                   WPI_PARAM1   wParam,
                                   WPI_PARAM2   lParam )
//=============================================================

{
    WPI_PRES            Win_dc;
    PAINTSTRUCT         ps;
    int                 width, height;
    int                 x, y, t;
    int                 h_minpos, h_maxpos, h_currpos;
    int                 v_minpos, v_maxpos, v_currpos;
    WPI_RECTDIM         left, top, right, bottom;
    WPI_RECT            rect;
    struct ScrollStruct scroll_info;
    LPWDATA             w;
    HWND                frame;
#if defined( __OS2__ )
    int                 wheight;
    WPI_RECT            wrect;
#endif

    w = _GetWindowData( Wnd );
    if( w == NULL ) {
        return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) );
    }
#if defined( __OS2__ )
    frame = w->frame;
#else
    frame = Wnd;
#endif

    switch( message ) {
#if defined( __WINDOWS__ )
    case WM_SETFOCUS:
        SetFocus( _MainWindow );
    case WM_SYSCOMMAND:
    case WM_MOUSEACTIVATE:
        _MakeWindowActive( w );
        return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) );

    case WM_KILLFOCUS:
        if( ( wParam != NULL) && ( wParam != _MainWindow ) ) {
            _ShowWindowActive( NULL, w );
        }
        return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) );
#else
    case WM_FOCUSCHANGE:
    case WM_SYSCOMMAND:
        _MakeWindowActive( w );
        return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) );
#endif

    case WM_PAINT:
        // Setup
        Win_dc = _wpi_beginpaint( Wnd, NULLHANDLE, &ps );
        _wpi_torgbmode( Win_dc );
        _wpi_getpaintrect( &ps, &rect );
        _wpi_getwrectvalues( rect, &left, &top, &right, &bottom );
        width = _wpi_getwidthrect( rect );
        height = _wpi_getheightrect( rect );

        // Copy from the memory dc to the screen
#if defined( __OS2__ )
        GetClientRect( Wnd, &wrect );
        wheight = _wpi_getheightrect( wrect );
        y = _GetPresHeight() - wheight - _BitBlt_Coord.ycoord + top;
#else
        y = _BitBlt_Coord.ycoord + top;
#endif
        _wpi_bitblt( Win_dc,
                left,
                top,
                width, height,
                _Mem_dc,
                _BitBlt_Coord.xcoord + left,
                y,
                SRCCOPY );

        //Cleanup
        _wpi_endpaint( Wnd, Win_dc, &ps );
        break;
#if defined( __OS2__ )
    case WM_CLOSE:
        WinDestroyWindow( w->frame );
        return( 0 );
#endif
    case WM_DESTROY:
        // free the system resources allocated

        if( _Mem_dc ){
            _wpi_deletecliprgn( _Mem_dc, _ClipRgn );
            _wpi_deletecompatiblepres( _Mem_dc, _Hdc );
            if( _Mem_bmp ){
                _wpi_deletebitmap( _Mem_bmp );
                if( !_IsStockFont() ){
                    _wpi_f_deletefont( _CurFnt );
                }
            }
#if defined( __OS2__ )
            WinSendMsg( _GetWinMenuHandle(), ( ULONG )MM_DELETEITEM,
                MPFROM2SHORT( ( w->handles[0] + DID_WIND_STDIO ), FALSE ), 0 );
#endif
            _DestroyAWindow( w );
        }
        break;

    case WM_VSCROLL:
        scroll_info = getscrolldata( frame, SB_VERT );
        CalPos( &scroll_info, wParam, lParam, &v_currpos, &y );

        // Make sure we have to refresh first
        if( _BitBlt_Coord.ycoord != y ) {
            _BitBlt_Coord.ycoord = y;
            _wpi_setscrollpos( frame,
                          SB_VERT,
                          v_currpos,
                          TRUE );
            _wpi_invalidaterect( Wnd, NULL, 0 );
            _wpi_updatewindow( Wnd );
        }
        return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) );

    case WM_HSCROLL:
        scroll_info = getscrolldata( frame, SB_HORZ );
        CalPos( &scroll_info, wParam, lParam, &h_currpos, &x );

        // make sure we need to refresh first
        if( _BitBlt_Coord.xcoord != x ) {
            _BitBlt_Coord.xcoord = x;
            _wpi_setscrollpos(  frame,
                                SB_HORZ,
                                h_currpos,
                                TRUE );
            _wpi_invalidaterect( Wnd, NULL, 0 );
            _wpi_updatewindow( Wnd );
        }
        return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) );

    case WM_SIZE:
        x = _wpi_getsystemmetrics( SM_CXSCREEN );
        y = _wpi_getsystemmetrics( SM_CYSCREEN );

        _wpi_getscrollrange( frame, SB_VERT, &v_minpos, &v_maxpos );
        _wpi_getscrollrange( frame, SB_HORZ, &h_minpos, &h_maxpos );
        _wpi_getclientrect( Wnd, &rect );
        _wpi_getrectvalues( rect, &left, &top, &right, &bottom );
        height = bottom - top + 1;
        width = right - left + 1;

        if( width >= x ) {
            // hide the scroll bar
#if defined( __OS2__ )
            WinShowWindow( WinWindowFromID( frame, FID_HORZSCROLL ),
                           FALSE );
#else
            ShowScrollBar( Wnd, SB_HORZ, FALSE );
#endif
            _BitBlt_Coord.xcoord = 0;
            h_currpos = 0;
        } else {
            // if the window isn't as big as the device context
            // show the scroll bar
            t = x - width + 1;
            if( x - _BitBlt_Coord.xcoord + 1 < width ) {
                _BitBlt_Coord.xcoord = x - width + 1;
            }
            if( _BitBlt_Coord.xcoord == t ) {
                h_currpos = h_maxpos;
            } else {
            h_currpos = CalScrollAmt( h_maxpos, h_minpos,
                                      _BitBlt_Coord.xcoord,
                                      x, width );
            }
#if defined( __OS2__ )
            WinShowWindow( WinWindowFromID( frame, FID_HORZSCROLL ),
                           TRUE );
#else
            ShowScrollBar( Wnd, SB_HORZ, 1 );
#endif
        }

        if( height >= y ) {
            // hide the scroll bar
#if defined( __OS2__ )
            WinShowWindow( WinWindowFromID( frame, FID_VERTSCROLL ),
                           FALSE );
#else
            ShowScrollBar( Wnd, SB_VERT, 0 );
#endif
            _BitBlt_Coord.ycoord = 0;
            v_currpos = 0;
        } else {
            // if the the window isn't as big as the device context
            // then show the scroll bar
            t = y - height + 1;
            if( y - _BitBlt_Coord.ycoord + 1 < height ) {
                _BitBlt_Coord.ycoord = t;
            }
            if( _BitBlt_Coord.ycoord == t ) {
                v_currpos = v_maxpos;
            } else {
                v_currpos = CalScrollAmt( v_maxpos, v_minpos,
                                          _BitBlt_Coord.ycoord,
                                          y, height );
            }
#if defined( __OS2__ )
            WinShowWindow( WinWindowFromID( frame, FID_VERTSCROLL ),
                           TRUE );
#else
            ShowScrollBar( Wnd, SB_VERT, 1 );
#endif
        }


        // Adjust the scroll bar thumbs' positions
        _wpi_setscrollpos( frame, SB_HORZ, h_currpos, TRUE );
        _wpi_setscrollpos( frame, SB_VERT, v_currpos, TRUE );
#if defined( __OS2__ )
        Win_dc = WinBeginPaint( Wnd, NULL, &rect );
        WinFillRect( Win_dc, &rect, CLR_BLACK );
        WinEndPaint( Win_dc );
#endif
        _wpi_invalidaterect( Wnd, NULL, 0 );
        break;
    default:
        return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) );
    }
   return( NULL );
}
Exemple #14
0
/*
 * ChangeImageSize - changes the size of the current image being edited
 */
void ChangeImageSize( void )
{
    img_node        *node;
    WPI_DLGPROC     dlgproc;
    WPI_DLGRESULT   button_type;
    img_node        new_node;
    WPI_PRES        pres;
    HDC             srcdc;
    WPI_PRES        srcpres;
    HDC             destdc;
    WPI_PRES        destpres;
    HBITMAP         oldsrc;
    HBITMAP         olddest;
    int             retcode;
    WPI_PARAM2      lparam;
    WPI_RECT        rc;
    short           new_width;
    short           new_height;
    int             y_src;
    int             y_dest;
    char            *title;
    char            *text;

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

    if( node->imgtype != BITMAP_IMG ) {
        return;
    }

    imgHeight = node->height;
    imgWidth = node->width;

    dlgproc = _wpi_makedlgprocinstance( ChangeSizeDlgProc, Instance );
    button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, IMAGESIZE, 0L );
    _wpi_freedlgprocinstance( dlgproc );

    if( button_type == DLGID_CANCEL ) {
        return;
    }
    if( imgWidth == node->width && imgHeight == node->height ) {
        PrintHintTextByID( WIE_IMAGESIZEUNCHANGED, NULL );
        return;
    }
    title = IEAllocRCString( WIE_INFORMATIONTEXT );
    text = IEAllocRCString( WIE_RESETUNDOSTACKWARNING );
    retcode = _wpi_messagebox( HMainWindow, text, title, MB_YESNO | MB_ICONINFORMATION );
    if( text != NULL ) {
        IEFreeRCString( text );
    }
    if( title != NULL ) {
        IEFreeRCString( title );
    }

    if( retcode == WPI_IDNO ) {
        return;
    }

    new_node.width = (short)imgWidth;
    new_node.height = (short)imgHeight;
    new_node.bitcount = node->bitcount;
    new_node.imgtype = BITMAP_IMG;

    MakeBitmap( &new_node, TRUE );

    pres = _wpi_getpres( HWND_DESKTOP );
    srcpres = _wpi_createcompatiblepres( pres, Instance, &srcdc );
    destpres = _wpi_createcompatiblepres( pres, Instance, &destdc );
    _wpi_releasepres( HWND_DESKTOP, pres );

    oldsrc = _wpi_selectbitmap( srcpres, node->hxorbitmap );
    olddest = _wpi_selectbitmap( destpres, new_node.hxorbitmap );

    if( stretchImage ) {
        _wpi_stretchblt( destpres, 0, 0, imgWidth, imgHeight,
                         srcpres, 0, 0, node->width, node->height, SRCCOPY );
    } else {
#ifdef __OS2_PM__
        y_src = node->height - imgHeight;
        if( y_src < 0 ) {
            y_src = 0;
            y_dest = imgHeight - node->height;
        } else {
            y_dest = 0;
        }
#else
        y_src = 0;
        y_dest = 0;
#endif
        _wpi_bitblt( destpres, 0, y_dest, node->width, node->height,
                     srcpres, 0, y_src, SRCCOPY );
    }
    _wpi_getoldbitmap( srcpres, oldsrc );
    oldsrc = _wpi_selectbitmap( srcpres, node->handbitmap );
    _wpi_getoldbitmap( destpres, olddest );
    olddest = _wpi_selectbitmap( destpres, new_node.handbitmap );

    if( stretchImage ) {
        _wpi_stretchblt( destpres, 0, 0, imgWidth, imgHeight,
                         srcpres, 0, 0, node->width, node->height, SRCCOPY );
    } else {
        _wpi_bitblt( destpres, 0, 0, node->width, node->height, srcpres, 0, 0, SRCCOPY );
    }

    _wpi_getoldbitmap( srcpres, oldsrc );
    _wpi_getoldbitmap( destpres, olddest );
    _wpi_deletebitmap( node->hxorbitmap );
    _wpi_deletebitmap( node->handbitmap );
    _wpi_deletecompatiblepres( srcpres, srcdc );
    _wpi_deletecompatiblepres( destpres, destdc );

    node->hxorbitmap = new_node.hxorbitmap;
    node->handbitmap = new_node.handbitmap;
    node->width = (short)imgWidth;
    node->height = (short)imgHeight;

    SetIsSaved( node->hwnd, FALSE );
    ResetUndoStack( node );

    RePositionViewWnd( node );

    _wpi_getclientrect( node->hwnd, &rc );
    new_width = (short)_wpi_getwidthrect( rc );
    new_height = (short)_wpi_getheightrect( rc );
    lparam = WPI_MAKEP2( new_width, new_height );

    ResizeChild( lparam, node->hwnd, false );
    DisplayImageText( node );
    WriteSetSizeText( WIE_NEWIMAGESIZE, imgWidth, imgHeight );

} /* ChangeImageSize */
Exemple #15
0
/*
 * writeImageBits - writes the bits for the image
 */
static bool writeImageBits( FILE *fp, img_node *node )
{
    WPI_PRES                    pres;
    WPI_PRES                    mempres;
    HDC                         memdc;
    ULONG                       byte_count;
    img_node                    *new_image;
    BITMAPINFO2                 *bmi;
    HBITMAP                     oldbitmap;
    HBITMAP                     inverse_bitmap;
    HBITMAP                     clr_bitmap;
    BYTE                        *buffer;
    bool                        ok;

    ok = true;
    pres = _wpi_getpres( HWND_DESKTOP );
    mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
    _wpi_releasepres( HWND_DESKTOP, pres );
    for( new_image = node; new_image != NULL; new_image = new_image->nexticon ) {
        bmi = GetAndBitmapInfo(new_image);
        if( bmi == NULL ) {
            ok = false;
            break;
        }
        /*
         * first we write the PM XOR mask (inverse mask) then the PM AND
         * mask (and mask) and then the PM colour mask (xor mask).
         */
        byte_count = BITS_TO_BYTES( new_image->width, new_image->height );
        buffer = MemAlloc( byte_count );

        inverse_bitmap = CreateInverseBitmap( new_image->handbitmap, new_image->hxorbitmap );
        oldbitmap = _wpi_selectobject( mempres, inverse_bitmap );
        GpiQueryBitmapBits( mempres, 0, new_image->height, buffer, bmi );
        fwrite( buffer, sizeof( BYTE ), byte_count, fp );
        _wpi_selectobject( mempres, oldbitmap );
        _wpi_deletebitmap( inverse_bitmap );

        oldbitmap = _wpi_selectobject( mempres, new_image->handbitmap );
        GpiQueryBitmapBits( mempres, 0, new_image->height, buffer, bmi );
        fwrite( buffer, sizeof( BYTE ), byte_count, fp );
        _wpi_selectobject( mempres, oldbitmap );

        MemFree( buffer );
        FreeDIBitmapInfo( bmi );

        bmi = GetXorBitmapInfo( new_image );
        if( bmi == NULL ) {
            ok = false;
            break;
        }
        clr_bitmap = CreateColourBitmap( new_image->handbitmap, new_image->hxorbitmap );
        oldbitmap = _wpi_selectobject( mempres, clr_bitmap );
        byte_count = BITS_TO_BYTES( new_image->width * new_image->bitcount, new_image->height );
        buffer = MemAlloc( byte_count );
        GpiQueryBitmapBits( mempres, 0, node->height, buffer, bmi );
        fwrite( buffer, sizeof( BYTE ), byte_count, fp );
        MemFree( buffer );
        FreeDIBitmapInfo( bmi );
        _wpi_selectobject( mempres, oldbitmap );
        _wpi_deletebitmap( clr_bitmap );
    }
    _wpi_deletecompatiblepres( mempres, memdc );
    return( ok );
} /* writeImageBits */