📄 meta.h
字号:
wmfFunctionReference* FR = (wmfFunctionReference*) API->function_reference; wmfL_Coord l_pt; wmfDrawArc_t drawarc; wmfPen* pen = 0; U16 par_U16_x; U16 par_U16_y; float scope; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 3",Record->size); } par_U16_x = ParU16 (API,Record,3); par_U16_y = ParU16 (API,Record,2); l_pt = L_Coord (API,par_U16_x,par_U16_y); drawarc.TL = wmf_D_Coord_translate (API,l_pt); par_U16_x = ParU16 (API,Record,1); par_U16_y = ParU16 (API,Record,0); l_pt = L_Coord (API,par_U16_x,par_U16_y); drawarc.BR = wmf_D_Coord_translate (API,l_pt); if (SCAN (API)) { pen = WMF_DC_PEN (P->dc); scope = (float) (MAX (WMF_PEN_WIDTH (pen),WMF_PEN_HEIGHT (pen))) / 2; D_Coord_Register (API,drawarc.TL,scope); D_Coord_Register (API,drawarc.BR,scope); return (changed); } drawarc.dc = P->dc; if (FR->draw_ellipse) FR->draw_ellipse (API,&drawarc); return (changed);}static int meta_line (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; wmfPlayer_t* P = (wmfPlayer_t*) API->player_data; wmfFunctionReference* FR = (wmfFunctionReference*) API->function_reference; wmfL_Coord l_pt; wmfDrawLine_t drawline; wmfPen* pen = 0; U16 par_U16_x; U16 par_U16_y; float scope; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 1",Record->size); } drawline.from = wmf_D_Coord_translate (API,P->current); par_U16_x = ParU16 (API,Record,1); par_U16_y = ParU16 (API,Record,0); l_pt = L_Coord (API,par_U16_x,par_U16_y); drawline.to = wmf_D_Coord_translate (API,l_pt); P->current = l_pt; if (SCAN (API)) { pen = WMF_DC_PEN (P->dc); scope = (float) (MAX (WMF_PEN_WIDTH (pen),WMF_PEN_HEIGHT (pen))) / 2; D_Coord_Register (API,drawline.from,scope); D_Coord_Register (API,drawline.to,scope); return (changed); } drawline.dc = P->dc; if (FR->draw_line) FR->draw_line (API,&drawline); return (changed);}static int meta_lines (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; wmfPlayer_t* P = (wmfPlayer_t*) API->player_data; wmfFunctionReference* FR = (wmfFunctionReference*) API->function_reference; wmfL_Coord l_pt; wmfD_Coord d_pt; wmfPolyLine_t polyline; wmfPen* pen = 0; U16 par_U16_x; U16 par_U16_y; U16 i; unsigned long index; float scope; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 0",Record->size); } polyline.count = ParU16 (API,Record,0); if (SCAN (API) && DIAG (API)) { fprintf (stderr,",%lu",(unsigned long) (2 * polyline.count)); } if (SCAN (API)) { pen = WMF_DC_PEN (P->dc); scope = (float) (MAX (WMF_PEN_WIDTH (pen),WMF_PEN_HEIGHT (pen))) / 2; index = 1; for (i = 0; i < polyline.count; i++) { par_U16_x = ParU16 (API,Record,index); index++; par_U16_y = ParU16 (API,Record,index); index++; l_pt = L_Coord (API,par_U16_x,par_U16_y); d_pt = wmf_D_Coord_translate (API,l_pt); D_Coord_Register (API,d_pt,scope); } return (changed); } polyline.pt = (wmfD_Coord*) wmf_malloc (API,polyline.count * sizeof (wmfD_Coord)); if (ERR (API)) { WMF_DEBUG (API,"bailing..."); return (changed); } index = 1; for (i = 0; i < polyline.count; i++) { par_U16_x = ParU16 (API,Record,index); index++; par_U16_y = ParU16 (API,Record,index); index++; l_pt = L_Coord (API,par_U16_x,par_U16_y); polyline.pt[i] = wmf_D_Coord_translate (API,l_pt); } polyline.dc = P->dc; if (FR->poly_line) FR->poly_line (API,&polyline); wmf_free (API,polyline.pt); return (changed);}static int meta_polygon (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; wmfPlayer_t* P = (wmfPlayer_t*) API->player_data; wmfFunctionReference* FR = (wmfFunctionReference*) API->function_reference; wmfL_Coord l_pt; wmfD_Coord d_pt; wmfPolyLine_t polyline; wmfPen* pen = 0; U16 par_U16_x; U16 par_U16_y; U16 i; unsigned long index; float scope; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 0",Record->size); } polyline.count = ParU16 (API,Record,0); if (SCAN (API) && DIAG (API)) { fprintf (stderr,",%lu",(unsigned long) (2 * polyline.count)); } if (SCAN (API)) { pen = WMF_DC_PEN (P->dc); scope = (float) (MAX (WMF_PEN_WIDTH (pen),WMF_PEN_HEIGHT (pen))) / 2; index = 1; for (i = 0; i < polyline.count; i++) { par_U16_x = ParU16 (API,Record,index); index++; par_U16_y = ParU16 (API,Record,index); index++; l_pt = L_Coord (API,par_U16_x,par_U16_y); d_pt = wmf_D_Coord_translate (API,l_pt); D_Coord_Register (API,d_pt,scope); } return (changed); } polyline.pt = (wmfD_Coord*) wmf_malloc (API,polyline.count * sizeof (wmfD_Coord)); if (ERR (API)) { WMF_DEBUG (API,"bailing..."); return (changed); } index = 1; for (i = 0; i < polyline.count; i++) { par_U16_x = ParU16 (API,Record,index); index++; par_U16_y = ParU16 (API,Record,index); index++; l_pt = L_Coord (API,par_U16_x,par_U16_y); polyline.pt[i] = wmf_D_Coord_translate (API,l_pt); } polyline.dc = P->dc; if (FR->draw_polygon) FR->draw_polygon (API,&polyline); wmf_free (API,polyline.pt); return (changed);}static int meta_polygons (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; wmfPlayer_t* P = (wmfPlayer_t*) API->player_data; wmfFunctionReference* FR = (wmfFunctionReference*) API->function_reference; wmfL_Coord l_pt; wmfD_Coord d_pt; wmfPolyLine_t polyline; wmfPolyPoly_t polypoly; wmfRecord Polygon; wmfPen* pen = 0; U16 par_U16_x; U16 par_U16_y; U16 num_pars; U16 count; U16 style; U16 i; U16 j; unsigned long index; float scope; int skip_record; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 0",Record->size); } polypoly.npoly = ParU16 (API,Record,0); if (polypoly.npoly == 0) return (changed); if (SCAN (API) && DIAG (API)) { fprintf (stderr,",%lu",(unsigned long) polypoly.npoly); } polypoly.pt = (wmfD_Coord**) wmf_malloc (API, polypoly.npoly * sizeof (wmfD_Coord*)); if (ERR (API)) { WMF_DEBUG (API,"bailing..."); return (changed); } polypoly.count = (U16*) wmf_malloc (API, polypoly.npoly * sizeof (U16)); if (ERR (API)) { WMF_DEBUG (API,"bailing..."); return (changed); } count = 0; num_pars = 0; skip_record = 0; for (i = 0; i < polypoly.npoly; i++) { polypoly.count[i] = ParU16 (API,Record,(unsigned long) (1 + i)); count += polypoly.count[i] + 2; /* for polypoly->polyline fill constructor */ num_pars += polypoly.count[i]; if ((polypoly.count[i] < 3) && (skip_record == 0)) { WMF_DEBUG (API,"strange polygon in polypolygon list; skipping record..."); skip_record = 1; } if (skip_record) { polypoly.pt[i] = 0; } else { polypoly.pt[i] = (wmfD_Coord*) wmf_malloc (API, polypoly.count[i] * sizeof (wmfD_Coord)); if (ERR (API)) break; } } if (skip_record) { for (i = 0; i < polypoly.npoly; i++) { if (polypoly.pt[i]) wmf_free (API, polypoly.pt[i]); } wmf_free (API, polypoly.pt); wmf_free (API, polypoly.count); return (changed); } if (ERR (API)) { WMF_DEBUG (API,"bailing..."); return (changed); } if (SCAN (API) && DIAG (API)) { fprintf (stderr,",%lu",(unsigned long) (polypoly.npoly + 2 * num_pars)); } if (SCAN (API)) { pen = WMF_DC_PEN (P->dc); scope = (float) (MAX (WMF_PEN_WIDTH (pen),WMF_PEN_HEIGHT (pen))) / 2; index = 1 + polypoly.npoly; for (i = 0; i < num_pars; i++) { par_U16_x = ParU16 (API,Record,index); index++; par_U16_y = ParU16 (API,Record,index); index++; l_pt = L_Coord (API,par_U16_x,par_U16_y); d_pt = wmf_D_Coord_translate (API,l_pt); D_Coord_Register (API,d_pt,scope); } return (changed); } polypoly.dc = P->dc; Polygon = OffsetRecord (API,Record,(unsigned long) (1 + polypoly.npoly)); for (i = 0; i < polypoly.npoly; i++) { polyline.count = polypoly.count[i]; index = 0; for (j = 0; j < polyline.count; j++) { par_U16_x = ParU16 (API,&Polygon,index); index++; par_U16_y = ParU16 (API,&Polygon,index); index++; l_pt = L_Coord (API,par_U16_x,par_U16_y); polypoly.pt[i][j] = wmf_D_Coord_translate (API,l_pt); } Polygon = OffsetRecord (API,&Polygon,index); } if (FR->draw_polypolygon) { FR->draw_polypolygon (API,&polypoly); } else if (FR->draw_polygon) { if (TO_FILL (&polypoly)) { style = polypoly.dc->pen->lopnStyle; /* [TODO: use macros ??] */ polypoly.dc->pen->lopnStyle = PS_NULL; polyline.dc = polypoly.dc; polyline.pt = (wmfD_Coord*) wmf_malloc (API, count * sizeof (wmfD_Coord)); polyline.count = 0; if (ERR (API)) { WMF_DEBUG (API,"bailing..."); return (changed); } polypoly_construct (API, &polypoly, &polyline, 0); if (polyline.count > 2) FR->draw_polygon (API,&polyline); wmf_free (API, polyline.pt); polypoly.dc->pen->lopnStyle = style; } if (TO_DRAW (&polypoly)) { style = polypoly.dc->brush->lbStyle; /* [TODO: use macros ??] */ polypoly.dc->brush->lbStyle = BS_NULL; for (i = 0; i < polypoly.npoly; i++) { polyline.dc = polypoly.dc; polyline.pt = polypoly.pt[i]; polyline.count = polypoly.count[i]; if ((polyline.count > 2) && polyline.pt) { FR->draw_polygon (API,&polyline); } } polypoly.dc->brush->lbStyle = style; } } for (i = 0; i < polypoly.npoly; i++) { if (polypoly.pt[i]) wmf_free (API, polypoly.pt[i]); } wmf_free (API, polypoly.pt); wmf_free (API, polypoly.count); return (changed);}static void polypoly_construct (wmfAPI* API,wmfPolyPoly_t* polypoly,wmfPolyLine_t* polyline,U16 ipoly){ U16 count = polypoly->count[ipoly]; U16 i; U16 imin; U16 last; double x2; double y2; double r2; double r2_min; if ((polyline->pt == 0) || (polypoly->pt == 0)) return; /* erk!! */ if ((polypoly->pt[ipoly] == 0) || (polypoly->count[ipoly] < 3)) return; while ((polypoly->pt[ipoly][0].x == polypoly->pt[ipoly][count-1].x) && (polypoly->pt[ipoly][0].y == polypoly->pt[ipoly][count-1].y)) { count--; if (count < 3) break; } if (count < 3) return; last = 0; if (ipoly < (polypoly->npoly - 1)) { if ((polypoly->pt[ipoly+1] == 0) || (polypoly->count[ipoly+1] < 3)) { last = 1; /* erk!! */ } } else { last = 1; /* last poly, yay! */ } if (last) { for (i = 0; i < count; i++) { polyline->pt[polyline->count].x = polypoly->pt[ipoly][i].x; polyline->pt[polyline->count].y = polypoly->pt[ipoly][i].y; polyline->count++; } polyline->pt[polyline->count].x = polypoly->pt[ipoly][0].x; polyline->pt[polyline->count].y = polypoly->pt[ipoly][0].y; polyline->count++; return; } /* find polygon point closest to point 0 in next polygon [TODO: improve this??] */ imin = 0; for (i = 0; i < count; i++) { x2 = (double) polypoly->pt[ipoly][i].x - (double) polypoly->pt[ipoly+1][0].x; x2 *= x2; y2 = (double) polypoly->pt[ipoly][i].y - (double) polypoly->pt[ipoly+1][0].y; y2 *= y2; r2 = x2 + y2; if (i == 0) { r2_min = r2; } else if (r2 < r2_min) { r2_min = r2; imin = i; } } for (i = 0; i <= imin; i++) { polyline->pt[polyline->count].x = polypoly->pt[ipoly][i].x; polyline->pt[polyline->count].y = polypoly->pt[ipoly][i].y; polyline->count++; } polypoly_construct (API, polypoly, polyline, (U16)(ipoly + 1)); for (i = imin; i < count; i++) { polyline->pt[polyline->count].x = polypoly->pt[ipoly][i].x; polyline->pt[polyline->count].y = polypoly->pt[ipoly][i].y; polyline->count++; } polyline->pt[polyline->count].x = polypoly->pt[ipoly][0].x; polyline->pt[polyline->count].y = polypoly->pt[ipoly][0].y; polyline->count++;}static int meta_round (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; wmfPlayer_t* P = (wmfPlayer_t*) API->player_data; wmfFunctionReference* FR = (wmfFunctionReference*) API->function_reference; wmfL_Coord l_pt; wmfDrawRectangle_t drawrect; wmfPen* pen = 0; U16 par_U16_x; U16 par_U16_y; float scope; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 5",Record->size); } par_U16_x = ParU16 (API,Record,5); par_U16_y = ParU16 (API,Record,4); l_pt = L_Coord (API,par_U16_x,par_U16_y); drawrect.TL = wmf_D_Coord_translate (API,l_pt); par_U16_x = ParU16 (API,Record,3); par_U16_y = ParU16 (API,Record,2); l_pt = L_Coord (API,par_U16_x,par_U16_y); drawrect.BR = wmf_D_Coord_translate (API,l_pt); if (SCAN (API)) { pen = WMF_DC_PEN (P->dc); scope = (float) (MAX (WMF_PEN_WIDTH (pen),WMF_PEN_HEIGHT (pen))) / 2; D_Coord_Register (API,drawrect.TL,scope); D_Coord_Register (API,drawrect.BR,scope); return (changed); } par_U16_x = ParU16 (API,Record,1); par_U16_y = ParU16 (API,Record,0); drawrect.width = (float) ((double) par_U16_x * ABS (P->dc->pixel_width )); drawrect.height = (float) ((double) par_U16_y * ABS (P->dc->pixel_height)); drawrect.dc = P->dc; if (FR->draw_rectangle) FR->draw_rectangle (API,&drawrect);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -