Exemplo n.º 1
0
/*
 * IECopyImage - copy the current clipping rectangle to the clipboard
 *
 * 1) Copy the bitmap to the clipboard (so other apps can use it).
 * 2) Make a copy of the XOR bitmap and the AND bitmaps so that if
 *    screen colors are involved, they will be preserved.
 *    Later, we check the owner of the clipboard to see if we really
 *    want to use the XOR/AND bitmaps or not.
 */
void IECopyImage( void )
{
    short       width;
    short       height;
    img_node    *node;

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

    if( !fEnableCutCopy ) {
        _wpi_setwrectvalues( &clipRect.rect, 0, 0, node->width, node->height );
        width = node->width;
        height = node->height;
    } else {
        width = _wpi_getwidthrect( clipRect.rect );
        height = _wpi_getheightrect( clipRect.rect );
    }

    copyImageToClipboard( width, height, node );

    if( !fEnableCutCopy ) {
        PrintHintTextByID( WIE_ENTIREIMAGECOPIED, NULL );
    } else {
        PrintHintTextByID( WIE_AREACOPIED, NULL );
        RedrawPrevClip( node->hwnd );
        fEnableCutCopy = FALSE;
    }

} /* IECopyImage */
Exemplo n.º 2
0
/*
 * CheckGridItem - Check the grid item and display the grid if necessary.
 *                 First we check if an item has been created or not, if not
 *                 we just check some flags so that when it is created, a
 *                 grid will (not) be displayed.
 */
void CheckGridItem( HMENU hmenu )
{
    WPI_ENUMPROC        fp_enum;
    HCURSOR             prevcursor;

    prevcursor = _wpi_setcursor( _wpi_getsyscursor(IDC_WAIT) );
    if ( _wpi_isitemchecked(hmenu, IMGED_GRID) ) {
        _wpi_checkmenuitem( hmenu, IMGED_GRID, MF_UNCHECKED, FALSE );
        ImgedConfigInfo.grid_on = FALSE;
        BlowupImage( NULL, NULL );
        PrintHintTextByID( WIE_GRIDTURNEDOFF, NULL );
    } else {
        _wpi_checkmenuitem( hmenu, IMGED_GRID, MF_CHECKED, FALSE );
        ImgedConfigInfo.grid_on = TRUE;
        BlowupImage( NULL, NULL );
        PrintHintTextByID( WIE_GRIDTURNEDON, NULL );
    }
    PressGridButton();

    if( DoImagesExist() ) {
        fp_enum = _wpi_makeenumprocinstance( GridEnumProc, Instance );
        _wpi_enumchildwindows( ClientWindow, fp_enum, 0L );
        _wpi_freeprocinstance( fp_enum );
    }
    _wpi_setcursor( prevcursor );
} /* CheckGridItem */
Exemplo n.º 3
0
/*
 * CutImage - cuts the current clipping rectangle to the clipboard
 */
void CutImage( void )
{
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HDC         memdc;
    HBITMAP     oldbitmap;
    short       width;
    short       height;
    img_node    *node;
    WPI_RECTDIM left;
    WPI_RECTDIM right;
    WPI_RECTDIM top;
    WPI_RECTDIM bottom;

    node = GetCurrentNode();

    if( node == NULL ) {
        return;
    }

    if( !fEnableCutCopy ) {
        _wpi_setwrectvalues( &clipRect.rect, 0, 0, node->width, node->height );
        width = node->width;
        height = node->height;
    } else {
        width = (short)_wpi_getwidthrect( clipRect.rect );
        height = (short)_wpi_getheightrect( clipRect.rect );
    }
    copyImageToClipboard( width, height, node );

    pres = _wpi_getpres( node->viewhwnd );
    mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
    _wpi_releasepres( node->viewhwnd, pres );

    oldbitmap = _wpi_selectbitmap( mempres, node->hxorbitmap );
    _wpi_getrectvalues( clipRect.rect, &left, &top, &right, &bottom );
    _wpi_patblt( mempres, left, top, width, height, WHITENESS );

    _wpi_getoldbitmap( mempres, oldbitmap );
    oldbitmap = _wpi_selectbitmap( mempres, node->handbitmap );
    _wpi_patblt( mempres, left, top, width, height, BLACKNESS );
    _wpi_getoldbitmap( mempres, oldbitmap );
    _wpi_deletecompatiblepres( mempres, memdc );

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

    if( !fEnableCutCopy ) {
        PrintHintTextByID( WIE_ENTIREIMAGECUT, NULL );
    } else {
        PrintHintTextByID( WIE_AREACUT, NULL );
        fEnableCutCopy = FALSE;
    }
    BlowupImage( node->hwnd, NULL );

} /* CutImage */
Exemplo n.º 4
0
/*
 * CheckSquareGrid - checks the square grid item
 */
void CheckSquareGrid( HMENU hmenu )
{
    if ( _wpi_isitemchecked(hmenu, IMGED_SQUARE) ) {
        _wpi_checkmenuitem(hmenu, IMGED_SQUARE, MF_UNCHECKED, FALSE);
        ImgedConfigInfo.square_grid = FALSE;
        PrintHintTextByID( WIE_SQUAREGRIDOFF, NULL );
    } else {
        _wpi_checkmenuitem( hmenu, IMGED_SQUARE, MF_CHECKED, FALSE );
        ImgedConfigInfo.square_grid = TRUE;
        PrintHintTextByID( WIE_SQUAREGRIDON, NULL );
    }
} /* CheckSquareGrid */
Exemplo n.º 5
0
/*
 * CloseCurrentImage - Gets the current image the user is editing and deletes
 *                     the node from the linked list and sends a message to
 *                     destroy the mdi child (this will activate another
 *                     child then).
 */
