Example #1
0
void GUIResizeToolBar( gui_window *wnd )
{
    WPI_RECT    rect;
    GUI_RECTDIM left, top, right, bottom;
    GUI_RECTDIM height;
    GUI_RECTDIM t, h;
    toolbarinfo *tbar;

    tbar = wnd->tbinfo;
    if( tbar != NULL ) {
        rect = wnd->root_client_rect;
        if( wnd->root == NULLHANDLE ) {
            rect = wnd->hwnd_client_rect;
        }
        _wpi_rationalize_rect( &rect );
        if( tbar->info.is_fixed ) {
            height = _wpi_getheightrect( tbar->fixedrect );
            h = _wpi_getheightrect( rect );
            _wpi_getrectvalues( rect, &left, &top, &right, &bottom );
            t = _wpi_cvth_y_plus1( top, h );
            bottom = _wpi_cvth_y_plus1( height, h );
            _wpi_setwrectvalues( &tbar->fixedrect, left, t, right, bottom );
            t = _wpi_cvth_y_size_plus1( top, h, height );
            _wpi_movewindow( ToolBarWindow( tbar->hdl ), left, t, right - left, height, TRUE );
        }
    }
}
Example #2
0
void GUICalcLocation( gui_rect *rect, gui_coord *pos, gui_coord *size,
                      HWND parent )
{
    WPI_RECT    r;
    GUI_RECTDIM left, top, right, bottom;

    if( parent == NULLHANDLE ) {
        parent = HWND_DESKTOP;
    }
    pos->x = rect->x;
    pos->y = rect->y;
    size->x = rect->width;
    size->y = rect->height;
    if( parent == HWND_DESKTOP ) {
        GUIScaleToScreen( pos );
    } else {
        GUIScaleToScreenR( pos );
        _wpi_getclientrect( parent, &r );
        _wpi_getrectvalues( r, &left, &top, &right, &bottom );
        pos->x += left;
        pos->y += top;
    }
    GUIScaleToScreenR( size );

    pos->y = _wpi_cvtc_y_size_plus1( parent, pos->y, size->y );
}
Example #3
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 */
Example #4
0
/*
 * outlineRect - draw the outline of a rectangle
 */
