Exemplo n.º 1
0
/*
 * RePositionViewWnd - reposition the size of the window (for when a
 *                     different icon is selected)
 */
void RePositionViewWnd( img_node *node )
{
    WPI_RECT    location;
    int         h_adj;
    int         v_adj;
    WPI_RECTDIM left;
    WPI_RECTDIM top;
    WPI_RECTDIM right;
    WPI_RECTDIM bottom;
    HWND        frame;
    
    frame = _wpi_getframe( node->viewhwnd );
    _wpi_getwindowrect( frame, &location );

    h_adj = 2 * _wpi_getsystemmetrics( SM_CXDLGFRAME ) + 2 * BORDER_WIDTH;
    v_adj = 2 * _wpi_getsystemmetrics( SM_CYDLGFRAME ) +
#ifndef __NT__
                _wpi_getsystemmetrics( SM_CYCAPTION ) + 2 * BORDER_WIDTH - 1;
#else
                _wpi_getsystemmetrics( SM_CYSMCAPTION ) + 2 * BORDER_WIDTH - 1;
#endif
    _wpi_getrectvalues( location, &left, &top, &right, &bottom );
#ifdef __OS2_PM__
    SetWindowPos( frame, NULL, left, bottom, h_adj + node->width, v_adj + node->height,
                 SWP_SIZE | SWP_MOVE | SWP_NOZORDER | SWP_HIDEWINDOW );
#else
    SetWindowPos( node->viewhwnd, NULL, left, top, h_adj + node->width, v_adj + node->height,
                 SWP_SIZE | SWP_MOVE | SWP_NOZORDER | SWP_HIDEWINDOW );
#endif
    hViewWindow = node->viewhwnd;
    ShowWindow( frame, showState );
    SetFocus( HMainWindow );
    InvalidateRect( hViewWindow, NULL, TRUE );

} /* RePositionViewWnd */
Exemplo n.º 2
0
bool GUIWndInit( unsigned DClickInterval, gui_window_styles style )
{
    GUIMemOpen();
    Style = style;
    GUISysInit( 0 );
    _wpi_setdoubleclicktime( DClickInterval );
    GUISetScreen( 0, 0, _wpi_getsystemmetrics( SM_CXSCREEN ),
                        _wpi_getsystemmetrics( SM_CYSCREEN ) );
    GUIInitDialog();
    return( TRUE );
}
Exemplo n.º 3
0
/*
 * CalculateDims - calculate the size of the "pixel" in the drawing
 *                 area and establish the device draw area size
 */
void CalculateDims( short img_width, short img_height, short *area_width,
                    short *area_height )
{
    int         point_size1;
    int         point_size2;
    int         max_width;
    int         max_height;
    WPI_RECT    rcclient;
    int         x_adj;
    int         y_adj;

    GetClientRect( ClientWindow, &rcclient );
    x_adj = (short)(2 * _wpi_getsystemmetrics( SM_CXFRAME ));
    y_adj = (short)(2 * _wpi_getsystemmetrics( SM_CYFRAME ) +
                        _wpi_getsystemmetrics( SM_CYCAPTION ));

#if 0
    max_width = _wpi_getwidthrect( rcclient ) - x_adj - origin->x;
    max_height = _wpi_getheightrect( rcclient ) - y_adj - origin->y;
#else
    max_width = _wpi_getwidthrect( rcclient ) - x_adj;
    max_height = _wpi_getheightrect( rcclient ) - y_adj;
#endif

    point_size1 = max( 1, max_width / img_width );
    point_size2 = max( 1, max_height / img_height );

    if( point_size1 < 1 ) {
        point_size1 = 1;
    }
    if( point_size2 < 1 ) {
        point_size2 = 1;
    }

    pointSize.x = min( point_size1, point_size2 );
    while( pointSize.x * img_width < MIN_DRAW_WIN_WIDTH ) {
        pointSize.x++;
    }

    pointSize.y = pointSize.x;

    *area_width = (short)(pointSize.x * img_width);
    *area_height = (short)(pointSize.y * img_height);

} /* CalculateDims */
Exemplo n.º 4
0
static struct ScrollStruct getscrolldata( HWND Wnd, int dir )
/*===========================================================

   This function gets the information needed to scroll a window properly
*/
{
    WPI_RECT            rect;
    struct ScrollStruct info;
    WPI_RECTDIM         left, right, top, bottom;

    //Get the necessary data
   _wpi_getscrollrange( Wnd, dir, &info.minpos, &info.maxpos );
   info.currpos = _wpi_getscrollpos( Wnd, dir );
   _wpi_getclientrect( Wnd, &rect );
   _wpi_getrectvalues( rect, &left, &top, &right, &bottom );

   if( dir == SB_VERT ){
       info.max = _wpi_getsystemmetrics( SM_CYSCREEN );
       info.pixls = bottom - top;
       info.currcoord = _BitBlt_Coord.ycoord;
   } else {
       info.max = _wpi_getsystemmetrics( SM_CXSCREEN );
       info.pixls = right - left;
       info.currcoord = _BitBlt_Coord.xcoord;
   }

   // Amount to move the thumb by for every line scrolled
   if( info.pixls > LINEAMT ) {
       info.line = CalScrollAmt( info.maxpos, info.minpos,
                                  LINEAMT, info.max,
                                  info.pixls + 1);
   } else {
       info.line = info.pixls;
   }

   // Amount to move the thumb by for every page scrolled
   info.page = CalScrollAmt( info.maxpos, info.minpos,
                              info.pixls, info.max,
                              info.pixls + 1);
   return( info );
}
Exemplo n.º 5
0
/*
 * HitRestoreButton - check if a specified point hit the restore button
 */
