⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clrcntls.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
        selectColour(&pt, RMOUSEBUTTON);
        break;

    case WM_DESTROY:
        _wpi_deletebitmap( hColourBitmap );
        _wpi_deletebitmap( hMonoBitmap );
        break;

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

} /* CurrentWndProc */

/*
 * ScreenWndProc - handle messages for the screen and inverse windows
 */
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( screenColour.box.top, screenHeight );
        bottom = _wpi_cvth_y( screenColour.box.bottom, screenHeight );
        _wpi_setintwrectvalues( &wrect1, screenColour.box.left, top,
                                            screenColour.box.right, bottom );

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

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

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

/*
 * CreateColourControls - Creates controls in the colour palette window.
 */
void CreateColourControls( HWND hparent )
{
    WPI_RECT    rect;
#ifdef __OS2_PM__
    PM_CreateColourCtrls( hparent, &hColoursWnd, &hScreenWnd, &hScreenTxt,
                                        &hInverseTxt );
#else
    Win_CreateColourCtrls( hparent, &hColoursWnd, &hScreenWnd, &hScreenTxt,
                                        &hInverseTxt );
#endif
    _wpi_getclientrect( hColoursWnd, &rect );
    coloursHeight = _wpi_getheightrect( rect );
    _wpi_getclientrect( hScreenWnd, &rect );
    screenHeight =_wpi_getheightrect( rect );
} /* CreateColourControls */

/*
 * DisplayScreenClrs - Depending on the parameter, display the screen colour
 *                     and the inverse colour (for icons and cursors but
 *                     not for bitmaps).
 */
void DisplayScreenClrs( BOOL fdisplay )
{
    HWND        frame;
    char        *text;

    frame = _wpi_getframe( hScreenWnd );

    if (!fdisplay) {
        if (fShowScreenClr) {
            ChangeCurrentColour();
        }
        SetWindowText( hScreenTxt, "" );
        SetWindowText( hInverseTxt, "");
        fShowScreenClr = FALSE;
        ShowWindow( frame, SW_HIDE );
    } else {
        text = IEAllocRCString( WIE_SCREENTEXT );
        if( text ) {
            SetWindowText( hScreenTxt, text );
            IEFreeRCString( text );
        } else {
            SetWindowText( hScreenTxt, "Screen:" );
        }
        text = IEAllocRCString( WIE_INVERSETEXT );
        if( text ) {
            SetWindowText( hInverseTxt, text );
            IEFreeRCString( text );
        } else {
            SetWindowText( hInverseTxt, "Inverse:" );
        }
        fShowScreenClr = TRUE;
        ShowWindow( frame, SW_SHOWNORMAL );
#ifdef __OS2_PM__
        InvalidateRect( hScreenWnd, NULL, TRUE );
#endif
    }
} /* DisplayScreenClrs */

/*
 * SetNumColours - sets the number of colours in the image and repaints the
 *                      window.
 */
void SetNumColours( int number_of_colours )
{
    HMENU       hmenu;
    HWND        frame;

    if (numberOfColours == number_of_colours) {
        return;
    }
    SetCurrentNumColours( number_of_colours );
    numberOfColours = number_of_colours;
    initPaletteBoxes(FALSE);
    _wpi_invalidaterect( hColoursWnd, NULL, FALSE );

    if (numberOfColours == 2) {
        if (HMainWindow) {
            frame = _wpi_getframe( HMainWindow );
            hmenu = GetMenu( frame );
            if ( _wpi_isitemenabled(hmenu, IMGED_RCOLOUR) ) {
                prevRestoreState = TRUE;
            } else {
                prevRestoreState = FALSE;
            }
            _wpi_enablemenuitem( hmenu, IMGED_SCOLOUR, FALSE, FALSE );
            _wpi_enablemenuitem( hmenu, IMGED_RCOLOUR, FALSE, FALSE );
            _wpi_enablemenuitem( hmenu, IMGED_LCOLOUR, FALSE, FALSE );
        }
    } else {
        if (HMainWindow) {
            frame = _wpi_getframe( HMainWindow );
            hmenu = GetMenu( frame );
            _wpi_enablemenuitem( hmenu, IMGED_SCOLOUR, TRUE, FALSE );
            _wpi_enablemenuitem(hmenu, IMGED_RCOLOUR, prevRestoreState, FALSE);
            _wpi_enablemenuitem( hmenu, IMGED_LCOLOUR, TRUE, FALSE );
        }
    }
} /* SetNumColours */