static void outlineRect( statwnd *sw, WPI_PRES pres, WPI_RECT *r )
{
    WPI_POINT   pt;
    WPI_RECTDIM left;
    WPI_RECTDIM right;
    WPI_RECTDIM top;
    WPI_RECTDIM bottom;
    HPEN        oldpen;

    sw = sw;
    _wpi_getrectvalues( *r, &left, &top, &right, &bottom );

    _wpi_setpoint( &pt, left, bottom - 1 );
    _wpi_cvth_pt( &pt, sw->wndHeight );
    _wpi_movetoex( pres, &pt, NULL );

    oldpen = _wpi_selectobject( pres, penLight );
    pt.x = right - 1;
    _wpi_lineto( pres, &pt );
    pt.y = _wpi_cvth_y( top, sw->wndHeight );
    _wpi_lineto( pres, &pt );

    _wpi_selectobject( pres, penShade );

    pt.x = left;
    _wpi_lineto( pres, &pt );
    pt.y = _wpi_cvth_y( bottom - 1, sw->wndHeight );
    _wpi_lineto( pres, &pt );

    _wpi_selectobject( pres, oldpen );

} /* outlineRect */
Example #5
0
static void ResizeStatus( gui_window *wnd )
{
    WPI_RECT    status;
    GUI_RECTDIM left, top, right, bottom;

    if( GUIHasStatus( wnd ) ) {
        _wpi_getwindowrect( wnd->status, &status );
        _wpi_mapwindowpoints( HWND_DESKTOP, wnd->root, (WPI_LPPOINT)&status, 2 );
        _wpi_getrectvalues( status, &left, &top, &right, &bottom );
        /* maintain height and left position of status window -- tie the
           rest to the client are of the parent */
        SetStatusRect( wnd->root, &status, left, bottom - top );
        _wpi_getrectvalues( status, &left, &top, &right, &bottom );
        _wpi_movewindow( wnd->status, left, top, right - left, bottom - top, TRUE );
    }
}
Example #6
0
static bool CreateBackgroundWnd( gui_window *wnd, gui_create_info *info )
{
    DWORD               style;
    wmcreate_info       wmcreateinfo;
    HWND                frame_hwnd;
    GUI_RECTDIM         left, top, right, bottom;

    _wpi_getclientrect( wnd->root, &wnd->hwnd_client );
    _wpi_getrectvalues( wnd->hwnd_client, &left, &top, &right, &bottom );

    style = BACKGROUND_STYLES;

    wmcreateinfo.size = sizeof(wmcreate_info);
    wmcreateinfo.wnd = wnd;
    wmcreateinfo.info = info;

    wnd->hwnd = NULLHANDLE;
    frame_hwnd = NULLHANDLE;

    _wpi_createanywindow( GUIClass, NULL, style,
                          0, 0, right-left, bottom-top,
                          wnd->root, NULL, GUIMainHInst,
                          &wmcreateinfo, &wnd->hwnd, 0, &frame_hwnd );

    wnd->hwnd_frame = wnd->root_frame;

    return( wnd->hwnd != NULLHANDLE );
}
Example #7
0
bool GUITrackFloatingPopup( gui_window *wnd, gui_point *location,
                            gui_mouse_track track, gui_ctl_id *curr_id )
{
    WPI_POINT   pt;
    ULONG       flags;
    GUI_RECTDIM left, top, right, bottom;
    HMENU       popup;

    if( ( popup = GUIHFloatingPopup ) == (HMENU)NULL ) {
        return( false );
    }

    GUIScaleToScreenRPt( location );
    _wpi_getrectvalues( wnd->hwnd_client_rect, &left, &top, &right, &bottom );
    location->x += left;
    location->y += top;
    if( GUI_DO_HSCROLL( wnd ) ) {
        location->x -= GUIGetScrollPos( wnd, SB_HORZ );
    }
    if( GUI_DO_VSCROLL( wnd ) ) {
        location->y -= GUIGetScrollPos( wnd, SB_VERT );
    }

    CurrId = NO_SELECT;
    if( ( curr_id != NULL ) && ( *curr_id != 0 ) ) {
        CurrId = *curr_id;
    }

    location->y = _wpi_cvth_y( location->y, (bottom - top) );

    pt.x = location->x;
    pt.y = location->y;

    _wpi_mapwindowpoints( wnd->hwnd, HWND_DESKTOP, &pt, 1 );

    flags = TPM_LEFTALIGN;
    if( track & GUI_TRACK_LEFT ) {
        flags |= TPM_LEFTBUTTON;
    }
    if( track & GUI_TRACK_RIGHT ) {
        flags |= TPM_RIGHTBUTTON;
    }
    InitComplete = false;

    GUIFlushKeys();

    _wpi_trackpopupmenu( popup, flags, pt.x, pt.y, wnd->hwnd_frame );

    _wpi_destroymenu( popup );

    GUIHFloatingPopup = NULLHANDLE;

    if( ( CurrId != NO_SELECT ) && ( curr_id != NULL ) ) {
        *curr_id = CurrId;
    }
    CurrId = NO_SELECT;
    GUIDeleteFloatingPopups( wnd );
    return( true );
}
Example #8
0
/*
 * ViewWindowProc - window procedure for the view window
 */
WPI_MRESULT CALLBACK ViewWindowProc( HWND hwnd, WPI_MSG msg,
                                 WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    static HMENU                sysmenu;
    static HWND                 hframe;
    HMENU                       hmenu;
    WPI_RECT                    rcview;
    WPI_RECTDIM                 left;
    WPI_RECTDIM                 top;
    WPI_RECTDIM                 right;
    WPI_RECTDIM                 bottom;

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

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

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

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

    case WM_DESTROY:
        hViewWindow = NULL;
        break;

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

} /* ViewWindowProc */
Example #9
0
/*
 * CutImage - cuts the current clipping rectangle to the clipboard
 */
void CutImage( void )
{
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HDC         memdc;
    HBITMAP     oldbitmap;
    short       width;
    short       height;
    img_node    *node;
    WPI_RECTDIM left;
    WPI_RECTDIM right;
    WPI_RECTDIM top;
    WPI_RECTDIM bottom;

    node = GetCurrentNode();

    if( node == NULL ) {
        return;
    }

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

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

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

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

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

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

} /* CutImage */
Example #10
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 */
Example #11
0
static void SetStatusRect( HWND parent, WPI_RECT *status, int x, int height )
{
    WPI_RECT    client;
    GUI_RECTDIM left, right, top, bottom;
    int         y, h;

    _wpi_getclientrect( parent, &client );
    _wpi_getrectvalues( client, &left, &top, &right, &bottom );
    y = _wpi_cvth_y_plus1( bottom - height, bottom - top );
    h = _wpi_cvth_y_plus1( bottom - top, bottom - top );
    _wpi_setwrectvalues( status, x, y, right - left, h );
}
Example #12
0
void GUIResizeBackground( gui_window *wnd, bool force_msg )
{
    WPI_RECT    status;
    int         t_height, s_height;
    GUI_RECTDIM left, top, right, bottom;
    gui_coord   size;

    if( wnd->root == NULLHANDLE ) {
        if( wnd->hwnd != NULLHANDLE ) {
            _wpi_getclientrect( wnd->hwnd, &wnd->hwnd_client );
        }
        return;
    }

    t_height = 0;
    s_height = 0;

    if( ( wnd->toolbar != NULL ) && ( wnd->toolbar->info.is_fixed ) ) {
        t_height = _wpi_getheightrect( wnd->toolbar->fixedrect );
    }

    if( wnd->status != NULLHANDLE ) {
        _wpi_getwindowrect( wnd->status, &status );
        s_height = _wpi_getheightrect( status );
    }

    _wpi_getclientrect( wnd->root_frame, &wnd->root_client );
    _wpi_getrectvalues( wnd->root_client, &left, &top, &right, &bottom );
    bottom -= top;
    right  -= left;
    top = left = 0;

#ifdef __OS2_PM__
    top    += s_height;
    bottom -= t_height;
#else
    top    += t_height;
    bottom -= s_height;
#endif

    /* if the root client is a separate window resize it too */
    _wpi_movewindow( wnd->hwnd, left, top, right - left, bottom - top, TRUE );

    _wpi_getclientrect( wnd->hwnd, &wnd->hwnd_client );

    if( force_msg && ( wnd->flags & SENT_INIT ) ) {
        size.x = right - left;
        size.y = bottom - top;
        GUIScreenToScaleR( &size );
        GUIEVENTWND( wnd, GUI_RESIZE, &size );
    }
}
Example #13
0
bool GUIResizeStatusWindow( gui_window *wnd, gui_ord x, gui_ord height )
{
    WPI_RECT    status;
    GUI_RECTDIM left, top, right, bottom;

    if( !GUIHasStatus( wnd ) ) {
        return( false );
    }
    CalcStatusRect( wnd, x, height, &status );
    _wpi_getrectvalues( status, &left, &top, &right, &bottom );
    _wpi_movewindow( wnd->status, left, top, right - left, bottom - top, TRUE );
    GUIResizeBackground( wnd, true );
    return( true );
}
Example #14
0
/*
 * RedrawPrevClip - redraw the area if a region has been selected and copied to the
 *                  clipboard OR if a region has been selected and then another is
 *                  selected (without a cut or copy in between)
 *                - the hwnd parameter indicates which window to draw the clip rect on
 *                - if the hwnd does not match the one associated with clipRect, we return
 */