void CloseCurrentImage( HWND hwnd )
{
    img_node    *node;
    char        file_name[ _MAX_PATH ];
    BOOL        ret;

    node = SelectImage( hwnd );
    if (!node) return;
    ret = DestroyWindow( _wpi_getframe(node->viewhwnd) );
    GetFnameFromPath( node->fname, file_name );
    DeleteUndoStack( hwnd );
    if ( !DeleteNode(hwnd) ) {
        WImgEditError( WIE_ERR_BAD_HWND, WIE_INTERNAL_002 );
        return;
    }
    DeleteActiveImage();
    ClearImageText();

    GrayEditOptions();
    PrintHintTextByID( WIE_FILEHASBEENCLOSED, file_name );
    SetWindowText( _wpi_getframe(HMainWindow), IEAppTitle );

#ifdef __OS2_PM__
    ret = DestroyWindow( _wpi_getframe(hwnd) );
#else
    SendMessage(ClientWindow, WM_MDIDESTROY, (WPARAM)hwnd, 0L);
#endif
} /* CloseCurrentImage */
Exemplo n.º 6
0
/*
 * ViewWindowProc - window procedure for the view window
 */
WPI_MRESULT CALLBACK ViewWindowProc( HWND hwnd, WPI_MSG msg,
                                 WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    static HMENU                sysmenu;
    static HWND                 hframe;
    HMENU                       hmenu;
    WPI_RECT                    rcview;
    WPI_RECTDIM                 left;
    WPI_RECTDIM                 top;
    WPI_RECTDIM                 right;
    WPI_RECTDIM                 bottom;

    switch ( msg ) {
    case WM_CREATE:
        hframe = _wpi_getframe( hwnd );
        sysmenu = _wpi_getcurrentsysmenu( hframe );
        _wpi_deletemenu( sysmenu, SC_RESTORE, FALSE );
        _wpi_deletemenu( sysmenu, SC_SIZE, FALSE );
        _wpi_deletemenu( sysmenu, SC_MINIMIZE, FALSE );
        _wpi_deletemenu( sysmenu, SC_MAXIMIZE, FALSE );
        _wpi_deletemenu( sysmenu, SC_TASKLIST, FALSE );
#ifdef __OS2_PM__
        _wpi_deletemenu( sysmenu, SC_HIDE, FALSE );
#endif
        _wpi_deletesysmenupos( sysmenu, 1 );
        _wpi_deletesysmenupos( sysmenu, 2 );
        break;

    case WM_PAINT:
        redrawViewWnd( hwnd );
        return( 0 );

    case WM_MOVE:
        _wpi_getwindowrect( _wpi_getframe( hwnd ), &rcview );
        _wpi_getrectvalues( rcview, &left, &top, &right, &bottom );
        ImgedConfigInfo.view_xpos = (short)left;
        ImgedConfigInfo.view_ypos = (short)top;
        break;

    case WM_CLOSE:
        hmenu = GetMenu( _wpi_getframe( HMainWindow ) );
        if( fOneViewWindow ) {
            CheckViewItem( hmenu );
        } else {
            PrintHintTextByID( WIE_USEOPTIONSTOHIDEALL, NULL );
        }
        break;

    case WM_DESTROY:
        hViewWindow = NULL;
        break;

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

} /* ViewWindowProc */
Exemplo n.º 7
0
/*
 * CloseAllImages - used in the close all menu option
 */
void CloseAllImages( void )
{
    img_node    *head;
    img_node    *current;
    WPI_PARAM1  p1;
    HWND        parent;

    head = GetHeadNode();
    if( !head ) {
        PrintHintTextByID( WIE_NOIMAGESTOCLOSE, NULL );
        return;
    }

    current = head;
    while( current ) {
        if( !(current->issaved) ) {
            p1 = WPI_MAKEP1( current->hwnd, 0 );
            parent = _wpi_getparent( current->hwnd );
#ifdef __OS2_PM__
            _wpi_sendmessage(parent, WM_ACTIVATE, (WPI_PARAM1)p1, 0L);
#else
            _wpi_sendmessage( parent, WM_MDIRESTORE, (WPI_PARAM1)p1, 0L );
            _wpi_sendmessage(ClientWindow, WM_MDIACTIVATE, (WPI_PARAM1)p1, 0L);
#endif

            if( !(lastChanceSave(current)) ) {
                return;
            }
        }
        current = current->next;
    }

    DeleteActiveImage();
    while( head ) {
        closeTheImage( head );
        head = GetHeadNode();
    }

    ClearImageText();
    GrayEditOptions();
    PrintHintTextByID( WIE_ALLIMAGESCLOSED, NULL );
    _wpi_setwindowtext( _wpi_getframe(HMainWindow), IEAppTitle );
} /* CloseAllImages */
Exemplo n.º 8
0
/*
 * ClearImage - clear the XOR and the AND bitmaps
 */
void ClearImage( void )
{
    WPI_PRES            pres;
    WPI_PRES            xorpres;
    WPI_PRES            andpres;
    HDC                 xormemdc;
    HDC                 andmemdc;
    HBITMAP             oldxor;
    HBITMAP             oldand;
    img_node            *node;
    WPI_RECT            clear_area;
    IMGED_DIM           left;
    IMGED_DIM           top;
    IMGED_DIM           right;
    IMGED_DIM           bottom;
    int                 width;
    int                 height;

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

    if( DoesRectExist( &clear_area ) ) {
        SetRectExists( FALSE );
    } else {
        _wpi_setwrectvalues( &clear_area, 0, 0, node->width, node->height );
    }

    pres = _wpi_getpres( HWND_DESKTOP );
    xorpres = _wpi_createcompatiblepres( pres, Instance, &xormemdc );
    andpres = _wpi_createcompatiblepres( pres, Instance, &andmemdc );
    _wpi_releasepres( HWND_DESKTOP, pres );

    oldxor = _wpi_selectobject( xorpres, node->hxorbitmap );
    oldand = _wpi_selectobject( andpres, node->handbitmap );

    _wpi_getwrectvalues( clear_area, &left, &top, &right, &bottom );
    width = _wpi_getwidthrect( clear_area );
    height = _wpi_getheightrect( clear_area );

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

    _wpi_selectobject( xorpres, oldxor );
    _wpi_selectobject( andpres, oldand );
    _wpi_deletecompatiblepres( xorpres, xormemdc );
    _wpi_deletecompatiblepres( andpres, andmemdc );

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

} /* ClearImage */
Exemplo n.º 9
0
/*
 * DontPaste - when escape is hit while dragging the image to paste
 */
void DontPaste( HWND hwnd, WPI_POINT *topleft, WPI_POINT pointsize )
{
    firstTime = true;
    DragClipBitmap( hwnd, topleft, pointsize );
    _wpi_setcursor( prevCursor );
    _wpi_destroycursor( pointCursor );
    ReleaseCapture();
    SetToolType( prevToolType );
    PrintHintTextByID( WIE_PASTECANCELLED, NULL );

} /* DontPaste */
Exemplo n.º 10
0
/*
 * PlaceAndPaste - find out where the image is to be placed and then paste it there
 */
void PlaceAndPaste( void )
{
    HBITMAP         hbitmap;
    WPI_POINT       pointsize;
    img_node        *node;
    WPI_POINT       pt;
    unsigned long   format;
    int             bm_width;
    int             bm_height;

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

    if( !_wpi_isclipboardformatavailable( Instance, CF_BITMAP, &format ) ) {
        PrintHintTextByID( WIE_NOBITMAPINCLIPBOARD, NULL );
        return;
    }

    pointsize = GetPointSize( node->hwnd );
    if( fEnableCutCopy ) {
        RedrawPrevClip( node->hwnd );
        PasteImage( NULL, pointsize, node->hwnd );
        fEnableCutCopy = FALSE;
        return;
    }

    prevToolType = SetToolType( IMGED_PASTE );
    pointCursor = _wpi_loadcursor( Instance, POINT_CUR );
    prevCursor = _wpi_setcursor( pointCursor );

    _wpi_openclipboard( Instance, HMainWindow );
    hbitmap = _wpi_getclipboarddata( Instance, CF_BITMAP );
    _wpi_getbitmapdim( hbitmap, &bm_width, &bm_height );
    _wpi_closeclipboard( Instance );

    dragWidth = (short)(bm_width * pointsize.x);
    dragHeight = (short)(bm_height * pointsize.y);
    WriteSetSizeText( WIE_CLIPBOARDBITMAPSIZE, bm_width, bm_height);

    _wpi_getcursorpos( &pt );
    _wpi_screentoclient( node->hwnd, &pt );
    pt.x = pt.x / pointsize.x;
    pt.y = pt.y / pointsize.y;
    _wpi_setcapture( node->hwnd );
    firstTime = true;
    DragClipBitmap( node->hwnd, &pt, pointsize );

} /* PlaceAndPaste */
Exemplo n.º 11
0
/*
 * TransferImage - transfer the image in the outlined box to the view window
 */
void TransferImage( HWND hwnd )
{
    POINT       topleft_desk;
    HDC         hdc;
    HDC         memdc;
    HBITMAP     oldbitmap;
    img_node    *node;

#ifdef __NT__
    SetDeskTopHook( NULL );
#endif
    redrawPrevRegion();

    GetCursorPos( &topleft_desk );
    node = SelectImage( hwnd );
    hdc = GetDC( NULL );
    memdc = CreateCompatibleDC( hdc );

    oldbitmap = SelectObject( memdc, node->handbitmap );
    PatBlt( memdc, topLeft.x, topLeft.y, snapWidth, snapHeight, BLACKNESS );

    SelectObject( memdc, node->hxorbitmap );
    BitBlt( memdc, topLeft.x, topLeft.y, snapWidth, snapHeight, hdc,
            topleft_desk.x, topleft_desk.y, SRCCOPY );
    ReleaseDC( NULL, hdc );
    SelectObject( memdc, oldbitmap );
    DeleteDC( memdc );
    ReleaseCapture();
    ShowWindow( HMainWindow, previousState );

#ifdef __NT__
    DestroyWindow( deskTopWindow );
#else
    InvalidateRect( node->viewhwnd, NULL, FALSE );
#endif
    RecordImage( hwnd );

    SetToolType( prevToolType );
    if( !DoKeepRect() ) {
        SetRectExists( FALSE );
    } else {
        SetRectExists( rectExists );
    }
#ifndef __NT__
    BlowupImage( node->hwnd, NULL );
#endif
    SetCursor( prevCursor );
    PrintHintTextByID( WIE_BMPSNAPPEDFROMDSKTOP, NULL );

} /* TransferImage */
Exemplo n.º 12
0
/*
 * doReadCursor
 */
BOOL doReadCursor( char *fname, an_img_file *cursorfile, an_img *cursor,
                   WRInfo *info, WResLangNode *lnode )
{
    img_node            node;
    HDC                 hdc;
    char                filename[_MAX_FNAME + _MAX_EXT];

    if( cursorfile == NULL || cursor == NULL ) {
        return( FALSE );
    }

    GetFnameFromPath( fname, filename );

    node.imgtype = CURSOR_IMG;
    node.width = cursor->bm->bmiHeader.biWidth;
    node.height = cursor->bm->bmiHeader.biHeight;
    if( node.height == 0 ) {
        node.height = node.width;
    }
    node.bitcount = cursor->bm->bmiHeader.biBitCount;
    node.hotspot.x = cursorfile->resources->xhotspot;
    node.hotspot.y = cursorfile->resources->yhotspot;
    node.issaved = TRUE;
    node.num_of_images = 1;
    node.next = NULL;
    node.nexticon = NULL;
    node.wrinfo = info;
    node.lnode = lnode;

    hdc = GetDC( NULL );
    node.handbitmap = ImgToAndBitmap( hdc, cursor );
    node.hxorbitmap = ImgToXorBitmap( hdc, cursor );
    ReleaseDC( NULL, hdc );

    strcpy( node.fname, strupr( fname ) );
    ImageFini( cursor );
    ImageClose( cursorfile );

    PrintHintTextByID( WIE_OPENEDTEXT, filename );
    MakeIcon( &node, FALSE );           // also makes cursors
    CreateNewDrawPad( &node );

    return( TRUE );

} /* doReadCursor */
Exemplo n.º 13
0
/*
 * LoadColorPalette - load a palette
 */
BOOL LoadColorPalette( void )
{
    char                fname[_MAX_PATH];
    char                filename[_MAX_FNAME + _MAX_EXT];
    a_pal_file          *pal_file;
    FILE                *fp;
    WORD                file_type;

    if( !getOpenPalName( fname ) ) {
        if( CommDlgExtendedError() == FNERR_INVALIDFILENAME ) {
            WImgEditError( WIE_ERR_BAD_FILENAME, fname );
            return( FALSE );
        }
        return( TRUE );
    }

    pal_file = MemAlloc( sizeof( a_pal_file ) );
    fp = fopen( fname, "rb" );
    if( fp == NULL ) {
        WImgEditError( WIE_ERR_FILE_NOT_OPENED, fname );
        return( FALSE );
    }

    GetFnameFromPath( fname, filename );

    fseek( fp, 0L, SEEK_SET );
    fread( &file_type, sizeof( WORD ), 1, fp );
    if( file_type != PALETTE_FILE ) {
        WImgEditError( WIE_ERR_BAD_PALFILE, filename );
        fclose( fp );
        return( FALSE );
    }

    fseek( fp, 0L, SEEK_SET );
    fread( pal_file, sizeof( a_pal_file ), 1, fp );

    fclose( fp );
    SetNewPalette( pal_file );
    PrintHintTextByID( WIE_PALETTELOADEDFROM, filename );

    MemFree( pal_file );
    return( TRUE );

} /* LoadColorPalette */
Exemplo n.º 14
0
/*
 * ChooseBkColor - choose the color to represent the background
 */
void ChooseBkColor( void )
{
    WPI_DLGPROC         dlgproc;
    WPI_DLGRESULT       button_type;

    screenColor.color = GetViewBkColor();
    dlgproc = _wpi_makedlgprocinstance( SelColorDlgProc, Instance );
    button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, SELBKCOLOR, 0L );
    _wpi_freedlgprocinstance( dlgproc );

    if( button_type == IDCANCEL ) {
        return;
    }

    SetViewBkColor( screenColor.color );
    SetScreenClr( screenColor.color );
    PrintHintTextByID( WIE_NEWBKCOLORSELECTED, NULL );

} /* ChooseBkColor */
Exemplo n.º 15
0
/*
 * EditColors - edit the current color selection
 */
