Annotation of OpenXM_contrib/gnuplot/term/win.trm, Revision 1.1.1.1
1.1 maekawa 1: /*
2: * $Id: $
3: */
4:
5: /* GNUPLOT - win.trm */
6:
7: /*[
8: * Copyright 1992 - 1993, 1998
9: *
10: * Permission to use, copy, and distribute this software and its
11: * documentation for any purpose with or without fee is hereby granted,
12: * provided that the above copyright notice appear in all copies and
13: * that both that copyright notice and this permission notice appear
14: * in supporting documentation.
15: *
16: * Permission to modify the software is granted, but not the right to
17: * distribute the complete modified source code. Modifications are to
18: * be distributed as patches to the released version. Permission to
19: * distribute binaries produced by compiling modified sources is granted,
20: * provided you
21: * 1. distribute the corresponding source modifications from the
22: * released version in the form of a patch file along with the binaries,
23: * 2. add special version identification to distinguish your version
24: * in addition to the base release version number,
25: * 3. provide your name and address as the primary contact for the
26: * support of your modified version, and
27: * 4. retain our contact information in regard to use of the base
28: * software.
29: * Permission to distribute the released version of the source code along
30: * with corresponding source modifications in the form of a patch file is
31: * granted with same provisions 2 through 4 for binary distributions.
32: *
33: * This software is provided "as is" without express or implied warranty
34: * to the extent permitted by applicable law.
35: ]*/
36:
37: /*
38: *
39: * AUTHORS
40: *
41: * Gnuplot for Windows:
42: * Maurice Castro, Russell Lang
43: *
44: * There is a mailing list for gnuplot users. Note, however, that the
45: * newsgroup
46: * comp.graphics.apps.gnuplot
47: * is identical to the mailing list (they
48: * both carry the same set of messages). We prefer that you read the
49: * messages through that newsgroup, to subscribing to the mailing list.
50: * (If you can read that newsgroup, and are already on the mailing list,
51: * please send a message to majordomo@dartmouth.edu, asking to be
52: * removed from the mailing list.)
53: *
54: * The address for mailing to list members is
55: * info-gnuplot@dartmouth.edu
56: * and for mailing administrative requests is
57: * majordomo@dartmouth.edu
58: * The mailing list for bug reports is
59: * bug-gnuplot@dartmouth.edu
60: * The list of those interested in beta-test versions is
61: * info-gnuplot-beta@dartmouth.edu
62: */
63:
64:
65: /* This file implements the terminal and printer display for gnuplot */
66: /* under Microsoft Windows. The code currently compiles only with the */
67: /* Borland C++ 3.1 compiler. */
68: /* */
69: /* The modifications to allow Gnuplot to run under Windows were made */
70: /* by Maurice Castro (maurice@bruce.cs.monash.edu.au) */
71: /* and Russell Lang (rjl@monu1.cc.monash.edu.au) 19 Nov 1992 */
72: /* */
73:
74: /* Edit this file with tabstop=4 (vi :se ts=4) */
75:
76: /*
77: * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
78: */
79:
80: #include "driver.h"
81:
82: #ifdef TERM_REGISTER
83: register_term(windows)
84: #endif
85:
86: #ifdef TERM_PROTO
87: TERM_PUBLIC void WIN_options __PROTO((void));
88: TERM_PUBLIC int WIN_scale __PROTO((void));
89: TERM_PUBLIC void WIN_init __PROTO((void));
90: TERM_PUBLIC void WIN_reset __PROTO((void));
91: TERM_PUBLIC void WIN_text __PROTO((void));
92: TERM_PUBLIC void WIN_graphics __PROTO((void));
93: TERM_PUBLIC void WIN_move __PROTO((unsigned int x, unsigned int y));
94: TERM_PUBLIC void WIN_vector __PROTO((unsigned int x, unsigned int y));
95: TERM_PUBLIC void WIN_linetype __PROTO((int lt));
96: TERM_PUBLIC void WIN_put_text __PROTO((unsigned int x, unsigned int y, char *str));
97: TERM_PUBLIC int WIN_justify_text __PROTO((enum JUSTIFY mode));
98: TERM_PUBLIC int WIN_text_angle __PROTO((int ang));
99: TERM_PUBLIC void WIN_point __PROTO((unsigned int x, unsigned int y, int number));
100: TERM_PUBLIC void WIN_resume __PROTO((void));
101: TERM_PUBLIC void WIN_set_pointsize __PROTO((double));
102:
103:
104: /* Initialization values - Guess Now Scale later */
105: #define WIN_XMAX (24000)
106: #define WIN_YMAX (18000)
107: #define WIN_HCHAR (WIN_XMAX/75)
108: #define WIN_VCHAR (WIN_YMAX/25)
109: #define WIN_HTIC (WIN_XMAX/160)
110: #define WIN_VTIC WIN_HTIC
111: #endif /* TERM_PROTO */
112:
113: #ifndef TERM_PROTO_ONLY
114: #ifdef TERM_BODY
115:
116: #include <windows.h>
117: #include "../win/wgnuplib.h"
118:
119: #ifdef __MSC__
120: #include <io.h> /* for mktemp() */
121: #endif
122:
123: extern GW graphwin;
124:
125: #define WIN_POINT_TYPES 12
126:
127: /* Interface routines - create list of actions for Windows */
128:
129: TERM_PUBLIC void WIN_options()
130: {
131: if (!END_OF_COMMAND) {
132: if (almost_equals(c_token, "d$efault")) {
133: graphwin.color = TRUE;
134: strcpy(graphwin.fontname, WINFONT);
135: graphwin.fontsize = WINFONTSIZE;
136: c_token++;
137: }
138: }
139: if (!END_OF_COMMAND) {
140: if (almost_equals(c_token, "m$onochrome")) {
141: graphwin.color = FALSE;
142: c_token++;
143: } else if (almost_equals(c_token, "c$olor")
144: || almost_equals(c_token, "c$olour")) {
145: graphwin.color = TRUE;
146: c_token++;
147: }
148: }
149: if (!END_OF_COMMAND && isstring(c_token)) {
150: quote_str(graphwin.fontname, c_token, MAX_ID_LEN);
151: c_token++;
152: }
153: if (!END_OF_COMMAND) {
154: /* We have font size specified */
155: struct value a;
156: graphwin.fontsize = (int) real(const_express(&a));
157: }
158: if (graphwin.fontname[0] == '\0')
159: sprintf(term_options, "%s", graphwin.color ? "color" : "monochrome");
160: else
161: sprintf(term_options, "%s \"%s\" %d", graphwin.color ? "color" : "monochrome",
162: graphwin.fontname, graphwin.fontsize);
163: if (IsWindow(graphwin.hWndGraph) && IsIconic(graphwin.hWndGraph)) {
164: ShowWindow(graphwin.hWndGraph, SW_SHOWNORMAL);
165: }
166: GraphRedraw(&graphwin);
167: }
168:
169: /* We don't actually do scaling, but we need to fix up the text size
170: * if the user has resized the window */
171: int WIN_scale()
172: {
173: term->h_char = graphwin.hchar;
174: term->v_char = graphwin.vchar;
175: term->h_tic = graphwin.htic;
176: term->v_tic = graphwin.vtic;
177: sprintf(term_options, "%s \"%s\" %d",
178: graphwin.color ? "color" : "monochrome",
179: graphwin.fontname, graphwin.fontsize);
180: return FALSE; /* can't be done */
181: }
182:
183: TERM_PUBLIC void WIN_init()
184: {
185: if (!graphwin.hWndGraph) {
186: graphwin.xmax = WIN_XMAX;
187: graphwin.ymax = WIN_YMAX;
188: graphwin.htic = WIN_HTIC;
189: graphwin.vtic = WIN_VTIC;
190: GraphInit(&graphwin);
191: #ifdef WIN32
192: SetClassLong(graphwin.hWndGraph, GCL_HICON, (LONG) LoadIcon(graphwin.hInstance, "GRPICON"));
193: #else
194: SetClassWord(graphwin.hWndGraph, GCW_HICON, LoadIcon(graphwin.hInstance, "GRPICON"));
195: #endif
196: graphwin.resized = FALSE;
197: }
198: }
199:
200:
201: TERM_PUBLIC void WIN_reset()
202: {
203: }
204:
205: TERM_PUBLIC void WIN_text()
206: {
207: GraphEnd(&graphwin);
208: }
209:
210: TERM_PUBLIC void WIN_graphics()
211: {
212: GraphStart(&graphwin, pointsize);
213: }
214:
215: TERM_PUBLIC void WIN_move(x, y)
216: unsigned int x, y;
217: {
218: GraphOp(&graphwin, W_move, x, y, NULL);
219: }
220:
221: TERM_PUBLIC void WIN_vector(x, y)
222: unsigned int x, y;
223: {
224: GraphOp(&graphwin, W_vect, x, y, NULL);
225: }
226:
227: TERM_PUBLIC void WIN_linetype(lt)
228: int lt;
229: {
230: GraphOp(&graphwin, W_line_type, lt, 0, NULL);
231: }
232:
233: TERM_PUBLIC void WIN_put_text(x, y, str)
234: unsigned int x, y;
235: char *str;
236: {
237: GraphOp(&graphwin, W_put_text, x, y, str);
238: }
239:
240: TERM_PUBLIC int WIN_justify_text(mode)
241: enum JUSTIFY mode;
242: {
243: GraphOp(&graphwin, W_justify, mode, 0, NULL);
244: return (TRUE);
245: }
246:
247: TERM_PUBLIC int WIN_text_angle(ang)
248: int ang;
249: {
250: if (graphwin.rotate)
251: GraphOp(&graphwin, W_text_angle, ang, 0, NULL);
252: return graphwin.rotate;
253: }
254:
255: TERM_PUBLIC void WIN_point(x, y, number)
256: unsigned int x, y;
257: int number;
258: {
259: /* draw point shapes later to save memory */
260: /* size of point symbols */
261: graphwin.htic = pointsize * term->h_tic / 2;
262: graphwin.vtic = pointsize * term->v_tic / 2;
263: if (number >= 0)
264: number %= WIN_POINT_TYPES;
265: number += 1;
266: GraphOp(&graphwin, W_dot + number, x, y, NULL);
267: }
268:
269: TERM_PUBLIC void WIN_resume(void)
270: {
271: GraphResume(&graphwin);
272: }
273:
274: TERM_PUBLIC void WIN_set_pointsize(s)
275: double s;
276: {
277: /* Save new pointsize as string */
278: char scale[30];
279: sprintf(scale, "%.15g", s);
280: #if 1
281: /* HBB 980309: it seems passing it as a string is a bad idea
282: * in Win16: it means the wgnuplot.dll has to parse the string
283: * via sscanf(), leading to crash (by stack overflow?). Alternative:
284: * pass it as a scaled-up integer. For the sake of compatibility,
285: * pass the string as well. */
286: GraphOp(&graphwin, W_pointsize, (int) 100 * s, 0, scale);
287: #else
288: GraphOp(&graphwin, W_pointsize, 0, 0, scale);
289: #endif
290: }
291:
292: #endif /* TERM_BODY */
293:
294: #ifdef TERM_TABLE
295:
296: TERM_TABLE_START(win_driver)
297: "windows", "Microsoft Windows",
298: WIN_XMAX, WIN_YMAX, WIN_VCHAR, WIN_HCHAR,
299: WIN_VTIC, WIN_HTIC, WIN_options, WIN_init, WIN_reset,
300: WIN_text, null_scale, WIN_graphics, WIN_move, WIN_vector,
301: WIN_linetype, WIN_put_text, WIN_text_angle,
302: WIN_justify_text, WIN_point, do_arrow, set_font_null,
303: WIN_set_pointsize, TERM_CAN_MULTIPLOT,
304: WIN_text /* suspend */ , WIN_resume, 0 /*boxfill */
305: TERM_TABLE_END(win_driver)
306:
307: #undef LAST_TERM
308: #define LAST_TERM win_driver
309:
310: #endif /* TERM_TABLE */
311: #endif /* TERM_PROTO_ONLY */
312:
313: #ifdef TERM_HELP
314: START_HELP(windows)
315: "1 windows",
316: "?commands set terminal windows",
317: "?set terminal windows",
318: "?set term windows",
319: "?terminal windows",
320: "?term windows",
321: "?windows",
322: " Three options may be set in the `windows` terminal driver.",
323: "",
324: " Syntax:",
325: " set terminal windows {<color>} {\"<fontname>\"} {<fontsize>}",
326: "",
327: " where `<color>` is either `color` or `monochrome`, `\"<fontname>\"` is the",
328: " name of a valid Windows font, and `<fontsize>` is the size of the font in",
329: " points.",
330: "",
331: " Other options may be set with the graph-menu, the initialization file,",
332: " and `set linestyle`.",
333: /* Does this really belong here? If not, someone move it where it does. */
334: "",
335: " The Windows version normally terminates immediately as soon as the end of",
336: " any files given as command line arguments is reached (i.e. in non-interactive",
337: " mode). It will also not show the text-window at all, in this mode, only",
338: " the plot. By giving the optional argument",
339: " `/noend` or `-noend`, you can disable this behaviour.",
340: "2 graph-menu",
341: "?commands set terminal windows graph-menu",
342: "?set terminal windows graph-menu",
343: "?set term windows graph-menu",
344: "?windows graph-menu",
345: "?graph-menu",
346: " The `gnuplot graph` window has the following options on a pop-up menu",
347: " accessed by pressing the right mouse button or selecting `Options` from the",
348: " system menu:",
349: "",
350: " `Bring to Top` when checked brings the graph window to the top after every",
351: " plot.",
352: "",
353: " `Color` when checked enables color linestyles. When unchecked it forces",
354: " monochrome linestyles.",
355: "",
356: " `Copy to Clipboard` copies a bitmap and a Metafile picture.",
357: "",
358: " `Background...` sets the window background color.",
359: "",
360: " `Choose Font...` selects the font used in the graphics window.",
361: "",
362: " `Line Styles...` allows customization of the line colors and styles.",
363: "",
364: " `Print...` prints the graphics windows using a Windows printer driver and",
365: " allows selection of the printer and scaling of the output. The output",
366: " produced by `Print` is not as good as that from `gnuplot`'s own printer",
367: " drivers.",
368: "",
369: " `Update wgnuplot.ini` saves the current window locations, window sizes, text",
370: " window font, text window font size, graph window font, graph window font",
371: " size, background color and linestyles to the initialization file",
372: " `WGNUPLOT.INI`.",
373: "2 printing",
374: "?commands set terminal windows printing",
375: "?set terminal windows printing",
376: "?set term windows printing",
377: "?windows printing",
378: "?printing",
379: " In order of preference, graphs may be be printed in the following ways.",
380: "",
381: " `1.` Use the `gnuplot` command `set terminal` to select a printer and `set",
382: " output` to redirect output to a file.",
383: "",
384: " `2.` Select the `Print...` command from the `gnuplot graph` window. An extra",
385: " command `screendump` does this from the text window.",
386: "",
387: " `3.` If `set output \"PRN\"` is used, output will go to a temporary file. When",
388: " you exit from `gnuplot` or when you change the output with another `set",
389: " output` command, a dialog box will appear for you to select a printer port.",
390: " If you choose OK, the output will be printed on the selected port, passing",
391: " unmodified through the print manager. It is possible to accidentally (or",
392: " deliberately) send printer output meant for one printer to an incompatible",
393: " printer.",
394: "2 text-menu",
395: "?commands set terminal windows text-menu",
396: "?set terminal windows text-menu",
397: "?set term windows text-menu",
398: "?windows text-menu",
399: "?text-menu",
400: " The `gnuplot text` window has the following options on a pop-up menu accessed",
401: " by pressing the right mouse button or selecting `Options` from the system",
402: " menu:",
403: "",
404: " `Copy to Clipboard` copies marked text to the clipboard.",
405: "",
406: " `Paste` copies text from the clipboard as if typed by the user.",
407: "",
408: " `Choose Font...` selects the font used in the text window.",
409: "",
410: " `System Colors` when selected makes the text window honor the System Colors",
411: " set using the Control Panel. When unselected, text is black or blue on a",
412: " white background.",
413: "",
414: " `Update wgnuplot.ini` saves the current text window location, text window",
415: " size, text window font and text window font size to the initialisation file",
416: " `WGNUPLOT.INI`.",
417: "",
418: " `MENU BAR`",
419: "",
420: " If the menu file `WGNUPLOT.MNU` is found in the same directory as",
421: " WGNUPLOT.EXE, then the menu specified in `WGNUPLOT.MNU` will be loaded.",
422: " Menu commands:",
423: "",
424: " [Menu] starts a new menu with the name on the following line.",
425: "",
426: " [EndMenu] ends the current menu.",
427: "",
428: " [--] inserts a horizontal menu separator.",
429: "",
430: " [|] inserts a vertical menu separator.",
431: "",
432: " [Button] puts the next macro on a push button instead of a menu.",
433: "",
434: " Macros take two lines with the macro name (menu entry) on the first line and",
435: " the macro on the second line. Leading spaces are ignored. Macro commands:",
436: "",
437: " [INPUT] --- Input string with prompt terminated by [EOS] or {ENTER}",
438: "",
439: " [EOS] --- End Of String terminator. Generates no output.",
440: "",
441: " [OPEN] --- Get name of file to open from list box, with title of list box",
442: " terminated by [EOS], followed by default filename terminated by [EOS] or",
443: " {ENTER}. This uses COMMDLG.DLL from Windows 3.1.",
444: "",
445: " [SAVE] --- Get name of file to save. Similar to [OPEN]",
446: "",
447: " Macro character substitutions:",
448: "",
449: " {ENTER} --- Carriage Return '\\r'",
450: "",
451: " {TAB} --- Tab '\\011'",
452: "",
453: " {ESC} --- Escape '\\033'",
454: "",
455: " {^A} --- '\\001'",
456: "",
457: " ...",
458: "",
459: " {^_} --- '\\031'",
460: "",
461: " Macros are limited to 256 characters after expansion.",
462: "2 wgnuplot.ini",
463: "?commands set terminal windows wgnuplot.ini",
464: "?set terminal windows wgnuplot.ini",
465: "?set term windows wgnuplot.ini",
466: "?windows wgnuplot.ini",
467: "?wgnuplot.ini",
468: " Windows `gnuplot` will read some of its options from the `[WGNUPLOT]` section",
469: " of `WGNUPLOT.INI` in the Windows directory. A sample `WGNUPLOT.INI` file:",
470: "",
471: " [WGNUPLOT]",
472: " TextOrigin=0 0",
473: " TextSize=640 150",
474: " TextFont=Terminal,9",
475: " GraphOrigin=0 150",
476: " GraphSize=640 330",
477: " GraphFont=Arial,10",
478: " GraphColor=1",
479: " GraphToTop=1",
480: " GraphBackground=255 255 255",
481: " Border=0 0 0 0 0",
482: " Axis=192 192 192 2 2",
483: " Line1=0 0 255 0 0",
484: " Line2=0 255 0 0 1",
485: " Line3=255 0 0 0 2",
486: " Line4=255 0 255 0 3",
487: " Line5=0 0 128 0 4",
488: "",
489: " The `GraphFont` entry specifies the font name and size in points. The five",
490: " numbers given in the `Border`, `Axis` and `Line` entries are the `Red`",
491: " intensity (0--255), `Green` intensity, `Blue` intensity, `Color Linestyle`",
492: " and `Mono Linestyle`. `Linestyles` are 0=SOLID, 1=DASH, 2=DOT, 3=DASHDOT,",
493: " 4=DASHDOTDOT. In the sample `WGNUPLOT.INI` file above, Line 2 is a green",
494: " solid line in color mode, or a dashed line in monochrome mode. The default",
495: " line width is 1 pixel. If `Linestyle` is negative, it specifies the width of",
496: " a SOLID line in pixels. Line1 and any linestyle used with the `points` style",
497: " must be SOLID with unit width.",
498: "2 windows3.0",
499: "?commands set terminal windows windows3.0",
500: "?set terminal windows windows3.0",
501: "?set term windows windows3.0",
502: "?windows windows3.0",
503: "?windows3.0",
504: " Windows 3.1 is preferred, but WGNUPLOT will run under Windows 3.0 with the",
505: " following restrictions:",
506: " `1.` COMMDLG.DLL and SHELL.DLL (available with Windows 3.1 or Borland C++",
507: " 3.1) must be in the windows directory.",
508: "",
509: " `2.` WGNUPLOT.HLP produced by Borland C++ 3.1 is in Windows 3.1 format.",
510: " You need to use the WINHELP.EXE supplied with Borland C++ 3.1.",
511: "",
512: " `3.` It will not run in real mode due to lack of memory.",
513: "",
514: " `4.` TrueType fonts are not available in the graph window.",
515: "",
516: " `5.` Drag-drop does not work."
517: END_HELP(windows)
518: #endif /* TERM_HELP */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>