void RedrawPrevClip( HWND hwnd )
{
    WPI_POINT   pointsize;
    int         prevROP2;
    HBRUSH      blackbrush;
    HBRUSH      oldbrush;
    HPEN        whitepen;
    HPEN        oldpen;
    WPI_PRES    pres;
    WPI_RECTDIM left;
    WPI_RECTDIM top;
    WPI_RECTDIM right;
    WPI_RECTDIM bottom;
    img_node    *node;

    if( !fEnableCutCopy || !_wpi_iswindow( Instance, hwnd ) || clipRect.hwnd != hwnd ) {
        return;
    }

    pointsize = GetPointSize( hwnd );

    pres = _wpi_getpres( hwnd );
    _wpi_torgbmode( pres );
    prevROP2 = _wpi_setrop2( pres, R2_XORPEN );
    blackbrush = _wpi_createsolidbrush( BLACK );
    oldbrush = _wpi_selectobject( pres, blackbrush );

    whitepen = _wpi_createpen( PS_SOLID, 0, WHITE );
    oldpen = _wpi_selectobject( pres, whitepen );

    _wpi_getrectvalues( clipRect.rect, &left, &top, &right, &bottom );

    node = SelectImage( hwnd );
#ifdef __OS2_PM__
    _wpi_rectangle( pres, left * pointsize.x + 1, bottom * pointsize.y + 1,
                    right * pointsize.x, top * pointsize.y );
#else
    _wpi_rectangle( pres, left * pointsize.x, top * pointsize.y,
                    right * pointsize.x, bottom * pointsize.y );
#endif
    _wpi_selectobject( pres, oldpen );
    _wpi_selectobject( pres, oldbrush );
    _wpi_setrop2( pres, prevROP2 );
    _wpi_releasepres( hwnd, pres );
    _wpi_deleteobject( whitepen );
    _wpi_deleteobject( blackbrush );

} /* RedrawPrevClip */
Example #15
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 */
Example #16
0
int GUIGetScrollScreenSize( gui_window *wnd, int bar )
{
    GUI_RECTDIM left, top, right, bottom;

    _wpi_getclientrect( wnd->hwnd, &wnd->hwnd_client );
    _wpi_getrectvalues( wnd->hwnd_client, &left, &top, &right, &bottom );
    if( bar == SB_HORZ ) {
        return( right - left );
    } else {
        if( GUI_VSCROLL_ROWS( wnd ) ) {
            return( GUIFromTextY( wnd->num_rows, wnd ) );
        } else {
            return( bottom - top );
        }
    }
}
Example #17
0
/*
 * GetPosProc - get the position of all the child windows
 */
BOOL CALLBACK GetPosProc( HWND hwnd, LONG lparam )
{
    WPI_RECT    windowrect;
    WPI_POINT   topleft;        // this ends up being bottom left for PM
    WPI_RECTDIM left;
    WPI_RECTDIM top;

    lparam = lparam;

#ifdef __OS2_PM__
    if( windowIndex >= imageMax ) {
        return( 0 );
    }
#endif
    if( _wpi_getowner( hwnd ) != NULL ) {
        return( 1 );
    }

    if( _wpi_isiconic( hwnd ) ) {
        windowCoords[windowIndex].x = -1;
        windowCoords[windowIndex].y = -1;
        windowIndex++;
        return( 1 );
    }

    _wpi_getwindowrect( hwnd, &windowrect );
    _wpi_getrectvalues( windowrect, &left, &top, NULL, NULL );
    topleft.x = left;
    topleft.y = top;

    _wpi_screentoclient( ClientWindow, &topleft );
    if( topleft.x < 0 ) {
        topleft.x = 0;
    }
#ifndef __OS2_PM__
    if( topleft.y < 0 ) {
        topleft.y = 0;
    }
#endif
    windowCoords[windowIndex] = topleft;
    windowIndex++;
    return( 1 );

} /* GetPosProc */
Example #18
0
/*
 * ResetViewWindow - when a new MDI child is activated, reset the position
 *                   of the view window
 *                 - first check if only 1 view window is being shown, or all of them
 */
void ResetViewWindow( HWND hwnd )
{
    WPI_RECT    currentloc;
    WPI_RECT    newloc;
    WPI_RECTDIM left;
    WPI_RECTDIM top;
    WPI_RECTDIM right;
    WPI_RECTDIM bottom;
    HWND        hframe;
    HWND        currentframe;

    hframe = _wpi_getframe( hwnd );
    if( hViewWindow != NULL ) {
        currentframe = _wpi_getframe( hViewWindow );
    } else {
        currentframe = NULL;
    }

    if( fOneViewWindow ) {
        _wpi_getwindowrect( hframe, &newloc );
        if( hViewWindow != NULL ) {
            _wpi_getwindowrect( currentframe, &currentloc );
            ShowWindow( currentframe, SW_HIDE );
        } else {
            currentloc = newloc;
        }
        _wpi_getrectvalues( currentloc, &left, &top, &right, &bottom );

        SetWindowPos( hframe, NULL, left, top,
                     _wpi_getwidthrect( newloc ), _wpi_getheightrect( newloc ),
                     SWP_MOVE | SWP_SIZE | SWP_NOZORDER | SWP_HIDEWINDOW );
        hViewWindow = hwnd;
        ShowWindow( hframe, showState );
    } else {
        hViewWindow = hwnd;
        ShowWindow( hframe, showState );
        _wpi_bringwindowtotop( hframe );
    }
#ifndef __OS2_PM__
    RedrawWindow( hwnd, NULL, NULL, RDW_UPDATENOW );
#endif

} /* ResetViewWindow */
Example #19
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 );
}
Example #20
0
void GUIMakeRelative( gui_window *wnd, WPI_POINT *pt, gui_point *point )
{
    WPI_RECT    rect;
    GUI_RECTDIM left, top, right, bottom;

    rect = wnd->hwnd_client_rect;
    _wpi_mapwindowpoints( wnd->hwnd, HWND_DESKTOP, (WPI_LPPOINT)&rect, 2 );
    _wpi_getrectvalues( rect, &left, &top, &right, &bottom );
    point->x = pt->x - left;
    point->y = pt->y - top;

    if( GUI_DO_HSCROLL( wnd ) || GUI_DO_VSCROLL( wnd ) ) {
        if( GUI_DO_HSCROLL( wnd ) ) {
            point->x += GUIGetScrollPos( wnd, SB_HORZ );
        }
        if( GUI_DO_VSCROLL( wnd ) ) {
            point->y += GUIGetScrollPos( wnd, SB_VERT );
        }
    }
    GUIScreenToScaleRPt( point );
}
Example #21
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 */
Example #22
0
/*
 * doRestore - handle restoring an edit window
 */