void EditColors( void )
{
    static CHOOSECOLOR          choosecolor;
    BOOL                        setcolor = FALSE;
    wie_clrtype                 type;
    COLORREF                    current_color;
    HMENU                       hmenu;
    HWND                        parent;

    if( ImgedConfigInfo.show_state & SET_SHOW_CLR ) {
        parent = HColorPalette;
    } else {
        parent = HMainWindow;
    }

    current_color = GetSelectedColor( LMOUSEBUTTON, NULL, &type );

    choosecolor.lStructSize = sizeof( CHOOSECOLOR );
    choosecolor.hwndOwner = parent;
    choosecolor.hInstance = NULL;
    choosecolor.rgbResult = current_color;
    choosecolor.lpCustColors = (LPDWORD)customcolors;
    choosecolor.Flags = CC_RGBINIT | CC_FULLOPEN;
    choosecolor.lCustData = 0l;
    choosecolor.lpfnHook = 0;
    choosecolor.lpTemplateName = (LPSTR)NULL;

    setcolor = ChooseColor( &choosecolor );

    if( !setcolor ) {
        return;
    }

    ReplacePaletteEntry( choosecolor.rgbResult );
    fRestEnabled = TRUE;
    hmenu = GetMenu( HMainWindow );
    EnableMenuItem( hmenu, IMGED_CRESET, MF_ENABLED );

    PrintHintTextByID( WIE_COLORPALETTEMODIFIED, NULL );

} /* EditColors */
Exemplo n.º 16
0
/*
 * AbortSnap - abort the snapping of an image
 */
void AbortSnap( HWND hwnd )
{
    img_node    *node;

#ifdef __NT__
    SetDeskTopHook( NULL );
#endif

    node = SelectImage( hwnd );
    ReleaseCapture();
    ShowWindow( HMainWindow, previousState );

#ifdef __NT__
    DestroyWindow( deskTopWindow );
#else
    InvalidateRect( node->viewhwnd, NULL, FALSE );
#endif

    SetToolType( prevToolType );
    SetCursor( prevCursor );
    PrintHintTextByID( WIE_BMPSNAPABORTED, NULL );

} /* AbortSnap */
Exemplo n.º 17
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 */
Exemplo n.º 18
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 */
Exemplo n.º 19
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 */
Exemplo n.º 20
0
/*
 * lastChanceSave - is called when the user quits and the current image
 *                  is not yet saved.  Returns FALSE if CANCEL
 *                  is selected, otherwise, it returns TRUE.
 */
static BOOL lastChanceSave( img_node *node )
{
    int         retcode;
    int         how;
    HMENU       hmenu;
    char        *title;
    char        *text;
    char        *msg_text;
    char        filename[ _MAX_PATH ];

    if( !node ) return( TRUE );

    IECheckIfActiveWindow();
    if( strnicmp( node->fname, IEImageUntitled, strlen( IEImageUntitled ) ) != 0 ) {
        GetFnameFromPath( node->fname, filename );
        how = SB_SAVE;
    } else {
        strcpy( filename, node->fname );
        how = SB_SAVE_AS;
    }

    retcode = IDCANCEL;
    title = IEAllocRCString( WIE_EXITTITLE );
    if( ImgedIsDDE ) {
        text = IEAllocRCString( WIE_QUERYIMAGEUPDATE );
    } else {
        text = IEAllocRCString( WIE_QUERYIMAGESAVE );
    }
    if( text ) {
        msg_text = (char *)MemAlloc( strlen( text ) + strlen( filename ) + 1 );
        if( msg_text ) {
            sprintf( msg_text, text, filename );
            retcode = _wpi_messagebox( HMainWindow, msg_text, title,
                                       MB_YESNOCANCEL | MB_ICONQUESTION );
            MemFree( msg_text );
        }
        IEFreeRCString( text );
    }
    if( title ) {
        IEFreeRCString( title );
    }

    if (retcode == IDYES) {
        if( ImgedIsDDE ) {
#ifndef __OS2_PM__
            if( IEUpdateDDEEditSession() ) {
                SetIsSaved( node->hwnd, TRUE );
            } else {
                PrintHintTextByID( WIE_FILENOTSAVED, NULL );
                return( FALSE );
            }
#else
            PrintHintTextByID( WIE_FILENOTSAVED, NULL );
            return( FALSE );
#endif
        } else {
            if (!SaveFile( how )) {
                PrintHintTextByID( WIE_FILENOTSAVED, NULL );
                return( FALSE );
            } else {
                hmenu = _wpi_getmenu( HMainWindow );
                _wpi_enablemenuitem( hmenu, IMGED_SAVE, FALSE, FALSE );
                SetIsSaved( node->hwnd, TRUE );
            }
        }
    } else if (retcode == IDCANCEL) {
        return (FALSE);
    }
    return (TRUE);
} /* lastChanceSave */
Exemplo n.º 21
0
/*
 * RestoreColors - restore the original color palette
 */
