2 * $Id: wxt.trm,v 1.17 2006/09/15 14:09:36 tlecomte Exp $
5 /* GNUPLOT - wxt.trm */
8 * Copyright 2005,2006 Timothee Lecomte
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.
37 /* ------------------------------------------------------
38 * Here you will find the terminal table, filled
39 * with C++ functions defined in wxt_gui.cpp,
40 * where the wxWidgets terminal is mainly implemented.
41 * See wxt_gui.cpp for details about this terminal.
42 * ------------------------------------------------------*/
49 TERM_PUBLIC void wxt_options __PROTO ((void));
50 #endif /* TERM_PROTO */
52 #ifndef TERM_PROTO_ONLY
56 #include "wxterminal/wxt_term.h"
57 /* for enhanced text mode */
58 #include "wxterminal/gp_cairo_term.h"
60 /* terminal state, defined extern in wxt_term.h */
61 int wxt_window_number = 0;
62 TBOOLEAN wxt_enhanced_enabled = FALSE;
63 int wxt_persist = UNSET;
64 int wxt_raise = UNSET;
66 /* default text font family: */
67 char wxt_set_fontname[MAX_ID_LEN + 1] = "";
68 /* default text size*/
69 int wxt_set_fontsize = 0;
71 char wxt_title[MAX_ID_LEN + 1] = "";
88 static struct gen_table wxt_opts[] = {
90 {"enh$anced", WXT_ENHANCED},
91 {"noenh$anced", WXT_NOENHANCED},
92 {"per$sist", WXT_PERSIST},
93 {"noper$sist", WXT_NOPERSIST},
94 {"rai$se", WXT_RAISE},
95 {"norai$se", WXT_NORAISE},
97 {"noct$rlq", WXT_NOCTRL},
98 {"ti$tle", WXT_TITLE},
99 {"cl$ose", WXT_CLOSE},
104 /* "Called when terminal type is selected. This procedure should parse options on the command line.
105 * A list of the currently selected options should be stored in term_options[],
106 * in a form suitable for use with the set term command.
107 * term_options[] is used by the save command. Use options_null() if no options are available." */
108 TERM_PUBLIC void wxt_options()
112 char *font_setting = NULL;
114 TBOOLEAN duplication = FALSE;
115 TBOOLEAN set_enhanced = FALSE, set_font = FALSE;
116 TBOOLEAN set_persist = FALSE, set_number = FALSE;
117 TBOOLEAN set_raise = FALSE, set_ctrl = FALSE;
118 TBOOLEAN set_title = FALSE, set_close = FALSE;
120 while (!END_OF_COMMAND) {
121 FPRINTF((stderr, "processing token\n"));
122 switch (lookup_table(&wxt_opts[0], c_token)) {
125 if (!(s = try_to_get_string()))
126 int_error(c_token,"font: expecting string");
128 strcpy (wxt_set_fontname, "");
129 wxt_set_fontsize = 0;
131 sep = strcspn(s,",");
133 strncpy(wxt_set_fontname, s, sep);
134 wxt_set_fontname[sep] = '\0';
137 sscanf(&(s[sep+1]), "%d", &wxt_set_fontsize);
139 font_setting = (char*) gp_alloc(strlen(s) + 1,"wxt font");
140 strcpy(font_setting,s);
142 if (set_font) duplication=TRUE;
147 wxt_enhanced_enabled = TRUE;
148 term->flags |= TERM_ENHANCED_TEXT;
149 if (set_enhanced) duplication=TRUE;
154 wxt_enhanced_enabled = FALSE;
155 term->flags &= ~TERM_ENHANCED_TEXT;
156 if (set_enhanced) duplication=TRUE;
162 if (set_persist) duplication=TRUE;
168 if (set_persist) duplication=TRUE;
174 if (set_raise) duplication=TRUE;
180 if (set_raise) duplication=TRUE;
186 if (set_ctrl) duplication=TRUE;
192 if (set_ctrl) duplication=TRUE;
197 if (!(s = try_to_get_string()))
198 int_error(c_token,"title: expecting string");
200 strncpy(wxt_title, s, sizeof(wxt_title));
202 if (set_title) duplication=TRUE;
207 if (set_close) duplication=TRUE;
212 wxt_window_number = (int) real(const_express(&a));
213 if (set_number) duplication=TRUE;
215 /*int_error(c_token, "unrecognized terminal option");*/
220 int_error(c_token-1, "Duplicated or contradicting arguments in wxt term options.");
223 /* Save options back into options string in normalized format */
224 snprintf(term_options, sizeof(term_options)-strlen(term_options),
225 "%d", wxt_window_number);
228 strncat(term_options, " title \"", sizeof(term_options)-strlen(term_options));
229 strncat(term_options, wxt_title, sizeof(term_options)-strlen(term_options));
230 strncat(term_options, "\"", sizeof(term_options)-strlen(term_options));
231 wxt_update_title(wxt_window_number);
235 strncat(term_options,
236 wxt_enhanced_enabled ? " enhanced" : " noenhanced",
237 sizeof(term_options)-strlen(term_options));
240 strncat(term_options, " font \"", sizeof(term_options)-strlen(term_options));
241 strncat(term_options, font_setting, sizeof(term_options)-strlen(term_options));
242 strncat(term_options, "\"", sizeof(term_options)-strlen(term_options));
247 strncat(term_options,
248 (wxt_persist==yes) ? " persist" : " nopersist",
249 sizeof(term_options)-strlen(term_options));
252 strncat(term_options,
253 (wxt_raise==yes) ? " raise" : " noraise",
254 sizeof(term_options)-strlen(term_options));
257 strncat(term_options,
258 (wxt_ctrl==yes) ? " ctrl" : " noctrl",
259 sizeof(term_options)-strlen(term_options));
262 wxt_close_terminal_window(wxt_window_number);
264 #endif /* TERM_BODY */
267 TERM_TABLE_START (wxt_driver)
268 "wxt", "wxWidgets cross-platform windowed terminal",
269 /* the following values are overriden by wxt_graphics */
270 1 /* xmax */ , 1 /* ymax */ , 1 /* vchar */ , 1 /* hchar */ ,
271 1 /* vtic */ , 1 /* htic */ ,
272 wxt_options, wxt_init, wxt_reset, wxt_text, null_scale, wxt_graphics,
273 wxt_move, wxt_vector, wxt_linetype, wxt_put_text,
274 wxt_text_angle, wxt_justify_text,
275 wxt_point, do_arrow, wxt_set_font,
276 wxt_pointsize, TERM_CAN_MULTIPLOT|TERM_NO_OUTPUTFILE,
277 wxt_text /* suspend */, 0 /* resume */, wxt_fillbox, wxt_linewidth
279 , wxt_waitforinput, wxt_put_tmptext, wxt_set_ruler, wxt_set_cursor, wxt_set_clipboard
281 , wxt_make_palette, 0 /* wxt_previous_palette */, wxt_set_color, wxt_filled_polygon
285 , gp_cairo_enhanced_open, gp_cairo_enhanced_flush, do_enh_writec
286 TERM_TABLE_END (wxt_driver)
289 #define LAST_TERM wxt_driver
291 #endif /* TERM_TABLE */
292 #endif /* TERM_PROTO_ONLY */
302 " The `wxt` terminal device generates output in a separate window. The window",
303 " is created by the wxWidgets library, where the 'wxt' comes from. The actual",
304 " drawing is done via cairo, a 2D graphics library, and pango, a library for",
305 " laying out and rendering text.",
308 " set term wxt {<n>}",
311 " {title \"title\"}",
317 " Multiple plot windows are supported: `set terminal wxt <n>` directs the",
318 " output to plot window number n.",
320 " The default window title is based on the window number. This title can also",
321 " be specified with the keyword \"title\".",
323 " Plot windows remain open even when the `gnuplot` driver is changed to a",
324 " different device. A plot window can be closed by pressing the letter 'q'",
325 " while that window has input focus, by choosing `close` from a window",
326 " manager menu, or with `set term wxt <n> close`.",
328 " When you resize a window, the plot is immediately scaled to fit in the",
329 " new size of the window. Unlike other interactive terminals, the `wxt`",
330 " terminal scales the whole plot, including fonts and linewidths, and keeps",
331 " its global aspect ratio constant, leaving an empty space painted in gray.",
332 " If you type `replot`, click the `replot` icon in the terminal toolbar or",
333 " type a new `plot` command, the new plot will completely fit in the window",
334 " and the font size and the linewidths will be reset to their defaults.",
336 " The active plot window (the one selected by `set term wxt <n>`) is",
337 " interactive. Its behaviour is shared with other terminal types. See `mouse`",
338 " for details. It also has some extra icons, which are supposed to be",
339 " self-explanatory.",
341 " This terminal supports an enhanced text mode, which allows font and other",
342 " formatting commands (subscripts, superscripts, etc.) to be embedded in labels",
343 " and other text strings. The enhanced text mode syntax is shared with other",
344 " gnuplot terminal types. See `enhanced` for more details.",
346 " <font> is in the format \"FontFace,FontSize\", i.e. the face and the size",
347 " comma-separated in a single string. FontFace is a usual font face name, such",
348 " as \'Arial\'. If you do not provide FontFace, the wxt terminal will use",
349 " \'Sans\'. FontSize is the font size, in points. If you do not provide it,",
350 " the wxt terminal will use a size of 10 points.",
352 " set term wxt font \"Arial,12\"",
353 " set term wxt font \"Arial\" # to change the font face only",
354 " set term wxt font \",12\" # to change the font size only",
355 " set term wxt font \"\" # to reset the font name and size",
357 " The fonts are retrieved from the usual fonts subsystems. Under Windows,",
358 " those fonts are to be found and configured in the entry \"Fonts\" of the",
359 " control panel. Under UNIX, they are handled by \"fontconfig\".",
361 " Pango, the library used to layout the text, is based on utf-8. Thus, the wxt",
362 " terminal has to convert from your encoding to utf-8. The default input",
363 " encoding is based on your \'locale\'. If you want to use another encoding,",
364 " make sure gnuplot knows which one you are using. See `encoding` for more",
367 " Pango may give unexpected results with fonts that do not respect the unicode",
368 " mapping. With the Symbol font, for example, the wxt terminal will use the map",
369 " provided by http://www.unicode.org/ to translate character codes to unicode.",
370 " Pango will do its best to find a font containing this character, looking for",
371 " your Symbol font, or other fonts with a broad unicode coverage, like the",
372 " DejaVu fonts. Note that \"the Symbol font\" is to be understood as the Adobe",
373 " Symbol font, distributed with Acrobat Reader as \"SY______.PFB\".",
374 " Alternatively, the OpenSymbol font, distributed with OpenOffice.org as",
375 " \"opens___.ttf\", offers the same characters. Microsoft has distributed a",
376 " Symbol font (\"symbol.ttf\"), but it has a different character set with",
377 " several missing or moved mathematic characters. If you experience problems",
378 " with your default setup (if the demo enhancedtext.dem is not displayed",
379 " properly for example), you probably have to install one of the Adobe or",
380 " OpenOffice Symbol fonts, and remove the Microsoft one.",
381 " Other non-conform fonts, such as \"wingdings\" have been observed working.",
383 " The rendering of the plot can be altered with a dialog available from the",
384 " toolbar. To obtain the best output possible, the rendering involves three",
385 " mechanisms : antialiasing, oversampling and hinting.",
386 " Antialiasing allows to display non-horizontal and non-vertical lines",
388 " Oversampling combined with antialiasing provides subpixel accuracy,",
389 " so that gnuplot can draw a line from non-integer coordinates. This avoids",
390 " wobbling effects on diagonal lines ('plot x' for example).",
391 " Hinting avoids the blur on horizontal and vertical lines caused by",
392 " oversampling. The terminal will snap these lines to integer coordinates so",
393 " that a one-pixel-wide line will actually be drawn on one and only one pixel.",
395 " By default, the window is raised to the top of your desktop when a plot is",
396 " drawn. This can be controlled with the keyword \"raise\".",
397 " The keyword \"persist\" will prevent gnuplot from exiting before you",
398 " explicitely close all the plot windows.",
399 " Finally, by default the key <space> raises the gnuplot console window, and",
400 " 'q' closes the plot window. The keyword \"ctrl\" allows you to replace those",
401 " bindings by <ctrl>+<space> and <ctrl>+'q', respectively.",
402 " These three keywords (raise, persist and ctrl) can also be set and remembered",
403 " between sessions through the configuration dialog."
405 #endif /* TERM_HELP */