46 RECT
MkRect( LONG L, LONG T, LONG R, LONG B ) {
52 RECTS r = { L,T,R,B };
61 POINT pt = { p.x, p.y };
65 POINTS pt = { (short)p.x, (
short)p.y };
99 OffsetRect( R, -(R->left), -(R->top) );
106 R->bottom = -R->bottom;
108 R->right = -R->right;
114 void FitRect( PRECT pRc, PRECT pBounds, OUT PRECT pOut )
116 SIZE ext, bounds, fit;
122 if ((ext.cx != bounds.cx) || (ext.cy != bounds.cy))
125 float scalex = float(bounds.cx) / ext.cx;
126 float scaley = float(bounds.cy) / ext.cy;
128 float scale = min_<float>( scalex, scaley );
129 fit.cx = long( scale * ext.cx );
130 fit.cy = long( scale * ext.cy );
134 long x = pBounds->left + ((bounds.cx - fit.cx) / 2);
135 long y = pBounds->top + ((bounds.cy - fit.cy) / 2);
136 SetRect( pOut, x, y, x + fit.cx, y + fit.cy );
141 void DiffRect( PRECT Borders, LPCRECT Outer, LPCRECT Inner )
143 Borders->top = Inner->top - Outer->top;
144 Borders->bottom = Inner->bottom - Outer->bottom;
145 Borders->left = Inner->left - Outer->left;
146 Borders->right = Inner->right - Outer->right;
152 Borders->top = abs( Inner->top - Outer->top );
153 Borders->bottom = abs( Inner->bottom - Outer->bottom );
154 Borders->left = abs( Inner->left - Outer->left );
155 Borders->right = abs( Inner->right - Outer->right );
161 Target->top -= Borders->top;
162 Target->bottom -= Borders->bottom;
163 Target->left -= Borders->left;
164 Target->right -= Borders->right;
169 Target->top -= Borders->top;
170 Target->bottom += Borders->bottom;
171 Target->left -= Borders->left;
172 Target->right += Borders->right;
180 long double EngUnits(
long double Value,
int* pExpo )
184 long double val = Value;
186 bool neg = (val < 0);
191 while( val > 1000.0 ) {
205 if (pExpo) *pExpo = expo;
RECT MkRect(LONG L, LONG T, LONG R, LONG B)
void InflateBorders(PRECT Target, LPCRECT Borders)
long double EngUnits(long double Value, int *pExpo)
LPRECT DimToAbsRect(LPRECT r)
LPRECT AbsToRelRect(LPRECT R)
void DiffRect(PRECT Borders, LPCRECT Outer, LPCRECT Inner)
bool operator !=(POINT P1, POINT P2)
SIZES MkSizeS(SHORT cx, SHORT cy)
void AbsDiffRect(PRECT Borders, LPCRECT Outer, LPCRECT Inner)
POINTS MkPointS(SHORT x, SHORT y)
LPRECT NegateRect(LPRECT R)
SIZE MkSize(LONG cx, LONG cy)
Debug and error handling support.
Common include; Added types, small "ubiquitous" utilities, et c.
bool operator==(POINT P1, POINT P2)
POINT MkPoint(LONG x, LONG y)
LPRECT AbsToDimRect(LPRECT r)
void AbsInflateBorders(PRECT Target, LPCRECT Borders)
RECTS MkRectS(SHORT L, SHORT T, SHORT R, SHORT B)
void FitRect(PRECT pRc, PRECT pBounds, OUT PRECT pOut)