From 7b52cc13af4e85f1ca2deb6b6c77de9c95ea0dcf Mon Sep 17 00:00:00 2001 From: scuri Date: Fri, 17 Oct 2008 06:10:33 +0000 Subject: First commit - moving from LuaForge to SourceForge --- test/cdtest/cdtest.c | 2662 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2662 insertions(+) create mode 100644 test/cdtest/cdtest.c (limited to 'test/cdtest/cdtest.c') diff --git a/test/cdtest/cdtest.c b/test/cdtest/cdtest.c new file mode 100644 index 0000000..bf701b9 --- /dev/null +++ b/test/cdtest/cdtest.c @@ -0,0 +1,2662 @@ +/*=========================================================================*/ +/* CDTEST.C - 09/12/95 */ +/* Canvas Draw Test. */ +/*=========================================================================*/ + +/*- Convenccoes Usadas: ---------------------------------------------------*/ +/* - Identificadores de funccoes associadas a um callback comeccam por f. */ +/* Ex: fResize, fRepaint. */ +/* - Identificadores de constantes sao escritos em maiusculas. */ +/* Ex: LINE, ARC, NEWPOINT. */ +/* - Identificadores de funcoes internas do programa sao escritas em */ +/* minusculas. */ +/* Ex: newpolypoint, dellist. */ +/*-------------------------------------------------------------------------*/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cdtest.h" + +/*- Contexto do CD Test: --------------------------------------------------*/ +tCTC ctgc; + +/*- Parametros geometricos da primitiva sendo desenhada: ------------------*/ +tLinePos line_pos; +tBoxPos box_pos; +tPixelPos pixel_pos; +tMarkPos mark_pos; +tArcPos arc_pos; + +//#define USE_GDIPLUS + +#ifdef USE_GDIPLUS +static const int use_gdiplus = 1; +#else +static const int use_gdiplus = 0; +#endif + +static const int antialias = 1; + + +/*-------------------------------------------------------------------------*/ +/* Associa os call-backs do IUP. */ +/*-------------------------------------------------------------------------*/ +void setcallbacks(void) +{ + IupSetFunction("cmdFileExit", (Icallback) fFileExit); + + IupSetFunction("cmdEditClear", (Icallback) fEditClear); + IupSetFunction("cmdEditUndo", (Icallback) fEditUndo); + + IupSetFunction("cmdHelpAbout", (Icallback) fHelpAbout); + IupSetFunction("cmdCloseAbout", (Icallback) fCloseAbout); + + IupSetFunction("cmdWDCanvas", (Icallback) fWDCanvas); + IupSetFunction("cmdCloseWD", (Icallback) fCloseWD); + IupSetFunction("cmdPICCanvas", (Icallback) fPICCanvas); + IupSetFunction("cmdClosePIC", (Icallback) fClosePIC); + + IupSetFunction("cmdShowDialog", (Icallback) fShowDialog); + IupSetFunction("cmdLine", (Icallback) fLine); + IupSetFunction("cmdRect", (Icallback) fRect); + IupSetFunction("cmdBox", (Icallback) fBox); + IupSetFunction("cmdArc", (Icallback) fArc); + IupSetFunction("cmdSector", (Icallback) fSector); + IupSetFunction("cmdChord", (Icallback) fChord); + IupSetFunction("cmdPixel", (Icallback) fPixel); + IupSetFunction("cmdMark", (Icallback) fMark); + IupSetFunction("cmdText", (Icallback) fText); + IupSetFunction("cmdPoly", (Icallback) fPoly); + + IupSetFunction("cmdOptions", (Icallback) fOptions); + IupSetFunction("cmdOptionsHide", (Icallback) fOptionsHide); + IupSetFunction("cmdAttributes", (Icallback) fAttributes); + IupSetFunction("cmdAttributesHide", (Icallback) fAttributesHide); + IupSetFunction("cmdMsgHide", (Icallback) fMsgHide); + IupSetFunction("cmdSimulate", (Icallback) fSimulate); + IupSetFunction("cmdStretchPlay", (Icallback) fStretchPlay); + + IupSetFunction("cmdWriteMode", (Icallback) fWriteMode); + IupSetFunction("cmdLineStyle", (Icallback) fLineStyle); + IupSetFunction("cmdLineCap", (Icallback) fLineCap); + IupSetFunction("cmdLineJoin", (Icallback) fLineJoin); + IupSetFunction("cmdFillMode", (Icallback) fFillMode); + IupSetFunction("cmdFontStyle", (Icallback) fFontStyle); + IupSetFunction("cmdFontTypeFace", (Icallback) fFontTypeFace); + IupSetFunction("cmdMarkType", (Icallback) fMarkType); + IupSetFunction("cmdTextAlignment", (Icallback) fTextAlignment); + IupSetFunction("cmdHatchStyle", (Icallback) fHatchStyle); + IupSetFunction("cmdOpacity", (Icallback) fOpacity); + + IupSetFunction("cmdNoBuffering", (Icallback) fNoBuffering); + IupSetFunction("cmdImageBuffer", (Icallback) fImageBuffer); + IupSetFunction("cmdRGBBuffer", (Icallback) fRGBBuffer); + + IupSetFunction("cmdInteger", (Icallback) fInteger); + IupSetFunction("cmdReal", (Icallback) fReal); + IupSetFunction("cmdDraw", (Icallback) fDraw); + + IupSetFunction("cmdSolid", (Icallback) fSolid); + IupSetFunction("cmdHatch", (Icallback) fHatch); + IupSetFunction("cmdStipple", (Icallback) fStipple); + IupSetFunction("cmdPattern", (Icallback) fPattern); + + IupSetFunction("cmdOpenLines", (Icallback) fOpenLines); + IupSetFunction("cmdClosedLines", (Icallback) fClosedLines); + IupSetFunction("cmdFill", (Icallback) fFill); + IupSetFunction("cmdPolyClip", (Icallback) fPolyClip); + IupSetFunction("cmdPolyBezier", (Icallback) fPolyBezier); + + IupSetFunction("cmdClip", (Icallback) fClip); + IupSetFunction("cmdClipArea", (Icallback) fClipArea); + IupSetFunction("cmdClipOff", (Icallback) fClipOff); + IupSetFunction("cmdClipPoly", (Icallback) fClipPoly); + + IupSetFunction("cmdImage", (Icallback) fImage); + IupSetFunction("cmdImagePut", (Icallback) fImagePut); + IupSetFunction("cmdImageGet", (Icallback) fImageGet); + + IupSetFunction("cmdImageRGB", (Icallback) fImageRGB); + IupSetFunction("cmdImageRGBPut", (Icallback) fImageRGBPut); + IupSetFunction("cmdImageRGBGet", (Icallback) fImageRGBGet); +} + +/*-------------------------------------------------------------------------*/ +/* Inicializa o stipple e o pattern exemplo. */ +/*-------------------------------------------------------------------------*/ +void initsamples(void) +{ + int i; + + /* zera os vetores */ + for (i=0; i<100; i++) { + ctgc.stipple[i] = 0; + ctgc.pattern[i] = 0xffffffl; + } + + /* especificaccao do stipple */ + ctgc.stipple[11] = 1; /*------------*/ + ctgc.stipple[21] = 1; /* 0123456789*/ + ctgc.stipple[31] = 1; /* */ + ctgc.stipple[41] = 1; /*9 0000000000*/ + ctgc.stipple[51] = 1; /*8 0000111110*/ + /*7 0001000110*/ + ctgc.stipple[12] = 1; /*6 0010001010*/ + ctgc.stipple[52] = 1; /*5 0111110010*/ + ctgc.stipple[62] = 1; /*4 0100010010*/ + /*3 0100010100*/ + ctgc.stipple[13] = 1; /*2 0100011000*/ + ctgc.stipple[53] = 1; /*1 0111110000*/ + ctgc.stipple[73] = 1; /*0 0000000000*/ + /*------------*/ + ctgc.stipple[14] = 1; + ctgc.stipple[54] = 1; + ctgc.stipple[84] = 1; + + ctgc.stipple[15] = 1; ctgc.stipple[26] = 1; + ctgc.stipple[25] = 1; ctgc.stipple[66] = 1; + ctgc.stipple[35] = 1; ctgc.stipple[86] = 1; + ctgc.stipple[45] = 1; + ctgc.stipple[55] = 1; ctgc.stipple[48] = 1; + ctgc.stipple[85] = 1; ctgc.stipple[58] = 1; + ctgc.stipple[68] = 1; + ctgc.stipple[37] = 1; ctgc.stipple[78] = 1; + ctgc.stipple[77] = 1; ctgc.stipple[88] = 1; + ctgc.stipple[87] = 1; + + + /* especificaccao do stipple */ + ctgc.pattern[11] = CD_RED; /*------------*/ + ctgc.pattern[21] = CD_RED; /* 0123456789*/ + ctgc.pattern[31] = CD_RED; /* */ + ctgc.pattern[41] = CD_RED; /*9 WWWWWWWWWW*/ + ctgc.pattern[51] = CD_RED; /*8 WWWWGGGGGW*/ + ctgc.pattern[12] = CD_RED; /*7 WWWGGGGGBW*/ + ctgc.pattern[22] = CD_RED; /*6 WWGGGGGBBW*/ + ctgc.pattern[32] = CD_RED; /*5 WrrrrrBBBW*/ + ctgc.pattern[42] = CD_RED; /*4 WrrrrrBBBW*/ + ctgc.pattern[52] = CD_RED; /*3 WrrrrrBBWW*/ + ctgc.pattern[13] = CD_RED; /*2 WrrrrrBWWW*/ + ctgc.pattern[23] = CD_RED; /*1 WrrrrrWWWW*/ + ctgc.pattern[33] = CD_RED; /*0 WWWWWWWWWW*/ + ctgc.pattern[43] = CD_RED; /*------------*/ + ctgc.pattern[53] = CD_RED; + ctgc.pattern[14] = CD_RED; ctgc.pattern[15] = CD_RED; + ctgc.pattern[24] = CD_RED; ctgc.pattern[25] = CD_RED; + ctgc.pattern[34] = CD_RED; ctgc.pattern[35] = CD_RED; + ctgc.pattern[44] = CD_RED; ctgc.pattern[45] = CD_RED; + ctgc.pattern[54] = CD_RED; ctgc.pattern[55] = CD_RED; + + ctgc.pattern[26] = CD_BLUE; ctgc.pattern[37] = CD_BLUE; + ctgc.pattern[36] = CD_BLUE; ctgc.pattern[47] = CD_BLUE; + ctgc.pattern[46] = CD_BLUE; ctgc.pattern[57] = CD_BLUE; + ctgc.pattern[56] = CD_BLUE; ctgc.pattern[67] = CD_BLUE; + + ctgc.pattern[48] = CD_BLUE; ctgc.pattern[62] = CD_GREEN; + ctgc.pattern[58] = CD_BLUE; ctgc.pattern[63] = CD_GREEN; + ctgc.pattern[68] = CD_BLUE; ctgc.pattern[64] = CD_GREEN; + ctgc.pattern[78] = CD_BLUE; ctgc.pattern[65] = CD_GREEN; + ctgc.pattern[66] = CD_GREEN; + + ctgc.pattern[73] = CD_GREEN; ctgc.pattern[84] = CD_GREEN; + ctgc.pattern[74] = CD_GREEN; ctgc.pattern[85] = CD_GREEN; + ctgc.pattern[75] = CD_GREEN; ctgc.pattern[86] = CD_GREEN; + ctgc.pattern[76] = CD_GREEN; ctgc.pattern[87] = CD_GREEN; + ctgc.pattern[77] = CD_GREEN; ctgc.pattern[88] = CD_GREEN; + + ctgc.dashes[0] = 10; + ctgc.dashes[1] = 2; + ctgc.dashes[2] = 5; + ctgc.dashes[3] = 2; +} + +/*-------------------------------------------------------------------------*/ +/* Inicializa o CD Test. */ +/*-------------------------------------------------------------------------*/ +void CDTestInit(void) +{ + memset(&ctgc, 0, sizeof(ctgc)); + + if (use_gdiplus) + { +#ifdef USE_GDIPLUS + cdInitGdiPlus(); +#endif + } + + /* inicializaccao dos drivers */ + DriversInit(); + + /* mostra o dialogo principal */ + IupShow(IupGetHandle("dlgMain")); + + /* inicializaccao da barra de cores */ + ColorBarInit(IupGetHandle("dlgMain"), IupGetHandle("cnvColorBar"), &ctgc.foreground, &ctgc.background); + + /* cria o canvas do CD associado ao canvas do IUP */ + if (use_gdiplus) cdUseContextPlus(1); + ctgc.iup_canvas = cdCreateCanvas(CD_IUP, IupGetHandle("cnvMain")); + if (!antialias) cdCanvasSetAttribute(ctgc.iup_canvas, "ANTIALIAS", "0"); + cdActivate(ctgc.iup_canvas); + if (use_gdiplus) cdUseContextPlus(0); + + /* associa os call-backs */ + setcallbacks(); + + /* os call-backs do canvas devem ser associados depois de sua criacao */ + IupSetFunction("cmdRepaint", (Icallback) fRepaint); + IupSetFunction("cmdMotionCB", (Icallback) fMotionCB); + IupSetFunction("cmdButtonCB", (Icallback) fButtonCB); + IupSetFunction("cmdResizeCB", (Icallback) fResizeCB); + IupSetFunction("cmdGetFocusCB", (Icallback) fGetFocusCB); + + /* inicializaccao do contexto */ + ctgc.write_mode = CD_REPLACE; + ctgc.line_style = CD_CONTINUOUS; + ctgc.line_cap = CD_CAPFLAT; + ctgc.line_join = CD_MITER; + ctgc.fill_mode = CD_EVENODD; + ctgc.line_width = 1; + ctgc.font_style = CD_PLAIN; + ctgc.font_typeface = CD_SYSTEM; + ctgc.font_size = CD_STANDARD; + ctgc.text_alignment = CD_BASE_LEFT; + ctgc.text_orientation = 0; + ctgc.back_opacity = CD_TRANSPARENT; + ctgc.mark_type = CD_STAR; + ctgc.poly_mode = CD_OPEN_LINES; + ctgc.interior_style = CD_SOLID; + ctgc.hatch = CD_HORIZONTAL; + ctgc.following = FALSE; + ctgc.foreground = CD_BLACK; + ctgc.background = CD_WHITE; + ctgc.head = NULL; + ctgc.test_image = NULL; + ctgc.sim = 0; + ctgc.stretch_play = 0; + ctgc.dlg_x = IUP_CENTER; + ctgc.dlg_y = IUP_CENTER; + ctgc.visible = 0; + + /* inicializa os vetores stipple e pattern */ + initsamples(); + + /* inicializa o CDTest com a primitiva LINE */ + ctgc.dlg_cur_prim = IupGetHandle("dlgLB"); + ctgc.bt_cur_prim = IupGetHandle("btCurPrim"); + ctgc.cur_prim = LINE; + + /* inicializaccao do Canvas do IUP */ + cdActivate(ctgc.iup_canvas); + cdFont(ctgc.font_typeface,ctgc.font_style,ctgc.font_size); + cdBackground(ctgc.background); + cdClear(); + cdGetCanvasSize(&(ctgc.w),&(ctgc.h),NULL,NULL); + ctgc.bpp = cdGetColorPlanes(); + + { + double mm, xres; + cdPixel2MM(1, 0, &mm, NULL); + xres = 1.0/mm; + ctgc.res = xres; + } + + /* inicializa o canvas off-screen de double-bufering */ + ctgc.buffering = NO_BUFFER; + ctgc.buffer_canvas = NULL; + + /* inicializa o clipping */ + ctgc.clip_mode = CD_CLIPOFF; + cdGetClipArea(&(ctgc.clip_xmin), &(ctgc.clip_xmax), + &(ctgc.clip_ymin), &(ctgc.clip_ymax)); + + /* zera o buffer temporario de pontos */ + ctgc.num_points = 0; + + /* a lista de primitivas jah estah vazia, nao hah o que apagar */ + IupSetAttribute(IupGetHandle("itEditUndo"), IUP_ACTIVE, IUP_NO); + + /* atualiza o tamanho do canvas em pixels na barra de titulo */ + sprintf(ctgc.title, "CDTest 5.3 (%dx%d - %dbpp)", ctgc.w, ctgc.h, ctgc.bpp); + IupSetAttribute(IupGetHandle("dlgMain"), IUP_TITLE, ctgc.title); + + /* inicializa a barra de status */ + sprintf(ctgc.status_line, "LEFT click and drag."); + set_status(); + + /* inicializa a posiccao do mouse */ + mouse_pos(0, 0); + + /* constroi os dialogos do CDTest sem mostra-los */ + IupMap(IupGetHandle("dlgLB")); + IupMap(IupGetHandle("dlgAS")); + IupMap(IupGetHandle("dlgPixel")); + IupMap(IupGetHandle("dlgImage")); + IupMap(IupGetHandle("dlgImageRGB")); + IupMap(IupGetHandle("dlgMark")); + IupMap(IupGetHandle("dlgText")); + IupMap(IupGetHandle("dlgClip")); + IupMap(IupGetHandle("dlgAttributes")); + IupMap(IupGetHandle("dlgWDCanvas")); + IupMap(IupGetHandle("dlgPICCanvas")); + + /* cria o canvas WD */ + if (use_gdiplus) cdUseContextPlus(1); + ctgc.wd_canvas = cdCreateCanvas(CD_IUP, IupGetHandle("cnvWDCanvas")); + ctgc.pic_canvas = cdCreateCanvas(CD_IUP, IupGetHandle("cnvPICCanvas")); + ctgc.picture = cdCreateCanvas(CD_PICTURE, ""); + if (use_gdiplus) cdUseContextPlus(0); + + /* CDTEST default values */ + cdActivate(ctgc.picture); + cdLineStyleDashes(ctgc.dashes, 4); + cdPattern(10, 10, ctgc.pattern); + cdStipple(10, 10, ctgc.stipple); + cdInteriorStyle(CD_SOLID); + + cdActivate(ctgc.wd_canvas); + cdLineStyleDashes(ctgc.dashes, 4); + cdPattern(10, 10, ctgc.pattern); + cdStipple(10, 10, ctgc.stipple); + cdInteriorStyle(CD_SOLID); + + /* reativa o canvas IUP */ + cdActivate(ctgc.iup_canvas); + cdLineStyleDashes(ctgc.dashes, 4); + cdPattern(10, 10, ctgc.pattern); + cdStipple(10, 10, ctgc.stipple); + cdInteriorStyle(CD_SOLID); +} + +static void CDTestClose(void) +{ + dellist(); + + ColorBarClose(); + + if (ctgc.buffer_canvas) cdKillCanvas(ctgc.buffer_canvas); + if (ctgc.test_image) cdKillImage(ctgc.test_image); + cdKillCanvas(ctgc.picture); + cdKillCanvas(ctgc.pic_canvas); + cdKillCanvas(ctgc.wd_canvas); + cdKillCanvas(ctgc.iup_canvas); + + IupDestroy(IupGetHandle("dlgLB")); + IupDestroy(IupGetHandle("dlgAS")); + IupDestroy(IupGetHandle("dlgPixel")); + IupDestroy(IupGetHandle("dlgImage")); + IupDestroy(IupGetHandle("dlgImageRGB")); + IupDestroy(IupGetHandle("dlgMark")); + IupDestroy(IupGetHandle("dlgText")); + IupDestroy(IupGetHandle("dlgClip")); + IupDestroy(IupGetHandle("dlgAttributes")); + IupDestroy(IupGetHandle("dlgWDCanvas")); + IupDestroy(IupGetHandle("dlgPICCanvas")); + + IupDestroy(IupGetHandle("dlgMain")); +} + +static int iscurvisible(void) +{ + char* vis = IupGetAttribute(ctgc.dlg_cur_prim, IUP_VISIBLE); + if (!vis) + return 0; + return strcmp(vis, IUP_YES) == 0? 1: 0; +} + +/*-------------------------------------------------------------------------*/ +/* Copia o conteudo da lista de primitivas para o dispositivo ativo. */ +/*-------------------------------------------------------------------------*/ +void putlist(cdCanvas *target) +{ + tList *temp; + int wdc_w, wdc_h, wd = 0; + + /* ativa o canvas destino */ + cdActivate(target); + + if (target == ctgc.wd_canvas) + { + cdGetCanvasSize(&wdc_w, &wdc_h, NULL, NULL); + wdWindow(0, ctgc.w, 0, ctgc.h); + wdViewport(0, wdc_w, 0, wdc_h); + wd = 1; + } + + /* limpa o canvas com a cor de fundo */ + cdBackground(ctgc.background); + cdClear(); + cdClipArea(ctgc.clip_xmin, ctgc.clip_xmax, ctgc.clip_ymin, ctgc.clip_ymax); + cdClip(ctgc.clip_mode); + + /* coloca a lista de primitivas no canvas */ + for (temp = ctgc.head; temp; temp = (tList *) temp->next) + { + switch (temp->type) { + case LINE: + cdWriteMode(temp->par.lineboxpar.write_mode); + cdLineCap(temp->par.lineboxpar.line_cap); + cdLineJoin(temp->par.lineboxpar.line_join); + cdLineStyle(temp->par.lineboxpar.line_style); + cdLineWidth(temp->par.lineboxpar.line_width); + cdForeground(temp->par.lineboxpar.foreground); + if (wd) + wdLine(temp->par.lineboxpar.x1, temp->par.lineboxpar.y1, + temp->par.lineboxpar.x2, temp->par.lineboxpar.y2); + else + cdLine(temp->par.lineboxpar.x1, temp->par.lineboxpar.y1, + temp->par.lineboxpar.x2, temp->par.lineboxpar.y2); + break; + case RECT: + cdWriteMode(temp->par.lineboxpar.write_mode); + cdLineCap(temp->par.lineboxpar.line_cap); + cdLineJoin(temp->par.lineboxpar.line_join); + cdLineStyle(temp->par.lineboxpar.line_style); + cdLineWidth(temp->par.lineboxpar.line_width); + cdForeground(temp->par.lineboxpar.foreground); + if (wd) + wdRect(temp->par.lineboxpar.x1, temp->par.lineboxpar.x2, + temp->par.lineboxpar.y1, temp->par.lineboxpar.y2); + else + cdRect(temp->par.lineboxpar.x1, temp->par.lineboxpar.x2, + temp->par.lineboxpar.y1, temp->par.lineboxpar.y2); + break; + case BOX: + cdWriteMode(temp->par.lineboxpar.write_mode); + cdLineCap(temp->par.lineboxpar.line_cap); + cdLineJoin(temp->par.lineboxpar.line_join); + cdLineStyle(temp->par.lineboxpar.line_style); + cdLineWidth(temp->par.lineboxpar.line_width); + cdForeground(temp->par.lineboxpar.foreground); + cdBackground(temp->par.lineboxpar.background); + cdBackOpacity(temp->par.lineboxpar.back_opacity); + cdHatch(temp->par.lineboxpar.hatch); + cdInteriorStyle(temp->par.lineboxpar.interior_style); + if (wd) + wdBox(temp->par.lineboxpar.x1, temp->par.lineboxpar.x2, + temp->par.lineboxpar.y1, temp->par.lineboxpar.y2); + else + cdBox(temp->par.lineboxpar.x1, temp->par.lineboxpar.x2, + temp->par.lineboxpar.y1, temp->par.lineboxpar.y2); + break; + case ARC: + cdWriteMode(temp->par.arcsectorpar.write_mode); + cdLineCap(temp->par.arcsectorpar.line_cap); + cdLineJoin(temp->par.arcsectorpar.line_join); + cdLineStyle(temp->par.arcsectorpar.line_style); + cdLineWidth(temp->par.arcsectorpar.line_width); + cdForeground(temp->par.arcsectorpar.foreground); + if (wd) + wdArc(temp->par.arcsectorpar.xc, temp->par.arcsectorpar.yc, + temp->par.arcsectorpar.w, temp->par.arcsectorpar.h, + temp->par.arcsectorpar.angle1, temp->par.arcsectorpar.angle2); + else + cdArc(temp->par.arcsectorpar.xc, temp->par.arcsectorpar.yc, + temp->par.arcsectorpar.w, temp->par.arcsectorpar.h, + temp->par.arcsectorpar.angle1, temp->par.arcsectorpar.angle2); + break; + case CHORD: + cdWriteMode(temp->par.arcsectorpar.write_mode); + cdLineCap(temp->par.arcsectorpar.line_cap); + cdLineJoin(temp->par.arcsectorpar.line_join); + cdLineStyle(temp->par.arcsectorpar.line_style); + cdLineWidth(temp->par.arcsectorpar.line_width); + cdForeground(temp->par.arcsectorpar.foreground); + cdBackground(temp->par.arcsectorpar.background); + cdBackOpacity(temp->par.arcsectorpar.back_opacity); + cdHatch(temp->par.arcsectorpar.hatch); + cdInteriorStyle(temp->par.arcsectorpar.interior_style); + if (wd) + wdChord(temp->par.arcsectorpar.xc, temp->par.arcsectorpar.yc, + temp->par.arcsectorpar.w, temp->par.arcsectorpar.h, + temp->par.arcsectorpar.angle1, temp->par.arcsectorpar.angle2); + else + cdChord(temp->par.arcsectorpar.xc, temp->par.arcsectorpar.yc, + temp->par.arcsectorpar.w, temp->par.arcsectorpar.h, + temp->par.arcsectorpar.angle1, temp->par.arcsectorpar.angle2); + break; + case SECTOR: + cdWriteMode(temp->par.arcsectorpar.write_mode); + cdLineCap(temp->par.arcsectorpar.line_cap); + cdLineJoin(temp->par.arcsectorpar.line_join); + cdLineStyle(temp->par.arcsectorpar.line_style); + cdLineWidth(temp->par.arcsectorpar.line_width); + cdForeground(temp->par.arcsectorpar.foreground); + cdBackground(temp->par.arcsectorpar.background); + cdBackOpacity(temp->par.arcsectorpar.back_opacity); + cdHatch(temp->par.arcsectorpar.hatch); + cdInteriorStyle(temp->par.arcsectorpar.interior_style); + if (wd) + wdSector(temp->par.arcsectorpar.xc, temp->par.arcsectorpar.yc, + temp->par.arcsectorpar.w, temp->par.arcsectorpar.h, + temp->par.arcsectorpar.angle1, temp->par.arcsectorpar.angle2); + else + cdSector(temp->par.arcsectorpar.xc, temp->par.arcsectorpar.yc, + temp->par.arcsectorpar.w, temp->par.arcsectorpar.h, + temp->par.arcsectorpar.angle1, temp->par.arcsectorpar.angle2); + break; + case PIXEL: + cdWriteMode(temp->par.pixelpar.write_mode); + cdPixel(temp->par.pixelpar.x, temp->par.pixelpar.y, + temp->par.pixelpar.foreground); + break; + case MARK: + cdWriteMode(temp->par.markpar.write_mode); + cdMarkSize(temp->par.markpar.mark_size); + cdMarkType(temp->par.markpar.mark_type); + cdForeground(temp->par.markpar.foreground); + if (wd) + wdMark(temp->par.markpar.x, temp->par.markpar.y); + else + cdMark(temp->par.markpar.x, temp->par.markpar.y); + break; + case TEXT: + cdWriteMode(temp->par.textpar.write_mode); + cdForeground(temp->par.textpar.foreground); + cdBackground(temp->par.textpar.background); + cdBackOpacity(temp->par.textpar.back_opacity); + cdTextAlignment(temp->par.textpar.text_alignment); + cdTextOrientation(temp->par.textpar.text_orientation); + cdFont(temp->par.textpar.font_typeface, + temp->par.textpar.font_style, + temp->par.textpar.font_size); + if (wd) + wdText(temp->par.textpar.x, temp->par.textpar.y, + temp->par.textpar.s); + else + cdText(temp->par.textpar.x, temp->par.textpar.y, + temp->par.textpar.s); + break; + case POLY: { + int i; + cdForeground(temp->par.polypar.foreground); + cdBackground(temp->par.polypar.background); + cdWriteMode(temp->par.polypar.write_mode); + cdLineCap(temp->par.polypar.line_cap); + cdLineJoin(temp->par.polypar.line_join); + cdLineStyle(temp->par.polypar.line_style); + cdLineWidth(temp->par.polypar.line_width); + cdFillMode(temp->par.polypar.fill_mode); + cdBackOpacity(temp->par.polypar.back_opacity); + cdHatch(temp->par.polypar.hatch); + cdInteriorStyle(temp->par.polypar.interior_style); + cdBegin(temp->par.polypar.poly_mode); + if (wd) + for (i=0; (ipar.polypar.num_points); i++) { + wdVertex(temp->par.polypar.points[i].x, + temp->par.polypar.points[i].y); + } + else + for (i=0; (ipar.polypar.num_points); i++) { + cdVertex(temp->par.polypar.points[i].x, + temp->par.polypar.points[i].y); + } + cdEnd(); + break; + case META: + cdWriteMode(CD_REPLACE); + cdLineStyle(CD_CONTINUOUS); + cdLineWidth(1); + cdBackground(CD_WHITE); + cdBackOpacity(CD_TRANSPARENT); + cdForeground(CD_BLACK); + cdInteriorStyle(CD_SOLID); + if (ctgc.stretch_play) + { + if (wd) + cdPlay(temp->par.metapar.ctx, 0, wdc_w-1, 0, wdc_h-1, temp->par.metapar.filename); + else + cdPlay(temp->par.metapar.ctx, 0, ctgc.w-1, 0, ctgc.h-1, temp->par.metapar.filename); + } + else + cdPlay(temp->par.metapar.ctx, 0, 0, 0, 0, temp->par.metapar.filename); + break; + default: + break; + } + } + } + + /* volta o clip-mode para o corrente */ + cdClip(ctgc.clip_mode); +} + +/*-------------------------------------------------------------------------*/ +/* Copia o conteudo da lista de primitivas no canvas WD. */ +/*-------------------------------------------------------------------------*/ +int fWDRepaint(void) +{ + putlist(ctgc.wd_canvas); + + /* reativa o canvas iup */ + cdActivate(ctgc.iup_canvas); + + return IUP_DEFAULT; +} + +int fPICRepaint(void) +{ + int w, h; + putlist(ctgc.picture); + + cdActivate(ctgc.pic_canvas); + cdGetCanvasSize(&w, &h, NULL, NULL); + cdClear(); + if (ctgc.stretch_play) + cdPlay(CD_PICTURE, 0, w-1, 0, h-1, ctgc.picture); + else + cdPlay(CD_PICTURE, 0, 0, 0, 0, ctgc.picture); + + /* reativa o canvas iup */ + cdActivate(ctgc.iup_canvas); + + return IUP_DEFAULT; +} + +/*-------------------------------------------------------------------------*/ +/* Redesenha o canvas. */ +/*-------------------------------------------------------------------------*/ +void updatecanvas(void) +{ + if (ctgc.buffering == NO_BUFFER) + putlist(ctgc.iup_canvas); + else + { + cdActivate(ctgc.iup_canvas); + cdClip(CD_CLIPOFF); + + putlist(ctgc.buffer_canvas); + cdFlush(); + + cdActivate(ctgc.iup_canvas); + cdClip(ctgc.clip_mode); + } + + if (ctgc.wd_dialog) + fWDRepaint(); + + if (ctgc.pic_dialog) + fPICRepaint(); +} + +/*-------------------------------------------------------------------------*/ +/* Redesenha o canvas. */ +/*-------------------------------------------------------------------------*/ +int fRepaint(void) +{ + int i; + + /* ativa o canvas na tela */ + cdActivate(ctgc.iup_canvas); + wdViewport(0, ctgc.w, 0, ctgc.h); + + /* desliga o clipping durante o evento Repaint */ + cdClip(CD_CLIPOFF); + + /* double-buffering? */ + cdWriteMode(CD_REPLACE); + updatecanvas(); + + /* se o evento repaint for gerado durante o rubber band...*/ + /* ...eh preciso restaurar o estado anterior */ + if (ctgc.following) { + cdWriteMode(CD_NOT_XOR); + cdForeground(CD_BLACK); + cdLineStyle(CD_CONTINUOUS); + cdLineWidth(1); + switch (ctgc.cur_prim) { + case POLY: + for (i=0; (i 1) { + cdBegin(ctgc.poly_mode); + for (a=0; (a