1 /* Hello, Emacs, this is -*-C-*-
2 * $Id: win.trm,v 1.52.2.5 2008/09/09 16:42:52 sfeam Exp $
5 /* GNUPLOT - win.trm */
8 * Copyright 1992 - 1993, 1998, 2004
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.
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,
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
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.
33 * This software is provided "as is" without express or implied warranty
34 * to the extent permitted by applicable law.
41 * Gnuplot for Windows:
42 * Maurice Castro, Russell Lang
47 /* This file implements the terminal and printer display for gnuplot */
48 /* under Microsoft Windows. */
50 /* The modifications to allow Gnuplot to run under Windows were made */
51 /* by Maurice Castro (maurice@bruce.cs.monash.edu.au) */
52 /* and Russell Lang (rjl@monu1.cc.monash.edu.au) 19 Nov 1992 */
55 /* Edit this file with tabstop=4 (vi :se ts=4) */
58 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
64 register_term(windows)
68 TERM_PUBLIC void WIN_options __PROTO((void));
69 TERM_PUBLIC void WIN_init __PROTO((void));
70 TERM_PUBLIC void WIN_reset __PROTO((void));
71 TERM_PUBLIC void WIN_text __PROTO((void));
72 TERM_PUBLIC void WIN_graphics __PROTO((void));
73 TERM_PUBLIC void WIN_move __PROTO((unsigned int x, unsigned int y));
74 TERM_PUBLIC void WIN_vector __PROTO((unsigned int x, unsigned int y));
75 TERM_PUBLIC void WIN_linetype __PROTO((int lt));
76 TERM_PUBLIC void WIN_put_text __PROTO((unsigned int x, unsigned int y, const char *str));
77 TERM_PUBLIC int WIN_justify_text __PROTO((enum JUSTIFY mode));
78 TERM_PUBLIC int WIN_text_angle __PROTO((int ang));
79 TERM_PUBLIC void WIN_point __PROTO((unsigned int x, unsigned int y, int number));
80 TERM_PUBLIC void WIN_resume __PROTO((void));
81 TERM_PUBLIC void WIN_set_pointsize __PROTO((double));
82 TERM_PUBLIC void WIN_linewidth __PROTO((double linewidth));
84 TERM_PUBLIC void WIN_set_ruler __PROTO((int, int));
85 TERM_PUBLIC void WIN_set_cursor __PROTO((int, int, int));
86 TERM_PUBLIC void WIN_put_tmptext __PROTO((int, const char str[]));
87 TERM_PUBLIC void WIN_set_clipboard __PROTO((const char[]));
89 TERM_PUBLIC int WIN_make_palette __PROTO((t_sm_palette *palette));
90 TERM_PUBLIC void WIN_set_color __PROTO((t_colorspec *));
91 TERM_PUBLIC void WIN_filled_polygon __PROTO((int points, gpiPoint *corners));
92 TERM_PUBLIC void WIN_boxfill __PROTO((int, unsigned int, unsigned int, unsigned int, unsigned int));
93 /* To support "set term win enhanced" */
94 TERM_PUBLIC int WIN_set_font __PROTO((const char *font));
95 TERM_PUBLIC void WIN_enhanced_put_text __PROTO((unsigned int x, unsigned int y, const char *str));
96 TERM_PUBLIC void WIN_enhanced_open __PROTO((char * fontname, double fontsize,
97 double base, TBOOLEAN widthflag, TBOOLEAN showflag,
99 TERM_PUBLIC void WIN_enhanced_flush __PROTO((void));
101 TERM_PUBLIC void WIN_image __PROTO((unsigned int, unsigned int, coordval *, gpiPoint *, t_imagecolor));
105 /* Initialization values - Guess Now Scale later */
106 #define WIN_XMAX (24000)
107 #define WIN_YMAX (18000)
108 #define WIN_HCHAR (WIN_XMAX/75)
109 #define WIN_VCHAR (WIN_YMAX/25)
110 #define WIN_HTIC (WIN_XMAX/160)
111 #define WIN_VTIC WIN_HTIC
112 #endif /* TERM_PROTO */
114 #ifndef TERM_PROTO_ONLY
118 #include "win/winmain.h"
121 #include <io.h> /* for mktemp() */
124 #define WIN_POINT_TYPES 15 /* 20010411: raised */
126 /* Interface routines - create list of actions for Windows */
128 enum WIN_id { WIN_DEFAULT, WIN_MONOCHROME, WIN_COLOR,
129 WIN_ENHANCED, WIN_NOENHANCED, WIN_FONT, WIN_OTHER };
131 static struct gen_table WIN_opts[] =
133 { "d$efault", WIN_DEFAULT },
134 { "m$onochrome", WIN_MONOCHROME },
135 { "c$olor", WIN_COLOR },
136 { "c$olour", WIN_COLOR },
137 { "noenh$anced", WIN_NOENHANCED },
138 { "enh$anced", WIN_ENHANCED },
139 { "font", WIN_FONT },
143 static int WIN_last_linetype = LT_NODRAW; /* HBB 20000813: linetype caching */
145 /* these variables are needed for enhanced text only */
147 /* FIXME: these are duplicates of struct graphwin members */
148 static char WIN_font[MAXFONTNAME] = WINFONT;
149 static int WIN_fontsize = WINFONTSIZE;
150 static double WIN_angle = 0.; /* unit is radian */
152 /* FIXME: these should most likely be members of struct graphwin */
153 static unsigned int WIN_x = 0;
154 static unsigned int WIN_y = 0;
155 static enum JUSTIFY WIN_justification = LEFT;
157 /* state variables for enhanced text processing */
158 static TBOOLEAN ENHwin_opened_string;
159 static TBOOLEAN ENHwin_show = TRUE;
160 static int ENHwin_overprint = 0;
161 static TBOOLEAN ENHwin_widthflag = TRUE;
162 static TBOOLEAN ENHwin_sizeonly = FALSE;
163 static double ENHwin_base;
171 TBOOLEAN set_font = FALSE, set_fontsize = FALSE;
173 while (!END_OF_COMMAND) {
174 switch(lookup_table(&WIN_opts[0],c_token)) {
176 graphwin.color = TRUE;
177 strcpy(graphwin.fontname, WINFONT);
178 graphwin.fontsize = WINFONTSIZE;
179 strcpy(graphwin.deffontname, WINFONT);
180 graphwin.deffontsize = WINFONTSIZE;
184 graphwin.color = FALSE;
188 graphwin.color = TRUE;
193 term->put_text = WIN_enhanced_put_text;
194 term->flags |= TERM_ENHANCED_TEXT;
198 term->put_text = WIN_put_text;
199 term->flags &= ~TERM_ENHANCED_TEXT;
203 /* Fall through to attempt to read font name */
206 /* Code copied from ps.trm and modified for windows terminal */
207 if ((s = try_to_get_string())) {
211 "extraneous argument in set terminal %s",
214 comma = strrchr(s,',');
215 if (comma && (1 == sscanf(comma+1,"%i", &graphwin.fontsize))) {
216 graphwin.deffontsize = graphwin.fontsize;
221 strncpy(graphwin.fontname, s, MAX_ID_LEN);
222 strcpy(graphwin.deffontname, graphwin.fontname);
228 "extraneous argument in set terminal %s",
231 /* We have font size specified */
232 graphwin.fontsize = (int) real(const_express(&a));
233 graphwin.deffontsize = graphwin.fontsize;
239 if (graphwin.fontname[0] == '\0')
240 sprintf(term_options, "%s %s",
241 graphwin.color ? "color" : "monochrome",
242 term->flags & TERM_ENHANCED_TEXT ? "enhanced" : "noenhanced");
244 sprintf(term_options, "%s %s font \"%s, %d\"",
245 graphwin.color ? "color" : "monochrome",
246 term->flags & TERM_ENHANCED_TEXT ? "enhanced" : "noenhanced",
247 graphwin.fontname, graphwin.fontsize);
249 if (IsWindow(graphwin.hWndGraph) && IsIconic(graphwin.hWndGraph))
250 ShowWindow(graphwin.hWndGraph, SW_SHOWNORMAL);
252 GraphRedraw(&graphwin);
255 /* We don't actually do scaling, but we need to fix up the text size
256 * if the user has resized the window.
257 * Routine unused -- terminals are not allowed to do their own scale().
263 term->h_char = graphwin.hchar;
264 term->v_char = graphwin.vchar;
265 term->h_tic = graphwin.htic;
266 term->v_tic = graphwin.vtic;
267 sprintf(term_options, "%s \"%s\" %d",
268 graphwin.color ? "color" : "monochrome",
269 graphwin.fontname, graphwin.fontsize);
270 return FALSE; /* can't be done */
277 if (!graphwin.hWndGraph) {
278 graphwin.xmax = WIN_XMAX;
279 graphwin.ymax = WIN_YMAX;
280 graphwin.htic = WIN_HTIC;
281 graphwin.vtic = WIN_VTIC;
282 GraphInit(&graphwin);
284 SetClassLong(graphwin.hWndGraph, GCL_HICON, (LONG) LoadIcon(graphwin.hInstance, "GRPICON"));
286 SetClassWord(graphwin.hWndGraph, GCW_HICON, LoadIcon(graphwin.hInstance, "GRPICON"));
288 graphwin.resized = FALSE;
290 WIN_last_linetype = LT_NODRAW; /* HBB 20000813: linetype caching */
308 GraphStart(&graphwin, pointsize);
309 WIN_last_linetype = LT_NODRAW; /* HBB 20000813: linetype caching */
313 WIN_move(unsigned int x, unsigned int y)
315 /* Notice HBB 20010208: on Win32 platforms, passing int or
316 * unsigned int arguments to GraphOp() might cause problems: int
317 * is 32bits, but GraphOp() args are 16bit WORDS. */
318 GraphOp(&graphwin, W_move, x, y, NULL);
320 /* save current position, only needed for enhanced text */
326 WIN_vector(unsigned int x, unsigned int y)
328 /* Notice HBB 20010208: --> WIN_move() */
329 GraphOp(&graphwin, W_vect, x, y, NULL);
335 if (lt != WIN_last_linetype) {
336 /* Notice HBB 20010208: --> see WIN_move() */
337 GraphOp(&graphwin, W_line_type, lt, 0, NULL);
338 WIN_last_linetype = lt;
343 WIN_put_text(unsigned int x, unsigned int y, const char *str)
345 /* Notice HBB 20010208: --> WIN_move() */
346 GraphOp(&graphwin, W_put_text, x, y, str);
350 WIN_justify_text(enum JUSTIFY mode)
352 /* Notice HBB 20010208: --> WIN_move() */
353 GraphOp(&graphwin, W_justify, mode, 0, NULL);
354 /* store text justification, only needed for enhanced text */
355 WIN_justification = mode;
360 WIN_text_angle(int ang)
362 if (graphwin.rotate) {
363 /* Notice HBB 20010208: --> WIN_move() */
364 GraphOp(&graphwin, W_text_angle, ang, 0, NULL);
366 /* store text angle, only needed for enhanced text */
367 WIN_angle = (double)ang * M_PI / 180.;
369 return graphwin.rotate;
373 WIN_point(unsigned int x, unsigned int y, int number)
375 /* draw point shapes later to save memory */
376 /* size of point symbols */
377 graphwin.htic = pointsize * term->h_tic / 2;
378 graphwin.vtic = pointsize * term->v_tic / 2;
379 /* HBB 20010411: secure against pointtype -1 or lower */
381 number = -1; /* refuse nonsense values */
383 number %= WIN_POINT_TYPES;
385 /* Notice HBB 20010208: --> WIN_move() */
386 GraphOp(&graphwin, W_dot + number, x, y, NULL);
392 GraphResume(&graphwin);
396 WIN_set_pointsize(double s)
398 /* Save new pointsize as string */
403 sprintf(scale, "%.15g", s);
405 /* HBB 980309: it seems passing it as a string is a bad idea
406 * in Win16: it means the wgnuplot.dll has to parse the string
407 * via sscanf(), leading to crash (by stack overflow?). Alternative:
408 * pass it as a scaled-up integer. For the sake of compatibility,
409 * pass the string as well. */
410 /* Notice HBB 20010208: --> WIN_move() */
411 GraphOp(&graphwin, W_pointsize, (int) 100 * s, 0, scale);
413 GraphOp(&graphwin, W_pointsize, 0, 0, scale);
418 WIN_linewidth(double linewidth)
420 /* HBB 20000813: New routine */
421 WIN_last_linetype = LT_NODRAW; /* invalidate cached linetype */
422 /* Notice HBB 20010208: --> WIN_move() */
423 GraphOp(&graphwin, W_line_width, (int) 100 * linewidth, 0, NULL);
428 /* Implemented by Petr Mikulik, February 2001 --- the best Windows solutions
429 * come from OS/2 :-))
433 WIN_put_tmptext ( int i, const char str[] )
435 Graph_put_tmptext(&graphwin, i, str );
439 WIN_set_ruler ( int x, int y )
441 Graph_set_ruler(&graphwin, x, y );
445 WIN_set_cursor ( int c, int x, int y )
447 Graph_set_cursor(&graphwin, c, x, y );
451 WIN_set_clipboard ( const char s[] )
453 Graph_set_clipboard(&graphwin, s);
456 #endif /* USE_MOUSE */
461 /* Note: this is a verbatim copy of PM_image (pm.trm) with only minor changes */
464 WIN_image(unsigned int M, unsigned int N, coordval *image,
465 gpiPoint *corner, t_imagecolor color_mode)
468 unsigned int image_size;
469 unsigned int pad_bytes;
471 /* IC_PALETTE and IC_RGB images are converted to a 24bit RGB format
472 suitable for Windows:
473 - sequence of lines is reversed
474 - each line starts at a 4 byte boundary
477 /* fprintf(stderr, "WIN_image: %i x %i, mode=%s\n", M, N, color_mode==IC_RGB?"IC_RGB":"IC_PALETTE" ); */
478 pad_bytes = (4 - (3 * M) % 4) % 4; /* scan lines start on ULONG boundaries */
480 image_size = (M + pad_bytes ) * N * 3;
481 rgb_image = (PBYTE) gp_alloc(image_size, "WIN RGB image");
483 if (color_mode == IC_PALETTE) {
486 rgb_image += N * (3 * M + pad_bytes);
487 for (y=0; y<N; y++) {
488 rgb_image -= 3 * M + pad_bytes;
491 rgb255maxcolors_from_gray(*image++, &rgb255);
492 *(rgb_image++) = rgb255.b;
493 *(rgb_image++) = rgb255.g;
494 *(rgb_image++) = rgb255.r;
498 } else if (color_mode == IC_RGB) {
501 rgb_image += N * (3 * M + pad_bytes);
502 for (y=0; y<N; y++) {
503 rgb_image -= 3 * M + pad_bytes;
506 rgb255.r = (BYTE) (*image++ * 255 + 0.5);
507 rgb255.g = (BYTE) (*image++ * 255 + 0.5);
508 rgb255.b = (BYTE) (*image++ * 255 + 0.5);
509 *(rgb_image++) = rgb255.b;
510 *(rgb_image++) = rgb255.g;
511 *(rgb_image++) = rgb255.r;
517 /* squeze all the information into the buffer */
518 if ((color_mode == IC_PALETTE) || (color_mode == IC_RGB)) {
519 GraphOp(&graphwin, W_image, corner[0].x, corner[0].y, NULL);
520 GraphOp(&graphwin, W_image, corner[1].x, corner[1].y, NULL);
521 GraphOp(&graphwin, W_image, corner[2].x, corner[2].y, NULL);
522 GraphOp(&graphwin, W_image, corner[3].x, corner[3].y, NULL);
523 /* GraphOp() cannot be used here since the image might
524 contain char(0), so use GraphOpSize() instead */
525 GraphOpSize(&graphwin, W_image, M, N, rgb_image, image_size);
531 #endif /* WITH_IMAGE */
535 WIN_make_palette(t_sm_palette *palette)
537 /* Win can do continuous colors. However, we round them only to 256 levels
538 * in order to pass an integer to GraphOp; it also reasonably limits
539 * the number of colors if "copy to clipboard" is used. Don't change this
540 * number unless you change it also in WIN_set_color() and in wgraph.c.
546 WIN_set_color(t_colorspec *colorspec)
548 switch (colorspec->type ) {
550 GraphOp(&graphwin, W_pm3d_setcolor, (int)(256*colorspec->value), 0, NULL);
553 GraphOp(&graphwin, W_pm3d_setcolor, (colorspec->lt) & 0xffff, 0xff00 | ((colorspec->lt >> 16) & 0x00ff), NULL);
556 /* set color only when second parameter to W_line_type equals 1 */
557 GraphOp(&graphwin, W_line_type, colorspec->lt, 1, NULL);
560 WIN_last_linetype = LT_NODRAW; /* invalidate cached linetype */
564 WIN_filled_polygon(int points, gpiPoint *corners)
567 /* Notice HBB 20010208: --> WIN_move() */
568 for (i=0; i<points; i++)
569 GraphOp(&graphwin, W_pm3d_filled_polygon_pt, corners[i].x, corners[i].y, NULL);
571 GraphOp(&graphwin, W_pm3d_filled_polygon_draw, points, 0, NULL);
577 unsigned int xleft, unsigned int ybottom,
578 unsigned int width, unsigned int height)
580 /* split into two commands to squeeze through all the necessary info */
581 /* Notice HBB 20010208: --> WIN_move() */
582 GraphOp(&graphwin, W_fillstyle, style, 0, NULL);
583 GraphOp(&graphwin, W_move, xleft, ybottom, NULL);
584 GraphOp(&graphwin, W_boxfill, width, height, NULL);
589 WIN_set_font(const char *font)
591 char fontname[MAXFONTNAME];
595 if (font[0] == '\0') {
596 strcpy(fontname, graphwin.deffontname);
597 fontsize = graphwin.deffontsize;
601 size = strrchr(font, ',');
603 /* only font name given */
604 strcpy(fontname, font);
605 fontsize = graphwin.deffontsize;
606 } else if (size == font) {
607 /* only font size given */
608 strcpy(fontname, graphwin.deffontname);
609 sscanf(size+1,"%i", &fontsize);
611 /* full font information supplied */
612 strncpy(fontname, font, size-font);
613 fontname[size-font] = '\0';
614 sscanf(size+1,"%i", &fontsize);
620 GraphOp(&graphwin, W_font, fontsize, 0, fontname);
621 strcpy(WIN_font, fontname);
622 WIN_fontsize = fontsize;
625 GraphOp(&graphwin, W_font, 0, 0, "");
626 strcpy(WIN_font, graphwin.deffontname);
627 WIN_fontsize = graphwin.deffontsize;
636 double fontsize, double base,
637 TBOOLEAN widthflag, TBOOLEAN showflag,
640 static const int win_scale = 40; /* scaling of base offset */
641 static unsigned int ENHwin_xsave, ENHwin_ysave;
644 /* There are two special cases:
645 * overprint = 3 means save current position
646 * overprint = 4 means restore saved position
648 if (overprint == 3) {
649 ENHwin_xsave = WIN_x;
650 ENHwin_ysave = WIN_y;
652 } else if (overprint == 4) {
653 WIN_x = ENHwin_xsave;
654 WIN_y = ENHwin_ysave;
658 if (!ENHwin_opened_string) {
659 ENHwin_opened_string = TRUE;
661 /* Start new text fragment */
662 enhanced_cur_text = &enhanced_text[0];
664 /* Keep track of whether we are supposed to show this string */
665 ENHwin_show = showflag;
667 /* 0/1/2 no overprint / 1st pass / 2nd pass */
668 ENHwin_overprint = overprint;
670 /* widthflag FALSE means do not update text position after printing */
671 ENHwin_widthflag = widthflag;
673 /* Scale fractional font height to vertical units of display */
675 Font scaling is not done properly (yet) and will lead to
676 non-optimal results for most font and size selections.
677 OUTLINEFONTMETRICS could be used for better here.
679 ENHwin_base = win_scale * base;
682 /* FIXME: It would be nice to have fractional font sizes
683 for super- and subscripts. */
684 /* FIXME: sometimes fontname has zero length */
685 if ((fontname != NULL) && strlen(fontname) > 0) {
686 fontstring = malloc(strlen(fontname) + 16);
687 sprintf(fontstring, "%s,%i", fontname, (int)fontsize);
689 fontstring = malloc( strlen(graphwin.deffontname) + 16 );
690 sprintf( fontstring, "%s,%i", graphwin.deffontname, (int)fontsize);
692 WIN_set_font( fontstring );
701 static unsigned int ENHwin_xsave, ENHwin_ysave;
703 if (ENHwin_opened_string) {
705 unsigned int x, y, len;
707 *enhanced_cur_text = '\0';
709 /* print the string fragment, perhaps invisibly */
710 /* NB: base expresses offset from current y pos */
711 x = WIN_x - ENHwin_base * sin(WIN_angle);
712 y = WIN_y + ENHwin_base * cos(WIN_angle);
714 /* calculate length of string first */
715 len = GraphGetTextLength(&graphwin, enhanced_text, WIN_font, WIN_fontsize);
716 width = cos(WIN_angle) * len;
717 height = sin(WIN_angle) * len;
719 if (ENHwin_show && !ENHwin_sizeonly) {
721 GraphOp(&graphwin, W_put_text, x, y, enhanced_text);
724 /* update drawing position according to len */
725 if (!ENHwin_widthflag) {
729 if (ENHwin_sizeonly) {
730 /* This is the first pass for justified printing. */
731 /* We just adjust the starting position for second pass. */
732 if (WIN_justification == RIGHT) {
736 else if (WIN_justification == CENTRE) {
740 /* nothing to do for LEFT justified text */
742 else if (ENHwin_overprint == 1) {
743 /* Save current position */
744 ENHwin_xsave = WIN_x + width;
745 ENHwin_ysave = WIN_y + height;
746 /* First pass of overprint, leave position in center of fragment */
750 else if (ENHwin_overprint == 2) {
751 /* Restore current position, */
752 /* this sets the position behind the overprinted text */
753 WIN_x = ENHwin_xsave;
754 WIN_y = ENHwin_ysave;
757 /* Normal case is to update position to end of fragment */
762 ENHwin_opened_string = FALSE;
768 WIN_enhanced_put_text(unsigned int x, unsigned int y, const char *str)
770 char *original_string = (char *)str;
771 unsigned int pass, num_passes;
773 /* If no enhanced text processing is needed, we can use the plain */
774 /* vanilla put_text() routine instead of this fancy recursive one. */
775 if (ignore_enhanced_text || !strpbrk(str, "{}^_@&~")) {
776 WIN_put_text(x,y,str);
780 /* Set up global variables needed by enhanced_recursion() */
781 ENHwin_opened_string = FALSE;
782 enhanced_fontscale = 1.0;
783 strncpy(enhanced_escape_format,"%c",sizeof(enhanced_escape_format));
785 /* Tell the terminal to move the drawing position */
786 /* we store the current position to WIN_x and WIN_y */
790 /* Text justification requires two passes. During the first pass we */
791 /* don't draw anything, we just measure the space it will take. */
792 /* Without justification one pass is enough */
793 if (WIN_justification == LEFT) {
798 ENHwin_sizeonly = TRUE;
801 for( pass=1; pass <= num_passes; pass++ ) {
803 /* This will restore the default font
804 and update WIN_font and WIN_fontsize */
807 /* Set the recursion going. We say to keep going until a
808 * closing brace, but we don't really expect to find one.
809 * If the return value is not the nul-terminator of the
810 * string, that can only mean that we did find an unmatched
811 * closing brace in the string. We increment past it (else
812 * we get stuck in an infinite loop) and try again.
814 while (*(str = enhanced_recursion((char *)str, TRUE,
816 0.0, TRUE, TRUE, 0))) {
817 (term->enhanced_flush)();
819 /* I think we can only get here if *str == '}' */
823 break; /* end of string */
825 /* else carry on and process the rest of the string */
828 /* In order to do text justification we need to do a second pass that */
829 /* uses information stored during the first pass. */
830 /* see WIN_enhanced_flush() */
832 /* do the actual printing in the next pass */
833 ENHwin_sizeonly = FALSE;
834 str = original_string;
836 /* temporarily switch to left alignment since we do it ourselves */
837 GraphOp(&graphwin, W_justify, LEFT, 0, NULL);
841 /* restore default font */
844 /* restore text alignment */
846 GraphOp(&graphwin, W_justify, WIN_justification, 0, NULL);
849 #endif /* TERM_BODY */
853 TERM_TABLE_START(win_driver)
854 "windows", "Microsoft Windows",
855 WIN_XMAX, WIN_YMAX, WIN_VCHAR, WIN_HCHAR,
856 WIN_VTIC, WIN_HTIC, WIN_options, WIN_init, WIN_reset,
857 WIN_text, null_scale, WIN_graphics, WIN_move, WIN_vector,
858 WIN_linetype, WIN_put_text, WIN_text_angle,
859 WIN_justify_text, WIN_point, do_arrow, WIN_set_font,
860 WIN_set_pointsize, TERM_CAN_MULTIPLOT|TERM_NO_OUTPUTFILE,
861 WIN_text /* suspend */ , WIN_resume,
862 WIN_boxfill, WIN_linewidth
864 , 0 /* WIN_waitforinput */,
865 WIN_put_tmptext, WIN_set_ruler, WIN_set_cursor, WIN_set_clipboard
867 , WIN_make_palette, 0 /* previous_palette */,
868 WIN_set_color, WIN_filled_polygon
872 , WIN_enhanced_open, WIN_enhanced_flush, do_enh_writec
873 TERM_TABLE_END(win_driver)
876 #define LAST_TERM win_driver
878 #endif /* TERM_TABLE */
879 #endif /* TERM_PROTO_ONLY */
884 "?commands set terminal windows",
885 "?set terminal windows",
890 " Three options may be set in the `windows` terminal driver.",
893 " set terminal windows {color | monochrome}",
894 " {enhanced | noenhanced}",
895 " {{font} \"fontname{,fontsize}\" {<fontsize>}}",
897 " where `color` and `monochrome` select colored or mono output,",
898 " `enhanced` enables enhanced text mode features (subscripts,",
899 " superscripts and mixed fonts). See `enhanced` for more information.",
900 " `\"<fontname>\"` is the name of a valid Windows font, and `<fontsize>`",
901 " is the size of the font in points.",
903 " Other options may be set with the graph-menu or the initialization file.",
905 " The Windows version normally terminates immediately as soon as the end of",
906 " any files given as command line arguments is reached (i.e. in non-interactive",
907 " mode), unless you specify `-` as the last command line option.",
908 " It will also not show the text-window at all, in this mode, only the plot.",
909 " By giving the optional argument `-persist` (same as for gnuplot under x11;",
910 " former Windows-only options `/noend` or `-noend` are still accepted as well),",
911 " will not close gnuplot. Contrary to gnuplot on other operating systems,",
912 " gnuplot's interactive command line is accessible after the -persist option.",
914 "?commands set terminal windows graph-menu",
915 "?set terminal windows graph-menu",
916 "?set term windows graph-menu",
917 "?windows graph-menu",
919 " The `gnuplot graph` window has the following options on a pop-up menu",
920 " accessed by pressing the right mouse button or selecting `Options` from the",
923 " `Bring to Top` when checked brings the graph window to the top after every",
926 " `Color` when checked enables color linestyles. When unchecked it forces",
927 " monochrome linestyles.",
929 " `Copy to Clipboard` copies a bitmap and a Metafile picture.",
931 " `Background...` sets the window background color.",
933 " `Choose Font...` selects the font used in the graphics window.",
935 " `Line Styles...` allows customization of the line colors and styles.",
937 " `Print...` prints the graphics windows using a Windows printer driver and",
938 " allows selection of the printer and scaling of the output. The output",
939 " produced by `Print` is not as good as that from `gnuplot`'s own printer",
942 " `Update wgnuplot.ini` saves the current window locations, window sizes, text",
943 " window font, text window font size, graph window font, graph window font",
944 " size, background color and linestyles to the initialization file",
947 "?commands set terminal windows printing",
948 "?set terminal windows printing",
949 "?set term windows printing",
952 " In order of preference, graphs may be be printed in the following ways.",
954 " `1.` Use the `gnuplot` command `set terminal` to select a printer and `set",
955 " output` to redirect output to a file.",
957 " `2.` Select the `Print...` command from the `gnuplot graph` window. An extra",
958 " command `screendump` does this from the text window.",
960 " `3.` If `set output \"PRN\"` is used, output will go to a temporary file. When",
961 " you exit from `gnuplot` or when you change the output with another `set",
962 " output` command, a dialog box will appear for you to select a printer port.",
963 " If you choose OK, the output will be printed on the selected port, passing",
964 " unmodified through the print manager. It is possible to accidentally (or",
965 " deliberately) send printer output meant for one printer to an incompatible",
968 "?commands set terminal windows text-menu",
969 "?set terminal windows text-menu",
970 "?set term windows text-menu",
971 "?windows text-menu",
973 " The `gnuplot text` window has the following options on a pop-up menu accessed",
974 " by pressing the right mouse button or selecting `Options` from the system",
977 " `Copy to Clipboard` copies marked text to the clipboard.",
979 " `Paste` copies text from the clipboard as if typed by the user.",
981 " `Choose Font...` selects the font used in the text window.",
983 " `System Colors` when selected makes the text window honor the System Colors",
984 " set using the Control Panel. When unselected, text is black or blue on a",
985 " white background.",
987 " `Update wgnuplot.ini` saves the current text window location, text window",
988 " size, text window font and text window font size to the initialisation file",
993 " If the menu file `WGNUPLOT.MNU` is found in the same directory as",
994 " WGNUPLOT.EXE, then the menu specified in `WGNUPLOT.MNU` will be loaded.",
997 " [Menu] starts a new menu with the name on the following line.",
999 " [EndMenu] ends the current menu.",
1001 " [--] inserts a horizontal menu separator.",
1003 " [|] inserts a vertical menu separator.",
1005 " [Button] puts the next macro on a push button instead of a menu.",
1007 " Macros take two lines with the macro name (menu entry) on the first line and",
1008 " the macro on the second line. Leading spaces are ignored. Macro commands:",
1010 " [INPUT] --- Input string with prompt terminated by [EOS] or {ENTER}",
1012 " [EOS] --- End Of String terminator. Generates no output.",
1014 " [OPEN] --- Get name of file to open from list box, with title of list box",
1015 " terminated by [EOS], followed by default filename terminated by [EOS] or",
1018 " [SAVE] --- Get name of file to save. Similar to [OPEN]",
1020 " Macro character substitutions:",
1022 " {ENTER} --- Carriage Return '\\r'",
1024 " {TAB} --- Tab '\\011'",
1026 " {ESC} --- Escape '\\033'",
1028 " {^A} --- '\\001'",
1032 " {^_} --- '\\031'",
1034 " Macros are limited to 256 characters after expansion.",
1036 "?commands set terminal windows wgnuplot.ini",
1037 "?set terminal windows wgnuplot.ini",
1038 "?set term windows wgnuplot.ini",
1039 "?windows wgnuplot.ini",
1041 " Windows `gnuplot` will read some of its options from the `[WGNUPLOT]` section",
1042 " of `WGNUPLOT.INI` in user's %APPDATA% directory. A sample `WGNUPLOT.INI` file:",
1046 " TextSize=640 150",
1047 " TextFont=Terminal,9",
1048 " GraphOrigin=0 150",
1049 " GraphSize=640 330",
1050 " GraphFont=Arial,10",
1053 " GraphBackground=255 255 255",
1054 " Border=0 0 0 0 0",
1055 " Axis=192 192 192 2 2",
1056 " Line1=0 0 255 0 0",
1057 " Line2=0 255 0 0 1",
1058 " Line3=255 0 0 0 2",
1059 " Line4=255 0 255 0 3",
1060 " Line5=0 0 128 0 4",
1062 " The `GraphFont` entry specifies the font name and size in points. The five",
1063 " numbers given in the `Border`, `Axis` and `Line` entries are the `Red`",
1064 " intensity (0--255), `Green` intensity, `Blue` intensity, `Color Linestyle`",
1065 " and `Mono Linestyle`. `Linestyles` are 0=SOLID, 1=DASH, 2=DOT, 3=DASHDOT,",
1066 " 4=DASHDOTDOT. In the sample `WGNUPLOT.INI` file above, Line 2 is a green",
1067 " solid line in color mode, or a dashed line in monochrome mode. The default",
1068 " line width is 1 pixel. If `Linestyle` is negative, it specifies the width of",
1069 " a SOLID line in pixels. Line1 and any linestyle used with the `points` style",
1070 " must be SOLID with unit width."
1072 #endif /* TERM_HELP */