From b7d40636e5d29607eb04ddab30ef9647c03fd134 Mon Sep 17 00:00:00 2001 From: Jim Monte Date: Sun, 15 Dec 2019 01:17:04 -0500 Subject: [PATCH] Additional freeing of device-dependent information for bug #419 and related bugs. --- src/frontend/hpgl.c | 67 ++-- src/frontend/plotting/plot5.c | 44 ++- src/frontend/plotting/x11.c | 12 +- src/frontend/postsc.c | 63 ++-- src/frontend/wdisp/windisp.c | 150 ++++---- src/frontend/wdisp/winprint.c | 621 ++++++++++++++++++---------------- 6 files changed, 495 insertions(+), 462 deletions(-) diff --git a/src/frontend/hpgl.c b/src/frontend/hpgl.c index 68d0a3485..865bbb62c 100644 --- a/src/frontend/hpgl.c +++ b/src/frontend/hpgl.c @@ -89,7 +89,8 @@ int GL_Init(void) { if (!cp_getvar("hcopyscale", CP_STRING, psscale, sizeof(psscale))) { scale = 1.0; - } else { + } + else { sscanf(psscale, "%lf", &scale); if ((scale <= 0) || (scale > 10)) scale = 1.0; @@ -106,20 +107,21 @@ int GL_Init(void) dispdev->minx = (int)(XOFF * 1.0); dispdev->miny = (int)(YOFF * 1.0); - return (0); + return 0; } /* devdep initially contains name of output file */ -int -GL_NewViewport(GRAPH *graph) +int GL_NewViewport(GRAPH *graph) { hcopygraphid = graph->graphid; if ((plotfile = fopen((char*) graph->devdep, "w")) == NULL) { - perror((char*) graph->devdep); + perror((char *) graph->devdep); + free(graph->devdep); graph->devdep = NULL; - return (1); + graph->n_byte_devdep = 0; + return 1; } if (graph->absolute.width) { @@ -146,13 +148,18 @@ GL_NewViewport(GRAPH *graph) /* start file off with a % */ fprintf(plotfile, "IN;DF;PA;"); - fprintf(plotfile, "SI %f,%f;", tocm*jgmult*fontwidth*scale, tocm*jgmult*fontheight*scale); + fprintf(plotfile, "SI %f,%f;", + tocm * jgmult * fontwidth * scale, + tocm * jgmult * fontheight * scale); #ifdef notdef if (!screenflag) #endif - + { graph->devdep = TMALLOC(GLdevdep, 1); + graph->n_byte_devdep = sizeof(GLdevdep); + } + DEVDEP(graph).lastlinestyle = -1; DEVDEP(graph).lastx = -1; DEVDEP(graph).lasty = -1; @@ -163,8 +170,7 @@ GL_NewViewport(GRAPH *graph) } -int -GL_Close(void) +int GL_Close(void) { /* in case GL_Close is called as part of an abort, w/o having reached GL_NewViewport */ @@ -187,8 +193,7 @@ GL_Close(void) } -int -GL_Clear(void) +int GL_Clear(void) { /* do nothing */ @@ -196,21 +201,21 @@ GL_Clear(void) } -int -GL_DrawLine(int x1, int y1, int x2, int y2) +int GL_DrawLine(int x1, int y1, int x2, int y2) { /* note: this is not extendible to more than one graph => will have to give NewViewport a writeable graph XXX */ if (DEVDEP(currentgraph).linecount == 0 - || x1 != DEVDEP(currentgraph).lastx - || y1 != DEVDEP(currentgraph).lasty) - { - fprintf(plotfile, "PU;PA %d , %d ;", jgmult*(x1 + xoff), jgmult*(y1 + yoff)); + || x1 != DEVDEP(currentgraph).lastx + || y1 != DEVDEP(currentgraph).lasty) { + fprintf(plotfile, "PU;PA %d , %d ;", + jgmult * (x1 + xoff), jgmult * (y1 + yoff)); } if (x1 != x2 || y1 != y2) { - fprintf(plotfile, "PD;PA %d , %d ;", jgmult*(x2 + xoff), jgmult*(y2 + yoff)); + fprintf(plotfile, "PD;PA %d , %d ;", + jgmult * (x2 + xoff), jgmult * (y2 + yoff)); DEVDEP(currentgraph).linecount += 1; } @@ -223,8 +228,7 @@ GL_DrawLine(int x1, int y1, int x2, int y2) /* ARGSUSED */ -int -GL_Arc(int x0, int y0, int r, double theta, double delta_theta) +int GL_Arc(int x0, int y0, int r, double theta, double delta_theta) { int x1, y1, angle; @@ -233,8 +237,10 @@ GL_Arc(int x0, int y0, int r, double theta, double delta_theta) angle = (int)(RAD_TO_DEG * delta_theta); - fprintf(plotfile, "PU;PA %d , %d;", jgmult*(x1+xoff+XTADJ), jgmult*(y1+yoff+YTADJ)); - fprintf(plotfile, "PD;AA %d , %d, %d;", jgmult*(x0+xoff+XTADJ), jgmult*(y0+yoff+YTADJ), angle); + fprintf(plotfile, "PU;PA %d , %d;", + jgmult * (x1 + xoff + XTADJ), jgmult * (y1 + yoff + YTADJ)); + fprintf(plotfile, "PD;AA %d , %d, %d;", + jgmult * (x0 + xoff + XTADJ), jgmult*(y0 + yoff + YTADJ), angle); DEVDEP(currentgraph).linecount = 0; @@ -242,13 +248,13 @@ GL_Arc(int x0, int y0, int r, double theta, double delta_theta) } -int -GL_Text(char *text, int x, int y, int angle) +int GL_Text(char *text, int x, int y, int angle) { /* move to (x, y) */ NG_IGNORE(angle); - fprintf(plotfile, "PU;PA %d , %d;", jgmult*(x+xoff+XTADJ), jgmult*(y+yoff+YTADJ)); + fprintf(plotfile, "PU;PA %d , %d;", + jgmult * (x + xoff + XTADJ), jgmult * (y + yoff + YTADJ)); fprintf(plotfile, "LB %s \x03", text); DEVDEP(currentgraph).lastx = -1; @@ -258,8 +264,7 @@ GL_Text(char *text, int x, int y, int angle) } -int -GL_SetLinestyle(int linestyleid) +int GL_SetLinestyle(int linestyleid) { /* special case get it when GL_Text restores a -1 linestyle */ @@ -283,8 +288,7 @@ GL_SetLinestyle(int linestyleid) /* ARGSUSED */ -int -GL_SetColor(int colorid) +int GL_SetColor(int colorid) { fprintf(plotfile, "SP %d;", colorid); @@ -292,8 +296,7 @@ GL_SetColor(int colorid) } -int -GL_Update(void) +int GL_Update(void) { fflush(plotfile); diff --git a/src/frontend/plotting/plot5.c b/src/frontend/plotting/plot5.c index f07b26426..5c4db679c 100644 --- a/src/frontend/plotting/plot5.c +++ b/src/frontend/plotting/plot5.c @@ -28,8 +28,7 @@ static char *linestyle[] = { static int currentlinestyle = SOLID; -int -Plt5_Init(void) +int Plt5_Init(void) { dispdev->numlinestyles = 4; dispdev->numcolors = 2; @@ -38,17 +37,18 @@ Plt5_Init(void) dispdev->width = 1000; dispdev->height = 1000; - return (0); + return 0; } -int -Plt5_NewViewport(GRAPH *graph) +int Plt5_NewViewport(GRAPH *graph) { if ((plotfile = fopen((char*) graph->devdep, "w")) == NULL) { + perror((char *) graph->devdep); + free(graph->devdep); graph->devdep = NULL; - perror((char*) graph->devdep); - return (1); + graph->n_byte_devdep = 0; + return 1; } if (graph->absolute.width) { @@ -64,7 +64,8 @@ Plt5_NewViewport(GRAPH *graph) /* re-scale linestyles */ gr_relinestyle(graph); - } else { + } + else { /* scale space */ putc('s', plotfile); putsi(0); @@ -83,13 +84,13 @@ Plt5_NewViewport(GRAPH *graph) /* set to NULL so graphdb doesn't incorrectly de-allocate it */ graph->devdep = NULL; + graph->n_byte_devdep = 0; - return (0); + return 0; } -int -Plt5_Close(void) +int Plt5_Close(void) { /* in case Plt5_Close is called as part of an abort, w/o having reached Plt5_NewViewport */ @@ -100,16 +101,14 @@ Plt5_Close(void) } -int -Plt5_Clear(void) +int Plt5_Clear(void) { /* do nothing */ return 0; } -int -Plt5_DrawLine(int x1, int y1, int x2, int y2) +int Plt5_DrawLine(int x1, int y1, int x2, int y2) { putc('l', plotfile); putsi(x1); @@ -121,8 +120,7 @@ Plt5_DrawLine(int x1, int y1, int x2, int y2) } -int -Plt5_Arc(int xc, int yc, int radius, double theta, double delta_theta) +int Plt5_Arc(int xc, int yc, int radius, double theta, double delta_theta) { int x0, y0, x1, y1; @@ -169,8 +167,7 @@ Plt5_Arc(int xc, int yc, int radius, double theta, double delta_theta) } -int -Plt5_Text(char *text, int x, int y, int angle) +int Plt5_Text(char *text, int x, int y, int angle) { int savedlstyle; NG_IGNORE(angle); @@ -195,8 +192,7 @@ Plt5_Text(char *text, int x, int y, int angle) } -int -Plt5_SetLinestyle(int linestyleid) +int Plt5_SetLinestyle(int linestyleid) { if (linestyleid < 0 || linestyleid > dispdev->numlinestyles) { internalerror("bad linestyleid"); @@ -211,8 +207,7 @@ Plt5_SetLinestyle(int linestyleid) /* ARGSUSED */ -int -Plt5_SetColor(int colorid) +int Plt5_SetColor(int colorid) { NG_IGNORE(colorid); @@ -221,8 +216,7 @@ Plt5_SetColor(int colorid) } -int -Plt5_Update(void) +int Plt5_Update(void) { fflush(plotfile); return 0; diff --git a/src/frontend/plotting/x11.c b/src/frontend/plotting/x11.c index 3b726d7f7..f581028f5 100644 --- a/src/frontend/plotting/x11.c +++ b/src/frontend/plotting/x11.c @@ -383,6 +383,7 @@ X11_NewViewport(GRAPH *graph) int trys; graph->devdep = TMALLOC(X11devdep, 1); + graph->n_byte_devdep = sizeof(X11devdep); /* set up new shell */ DEVDEP(graph).shell = XtCreateApplicationShell @@ -855,7 +856,7 @@ hardcopy(Widget w, XtPointer client_data, XtPointer call_data) NG_IGNORE(call_data); NG_IGNORE(w); - /* com_hardcopy() -> gr_resize() -> setcolor() dirung postscript + /* com_hardcopy() -> gr_resize() -> setcolor() during postscript printing will act on currentgraph with a DEVDEP inherited from PSdevdep. But currentgraph had not changed its devdep, which was derived from incompatible X11devdep, thus overwriting some variables. Here you find a @@ -893,16 +894,16 @@ killwin(Widget w, XtPointer client_data, XtPointer call_data) } + /* called from postcoms.c In the command 'destroy ac2' Will remove window associated with the plot (e.g. ac2) just before data of the plot are deleted.*/ -void -RemoveWindow(GRAPH *graph) +void RemoveWindow(GRAPH *graph) { if (graph->devdep) { /* Iplots are done asynchronously */ DEVDEP(graph).isopen = 0; - /* MW. Not sure but DestroyGraph might free() to much - try Xt...() first */ + /* MW. Not sure but DestroyGraph might free() too much - try Xt...() first */ XtUnmapWidget(DEVDEP(graph).shell); XtDestroyWidget(DEVDEP(graph).shell); XFreeFont(display, DEVDEP(graph).font); @@ -913,7 +914,8 @@ RemoveWindow(GRAPH *graph) currentgraph = NULL; DestroyGraph(graph->graphid); -} +} /* end of function RemoveWindow */ + /* call higher gr_redraw routine */ diff --git a/src/frontend/postsc.c b/src/frontend/postsc.c index 4c422f459..a3145b027 100644 --- a/src/frontend/postsc.c +++ b/src/frontend/postsc.c @@ -79,8 +79,7 @@ void PS_Stroke(void); /* Set scale, color and size of the plot */ -int -PS_Init(void) +int PS_Init(void) { char pswidth[30], psheight[30]; @@ -108,7 +107,8 @@ PS_Init(void) /* plot size */ if (!cp_getvar("hcopywidth", CP_STRING, pswidth, sizeof( pswidth))) { dispdev->width = (int)(7.75 * 72.0 * scale); /* (8 1/2 - 3/4) * 72 */ - } else { + } + else { sscanf(pswidth, "%d", &(dispdev->width)); if (dispdev->width <= 100) dispdev->width = 100; @@ -117,7 +117,8 @@ PS_Init(void) } if (!cp_getvar("hcopyheight", CP_STRING, psheight, sizeof(psheight))) { dispdev->height = dispdev->width; - } else { + } + else { sscanf(psheight, "%d", &(dispdev->height)); if (dispdev->height <= 100) dispdev->height = 100; @@ -135,15 +136,17 @@ PS_Init(void) * viewport.height = absolute.height - 2 * viewportyoff */ - if (!cp_getvar("hcopyfont", CP_STRING, psfont, sizeof(psfont))) + if (!cp_getvar("hcopyfont", CP_STRING, psfont, sizeof(psfont))) { strcpy(psfont, "Helvetica"); + } if (!cp_getvar("hcopyfontsize", CP_STRING, psfontsize, sizeof(psfontsize))) { fontsize = 10; fontwidth = 6; fontheight = 14; xtadj = (int)(XTADJ * scale); ytadj = (int)(YTADJ * scale); - } else { + } + else { sscanf(psfontsize, "%d", &fontsize); if ((fontsize < 10) || (fontsize > 14)) fontsize = 10; @@ -157,21 +160,23 @@ PS_Init(void) dispdev->minx = (int)(XOFF / scale); dispdev->miny = (int)(YOFF / scale); - return (0); -} + return 0; +} /* end of function PS_Init */ + /* Plot and fill bounding box */ -int -PS_NewViewport(GRAPH *graph) +int PS_NewViewport(GRAPH *graph) { int x1, x2, y1, y2; hcopygraphid = graph->graphid; /* devdep initially contains name of output file */ if ((plotfile = fopen((char*)graph->devdep, "w")) == NULL) { - perror((char*)graph->devdep); + perror((char *) graph->devdep); + free(graph->devdep); graph->devdep = NULL; - return (1); + graph->n_byte_devdep = 0; + return 1; } if (graph->absolute.width) { @@ -233,6 +238,7 @@ PS_NewViewport(GRAPH *graph) psfont, (int) (fontsize * scale)); graph->devdep = TMALLOC(PSdevdep, 1); + graph->n_byte_devdep = sizeof(PSdevdep); DEVDEP(graph).lastlinestyle = -1; DEVDEP(graph).lastcolor = -1; DEVDEP(graph).lastx = -1; @@ -245,8 +251,7 @@ PS_NewViewport(GRAPH *graph) } -int -PS_Close(void) +int PS_Close(void) { /* in case PS_Close is called as part of an abort, w/o having reached PS_NewViewport */ @@ -267,16 +272,14 @@ PS_Close(void) } -int -PS_Clear(void) +int PS_Clear(void) { /* do nothing */ return 0; } -int -PS_DrawLine(int x1, int y1, int x2, int y2) +int PS_DrawLine(int x1, int y1, int x2, int y2) { /* note: this is not extendible to more than one graph => will have to give NewViewport a writeable graph XXX */ @@ -303,8 +306,7 @@ PS_DrawLine(int x1, int y1, int x2, int y2) } -int -PS_Arc(int x0, int y0, int r, double theta, double delta_theta) +int PS_Arc(int x0, int y0, int r, double theta, double delta_theta) { double x1, y1; double angle1, angle2; @@ -325,8 +327,7 @@ PS_Arc(int x0, int y0, int r, double theta, double delta_theta) } -int -PS_Text(char *text, int x, int y, int angle) +int PS_Text(char *text, int x, int y, int angle) { int savedlstyle, savedcolor; @@ -368,8 +369,7 @@ PS_Text(char *text, int x, int y, int angle) /* PS_DefineColor */ /* PS_DefineLinestyle */ -int -PS_SetLinestyle(int linestyleid) +int PS_SetLinestyle(int linestyleid) { /* special case get it when PS_Text restores a -1 linestyle */ @@ -387,16 +387,14 @@ PS_SetLinestyle(int linestyleid) } -int -PS_SetColor(int colorid) +int PS_SetColor(int colorid) { PS_LinestyleColor(currentgraph->linestyle, colorid); return 0; } -int -PS_Update(void) +int PS_Update(void) { fflush(plotfile); return 0; @@ -405,8 +403,7 @@ PS_Update(void) /**************** PRIVAT FUNCTIONS OF PS FRONTEND *****************************/ -void -PS_SelectColor(int colorid) /* should be replaced by PS_DefineColor */ +void PS_SelectColor(int colorid) /* should be replaced by PS_DefineColor */ { char colorN[30] = "", colorstring[30] = ""; char rgb[30], s_red[30] = "0x", s_green[30] = "0x", s_blue[30] = "0x"; @@ -468,8 +465,7 @@ PS_SelectColor(int colorid) /* should be replaced by PS_DefineColor */ } -void -PS_LinestyleColor(int linestyleid, int colorid) +void PS_LinestyleColor(int linestyleid, int colorid) { /* we have some different linestyles and colors: - color and linestyle we got via function call @@ -519,8 +515,7 @@ PS_LinestyleColor(int linestyleid, int colorid) } -void -PS_Stroke(void) +void PS_Stroke(void) { /* strokes an open path */ if (DEVDEP(currentgraph).linecount > 0) { diff --git a/src/frontend/wdisp/windisp.c b/src/frontend/wdisp/windisp.c index 557169cb4..598f613e0 100644 --- a/src/frontend/wdisp/windisp.c +++ b/src/frontend/wdisp/windisp.c @@ -107,9 +107,7 @@ WIN_Init() returns 0, if no error ocurred. WIN_Init() does not yet open a window, this happens only in WIN_NewViewport() ******************************************************************************/ - -int -WIN_Init(void) +int WIN_Init(void) { char colorstring[BSIZE_SP]; @@ -126,10 +124,12 @@ WIN_Init(void) isblack = !cieq(colorstring, "white"); /* get linewidth information from spinit */ - if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth, 0)) + if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth, 0)) { linewidth = 0; - if (linewidth < 0) + } + if (linewidth < 0) { linewidth = 0; + } /* only for the first time: */ if (!IsRegistered) { @@ -165,10 +165,12 @@ WIN_Init(void) ColorTable[11] = RGB(255, 128, 128); /* pink */ /* 2. color bank (with different line style */ - if (isblack) + if (isblack) { ColorTable[12] = RGB(255, 255, 255); /* white */ - else + } + else { ColorTable[12] = RGB( 0, 0, 0); /* black */ + } ColorTable[13] = RGB( 0, 255, 0); /* green */ ColorTable[14] = RGB(255, 0, 0); /* red */ @@ -192,17 +194,20 @@ WIN_Init(void) TheWndClass.lpszMenuName = NULL; TheWndClass.hCursor = LoadCursor(NULL, IDC_ARROW); - if (isblack) + if (isblack) { TheWndClass.hbrBackground = GetStockObject(BLACK_BRUSH); - else + } + else { TheWndClass.hbrBackground = GetStockObject(WHITE_BRUSH); + } TheWndClass.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(2)); TheWndClass.cbClsExtra = 0; TheWndClass.cbWndExtra = sizeof(GRAPH *); - if (!RegisterClass(&TheWndClass)) + if (!RegisterClass(&TheWndClass)) { return 1; + } } /* not first time */ else if (isblackold != isblack) { @@ -214,10 +219,12 @@ WIN_Init(void) ColorTable[0] = RGB(255, 255, 255); /* white = background */ ColorTable[1] = RGB( 0, 0, 0); /* black = text and grid */ } - if (isblack) + if (isblack) { ColorTable[12] = RGB(255, 255, 255); /* white */ - else + } + else { ColorTable[12] = RGB( 0, 0, 0); /* black */ + } isblackold = isblack; } @@ -230,28 +237,27 @@ WIN_Init(void) /* get pointer to graph */ /* (attach to window) */ -static GRAPH * -pGraph(HWND hwnd) +static GRAPH *pGraph(HWND hwnd) { return (GRAPH *) GetWindowLongPtr(hwnd, 0); } /* return line style for plotting */ -static int -LType(int ColorIndex) +static int LType(int ColorIndex) { - if (ColorIndex >= 12) + if (ColorIndex >= 12) { return PS_DOT; - else + } + else { return PS_SOLID; + } } /* postscript hardcopy from a plot window */ /* called by SystemMenue / Postscript hardcopy */ -static LRESULT -HcpyPlot(HWND hwnd) +static LRESULT HcpyPlot(HWND hwnd) { int colorval = isblack? 0 : 1; NG_IGNORE(hwnd); @@ -261,13 +267,13 @@ HcpyPlot(HWND hwnd) } -static LRESULT -HcpyPlotBW(HWND hwnd) +static LRESULT HcpyPlotBW(HWND hwnd) { int bgcolor; NG_IGNORE(hwnd); - if (cp_getvar("hcopypscolor", CP_NUM, &bgcolor, 0)) + if (cp_getvar("hcopypscolor", CP_NUM, &bgcolor, 0)) { cp_remvar("hcopypscolor"); + } com_hardcopy(NULL); return 0; } @@ -275,8 +281,7 @@ HcpyPlotBW(HWND hwnd) /* print a plot window */ /* called by SystemMenue / Print */ -static LRESULT -PrintPlot(HWND hwnd) +static LRESULT PrintPlot(HWND hwnd) { GRAPH *graph; GRAPH *temp; @@ -288,20 +293,23 @@ PrintPlot(HWND hwnd) /* switch to printer */ /* (results in WPRINT_Init()) */ - if (DevSwitch("WinPrint")) + if (DevSwitch("WinPrint")) { return 0; + } /* Cursor = wait */ SetCursor(LoadCursor(NULL, IDC_WAIT)); /* copy graph */ temp = CopyGraph(graph); - if (!temp) + if (!temp) { goto PrintEND; + } /* add to the copy the new printer data */ - if (NewViewport(temp)) + if (NewViewport(temp)) { goto PrintEND2; + } /* make correction to placement of grid (copy from gr_init) */ temp->viewportxoff = temp->fontwidth * 8; @@ -326,8 +334,7 @@ PrintPlot(HWND hwnd) /* initialze printer */ -static LRESULT -PrintInit(HWND hwnd) +static LRESULT PrintInit(HWND hwnd) { /* hand over to printer module */ WPRINT_PrintInit(hwnd); @@ -336,8 +343,8 @@ PrintInit(HWND hwnd) /* window procedure */ -LRESULT CALLBACK -PlotWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK PlotWindowProc(HWND hwnd, UINT uMsg, + WPARAM wParam, LPARAM lParam) { static int x0, y0, xep, yep; int xe, ye, prevmix; @@ -380,10 +387,12 @@ PlotWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) /* left mouse button: connect coordinate pair by dashed pair of x, y lines */ if (wParam & MK_LBUTTON) { hdc = GetDC(hwnd); - if (isblack) + if (isblack) { prevmix = SetROP2(hdc, R2_XORPEN); - else + } + else { prevmix = SetROP2(hdc, R2_NOTXORPEN); + } /* Create white dashed pen */ NewPen = CreatePen(LType(12), 0, ColorTable[1]); OldPen = SelectObject(hdc, NewPen); @@ -466,7 +475,8 @@ PlotWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) hypot(fx0, fy0), (angle > 0) ? angle : 360.0 + angle); } - } else { + } + else { /* need to print info about two points */ fprintf(stdout, "\nx0 = %g, y0 = %g x1 = %g, y1 = %g\n", fx0, fy0, fxe, fye); @@ -601,8 +611,7 @@ PlotWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ******************************************************************************/ -int -WIN_NewViewport(GRAPH *graph) +int WIN_NewViewport(GRAPH *graph) { int i; HWND window; @@ -612,8 +621,9 @@ WIN_NewViewport(GRAPH *graph) HMENU sysmenu; /* test the parameters */ - if (!graph) + if (!graph) { return 1; + } /* initialize if not yet done */ if (WIN_Init() != 0) { @@ -623,24 +633,30 @@ WIN_NewViewport(GRAPH *graph) /* allocate device dependency info */ wd = calloc(1, sizeof(tWindowData)); - if (!wd) + if (!wd) { return 1; + } graph->devdep = wd; + graph->n_byte_devdep = sizeof(tWindowData); /* Create the window */ i = GetSystemMetrics(SM_CYSCREEN) / 3; window = CreateWindow(WindowName, graph->plotname, WS_OVERLAPPEDWINDOW, 0, 0, WinLineWidth, i * 2 - 22, NULL, NULL, hInst, NULL); - if (!window) + if (!window) { return 1; + } + /* change the background color of all windows (both new and already plotted) by assessing the registered window class */ - if (isblack) + if (isblack) { SetClassLongPtr(window, GCLP_HBRBACKGROUND, (LONG_PTR)GetStockObject(BLACK_BRUSH)); - else + } + else { SetClassLongPtr(window, GCLP_HBRBACKGROUND, (LONG_PTR)GetStockObject(WHITE_BRUSH)); + } wd->wnd = window; @@ -709,8 +725,7 @@ to the printer. Therefore WIN_Close is not allowed to do anything, cancelling of the structures occurs at program termination. ******************************************************************************/ -int -WIN_Close(void) +int WIN_Close(void) { return 0; } @@ -733,8 +748,7 @@ RealClose(void) #endif -int -WIN_Clear(void) +int WIN_Clear(void) { tpWindowData wd; @@ -753,8 +767,7 @@ WIN_Clear(void) } -int -WIN_DrawLine(int x1, int y1, int x2, int y2) +int WIN_DrawLine(int x1, int y1, int x2, int y2) { tpWindowData wd; HPEN OldPen; @@ -778,8 +791,7 @@ WIN_DrawLine(int x1, int y1, int x2, int y2) } -int -WIN_Arc(int x0, int y0, int radius, double theta, double delta_theta) +int WIN_Arc(int x0, int y0, int radius, double theta, double delta_theta) /* * Notes: * Draws an arc of and center at (x0,y0) beginning at @@ -859,8 +871,7 @@ WIN_Text_old(char *text, int x, int y, int degrees) #endif -int -WIN_Text(char *text, int x, int y, int angle) +int WIN_Text(char *text, int x, int y, int angle) { tpWindowData wd; HFONT hfont; @@ -906,8 +917,7 @@ WIN_Text(char *text, int x, int y, int angle) } -int -WIN_DefineColor(int colorid, double red, double green, double blue) +int WIN_DefineColor(int colorid, double red, double green, double blue) { NG_IGNORE(colorid); NG_IGNORE(red); @@ -917,8 +927,7 @@ WIN_DefineColor(int colorid, double red, double green, double blue) } -int -WIN_DefineLinestyle(int num, int mask) +int WIN_DefineLinestyle(int num, int mask) { NG_IGNORE(num); NG_IGNORE(mask); @@ -926,16 +935,14 @@ WIN_DefineLinestyle(int num, int mask) } -int -WIN_SetLinestyle(int style) +int WIN_SetLinestyle(int style) { NG_IGNORE(style); return 0; } -int -WIN_SetColor(int color) +int WIN_SetColor(int color) { tpWindowData wd; @@ -952,8 +959,7 @@ WIN_SetColor(int color) } -int -WIN_Update(void) +int WIN_Update(void) { tpWindowData wd; @@ -973,16 +979,14 @@ WIN_Update(void) #if 0 -int -WIN_DiagramReady(void) +int WIN_DiagramReady(void) { return 0; } #endif -void -RemoveWindow(GRAPH *dgraph) +void RemoveWindow(GRAPH *dgraph) { tpWindowData wd; @@ -998,15 +1002,15 @@ static void WIN_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy) double lmin, lmax; if (graph->grid.gridtype == GRID_XLOG || - graph->grid.gridtype == GRID_LOGLOG) - { + graph->grid.gridtype == GRID_LOGLOG) { lmin = log10(graph->datawindow.xmin); lmax = log10(graph->datawindow.xmax); *fx = exp(((x - graph->viewportxoff) * - (lmax - lmin) / graph->viewport.width + lmin) * M_LN10); - } else { + (lmax - lmin) / graph->viewport.width + lmin) * M_LN10); + } + else { *fx = (x - graph->viewportxoff) * graph->aspectratiox + - graph->datawindow.xmin; + graph->datawindow.xmin; } if (graph->grid.gridtype == GRID_YLOG || @@ -1015,10 +1019,10 @@ static void WIN_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy) lmin = log10(graph->datawindow.ymin); lmax = log10(graph->datawindow.ymax); *fy = exp(((graph->absolute.height - y - graph->viewportyoff) * - (lmax - lmin) / graph->viewport.height + lmin) * M_LN10); + (lmax - lmin) / graph->viewport.height + lmin) * M_LN10); } else { *fy = ((graph->absolute.height - y) - graph->viewportyoff) * - graph->aspectratioy + graph->datawindow.ymin; + graph->aspectratioy + graph->datawindow.ymin; } } diff --git a/src/frontend/wdisp/winprint.c b/src/frontend/wdisp/winprint.c index 9a9d5ea9d..e81fff873 100644 --- a/src/frontend/wdisp/winprint.c +++ b/src/frontend/wdisp/winprint.c @@ -34,26 +34,26 @@ #include "winprint.h" /* function prototypes */ /* Typen */ -typedef struct { /* Extra Printdaten */ - int ColorIndex; /* Index auf die akt. Farbe */ - int LineIndex; /* Index auf den akt. Linientyp */ +typedef struct { /* Extra Printdaten */ + int ColorIndex; /* Index auf die akt. Farbe */ + int LineIndex; /* Index auf den akt. Linientyp */ } tPrintData; -typedef tPrintData * tpPrintData; /* Zeiger darauf */ +typedef tPrintData *tpPrintData; /* Zeiger darauf */ #define pPrintData(g) ((tpPrintData)(g->devdep)) /* externals */ -void WaitForIdle(void); /* Warte, bis keine Events da */ +void WaitForIdle(void); /* Warte, bis keine Events da */ /* lokale Variablen */ -static HFONT PlotFont = NULL; /* Font-Merker */ -static HFONT OldFont = NULL; -#define NumLines 7 /* Anzahl der LineStyles */ -static int LineTable[NumLines]; /* Speicher fuer die LineStyles */ -static HDC PrinterDC = NULL; /* Device Context */ -#define NumPrintColors 2 /* vordef. Farben */ -static COLORREF ColorTable[NumPrintColors];/* Speicher fuer die Farben */ -static int PrinterWidth = 1000; /* Breite des Papiers */ -static int PrinterHeight = 1000; /* Hoehe des Papiers */ +static HFONT PlotFont = NULL; /* Font-Merker */ +static HFONT OldFont = NULL; +#define NumLines 7 /* Anzahl der LineStyles */ +static int LineTable[NumLines]; /* Speicher fuer die LineStyles */ +static HDC PrinterDC = NULL; /* Device Context */ +#define NumPrintColors 2 /* vordef. Farben */ +static COLORREF ColorTable[NumPrintColors];/* Speicher fuer die Farben */ +static int PrinterWidth = 1000; /* Breite des Papiers */ +static int PrinterHeight = 1000; /* Hoehe des Papiers */ /****************************************************************************** Drucker-Initialisierung @@ -61,59 +61,63 @@ static int PrinterHeight = 1000; /* Hoehe des Papiers */ void WPRINT_PrintInit(HWND hwnd) { - /* Parameter-Block */ - PRINTDLG pd; + /* Parameter-Block */ + PRINTDLG pd; - /* Initialisieren */ - pd.lStructSize = sizeof(PRINTDLG); - pd.hwndOwner = hwnd; - pd.hDevMode = NULL; - pd.hDevNames = NULL; - pd.hDC = NULL; - pd.Flags = PD_PRINTSETUP; - pd.nFromPage = 1; - pd.nToPage = 1; - pd.nMinPage = 0; - pd.nMaxPage = 0; - pd.nCopies = 1; - pd.hInstance = NULL; - pd.lCustData = 0; - pd.lpfnPrintHook = NULL; - pd.lpfnSetupHook = NULL; - pd.lpPrintTemplateName = NULL; - pd.lpSetupTemplateName = NULL; - pd.hPrintTemplate = NULL; - pd.hSetupTemplate = NULL; + /* Initialisieren */ + pd.lStructSize = sizeof(PRINTDLG); + pd.hwndOwner = hwnd; + pd.hDevMode = NULL; + pd.hDevNames = NULL; + pd.hDC = NULL; + pd.Flags = PD_PRINTSETUP; + pd.nFromPage = 1; + pd.nToPage = 1; + pd.nMinPage = 0; + pd.nMaxPage = 0; + pd.nCopies = 1; + pd.hInstance = NULL; + pd.lCustData = 0; + pd.lpfnPrintHook = NULL; + pd.lpfnSetupHook = NULL; + pd.lpPrintTemplateName = NULL; + pd.lpSetupTemplateName = NULL; + pd.hPrintTemplate = NULL; + pd.hSetupTemplate = NULL; - /* Default-Drucker initialisieren */ - (void) PrintDlg( &pd); + /* Default-Drucker initialisieren */ + (void) PrintDlg(&pd); - /* Speicher freigeben */ - if( pd.hDevMode) GlobalFree( pd.hDevMode); - if( pd.hDevNames) GlobalFree( pd.hDevNames); + /* Speicher freigeben */ + if (pd.hDevMode) { + GlobalFree(pd.hDevMode); + } + if (pd.hDevNames) { + GlobalFree(pd.hDevNames); + } } /* Abort-Procedur zum Drucken */ -BOOL CALLBACK WPRINT_Abort( HDC hdc, int iError) +BOOL CALLBACK WPRINT_Abort(HDC hdc, int iError) { NG_IGNORE(hdc); NG_IGNORE(iError); /* Multitasking */ - WaitForIdle(); + WaitForIdle(); - /* Warten */ - return TRUE; + /* Warten */ + return TRUE; } /****************************************************************************** WPRINT_Init() stellt die Verbindung zur Grafik her. Dazu gehoert die Feststellung von - dispdev->numlinestyles - dispdev->numcolors - dispdev->width - dispdev->height + dispdev->numlinestyles + dispdev->numcolors + dispdev->width + dispdev->height WPRINT_Init() gibt 0 zurueck, falls kein Fehler auftrat. @@ -121,102 +125,108 @@ WPRINT_Init() gibt 0 zurueck, falls kein Fehler auftrat. int WPRINT_Init(void) { - int pWidth; - int pHeight; + int pWidth; + int pHeight; - /* Printer-DC holen */ - if (!PrinterDC) { + /* Printer-DC holen */ + if (!PrinterDC) { - /* Parameter-Block */ - PRINTDLG pd; + /* Parameter-Block */ + PRINTDLG pd; - /* Initialisieren */ - pd.lStructSize = sizeof(PRINTDLG); - pd.hwndOwner = NULL; - pd.hDevMode = NULL; - pd.hDevNames = NULL; - pd.hDC = NULL; - pd.Flags = PD_NOPAGENUMS | PD_NOSELECTION | PD_RETURNDC; - pd.nFromPage = 1; - pd.nToPage = 1; - pd.nMinPage = 0; - pd.nMaxPage = 0; - pd.nCopies = 1; - pd.hInstance = NULL; - pd.lCustData = 0; - pd.lpfnPrintHook = NULL; - pd.lpfnSetupHook = NULL; - pd.lpPrintTemplateName = NULL; - pd.lpSetupTemplateName = NULL; - pd.hPrintTemplate = NULL; - pd.hSetupTemplate = NULL; + /* Initialisieren */ + pd.lStructSize = sizeof(PRINTDLG); + pd.hwndOwner = NULL; + pd.hDevMode = NULL; + pd.hDevNames = NULL; + pd.hDC = NULL; + pd.Flags = PD_NOPAGENUMS | PD_NOSELECTION | PD_RETURNDC; + pd.nFromPage = 1; + pd.nToPage = 1; + pd.nMinPage = 0; + pd.nMaxPage = 0; + pd.nCopies = 1; + pd.hInstance = NULL; + pd.lCustData = 0; + pd.lpfnPrintHook = NULL; + pd.lpfnSetupHook = NULL; + pd.lpPrintTemplateName = NULL; + pd.lpSetupTemplateName = NULL; + pd.hPrintTemplate = NULL; + pd.hSetupTemplate = NULL; - /* Default-Drucker initialisieren */ - (void) PrintDlg( &pd); + /* Default-Drucker initialisieren */ + (void) PrintDlg(&pd); - /* Speicher freigeben */ - if( pd.hDevMode) GlobalFree( pd.hDevMode); - if( pd.hDevNames) GlobalFree( pd.hDevNames); + /* Speicher freigeben */ + if (pd.hDevMode) { + GlobalFree(pd.hDevMode); + } + if (pd.hDevNames) { + GlobalFree(pd.hDevNames); + } - /* DC holen */ - PrinterDC = pd.hDC; - if (!PrinterDC) return 1; + /* DC holen */ + PrinterDC = pd.hDC; + if (!PrinterDC) return 1; - /* Abmasze bestimmen */ - PrinterWidth = GetDeviceCaps( PrinterDC, HORZRES); - PrinterHeight = GetDeviceCaps( PrinterDC, VERTRES); - pWidth = GetDeviceCaps( PrinterDC, HORZSIZE); - pHeight = GetDeviceCaps( PrinterDC, VERTSIZE); + /* Abmasze bestimmen */ + PrinterWidth = GetDeviceCaps(PrinterDC, HORZRES); + PrinterHeight = GetDeviceCaps(PrinterDC, VERTRES); + pWidth = GetDeviceCaps(PrinterDC, HORZSIZE); + pHeight = GetDeviceCaps(PrinterDC, VERTSIZE); - /* Mapping Mode setzen (fuer Kreise) */ - if ( pWidth > pHeight) - /* Querformat */ - PrinterWidth = (PrinterHeight * pWidth) / pHeight; - else - /* Hochformat */ - PrinterHeight = (PrinterWidth * pHeight) / pWidth; + /* Mapping Mode setzen (fuer Kreise) */ + if (pWidth > pHeight) { + /* Querformat */ + PrinterWidth = (PrinterHeight * pWidth) / pHeight; + } + else { + /* Hochformat */ + PrinterHeight = (PrinterWidth * pHeight) / pWidth; + } - SetMapMode( PrinterDC, MM_ISOTROPIC); - SetWindowExtEx( PrinterDC, PrinterWidth, PrinterHeight, NULL); - SetViewportExtEx( PrinterDC, PrinterWidth, PrinterHeight, NULL); + SetMapMode(PrinterDC, MM_ISOTROPIC); + SetWindowExtEx(PrinterDC, PrinterWidth, PrinterHeight, NULL); + SetViewportExtEx(PrinterDC, PrinterWidth, PrinterHeight, NULL); - /* nicht hoeher als breit zeichnen */ - if (pWidth < pHeight) { - /* Papier im Hochformat */ - PrinterHeight = PrinterWidth; - } + /* nicht hoeher als breit zeichnen */ + if (pWidth < pHeight) { + /* Papier im Hochformat */ + PrinterHeight = PrinterWidth; + } - /* Initialisierungen des Display-Descriptors */ - dispdev->width = PrinterWidth; - dispdev->height = PrinterHeight; - dispdev->numlinestyles = NumLines; - dispdev->numcolors = NumPrintColors; + /* Initialisierungen des Display-Descriptors */ + dispdev->width = PrinterWidth; + dispdev->height = PrinterHeight; + dispdev->numlinestyles = NumLines; + dispdev->numcolors = NumPrintColors; - /* Farben initialisieren */ - ColorTable[0] = RGB(255,255,255); /* Weisz */ - ColorTable[1] = RGB( 0, 0, 0); /* Schwarz */ + /* Farben initialisieren */ + ColorTable[0] = RGB(255,255,255); /* Weisz */ + ColorTable[1] = RGB(0, 0, 0); /* Schwarz */ - /* LineStyles initialisieren */ - LineTable[0] = PS_SOLID; - LineTable[1] = PS_DOT; /* Gitter */ - LineTable[2] = PS_SOLID; /* Erste Linie */ - LineTable[3] = PS_DOT; /* Zweite Linie */ - LineTable[4] = PS_DASH; /* usw */ - LineTable[5] = PS_DASHDOT; - LineTable[6] = PS_DASHDOTDOT; + /* LineStyles initialisieren */ + LineTable[0] = PS_SOLID; + LineTable[1] = PS_DOT; /* Gitter */ + LineTable[2] = PS_SOLID; /* Erste Linie */ + LineTable[3] = PS_DOT; /* Zweite Linie */ + LineTable[4] = PS_DASH; /* usw */ + LineTable[5] = PS_DASHDOT; + LineTable[6] = PS_DASHDOTDOT; - /* Font */ - if (!PlotFont) { - PlotFont = CreateFont( 0,0,0,0, FW_DONTCARE, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, - PROOF_QUALITY, FIXED_PITCH, NULL); - } + /* Font */ + if (!PlotFont) { + PlotFont = CreateFont(0,0,0,0, FW_DONTCARE, FALSE, FALSE, FALSE, + ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, + PROOF_QUALITY, FIXED_PITCH, NULL); + } - /* Abort-Prozedur setzen */ - SetAbortProc( PrinterDC, WPRINT_Abort); - } - /* fertig */ - return (0); + /* Abort-Prozedur setzen */ + SetAbortProc(PrinterDC, WPRINT_Abort); + } + /* fertig */ + return 0; } @@ -227,250 +237,275 @@ int WPRINT_Init(void) ******************************************************************************/ -int WPRINT_NewViewport( GRAPH * graph) +int WPRINT_NewViewport(GRAPH * graph) { - TEXTMETRIC tm; - tpPrintData pd; - DOCINFO di; + TEXTMETRIC tm; + tpPrintData pd; + DOCINFO di; - /* Parameter testen */ - if (!graph) return 1; + /* Parameter testen */ + if (!graph) { + return 1; + } - /* Initialisiere, falls noch nicht geschehen */ - if (WPRINT_Init() != 0) { - externalerror("Can't initialize Printer."); - return(1); - } + /* Initialisiere, falls noch nicht geschehen */ + if (WPRINT_Init() != 0) { + externalerror("Can't initialize Printer."); + return(1); + } - /* Device dep. Info allocieren */ - pd = calloc(1, sizeof(tPrintData)); - if (!pd) return 1; - graph->devdep = pd; + /* Device dep. Info allocieren */ + pd = calloc(1, sizeof(tPrintData)); + if (!pd) return 1; + graph->devdep = pd; + graph->n_byte_devdep = sizeof(tPrintData); - /* Setze den Color-Index */ - pd->ColorIndex = 0; + /* Setze den Color-Index */ + pd->ColorIndex = 0; - /* Font setzen */ - OldFont = SelectObject( PrinterDC, PlotFont); + /* Font setzen */ + OldFont = SelectObject(PrinterDC, PlotFont); - /* Font-Parameter abfragen */ - if (GetTextMetrics( PrinterDC, &tm)) { - graph->fontheight = tm.tmHeight; - graph->fontwidth = tm.tmAveCharWidth; - } + /* Font-Parameter abfragen */ + if (GetTextMetrics(PrinterDC, &tm)) { + graph->fontheight = tm.tmHeight; + graph->fontwidth = tm.tmAveCharWidth; + } - /* Setze den Linien-Index */ - pd->LineIndex = 0; + /* Setze den Linien-Index */ + pd->LineIndex = 0; - /* Viewport-Parameter setzen */ - graph->viewport.height = PrinterHeight; - graph->viewport.width = PrinterWidth; + /* Viewport-Parameter setzen */ + graph->viewport.height = PrinterHeight; + graph->viewport.width = PrinterWidth; - /* Absolut-Parameter setzen */ - graph->absolute.xpos = 0; - graph->absolute.ypos = 0; - graph->absolute.width = PrinterWidth; - graph->absolute.height = PrinterHeight; + /* Absolut-Parameter setzen */ + graph->absolute.xpos = 0; + graph->absolute.ypos = 0; + graph->absolute.width = PrinterWidth; + graph->absolute.height = PrinterHeight; - /* Druckauftrag anmelden */ - di.cbSize = sizeof( DOCINFO); - di.lpszDocName = graph->plotname; - di.lpszOutput = NULL; - if (StartDoc( PrinterDC, &di) <= 0) return 1; - if (StartPage( PrinterDC) <= 0) return 1; + /* Druckauftrag anmelden */ + di.cbSize = sizeof(DOCINFO); + di.lpszDocName = graph->plotname; + di.lpszOutput = NULL; + if (StartDoc(PrinterDC, &di) <= 0) { + return 1; + } + if (StartPage(PrinterDC) <= 0) { + return 1; + } - /* titel drucken */ - if (graph->plotname) { - UINT align; - align = GetTextAlign( PrinterDC); - SetTextAlign( PrinterDC, TA_RIGHT | TA_TOP | TA_NOUPDATECP); - TextOut( PrinterDC, PrinterWidth-graph->fontwidth, 1, graph->plotname, - (int)strlen(graph->plotname)); - SetTextAlign( PrinterDC, align); - } + /* titel drucken */ + if (graph->plotname) { + UINT align; + align = GetTextAlign(PrinterDC); + SetTextAlign(PrinterDC, TA_RIGHT | TA_TOP | TA_NOUPDATECP); + TextOut(PrinterDC, PrinterWidth-graph->fontwidth, 1, graph->plotname, + (int) strlen(graph->plotname)); + SetTextAlign(PrinterDC, align); + } - /* fertig */ - return(0); + /* fertig */ + return 0; } int WPRINT_Close(void) { - if (PrinterDC) { - EndPage( PrinterDC); - EndDoc( PrinterDC); - if (OldFont) { - SelectObject( PrinterDC, OldFont); - OldFont = NULL; - } - DeleteObject( PlotFont); - DeleteDC( PrinterDC); - PrinterDC = NULL; - } - return (0); + if (PrinterDC) { + EndPage(PrinterDC); + EndDoc(PrinterDC); + if (OldFont) { + SelectObject(PrinterDC, OldFont); + OldFont = NULL; + } + DeleteObject(PlotFont); + DeleteDC(PrinterDC); + PrinterDC = NULL; + } + return 0; } int WPRINT_Clear(void) { - return 0; + return 0; } int WPRINT_DrawLine(int x1, int y1, int x2, int y2) { - tpPrintData pd; - HPEN OldPen; - HPEN NewPen; - int ColIndex; + tpPrintData pd; + HPEN OldPen; + HPEN NewPen; + int ColIndex; - if (!currentgraph) return 0; - pd = pPrintData(currentgraph); - if (!pd) return 0; + if (!currentgraph) return 0; + pd = pPrintData(currentgraph); + if (!pd) return 0; - /* Farben/Dicke */ - ColIndex = pd->ColorIndex; - if (ColIndex > 1) - ColIndex = 1; + /* Farben/Dicke */ + ColIndex = pd->ColorIndex; + if (ColIndex > 1) + ColIndex = 1; - MoveToEx(PrinterDC, x1, PrinterHeight - y1, NULL); - NewPen = CreatePen( LineTable[pd->LineIndex], 0, ColorTable[ColIndex] ); - OldPen = SelectObject(PrinterDC, NewPen); - LineTo(PrinterDC, x2, PrinterHeight - y2); - OldPen = SelectObject(PrinterDC, OldPen); - DeleteObject( NewPen); - return (0); + MoveToEx(PrinterDC, x1, PrinterHeight - y1, NULL); + NewPen = CreatePen(LineTable[pd->LineIndex], 0, ColorTable[ColIndex] ); + OldPen = SelectObject(PrinterDC, NewPen); + LineTo(PrinterDC, x2, PrinterHeight - y2); + OldPen = SelectObject(PrinterDC, OldPen); + DeleteObject(NewPen); + return 0; } int WPRINT_Arc(int x0, int y0, int radius, double theta, double delta_theta) - /* - * Notes: - * Draws an arc of and center at (x0,y0) beginning at - * angle theta (in rad) and ending at theta + delta_theta - */ + /* + * Notes: + * Draws an arc of and center at (x0,y0) beginning at + * angle theta (in rad) and ending at theta + delta_theta + */ { - tpPrintData pd; - HPEN OldPen; - HPEN NewPen; - int left, right, top, bottom; - int xs, ys, xe, ye; - int yb; - int direction; - int ColIndex; - double r; - double dx0; - double dy0; + tpPrintData pd; + HPEN OldPen; + HPEN NewPen; + int left, right, top, bottom; + int xs, ys, xe, ye; + int yb; + int direction; + int ColIndex; + double r; + double dx0; + double dy0; - if (!currentgraph) return 0; - pd = pPrintData(currentgraph); - if (!pd) return 0; + if (!currentgraph) { + return 0; + } + pd = pPrintData(currentgraph); + if (!pd) { + return 0; + } - ColIndex = pd->ColorIndex; - if (ColIndex > 1) - ColIndex = 1; + ColIndex = pd->ColorIndex; + if (ColIndex > 1) { + ColIndex = 1; + } - direction = AD_COUNTERCLOCKWISE; - if (delta_theta < 0) { - theta = theta + delta_theta; - delta_theta = - delta_theta; - direction = AD_CLOCKWISE; - } - SetArcDirection( PrinterDC, direction); + direction = AD_COUNTERCLOCKWISE; + if (delta_theta < 0) { + theta = theta + delta_theta; + delta_theta = - delta_theta; + direction = AD_CLOCKWISE; + } + SetArcDirection(PrinterDC, direction); - /* Geometrische Vorueberlegungen */ - yb = PrinterHeight; - left = x0 - radius; - right = x0 + radius; - top = y0 + radius; - bottom = y0 - radius; + /* Geometrische Vorueberlegungen */ + yb = PrinterHeight; + left = x0 - radius; + right = x0 + radius; + top = y0 + radius; + bottom = y0 - radius; - r = radius; - dx0 = x0; - dy0 = y0; - xs = (int)(dx0 + (r * cos(theta))); - ys = (int)(dy0 + (r * sin(theta))); - xe = (int)(dx0 + (r * cos(theta + delta_theta))); - ye = (int)(dy0 + (r * sin(theta + delta_theta))); + r = radius; + dx0 = x0; + dy0 = y0; + xs = (int) (dx0 + (r * cos(theta))); + ys = (int) (dy0 + (r * sin(theta))); + xe = (int) (dx0 + (r * cos(theta + delta_theta))); + ye = (int) (dy0 + (r * sin(theta + delta_theta))); - /* Zeichnen */ - NewPen = CreatePen( LineTable[pd->LineIndex], 0, ColorTable[ColIndex] ); - OldPen = SelectObject(PrinterDC, NewPen); - Arc( PrinterDC, left, yb-top, right, yb-bottom, xs, yb-ys, xe, yb-ye); - OldPen = SelectObject(PrinterDC, OldPen); - DeleteObject( NewPen); + /* Zeichnen */ + NewPen = CreatePen(LineTable[pd->LineIndex], 0, ColorTable[ColIndex] ); + OldPen = SelectObject(PrinterDC, NewPen); + Arc(PrinterDC, left, yb-top, right, yb-bottom, xs, yb-ys, xe, yb-ye); + OldPen = SelectObject(PrinterDC, OldPen); + DeleteObject(NewPen); - return 0; + return 0; } -int WPRINT_Text( char * text, int x, int y, int degrees) +int WPRINT_Text(char * text, int x, int y, int degrees) { - tpPrintData pd; - int ColIndex; + tpPrintData pd; + int ColIndex; NG_IGNORE(degrees); - if (!currentgraph) return 0; - pd = pPrintData(currentgraph); - if (!pd) return 0; + if (!currentgraph) { + return 0; + } + pd = pPrintData(currentgraph); + if (!pd) { + return 0; + } - ColIndex = pd->ColorIndex; - if (ColIndex > 1) { - ColIndex = 1; - } + ColIndex = pd->ColorIndex; + if (ColIndex > 1) { + ColIndex = 1; + } - SetTextColor( PrinterDC, ColorTable[ColIndex]); - TextOut( PrinterDC, x, PrinterHeight - y - currentgraph->fontheight, text, (int) strlen(text)); - return (0); + SetTextColor(PrinterDC, ColorTable[ColIndex]); + TextOut(PrinterDC, x, PrinterHeight - y - currentgraph->fontheight, + text, (int) strlen(text)); + return 0; } int WPRINT_DefineColor(int colorid, double red, double green, double blue) { - /* nix */ + /* nix */ NG_IGNORE(colorid); NG_IGNORE(red); NG_IGNORE(green); NG_IGNORE(blue); - return (0); + return 0; } int WPRINT_DefineLinestyle(int num, int mask) { - /* nix */ + /* nix */ NG_IGNORE(num); NG_IGNORE(mask); - return (0); + return 0; } int WPRINT_SetLinestyle(int style) { - tpPrintData pd; - if (!currentgraph) return 0; - pd = pPrintData(currentgraph); - if (!pd) return 0; + tpPrintData pd; + if (!currentgraph) { + return 0; + } + pd = pPrintData(currentgraph); + if (!pd) { + return 0; + } - pd->LineIndex = style % NumLines; - return (0); + pd->LineIndex = style % NumLines; + return 0; } -int WPRINT_SetColor( int color) +int WPRINT_SetColor(int color) { - tpPrintData pd; - if (!currentgraph) return 0; - pd = pPrintData(currentgraph); - if (!pd) return 0; + tpPrintData pd; + if (!currentgraph) { + return 0; + } + pd = pPrintData(currentgraph); + if (!pd) { + return 0; + } - pd->ColorIndex = color; - return (0); + pd->ColorIndex = color; + return 0; } int WPRINT_Update(void) { - return (0); + return 0; } int WPRINT_DiagramReady(void) { - return 0; + return 0; } #endif /* HAS_WINGUI */