ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/x10.c
(Generate patch)

Comparing ray/src/rt/x10.c (file contents):
Revision 1.17 by greg, Wed Oct 25 17:17:09 1989 UTC vs.
Revision 1.18 by greg, Mon Jan 8 13:38:41 1990 UTC

# Line 27 | Line 27 | static char SCCSid[] = "$SunId$ LBL";
27   #define GAMMA           2.2             /* exponent for color correction */
28  
29   #define BORWIDTH        5               /* border width */
30 #define BARHEIGHT       25              /* menu bar size */
30   #define COMHEIGHT       (COMLH*COMCH)   /* command line height (pixels) */
31 + #define MINWIDTH        (32*COMCW)      /* minimum graphics window width */
32 + #define MINHEIGHT       64              /* minimum graphics window height */
33  
34   #define COMFN           "8x13"          /* command line font name */
35   #define COMLH           3               /* number of command lines */
# Line 65 | Line 66 | static char  c_queue[64];              /* input queue */
66   static int  c_first = 0;                /* first character in queue */
67   static int  c_last = 0;                 /* last character in queue */
68  
69 < extern char  *malloc();
69 > extern char  *malloc(), *getcombuf();
70  
71   int  x_close(), x_clear(), x_paintr(), x_errout(),
72                  x_getcur(), x_comout(), x_comin();
73  
74   static struct driver  x_driver = {
75          x_close, x_clear, x_paintr, x_getcur,
76 <        x_comout, x_comin,
76 <        MAXRES, MAXRES
76 >        x_comout, x_comin, 1.0
77   };
78  
79  
# Line 97 | Line 97 | char  *name, *id;
97                          bcross_x_hot, bcross_y_hot,
98                          BlackPixel, WhitePixel, GXcopy);
99          clientname = id;
100 +        x_driver.xsiz = DisplayWidth()-(2*BORWIDTH);
101 +        x_driver.ysiz = DisplayHeight()-(COMHEIGHT+2*BORWIDTH);
102          x_driver.inpready = 0;
103          cmdvec = x_comout;                      /* set error vectors */
104          if (wrnvec != NULL)
# Line 133 | Line 135 | static
135   x_clear(xres, yres)                     /* clear our display */
136   int  xres, yres;
137   {
138 +        if (xres < MINWIDTH)
139 +                xres = MINWIDTH;
140 +        if (yres < MINHEIGHT)
141 +                yres = MINHEIGHT;
142          if (xres != gwidth || yres != gheight) {        /* new window */
143                  if (comline != NULL)
144                          xt_close(comline);
145                  if (gwind == 0) {
146 <                        gwind = XCreateWindow(RootWindow, 0, BARHEIGHT,
146 >                        gwind = XCreateWindow(RootWindow, 0, 0,
147                                          xres, yres+COMHEIGHT, BORWIDTH,
148                                          BlackPixmap, BlackPixmap);
149                          if (gwind == 0)
# Line 196 | Line 202 | char  *inp;
202   {
203          int  x_getc(), x_comout();
204  
205 +        if (fromcombuf(inp, &x_driver))
206 +                return;
207          xt_cursor(comline, TBLKCURS);
208          editline(inp, x_getc, x_comout);
209          xt_cursor(comline, TNOCURS);
# Line 317 | Line 325 | getevent()                     /* get next event */
325                  getkey(levptr(XKeyPressedEvent));
326                  break;
327          case ExposeWindow:
328 <                if (levptr(XExposeEvent)->subwindow == 0) {
329 <                        if (ncolors == 0 && getpixels() == 0) {
322 <                                stderr_v("cannot allocate colors\n");
323 <                                break;
324 <                        }
325 <                        new_ctab(ncolors);
326 <                }
327 <                /* fall through */
328 >                windowchange(levptr(XExposeEvent));
329 >                break;
330          case ExposeRegion:
331                  fixwindow(levptr(XExposeEvent));
332                  break;
# Line 339 | Line 341 | getevent()                     /* get next event */
341  
342  
343   static
344 + windowchange(eexp)                      /* process window change event */
345 + register XExposeEvent  *eexp;
346 + {
347 +        if (eexp->subwindow != 0) {
348 +                fixwindow(eexp);
349 +                return;
350 +        }
351 +                                        /* check for change in size */
352 +        if (eexp->width != gwidth || eexp->height != gheight+COMHEIGHT) {
353 +                x_driver.xsiz = eexp->width;
354 +                x_driver.ysiz = eexp->height;
355 +                strcpy(getcombuf(&x_driver), "new\n");
356 +                return;
357 +        }
358 +                                        /* remap colors */
359 +        if (ncolors == 0 && getpixels() == 0) {
360 +                stderr_v("cannot allocate colors\n");
361 +                return;
362 +        }
363 +        new_ctab(ncolors);
364 +                                        /* redraw */
365 +        fixwindow(eexp);
366 + }
367 +
368 +
369 + static
370   getkey(ekey)                            /* get input key */
371   register XKeyPressedEvent  *ekey;
372   {
# Line 357 | Line 385 | fixwindow(eexp)                                /* repair damage to window */
385   register XExposeEvent  *eexp;
386   {
387          if (eexp->subwindow == 0)
388 <                repaint(eexp->x, gheight - eexp->y - eexp->height,
388 >                sprintf(getcombuf(&x_driver), "repaint %d %d %d %d\n",
389 >                        eexp->x, gheight - eexp->y - eexp->height,
390                          eexp->x + eexp->width, gheight - eexp->y);
391          else if (eexp->subwindow == comline->w)
392                  xt_redraw(comline);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines