Exemple #1
0
void GUISetRestoredSize( gui_window *wnd, gui_rect *rect )
{
    gui_coord           pos;
    gui_coord           size;
    gui_window          *parent;
    HWND                frame;
    HWND                phwnd;
    WPI_RECT            new_rect;

    if( GUIIsMaximized( wnd ) || GUIIsMinimized( wnd ) ) {
        if( wnd->hwnd != NULLHANDLE ) {
            frame = GUIGetParentFrameHWND( wnd );
            parent = wnd->parent;
            phwnd = HWND_DESKTOP;
            if( parent ) {
                phwnd = parent->hwnd;
            }
            GUICalcLocation( rect, &pos, &size, phwnd );
            _wpi_setrectvalues( &new_rect, pos.x, pos.y, pos.x + size.x,
                                pos.y + size.y );
            if( GUIMDIMaximized( wnd ) ) {
                GUISetMDIRestoredSize( frame, &new_rect );
            } else {
                _wpi_setrestoredrect( frame, &new_rect );
            }
        }
    } else {
        GUIResizeWindow( wnd, rect );
    }
}
Exemple #2
0
/*
 * DoesRectExist - return whether or not a rectangle exists
 */
BOOL DoesRectExist( WPI_RECT *rc )
{
    if( fEnableCutCopy ) {
        *rc = clipRect.rect;
    } else {
        _wpi_setrectvalues( rc, 0, 0, 0, 0 );
    }
    return( fEnableCutCopy );

} /* DoesRectExist */
Exemple #3
0
/*
 * SetClipRect - set the value of the clipping rectangle
 */
void SetClipRect( HWND hwnd, WPI_POINT *startpt, WPI_POINT *endpt, WPI_POINT pointsize )
{
    WPI_RECTDIM left;
    WPI_RECTDIM top;
    WPI_RECTDIM right;
    WPI_RECTDIM bottom;
    WPI_RECTDIM tmps;
    WPI_RECTDIM tmpe;

    CheckBounds( hwnd, startpt );
    CheckBounds( hwnd, endpt );

    tmps = startpt->x / pointsize.x;
    tmpe = endpt->x / pointsize.x;
    left = tmps;
    if( left > tmpe )
        left = tmpe;
    right = tmps;
    if( right < tmpe )
        right = tmpe;
    ++right;

    tmps = startpt->y / pointsize.y;
    tmpe = endpt->y / pointsize.y;
    top = tmps;
#ifdef __OS2_PM__
    if( top < tmpe )
        top = tmpe;
    ++top;
#else
    if( top > tmpe )
        top = tmpe;
#endif
    bottom = tmps;
#ifdef __OS2_PM__
    if( bottom > tmpe )
        bottom = tmpe;
#else
    if( bottom < tmpe )
        bottom = tmpe;
    ++bottom;
#endif
    _wpi_setrectvalues( &clipRect.rect, left, top, right, bottom );
    clipRect.hwnd = hwnd;

    fEnableCutCopy = TRUE;

} /* SetClipRect */
Exemple #4
0
/*
 * makeInsideRect - make a rectangle the inside of a rectangle
 */
static void makeInsideRect( WPI_RECT *r )
{
    WPI_RECTDIM r_left;
    WPI_RECTDIM r_right;
    WPI_RECTDIM r_top;
    WPI_RECTDIM r_bottom;

    _wpi_getrectvalues( *r, &r_left, &r_top, &r_right, &r_bottom );
    r_left += BORDER_SIZE;
    r_top += BORDER_SIZE;
    r_right -= BORDER_SIZE;
    r_bottom -= BORDER_SIZE;

    _wpi_setrectvalues( r, r_left, r_top, r_right, r_bottom );

} /* makeInsideRect */
Exemple #5
0
/*
 * getRect - get a rectangle
 */
static void getRect( statwnd *sw, WPI_RECT *r, int i )
{
    WPI_RECTDIM pos;
    WPI_RECTDIM left;
    WPI_RECTDIM right;
    WPI_RECTDIM top;
    WPI_RECTDIM bottom;
    WPI_RECTDIM r_left;
    WPI_RECTDIM r_right;
    WPI_RECTDIM r_top;
    WPI_RECTDIM r_bottom;

    *r = sw->statusRect;
    _wpi_getrectvalues( sw->statusRect, &left, &top, &right, &bottom );
    _wpi_getrectvalues( *r, &r_left, &r_top, &r_right, &r_bottom );
    if( i > 0 ) {
        if( sw->sectionDesc[i - 1].width_is_percent ) {
            if( r_right > r_left ) {
                pos = (WORD)( ( ( r_right - r_left ) * (DWORD)sw->sectionDesc[i].width ) / 100L );
            } else {
                pos = (WORD)( ( ( r_left - r_right ) * (DWORD)sw->sectionDesc[i].width ) / 100L );
            }
        } else {
            pos = sw->sectionDesc[i - 1].width;
        }
        r_left = pos + sw->sectionDesc[i - 1].separator_width;
    }
    if( i == sw->numSections ) {
        pos = right;
    } else if( sw->sectionDesc[i].width_is_percent ) {
        if( r_right > r_left ) {
            pos = (WORD)( ( ( r_right - r_left ) * (DWORD)sw->sectionDesc[i].width ) / 100L );
        } else {
            pos = (WORD)( ( ( r_left - r_right ) * (DWORD)sw->sectionDesc[i].width ) / 100L );
        }
    } else {
        pos = sw->sectionDesc[i].width;
    }
    _wpi_setrectvalues( r, r_left, r_top, pos, r_bottom );

} /* getRect */
Exemple #6
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 */
void GUIInvalidateResize( gui_window *wnd )
{
    WPI_RECT    rect;
    GUI_RECTDIM left, top, right, bottom;

    if( ( wnd->flags & NEEDS_RESIZE_REDRAW ) &&
        ( wnd->old_rows != wnd->num_rows ) ) {
        _wpi_getrectvalues( wnd->hwnd_client_rect, &left, &top, &right, &bottom );
        GUIGetMetrics( wnd );
        if( wnd->old_rows < wnd->num_rows ) {
            /* window grew */
            top = wnd->old_rows * AVGYCHAR( GUItm );
        } else {
            /* window shrunk */
            top = wnd->num_rows * AVGYCHAR( GUItm );
        }
        _wpi_setrectvalues( &rect, left, top, right, bottom );
        _wpi_invalidaterect( wnd->hwnd, &rect, TRUE );
        wnd->flags &= ~NEEDS_RESIZE_REDRAW;
    }
    wnd->old_rows = wnd->num_rows;
}
Exemple #8
0
/*
 * OutlineClip - displays the potential region to be clipped to the clip board
 */
void OutlineClip( HWND hwnd, WPI_POINT *start_pt, WPI_POINT *end_pt,
                                        WPI_POINT *prev_pt, BOOL firsttime )
{
    WPI_RECT    newpos;
    WPI_RECT    oldpos;
    short       temp;
    WPI_PRES    pres;
    IMGED_DIM   left;
    IMGED_DIM   top;
    IMGED_DIM   right;
    IMGED_DIM   bottom;

    CheckBounds( hwnd, start_pt );
    CheckBounds( hwnd, end_pt );
    CheckBounds( hwnd, prev_pt );
    left = (IMGED_DIM)MAKELOGPTX(start_pt->x);
    top = (IMGED_DIM)MAKELOGPTY(start_pt->y);
    right = (IMGED_DIM)MAKELOGPTX(end_pt->x);
    bottom = (IMGED_DIM)MAKELOGPTY(end_pt->y);

    if (left > right) {
        temp = right;
        right = left + pointSize.x;
        left = temp;
    } else {
        right += pointSize.x;
    }
    if (top > bottom) {
        temp = bottom;
        bottom = top + pointSize.y;
        top = temp;
    } else {
        bottom += pointSize.y;
    }
    _wpi_setrectvalues( &newpos, left, top, right, bottom );

    left = (IMGED_DIM)MAKELOGPTX( start_pt->x );
    top = (IMGED_DIM)MAKELOGPTY( start_pt->y );
    right = (IMGED_DIM)MAKELOGPTX( prev_pt->x );
    bottom = (IMGED_DIM)MAKELOGPTY( prev_pt->y );

    if (left > right) {
        temp = right;
        right = left + pointSize.x;
        left = temp;
    } else {
        right += pointSize.x;
    }
    if (top > bottom) {
        temp = bottom;
        bottom = top + pointSize.y;
        top = temp;
    } else {
        bottom += pointSize.y;
    }
    _wpi_setrectvalues( &oldpos, left, top, right, bottom );

    pres = _wpi_getpres( hwnd );
    OutlineRectangle( firsttime, pres, &oldpos, &newpos );
    _wpi_releasepres( hwnd, pres );
} /* OutlineClip */
Exemple #9
0
/*
 * DisplayRegion - Draws the region (rectangle or ellipse) first in the view
 *              window, then in the draw area.
 */
void DisplayRegion( HWND hwnd, WPI_POINT *start_pt, WPI_POINT *end_pt, int mousebutton )
{
    COLORREF    colour;
    COLORREF    dithered;
    COLORREF    solid;
    WPI_POINT   imgstart_pt;
    WPI_POINT   imgend_pt;
    WPI_RECT    rect;
    BOOL        dofillrgn;
    BOOL        is_rect;
    wie_clrtype type;
    img_node    *node;

    CheckBounds( hwnd, start_pt );
    CheckBounds( hwnd, end_pt );
    imgstart_pt.x = min(start_pt->x / pointSize.x, end_pt->x / pointSize.x);
    imgend_pt.x = max(start_pt->x / pointSize.x, end_pt->x / pointSize.x);
#ifdef __OS2_PM__
    imgstart_pt.y = max(start_pt->y / pointSize.y, end_pt->y / pointSize.y);
    imgend_pt.y = min(start_pt->y / pointSize.y, end_pt->y / pointSize.y) - 1;
#else
    imgstart_pt.y = min(start_pt->y / pointSize.y, end_pt->y / pointSize.y);
    imgend_pt.y = max(start_pt->y / pointSize.y, end_pt->y / pointSize.y) + 1;
#endif

    imgend_pt.x += 1;

    dithered = GetSelectedColour(mousebutton, &solid, &type);
    switch (toolType) {
    case IMGED_RECTO:
        dofillrgn = FALSE;
        is_rect = TRUE;
        colour = solid;
        break;

    case IMGED_RECTF:
        dofillrgn = TRUE;
        is_rect = TRUE;
        colour = dithered;
        break;

    case IMGED_CIRCLEO:
        dofillrgn = FALSE;
        is_rect = FALSE;
        colour = solid;
        break;

    case IMGED_CIRCLEF:
        dofillrgn = TRUE;
        is_rect = FALSE;
        colour = dithered;
        break;

    default:
        return;
    }

    _wpi_setrectvalues(&rect, imgstart_pt.x, imgstart_pt.y, imgend_pt.x,
                                                        imgend_pt.y);
    if (type == SCREEN_CLR) {
        RegionXorAnd(BLACK, WHITE, dofillrgn, &rect, is_rect);
    } else if (type == INVERSE_CLR) {
        RegionXorAnd(WHITE, WHITE, dofillrgn, &rect, is_rect);
    } else {
        RegionXorAnd(colour, BLACK, dofillrgn, &rect, is_rect);
    }

    node = GetCurrentNode();
    InvalidateRect( node->viewhwnd, NULL, FALSE );
    BlowupImage( hwnd, NULL );
} /* DisplayRegion */
Exemple #10
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 */
Exemple #11
0
static bool DrawRect( gui_window *wnd, gui_rect *rect, WPI_COLOUR colour,
                      bool fill, bool outline )
{
    WPI_RECT    wnd_rect;
    gui_coord   pos;
    gui_coord   size;
    HBRUSH      brush;
    int         hscroll;
    int         vscroll;
    int         win_height;

    if( ( rect->width == 0 ) || ( rect->height == 0 ) ) {
        return( false );
    }

    if( GUI_DO_VSCROLL( wnd ) ) {
        vscroll = GUIGetScrollPos( wnd, SB_VERT );
    } else {
        vscroll = 0;
    }

    if( GUI_DO_HSCROLL( wnd ) ) {
        hscroll = GUIGetScrollPos( wnd, SB_HORZ );
    } else {
        hscroll = 0;
    }

    win_height = _wpi_getheightrect( wnd->hwnd_client_rect );

    pos.x = rect->x;
    pos.y = rect->y;
    size.x = rect->width;
    if( rect->width < 0 ) {
        pos.x += rect->width;
        size.x *= -1;
    }
    size.y = rect->height;
    if( rect->height < 0 ) {
        pos.y += rect->height;
        size.y *= -1;
    }

    GUIScaleToScreenR( &pos );
    GUIScaleToScreenR( &size );

    pos.x -= hscroll;
    pos.y -= vscroll;

    pos.y  = _wpi_cvth_y_size_plus1( pos.y, win_height, size.y );

    _wpi_setrectvalues( &wnd_rect, pos.x, pos.y, pos.x + size.x, pos.y + size.y );
    if( GUIIsRectInUpdateRect( wnd, &wnd_rect ) ) {
        brush = _wpi_createsolidbrush( colour );
        if( fill ) {
            _wpi_fillrect( wnd->hdc, &wnd_rect, colour, brush );
        }
        if( outline ) {
            _wpi_borderrect( wnd->hdc, &wnd_rect, brush, colour, colour );
        }
        _wpi_deletebrush( brush );
    }
    return( true );
}
Exemple #12
0
void GUIDrawTextBitmapRGB( gui_window *wnd, const char *text,
                            size_t length, int height, gui_coord *pos,
                            WPI_COLOUR fore, WPI_COLOUR back, gui_ord extentx,
                            bool draw_extent, int bitmap )
{
    int         nDrawX, nDrawY;
    UINT        lenx;
    HBRUSH      brush;
    HBRUSH      old_brush;
    HPEN        pen;
    HPEN        old_pen;
    int         old_rop;
    size_t      num_chars;
    WPI_RECT    rect;
    gui_coord   indent;
    int         hscroll_pos;
    gui_coord   extent;
    WPI_COLOUR  colour;
    GUI_RECTDIM left, top, right, bottom;
    GUI_RECTDIM paint_left, paint_top, paint_right, paint_bottom;
    WPI_RECT    paint_rect;
    WPI_RECT    draw_rect;
    //draw_cache        dcache;

    if( ( wnd->hdc == NULLHANDLE ) || ( wnd->ps == NULL ) ||
        ( ( text == NULL ) && ( bitmap == 0 ) ) ||
        ( ( bitmap != 0 ) && ( height == 0 ) ) ) {
        return;
    }
    old_rop = 0;
    old_brush = (HBRUSH)NULL;
    brush = (HBRUSH)NULL;
    old_pen = (HPEN)NULL;
    pen = (HPEN)NULL;
    GUIGetMetrics( wnd );
    if( !bitmap ) {
        height = AVGYCHAR(GUItm);
    }
    rect = wnd->hwnd_client;
    _wpi_getrectvalues( rect, &left, &top, &right, &bottom);
    _wpi_getpaintrect( wnd->ps, &paint_rect );
    _wpi_getwrectvalues( paint_rect, &paint_left, &paint_top, &paint_right,
                         &paint_bottom );
    top = paint_top / height * height;
    bottom = ( paint_bottom + height - 1) / height * height;

    if( GUI_DO_HSCROLL( wnd ) ) {
        hscroll_pos = GUIGetScrollPos( wnd, SB_HORZ );
    } else {
        hscroll_pos = 0;
    }

    if( bitmap == 0 ) {
        num_chars = strlen( text );
        if( num_chars > length ) {
            num_chars = length;
        }
    }

    indent.x = pos->x;
    indent.y = pos->y;
    GUIScaleToScreenR( &indent );
    nDrawY = indent.y;
    if( GUI_DO_VSCROLL( wnd ) ) {
        nDrawY -= GUIGetScrollPos( wnd, SB_VERT );
    }
    nDrawX = left;
    nDrawX += ( indent.x - hscroll_pos );

    if( bitmap > 0 ) {
        lenx = length ;
    } else {
        lenx = GUIGetTextExtentX( wnd, text, num_chars );
    }

    if( draw_extent ) {
        /* blanks out some portion of rest of the line */
        if( extentx != GUI_NO_COLUMN ) {
            extent.x = extentx;
            GUIScaleToScreen( &extent );
            right = nDrawX + extent.x;
        }
    } else {
        right = nDrawX + lenx;
    }
    nDrawY = _wpi_cvth_y_size( nDrawY, _wpi_getheightrect(wnd->hwnd_client), height );

    _wpi_setrectvalues( &draw_rect, nDrawX, nDrawY, right, nDrawY+height );
    if( GUIIsRectInUpdateRect( wnd, &draw_rect ) ) {
        colour = _wpi_getnearestcolor( wnd->hdc, back );
        brush = _wpi_createsolidbrush( colour );
        pen = _wpi_createpen( PS_SOLID, 1, colour );
        if( pen == NULLHANDLE ) {
            GUIError(LIT( Pen_Failed ));
        }
        old_brush = _wpi_selectbrush( wnd->hdc, brush );
        old_pen = _wpi_selectpen( wnd->hdc, pen );
#ifdef __OS2_PM__
        _wpi_rectangle( wnd->hdc, nDrawX, nDrawY+1, right, nDrawY + height - 1 );
#else
        _wpi_rectangle( wnd->hdc, nDrawX, nDrawY, right, nDrawY + height);
#endif

        /* if visible even with scrolling */
        if( nDrawX < ( paint_right + hscroll_pos ) ) {
            if( bitmap > 0 ) {
                GUIDrawBitmap( bitmap, wnd->hdc, nDrawX, nDrawY, colour);
            } else {
#ifdef __OS2_PM__
                nDrawY += _wpi_metricdescent( GUItm );
#endif
                old_rop = _wpi_setrop2( wnd->hdc, R2_COPYPEN );
                SetText( wnd, fore, back );
                _wpi_textout( wnd->hdc, nDrawX, nDrawY, text, num_chars );
            }
        }
        /* restore old resources */
        if( old_rop != 0 ) {
            _wpi_setrop2( wnd->hdc, old_rop );
        }
        if( old_brush != (HBRUSH)NULL ) {
            _wpi_getoldbrush( wnd->hdc, old_brush );
        }
        if( brush != (HBRUSH)NULL ) {
            _wpi_deletebrush( brush );
        }
        if( old_pen != (HPEN)NULL ) {
            _wpi_getoldpen( wnd->hdc, old_pen );
        }
        if( pen != (HPEN)NULL ) {
            _wpi_deletepen( pen );
        }
    }
}
Exemple #13
0
static void DoScroll( gui_window *wnd, int rows, int cols, int start, int end,
                      bool chars )
{
    int         dx, dy;
    WPI_RECT    client;
    HWND        hwnd;
    int         multx, multy;
    GUI_RECTDIM left, top, right, bottom;
#ifdef __OS2_PM__
    int         bottom_adjust;
#endif

    hwnd = GUIGetScrollHWND( wnd );
    _wpi_getclientrect( wnd->hwnd, &client );
    _wpi_getrectvalues( client, &left, &top, &right, &bottom );
#ifdef __OS2_PM__
    bottom_adjust = bottom - GUIGetScrollScreenSize( wnd, SB_VERT );
    top += bottom_adjust;
#else
    bottom = GUIGetScrollScreenSize( wnd, SB_VERT );
#endif
    multx = 1;
    multy = 1;
    if( chars ) {
        multx = GUIFromTextX( multx, wnd );
        multy = GUIFromTextY( multy, wnd );
    }
    dx = -cols * multx;
    dy = -rows * multy;
    if( dy != 0 ) {
#ifdef __OS2_PM__
        start *= multy;
        end *= multy;
        if( end > -multy ) {
            end += multy;
            if( end > bottom ) {
                end = bottom;
            }
            top = _wpi_getheightrect( client ) - end;
            //bottom = end + bottom_adjust;
        }
        if( start > -multy ) {
            //start += multy;
            if( start > bottom ) {
                start = bottom;
            }
            bottom = _wpi_getheightrect( client ) - start;
            //top = start + bottom_adjust;
        }
#else
        start *= multy;
        end *= multy;
        if( start > -multy ) {
            if( start > bottom ) {
                start = bottom;
            }
            top = start;
        }
        if( end > -multy ) {
            end += multy;
            if( end > bottom ) {
                end = bottom;
            }
            bottom = end;
        }
#endif

    }

    if( dx != 0 ) {
        start *= multx;
        end *= multx;
        if( start > -multx ) {
            if( start > right ) {
                start = right;
            }
            left = start;
        }
        if( end > -multx ) {
            end += multx;
            if( end > right ) {
                end = right;
            }
            right = end;
        }
    }

    _wpi_setrectvalues( &client, left, top, right, bottom );
    GUIInvalidatePaintHandles( wnd );
    _wpi_scrollwindow( hwnd, dx, dy, &client, &client );
    _wpi_updatewindow( hwnd );
}
Exemple #14
0
/*
 * doMaximize - handle maximizing an edit window
 */
static void doMaximize( HWND hwnd )
{
    DWORD               style;
    mdi_data            *md;
    WPI_RECT            r;
    bool                iconic;
    WPI_RECTDIM         left;
    WPI_RECTDIM         top;
    WPI_RECTDIM         right;
    WPI_RECTDIM         bottom;

    setMaximizedMenuConfig( hwnd );

    md = MDI_DATA_FROM_HWND( hwnd );

    if( mdiInfo.start_max_restore != NULL ) {
        mdiInfo.start_max_restore( hwnd );
    }

    iconic = _wpi_isiconic( hwnd );
    if( iconic ) {
        _wpi_getrestoredrect( hwnd, &md->orig_size );
    } else {
        _wpi_getwindowrect( hwnd, &md->orig_size );
    }
    md->orig_state = md->curr_state;
    md->curr_state = STATE_MAX;

    if( mdiInfo.set_style != NULL ) {
        (mdiInfo.set_style)( hwnd, TRUE );
    } else {
        style = _wpi_getwindowlong( hwnd, GWL_STYLE );
        style &= ~mdiInfo.reg_style;
        style |= mdiInfo.max_style;
        _wpi_setwindowlong( hwnd, GWL_STYLE, style );
    }
    _wpi_setscrollrange( hwnd, SB_VERT, 1, 1, TRUE );
    _wpi_setscrollrange( hwnd, SB_HORZ, 1, 1, TRUE );
    _wpi_getwindowrect( mdiInfo.container, &r );

    _wpi_getrectvalues( r, &left, &top, &right, &bottom );

    if( !iconic ) {
        _wpi_offsetrect( mdiInfo.hinstance, &md->orig_size, -left, -top );
    }

    _wpi_setrectvalues( &r, 0, 0, right-left+1, bottom-top+1 );

    if( iconic ) {
        _wpi_setrestoredrect( hwnd, &r );
    } else {
        _wpi_getrectvalues( r, &left, &top, &right, &bottom );
        _wpi_movewindow( hwnd, left, top, right, bottom, TRUE );
    }

    if( mdiInfo.end_max_restore != NULL ) {
        mdiInfo.end_max_restore( hwnd );
    }

    _wpi_invalidaterect( hwnd, NULL, FALSE );

} /* doMaximize */
Exemple #15
0
/*
 * outputText - output a text string
 */
