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>(); }
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; } } }
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(); }