1 /* Hello, Emacs, this is -*-C-*-
2 * $Id: sun.trm,v 1.13.2.1 2008/04/20 00:38:45 sfeam Exp $
6 /* GNUPLOT - sun.trm */
9 * Copyright 1990 - 1993, 1998, 2004
11 * Permission to use, copy, and distribute this software and its
12 * documentation for any purpose with or without fee is hereby granted,
13 * provided that the above copyright notice appear in all copies and
14 * that both that copyright notice and this permission notice appear
15 * in supporting documentation.
17 * Permission to modify the software is granted, but not the right to
18 * distribute the complete modified source code. Modifications are to
19 * be distributed as patches to the released version. Permission to
20 * distribute binaries produced by compiling modified sources is granted,
22 * 1. distribute the corresponding source modifications from the
23 * released version in the form of a patch file along with the binaries,
24 * 2. add special version identification to distinguish your version
25 * in addition to the base release version number,
26 * 3. provide your name and address as the primary contact for the
27 * support of your modified version, and
28 * 4. retain our contact information in regard to use of the base
30 * Permission to distribute the released version of the source code along
31 * with corresponding source modifications in the form of a patch file is
32 * granted with same provisions 2 through 4 for binary distributions.
34 * This software is provided "as is" without express or implied warranty
35 * to the extent permitted by applicable law.
39 * This file is included by ../term.c.
41 * This terminal driver supports:
42 * SUNview windowing system
47 * send your comments or suggestions to (gnuplot-info@lists.sourceforge.net).
51 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
61 TERM_PUBLIC void SUN_init __PROTO((void));
62 TERM_PUBLIC void SUN_graphics __PROTO((void));
63 TERM_PUBLIC void SUN_text __PROTO((void));
64 TERM_PUBLIC void SUN_linetype __PROTO((int linetype));
65 TERM_PUBLIC void SUN_move __PROTO((unsigned int x, unsigned int y));
66 TERM_PUBLIC void SUN_vector __PROTO((unsigned int x, unsigned int y));
67 TERM_PUBLIC void SUN_put_text __PROTO((unsigned int x, unsigned int y, const char *str));
68 TERM_PUBLIC int SUN_justify_text __PROTO((enum JUSTIFY mode));
69 TERM_PUBLIC void SUN_reset __PROTO((void));
73 #define SUN_VCHAR (12) /* default, will be changed */
74 #define SUN_HCHAR (8) /* default, will be changed */
75 #define SUN_VTIC (SUN_YMAX/80)
76 #define SUN_HTIC (SUN_XMAX/80)
77 #endif /* TERM_PROTO */
79 #ifndef TERM_PROTO_ONLY
81 #include <suntool/sunview.h>
82 #include <suntool/canvas.h>
83 #include <suntool/scrollbar.h>
84 #include <suntool/panel.h>
85 #include <pixrect/pixrect_hs.h>
87 void sun_setmaskpixel __PROTO((unsigned int x, unsigned int y, unsigned int value));
88 void sun_line __PROTO((unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2));
89 static Notify_value local_notice_destroy __PROTO((Frame frame, Destroy_status status));
95 static Canvas SUN_canvas;
97 static struct pixfont *sun_font = NULL;
99 static enum JUSTIFY sun_justify = LEFT;
101 static Notify_value local_notice_destroy();
103 extern Notify_error notify_dispatch();
105 /* dotted line generator */
106 unsigned int sun_value = 1; /* this can be used for colour */
107 unsigned int sun_line_mask = 0xffff; /* 16 bit mask for dotted lines */
108 static unsigned int sun_pattern[] =
110 0xffff, 0x5555, 0x3333, 0x7777, 0x3f3f, 0x0f0f, 0x5f5f};
111 int sun_mask_count = 0;
112 unsigned int sun_lastx, sun_lasty; /* last pixel set - used by sun_line */
118 struct termentry *t = term;
119 struct pr_subregion bound;
121 frame = window_create(NULL, FRAME,
122 FRAME_LABEL, "Gnuplot",
124 notify_interpose_destroy_func(frame, local_notice_destroy);
125 SUN_canvas = window_create(frame, CANVAS,
126 CANVAS_AUTO_EXPAND, TRUE,
127 CANVAS_AUTO_SHRINK, TRUE,
128 CANVAS_MARGIN, MARGIN,
130 notify_do_dispatch();
131 pw = canvas_pixwin(SUN_canvas);
132 window_set(frame, WIN_SHOW, TRUE, 0);
134 /* figure out font and rough size */
135 sun_font = pf_default();
136 pf_textbound(&bound, 1, sun_font, "M");
137 t->v_char = bound.size.y;
138 t->h_char = bound.size.x;
146 term->xmax = (int) window_get(SUN_canvas, CANVAS_WIDTH);
147 term->ymax = (int) window_get(SUN_canvas, CANVAS_HEIGHT);
148 pw_writebackground(pw, 0, 0, term->xmax, term->ymax, PIX_SRC);
150 /* do not let the user make the window too small */
151 if ((term->xmax) < MINWIN) {
153 WIN_WIDTH, MINWIN + 2 * MARGIN + 24,
158 if ((term->ymax) < MINWIN) {
160 WIN_HEIGHT, MINWIN + 2 * MARGIN + 24,
173 return; /* enter text from another window!!! */
177 SUN_linetype(int linetype)
183 sun_line_mask = sun_pattern[linetype + 2];
189 SUN_move(unsigned int x, unsigned int y)
198 SUN_vector(unsigned int x, unsigned int y)
200 if ((x >= term->xmax) || (y >= term->ymax))
202 sun_line(sun_lastx, x, sun_lasty, y);
203 canvas_pixwin(SUN_canvas);
209 SUN_put_text(unsigned int x, unsigned int y, const char *str)
211 struct pr_subregion bound;
213 if ((x >= term->xmax) || (y >= term->ymax))
216 pf_textbound(&bound, strlen(str), sun_font, str);
217 y = term->ymax - 1 - y + bound.size.y / 3; /* vertical centering */
219 switch (sun_justify) {
223 x -= bound.size.x / 2;
229 pw_text(pw, x, y, PIX_SRC | PIX_DST, 0, str);
230 canvas_pixwin(SUN_canvas);
237 SUN_justify_text(enum JUSTIFY mode)
250 term->xmax = SUN_XMAX;
251 term->ymax = SUN_YMAX;
252 window_set(frame, WIN_SHOW, FALSE, 0);
259 sun_setmaskpixel(unsigned int x, unsigned int y, unsigned int value)
261 /* dotted line generator */
262 if ((sun_line_mask >> sun_mask_count) & (unsigned int) (1)) {
263 pw_put(pw, x, term->ymax - 1 - y, sun_value);
265 sun_mask_count = (sun_mask_count + 1) % 16;
266 sun_lastx = x; /* last pixel set with mask */
274 sun_line(unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2)
279 unsigned int xplot, yplot;
282 dx = ABS((int) (x1) - (int) (x2));
289 dy = ABS((int) (y1) - (int) (y2));
300 if ((sun_line_mask == 0xffff) ||
301 ((xplot != sun_lastx) && (yplot != sun_lasty)))
302 sun_setmaskpixel(xplot, yplot, sun_value);
303 while (xplot != x2) {
306 if (runcount >= (dx - runcount)) {
310 sun_setmaskpixel(xplot, yplot, sun_value);
314 if ((sun_line_mask == 0xffff) ||
315 ((xplot != sun_lastx) && (yplot != sun_lasty)))
316 sun_setmaskpixel(xplot, yplot, sun_value);
317 while (yplot != y2) {
320 if (runcount >= (dy - runcount)) {
324 sun_setmaskpixel(xplot, yplot, sun_value);
331 local_notice_destroy(Frame frame, Destroy_status status)
333 if (status != DESTROY_CHECKING) {
335 /* extern TBOOLEAN term_init is gone; is it sufficient just */
336 /* to comment it out? -lh */
337 /* term_init = FALSE; */
339 return (NOTIFY_DONE);
342 #endif /* TERM_BODY */
346 TERM_TABLE_START(sun_driver)
347 "sun", "SunView window system",
348 SUN_XMAX, SUN_YMAX, SUN_VCHAR, SUN_HCHAR,
349 SUN_VTIC, SUN_HTIC, options_null, SUN_init, SUN_reset,
350 SUN_text, null_scale, SUN_graphics, SUN_move, SUN_vector,
351 SUN_linetype, SUN_put_text, null_text_angle,
352 SUN_justify_text, line_and_point, do_arrow, set_font_null
353 TERM_TABLE_END(sun_driver)
356 #define LAST_TERM sun_driver
358 #endif /* TERM_TABLE */
359 #endif /* TERM_PROTO_ONLY */
364 "?commands set terminal sun",
370 " The `sun` terminal driver supports the SunView window system. It has no",