コード例 #1
0
ファイル: clrcntls.c プロジェクト: Ukusbobra/open-watcom-v2
/*
 * selectScreen - selects the screen color
 */
static void selectScreen( WPI_POINT *pt, int mousebutton )
{
    WPI_RECT    wrect;
    int         top;
    int         bottom;

    if( !fShowScreenClr ) {
        return;
    }
    top = _wpi_cvth_y( screenColor.box.top, screenHeight );
    bottom = _wpi_cvth_y( screenColor.box.bottom, screenHeight );

    _wpi_setintwrectvalues( &wrect, screenColor.box.left, top,
                                    screenColor.box.right, bottom );

    if( _wpi_ptinrect( &wrect, *pt ) ) {
        SetColor( mousebutton, screenColor.color, screenColor.color, SCREEN_CLR );
        return;
    }

    top = _wpi_cvth_y( inverseColor.box.top, screenHeight );
    bottom = _wpi_cvth_y( inverseColor.box.bottom, screenHeight );

    _wpi_setintwrectvalues( &wrect, inverseColor.box.left, top,
                                    inverseColor.box.right, bottom );
    if( _wpi_ptinrect( &wrect, *pt ) ) {
        SetColor( mousebutton, inverseColor.color, inverseColor.color, INVERSE_CLR );
        return;
    }

} /* selectScreen */
コード例 #2
0
ファイル: clrcntls.c プロジェクト: Ukusbobra/open-watcom-v2
/*
 * ScreenWndProc - handle messages for the screen and inverse windows
 */
WPI_MRESULT CALLBACK ScreenWndProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    WPI_POINT   pt;
    WPI_RECT    wrect1;
    WPI_RECT    wrect2;
    int         top;
    int         bottom;

    switch( msg ) {
    case WM_PAINT:
        paintScreen( hwnd );
        break;

    case WM_LBUTTONDOWN:
        IMGED_MAKEPOINT( wparam, lparam, pt );
        selectScreen( &pt, LMOUSEBUTTON );
        break;

    case WM_LBUTTONDBLCLK:
        if( !fShowScreenClr ) {
            break;
        }

        IMGED_MAKEPOINT( wparam, lparam, pt );

        top = _wpi_cvth_y( screenColor.box.top, screenHeight );
        bottom = _wpi_cvth_y( screenColor.box.bottom, screenHeight );
        _wpi_setintwrectvalues( &wrect1, screenColor.box.left, top,
                                         screenColor.box.right, bottom );

        top = _wpi_cvth_y( inverseColor.box.top, screenHeight );
        bottom = _wpi_cvth_y( inverseColor.box.bottom, screenHeight );
        _wpi_setintwrectvalues( &wrect2, inverseColor.box.left, top,
                                         inverseColor.box.right, bottom );
        if( _wpi_ptinrect( &wrect1, pt ) || _wpi_ptinrect( &wrect2, pt ) ) {
            ChooseBkColor();
        }
        break;

    case WM_RBUTTONDOWN:
        IMGED_MAKEPOINT( wparam, lparam, pt );
        selectScreen( &pt, RMOUSEBUTTON );
        break;

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

} /* ScreenWndProc */
コード例 #3
0
/*
 * selectColor - select the color
 */
static void selectColor( WPI_POINT *pt, HWND hwnd )
{
    int         i;
    WPI_PRES    pres;
    HWND        currentwnd;
    int         top;
    int         bottom;
    WPI_RECT    wrect;

    currentwnd = _wpi_getdlgitem( hwnd, BK_CURRENT );
    pres = _wpi_getpres( currentwnd );
    _wpi_mapwindowpoints( hwnd, currentwnd, pt, 1 );

    _wpi_torgbmode( pres );
    for( i = 0; i < 16; i++ ) {
        top = availColor[i].box.top;
        bottom = availColor[i].box.bottom;

        top = _wpi_cvth_y( top, 2 * SQR_SIZE );
        bottom = _wpi_cvth_y( bottom, 2 * SQR_SIZE );
        _wpi_setintwrectvalues( &wrect, availColor[i].box.left, top,
                                        availColor[i].box.right, bottom );
        if( _wpi_ptinrect( &wrect, *pt ) ) {
            screenColor.color = availColor[i].color;
            DisplayColorBox( pres, &screenColor );

            inverseColor.color = GetInverseColor( screenColor.color );
            DisplayColorBox( pres, &inverseColor );
            break;
        }
    }
    _wpi_releasepres( currentwnd, pres );

} /* selectColor */
コード例 #4
0
/*
 * SetPosInStatus - set the position in the status window
 */
void SetPosInStatus( WPI_POINT *pt, WPI_POINT *pointsize, HWND hwnd )
{
    WPI_PRES    pres;
    WPI_RECT    rcclient;
    int         x;
    int         y;

    GetClientRect( hwnd, &rcclient );

    if( _wpi_ptinrect( &rcclient, *pt ) && PositionText != NULL && SetPosText != NULL ) {
        if( pointsize->x == 0 ) {
            pointsize->x = 1;
        }
        if( pointsize->y == 0 ) {
            pointsize->y = 1;
        }
        x = pt->x / pointsize->x;
        y = pt->y / pointsize->y;

        sprintf( PositionText, SetPosText, leftBlock, x, y );
        pres = _wpi_getpres( statusBarWnd );
        StatusWndDrawLine( statusBar, pres, SmallFont, PositionText, -1 );
        _wpi_releasepres( statusBarWnd, pres );
    }

} /* SetPosInStatus */
コード例 #5
0
ファイル: clrcntls.c プロジェクト: Ukusbobra/open-watcom-v2
/*
 * editCurrentColor - edit the color under the cursor
  */
static void editCurrentColor( WPI_POINT *pt )
{
    int         i;
    WPI_RECT    wrect;
    int         top;
    int         bottom;

    for( i = 0; i < PALETTE_SIZE; i++ ) {
        top = _wpi_cvth_y( paletteBox[i].box.top, colorsHeight );
        bottom = _wpi_cvth_y( paletteBox[i].box.bottom, colorsHeight );

        _wpi_setintwrectvalues( &wrect, paletteBox[i].box.left, top,
                                        paletteBox[i].box.right, bottom );
        if( _wpi_ptinrect( &wrect, *pt ) ) {
            if( numberOfColors == 2 ) {
                return;
            } else {
#ifndef __OS2_PM__
                EditColors();
#endif
                return;
            }
        }
    }

} /* editCurrentColor */
コード例 #6
0
ファイル: wmdisim.c プロジェクト: hubei/open-watcom
/*
 * 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 */
コード例 #7
0
ファイル: clrcntls.c プロジェクト: Ukusbobra/open-watcom-v2
/*
 * selectColor - select the color under the cursor
 */
static void selectColor( WPI_POINT *pt, int mousebutton )
{
    short       i;
    WPI_RECT    wrect;
    int         top;
    int         bottom;

    for( i = 0; i < PALETTE_SIZE; i++ ) {
        top = _wpi_cvth_y( paletteBox[i].box.top, colorsHeight );
        bottom = _wpi_cvth_y( paletteBox[i].box.bottom, colorsHeight );

        _wpi_setintrectvalues( &wrect, paletteBox[i].box.left, top,
                                       paletteBox[i].box.right, bottom );
        if( _wpi_ptinrect( &wrect, *pt ) ) {
            SetColor( mousebutton, paletteBox[i].color,
                                   paletteBox[i].solid_color, NORMAL_CLR );
            return;
        }
    }

} /* selectColor */
コード例 #8
0
ファイル: ieutil.c プロジェクト: Azarien/open-watcom-v2
/*
 * 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 */