graphic.c
来自「好记星的控件,包括button,list,对文件操作」· C语言 代码 · 共 1,483 行 · 第 1/5 页
C
1,483 行
__GraphMappingVideoBuffer();
}
/****************************************************************************/
/* FUNCTION: _GraphDrawNosolidLine */
/* DESCRIPTION:Draw a vertical line or horizontal Line,jumping. */
/* INPUTS: ,Device to fill. */
/* point,a array of 5 items(x0,y0,x1,y1,jump distance) */
/* verline,BOOL flag of vertical line. */
/* uDotSize,decide the line width. */
/* drawDot,solid line length. */
/* OUTPUTS: NONE. */
/* RETURN: NONE. */
/****************************************************************************/
/* NAME DATE REMARKS */
/* ========== ============ ==============================================*/
/* Qorse 2002-08-11 build */
/****************************************************************************/
VOID _GraphDrawNosolidLine(INT *point,BOOL verline,UINT uDotSize,UINT drawDot)
{
INT start0,start1; /*用前景色跳跃画线段*/
start0 = point[verline];
while(start0<= point[verline+2])
{
start1 = start0+drawDot*uDotSize-1; /*----- ----- -----*/
if (start1>point[verline+2])
{
start1 = point[verline+2]; /*出界*/
}
if (verline)
{
_GraphDrawBlock(point[0],start0,(UINT)(point[2]-point[0]+1),(UINT)(start1-start0+1));
}
else
{
_GraphDrawBlock(start0,point[1],(UINT)(start1-start0+1),(UINT)(point[3]-point[1]+1));
}
start0 += point[4]*uDotSize; /*单位线段长度,默认为8*/
}
// point[verline] += drawDot*uDotSize; /*变更起始坐标准备下一次使用该函数*/
}
/****************************************************************************/
/* FUNCTION: _GraphPlotSkewLine */
/* DESCRIPTION:Draw a Skew line. */
/* INPUTS: ,Device to fill. */
/* x1,x-coordinate of start point. */
/* y1,y-coordinate of start point. */
/* x2,x-coordinate of end point. */
/* y2,y-coordinate of end point. */
/* OUTPUTS: NONE. */
/* RETURN: NONE. */
/****************************************************************************/
/* NAME DATE REMARKS */
/* ========== ============ ==============================================*/
/* Qorse 2002-08-11 build */
/****************************************************************************/
VOID _GraphPlotSkewLine(INT x1,INT y1,INT x2,INT y2) /*画斜线*/
{
UINT uLineStyle; //Line style
INT x, y, e; //record the point to plot point
INT xsign, ysign; //record the direction of line
INT delta_x, delta_y;
INT i, change, dotSize;
UINT32 dwBsColor;
dwBsColor = g_dcSystemDC.dcBrush.bsColor;
g_dcSystemDC.dcBrush.bsColor = g_dcSystemDC.dcPen.pnColor;
uLineStyle = g_dcSystemDC.dcPen.pnStyle;
x = x1;
y = y1;
delta_x = x2 - x1;
delta_y = y2 - y1;
if (delta_x < 0)
{
xsign = -1;
delta_x = -delta_x;
}
else
{
xsign = 1;
}
if (delta_y < 0)
{
ysign = -1;
delta_y = -delta_y;
}
else
{
ysign = 1;
}
if (delta_x < delta_y)
{
swap(&delta_x, &delta_y);
change = 1;
}
else
{
change = 0;
}
e = 2 * delta_y - delta_x;
dotSize = g_dcSystemDC.dcPen.pnWidth.x - 1;
for (i = 0; i <= delta_x; i++)
{
switch (uLineStyle)
{
case PS_SOLID:
GraphFillRect(x, y, x + dotSize, y + dotSize);
break;
case PS_DOT:
if (i % 2 == 0)
{
GraphFillRect(x, y, x + dotSize, y + dotSize);
}
break;
case PS_DASH:
if ((i + 1) % 4 != 0)
{
GraphFillRect(x, y, x + dotSize, y + dotSize);
}
break;
case PS_DASHDOT:
if ((i & 0x07) <= 2 || (i & 0x07) == 5)
{
GraphFillRect(x, y, x + dotSize, y + dotSize);
}
break;
default:
break;
}
while (e >= 0)
{
if (change == 1)
{
x = x + xsign;
}
else
{
y = y + ysign;
}
e = e - (delta_x << 1);
}
if (change == 1)
{
y = y + ysign;
}
else
{
x = x + xsign;
}
e = e + (delta_y << 1);
}
g_dcSystemDC.dcBrush.bsColor = dwBsColor;
}
/****************************************************************************/
/* FUNCTION: GraphDrawLine */
/* DESCRIPTION:Draw a Skew line. */
/* INPUTS: ,Device to fill. */
/* x1,x-coordinate of start point. */
/* y1,y-coordinate of start point. */
/* x2,x-coordinate of end point. */
/* y2,y-coordinate of end point. */
/* OUTPUTS: NONE. */
/* RETURN: NONE. */
/****************************************************************************/
/* NAME DATE REMARKS */
/* ========== ============ ==============================================*/
/* Qorse 2002-08-11 build */
/****************************************************************************/
VOID GraphDrawLine(INT x1,INT y1,INT x2,INT y2)
{
INT uDotSize;
INT point[5];
uDotSize = (INT)g_dcSystemDC.dcPen.pnWidth.x;
if (uDotSize == 0)
{
return;
}
if (y1 == y2 || x1 == x2)
{
if (x1 > x2) {
swap(&x1, &x2);
}
if (y1 > y2) {
swap(&y1, &y2);
}
x1 -= uDotSize >> 1;
y1 -= uDotSize >> 1;
x2 += (uDotSize - 1) >> 1;
y2 += (uDotSize - 1) >> 1;
if (__gMdfyRectPara( &g_dcSystemDC,&x1, &y1, &x2, &y2))
{
UINT32 bakBrushColor;
BOOL verline;
UINT lineStyle;
lineStyle = g_dcSystemDC.dcPen.pnStyle;
bakBrushColor = g_dcSystemDC.dcBrush.bsColor;
g_dcSystemDC.dcBrush.bsColor = g_dcSystemDC.dcPen.pnColor;
if (lineStyle == PS_SOLID || (x2 - x1 + 1) <= uDotSize * 5
&& (y2 - y1 + 1) <= uDotSize * 5) //实线或者比较短的线
{
_GraphDrawBlock(x1, y1,
(UINT)(x2 - x1 + 1), (UINT)(y2 - y1 + 1));
}
else
{
point[0] = x1;
point[1] = y1;
point[2] = x2;
point[3] = y2;
point[4] = 8; //单位线段长度为8个dot
if (x2 - x1 + 1 > uDotSize * 5) //横线
{
verline = FALSE;
}
else {
verline = TRUE;
}
switch (lineStyle) {
case PS_DASH: //虚线---
_GraphDrawNosolidLine(point, verline, uDotSize,5);
break;
case PS_DOT: //点线...
point[4] = 2;
_GraphDrawNosolidLine(point, verline, uDotSize,1);
break;
case PS_DOT_SPACE: //稀点线. . .
point[4] = 3;
_GraphDrawNosolidLine(point, verline, uDotSize,1);
break;
case PS_DASHDOTDOT: //双点划线..-..-
point[4] = 10;
_GraphDrawNosolidLine(point, verline, uDotSize,1);
point[verline] += uDotSize * 2; // no break
case PS_DASHDOT: //点划线.-.-
_GraphDrawNosolidLine(point, verline, uDotSize,5);
point[verline] += uDotSize * 6;
_GraphDrawNosolidLine(point,verline,uDotSize,1);
break;
default:
break;
}
}
g_dcSystemDC.dcBrush.bsColor = bakBrushColor;
}
}
else
{
_GraphPlotSkewLine(x1, y1, x2, y2);
}
__GraphMappingVideoBuffer();
}
/****************************************************************************/
/* FUNCTION: GraphDrawRect */
/* DESCRIPTION:Draw a Rect. */
/* INPUTS: ,Device to fill. */
/* x1,x-coordinate of start point. */
/* y1,y-coordinate of start point. */
/* x2,x-coordinate of end point. */
/* y2,y-coordinate of end point. */
/* OUTPUTS: NONE. */
/* RETURN: NONE. */
/****************************************************************************/
/* NAME DATE REMARKS */
/* ========== ============ ==============================================*/
/* Qorse 2002-08-11 build */
/****************************************************************************/
VOID GraphDrawRect(INT x1,INT y1,INT x2,INT y2)
{
UINT uDotSize, delta;
UI
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?