/*
 * SetScreenClr - sets the colour to represent the screen.
 */
void SetScreenClr( COLORREF screen_colour )
{
    WPI_PRES    pres;

    pres = _wpi_getpres( HWND_DESKTOP );
    _wpi_torgbmode( pres );
    screenColour.colour = _wpi_getnearestcolor(pres, screen_colour);
    screenColour.solid_colour = screenColour.colour;
    _wpi_releasepres( HWND_DESKTOP, pres );

    inverseColour.colour = GetInverseColour( screenColour.colour );
    inverseColour.solid_colour = inverseColour.colour;

    VerifyCurrentClr( screenColour.colour, inverseColour.colour );
    _wpi_invalidaterect( hScreenWnd, NULL, FALSE );
} /* SetScreenClr */

/*
 * ShowNewColour - replaces the colour of the colour box and re-displays the
 *                      boxes.
 */
void ShowNewColour( int index, COLORREF newcolour, BOOL repaint )
{
    WPI_POINT   topleft;
    WPI_POINT   bottomright;
    WPI_PRES    pres;
    WPI_PRES    mempres;
    HDC         hdc;
    HBITMAP     oldbitmap;
    HBRUSH      brush;
    HBRUSH      oldbrush;
    HPEN        blackpen;
    HPEN        oldpen;

    pres = _wpi_getpres( HWND_DESKTOP );
    _wpi_torgbmode( pres );
    paletteBox[index].colour = newcolour;
    paletteBox[index].solid_colour = _wpi_getnearestcolor( pres, newcolour );
    _wpi_releasepres( HWND_DESKTOP, pres );

    if (numberOfColours != 2) {
        topleft.x = (index / 2) * SQR_SIZE;
        bottomright.x = topleft.x + SQR_SIZE + 1;
        if ( (index/2) == (index+1)/2 ) {
            topleft.y = 0;
            bottomright.y = SQR_SIZE + 1;
        } else {
            topleft.y = SQR_SIZE;
            bottomright.y = 2*SQR_SIZE + 1;
        }
        pres = _wpi_getpres( HWND_DESKTOP );
        mempres = _wpi_createcompatiblepres( pres, Instance, &hdc );
        _wpi_releasepres( HWND_DESKTOP, pres );
        _wpi_torgbmode( mempres );

        brush = _wpi_createsolidbrush( newcolour );
        oldbrush = _wpi_selectobject( mempres, brush );
        blackpen = _wpi_createpen( PS_SOLID, 0, BLACK );
        oldpen = _wpi_selectobject( mempres, blackpen );
        oldbitmap = _wpi_selectbitmap( mempres, hColourBitmap );

        _wpi_cvth_pt( &topleft, coloursHeight );
        _wpi_cvth_pt( &bottomright, coloursHeight );

        _wpi_rectangle( mempres, topleft.x, topleft.y, bottomright.x,
                                                            bottomright.y );
        _wpi_selectobject( mempres, oldpen );
        _wpi_selectobject( mempres, oldbrush );
        _wpi_deleteobject( blackpen );
        _wpi_deleteobject( brush );
        _wpi_getoldbitmap( mempres, oldbitmap );
        _wpi_deletecompatiblepres( mempres, hdc );
    }

    if (repaint) {
        _wpi_invalidaterect( hColoursWnd, NULL, FALSE );
    }
} /* ShowNewColour */

/*
 * SetInitScreenColour - sets the initial screen and inverse colours from
 *                       the profile information.
 */
void SetInitScreenColour( COLORREF colour )
{
    WPI_PRES    pres;

    pres = _wpi_getpres( HWND_DESKTOP );
    _wpi_torgbmode( pres );
    screenColour.colour = _wpi_getnearestcolor(pres, colour);
    screenColour.solid_colour = screenColour.colour;
    _wpi_releasepres( HWND_DESKTOP, pres );

    SetBkColour( screenColour.colour );
} /* SetInitScreenColour */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -