Esempio n. 1
0
VOID SetColorPalette(
    INT nColors,
    INT iType,
    BOOL fForce)
{
    /*
     * Quit if nothing changed (unless they are forcing it to be updated).
     */
    if (!fForce && nColors == gnColorPalColors && iType == giColorPalType)
        return;

    /*
     * Set the globals that all the color palette routines use.
     */
    gnColorPalColors = nColors;
    giColorPalType = iType;

    if (gnColorPalColors == 2)
        gargbCurrent = gargbMono;
    else
        gargbCurrent = gargbColor;

    ShowWindow(GetDlgItem(ghwndColor, DID_COLORSCREENLABEL),
            (giColorPalType == FT_BITMAP) ? SW_HIDE : SW_SHOW);
    ShowWindow(GetDlgItem(ghwndColor, DID_COLORINVERSELABEL),
            (giColorPalType == FT_BITMAP) ? SW_HIDE : SW_SHOW);

    SetLeftColor(1, MODE_COLOR);
    SetRightColor(0, MODE_COLOR);

    InvalidateRect(GetDlgItem(ghwndColor, DID_COLORBOX), NULL, TRUE);
}
RSubCube::RSubCube(GLfloat _size)
	: Cube(_size)
{
	SetFaceColors(Colors::Gray);
	SetBottomColor(Colors::DarkGray);
	SetTopColor(Colors::DarkGray);
	SetLeftColor(Colors::DarkGray);
	SetRightColor(Colors::DarkGray);
	moveList = new std::list<Move>();
}
Esempio n. 3
0
STATICFN VOID NEAR ColorBoxClicked(
    UINT msg,
    PPOINT ppt)
{
    INT iColor;
    INT iMode;

    if (ColorBoxHitTest(ppt, &iColor, &iMode)) {
        switch (msg) {
            case WM_LBUTTONDOWN:
                SetLeftColor(iColor, iMode);
                break;

            case WM_RBUTTONDOWN:
                SetRightColor(iColor, iMode);
                break;
        }
    }
}
Esempio n. 4
0
STATICFN VOID NEAR ColorProcessCommand(
    HWND hwnd,
    INT idCtrl,
    INT NotifyCode)
{
    switch (idCtrl) {
        case DID_COLOREDIT:
            ColorEdit();
            break;

        case DID_COLORDEFAULT:
            if (gfModeLeft == MODE_COLOR) {
                gargbColor[giColorLeft] = gargbDefaultColor[giColorLeft];
                InvalidateRect(GetDlgItem(ghwndColor, DID_COLORBOX),
                        NULL, TRUE);
                SetLeftColor(giColorLeft, gfModeLeft);
            }

            break;
    }
}
Esempio n. 5
0
STATICFN VOID NEAR ColorEdit(VOID)
{
    /*
     * This array of custom colors is initialized to all white colors.
     * The custom colors will be remembered between calls, but not
     * between sessions.
     */
    static DWORD argbCust[16] = {
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255),
        RGB(255, 255, 255), RGB(255, 255, 255)
    };
    CHOOSECOLOR cc;
    DWORD rgbOld;
    BOOL fResult;
    INT idPrevDlg;

    switch (gfModeLeft) {
        case MODE_COLOR:
            /*
             * The monochrome palette cannot be edited.
             */
            if (gnColorPalColors == 2)
                return;

            rgbOld = gargbCurrent[giColorLeft];
            break;

        case MODE_SCREEN:
            rgbOld = grgbScreen;
            break;

        case MODE_INVERSE:
            rgbOld = grgbInverse;
            break;
    }

    cc.lStructSize = sizeof(CHOOSECOLOR);
    cc.hwndOwner = ghwndMain;
    cc.hInstance = ghInst;
    cc.rgbResult = rgbOld;
    cc.lpCustColors = argbCust;
    cc.Flags = CC_RGBINIT | CC_SHOWHELP;
    cc.lCustData = 0;
    cc.lpfnHook = NULL;
    cc.lpTemplateName = NULL;

    EnteringDialog(DID_COMMONFILECHOOSECOLOR, &idPrevDlg, TRUE);
    fResult = ChooseColor(&cc);
    EnteringDialog(idPrevDlg, NULL, FALSE);

    if (fResult && rgbOld != cc.rgbResult) {
        switch (gfModeLeft) {
            case MODE_COLOR:
                gargbCurrent[giColorLeft] = cc.rgbResult;
                break;

            case MODE_SCREEN:
                SetScreenColor(cc.rgbResult);
                break;

            case MODE_INVERSE:
                SetScreenColor(ComputeInverseColor(cc.rgbResult));
                break;
        }

        SetLeftColor(giColorLeft, gfModeLeft);
        InvalidateRect(GetDlgItem(ghwndColor, DID_COLORBOX), NULL, TRUE);
    }
}
Esempio n. 6
0
VOID SetScreenColor(
    DWORD rgb)
{
    DWORD rgbInverse;
    HDC hdcTemp;
    HBITMAP hbmOld;
    HDC hdcANDTemp;
    HBITMAP hbmANDOld;

    rgb = MyGetNearestColor(rgb, FALSE);

    /*
     * Because we are about to change the screen color, separate
     * out the XOR mask (but only for icons/cursors).
     */
    if (giColorPalType != FT_BITMAP) {
        if (gpImageCur) {
            ImageDCSeparate(ghdcImage, gcxImage, gcyImage, ghdcANDMask,
                    grgbScreen);

            /*
             * Is there a pending undo buffer?  If so, it must be
             * changed as well or an undo that is done after a screen
             * color change will restore the wrong colors!
             */
            if (ghbmUndo) {
                /*
                 * Create some temporary DC's to use when separating
                 * out the undo buffer's masks.  These will be deleted
                 * a little later.
                 */
                hdcTemp = CreateCompatibleDC(ghdcImage);
                hbmOld = SelectObject(hdcTemp, ghbmUndo);
                hdcANDTemp = CreateCompatibleDC(ghdcANDMask);
                hbmANDOld = SelectObject(hdcANDTemp, ghbmUndoMask);

                /*
                 * Separate out the undo buffer's colors, before
                 * changing the screen color.  It will be combined
                 * later.
                 */
                ImageDCSeparate(hdcTemp, gcxImage, gcyImage, hdcANDTemp,
                        grgbScreen);
            }
        }
    }

    if (ghbrScreen)
        DeleteObject(ghbrScreen);

    ghbrScreen = CreateSolidBrush(rgb);
    grgbScreen = rgb;

    if (ghbrInverse)
        DeleteObject(ghbrInverse);

    rgbInverse = ComputeInverseColor(rgb);
    ghbrInverse = CreateSolidBrush(rgbInverse);
    grgbInverse = rgbInverse;

    /*
     * For icons and cursors, we might need to update a few more things.
     */
    if (giColorPalType != FT_BITMAP) {
        /*
         * Recombine the XOR and AND images now that there is a new screen
         * color.  This updates the image DC with the new color properly.
         */
        if (gpImageCur) {
            ImageDCCombine(ghdcImage, gcxImage, gcyImage, ghdcANDMask);

            /*
             * Is there a pending undo buffer?  If so, it has to be
             * recombined with the new screen color.
             */
            if (ghbmUndo) {
                ImageDCCombine(hdcTemp, gcxImage, gcyImage, hdcANDTemp);

                /*
                 * Clean up the DC's that were allocated a little earlier.
                 */
                SelectObject(hdcANDTemp, hbmANDOld);
                DeleteDC(hdcANDTemp);
                SelectObject(hdcTemp, hbmOld);
                DeleteDC(hdcTemp);
            }
        }

        /*
         * Reset the colors on the mouse buttons, just in case a screen
         * or inverse screen color was assigned to either of them.
         */
        SetLeftColor(giColorLeft, gfModeLeft);
        SetRightColor(giColorRight, gfModeRight);

        InvalidateRect(GetDlgItem(ghwndColor, DID_COLORBOX), NULL, TRUE);
    }

    ViewUpdate();
}