static void doRestore( HWND hwnd )
{
    DWORD       style;
    mdi_data    *md;
    WPI_RECTDIM left;
    WPI_RECTDIM top;
    WPI_RECTDIM right;
    WPI_RECTDIM bottom;

    md = MDI_DATA_FROM_HWND( hwnd );

    if( md->curr_state == STATE_NORMAL ) {
        return;
    }

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

    md->curr_state = md->orig_state = STATE_NORMAL;

    if( mdiInfo.set_style != NULL ) {
        (mdiInfo.set_style)( hwnd, FALSE );
    } else {
        style = _wpi_getwindowlong( hwnd, GWL_STYLE );
        style &= ~mdiInfo.max_style;
        style |= mdiInfo.reg_style;
        _wpi_setwindowlong( hwnd, GWL_STYLE, style );
    }

    _wpi_setscrollrange( hwnd, SB_VERT, 1, 1, TRUE );
    _wpi_setscrollrange( hwnd, SB_HORZ, 1, 1, TRUE );
    _wpi_updatewindow( hwnd );
    _wpi_getrectvalues( md->orig_size, &left, &top, &right, &bottom );
    _wpi_movewindow( hwnd, left, top, right - left, bottom - top, TRUE );
    if( mdiInfo.end_max_restore != NULL ) {
        mdiInfo.end_max_restore( hwnd );
    }

} /* doRestore */
Example #23
0
/*
 * CheckBounds - checks the bounds vs the client rectangle.
 */
void CheckBounds( HWND hwnd, WPI_POINT *pt )
{
    WPI_RECT    client;
    IMGED_DIM   left;
    IMGED_DIM   right;
    IMGED_DIM   top;
    IMGED_DIM   bottom;

    GetClientRect(hwnd, &client);
    _wpi_getrectvalues( client, &left, &top, &right, &bottom );

    if (pt->x >= right) {
        pt->x = right-1;
    } else if (pt->x < left) {
        pt->x = left;
    }
    if (pt->y >= bottom) {
        pt->y = bottom-1;
    } else if (pt->y < top) {
        pt->y = top;
    }
} /* CheckBounds */
Example #24
0
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;
}
Example #25
0
bool GUIChangeToolBar( gui_window *wnd )
{
    gui_event   gui_ev;
    toolbarinfo *tbar;
    HWND        toolhwnd;
    int         t;
    GUI_RECTDIM left, top, right, bottom;

    tbar = wnd->tbinfo;
    if( !tbar->info.is_fixed ) {
        tbar->info.is_fixed = true;
        tbar->info.style = TOOLBAR_FIXED_STYLE;
        tbar->info.area = tbar->fixedrect;
        gui_ev = GUI_TOOLBAR_FIXED;
    } else {
        tbar->info.is_fixed = false;
        tbar->info.style = TOOLBAR_FLOAT_STYLE;
        tbar->info.area = tbar->floatrect;
        _wpi_cvtc_rect_plus1( wnd->root, &tbar->info.area );
        gui_ev = GUI_TOOLBAR_FLOATING;
    }
    ToolBarDisplay( tbar->hdl, &tbar->info );
    if( tbar->info.style != TOOLBAR_FLOAT_STYLE ) {
        ToolBarRedrawButtons( tbar->hdl );
    }
    toolhwnd = ToolBarWindow( tbar->hdl );
    if( tbar->info.style == TOOLBAR_FLOAT_STYLE ) {
        _wpi_getrectvalues( tbar->floatrect, &left, &top, &right, &bottom );
        t = top;
        //t = _wpi_cvtc_y_size( wnd->hwnd, t, bottom - top );
        t = _wpi_cvtc_y_plus1( wnd->root, t );
        _wpi_movewindow( toolhwnd, left, t, right-left, bottom-top, TRUE );
    }
    GUIResizeBackground( wnd, true );
    _wpi_showwindow( toolhwnd, SW_SHOWNORMAL );
    _wpi_updatewindow( toolhwnd );
    GUIEVENTWND( wnd, gui_ev, NULL );
    return( true );
}
Example #26
0
/*
 * MDIContainerResized - resize MDI windows when container resized, if we're
 *                       maximized
 */
void MDIContainerResized( void )
{
    mdi_data    *md;
    WPI_RECT    r;
    WPI_RECTDIM left;
    WPI_RECTDIM top;
    WPI_RECTDIM right;
    WPI_RECTDIM bottom;

    if( MDIIsMaximized() ) {
        _wpi_getwindowrect( mdiInfo.container, &r );
        _wpi_getrectvalues( r, &left, &top, &right, &bottom );
        md = mdiHead;
        while( md != NULL ) {
            if( _wpi_isiconic( md->hwnd ) ) {
                _wpi_movewindow( md->hwnd, 0, 0, right - left + 1,
                                 bottom - top + 1, TRUE );
            }
            md = md->next;
        }
    }

} /* MDIContainerResized */
Example #27
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 */
Example #28
0
/*
 * FlipImage - flip the image along either the x-axis or the y-axis
 */
void FlipImage( WORD whichway )
{
    img_node    *node;
    short       width;
    short       height;
    short       destwidth;
    short       destheight;
    short       new_left;
    short       new_top;
    WPI_RECT    dims;
    HBITMAP     xorflip;
    HBITMAP     oldflip;
    HBITMAP     oldbitmap;
    HBITMAP     andflip;
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HDC         memdc;
    WPI_PRES    flippres;
    HDC         flipdc;
    HCURSOR     prevcursor;
    IMGED_DIM   bottom;
    IMGED_DIM   left;
    IMGED_DIM   right;
    IMGED_DIM   top;

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

    PrintHintTextByID( WIE_FLIPPINGIMAGE, NULL );
    prevcursor = _wpi_setcursor( _wpi_getsyscursor( IDC_WAIT ) );

    if( !DoesRectExist( &dims ) ) {
        _wpi_setwrectvalues( &dims, 0, 0, (IMGED_DIM)node->width, (IMGED_DIM)node->height );
    }
    width = (short)_wpi_getwidthrect( dims );
    height = (short)_wpi_getheightrect( dims );

    pres = _wpi_getpres( HWND_DESKTOP );
    if( node->bitcount == 1 ) {
        xorflip = _wpi_createbitmap( width, height, 1, 1, NULL );
    } else {
#if 1
        xorflip = _wpi_createcompatiblebitmap( pres, width, height );
#else
        xorflip = _wpi_createbitmap( width, height, ColorPlanes, BitsPerPixel, NULL );
#endif
    }
    andflip = _wpi_createbitmap( width, height, 1, 1, NULL );

    mempres = _wpi_createcompatiblepres( pres, Instance, &memdc );
    flippres = _wpi_createcompatiblepres( pres, Instance, &flipdc );
    _wpi_releasepres( HWND_DESKTOP, pres );

    _wpi_getrectvalues( dims, &left, &top, &right, &bottom );
    _wpi_preparemono( flippres, BLACK, WHITE );

    oldbitmap = _wpi_selectobject( mempres, node->hxorbitmap );
    oldflip = _wpi_selectobject( flippres, xorflip );
    _wpi_bitblt( flippres, 0, 0, width, height, mempres, left, top, SRCCOPY );
    _wpi_selectobject( mempres, oldbitmap );
    _wpi_selectobject( flippres, oldflip );

    oldbitmap = _wpi_selectobject( mempres, node->handbitmap );
    oldflip = _wpi_selectobject( flippres, andflip );
    _wpi_bitblt( flippres, 0, 0, width, height, mempres, left, top, SRCCOPY );

    if( whichway == IMGED_FLIPVERT ) {
        destwidth = -1 * width;
        new_left = right - 1;
        new_top = top;
        destheight = height;
    } else {
        destwidth = width;
        new_left = left;
        new_top = bottom - 1;
        destheight = -1 * height;
    }

    _wpi_stretchblt( mempres, new_left, new_top, destwidth, destheight,
                     flippres, 0, 0, width, height, SRCCOPY );
    _wpi_selectobject( mempres, oldbitmap );
    oldbitmap = _wpi_selectobject( mempres, node->hxorbitmap );
    _wpi_selectobject( flippres, oldflip );
    oldflip = _wpi_selectobject( flippres, xorflip );
    _wpi_stretchblt( mempres, new_left, new_top, destwidth, destheight,
                     flippres, 0, 0, width, height, SRCCOPY );
    _wpi_selectobject( mempres, oldbitmap );
    _wpi_selectobject( flippres, oldflip );

    _wpi_deleteobject( xorflip );
    _wpi_deleteobject( andflip );
    _wpi_deletecompatiblepres( mempres, memdc );
    _wpi_deletecompatiblepres( flippres, flipdc );

    InvalidateRect( node->viewhwnd, NULL, TRUE );

    if( !DoKeepRect() ) {
        SetRectExists( FALSE );
    }
    RecordImage( node->hwnd );
    BlowupImage( node->hwnd, NULL );
    if( whichway == IMGED_FLIPHORZ ) {
        PrintHintTextByID( WIE_IMAGEREFLECTEDH, NULL );
    } else {
        PrintHintTextByID( WIE_IMAGEREFLECTEDV, NULL );
    }
    _wpi_setcursor( prevcursor );

} /* FlipImage */
Example #29
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 );
}
Example #30
0
/*
 * showGrid - Display the grid on the draw area.
 */