bool HitRestoreButton( HWND hwnd, WPI_PARAM2 lparam )
{
    WPI_RECT    r;
    WPI_POINT   pt;
    int         left;
    int         top;
    int         right;
    int         bottom;

    _wpi_getwindowrect( hwnd, &r );
    _wpi_getrectvalues( r, &left, &top, &right, &bottom );
    top   += _wpi_getsystemmetrics( SM_CYCAPTION ) +
             _wpi_getsystemmetrics( SM_CYFRAME );
    bottom = top + CLOSE_BITMAP_Y;
    right -= _wpi_getsystemmetrics( SM_CXFRAME );
    left   = right - CLOSE_BITMAP_X;
    _wpi_setrectvalues( &r, left, top, right, bottom );
    WPI_MAKEPOINT(lparam, lparam, pt);
    return( _wpi_ptinrect( &r, pt ) );

} /* HitRestoreButton */
Exemplo n.º 6
0
/*
 * setDefaultValues - set the default values of ImgedConfigInfo structure
 */
static void setDefaultValues( settings_info *info )
{
    int         x, y;

    /* save settings */
    info->settings = SET_SAVE_ALL;

    x = _wpi_getsystemmetrics( SM_CXSCREEN );
    y = _wpi_getsystemmetrics( SM_CYSCREEN );

    /* set defaults */
    ImgedConfigInfo.x_pos = 0;
    ImgedConfigInfo.width = x;
#ifdef __OS2_PM__
    ImgedConfigInfo.y_pos = y / 5;
    ImgedConfigInfo.height = 4 * (y / 5);
#else
    ImgedConfigInfo.y_pos = 0;
    ImgedConfigInfo.height = 4 * (y / 5);
#endif
    ImgedConfigInfo.ismaximized = FALSE;

    ImgedConfigInfo.tool_xpos = ImgedConfigInfo.x_pos + ImgedConfigInfo.width - TBWidth - 2;
    ImgedConfigInfo.tool_ypos = ImgedConfigInfo.y_pos +
        _wpi_getsystemmetrics( SM_CYCAPTION ) + _wpi_getsystemmetrics( SM_CYMENU ) +
        FUNCTIONBAR_WIDTH + 2;

    ImgedConfigInfo.pal_xpos = ImgedConfigInfo.x_pos + ImgedConfigInfo.width - CP_WIDTH - 2;
#ifdef __OS2_PM__
    ImgedConfigInfo.pal_ypos = ImgedConfigInfo.y_pos + STATUS_WIDTH;
#else
    ImgedConfigInfo.pal_ypos = ImgedConfigInfo.y_pos + ImgedConfigInfo.height -
        StatusWidth - CP_HEIGHT - 2;
#endif

    ImgedConfigInfo.view_xpos = VIEWIN_XPOS;
    ImgedConfigInfo.view_ypos = ImgedConfigInfo.y_pos +
        _wpi_getsystemmetrics( SM_CYCAPTION ) + _wpi_getsystemmetrics( SM_CYMENU ) +
        FUNCTIONBAR_WIDTH + 2;

    /* other settings */
    ImgedConfigInfo.show_state = SET_SHOW_TOOL | SET_SHOW_CLR | SET_SHOW_VIEW;
    info->paste = SET_PASTE_STR;
    info->rotate = 10 + SET_ROT_SIMPLE;        // 10 means keep area
    info->viewwnd = SET_VIEW_1;
    info->wrapshift = TRUE;
    ImgedConfigInfo.shift = 1;
    ImgedConfigInfo.square_grid = TRUE;
    ImgedConfigInfo.brush_size = 2;
    ImgedConfigInfo.grid_on = TRUE;

    strcpy( info->opendir, "" );
    strcpy( info->savedir, "" );
    sprintf( info->color, "%ld", WHITE );

} /* setDefaultValues */
Exemplo n.º 7
0
bool GUIGetMousePosn( gui_window *wnd, gui_point *point )
{
    WPI_POINT   pt;

    if( !_wpi_getsystemmetrics( SM_MOUSEPRESENT ) ) {
        return( false );
    }
    _wpi_getcursorpos( &pt );
#ifdef __OS2_PM__ // close your eyes!!! gross hack coming up
    _wpi_screentoclient( wnd->hwnd, &pt );
    pt.y = _wpi_cvtc_y( wnd->hwnd, pt.y );
    _wpi_clienttoscreen( wnd->hwnd, &pt );
#endif
    GUIMakeRelative( wnd, &pt, point );
    return( true );
}
Exemplo n.º 8
0
bool GUIXCreateToolBarWithTips( gui_window *wnd, bool fixed, gui_ord height,
                                int num_toolbar_items, gui_toolbar_struct *toolinfo,
                                bool excl, gui_colour_set *plain,
                                gui_colour_set *standout, gui_rect *float_pos,
                                bool use_tips )
{
    gui_coord           size;
    gui_coord           pos;
    HWND                parent;
    HWND                toolhwnd;
    toolbarinfo         *tbar;
    int                 i;
    TOOLITEMINFO        info;
    int                 fixed_height;
    int                 fixed_width;
    int                 adjust_amount;
    int                 width;
    int                 new_right;
    int                 bm_h;
    int                 bm_w;
    GUI_RECTDIM         left, top, right, bottom;
    int                 h;

    excl = excl;
    plain = plain;
    standout = standout;
    fixed_height = 0;
    fixed_width = 0;
    if( ( wnd == NULL ) || ( num_toolbar_items < 1 ) || ( toolinfo == NULL ) ||
        ( wnd->hwnd == NULLHANDLE ) || ( wnd->root == NULLHANDLE ) ) {
        return( false );
    }
    if( wnd->tbinfo != NULL ) {
        GUICloseToolBar( wnd );
    }
    tbar = wnd->tbinfo = (toolbarinfo *)GUIMemAlloc( sizeof( toolbarinfo ) );
    if( tbar == NULL ) {
        return( false );
    }
    memset( tbar, 0, sizeof( toolbarinfo ) );
    parent = wnd->root;
    tbar->fixedrect = wnd->hwnd_client_rect;
    tbar->bitmaps = (HBITMAP *)GUIMemAlloc( num_toolbar_items * sizeof( HBITMAP ) );
    if( tbar->bitmaps == NULL ) {
        GUIMemFree( tbar );
        wnd->tbinfo = NULL;
        return( false );
    }
    for( i = 0; i < num_toolbar_items; i++ ) {
        tbar->bitmaps[i] = _wpi_loadbitmap( GUIResHInst,
                                _wpi_makeintresource( toolinfo[i].bitmap ) );
        if( height == 0 ) {
            _wpi_getbitmapdim( tbar->bitmaps[i], &bm_w, &bm_h );
            if( bm_h > fixed_height ) {
                fixed_height = bm_h;
            }
            if( bm_w > fixed_width ) {
                fixed_width = bm_w;
            }
        }
    }
    tbar->info.border_size.x = BORDER_AMOUNT;
    tbar->info.border_size.y = BORDER_AMOUNT;
    /* space for border and space before border */
    adjust_amount = 2*(_wpi_getsystemmetrics( SM_CYBORDER )+BORDER_AMOUNT);
    if( height == 0 ) { /* maintian # of pixels in bitmap */
        height = fixed_height + adjust_amount + OUTLINE_AMOUNT;
        width = fixed_width + OUTLINE_AMOUNT;
    } else {
        /* only height of windows given, make bitmaps square */
        size.x = 0;
        size.y = height - 2;
        GUIScaleToScreenR( &size );
        height = size.y;
        width = size.y;
    }

    _wpi_getrectvalues( tbar->fixedrect, &left, &top, &right, &bottom );
    h      = _wpi_getheightrect( tbar->fixedrect );
    bottom = _wpi_cvth_y_plus1( height, h );
    top    = _wpi_cvth_y_plus1( top, h );
    _wpi_setwrectvalues( &tbar->fixedrect, left, top, right, bottom );
    height -= adjust_amount; /* leaving just button size */
    tbar->info.button_size.x = width;
    tbar->info.button_size.y = height;
    bottom = height + BORDER_AMOUNT * 2 +
             _wpi_getsystemmetrics( SM_CYCAPTION ) +
             2 * ( _wpi_getsystemmetrics( SM_CYFRAME ) -
                   _wpi_getsystemmetrics( SM_CYBORDER ) );
    bottom = _wpi_cvth_y_plus1( bottom, h );
#ifdef __OS2_PM__
    bottom -= 2;
#endif
    new_right = width * num_toolbar_items -
                (num_toolbar_items - 1) * tbar->info.border_size.x +
                left + 2 * _wpi_getsystemmetrics( SM_CXFRAME ) +
                BORDER_AMOUNT * 2;
    if( new_right < right ) {
        right = new_right;
    }

    _wpi_setwrectvalues( &tbar->floatrect, left, top, right, bottom );
    _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&tbar->floatrect, 2 );

    if( fixed ) {
        tbar->info.area = tbar->fixedrect;
        tbar->info.style = TOOLBAR_FIXED_STYLE;
    } else {
        if( float_pos != NULL ) {
            GUICalcLocation( float_pos, &pos, &size, parent );
            _wpi_setwrectvalues( &tbar->floatrect, pos.x, pos.y,
                                 pos.x + size.x, pos.y + size.y );
            _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&tbar->floatrect, 2 );
        }
        tbar->info.area = tbar->floatrect;
        tbar->info.style = TOOLBAR_FLOAT_STYLE;
    }

    tbar->info.hook = guiToolBarProc;
    tbar->info.helphook = guiToolBarHelp;
    tbar->info.background = 0;
    tbar->info.foreground = 0;
    tbar->num = num_toolbar_items;
    tbar->info.is_fixed = fixed;
    tbar->info.use_tips = use_tips;

    tbar->hdl = ToolBarInit( parent );

    ToolBarDisplay( tbar->hdl, &tbar->info );

    GUIResizeBackground( wnd, true );

    for( i = 0; i < num_toolbar_items; i++ ) {
        info.u.bmp = tbar->bitmaps[i];
        info.id = toolinfo[i].id;
        info.flags = 0;
        if( use_tips && toolinfo[i].tip != NULL ) {
            strncpy( info.tip, toolinfo[i].tip, MAX_TIP );
        } else {
            info.tip[0] = '\0';
        }
        ToolBarAddItem( tbar->hdl, &info );
    }
    toolhwnd = ToolBarWindow( tbar->hdl );
    _wpi_showwindow( toolhwnd, SW_SHOWNORMAL );
    _wpi_updatewindow( toolhwnd );
    return( true );
}
Exemplo n.º 9
0
static bool guiToolBarProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    gui_window              *wnd;
    toolbarinfo             *tbar;
    HMENU                   hmenu;
    gui_ctl_id              id;

    wnd = GetToolWnd( hwnd );
    if( wnd == NULL ) {
        return( false );
    }
    tbar = wnd->tbinfo;
    if( tbar == NULL ) {
        return( false );
    }
    switch( msg ) {
    case WM_CREATE :
        hwnd = _wpi_getframe( hwnd );
        hmenu = _wpi_getsystemmenu( hwnd );
        if( hmenu != NULLHANDLE ) {
            if( _wpi_appendmenu( hmenu, MF_SEPARATOR, 0, 0, NULLHANDLE, NULL ) ) {
                _wpi_appendmenu( hmenu, MF_ENABLED|MF_SYSMENU, 0,
                                 GUIHint[GUI_MENU_FIX_TOOLBAR].id, NULLHANDLE,
                                 GUIHint[GUI_MENU_FIX_TOOLBAR].label );
            }
        }
        break;
#ifdef __OS2_PM__
    case WM_CHAR :
    case WM_TRANSLATEACCEL :
#else
    case WM_SYSKEYDOWN :
    case WM_SYSKEYUP :
    case WM_KEYUP :
    case WM_KEYDOWN :
#endif
        return( GUIProcesskey( hwnd, msg, wparam, lparam ) != 0 );
    case WM_MENUSELECT :
        GUIProcessMenuSelect( wnd, hwnd, msg, wparam, lparam );
        return( true );
    case WM_SYSCOMMAND :
        id = _wpi_getid( wparam );
        switch( id ) {
        case GUI_FIX_TOOLBAR :
            GUIChangeToolBar( wnd );
        }
        break;
#ifndef __OS2_PM__
    case WM_NCLBUTTONDBLCLK :
#endif
    case WM_RBUTTONDBLCLK :
    case WM_LBUTTONDBLCLK :
        /* flip the current state of the toolbar -
         * if we are fixed then start to float or vice versa
         */
        if( !HasToolAtPoint( tbar->hdl, wparam, lparam ) ) {
#ifdef __OS2_PM__
            // Hack: For some reason we will get here with bogus coords,
            // we need to ignore the event. Should really find out where
            // the message is coming from.
            if( (ULONG)wparam != 0x0FFFFFFF )
                GUIChangeToolBar( wnd );
#else
            GUIChangeToolBar( wnd );
#endif
            return( true );
        }
        break;
    case WM_MOVE:
    case WM_SIZE:
        // Whenever we are moved or sized as a floating toolbar, we remember our position
        // so that we can restore it when dbl. clicked
        if( tbar->info.style == TOOLBAR_FLOAT_STYLE ) {
            hwnd = _wpi_getframe( hwnd );
            _wpi_getwindowrect( hwnd, &tbar->floatrect );
        }
        break;
    case WM_GETMINMAXINFO:
        {
#ifdef __WINDOWS_386__
            WPI_MINMAXINFO __far *minmax= (WPI_MINMAXINFO __far *)MK_FP32( (void *)lparam );
#else
            WPI_MINMAXINFO *minmax = (WPI_MINMAXINFO *)lparam;
#endif
            _wpi_setmintracksize( minmax,
                ( tbar->info.border_size.x + _wpi_getsystemmetrics( SM_CXFRAME ) ) * 2 + tbar->info.button_size.x,
                ( tbar->info.border_size.y + _wpi_getsystemmetrics( SM_CYFRAME ) ) * 2 + tbar->info.button_size.y + _wpi_getsystemmetrics( SM_CYCAPTION ) );
        }
        break;
    case WM_CLOSE :
        GUICloseToolBar( wnd );
        return( true );
        break;
    }
    return( false );
}
Exemplo n.º 10
0
/*
 * loadPositionValues - load the position values from the configuration file
 */
