void CRoundRect::DrawRoundRect(CDC *pDC,REAL left,REAL top,REAL right,REAL bottom,REAL fWidth,REAL fHeight) { REAL w = right - left; REAL h = bottom - top; if ((fWidth<0 && w>0) ||(fWidth>0 && w<0)) fWidth = 0; else if (abs(fWidth) > abs(w)) fWidth = w; if ((fHeight<0 && h>0) ||(fHeight>0 && h<0)) fHeight = 0; else if (abs(fHeight) > abs(h)) fHeight = h; REAL cx = fWidth/2; REAL cy = fHeight/2; if (fWidth==0.0 || fHeight==0.0) { DrawRect(pDC,left,top,right,bottom); } else { exchange_if_less(REAL,right,left); exchange_if_less(REAL,bottom,top); absx(cx);absx(cy); absx(fWidth);absx(fHeight); pDC->RoundRect((int)left,(int)top,(int)right,(int)bottom,(int)fWidth,(int)fHeight); } }
void CRoundRect::DrawRoundRectXY(CDC *pDC,REAL left,REAL top,REAL right,REAL bottom,REAL fXEllipse,REAL fYEllipse) { if (CRectF(left,top,right,bottom).IsRectEmpty()) return; REAL w = right - left; REAL h = bottom - top; REAL fWidth = (REAL)(fXEllipse*w); REAL fHeight = (REAL)(fYEllipse*h); if ((fWidth<0 && w>0) ||(fWidth>0 && w<0)) fWidth = 0; else if (abs(fWidth) > abs(w)) fWidth = w; if ((fHeight<0 && h>0) ||(fHeight>0 && h<0)) fHeight = 0; else if (abs(fHeight) > abs(h)) fHeight = h; if (fWidth==0.0 || fHeight==0.0) { DrawRect(pDC,left,top,right,bottom); } else { exchange_if_less(REAL,right,left); exchange_if_less(REAL,bottom,top); absx(fWidth);absx(fHeight); pDC->RoundRect((int)left,(int)top,(int)right,(int)bottom,(int)fWidth,(int)fHeight); } }
static fixed iLog2( fixed p_Base ) { fixed w = 0; fixed y = 0; fixed z = 0; int num = 1; int dec = 0; if( p_Base == 1 ) return 0; for( dec=0 ; absx( p_Base ) >= 2 ; ++dec ) p_Base /= XLN_E; p_Base -= 1; z = p_Base; y = p_Base; w = 1; while( y != y + w ) y += ( w = ( z = 0 - ( z * p_Base ) ) / ( num += 1 ) ); return y + dec; }
static fixed ipow( fixed p_Base, fixed p_Power ) { if( p_Base < 0 && p_Power%2 != 0 ) return - iExp2( (p_Power * iLog2( -p_Base )) ); else return iExp2( (p_Power * iLog2(absx( p_Base ))) ); }
int gAction::xToFrame_b() { return (absx() + w()) * parent->zoom; }