static void showGrid( HWND hwnd, WPI_PRES mempres )
{
    short       i;
    short       psx;
    short       psy;
    WPI_RECT    rcclient;
    HPEN        hblackpen;
    HPEN        holdpen;
    img_node    *node;
    short       width;
    short       height;
    IMGED_DIM   left;
    IMGED_DIM   right;
    IMGED_DIM   top;
    IMGED_DIM   bottom;
    WPI_PRES    pres;
    WPI_POINT   startpt;
    WPI_POINT   endpt;

    node = SelectImage( hwnd );

    _wpi_torgbmode( mempres );
    GetClientRect( hwnd, &rcclient );
    width = (short)( _wpi_getwidthrect(rcclient) );
    height = (short)( _wpi_getheightrect(rcclient) );

    if (((width / node->width) < POINTSIZE_MIN) ||
                                ((height / node->height) < POINTSIZE_MIN)) {
        psx = 0;
        psy = 0;
    } else {
        psx = width / node->width;
        psy = height / node->height;

        hblackpen = _wpi_createpen( PS_SOLID, 0, BLACK );
        holdpen = _wpi_selectobject( mempres, hblackpen );

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

        for (i=0; i < width; i = i + psx) {
            _wpi_setpoint( &startpt, i, top );
            _wpi_setpoint( &endpt, i, bottom );
            _wpi_movetoex( mempres, &startpt, NULL );
            _wpi_lineto( mempres, &endpt );
        }
        for (i=0; i <= height; i = i + psy) {
            _wpi_setpoint( &startpt, left, i );
            _wpi_setpoint( &endpt, right, i );
            _wpi_movetoex( mempres, &startpt, NULL );
            _wpi_lineto( mempres, &endpt );
        }

        _wpi_selectobject( mempres, holdpen );
        _wpi_deleteobject( hblackpen );
    }

    pres = _wpi_getpres( hwnd );
    _wpi_bitblt( pres, 0, 0, width, height, mempres, 0, 0, SRCCOPY );
    _wpi_releasepres( hwnd, pres );
    RedrawPrevClip(hwnd);  // Redraws if there was a clip region specified.
} /* showGrid */