static void loadPositionValues( HINI hini )
{
    int         sysbox_width;
    int         x, y;

    /* unused parameters */ (void)hini;

    x = _wpi_getsystemmetrics( SM_CXSCREEN );
    y = _wpi_getsystemmetrics( SM_CYSCREEN );
    sysbox_width = _wpi_getsystemmetrics( SM_CYCAPTION );

    /* position of main window */
    ImgedConfigInfo.x_pos = _wpi_getprivateprofileint( hini, imgedSection,
        "wnd_xpos", ImgedConfigInfo.x_pos, iniPath );
    ImgedConfigInfo.y_pos = _wpi_getprivateprofileint( hini, imgedSection,
        "wnd_ypos", ImgedConfigInfo.y_pos, iniPath );
    ImgedConfigInfo.width = _wpi_getprivateprofileint( hini, imgedSection,
        "wnd_width", ImgedConfigInfo.width, iniPath );
    ImgedConfigInfo.height = _wpi_getprivateprofileint( hini, imgedSection,
        "wnd_height", ImgedConfigInfo.height, iniPath );
    ImgedConfigInfo.ismaximized = _wpi_getprivateprofileint( hini, imgedSection,
        "ismaximized", ImgedConfigInfo.ismaximized, iniPath );

    /* location of the tool window */
    ImgedConfigInfo.tool_xpos = _wpi_getprivateprofileint( hini, imgedSection,
        "tool_xpos", ImgedConfigInfo.tool_xpos, iniPath );
    ImgedConfigInfo.tool_ypos = _wpi_getprivateprofileint( hini, imgedSection,
        "tool_ypos", ImgedConfigInfo.tool_ypos, iniPath );

    /* location of the color palette */
    ImgedConfigInfo.pal_xpos = _wpi_getprivateprofileint( hini, imgedSection,
        "pal_xpos", ImgedConfigInfo.pal_xpos, iniPath );
    ImgedConfigInfo.pal_ypos = _wpi_getprivateprofileint( hini, imgedSection,
        "pal_ypos", ImgedConfigInfo.pal_ypos, iniPath );

    /* location of the view window */
    ImgedConfigInfo.view_xpos = _wpi_getprivateprofileint( hini, imgedSection,
        "view_xpos", ImgedConfigInfo.view_xpos, iniPath );
    ImgedConfigInfo.view_ypos = _wpi_getprivateprofileint( hini, imgedSection,
        "view_ypos", ImgedConfigInfo.view_ypos, iniPath );
    /*
     * Now we want to make sure nothing is off the screen!
     */
    if( ImgedConfigInfo.x_pos + ImgedConfigInfo.width > x ) {
        ImgedConfigInfo.width = x - ImgedConfigInfo.x_pos - 2;
    }
    if( ImgedConfigInfo.y_pos + ImgedConfigInfo.height > y ) {
        ImgedConfigInfo.height = y - ImgedConfigInfo.y_pos - 2;
    }
    if( ImgedConfigInfo.tool_xpos > x - sysbox_width - 2 ) {
        ImgedConfigInfo.tool_xpos = x - TBWidth - 1;
    }
    if( ImgedConfigInfo.tool_ypos > y - sysbox_width - 2 ) {
        ImgedConfigInfo.tool_ypos = y - TBHeight - 1;
    }
    if( ImgedConfigInfo.pal_xpos > x - sysbox_width - 2 ) {
        ImgedConfigInfo.pal_xpos = x - CP_WIDTH - 1;
    }
    if( ImgedConfigInfo.pal_ypos > y - sysbox_width - 2 ) {
        ImgedConfigInfo.pal_ypos = y - CP_HEIGHT - 1;
    }
    if( ImgedConfigInfo.view_xpos > x - sysbox_width - 2 ) {
        ImgedConfigInfo.view_xpos = x - sysbox_width - 5;
    }
    if( ImgedConfigInfo.pal_ypos > y - sysbox_width - 2 ) {
        ImgedConfigInfo.pal_ypos = y - sysbox_width - 5;
    }

} /* loadPositionValues */
Exemplo n.º 11
0
/*
 * ResizeChild - resizes the draw area of the child window.
 */
