예제 #1
0
static void GUIDrawMenuBar( gui_window *wnd )
{
    if( wnd->root_frame != NULLHANDLE ) {
        if( _wpi_getmenu( wnd->root_frame ) != NULLHANDLE ) {
            _wpi_drawmenubar( wnd->root_frame );
        }
    } else {
        if( wnd->style & GUI_POPUP ) {
            if( _wpi_getmenu( wnd->hwnd_frame ) != NULLHANDLE ) {
                _wpi_drawmenubar( wnd->hwnd_frame );
            }
        }
    }
}
예제 #2
0
/*
 * GrayEditOptions - gray the edit options (at the beginning and when an
 *                   image is closed)
 */
void GrayEditOptions( void )
{
    HMENU       hmenu;

    if( HMainWindow == NULL ) {
        return;
    }
    hmenu = _wpi_getmenu( _wpi_getframe( HMainWindow ) );

    _wpi_enablemenuitem( hmenu, IMGED_UNDO, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_REDO, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_REST, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_CUT, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_COPY, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_PASTE, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_SNAP, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_CLEAR, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_NEWIMG, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_DELIMG, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_RIGHT, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_LEFT, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_UP, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_DOWN, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_FLIPHORZ, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_FLIPVERT, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_ROTATECC, FALSE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_ROTATECL, FALSE, FALSE );

} /* GrayEditOptions */
예제 #3
0
파일: wmdisim.c 프로젝트: hubei/open-watcom
/*
 * setMaximizedMenuConfig - set up main menu in the maximized configuration
 */
static void setMaximizedMenuConfig( HWND hwnd )
{
#ifndef __OS2_PM__
    HMENU       menu;
    HMENU       sys_menu;

    if( insertedItems ) {
        SetSystemMenu( hwnd );
    } else {
        getMenuBitmaps();
        menu = _wpi_getmenu( mdiInfo.root );
        insertedItems = TRUE;
        sys_menu = generateSystemMenu( hwnd );
        if( sys_menu != NULL ) {
            InsertMenu( menu, 0, MF_POPUP | MF_BYPOSITION | MF_BITMAP,
                        (UINT)sys_menu, (LPVOID)closeBitmap );
        } else {
            InsertMenu( menu, 0, MF_BYPOSITION | MF_BITMAP, -1, (LPVOID)closeBitmap );
        }
        InsertMenu( menu, -1, MF_HELP | MF_BYPOSITION | MF_BITMAP, SC_RESTORE,
                    (LPVOID)restoreBitmap );
        _wpi_drawmenubar( mdiInfo.root );
    }
#else
    hwnd = hwnd;
#endif

} /* setMaximizedMenuConfig */
예제 #4
0
파일: wmdisim.c 프로젝트: hubei/open-watcom
/*
 * SetSystemMenu -- make the system menu showing belong to the current window
 */
void SetSystemMenu( HWND hwnd )
{
    HMENU       sys_menu;
    HMENU       menu;

    sys_menu = NULLHANDLE;
    if( hwnd != NULLHANDLE ) {
        sys_menu = generateSystemMenu( hwnd );
    }
    menu = _wpi_getmenu( mdiInfo.root );
    getMenuBitmaps();
#ifndef __OS2_PM__
    if( sys_menu != NULL ) {
        ModifyMenu( menu, 0, MF_POPUP | MF_BYPOSITION | MF_BITMAP,
                    (UINT)sys_menu, (LPVOID)closeBitmap );
    } else {
        ModifyMenu( menu, 0, MF_BYPOSITION | MF_BITMAP, -1,
                    (LPVOID)closeBitmap );
    }
#else
    if( sys_menu != NULLHANDLE ) {
        _wpi_modifymenu( menu, 0, MF_POPUP | MF_STRING, 0, 0, sys_menu, "SYSMENU", TRUE );
    } else {
        _wpi_modifymenu( menu, 0, MF_STRING, 0, 0, NULLHANDLE, "SYSMENU", TRUE );
    }
#endif
    _wpi_drawmenubar( mdiInfo.root );

} /* SetSystemMenu */
예제 #5
0
HMENU GUIGetHMENU( gui_window *wnd )
{
    HMENU hmenu;

    if( wnd->root_frame == NULLHANDLE ) { /* child window */
        if( wnd->hwnd_frame == NULLHANDLE )
            return( NULLHANDLE );
        hmenu = _wpi_getsystemmenu( wnd->hwnd_frame );
    } else {
        hmenu = _wpi_getmenu( wnd->root_frame );
    }
    return( hmenu );
}
예제 #6
0
파일: wmdisim.c 프로젝트: hubei/open-watcom
/*
 * SetRestoreBitmap - set the bitmap on our restore menu item
 */
void SetRestoreBitmap( bool pressed )
{
    HMENU       menu;

    menu = _wpi_getmenu( mdiInfo.root );
    if( pressed ) {
        ModifyMenu( menu, 7, MF_BYPOSITION | MF_BITMAP | MF_HELP,
                    SC_RESTORE, (LPVOID) restoredBitmap );
    } else {
        ModifyMenu( menu, 7, MF_BYPOSITION | MF_BITMAP | MF_HELP,
                    SC_RESTORE, (LPVOID) restoreBitmap );
    }
    _wpi_drawmenubar( mdiInfo.root );

} /* SetRestoreBitmap */
예제 #7
0
/*
 * SetMenus - set the menu options for the new image
 */