void RestoreColors( void )
{
    ResetColorPalette();
    PrintHintTextByID( WIE_COLORPALETTERESTORED, NULL );

} /* RestoreColors */
Exemplo n.º 22
0
/*
 * ImgEdFrameProc - handle messages for the image editor application
 */
WPI_MRESULT CALLBACK ImgEdFrameProc( HWND hwnd, WPI_MSG msg,
                                 WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    static BOOL         window_destroyed = FALSE;
    static HMENU        hmenu;
    ctl_id              cmdid;
    img_node            *node;
    WPI_RECT            rcmain;
#ifndef __OS2_PM__
    about_info          ai;
#endif
    WPI_RECTDIM         left, top;

    if( !window_destroyed ) {
        enableMainItems( hmenu );
    }

    switch( msg ) {
    case UM_EXIT:
        _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L );
        /* fall through */

    case UM_EXIT_NO_SAVE:
        if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) {
            break;
        }
#ifndef __OS2_PM__
        _wpi_destroywindow( _wpi_getframe( hwnd ) );
#else
        _wpi_sendmessage( hwnd, WM_CLOSE, 0, 0 );
#endif

        break;

    case UM_SAVE_ALL:
        SaveAllImages();
        break;

    case WM_CREATE:
        hmenu = _wpi_getmenu( _wpi_getframe( hwnd ) );
#ifndef __OS2_PM__
        createClientWindow( hwnd );
#endif
        if( !InitStatusLine( hwnd ) ) {
            return( -1 );
        }

        InitFunctionBar( hwnd );
        InitIconInfo();
        InitializeCursors();

        /*
         * Set values from profile information ...
         */
        if( ImgedConfigInfo.brush_size <= 5 && ImgedConfigInfo.brush_size >= 2 ) {
            checkBrushItem( hmenu, IMGED_2x2 - 2 + ImgedConfigInfo.brush_size );
        }
        if( ImgedConfigInfo.grid_on ) {
            CheckGridItem( hmenu );
        }
        if( ImgedConfigInfo.square_grid ) {
            CheckSquareGrid( hmenu );
        }
        if( ImgedConfigInfo.show_state & SET_SHOW_VIEW ) {
            CheckViewItem( hmenu );
        }

        _wpi_enablemenuitem( hmenu, IMGED_CRESET, FALSE, FALSE );
        _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, FALSE, FALSE );
#ifndef __OS2_PM__
        // not necessary for PM
        InitMenus( hmenu );
#endif
        SetHintText( IEAppTitle );
        return( 0 );
#ifdef __NT__
    case WM_DROPFILES:
        OpenImage( (HANDLE)wparam );
        break;
#endif
    case WM_MOVE:
        _wpi_getwindowrect( hwnd, &rcmain );
        if( !ImgedConfigInfo.ismaximized ) {
            ImgedConfigInfo.last_xpos = ImgedConfigInfo.x_pos;
            ImgedConfigInfo.last_ypos = ImgedConfigInfo.y_pos;
            _wpi_getrectvalues( rcmain, &left, &top, NULL, NULL );
            ImgedConfigInfo.x_pos = (short)left;
            ImgedConfigInfo.y_pos = (short)top;
        }
        return( 0 );

    case WM_SIZE:
        ResizeFunctionBar( lparam );
        ResizeStatusBar( lparam );
#ifndef __OS2_PM__
        if( ClientWindow != NULL ) {
            setClientSize( hwnd );
        }
#else
        resizeClientArea( lparam );
