void GraphicsMisc::DrawGlass(CDC* pDC, LPCRECT pRect, COLORREF crFrom, COLORREF crTo, BOOL bHorz, int nBorder) { CRect rBarFrom(pRect), rBarTo(pRect); if (bHorz) { rBarFrom.right = rBarFrom.left + (rBarFrom.Width() * 2 / 5); rBarTo.left = rBarFrom.right; } else // vert { rBarFrom.bottom = rBarFrom.top + (rBarFrom.Height() * 2 / 5); rBarTo.top = rBarFrom.bottom; } DrawGradient(pDC, rBarFrom, Lighter(crFrom, 0.2), crFrom, bHorz, -1); DrawGradient(pDC, rBarTo, crTo, Lighter(crTo, 0.2), bHorz, -1); if (nBorder >= 0) { // draw a border in from the edge CRect rBorder(pRect); rBorder.DeflateRect(nBorder, nBorder); DrawRect(pDC, rBorder, CLR_NONE, crFrom); } }
COLORREF GraphicsMisc::GetGradientEdgeColor(GM_GRADIENT nType, COLORREF color, BOOL /*bFrom*/) { switch (nType) { case GMG_GRADIENT: case GMG_GLASSWITHGRADIENT: return color; case GMG_GLASS: return Lighter(color, 0.2); } // all the rest ASSERT(0); return color; }
void GraphicsMisc::DrawSplitBar(CDC* pDC, const CRect& rSplitter, COLORREF crSplitBar, BOOL bEdged) { BOOL bVert = (rSplitter.Height() > rSplitter.Width()); DWORD dwEdges = (bEdged ? (bVert ? (GMDR_LEFT | GMDR_RIGHT) : (GMDR_TOP | GMDR_BOTTOM)) : 0); DrawRect(pDC, rSplitter, crSplitBar, Darker(crSplitBar, 0.2), 0, dwEdges); // draw drag marker (2 x 20) int nSplitWidth = min(rSplitter.Width(), rSplitter.Height()); if (nSplitWidth > 2) { CRect rMarker(rSplitter); CPoint ptCentre = rMarker.CenterPoint(); if (bVert) { rMarker.left = ptCentre.x - 1; rMarker.right = ptCentre.x + 1; rMarker.top = ptCentre.y - 10; rMarker.bottom = ptCentre.y + 10; } else // horizontal { rMarker.left = ptCentre.x - 10; rMarker.right = ptCentre.x + 10; rMarker.top = ptCentre.y - 1; rMarker.bottom = ptCentre.y + 1; } // use the splitter bkgnd luminance to decide whether // to draw the marker lighter or darker if (RGBX(crSplitBar).Luminance() > 128) pDC->FillSolidRect(rMarker, Darker(crSplitBar, 0.3)); else pDC->FillSolidRect(rMarker, Lighter(crSplitBar, 0.3)); } }
wxRibbonHSLColour wxRibbonHSLColour::Darker(float delta) const { return Lighter(-delta); }