static void outputText( statwnd *sw, WPI_PRES pres, char *buff, WPI_RECT *r, UINT flags,
                 int curr_block )
{
    WPI_RECT    ir;
    WPI_RECT    draw_rect;
    size_t      len;
    int         ext;
    int         width;
    WPI_RECTDIM ir_left;
    WPI_RECTDIM ir_right;
    WPI_RECTDIM ir_top;
    WPI_RECTDIM ir_bottom;
    WPI_RECTDIM r_left;
    WPI_RECTDIM r_right;
    WPI_RECTDIM r_top;
    WPI_RECTDIM r_bottom;
    UINT        pmflags;
#ifndef __NT__
    int         height;
#else
    SIZE        sz;
#endif

    if( sw->sectionData[curr_block] != NULL ) {
        if( !strcmp( buff, sw->sectionData[curr_block] ) &&
            flags == sw->sectionDataFlags[curr_block] ) {
            return;
        }
    }

    len = strlen( buff );
    if( len == 0 ) {
        return;
    }
    MemFree( sw->sectionData[curr_block] );
    sw->sectionData[curr_block] = MemAlloc( len + 1 );
    memcpy( sw->sectionData[curr_block], buff, len + 1 );
    sw->sectionDataFlags[curr_block] = flags | DT_TEXTATTRS;

#ifndef __NT__
    _wpi_gettextextent( pres, buff, (int)len, &ext, &height );
#else
    GetTextExtentPoint( pres, buff, (int)len, &sz );
    ext = sz.cx;
#endif
    ir = *r;
    _wpi_getrectvalues( ir, &ir_left, &ir_top, &ir_right, &ir_bottom );
#ifdef __OS2_PM__
    ir_left++;
    ir_top++;
    ir_bottom++;
    _wpi_setrectvalues( &draw_rect, ir_left, ir_top, ir_right, ir_bottom );
#else
    draw_rect = *r;
#endif
    if( flags & DT_CENTER ) {
        width = ( ir_right - ir_left - ext ) / 2;
        if( width > 0 ) {
            ir_right = ir_left + width;
            _wpi_setrectvalues( &ir, ir_left, ir_top, ir_right, ir_bottom );
            _wpi_fillrect( pres, &ir, colorButtonFace, brushButtonFace );

            _wpi_getrectvalues( *r, &r_left, &r_top, &r_right, &r_bottom );
            ir_right = r_right;
            ir_left = r_right - width;
            _wpi_setrectvalues( &ir, ir_left, ir_top, ir_right, ir_bottom );
            _wpi_fillrect( pres, &ir, colorButtonFace, brushButtonFace );
        }
    } else if( flags & DT_RIGHT ) {
        ir_right -= ext;
        if( ir_right >= ir_left ) {
            _wpi_setrectvalues( &ir, ir_left, ir_top, ir_right, ir_bottom );
            _wpi_fillrect( pres, &ir, colorButtonFace, brushButtonFace );
        }
    } else {
        ir_left += ext;
        if( ir_left < ir_right ) {
            _wpi_setrectvalues( &ir, ir_left, ir_top, ir_right, ir_bottom );
            _wpi_fillrect( pres, &ir, colorButtonFace, brushButtonFace );
        }
    }
    pmflags = flags | DT_TEXTATTRS;
    _wpi_drawtext( pres, buff, -1, &draw_rect, pmflags );

} /* outputText */