void ResizeChild( WPI_PARAM2 lparam, HWND hwnd, BOOL firsttime )
{
    short       min_width;
    short       width;
    short       height;
    img_node    *node;
    short       x_adjustment;
    short       y_adjustment;
    short       new_width;
    short       new_height;
    WPI_POINT   point_size;
    WPI_POINT   max;
    HWND        frame;
    HMENU       hmenu;
    WPI_RECT    rc;
    WPI_RECT    rect;

    frame = _wpi_getframe( hwnd );
    width = LOWORD( lparam );
#ifdef __OS2_PM__
    height = SHORT2FROMMP( lparam );
#else
    height = HIWORD( lparam );
#endif

    GetClientRect( hwnd, &rc );
    GetWindowRect( hwnd, &rect );
    if( frame ) {
        GetClientRect( frame, &rc );
        GetWindowRect( frame, &rect );
    }

    max.x = _wpi_getsystemmetrics( SM_CXSCREEN );
    max.y = _wpi_getsystemmetrics( SM_CYSCREEN );

    x_adjustment = _wpi_getwidthrect( rect ) - _wpi_getwidthrect( rc );
    y_adjustment = _wpi_getheightrect( rect ) - _wpi_getheightrect( rc );

    #if 1
        min_width = MIN_DRAW_WIN_WIDTH;
    #else
        min_width = (short)(2*_wpi_getsystemmetrics(SM_CXSIZE)) +
                    x_adjustment +
                    8; // fudge factor to allow some of title bar to show
    #endif

#ifdef __OS2_PM__
    ++y_adjustment;
#endif

    node = SelectImage( hwnd );
    if (!node) return;

    // the following assumes that max.x >> min_width
    point_size.x = min( max.x / node->width, width / node->width );
    point_size.x = max( min_width / node->width + 1, point_size.x );

    point_size.y = min( max.y / node->height, height / node->height );
    point_size.y = max( 1, point_size.y );

    if( ImgedConfigInfo.square_grid ) {
        point_size.x = min( point_size.x, point_size.y );
        if( point_size.x < ( min_width / node->width + 1 ) ) {
            point_size.x = min_width / node->width + 1;
        }
        if( point_size.x > ( max.y / node->height ) ) {
            hmenu = GetMenu( _wpi_getframe(HMainWindow) );
            CheckSquareGrid( hmenu );
        } else {
            point_size.y = point_size.x;
        }
    }

    new_width = (short)(point_size.x * node->width + x_adjustment);
    new_height = (short)(point_size.y * node->height + y_adjustment);

    pointSize = point_size;

    if( (pointSize.x*node->width != width) ||
        (pointSize.y*node->height != height) ) {
        SetWindowPos( frame, HWND_TOP, 0, 0, new_width, new_height,
                        SWP_SIZE | SWP_ZORDER | SWP_NOMOVE | SWP_SHOWWINDOW);
        SetGridSize( pointSize.x, pointSize.y );
    }
    if( !firsttime ) {
        BlowupImage( node->hwnd, NULL );
    }
} /* ResizeChild */
Exemplo n.º 12
0
/*
 * FindOrigin - "cascade" the windows to find the placement of the new MDI child
 *            - origin is expected to come in as (0, 0) or the equivalent for PM
 */