#endif

        if( !_imgwpi_issizeminimized( wparam ) && !_imgwpi_issizemaximized( wparam ) ) {
            _wpi_getwindowrect( hwnd, &rcmain );
            ImgedConfigInfo.width = (short)_wpi_getwidthrect( rcmain );
            ImgedConfigInfo.height = (short)_wpi_getheightrect( rcmain );
            ImgedConfigInfo.ismaximized = FALSE;
        } else {
            ImgedConfigInfo.x_pos = ImgedConfigInfo.last_xpos;
            ImgedConfigInfo.y_pos = ImgedConfigInfo.last_ypos;
            ImgedConfigInfo.ismaximized = _imgwpi_issizemaximized( wparam );
        }
        return( FALSE );

    case WM_MENUSELECT:
#ifndef __OS2_PM__
        if( GET_WM_MENUSELECT_FLAGS( wparam, lparam ) & MF_SEPARATOR ) {
            break;
        }
        if( GET_WM_MENUSELECT_FLAGS( wparam, lparam ) & MF_SYSMENU ) {
            PrintHintTextByID( WIE_SYSMENUOPERATIONS, NULL );
            break;
        }
#endif
        ShowHintText( LOWORD( wparam ) );
        break;

    case WM_COMMAND:
        cmdid = LOWORD( wparam );
        if( !IEIsMenuIDValid( hmenu, cmdid ) ) {
            break;
        }
        switch( cmdid ) {
        case IMGED_NEW:
            if( !ImgedIsDDE ) {
                if( !NewImage( UNDEF_IMG, NULL ) ) {
                    PrintHintTextByID( WIE_NEIMAGENOTCREATED, NULL );
                }
            }
            break;

        case IMGED_CLOSE:
            node = GetCurrentNode();
            if( node != NULL ) {
                _wpi_sendmessage( node->hwnd, WM_CLOSE, 0, 0L );
            }
            break;

        case IMGED_CLOSEALL:
            CloseAllImages();
            break;

        case IMGED_HELP:
            IEHelpRoutine();
            break;

        case IMGED_HELP_SEARCH:
            IEHelpSearchRoutine();
            break;

        case IMGED_HELP_ON_HELP:
            IEHelpOnHelpRoutine();
            break;

        case IMGED_ABOUT:
#ifndef __OS2_PM__
            ai.owner = hwnd;
            ai.inst = Instance;
            ai.name = IEAllocRCString( WIE_ABOUTTEXT );
            ai.version = IEAllocRCString( WIE_ABOUTVERSION );
            ai.title = IEAllocRCString( WIE_ABOUTTITLE );
            DoAbout( &ai );
            if( ai.name != NULL ) {
                IEFreeRCString( ai.name );
            }
            if( ai.version != NULL ) {
                IEFreeRCString( ai.version );
            }
            if( ai.title != NULL ) {
                IEFreeRCString( ai.title );
            }
#endif
            break;

#ifndef __OS2_PM__
        case IMGED_DDE_UPDATE_PRJ:
            IEUpdateDDEEditSession();
            break;
#endif

        case IMGED_SAVE_AS:
            SaveFile( SB_SAVE_AS );
            break;

        case IMGED_SAVE:
            SaveFile( SB_SAVE );
            break;

        case IMGED_OPEN:
            if( !ImgedIsDDE ) {
                OpenImage( NULL );
            }
            break;

        case IMGED_CLEAR:
            ClearImage();
            break;

        case IMGED_NEWIMG:
            AddNewIcon();
            break;

        case IMGED_SELIMG:
            SelectIconImg();
            break;

        case IMGED_DELIMG:
            DeleteIconImg();
            break;

        case IMGED_UNDO:
            UndoOp();
            break;

        case IMGED_REDO:
            RedoOp();
            break;

        case IMGED_REST:
            RestoreImage();
            break;

        case IMGED_SNAP:
#ifndef __OS2_PM__
            SnapPicture();
#endif
            break;

        case IMGED_RIGHT:
        case IMGED_LEFT:
        case IMGED_UP:
        case IMGED_DOWN:
            ShiftImage( cmdid );
            break;

        case IMGED_FLIPHORZ:
        case IMGED_FLIPVERT:
            FlipImage( cmdid );
            break;

        case IMGED_ROTATECC:
        case IMGED_ROTATECL:
            RotateImage( cmdid );
            break;

        case IMGED_PASTE:
            PlaceAndPaste();
            break;

        case IMGED_COPY:
            IECopyImage();
            break;

        case IMGED_CUT:
            CutImage();
            break;

        case IMGED_COLOR:
            CheckPaletteItem( hmenu );
            break;

        case IMGED_VIEW:
            CheckViewItem( hmenu );
            break;

        case IMGED_TOOLBAR:
            CheckToolbarItem( hmenu );
            break;

        case IMGED_SQUARE:
            CheckSquareGrid( hmenu );
            break;

        case IMGED_SIZE:
            ChangeImageSize();
            break;

        case IMGED_GRID:
            CheckGridItem( hmenu );
            break;

        case IMGED_MAXIMIZE:
            MaximizeCurrentChild();
            break;

        case IMGED_SETTINGS:
            SelectOptions();
            break;

        case IMGED_2x2:
        case IMGED_3x3:
        case IMGED_4x4:
        case IMGED_5x5:
            checkBrushItem( hmenu, cmdid );
            break;

        case IMGED_CEDIT:
#ifndef __OS2_PM__
            EditColors();
#endif
            break;

        case IMGED_CRESET:
#ifndef __OS2_PM__
            RestoreColors();
#endif
            break;

        case IMGED_CSCREEN:
            ChooseBkColor();
            break;

        case IMGED_SCOLOR:
#ifndef __OS2_PM__
            SaveColorPalette();
#endif
            break;

        case IMGED_LCOLOR:
#ifndef __OS2_PM__
            if( LoadColorPalette() ) {
                _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, TRUE, FALSE );
            }
#endif
            break;

        case IMGED_RCOLOR:
            RestoreColorPalette();
            break;

        case IMGED_FREEHAND:
        case IMGED_LINE:
        case IMGED_RECTO:
        case IMGED_RECTF:
        case IMGED_CIRCLEO:
        case IMGED_CIRCLEF:
        case IMGED_FILL:
        case IMGED_BRUSH:
        case IMGED_CLIP:
        case IMGED_HOTSPOT:
            SetToolType( cmdid );
            PushToolButton( cmdid );
            break;

        case IMGED_ARRANGE:
#ifndef __OS2_PM__
            SendMessage( ClientWindow, WM_MDIICONARRANGE, 0, 0L );
#endif
            break;

        case IMGED_TILE:
#ifndef __OS2_PM__
            SendMessage( ClientWindow, WM_MDITILE, MDITILE_VERTICAL, 0L );
#endif
            break;

        case IMGED_CASCADE:
#ifndef __OS2_PM__
            SendMessage( ClientWindow, WM_MDICASCADE, MDITILE_SKIPDISABLED, 0L );
#endif
            break;

        case IMGED_EXIT:
            _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L );

            if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) {
                break;
            }
#ifndef __OS2_PM__
            _wpi_destroywindow( _wpi_getframe( hwnd ) );
#else
            _wpi_sendmessage( hwnd, WM_CLOSE, 0, 0 );
#endif
            break;

        default:
#if 1
            return( _imgwpi_defframeproc( hwnd, ClientWindow, msg, wparam, lparam ) );
#else
            return( 0 );
#endif
        }
        return( 0 );

#ifndef __OS2_PM__
    case WM_COMPACTING:
        RelieveUndos();
        return 0;
#endif

    case WM_QUERYENDSESSION:
        if( _wpi_isiconic( _wpi_getframe( hwnd ) ) ) {
            if( ImgedConfigInfo.ismaximized ) {
                _wpi_maximizewindow( _wpi_getframe( hwnd ) );
            } else {
                _wpi_showwindow( _wpi_getframe( hwnd ), SW_SHOWNORMAL );
            }
        }
        _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L );

        if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) {
            return( 0 );
        }
        return( (WPI_MRESULT)1 );

    case WM_CLOSE:
        // wParam is non-zero if the DDE connection died
        if( !wparam && !ImgEdEnableMenuInput ) {
            // this prevents the user from closing the editor during
            // DDE initialization
            return( 0 );
        }
        _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L );
#ifdef __OS2_PM__
        return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
#else

        if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) {
            return( 0 );
        }
        window_destroyed = TRUE;
        _wpi_destroywindow( _wpi_getframe( hwnd ) );
        return( 0 );
#endif

    case WM_DESTROY:
#ifndef __OS2_PM__
        WWinHelp( HMainWindow, "resimg.hlp", HELP_QUIT, 0 );
#endif
        FiniStatusLine();
        CleanupClipboard();
        CleanupCursors();
        CloseToolBar();
        CloseFunctionBar();
        _wpi_deletefont( SmallFont );
        _wpi_postquitmessage( 0 );
        return( 0 );
    default:
        break;
    }
    return( _imgwpi_defframeproc( hwnd, ClientWindow, msg, wparam, lparam ) );

} /* ImgEdFrameProc */
Exemplo n.º 23
0
/*
 * doReadInBitmapFile
 */
static BOOL doReadInBitmapFile( HBITMAP hbitmap, bitmap_info *bmi, char *fullname,
                                WRInfo *info, WResLangNode *lnode )
{
    HBITMAP             oldbmp1;
    HBITMAP             oldbmp2;
    img_node            node;
    char                filename[_MAX_FNAME + _MAX_EXT];
    BITMAPINFOHEADER    *h;
    HDC                 hdc;
    HDC                 srcdc;
    HDC                 destdc;

    GetFnameFromPath( fullname, filename );

    if( hbitmap != NULL ) {
        h = &bmi->u.bm_info->bmiHeader;

        if( h->biWidth > MAX_DIM || h->biHeight > MAX_DIM ) {
            WImgEditError( WIE_ERR_BITMAP_TOO_BIG, filename );
            MemFree( bmi->u.bm_info );
            DeleteObject( hbitmap );
            return( FALSE );
        }

#if 0
        /* Should not be an error... */
        else if( h->biBitCount > 8 ) {
            WImgEditError( WIE_ERR_TOO_MANY_COLOURS, filename );
            MemFree( bmi->u.bm_info );
            DeleteObject( hbitmap );
            return( FALSE );
        }
#endif
        node.imgtype = BITMAP_IMG;
        node.width = bmi->u.bm_info->bmiHeader.biWidth;
        node.height = bmi->u.bm_info->bmiHeader.biHeight;
        node.bitcount = bmi->u.bm_info->bmiHeader.biBitCount;
        node.hotspot.x = 0;
        node.hotspot.y = 0;
        node.num_of_images = 1;
        node.nexticon = NULL;
        node.issaved = TRUE;
        if( node.bitcount == 1 ) {
            hdc = GetDC( NULL );
            srcdc = CreateCompatibleDC( hdc );
            destdc = CreateCompatibleDC( hdc );
            ReleaseDC( NULL, hdc );

            node.hxorbitmap = CreateCompatibleBitmap( destdc, node.width, node.height );
            oldbmp1 = SelectObject( srcdc, hbitmap );
            oldbmp2 = SelectObject( destdc, node.hxorbitmap );
            BitBlt( destdc, 0, 0, node.width, node.height, srcdc, 0, 0, SRCCOPY );
            SelectObject( srcdc, oldbmp1 );
            SelectObject( destdc, oldbmp2 );
            DeleteDC( srcdc );
            DeleteDC( destdc );
            DeleteObject( hbitmap );
        } else {
            node.hxorbitmap = hbitmap;
        }

        strcpy( node.fname, fullname );
        PrintHintTextByID( WIE_OPENEDTEXT, filename );

        node.wrinfo = info;
        node.lnode = lnode;

        MakeBitmap( &node, FALSE );
        CreateNewDrawPad( &node );

        MemFree( bmi->u.bm_info );
        return( TRUE );
    }
    return( FALSE );

} /* doReadInBitmapFile */
Exemplo n.º 24
0
/*
 * RestoreColorPalette - restore the color palette to the hard-coded colors
 *                       in the initialization routine
 */
void RestoreColorPalette( void )
{
    int         i;
    COLORREF    leftcolor;
    COLORREF    rightcolor;
    COLORREF    color;
    WPI_PRES    pres;
    int         leftindex;
    int         rightindex;
    wie_clrtype lefttype;
    wie_clrtype righttype;
    HMENU       hmenu;
    HWND        frame;

    if( currentPalIndex != COLOR_16 && currentPalIndex != COLOR_256 ) {
        return;
    }
    leftcolor = GetSelectedColor( LMOUSEBUTTON, NULL, &lefttype );
    rightcolor = GetSelectedColor( RMOUSEBUTTON, NULL, &righttype );

    leftindex = getColorIndex( leftcolor );
    rightindex = getColorIndex( rightcolor );

    InitPalette();
    for( i = 0; i < PALETTE_SIZE - 1; i++ ) {
        ShowNewColor( i, RGB( palette[currentPalIndex][i].rgbRed,
                              palette[currentPalIndex][i].rgbGreen,
                              palette[currentPalIndex][i].rgbBlue ), FALSE );
    }
    /*
     * We do the last one separately to invalidate the window.
     */
    ShowNewColor( i, RGB( palette[currentPalIndex][i].rgbRed,
                          palette[currentPalIndex][i].rgbGreen,
                          palette[currentPalIndex][i].rgbBlue ), TRUE );

    if( lefttype == NORMAL_CLR ) {
        color = RGB( palette[currentPalIndex][leftindex].rgbRed,
                     palette[currentPalIndex][leftindex].rgbGreen,
                     palette[currentPalIndex][leftindex].rgbBlue );
        pres = _wpi_getpres( HWND_DESKTOP );
        _wpi_torgbmode( pres );
        SetColor( LMOUSEBUTTON, color, _wpi_getnearestcolor( pres, color ), NORMAL_CLR );
        _wpi_releasepres( HWND_DESKTOP, pres );
    }
    if( righttype == NORMAL_CLR ) {
        color = RGB( palette[currentPalIndex][rightindex].rgbRed,
                     palette[currentPalIndex][rightindex].rgbGreen,
                     palette[currentPalIndex][rightindex].rgbBlue );
        pres = _wpi_getpres( HWND_DESKTOP );
        _wpi_torgbmode( pres );
        SetColor( RMOUSEBUTTON, color, _wpi_getnearestcolor( pres, color ), NORMAL_CLR );
        _wpi_releasepres( HWND_DESKTOP, pres );
    }

    PrintHintTextByID( WIE_PALETTERESTORED, NULL );

    if( HMainWindow != NULL ) {
        frame = _wpi_getframe( _wpi_getframe( HMainWindow ) );
        hmenu = GetMenu( frame );
        _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, FALSE, FALSE );
    }

} /* RestoreColorPalette */
Exemplo n.º 25
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 */
Exemplo n.º 26
0
/*
 * lastChanceSave - called when the user quits and the current image
 *                  is not yet saved
 *                - return FALSE if CANCEL is selected
 *                - otherwise, it return TRUE
 */
static BOOL lastChanceSave( HWND hwnd )
{
    int         retcode;
    int         how;
    HMENU       hmenu;
    img_node    *node;
    img_node    *icon;
    char        *title;
    char        *text;
    char        *msg_text;
    char        filename[_MAX_PATH];

    if( !DoImagesExist() ) {
        return( TRUE );
    }

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

    icon = GetImageNode( hwnd );
    while( icon != NULL ) {
        if( icon->issaved ) {
            return( TRUE );
        }
        icon = icon->nexticon;
    }

    if( strnicmp( node->fname, IEImageUntitled, strlen( IEImageUntitled ) ) != 0 ) {
        GetFnameFromPath( node->fname, filename );
        how = SB_SAVE;
    } else {
        strcpy( filename, node->fname );
        how = SB_SAVE_AS;
    }

    retcode = WPI_IDCANCEL;
    title = IEAllocRCString( WIE_CLOSETITLE );
    text = IEAllocRCString( WIE_QUERYIMAGESAVE );
    if( text != NULL ) {
        msg_text = (char *)MemAlloc( strlen( text ) + strlen( filename ) + 1 );
        if( msg_text != NULL ) {
            sprintf( msg_text, text, filename );
            retcode = _wpi_messagebox( HMainWindow, msg_text, title,
                                       MB_YESNOCANCEL | MB_ICONQUESTION );
            MemFree( msg_text );
        }
        IEFreeRCString( text );
    }
    if( title != NULL ) {
        IEFreeRCString( title );
    }

    if( retcode == WPI_IDYES ) {
        if( !SaveFile( how ) ) {
            PrintHintTextByID( WIE_FILENOTSAVED, NULL );
            return( FALSE );
        } else {
            hmenu = _wpi_getmenu( _wpi_getframe( HMainWindow ) );
            _wpi_enablemenuitem( hmenu, IMGED_SAVE, FALSE, FALSE );
            SetIsSaved( hwnd, TRUE );
        }
    } else if( retcode == WPI_IDCANCEL ) {
        return( FALSE );
    }
    return( TRUE );

} /* lastChanceSave */