Exemple #1
0
/*
 * 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 */
Exemple #2
0
/*
 * 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 */
Exemple #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 */
Exemple #4
0
/*
 * 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 */
Exemple #5
0
/*
 * paintCurrent - paint the current window (process WM_PAINT)
 */
static void paintCurrent( HWND hwnd )
{
    WPI_PRES            pres;
    WPI_PRES            mempres;
    HDC                 hdc;
    PAINTSTRUCT         ps;
    WPI_RECT            rect;
    HBITMAP             oldbitmap;
    int                 top;
    int                 bottom;

    pres = _wpi_beginpaint( hwnd, NULL, &ps );
#ifdef __OS2_PM__
    WinFillRect( pres, &ps, CLR_PALEGRAY );
#endif

    mempres = _wpi_createcompatiblepres( pres, Instance, &hdc );
    _wpi_torgbmode( pres );
    _wpi_torgbmode( mempres );
    oldbitmap = _wpi_selectobject( mempres, lButton.bitmap );

    _wpi_bitblt( pres, 0, 0, CUR_SQR_SIZE + 1, 2 * CUR_SQR_SIZE + 1, mempres,
                 0, 0, SRCCOPY );
    _wpi_selectobject( mempres, oldbitmap );
    oldbitmap = _wpi_selectobject( mempres, rButton.bitmap );

    _wpi_bitblt( pres, CUR_RCOL_X - 1, 0, CUR_SQR_SIZE + 1, 2 * CUR_SQR_SIZE + 1,
                 mempres, 0, 0, SRCCOPY );

    _wpi_selectobject( mempres, oldbitmap );
    _wpi_deletecompatiblepres( mempres, hdc );

    _wpi_setbackmode( pres, TRANSPARENT );
    _wpi_settextcolor( pres, GetInverseColor( lButton.solid ) );

    top = _wpi_cvth_y( CUR_COL_Y, currentHeight );
    bottom = _wpi_cvth_y( CUR_COL_Y + CUR_SQR_SIZE, currentHeight );
    _wpi_setintwrectvalues( &rect, CUR_LCOL_X, top, CUR_LCOL_X + CUR_SQR_SIZE, bottom );
    _wpi_drawtext( pres, "L", 1, &rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER );
    _wpi_settextcolor( pres, GetInverseColor( rButton.solid ) );
    _wpi_setintwrectvalues( &rect, CUR_RCOL_X, top, CUR_RCOL_X + CUR_SQR_SIZE, bottom );
    _wpi_drawtext( pres, "R", 1, &rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER );
    _wpi_endpaint( hwnd, pres, &ps );

} /* paintCurrent */