Exemplo n.º 1
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 */
Exemplo n.º 2
0
/*
 * BitmapPickProc - handle messages for choosing the region to begin the
 *                  editing session.
 */
LONG CALLBACK BitmapPickProc( HWND hwnd, UINT msg, UINT wparam, LONG lparam )
{
    static POINT        topleft;
    static POINT        bottomright;
    static RECT         prevpos;
    static BOOL         firsttime = TRUE;
    static BOOL         buttondown;
    static HCURSOR      prevcursor;
    static HCURSOR      crosshairs;
    HDC                 hdc;

    switch ( msg ) {
    case WM_CREATE:
        crosshairs = LoadCursor( Instance, CROSSHAIRSCUR );
        prevcursor = SetCursor( crosshairs );
        SetCapture( hwnd );
        firsttime = TRUE;
        SetRect( &prevpos, 0, 0, 0, 0 );
        break;

    case WM_LBUTTONDOWN:
        GetCursorPos( &topleft );
        buttondown = TRUE;
        break;

    case WM_LBUTTONUP:
        GetCursorPos( &bottomright );
        SetRect( &bmpRegion, topleft.x, topleft.y, bottomright.x, bottomright.y );
        checkRectBounds( &bmpRegion );
        hdc = GetDC( NULL );
        OutlineRectangle( TRUE, hdc, &prevpos, &bmpRegion );
        ReleaseDC( NULL, hdc );
        buttondown = FALSE;
        ReleaseCapture();
        SendMessage( hwnd, WM_CLOSE, 0, 0L );
        break;

    case WM_MOUSEMOVE:
        if (buttondown) {
            GetCursorPos( &bottomright );
            SetRect( &bmpRegion, topleft.x, topleft.y, bottomright.x, bottomright.y );
            checkRectBounds( &bmpRegion );
            hdc = GetDC( NULL );
            OutlineRectangle( firsttime, hdc, &prevpos, &bmpRegion );
            ReleaseDC( NULL, hdc );
            firsttime = FALSE;
            prevpos = bmpRegion;
        }
        break;

    case WM_DESTROY:
        notDestroyed = FALSE;
        SetCursor( prevcursor );
        DestroyCursor( crosshairs );
        break;

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

} /* BitmapPickProc */