/***************************************************************************** ** Draw a rectangular frame from iSX,iSY to iDX,iDY. The type specifies ** whether to draw the lines as single or double line characters from the ** extended character set. The style is applied to all characters. */ VOID FAR PASCAL __export PlotFrame(int iSX, int iSY, int iDX, int iDY, char cType, char cStyle) { LPSTR lpExtChars; #ifdef PROTECT if (lpMonoMem == NULL) return; #endif #ifdef CLIP if ((iSX < 0) || (iSX > 79) || (iDX < 0) || (iDX > 79) || (iSY < 0) || (iSY > 24) || (iDY < 0) || (iDY > 24)) return; #endif if (cType == DUAL) lpExtChars = szDual; else lpExtChars = szSingle; HorizLine(iSX, iDX, iSY, lpExtChars[HORBAR], cStyle); HorizLine(iSX, iDX, iDY, lpExtChars[HORBAR], cStyle); VertLine(iSX, iSY, iDY, lpExtChars[VERBAR], cStyle); VertLine(iDX, iSY, iDY, lpExtChars[VERBAR], cStyle); PlotChar(iSX, iSY, lpExtChars[TOPLEFT], cStyle); PlotChar(iDX, iSY, lpExtChars[TOPRIGHT], cStyle); PlotChar(iDX, iDY, lpExtChars[BOTRIGHT], cStyle); PlotChar(iSX, iDY, lpExtChars[BOTLEFT], cStyle); }
void DrawHilite(HDC hdc, Rect& rect, Shader* pShader ) { int w,h,npts,xcen,ybot,ytop,ylast,i,iy; HPEN linePen = (HPEN)GetStockObject(WHITE_PEN); HPEN fgPen = CreatePen(PS_SOLID,0,GetCustSysColor(COLOR_BTNFACE)); HPEN bgPen = CreatePen(PS_SOLID,0,GetCustSysColor(COLOR_BTNSHADOW)); w = rect.w(); h = rect.h()-3; npts = (w-2)/2; xcen = rect.left+npts; ybot = rect.top+h; ytop = rect.top+2; ylast = -1; for (i=0; i<npts; i++) { float v = pShader->EvalHiliteCurve( (float)i/((float)npts*2.0f) ); if (v>2.0f) v = 2.0f; // keep iy from wrapping iy = ybot-(int)(v*((float)h-2.0f)); if (iy<ytop) iy = ytop; SelectPen(hdc, fgPen); VertLine(hdc,xcen+i,ybot,iy); VertLine(hdc,xcen-i,ybot,iy); if (iy-1>ytop) { // Fill in above curve SelectPen(hdc,bgPen); VertLine(hdc,xcen+i, ytop, iy-1); VertLine(hdc,xcen-i, ytop, iy-1); } if (ylast>=0) { SelectPen(hdc,linePen); VertLine(hdc,xcen+i-1,iy-1,ylast); VertLine(hdc,xcen-i+1,iy-1,ylast); } ylast = iy; } SelectObject( hdc, linePen ); DeleteObject(fgPen); DeleteObject(bgPen); WhiteRect3D(hdc, rect, 1); }
// iso projection of 2 orthogonal highlight curves void DrawHilite2(HDC hdc, Rect& rect, Shader* pShader, int layer ) { int w,h,npts,xcen,ybot,ytop,ylast,i,iy, off, vals[200]; float ybr, ybl; HPEN linePen = (HPEN)GetStockObject(WHITE_PEN); HPEN fgPen = CreatePen(PS_SOLID,0,GetCustSysColor(COLOR_BTNFACE)); HPEN fg2Pen = CreatePen(PS_SOLID,0,GetCustSysColor(COLOR_BTNHILIGHT)); HPEN bgPen = CreatePen(PS_SOLID,0,GetCustSysColor(COLOR_BTNSHADOW)); w = rect.w(); assert( w/2 < 200 ); // 200 vals saved for visibility h = rect.h()-3; npts = (w-2)/2; off = h / 6; float slope = float(h-off-off)/w; ybot = rect.top+h; ytop = rect.top+2; // first the X curve ybr = ybl = float(rect.top+h - 2.5* off); xcen = rect.left+npts; ylast = -1; for (i=0; i<npts; i++) { float v = pShader->EvalHiliteCurve2( (float)i/((float)npts*2.0f), 0.0f, layer ); if (v>2.0f) v = 2.0f; // keep iy from wrapping iy = (int)(v* 0.6f * ((float)h-2.0f)); int r = int( ybr + 0.5f ); if ( r > ybot ) r = ybot; int l = int( ybl + 0.5f ); if ( l > ybot ) l = ybot; int ry = r - iy; if (ry<ytop) ry = ytop; if (ry>ybot) ry = ybot; vals[i] = ry; // save for visibility int ly = l - iy; if (ly<ytop) ly = ytop; if (ly>ybot) ly = ybot; SelectPen(hdc, fgPen); VertLine(hdc,xcen+i, r, ry); // start at center & spread out on both sides VertLine(hdc,xcen-i, l, ly); SelectPen(hdc,bgPen); // Fill in below baseline VertLine(hdc,xcen+i, ybot, r+1); VertLine(hdc,xcen-i, ybot, l+1); VertLine(hdc,xcen+i, ytop, ry-1); VertLine(hdc,xcen-i, ytop, ly-1); // fill in above curve // if (ylast>=0) { // SelectPen(hdc,linePen); // VertLine(hdc, xcen+i-1, iy-1, ylast); // white dot marks curve // VertLine(hdc, xcen-i+1, iy-1, ylast); // } ylast = iy; ybr += slope; ybl += -slope; } // now do the Y curve ybr = ybl = float(rect.top+h - 2.5* off); xcen = rect.left+npts - 1; ylast = -1; for (i=0; i < npts; i++) { float v = pShader->EvalHiliteCurve2( 0.0f, (float)i/((float)npts*2.0f), layer ); if (v>2.0f) v = 2.0f; // keep iy from wrapping iy = (int)(v* 0.6f * ((float)h-2.0f)); int r = int( ybr + 0.5f ); if ( r > ybot ) r = ybot; int l = int( ybl + 0.5f ); if ( l > ybot ) l = ybot; int ry = r - iy; if (ry<ytop) ry = ytop; if (ry>ybot) ry = ybot; int ly = l - iy; if (ly<ytop) ly = ytop; if (ly>ybot) ly = ybot; SelectPen(hdc, fg2Pen); VertLine(hdc,xcen-i, l, ly); // left side always visible..in front if ( r <= vals[i] ) VertLine(hdc,xcen+i, r, ry); // start at center & spread out on both sides else if ( ry <= vals[i] ) VertLine(hdc,xcen+i, vals[i]-1, ry); // start at center & spread out on both sides // if (ylast>=0) { // SelectPen(hdc,linePen); // VertLine(hdc, xcen+i-1, iy-1, ylast); // white dot marks curve // VertLine(hdc, xcen-i+1, iy-1, ylast); // } ylast = iy; ybr += -slope; ybl += slope; } SelectObject( hdc, linePen ); DeleteObject(fgPen); DeleteObject(fg2Pen); DeleteObject(bgPen); WhiteRect3D(hdc, rect, 1); }