Ejemplo n.º 1
0
/*
 * SaveFile - Saves the image file (bitmap, cursor or icon).
 */
bool SaveFile( short how )
{
    img_node    *node;
    img_node    *rootnode;
    char        new_name[ _MAX_PATH ];
    bool        ok;

    ok = false;
    node = GetCurrentNode();
    if( node == NULL )
        return( ok );
    rootnode = GetImageNode( node->hwnd );

    if( rootnode == NULL )
        return( ok );

    if( strnicmp(rootnode->fname, "(Untitled)", 10) == 0 ) {
        how = SB_SAVE_AS;
    }

    if( how == SB_SAVE_AS ) {
        if( !getSaveFName(new_name, rootnode->imgtype) ) {
            return( ok );
        }
        for( node = rootnode; node != NULL; node = node->nexticon ) {
            strcpy( node->fname, new_name );
        }
    }

    checkForExt( rootnode );

    switch( rootnode->imgtype ) {
    case BITMAP_IMG:
        ok = saveBitmapFile( rootnode );
        if( !ok )
            MessageBox(HMainWindow, "Error trying to save file!", "Error", MB_OK | MB_ICONEXCLAMATION);
        break;
    case ICON_IMG:
    case CURSOR_IMG:
        ok = saveImageFile( rootnode );
        if( !ok )
            MessageBox(HMainWindow, "Error trying to save file!", "Error", MB_OK | MB_ICONEXCLAMATION);
        break;
    }
    return( ok );
} /* SaveFile */
Ejemplo n.º 2
0
/*
 * IEGetCurrentImageNode
 */
static img_node *IEGetCurrentImageNode( void )
{
    img_node    *node;
    img_node    *root;

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

    root = GetImageNode( node->hwnd );
    if( root == NULL ) {
        return( NULL );
    }

    return( root );

} /* IEGetCurrentImageNode */
Ejemplo n.º 3
0
/*
 * ShowViewWindows - toggle the showing of multiple view windows
 */
void ShowViewWindows( HWND hwnd )
{
    img_node    *node;

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

    if( fOneViewWindow ) {
        if( hViewWindow != node->viewhwnd ) {
            ShowWindow( node->viewhwnd, SW_HIDE );
        } else {
            ShowWindow( node->viewhwnd, showState );
        }
    } else {
        ShowWindow( node->viewhwnd, showState );
    }

} /* ShowViewWindows */
Ejemplo n.º 4
0
/*
 * SetIsSaved - set whether the given MDI child has been saved
 */
void SetIsSaved( HWND hwnd, BOOL fissaved )
{
    img_node    *node;
    img_node    *next_icon;
    char        fname[_MAX_FNAME];
    char        dir[_MAX_DIR];
    char        ext[_MAX_EXT];
    char        drive[_MAX_DRIVE];
    char        title[_MAX_EXT + _MAX_FNAME + 2];
    char        *main_title;

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

    // We do not check whether or not the image needs to have its
    // title bars updated here because sometimes we will save images
    // that are not modified to different files.
#if 0
    if( fissaved == node->issaved ) {
        return;
    }
#endif

    next_icon = node;
    while( next_icon != NULL ) {
        next_icon->issaved = fissaved;
        next_icon = next_icon->nexticon;
    }

    if( fissaved ) {
        _wpi_getwindowtext( _wpi_getframe( node->hwnd ), title, sizeof( title ) );
        if( strnicmp( title, IEImageUntitled, strlen( IEImageUntitled ) ) == 0 &&
            strnicmp( node->fname, IEImageUntitled, strlen( IEImageUntitled ) ) == 0 ) {
            return;
        }
        _splitpath( node->fname, drive, dir, fname, ext );

        strcpy( title, strupr( fname ) );
        strcat( title, strupr( ext ) );
        _wpi_setwindowtext( _wpi_getframe( node->hwnd ), (LPSTR)title );

        main_title = (char *)MemAlloc( strlen( IEAppTitle ) + strlen( title ) + 3 + 1 );
        if( main_title != NULL ) {
            strcpy( main_title, IEAppTitle );
            strcat( main_title, " - " );
            strcat( main_title, title );
            _wpi_setwindowtext( HMainWindow, main_title );
            MemFree( main_title );
        }
    } else {
        _wpi_getwindowtext( _wpi_getframe( node->hwnd ), title, sizeof( title ) );
        if( strnicmp( title, IEImageUntitled, strlen( IEImageUntitled ) ) == 0 ) {
            return;
        } else if( title[strlen( title ) - 1] == '*' ) {
            return;
        } else {
            strcat( title, "*" );
            _wpi_setwindowtext( _wpi_getframe( node->hwnd ), (LPSTR)title );
        }
    }

} /* SetIsSaved */
Ejemplo n.º 5
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 */