void SetMenus( img_node *node )
{
    HMENU       hmenu;

    hmenu = _wpi_getmenu( _wpi_getframe( HMainWindow ) );
    _wpi_enablemenuitem( hmenu, IMGED_SNAP, TRUE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_CUT, TRUE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_COPY, TRUE, FALSE );
    _wpi_enablemenuitem( hmenu, IMGED_CLEAR, TRUE, FALSE );
#ifndef __OS2_PM__
    SetColorMenus( node );
#endif

    if( node->imgtype == BITMAP_IMG ) {
        DisplayScreenClrs( FALSE );
        AddHotSpotTool( FALSE );
        _wpi_enablemenuitem( hmenu, IMGED_NEWIMG, FALSE, FALSE );
        _wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE );
        _wpi_enablemenuitem( hmenu, IMGED_DELIMG, FALSE, FALSE );
        _wpi_enablemenuitem( hmenu, IMGED_SIZE, TRUE, FALSE );
    } else if( node->imgtype == ICON_IMG ) {
        DisplayScreenClrs( TRUE );
        AddHotSpotTool( FALSE );
        _wpi_enablemenuitem( hmenu, IMGED_SELIMG, TRUE, FALSE );
        if( node->num_of_images < NUM_OF_ICONS ) {
            _wpi_enablemenuitem( hmenu, IMGED_NEWIMG, TRUE, FALSE );
        } else {
            _wpi_enablemenuitem( hmenu, IMGED_NEWIMG, FALSE, FALSE );
        }
        if( node->num_of_images > 1 ) {
            _wpi_enablemenuitem( hmenu, IMGED_DELIMG, TRUE, FALSE );
            _wpi_enablemenuitem( hmenu, IMGED_SELIMG, TRUE, FALSE );
        } else {
            _wpi_enablemenuitem( hmenu, IMGED_DELIMG, FALSE, FALSE );
            _wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE );
        }
        _wpi_enablemenuitem( hmenu, IMGED_SIZE, FALSE, FALSE );
        SetIconInfo( node );
    } else if( node->imgtype == CURSOR_IMG ) {
        DisplayScreenClrs( TRUE );
        AddHotSpotTool( TRUE );
        _wpi_enablemenuitem( hmenu, IMGED_NEWIMG, FALSE, FALSE );
        _wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE );
        _wpi_enablemenuitem( hmenu, IMGED_DELIMG, FALSE, FALSE );
        _wpi_enablemenuitem( hmenu, IMGED_SIZE, FALSE, FALSE );
    }

} /* SetMenus */
예제 #8
0
파일: wmdisim.c 프로젝트: hubei/open-watcom
/*
 * deleteMaximizedMenuConfig - delete the maximized menu configuration
 */
static void deleteMaximizedMenuConfig( void )
{
    HMENU       root_menu;
    int         count;

    if( !insertedItems ) {
        return;
    }
    insertedItems = FALSE;
    root_menu = _wpi_getmenu( mdiInfo.root );
    _wpi_deletemenu( root_menu, 0, TRUE );
    count = (int)_wpi_getmenuitemcount( root_menu );
    _wpi_deletemenu( root_menu, count-1, TRUE );
    _wpi_drawmenubar( mdiInfo.root );

} /* deleteMaximizedMenuConfig */
예제 #9
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 */
예제 #10
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 */
예제 #11
0
/*
 * imgEditInit - initialization
 */
static BOOL imgEditInit( HAB hab )
{
    ULONG       flags;
    BOOL        maximized;
    HWND        frame;
    char        clientclass[] = { "IMGEDClientClass" };
    HWND        hwnd;
    WPI_RECT    rect;
    HMENU       hmenu;

    // Change this to use the querycaps routine
    ColourPlanes = 1;
    BitsPerPixel = 4;

    Instance.hab = hab;
    Instance.mod_handle = NULL;
    /*
     * set up window class
     */
    if (!WinRegisterClass( hab,
                           className,
                           (PFNWP)ImgEdFrameProc,
                           CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           clientclass,
                           (PFNWP)ClientProc,
                           CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           PaletteClass,
                           (PFNWP)ColourPalWinProc,
                           CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           CURRENT_CLASS,
                           (PFNWP)CurrentWndProc,
                           CS_SIZEREDRAW | CS_SYNCPAINT,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           AVAIL_CLASS,
                           (PFNWP)ColoursWndProc,
                           CS_SIZEREDRAW | CS_SYNCPAINT,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           SCREEN_CLASS,
                           (PFNWP)ScreenWndProc,
                           CS_SIZEREDRAW,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           DrawAreaClassB,
                           (PFNWP)DrawAreaWinProc,
                           CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPSIBLINGS,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           DrawAreaClassI,
                           (PFNWP)DrawAreaWinProc,
                           CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPSIBLINGS,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           DrawAreaClassC,
                           (PFNWP)DrawAreaWinProc,
                           CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPSIBLINGS,
                           0 )) {
        return( FALSE );
    }
    if (!WinRegisterClass( hab,
                           ViewWinClass,
                           (PFNWP)ViewWindowProc,
                           CS_MOVENOTIFY | CS_SIZEREDRAW | CS_CLIPCHILDREN,
                           0 )) {
        return( FALSE );
    }

    LoadImgedConfig();
    maximized = ImgedConfigInfo.ismaximized;
    InitPalette();
    /*
     * now make the main window
     */
    flags = FCF_TITLEBAR        |
            FCF_SIZEBORDER      |
            FCF_MINMAX          |
            FCF_SYSMENU         |
            FCF_TASKLIST        |
            FCF_ICON            |
            FCF_MENU;

    frame = WinCreateStdWindow(
        HWND_DESKTOP,
        0L,
        &flags,
        className,
        ImgEdName,
        0L,
        (HMODULE)0,
        IMGED_MAIN,
        &HMainWindow);

    WinSetWindowPos(frame, HWND_TOP, ImgedConfigInfo.x_pos,
                ImgedConfigInfo.y_pos, ImgedConfigInfo.width,
                ImgedConfigInfo.height, SWP_MOVE | SWP_SHOW | SWP_SIZE);

    _wpi_getclientrect( HMainWindow, &rect );
    flags = 0L;
    /*
     * N.B. - NOTE that ClientWindow is actually a FRAME WINDOW!!!!!  The
     *        name is a bit misleading and it is unlike HMainWindow which
     *        is a client window.
     */
    ClientWindow = WinCreateStdWindow( HMainWindow, 0L, &flags, clientclass,
                                        "", 0L, (HMODULE)0, 0, &hwnd);

    WinSetWindowPos(ClientWindow, HWND_TOP, 0, STATUS_WIDTH,
                _wpi_getwidthrect( rect ),
                _wpi_getheightrect(rect) -STATUS_WIDTH -FUNCTIONBAR_WIDTH -1,
                SWP_MOVE | SWP_SHOW | SWP_SIZE);

    CreateColourPal();
    InitFunctionBar( HMainWindow );
    InitTools( _wpi_getframe(HMainWindow) );

    hmenu = _wpi_getmenu( frame );
    if (ImgedConfigInfo.grid_on) {
        CheckGridItem(hmenu);
    }
    SetHintText("Open Watcom Image Editor.");
    WinSetFocus( HWND_DESKTOP, _wpi_getframe(HMainWindow) );
    return( TRUE );
} /* imgEditInit */
예제 #12
0
/*
 * SetToolType - set the tool type
 */
int SetToolType( int toolid )
{
    HMENU       hmenu;
    int         i;
    int         prev_tool;
    img_node    *node;

    if( toolType == IMGED_CLIP ) {
        node = GetCurrentNode();
        if( node != NULL ) {
            RedrawPrevClip( node->hwnd );
            SetRectExists( FALSE );
        }
    }

    prev_tool = toolType;
    toolType = toolid;

    if( toolid == IMGED_PASTE || toolid == IMGED_SNAP ) {
        return( prev_tool );
    }

    if( HMainWindow == NULL ) {
        return( 0 );
    }
    hmenu = _wpi_getmenu( _wpi_getframe( HMainWindow ) );

    switch( toolid ) {
    case IMGED_FREEHAND:
        setTheCursor( PENCIL_CUR, NULL );
        break;
    case IMGED_LINE:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_HOTSPOT:
        setTheCursor( HOTSPOT_CUR, NULL );
        break;
    case IMGED_RECTO:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_RECTF:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_CIRCLEO:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_CIRCLEF:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_FILL:
        setTheCursor( FILL_CUR, NULL );
        break;
    case IMGED_BRUSH:
        setTheCursor( BRUSH_CUR, NULL );
        if( prev_tool != IMGED_PASTE && prev_tool !=IMGED_SNAP ) {
            WriteSetSizeText( WIE_BRUSHSIZEIS, ImgedConfigInfo.brush_size,
                              ImgedConfigInfo.brush_size );
        }
        break;
    case IMGED_CLIP:
        setTheCursor( CROSS_CUR, NULL );
        break;

    default:
        setTheCursor( PENCIL_CUR, NULL );
        toolType = IMGED_FREEHAND;
        break;
    }

    for( i = IMGED_CLIP; i <= IMGED_HOTSPOT; i++ ) {
#if 0
        if( _wpi_isitemenabled( hmenu, i ) ) {
            _wpi_checkmenuitem( hmenu, i, FALSE, FALSE );
        }
#else
        if( _wpi_isitemchecked( hmenu, i ) ) {
            _wpi_checkmenuitem( hmenu, i, FALSE, FALSE );
        }
#endif
    }
    _wpi_checkmenuitem( hmenu, toolType, TRUE, FALSE );

    SetDrawTool( toolType );
    return( prev_tool );

} /* SetToolType */
예제 #13
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 */