void FindOrigin( WPI_POINT *new_origin )
{
    WPI_ENUMPROC    fp;
    int             image_count;
    int             i, j;
    WPI_POINT       temp;
    WPI_RECT        proposed;
    WPI_RECTDIM     width;
    int             base;

    image_count = DoImagesExist();

    if( image_count == 0 ) {
        return;
    }

#ifdef __OS2_PM__
    imageMax = image_count;
#endif
    windowCoords = MemAlloc( image_count * sizeof( WPI_POINT ) );
    windowIndex = 0;

    fp = _wpi_makeenumprocinstance( GetPosProc, Instance );
    _wpi_enumchildwindows( ClientWindow, fp, 0L );
    _wpi_freeprocinstance( fp );

    /*
     * I'm just using a simple bubble sort ... we're using small amounts of data
     */
    for( i = 0; i < image_count; i++ ) {
        for( j = 0; j < image_count - i - 1; j++ ) {
            if( windowCoords[j].x > windowCoords[j + 1].x ) {
                temp = windowCoords[j];
                windowCoords[j] = windowCoords[j + 1];
                windowCoords[j + 1] = temp;
            }
        }
    }

    /*
     * Minimized windows will have coordinates set to negative, and we only
     * want non-minimized windows.
     */
    for( base = 0; base < image_count; base++ ) {
        if( windowCoords[base].x >= 0 ) {
            break;
        }
    }
    if( base >= image_count ) {
        MemFree( windowCoords );
        return;
    }

    width = _wpi_getsystemmetrics( SM_CYCAPTION );
#ifndef __OS2_PM__
    _wpi_setintrectvalues( &proposed, new_origin->x, new_origin->y,
                           new_origin->x + width, new_origin->y + width );
#else
    _wpi_setrectvalues( &proposed, new_origin->x, new_origin->y - 1,
                        new_origin->x + width, new_origin->y + width - 1 );
#endif

    /*
     * Try to place at the origin passed in if we can.
     */
    if( !_wpi_ptinrect( &proposed, windowCoords[base] ) ) {
        MemFree( windowCoords );
        return;
    }

    for( i = base; i < image_count - 1; i++ ) {
        if( windowCoords[i + 1].x - windowCoords[i].x > 2 * width ) {
            break;
        }
    }

    temp.x = windowCoords[i].x + width;
#ifndef __OS2_PM__
    temp.y = windowCoords[i].x + width;
#else
    temp.y = windowCoords[i].y - width;
#endif

    _wpi_getclientrect( ClientWindow, &proposed );
#ifndef __OS2_PM__
    if( !_wpi_ptinrect( &proposed, temp ) ) {
        return;
    } else {
        new_origin->x = temp.x;
        new_origin->y = temp.y;
    }
#else
    new_origin->x = temp.x;
    new_origin->y = temp.y;
#endif

    MemFree( windowCoords );

} /* FindOrigin */
Exemplo n.º 13
0
WPI_MRESULT CALLBACK GraphWndProc( HWND         Wnd,
                                   WPI_MSG      message,
                                   WPI_PARAM1   wParam,
                                   WPI_PARAM2   lParam )
