home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / Gnuplot / Source / term / win.trm < prev    next >
Encoding:
Text File  |  1993-03-02  |  5.4 KB  |  233 lines

  1. /* GNUPLOT - term/win.trm */
  2. /*
  3.  * Copyright (C) 1992   Maurice Castro, Russell Lang
  4.  *
  5.  * Permission to use, copy, and distribute this software and its
  6.  * documentation for any purpose with or without fee is hereby granted, 
  7.  * provided that the above copyright notice appear in all copies and 
  8.  * that both that copyright notice and this permission notice appear 
  9.  * in supporting documentation.
  10.  *
  11.  * Permission to modify the software is granted, but not the right to
  12.  * distribute the modified code.  Modifications are to be distributed 
  13.  * as patches to released version.
  14.  *  
  15.  * This software is provided "as is" without express or implied warranty.
  16.  * 
  17.  *
  18.  * AUTHORS
  19.  * 
  20.  *   Gnuplot for Windows:
  21.  *       Maurice Castro, Russell Lang
  22.  * 
  23.  * Send your comments or suggestions to 
  24.  *  info-gnuplot@dartmouth.edu.
  25.  * This is a mailing list; to join it send a note to 
  26.  *  info-gnuplot-request@dartmouth.edu.  
  27.  * Send bug reports to
  28.  *  bug-gnuplot@dartmouth.edu.
  29.  */
  30.  
  31.  
  32. /* This file implements the terminal and printer display for gnuplot  */
  33. /* under Microsoft Windows. The code currently compiles only with the */
  34. /* Borland C++ 3.1 compiler.                                          */
  35. /*                                                                    */
  36. /* The modifications to allow Gnuplot to run under Windows were made  */
  37. /* by Maurice Castro (maurice@bruce.cs.monash.edu.au)                 */
  38. /* and Russell Lang (rjl@monu1.cc.monash.edu.au)         19 Nov 1992  */
  39. /*                                                                    */
  40.  
  41. /* Edit this file with tabstop=4 (vi :se ts=4)                        */
  42.  
  43. #include <windows.h>
  44. #include "../win/wgnuplib.h"
  45.  
  46. extern GW graphwin;
  47.  
  48. char win_prntmp[256];    /* printer temporary file */
  49.  
  50. /* Initialization values - Guess Now Scale later */
  51. #define WIN_XMAX (2400)
  52. #define WIN_YMAX (1800)
  53. #define WIN_HCHAR (WIN_XMAX/75) 
  54. #define WIN_VCHAR (WIN_YMAX/25)
  55. #define WIN_HTIC (WIN_XMAX/160)
  56. #define WIN_VTIC WIN_HTIC
  57.  
  58. /* Interface routines - create list of actions for Windows */
  59.  
  60. WIN_options()
  61. {
  62.     extern struct value *const_express();
  63.     extern double real();
  64.  
  65.     if (!END_OF_COMMAND) {
  66.         if (almost_equals(c_token,"d$efault")) {
  67.             graphwin.color=TRUE;
  68.             strcpy(graphwin.fontname,WINFONT);
  69.             graphwin.fontsize = WINFONTSIZE;
  70.             c_token++;
  71.         }
  72.     }
  73.  
  74.     if (!END_OF_COMMAND) {
  75.         if (almost_equals(c_token,"m$onochrome")) {
  76.             graphwin.color=FALSE;
  77.             c_token++;
  78.         }
  79.         else if (almost_equals(c_token,"c$olor")) {
  80.             graphwin.color=TRUE;
  81.             c_token++;
  82.         }
  83.     }
  84.  
  85.     if (!END_OF_COMMAND && isstring(c_token)) {
  86.         quote_str(graphwin.fontname,c_token);
  87.         c_token++;
  88.     }
  89.  
  90.     if (!END_OF_COMMAND) {
  91.         /* We have font size specified */
  92.         struct value a;
  93.         graphwin.fontsize = (int)real(const_express(&a));
  94.     }
  95.  
  96.     if (graphwin.fontname[0] == '\0')
  97.       sprintf(term_options,"%s", graphwin.color ? "color" :  "monochrome");
  98.     else
  99.       sprintf(term_options,"%s \"%s\" %d", graphwin.color ? "color" :  "monochrome" ,
  100.         graphwin.fontname, graphwin.fontsize);
  101.     if (IsWindow(graphwin.hWndGraph) && IsIconic(graphwin.hWndGraph)) {
  102.         ShowWindow(graphwin.hWndGraph, SW_SHOWNORMAL);
  103.     }
  104.     GraphRedraw(&graphwin);
  105. }
  106.  
  107. /* We don't actually do scaling, but we need to fix up the text size
  108.  * if the user has resized the window */
  109. int WIN_scale()
  110. {
  111.     term_tbl[term].h_char = graphwin.hchar;
  112.     term_tbl[term].v_char = graphwin.vchar;
  113.     sprintf(term_options,"%s \"%s\" %d", graphwin.color ? "color" :  "monochrome" ,
  114.         graphwin.fontname, graphwin.fontsize);
  115.     return FALSE ;    /* can't be done */
  116. }
  117.  
  118. WIN_init()
  119. {
  120.     if (!graphwin.hWndGraph) {
  121.         graphwin.xmax = WIN_XMAX;
  122.         graphwin.ymax = WIN_YMAX;
  123.         graphwin.htic = WIN_HTIC;
  124.         graphwin.vtic = WIN_VTIC;
  125.         GraphInit(&graphwin);
  126.         SetClassWord(graphwin.hWndGraph, GCW_HICON, LoadIcon(graphwin.hInstance, "grpicon"));
  127.         graphwin.resized = FALSE;
  128.     }
  129. }
  130.  
  131.  
  132. WIN_reset()
  133. {
  134. }
  135.  
  136. WIN_text()
  137. {
  138.     GraphEnd(&graphwin);
  139. }
  140.  
  141. WIN_graphics()
  142. {
  143.     GraphStart(&graphwin);
  144. }
  145.  
  146. WIN_move(x, y)
  147. unsigned int x, y;
  148. {
  149.     GraphOp(&graphwin, W_move, x, y, NULL);
  150. }
  151.  
  152. WIN_vector(x,y)
  153. unsigned int x, y;
  154. {
  155.     GraphOp(&graphwin, W_vect, x, y, NULL);
  156. }
  157.  
  158. WIN_linetype(lt)
  159. int lt;
  160. {
  161.     GraphOp(&graphwin, W_line_type, lt, 0, NULL);
  162. }
  163.  
  164. WIN_put_text(x,y,str)
  165. int x, y;
  166. char *str;
  167. {
  168.     GraphOp(&graphwin, W_put_text, x, y, str);
  169. }
  170.  
  171. int WIN_justify_text(mode)
  172. enum JUSTIFY mode;
  173. {
  174.     GraphOp(&graphwin, W_justify, mode, 0, NULL);
  175.     return(TRUE);
  176. }
  177.  
  178. int WIN_text_angle(ang)
  179. int ang;
  180. {
  181.     if (graphwin.rotate)
  182.         GraphOp(&graphwin, W_text_angle, ang, 0, NULL);
  183.     return graphwin.rotate;
  184. }
  185.  
  186. WIN_point(x,y,number)
  187. int x,y;
  188. int number;
  189. {
  190.     /* draw point shapes later to save memory */
  191.     graphwin.htic = term_tbl[term].h_tic / 2;     /* size of point symbols */
  192.     graphwin.vtic = term_tbl[term].v_tic / 2;
  193.     if (number>=0)
  194.         number %= POINT_TYPES;
  195.     number += 1;
  196.     GraphOp(&graphwin, W_dot + number, x, y, NULL);
  197. }
  198.  
  199.  
  200. /* Windows PRN emulation */
  201. FILE *
  202. open_printer()
  203. {
  204. char *temp;
  205.     if ((temp = getenv("TEMP")) == (char *)NULL)
  206.         *win_prntmp='\0';
  207.     else  {
  208.         strncpy(win_prntmp,temp,MAX_ID_LEN-1);
  209.         /* stop X's in path being converted by mktemp */
  210.         for (temp=win_prntmp; *temp; temp++)
  211.             *temp = tolower(*temp);
  212.         if ( strlen(win_prntmp) && (win_prntmp[strlen(win_prntmp)-1]!='\\') )
  213.             strcat(win_prntmp,"\\");
  214.     }
  215.     strncat(win_prntmp, "_gptmp",MAX_ID_LEN-strlen(win_prntmp));
  216.     strncat(win_prntmp, "XXXXXX",MAX_ID_LEN-strlen(win_prntmp));
  217.     mktemp(win_prntmp);
  218.     return fopen(win_prntmp, "w");
  219. }
  220.  
  221. void
  222. close_printer()
  223. {
  224.     fclose(outfile);
  225.     DumpPrinter(graphwin.hWndGraph, graphwin.Title, win_prntmp);
  226. }
  227.  
  228. void
  229. screen_dump(void)
  230. {
  231.     GraphPrint(&graphwin);
  232. }
  233.