Term-Gnuplot
view release on metacpan or search on metacpan
gnuterm/term/win.trm view on Meta::CPAN
* comp.graphics.apps.gnuplot
* is identical to the mailing list (they
* both carry the same set of messages). We prefer that you read the
* messages through that newsgroup, to subscribing to the mailing list.
* (If you can read that newsgroup, and are already on the mailing list,
* please send a message to majordomo@dartmouth.edu, asking to be
* removed from the mailing list.)
*
* The address for mailing to list members is
* info-gnuplot@dartmouth.edu
* and for mailing administrative requests is
* majordomo@dartmouth.edu
* The mailing list for bug reports is
* bug-gnuplot@dartmouth.edu
* The list of those interested in beta-test versions is
* info-gnuplot-beta@dartmouth.edu
*/
/* This file implements the terminal and printer display for gnuplot */
/* under Microsoft Windows. The code currently compiles only with the */
/* Borland C++ 3.1 compiler. */
/* */
/* The modifications to allow Gnuplot to run under Windows were made */
/* by Maurice Castro (maurice@bruce.cs.monash.edu.au) */
/* and Russell Lang (rjl@monu1.cc.monash.edu.au) 19 Nov 1992 */
/* */
/* Edit this file with tabstop=4 (vi :se ts=4) */
/*
* adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
*/
#include "driver.h"
#ifdef TERM_REGISTER
register_term(windows)
#endif
#ifdef TERM_PROTO
TERM_PUBLIC void WIN_options __PROTO((void));
TERM_PUBLIC void WIN_init __PROTO((void));
TERM_PUBLIC void WIN_reset __PROTO((void));
TERM_PUBLIC void WIN_text __PROTO((void));
TERM_PUBLIC void WIN_graphics __PROTO((void));
TERM_PUBLIC void WIN_move __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void WIN_vector __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void WIN_linetype __PROTO((int lt));
TERM_PUBLIC void WIN_put_text __PROTO((unsigned int x, unsigned int y, const char *str));
TERM_PUBLIC int WIN_justify_text __PROTO((enum JUSTIFY mode));
TERM_PUBLIC int WIN_text_angle __PROTO((int ang));
TERM_PUBLIC void WIN_point __PROTO((unsigned int x, unsigned int y, int number));
TERM_PUBLIC void WIN_resume __PROTO((void));
TERM_PUBLIC void WIN_set_pointsize __PROTO((double));
TERM_PUBLIC void WIN_linewidth __PROTO((double linewidth));
#ifdef USE_MOUSE
TERM_PUBLIC void WIN_set_ruler __PROTO((int, int));
TERM_PUBLIC void WIN_set_cursor __PROTO((int, int, int));
TERM_PUBLIC void WIN_put_tmptext __PROTO((int, const char str[]));
TERM_PUBLIC void WIN_set_clipboard __PROTO((const char[]));
#endif
#ifdef PM3D
TERM_PUBLIC int WIN_make_palette __PROTO((t_sm_palette *palette));
TERM_PUBLIC void WIN_set_color __PROTO((double gray));
TERM_PUBLIC void WIN_filled_polygon __PROTO((int points, gpiPoint *corners));
#endif
TERM_PUBLIC void WIN_boxfill __PROTO((int, unsigned int, unsigned int, unsigned int, unsigned int));
/* Initialization values - Guess Now Scale later */
#define WIN_XMAX (24000)
#define WIN_YMAX (18000)
#define WIN_HCHAR (WIN_XMAX/75)
#define WIN_VCHAR (WIN_YMAX/25)
#define WIN_HTIC (WIN_XMAX/160)
#define WIN_VTIC WIN_HTIC
#endif /* TERM_PROTO */
#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY
#include <windows.h>
#include "win/winmain.h"
#ifdef __MSC__
#include <io.h> /* for mktemp() */
#endif
#define WIN_POINT_TYPES 15 /* 20010411: raised */
/* Interface routines - create list of actions for Windows */
enum WIN_id { WIN_DEFAULT, WIN_MONOCHROME, WIN_COLOR, WIN_OTHER };
static struct gen_table WIN_opts[] =
{
{ "d$efault", WIN_DEFAULT },
{ "m$onochrome", WIN_MONOCHROME },
{ "c$olor", WIN_COLOR },
{ "c$olour", WIN_COLOR },
{ NULL, WIN_OTHER }
};
static int WIN_last_linetype = -3; /* HBB 20000813: linetype caching */
TERM_PUBLIC void
WIN_options()
{
struct value a;
while (!END_OF_COMMAND) {
switch(lookup_table(&WIN_opts[0],c_token)) {
case WIN_DEFAULT:
graphwin.color = TRUE;
strcpy(graphwin.fontname, WINFONT);
graphwin.fontsize = WINFONTSIZE;
c_token++;
break;
case WIN_MONOCHROME:
graphwin.color = FALSE;
gnuterm/term/win.trm view on Meta::CPAN
WIN_resume(void)
{
GraphResume(&graphwin);
}
TERM_PUBLIC void
WIN_set_pointsize(s)
double s;
{
/* Save new pointsize as string */
char scale[30];
sprintf(scale, "%.15g", s);
#if 1
/* HBB 980309: it seems passing it as a string is a bad idea
* in Win16: it means the wgnuplot.dll has to parse the string
* via sscanf(), leading to crash (by stack overflow?). Alternative:
* pass it as a scaled-up integer. For the sake of compatibility,
* pass the string as well. */
/* Notice HBB 20010208: --> WIN_move() */
GraphOp(&graphwin, W_pointsize, (int) 100 * s, 0, scale);
#else
GraphOp(&graphwin, W_pointsize, 0, 0, scale);
#endif
}
TERM_PUBLIC void
WIN_linewidth(linewidth)
double linewidth;
{
/* HBB 20000813: New routine */
WIN_last_linetype = -3; /* invalidate cached linetype */
/* Notice HBB 20010208: --> WIN_move() */
GraphOp(&graphwin, W_line_width, (int) 100 * linewidth, 0, NULL);
}
#ifdef USE_MOUSE
/* Implemented by Petr Mikulik, February 2001 --- the best Windows solutions
* come from OS/2 :-))
*/
TERM_PUBLIC void
WIN_put_tmptext ( int i, const char str[] )
{
Graph_put_tmptext(&graphwin, i, str );
}
TERM_PUBLIC void
WIN_set_ruler ( int x, int y )
{
Graph_set_ruler(&graphwin, x, y );
}
TERM_PUBLIC void
WIN_set_cursor ( int c, int x, int y )
{
Graph_set_cursor(&graphwin, c, x, y );
}
TERM_PUBLIC void
WIN_set_clipboard ( const char s[] )
{
Graph_set_clipboard(&graphwin, s);
}
#endif /* USE_MOUSE */
#ifdef PM3D
TERM_PUBLIC int
WIN_make_palette(palette)
t_sm_palette *palette;
{
/* Win can do continuous colors. However, we round them only to 256 levels
* in order to pass an integer to GraphOp; it also reasonably limits
* the number of colors if "copy to clipboard" is used. Don't change this
* number unless you change it also in WIN_set_color() and in wgraph.c.
*/
return 256;
}
TERM_PUBLIC void
WIN_set_color(gray)
double gray;
{
WIN_last_linetype = -3; /* invalidate cached linetype */
GraphOp(&graphwin, W_pm3d_setcolor, (int)(256*gray), 0, NULL);
}
TERM_PUBLIC void
WIN_filled_polygon(points, corners)
int points;
gpiPoint *corners;
{
int i;
/* Notice HBB 20010208: --> WIN_move() */
for (i=0; i<points; i++)
GraphOp(&graphwin, W_pm3d_filled_polygon_pt, corners[i].x, corners[i].y, NULL);
/* finish series: */
GraphOp(&graphwin, W_pm3d_filled_polygon_draw, points, 0, NULL);
}
#endif /* PM3D */
TERM_PUBLIC void
WIN_boxfill(style, xleft, ybottom, width, height) /* changes by ULIG */
int style;
unsigned int xleft, ybottom, width, height;
{
/* split into two commands to squeeze through all the necessary info */
/* Notice HBB 20010208: --> WIN_move() */
#if USE_ULIG_FILLEDBOXES
GraphOp(&graphwin, W_fillstyle, style, 0, NULL);
#endif /* USE_ULIG_FILLEDBOXES */
GraphOp(&graphwin, W_move, xleft, ybottom, NULL);
GraphOp(&graphwin, W_boxfill, width, height, NULL);
}
#endif /* TERM_BODY */
#ifdef TERM_TABLE
TERM_TABLE_START(win_driver)
"windows", "Microsoft Windows",
WIN_XMAX, WIN_YMAX, WIN_VCHAR, WIN_HCHAR,
WIN_VTIC, WIN_HTIC, WIN_options, WIN_init, WIN_reset,
WIN_text, null_scale, WIN_graphics, WIN_move, WIN_vector,
WIN_linetype, WIN_put_text, WIN_text_angle,
WIN_justify_text, WIN_point, do_arrow, set_font_null,
WIN_set_pointsize, TERM_CAN_MULTIPLOT,
WIN_text /* suspend */ , WIN_resume,
WIN_boxfill, WIN_linewidth
#ifdef USE_MOUSE
, 0 /* WIN_waitforinput */,
WIN_put_tmptext, WIN_set_ruler, WIN_set_cursor, WIN_set_clipboard
#endif
#ifdef PM3D
, WIN_make_palette, 0 /* previous_palette */,
WIN_set_color, WIN_filled_polygon
#endif
TERM_TABLE_END(win_driver)
#undef LAST_TERM
#define LAST_TERM win_driver
#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */
#ifdef TERM_HELP
START_HELP(windows)
"1 windows",
"?commands set terminal windows",
"?set terminal windows",
"?set term windows",
"?terminal windows",
"?term windows",
"?windows",
" Three options may be set in the `windows` terminal driver.",
"",
" Syntax:",
" set terminal windows {<color>} {\"<fontname>\"} {<fontsize>}",
"",
" where `<color>` is either `color` or `monochrome`, `\"<fontname>\"` is the",
" name of a valid Windows font, and `<fontsize>` is the size of the font in",
" points.",
"",
" Other options may be set with the graph-menu, the initialization file,",
" and `set linestyle`.",
/* Does this really belong here? If not, someone move it where it does. */
"",
" The Windows version normally terminates immediately as soon as the end of",
" any files given as command line arguments is reached (i.e. in non-interactive",
" mode). It will also not show the text-window at all, in this mode, only",
" the plot. By giving the optional argument",
" `/noend` or `-noend`, you can disable this behaviour.",
"2 graph-menu",
"?commands set terminal windows graph-menu",
"?set terminal windows graph-menu",
"?set term windows graph-menu",
"?windows graph-menu",
"?graph-menu",
" The `gnuplot graph` window has the following options on a pop-up menu",
" accessed by pressing the right mouse button or selecting `Options` from the",
" system menu:",
"",
" `Bring to Top` when checked brings the graph window to the top after every",
" plot.",
"",
" `Color` when checked enables color linestyles. When unchecked it forces",
" monochrome linestyles.",
"",
" `Copy to Clipboard` copies a bitmap and a Metafile picture.",
"",
" `Background...` sets the window background color.",
"",
" `Choose Font...` selects the font used in the graphics window.",
"",
" `Line Styles...` allows customization of the line colors and styles.",
"",
" `Print...` prints the graphics windows using a Windows printer driver and",
" allows selection of the printer and scaling of the output. The output",
" produced by `Print` is not as good as that from `gnuplot`'s own printer",
" drivers.",
"",
" `Update wgnuplot.ini` saves the current window locations, window sizes, text",
" window font, text window font size, graph window font, graph window font",
" size, background color and linestyles to the initialization file",
" `WGNUPLOT.INI`.",
"2 printing",
"?commands set terminal windows printing",
"?set terminal windows printing",
"?set term windows printing",
"?windows printing",
"?printing",
" In order of preference, graphs may be be printed in the following ways.",
"",
" `1.` Use the `gnuplot` command `set terminal` to select a printer and `set",
" output` to redirect output to a file.",
"",
" `2.` Select the `Print...` command from the `gnuplot graph` window. An extra",
" command `screendump` does this from the text window.",
"",
" `3.` If `set output \"PRN\"` is used, output will go to a temporary file. When",
" you exit from `gnuplot` or when you change the output with another `set",
" output` command, a dialog box will appear for you to select a printer port.",
" If you choose OK, the output will be printed on the selected port, passing",
" unmodified through the print manager. It is possible to accidentally (or",
" deliberately) send printer output meant for one printer to an incompatible",
" printer.",
"2 text-menu",
"?commands set terminal windows text-menu",
"?set terminal windows text-menu",
"?set term windows text-menu",
"?windows text-menu",
"?text-menu",
" The `gnuplot text` window has the following options on a pop-up menu accessed",
" by pressing the right mouse button or selecting `Options` from the system",
" menu:",
"",
" `Copy to Clipboard` copies marked text to the clipboard.",
"",
" `Paste` copies text from the clipboard as if typed by the user.",
"",
" `Choose Font...` selects the font used in the text window.",
"",
" `System Colors` when selected makes the text window honor the System Colors",
" set using the Control Panel. When unselected, text is black or blue on a",
" white background.",
"",
" `Update wgnuplot.ini` saves the current text window location, text window",
" size, text window font and text window font size to the initialisation file",
" `WGNUPLOT.INI`.",
"",
" `MENU BAR`",
"",
" If the menu file `WGNUPLOT.MNU` is found in the same directory as",
" WGNUPLOT.EXE, then the menu specified in `WGNUPLOT.MNU` will be loaded.",
" Menu commands:",
"",
" [Menu] starts a new menu with the name on the following line.",
"",
" [EndMenu] ends the current menu.",
"",
" [--] inserts a horizontal menu separator.",
"",
" [|] inserts a vertical menu separator.",
"",
" [Button] puts the next macro on a push button instead of a menu.",
"",
" Macros take two lines with the macro name (menu entry) on the first line and",
" the macro on the second line. Leading spaces are ignored. Macro commands:",
"",
" [INPUT] --- Input string with prompt terminated by [EOS] or {ENTER}",
"",
" [EOS] --- End Of String terminator. Generates no output.",
"",
" [OPEN] --- Get name of file to open from list box, with title of list box",
" terminated by [EOS], followed by default filename terminated by [EOS] or",
" {ENTER}. This uses COMMDLG.DLL from Windows 3.1.",
"",
" [SAVE] --- Get name of file to save. Similar to [OPEN]",
"",
" Macro character substitutions:",
"",
" {ENTER} --- Carriage Return '\\r'",
"",
" {TAB} --- Tab '\\011'",
"",
" {ESC} --- Escape '\\033'",
"",
" {^A} --- '\\001'",
"",
" ...",
"",
" {^_} --- '\\031'",
"",
" Macros are limited to 256 characters after expansion.",
"2 wgnuplot.ini",
"?commands set terminal windows wgnuplot.ini",
"?set terminal windows wgnuplot.ini",
"?set term windows wgnuplot.ini",
"?windows wgnuplot.ini",
( run in 0.790 second using v1.01-cache-2.11-cpan-2398b32b56e )