//=============================================================

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


        // Adjust the scroll bar thumbs' positions
        _wpi_setscrollpos( frame, SB_HORZ, h_currpos, TRUE );
        _wpi_setscrollpos( frame, SB_VERT, v_currpos, TRUE );
#if defined( __OS2__ )
        Win_dc = WinBeginPaint( Wnd, NULL, &rect );
        WinFillRect( Win_dc, &rect, CLR_BLACK );
        WinEndPaint( Win_dc );
#endif
        _wpi_invalidaterect( Wnd, NULL, 0 );
        break;
    default:
        return( _wpi_defwindowproc( Wnd, message, wParam, lParam ) );
    }
   return( NULL );
}
Exemplo n.º 14
0
/*
 * DrawAreaWinProc - window procedure for the drawing area window
 *                 - this window is an MDI window
 */
MRESULT CALLBACK DrawAreaWinProc( HWND hwnd, WPI_MSG msg,
                                  WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    static WPI_POINT    start_pt = { -1, -1 };
    static WPI_POINT    end_pt = { -1, -1 };
    static WPI_POINT    prev_pt = { -1, -1 };
    static WPI_POINT    new_pt = { -1, -1 };
    static WPI_POINT    pt1;
    static BOOL         flbuttondown = FALSE;
    static BOOL         frbuttondown = FALSE;
    static BOOL         fdraw_shape = FALSE;
    static BOOL         firsttime;
    static BOOL         wasicon;
    int                 mousebutton;
    WPI_POINT           pointsize;
    WPI_POINT           pt2;
#ifndef __OS2_PM__
    CREATESTRUCT        *cs;
    MDICREATESTRUCT     *mdi_cs;
    MINMAXINFO          *minmax;
#endif
    img_node            *node;
    int                 i;

    switch ( msg ) {
    case WM_CREATE:
#ifndef __OS2_PM__
        cs = (CREATESTRUCT __FAR *)lparam;
        mdi_cs = (MDICREATESTRUCT __FAR *)cs->lpCreateParams;
        node = (img_node *)mdi_cs->lParam;

        for( i = 0; i < node->num_of_images; i++ ) {
            node[i].hwnd = hwnd;
        }
        AddImageNode( node );
        CreateUndoStack( node );
        setTheCursor( -1, hwnd );
        wasicon = FALSE;
#endif
        firsttime = TRUE;
        i = i;
        return( 0 );

    case WM_MDIACTIVATE:
        if( IMGED_GET_MDI_FACTIVATE( hwnd, wparam, lparam ) ) {
            if( _wpi_isiconic( hwnd ) ) {
                wasicon = TRUE;
                break;
            } else {
                wasicon = FALSE;
                FocusOnImage( hwnd );
            }
        }
        return( 0 );

#ifndef __OS2_PM__
    case WM_GETMINMAXINFO:
        node = SelectImage( hwnd );
        if( node != NULL ) {
            minmax = (MINMAXINFO *)lparam;
            minmax->ptMinTrackSize.x = node->width +
                2 * _wpi_getsystemmetrics( SM_CXFRAME );
            minmax->ptMinTrackSize.y = node->height +
                2 * _wpi_getsystemmetrics( SM_CYFRAME ) +
                _wpi_getsystemmetrics( SM_CYCAPTION ) - 1;
        }
        break;
#endif

    case UM_SHOWVIEWWINDOW:
        ShowViewWindows( hwnd );
        return 0;

    case WM_SIZE:
        if ( _imgwpi_issizerestored( wparam ) ) {
            ResizeChild( lparam, hwnd, firsttime );
            firsttime = FALSE;
            if( wasicon ) {
                FocusOnImage( hwnd );
                wasicon = FALSE;
            }
#ifndef __OS2_PM__
        } else if ( _imgwpi_issizeminimized( wparam ) ) {
            node = SelectImage( hwnd );
            HideViewWindow( hwnd );
            DeleteActiveImage();
            ClearImageText();
            SendMessage( ClientWindow, WM_MDINEXT, (WPARAM)(LPVOID)hwnd, 0L );
            wasicon = TRUE;
#endif
        }
        return( 0 );

#ifndef __OS2_PM__
    case WM_CHAR:
        pointsize = GetPointSize( hwnd );
        if( LOWORD( wparam ) == ESC_CHAR ) {
            if( !(lparam & 0x40000000) ) {
                switch( toolType ) {
                case IMGED_PASTE:
                    fdraw_shape = FALSE;
                    flbuttondown = FALSE;
                    frbuttondown = FALSE;
                    DontPaste( hwnd, &pt1, pointsize );
                    break;

                case IMGED_LINE:
                case IMGED_RECTO:
                case IMGED_RECTF:
                case IMGED_CIRCLEO:
                case IMGED_CIRCLEF:
                case IMGED_CLIP:
                    if( !flbuttondown && !frbuttondown ) {
                        break;
                    }
                    fdraw_shape = FALSE;
                    flbuttondown = FALSE;
                    frbuttondown = FALSE;
                    if( toolType == IMGED_LINE ) {
                        OutlineLine( hwnd, &start_pt, &prev_pt, &new_pt, TRUE );
                    } else if( toolType == IMGED_CLIP ) {
                        OutlineClip( hwnd, &start_pt, &prev_pt, &new_pt, TRUE );
                        SetRectExists( FALSE );
                    } else {
                        OutlineRegion( hwnd, &start_pt, &prev_pt, &new_pt, TRUE );
                    }
                    break;
                default:
                    break;
                }
            }
        }
        return( 0 );
#endif

    case WM_MOUSEMOVE:
        pointsize = GetPointSize( hwnd );
#ifdef __OS2_PM__
        WinSetPointer( HWND_DESKTOP, hCursor[cursorIndex] );
#endif
        IMGED_MAKEPOINT( wparam, lparam, new_pt );

        switch( toolType ) {
        case IMGED_SNAP:
#ifndef __OS2_PM__
            OutlineSnap();
#endif
            break;

        case IMGED_PASTE:
            pt1.x = new_pt.x / pointsize.x;
            pt1.y = new_pt.y / pointsize.y;
            pt2.x = prev_pt.x / pointsize.x;
            pt2.y = prev_pt.y / pointsize.y;
            if( pt1.x != pt2.x || pt1.y != pt2.y ) {
                DragClipBitmap( hwnd, &pt1, pointsize );
            }
            SetPosInStatus( &new_pt, &pointsize, hwnd );
            break;

        case IMGED_FREEHAND:
        case IMGED_BRUSH:
            if( flbuttondown ) {
                Paint( hwnd, &prev_pt, &new_pt, LMOUSEBUTTON );
            } else if( frbuttondown ) {
                Paint( hwnd, &prev_pt, &new_pt, RMOUSEBUTTON );
            }
            SetPosInStatus( &new_pt, &pointsize, hwnd );
            break;

        case IMGED_LINE:
        case IMGED_RECTO:
        case IMGED_RECTF:
        case IMGED_CIRCLEO:
        case IMGED_CIRCLEF:
        case IMGED_CLIP:
            if( flbuttondown || frbuttondown ) {
                if( new_pt.x / pointsize.x != end_pt.x / pointsize.x ||
                    new_pt.y / pointsize.y != end_pt.y / pointsize.y ) {
                    if( toolType == IMGED_LINE ) {
                        OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, FALSE );
                    } else if( toolType == IMGED_CLIP ) {
                        OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, FALSE );
                    } else {
                        OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, FALSE );
                    }
                    end_pt = new_pt;
                    SetSizeInStatus( hwnd, &start_pt, &new_pt, &pointsize );
                }
            } else {
                SetPosInStatus( &new_pt, &pointsize, hwnd );
            }
            break;

        case IMGED_FILL:
            SetPosInStatus( &new_pt, &pointsize, hwnd );
            break;

        default:
            SetPosInStatus( &new_pt, &pointsize, hwnd );
            break;
        }
        prev_pt = new_pt;
        return( 0 );

    case WM_LBUTTONDOWN:
    case WM_RBUTTONDOWN:
        pointsize = GetPointSize( hwnd );
        SetCapture( hwnd );
        if( msg == WM_LBUTTONDOWN ) {
            if( frbuttondown ) {
                break;
            }
#ifdef __OS2_PM__
            node = GetCurrentNode();
            if( hwnd != node->hwnd ) {
                break;
            }
#endif
            flbuttondown = TRUE;
            mousebutton = LMOUSEBUTTON;
        } else {
            if( flbuttondown ) {
                break;
            }
            node = GetCurrentNode();
            if( hwnd != node->hwnd ) {
                break;
            }
            frbuttondown = TRUE;
            mousebutton = RMOUSEBUTTON;
        }
        fdraw_shape = TRUE;
        IMGED_MAKEPOINT( wparam, lparam, start_pt );
        IMGED_MAKEPOINT( wparam, lparam, new_pt );

        switch( toolType ) {
        case IMGED_SNAP:
#ifndef __OS2_PM__
            TransferImage( hwnd );
#endif
            fdraw_shape = FALSE;
            flbuttondown = FALSE;
            frbuttondown = FALSE;
            break;

        case IMGED_FREEHAND:
        case IMGED_BRUSH:
            BeginFreeHand( hwnd );
            DrawSinglePoint( hwnd, &start_pt, mousebutton );
            break;

        case IMGED_LINE:
            IMGED_MAKEPOINT( wparam, lparam, end_pt );
            OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, TRUE );
            break;

        case IMGED_RECTO:
        case IMGED_RECTF:
        case IMGED_CIRCLEO:
        case IMGED_CIRCLEF:
            IMGED_MAKEPOINT( wparam, lparam, end_pt );
            OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, TRUE );
            break;

        case IMGED_CLIP:
            IMGED_MAKEPOINT( wparam, lparam, end_pt );
            RedrawPrevClip( hwnd );
            OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, TRUE );
            break;

        case IMGED_FILL:
            FillArea( &start_pt, mousebutton );
            RecordImage( hwnd );
            break;

        case IMGED_HOTSPOT:
            SetIsSaved( hwnd, FALSE );
            prev_pt.x = start_pt.x / pointsize.x;
            prev_pt.y = start_pt.y / pointsize.y;
            SetNewHotSpot( &prev_pt );
            break;

        default:
            break;
        }
        prev_pt = new_pt;
        return 0;

    case WM_LBUTTONUP:
    case WM_RBUTTONUP:
        pointsize = GetPointSize( hwnd );
        IMGED_MAKEPOINT( wparam, lparam, end_pt );
        IMGED_MAKEPOINT( wparam, lparam, new_pt );
        if( msg == WM_LBUTTONUP ) {
            mousebutton = LMOUSEBUTTON;
        } else {
            mousebutton = RMOUSEBUTTON;
        }

        if( fdraw_shape ) {
            switch( toolType ) {
            case IMGED_PASTE:
                PasteImage( &start_pt, pointsize, hwnd );
                flbuttondown = FALSE;
                frbuttondown = FALSE;
                break;

            case IMGED_FREEHAND:
            case IMGED_BRUSH:
                if( flbuttondown || frbuttondown ) {
                    EndFreeHand( hwnd );
                    RecordImage( hwnd );
                }
                break;

            case IMGED_LINE:
                DrawLine( hwnd, &start_pt, &end_pt, mousebutton );
                RecordImage( hwnd );
                break;

            case IMGED_RECTO:
            case IMGED_RECTF:
            case IMGED_CIRCLEO:
            case IMGED_CIRCLEF:
                DisplayRegion( hwnd, &start_pt, &end_pt, mousebutton );
                RecordImage( hwnd );
                break;

            case IMGED_CLIP:
                SetClipRect( hwnd, &start_pt, &end_pt, pointsize );
                break;

            default:
                break;
            }
            fdraw_shape = FALSE;
        }
        ReleaseCapture();
        flbuttondown = FALSE;
        frbuttondown = FALSE;
        prev_pt = new_pt;
        return( 0 );

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

    case WM_QUERYENDSESSION:
    case WM_CLOSE:
        if( lastChanceSave( hwnd ) ) {
            CloseCurrentImage( hwnd );
            return( (MRESULT)1 );
        } else {
            return( (MRESULT)0 );
        }

#ifndef __OS2_PM__
    case WM_DESTROY:
        SetCursor( LoadCursor( NULL, IDC_ARROW ) );
        return( 0 );
#endif

    default:
        break;
    }
    return( _imgwpi_defMDIchildproc( hwnd, msg, wparam, lparam ) );

} /* DrawAreaWinProc */