home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume21 / xfig / patch02p < prev    next >
Encoding:
Text File  |  1993-10-21  |  30.5 KB  |  1,062 lines

  1. Newsgroups: comp.sources.x
  2. From: envbvs@epb12.lbl.gov (Brian V. Smith)
  3. Subject: v21i036:  xfig - Draw amd manipulate objects in an X-Window, Patch02p/16
  4. Message-ID: <1993Oct21.190018.7794@sparky.sterling.com>
  5. X-Md4-Signature: 54dc4d1ca25f6d37f635320aeb08e3f2
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Thu, 21 Oct 1993 19:00:18 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: envbvs@epb12.lbl.gov (Brian V. Smith)
  12. Posting-number: Volume 21, Issue 36
  13. Archive-name: xfig/patch02p
  14. Environment: patch, X11, xfig
  15. Patch-To: xfig: Volume 19, Issue 113-139
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  xfig.11
  22. # Wrapped by chris@sparky on Thu Oct 21 13:40:08 1993
  23. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 16 (of 16)."'
  26. if test -f 'xfig.11' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'xfig.11'\"
  28. else
  29.   echo shar: Extracting \"'xfig.11'\" \(28014 characters\)
  30.   sed "s/^X//" >'xfig.11' <<'END_OF_FILE'
  31. X!     if(style.magnify!=1.) {
  32. X!     item->cols_in=old_cols_in;
  33. X!     item->rows_in=old_rows_in;
  34. X!     }
  35. X! 
  36. X! 
  37. X! #ifdef CACHE_BITMAPS
  38. X! 
  39. X!     /* create a bitmap to hold rotated text */
  40. X!     item->bitmap=XCreatePixmap(dpy, DefaultRootWindow(dpy),
  41. X!                    item->cols_out, item->rows_out, 1);
  42. X!     
  43. X!     /* make the text bitmap from XImage */
  44. X!     XPutImage(dpy, item->bitmap, font_gc, item->ximage, 0, 0, 0, 0,
  45. X!           item->cols_out, item->rows_out);
  46. X! 
  47. X!     XDestroyImage(item->ximage);
  48. X! 
  49. X! #endif /*CACHE_BITMAPS*/
  50. X! 
  51. X!     XFreeGC(dpy, font_gc);
  52. X!     XFreePixmap(dpy, canvas);
  53. X! 
  54. X!     return item;
  55. X  }
  56. X  
  57. X  
  58. X  /* ---------------------------------------------------------------------- */
  59. X  
  60. X  
  61. X! /**************************************************************************/
  62. X! /*  Adds a text item to the end of the cache, removing as many items      */
  63. X! /*      from the front as required to keep cache size below limit         */
  64. X! /**************************************************************************/
  65. X  
  66. X! static void XRotAddToLinkedList(dpy, item)
  67. X!     Display *dpy;
  68. X!     RotatedTextItem *item;
  69. X! {
  70. X!     
  71. X!     static long int current_size=0;
  72. X!     static RotatedTextItem *last=NULL;
  73. X!     RotatedTextItem *i1=first_text_item, *i2=NULL;
  74. X  
  75. X! #ifdef CACHE_BITMAPS
  76. X  
  77. X!     /* I don't know how much memory a pixmap takes in the server -
  78. X!            probably this + a bit more we can't account for */
  79. X  
  80. X!     item->size=((item->cols_out-1)/8+1)*item->rows_out;
  81. X  
  82. X! #else
  83. X  
  84. X!     /* this is pretty much the size of a RotatedTextItem */
  85. X  
  86. X!     item->size=((item->cols_out-1)/8+1)*item->rows_out +
  87. X!     sizeof(XImage) + strlen(item->text) + 
  88. X!         item->nl*8*sizeof(float) + sizeof(RotatedTextItem);
  89. X  
  90. X!     if(item->font_name!=NULL)
  91. X!     item->size+=strlen(item->font_name);
  92. X!     else
  93. X!     item->size+=sizeof(Font);
  94. X  
  95. X! #endif /*CACHE_BITMAPS */
  96. X  
  97. X!     /* count number of items in cache, for debugging */
  98. X!     if (appres.DEBUG) {
  99. X!     int i=0;
  100. X  
  101. X!     while(i1) {
  102. X!         i++;
  103. X!         i1=i1->next;
  104. X!     }
  105. X!     DEBUG_PRINT2("Cache has %d items.\n", i);
  106. X!     i1=first_text_item;
  107. X!     }
  108. X  
  109. X!     DEBUG_PRINT4("current cache size=%ld, new item=%ld, limit=%ld\n",
  110. X!          current_size, item->size, CACHE_SIZE_LIMIT*1024);
  111. X  
  112. X!     /* if this item is bigger than whole cache, forget it */
  113. X!     if(item->size>CACHE_SIZE_LIMIT*1024) {
  114. X!     DEBUG_PRINT1("Too big to cache\n\n");
  115. X!     item->cached=0;
  116. X!     return;
  117. X!     }
  118. X  
  119. X!     /* remove elements from cache as needed */
  120. X!     while(i1 && current_size+item->size>CACHE_SIZE_LIMIT*1024) {
  121. X  
  122. X!     DEBUG_PRINT2("Removed %d bytes\n", i1->size);
  123. X  
  124. X!     if(i1->font_name!=NULL)
  125. X!         DEBUG_PRINT5("  (`%s'\n   %s\n   angle=%f align=%d)\n",
  126. X!              i1->text, i1->font_name, i1->angle, i1->align);
  127. X  
  128. X! #ifdef CACHE_FID
  129. X!     if(i1->font_name==NULL)
  130. X!         DEBUG_PRINT5("  (`%s'\n  FID=%ld\n   angle=%f align=%d)\n",
  131. X!                          i1->text, i1->fid, i1->angle, i1->align);
  132. X! #endif /*CACHE_FID*/
  133. X  
  134. X!     current_size-=i1->size;
  135. X  
  136. X!     i2=i1->next;
  137. X! 
  138. X!     /* free resources used by the unlucky item */
  139. X!     XRotFreeTextItem(dpy, i1);
  140. X! 
  141. X!     /* remove it from linked list */
  142. X!     first_text_item=i2;
  143. X!     i1=i2;
  144. X!     }
  145. X! 
  146. X!     /* add new item to end of linked list */
  147. X!     if(first_text_item==NULL) {
  148. X!     item->next=NULL;
  149. X!     first_text_item=item;
  150. X!     last=item;
  151. X!     }
  152. X!     else {
  153. X!     item->next=NULL;
  154. X!     last->next=item;
  155. X!     last=item;
  156. X!     }
  157. X! 
  158. X!     /* new cache size */
  159. X!     current_size+=item->size;
  160. X! 
  161. X!     item->cached=1;
  162. X! 
  163. X!     DEBUG_PRINT1("Added item to cache.\n");
  164. X  }
  165. X! 
  166. X! 
  167. X  /* ---------------------------------------------------------------------- */
  168. X  
  169. X  
  170. X! /**************************************************************************/
  171. X! /*  Free the resources used by a text item                                */
  172. X! /**************************************************************************/
  173. X  
  174. X! static void XRotFreeTextItem(dpy, item)
  175. X!     Display *dpy;
  176. X!     RotatedTextItem *item;
  177. X  {
  178. X!     free(item->text);
  179. X! 
  180. X!     if(item->font_name!=NULL)
  181. X!     free(item->font_name);
  182. X! 
  183. X!     free((char *)item->corners_x);
  184. X!     free((char *)item->corners_y);
  185. X! 
  186. X! #ifdef CACHE_BITMAPS
  187. X!     XFreePixmap(dpy, item->bitmap);
  188. X! #else
  189. X!     XDestroyImage(item->ximage);
  190. X! #endif /* CACHE_BITMAPS */
  191. X! 
  192. X!     free((char *)item);
  193. X  }
  194. X  
  195. X  
  196. X***************
  197. X*** 609,782 ****
  198. X  /* ---------------------------------------------------------------------- */
  199. X  
  200. X  
  201. X! /* *** A front end to XRotPaintAlignedString : uses XRotDrawImageString *** */
  202. X  
  203. X! void XRotDrawAlignedImageString(dpy, drawable, rotfont, gc, x, y,
  204. X!                                   text, align)
  205. X!  Display *dpy;
  206. X!  Drawable drawable;  
  207. X!  XRotFontStruct *rotfont;
  208. X!  GC gc;
  209. X!  int x, y;
  210. X!  char *text;
  211. X!  int align;
  212. X  {
  213. X!  XRotPaintAlignedString(dpy, drawable, rotfont, gc, x, y, text, align, 1);
  214. X! }
  215. X  
  216. X  
  217. X! /* ---------------------------------------------------------------------- */
  218. X!                    
  219. X!                    
  220. X! /* *** Routine to paint a string, possibly containing newline characters,
  221. X!                                                        with alignment *** */
  222. X  
  223. X! /* *** The user should use one of the front ends above *** */
  224. X  
  225. X! void XRotPaintAlignedString(dpy, drawable, rotfont, gc, x, y, text,
  226. X!                             align, paintbg)
  227. X!  Display *dpy;
  228. X!  Drawable drawable;
  229. X!  XRotFontStruct *rotfont;
  230. X!  GC gc;
  231. X!  int x, y;
  232. X!  char *text;
  233. X!  int align;
  234. X!  int paintbg;
  235. X! {  
  236. X!  int xp, yp, dir;
  237. X!  int i, nl=1, max_width=0, this_width;
  238. X!  char *str1, *str2="\n\0", *str3;
  239. X  
  240. X!  if(text==NULL) return;
  241. X!   
  242. X!  dir=rotfont->dir;
  243. X  
  244. X!  /* count number of sections in string ... */
  245. X!  for(i=0; i<strlen(text); i++) if(text[i]=='\n') nl++;
  246. X  
  247. X!  /* find width of longest section ... */
  248. X!  str1=my_strdup(text);
  249. X!  str3=my_strtok(str1, str2);
  250. X!  max_width=XRotTextWidth(rotfont, str3, strlen(str3));
  251. X  
  252. X!  do
  253. X!   { str3=my_strtok((char *)NULL, str2);
  254. X!     if(str3)
  255. X!       max_width=XROTMAX(max_width,
  256. X!                         XRotTextWidth(rotfont, str3, strlen(str3))); }
  257. X!  while(str3!=NULL);
  258. X!  
  259. X!  /* calculate vertical starting point according to alignment policy and
  260. X!       rotation angle ... */
  261. X!  if(dir==0)
  262. X!  { if((align==TLEFT)||(align==TCENTRE)||(align==TRIGHT))
  263. X!      yp=y+rotfont->max_ascent;
  264. X  
  265. X!   else if((align==BLEFT)||(align==BCENTRE)||(align==BRIGHT))
  266. X!      yp=y-(nl-1)*rotfont->height - rotfont->max_descent;
  267. X  
  268. X!   else 
  269. X!      yp=y-(nl-1)/2*rotfont->height + rotfont->max_ascent -rotfont->height/2 -
  270. X!                          ( (nl%2==0)?rotfont->height/2:0 ); }
  271. X  
  272. X!  else if(dir==1)
  273. X!  { if((align==TLEFT)||(align==TCENTRE)||(align==TRIGHT))
  274. X!      xp=x+rotfont->max_ascent;
  275. X  
  276. X!    else if((align==BLEFT)||(align==BCENTRE)||(align==BRIGHT))
  277. X!      xp=x-(nl-1)*rotfont->height - rotfont->max_descent;
  278. X  
  279. X!    else 
  280. X!      xp=x-(nl-1)/2*rotfont->height + rotfont->max_ascent -rotfont->height/2 -
  281. X!                          ( (nl%2==0)?rotfont->height/2:0 ); }
  282. X  
  283. X!  else if(dir==2)
  284. X!  { if((align==TLEFT)||(align==TCENTRE)||(align==TRIGHT))
  285. X!      yp=y-rotfont->max_ascent;
  286. X!      
  287. X!    else if((align==BLEFT)||(align==BCENTRE)||(align==BRIGHT))
  288. X!      yp=y+(nl-1)*rotfont->height + rotfont->max_descent;
  289. X!      
  290. X!    else 
  291. X!      yp=y+(nl-1)/2*rotfont->height - rotfont->max_ascent +rotfont->height/2 +
  292. X!                          ( (nl%2==0)?rotfont->height/2:0 ); }
  293. X  
  294. X!  else
  295. X!  { if((align==TLEFT)||(align==TCENTRE)||(align==TRIGHT))
  296. X!      xp=x-rotfont->max_ascent;
  297. X      
  298. X!    else if((align==BLEFT)||(align==BCENTRE)||(align==BRIGHT))
  299. X!      xp=x+(nl-1)*rotfont->height + rotfont->max_descent;
  300. X!   
  301. X!    else 
  302. X!      xp=x+(nl-1)/2*rotfont->height - rotfont->max_ascent +rotfont->height/2 +
  303. X!                          ( (nl%2==0)?rotfont->height/2:0 ); }
  304. X  
  305. X!  str1=my_strdup(text);
  306. X!  str3=my_strtok(str1, str2);
  307. X!   
  308. X!  /* loop through each section in the string ... */
  309. X!  do
  310. X!  {
  311. X!   /* width of this section ... */
  312. X!   this_width=XRotTextWidth(rotfont, str3, strlen(str3));
  313. X  
  314. X-   /* horizontal alignment ... */
  315. X-   if(dir==0)
  316. X-   { if((align==TLEFT)||(align==MLEFT)||(align==BLEFT))
  317. X-       xp=x;
  318. X-   
  319. X-     else if((align==TCENTRE)||(align==MCENTRE)||(align==BCENTRE))
  320. X-       xp=x-this_width/2;
  321. X-  
  322. X-     else 
  323. X-       xp=x-max_width; }
  324. X  
  325. X-   else if(dir==1)
  326. X-   { if((align==TLEFT)||(align==MLEFT)||(align==BLEFT))
  327. X-       yp=y;
  328. X  
  329. X!     else if((align==TCENTRE)||(align==MCENTRE)||(align==BCENTRE))
  330. X!       yp=y+this_width/2;
  331. X  
  332. X-     else 
  333. X-       yp=y+max_width; }
  334. X  
  335. X!   else if(dir==2)
  336. X!   { if((align==TLEFT)||(align==MLEFT)||(align==BLEFT))
  337. X!       xp=x;
  338. X!   
  339. X!     else if((align==TCENTRE)||(align==MCENTRE)||(align==BCENTRE))
  340. X!       xp=x+this_width/2;
  341. X!  
  342. X!     else 
  343. X!       xp=x+max_width; }
  344. X  
  345. X!   else
  346. X!   { if((align==TLEFT)||(align==MLEFT)||(align==BLEFT))  
  347. X!       yp=y;
  348. X!      
  349. X!     else if((align==TCENTRE)||(align==MCENTRE)||(align==BCENTRE))
  350. X!       yp=y-this_width/2;
  351. X!      
  352. X!     else 
  353. X!       yp=y-max_width; }
  354. X  
  355. X!   /* draw the section ... */
  356. X!   if(!paintbg)  XRotDrawString(dpy, drawable, rotfont, gc, xp, yp,
  357. X!                                str3, strlen(str3));
  358. X!   else          XRotDrawImageString(dpy, drawable, rotfont, gc, xp, yp, 
  359. X!                                str3, strlen(str3));  
  360. X  
  361. X!   str3=my_strtok((char *)NULL, str2);
  362. X  
  363. X!   /* advance position ... */
  364. X!   if(dir==0)      yp+=rotfont->height;
  365. X!   else if(dir==1) xp+=rotfont->height;
  366. X!   else if(dir==2) yp-=rotfont->height;
  367. X!   else            xp-=rotfont->height;
  368. X!  }
  369. X!  while(str3!=NULL);
  370. X  }
  371. X  
  372. X--- 1311,1562 ----
  373. X  /* ---------------------------------------------------------------------- */
  374. X  
  375. X  
  376. X! /**************************************************************************/
  377. X! /* Magnify an XImage using bilinear interpolation                         */
  378. X! /**************************************************************************/
  379. X  
  380. X! static XImage *XRotMagnifyImage(dpy, ximage)
  381. X!     Display *dpy;
  382. X!     XImage *ximage;
  383. X  {
  384. X!     int i, j;
  385. X!     float x, y;
  386. X!     float u,t;
  387. X!     XImage *I_out;
  388. X!     int cols_in, rows_in;
  389. X!     int cols_out, rows_out;
  390. X!     register int i2, j2;
  391. X!     float z1, z2, z3, z4;
  392. X!     int byte_width_in, byte_width_out;
  393. X!     float mag_inv;
  394. X  
  395. X+     /* size of input image */
  396. X+     cols_in=ximage->width;
  397. X+     rows_in=ximage->height;
  398. X  
  399. X!     /* size of final image */
  400. X!     cols_out=(float)cols_in*style.magnify;
  401. X!     rows_out=(float)rows_in*style.magnify;
  402. X  
  403. X!     /* this will hold final image */
  404. X!     I_out=MakeXImage(dpy, cols_out, rows_out);
  405. X!     if(I_out==NULL)
  406. X!     return NULL;
  407. X  
  408. X!     /* width in bytes of input, output images */
  409. X!     byte_width_in=(cols_in-1)/8+1;
  410. X!     byte_width_out=(cols_out-1)/8+1;
  411. X  
  412. X!     /* for speed */
  413. X!     mag_inv=1./style.magnify;
  414. X  
  415. X!     y=0.;
  416. X  
  417. X!     /* loop over magnified image */
  418. X!     for(j2=0; j2<rows_out; j2++) {
  419. X!     x=0;
  420. X!     j=y;
  421. X  
  422. X!     for(i2=0; i2<cols_out; i2++) {
  423. X!         i=x;
  424. X  
  425. X!         /* bilinear interpolation - where are we on bitmap ? */
  426. X!         /* right edge */
  427. X!         if(i==cols_in-1 && j!=rows_in-1) {
  428. X!         t=0;
  429. X!         u=y-(float)j;
  430. X  
  431. X!         z1=(ximage->data[j*byte_width_in+i/8] & 128>>(i%8))>0;
  432. X!         z2=z1;
  433. X!         z3=(ximage->data[(j+1)*byte_width_in+i/8] & 128>>(i%8))>0;
  434. X!         z4=z3;
  435. X!         }
  436. X!         /* top edge */
  437. X!         else if(i!=cols_in-1 && j==rows_in-1) {
  438. X!         t=x-(float)i;
  439. X!         u=0;
  440. X  
  441. X!         z1=(ximage->data[j*byte_width_in+i/8] & 128>>(i%8))>0;
  442. X!         z2=(ximage->data[j*byte_width_in+(i+1)/8] & 128>>((i+1)%8))>0;
  443. X!         z3=z2;
  444. X!         z4=z1;
  445. X!         }
  446. X!         /* top right corner */
  447. X!         else if(i==cols_in-1 && j==rows_in-1) {
  448. X!         u=0;
  449. X!         t=0;
  450. X  
  451. X!         z1=(ximage->data[j*byte_width_in+i/8] & 128>>(i%8))>0;
  452. X!         z2=z1;
  453. X!         z3=z1;
  454. X!         z4=z1;
  455. X!         }
  456. X!         /* somewhere `safe' */
  457. X!         else {
  458. X!         t=x-(float)i;
  459. X!         u=y-(float)j;
  460. X  
  461. X!         z1=(ximage->data[j*byte_width_in+i/8] & 128>>(i%8))>0;
  462. X!         z2=(ximage->data[j*byte_width_in+(i+1)/8] & 128>>((i+1)%8))>0;
  463. X!         z3=(ximage->data[(j+1)*byte_width_in+(i+1)/8] &
  464. X!             128>>((i+1)%8))>0;
  465. X!         z4=(ximage->data[(j+1)*byte_width_in+i/8] & 128>>(i%8))>0;
  466. X!         }
  467. X  
  468. X!         /* if interpolated value is greater than 0.5, set bit */
  469. X!         if(((1-t)*(1-u)*z1 + t*(1-u)*z2 + t*u*z3 + (1-t)*u*z4)>0.5)
  470. X!         I_out->data[j2*byte_width_out+i2/8]|=128>>i2%8;
  471. X  
  472. X!         x+=mag_inv;
  473. X!     }
  474. X!     y+=mag_inv;
  475. X!     }
  476. X      
  477. X!     /* destroy original */
  478. X!     XDestroyImage(ximage);
  479. X  
  480. X!     /* return big image */
  481. X!     return I_out;
  482. X! }
  483. X  
  484. X  
  485. X  
  486. X! /* ---------------------------------------------------------------------- */
  487. X  
  488. X  
  489. X! /**************************************************************************/
  490. X! /* Calculate the bounding box some text will have when painted            */
  491. X! /**************************************************************************/
  492. X  
  493. X! XPoint *XRotTextExtents(dpy, font, angle, x, y, text, align)
  494. X!     Display *dpy;
  495. X!     XFontStruct *font;
  496. X!     float angle;
  497. X!     int x, y;
  498. X!     char *text;
  499. X!     int align;
  500. X! {
  501. X!     register int i;
  502. X!     char *str1, *str2, *str3;
  503. X!     char *str2_a="\0", *str2_b="\n\0";
  504. X!     int height;
  505. X!     float sin_angle, cos_angle;
  506. X!     int nl, max_width;
  507. X!     int cols_in, rows_in;
  508. X!     float hot_x, hot_y;
  509. X!     XPoint *xp_in, *xp_out;
  510. X!     int dir, asc, desc;
  511. X!     XCharStruct overall;
  512. X!     
  513. X!     /* manipulate angle to 0<=angle<2*PI radians */
  514. X!     while(angle<0.0)
  515. X!         angle+=M_2PI;
  516. X!     
  517. X!     while(angle>=M_2PI)
  518. X!         angle-=M_2PI;
  519. X!     
  520. X!     /* count number of sections in string */
  521. X!     nl=1;
  522. X!     if(align!=NONE)
  523. X!     for(i=0; i<strlen(text)-1; i++)
  524. X!         if(text[i]=='\n')
  525. X!         nl++;
  526. X!     
  527. X!     /* ignore newline characters if not doing alignment */
  528. X!     if(align==NONE)
  529. X!     str2=str2_a;
  530. X!     else
  531. X!     str2=str2_b;
  532. X!     
  533. X!     /* find width of longest section */
  534. X!     str1=my_strdup(text);
  535. X!     if(str1==NULL)
  536. X!     return NULL;
  537. X!     
  538. X!     str3=my_strtok(str1, str2);
  539. X  
  540. X!     XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc,
  541. X!          &overall);
  542. X  
  543. X!     max_width=overall.rbearing;
  544. X!     
  545. X!     /* loop through each section */
  546. X!     do {
  547. X!     str3=my_strtok((char *)NULL, str2);
  548. X  
  549. X!     if(str3!=NULL) {
  550. X!         XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc,
  551. X!              &overall);
  552. X! 
  553. X!         if(overall.rbearing>max_width)
  554. X!         max_width=overall.rbearing;
  555. X!     }
  556. X!     }
  557. X!     while(str3!=NULL);
  558. X!     
  559. X!     free(str1);
  560. X!     
  561. X!     /* overall font height */
  562. X!     height=font->ascent+font->descent;
  563. X!     
  564. X!     /* dimensions horizontal text will have */
  565. X!     cols_in=max_width;
  566. X!     rows_in=nl*height;
  567. X!     
  568. X!     /* pre-calculate sin and cos */
  569. X!     sin_angle=sin(angle);
  570. X!     cos_angle=cos(angle);
  571. X!     
  572. X!     /* y position */
  573. X!     if(align==TLEFT || align==TCENTRE || align==TRIGHT)
  574. X!         hot_y=(float)rows_in/2*style.magnify;
  575. X!     else if(align==MLEFT || align==MCENTRE || align==MRIGHT)
  576. X!     hot_y=0;
  577. X!     else if(align==BLEFT || align==BCENTRE || align==BRIGHT)
  578. X!     hot_y= -(float)rows_in/2*style.magnify;
  579. X!     else
  580. X!     hot_y= -((float)rows_in/2-(float)font->descent)*style.magnify;
  581. X!     
  582. X!     /* x position */
  583. X!     if(align==TLEFT || align==MLEFT || align==BLEFT || align==NONE)
  584. X!     hot_x= -(float)max_width/2*style.magnify;
  585. X!     else if(align==TCENTRE || align==MCENTRE || align==BCENTRE)
  586. X!     hot_x=0;
  587. X!     else
  588. X!         hot_x=(float)max_width/2*style.magnify;
  589. X!     
  590. X!     /* reserve space for XPoints */
  591. X!     xp_in=(XPoint *)malloc((unsigned)(5*sizeof(XPoint)));
  592. X!     if(!xp_in)
  593. X!     return NULL;
  594. X! 
  595. X!     xp_out=(XPoint *)malloc((unsigned)(5*sizeof(XPoint)));
  596. X!     if(!xp_out)
  597. X!     return NULL;
  598. X! 
  599. X!     /* bounding box when horizontal, relative to bitmap centre */
  600. X!     xp_in[0].x= -(float)cols_in*style.magnify/2-style.bbx_pad;
  601. X!     xp_in[0].y= (float)rows_in*style.magnify/2+style.bbx_pad;
  602. X!     xp_in[1].x= (float)cols_in*style.magnify/2+style.bbx_pad;
  603. X!     xp_in[1].y= (float)rows_in*style.magnify/2+style.bbx_pad;
  604. X!     xp_in[2].x= (float)cols_in*style.magnify/2+style.bbx_pad;
  605. X!     xp_in[2].y= -(float)rows_in*style.magnify/2-style.bbx_pad;
  606. X!     xp_in[3].x= -(float)cols_in*style.magnify/2-style.bbx_pad;
  607. X!     xp_in[3].y= -(float)rows_in*style.magnify/2-style.bbx_pad;
  608. X!     xp_in[4].x=xp_in[0].x;
  609. X!     xp_in[4].y=xp_in[0].y;
  610. X!     
  611. X!     /* rotate and translate bounding box */
  612. X!     for(i=0; i<5; i++) {
  613. X!     xp_out[i].x=(float)x + ( ((float)xp_in[i].x-hot_x)*cos_angle +
  614. X!                  ((float)xp_in[i].y+hot_y)*sin_angle);
  615. X!     xp_out[i].y=(float)y + (-((float)xp_in[i].x-hot_x)*sin_angle +
  616. X!                  ((float)xp_in[i].y+hot_y)*cos_angle);
  617. X!     }
  618. X! 
  619. X!     free((char *)xp_in);
  620. X! 
  621. X!     return xp_out;
  622. X  }
  623. X+ 
  624. X  
  625. Xdiff -rc xfig.2.1.7a/w_rottext.h xfig.2.1.8/w_rottext.h
  626. X*** xfig.2.1.7a/w_rottext.h    Wed Dec  9 17:36:44 1992
  627. X--- xfig.2.1.8/w_rottext.h    Mon Aug 23 09:21:38 1993
  628. X***************
  629. X*** 1,73 ****
  630. X! /*
  631. X!  * FIG : Facility for Interactive Generation of figures
  632. X!  * Copyright (c) 1992 by Alan Richardson
  633. X!  *
  634. X!  * "Permission to use, copy, modify, distribute, and sell this software and its
  635. X!  * documentation for any purpose is hereby granted without fee, provided that
  636. X!  * the above copyright notice appear in all copies and that both the copyright
  637. X!  * notice and this permission notice appear in supporting documentation. 
  638. X!  * No representations are made about the suitability of this software for 
  639. X!  * any purpose.  It is provided "as is" without express or implied warranty."
  640. X!  */
  641. X  
  642. X- #define TLEFT     1
  643. X- #define TCENTRE     2
  644. X- #define TRIGHT     3
  645. X- #define MLEFT     4
  646. X- #define MCENTRE     5
  647. X- #define MRIGHT     6
  648. X- #define BLEFT     7
  649. X- #define BCENTRE     8
  650. X- #define BRIGHT     9
  651. X  
  652. X  
  653. X! /* ---------------------------------------------------------------------- */
  654. X  
  655. X  
  656. X! /* *** The font structures *** */
  657. X  
  658. X! typedef struct
  659. X! { int         bit_w;
  660. X!   int         bit_h;
  661. X  
  662. X-   Pixmap     bm;         } BitmapStruct;
  663. X  
  664. X! typedef struct
  665. X! { int         ascent;
  666. X!   int         descent;
  667. X!   int          lbearing;
  668. X!   int         rbearing;
  669. X!   int         width;
  670. X  
  671. X-   BitmapStruct     glyph;        } XRotCharStruct;
  672. X  
  673. X! typedef struct
  674. X! { int         dir;
  675. X!   int         height;    /* max_ascent+max_descent */
  676. X!   int         width;        /* max_bounds.width from XFontStruct */
  677. X!   int         max_ascent;
  678. X!   int         max_descent;
  679. X!   int         max_char;
  680. X!   int         min_char;
  681. X!   char        *name;
  682. X  
  683. X-   XFontStruct    *xfontstruct;
  684. X  
  685. X!   XRotCharStruct per_char[95];    } XRotFontStruct;
  686. X  
  687. X  
  688. X  /* ---------------------------------------------------------------------- */
  689. X  
  690. X  
  691. X! extern XRotFontStruct         *XRotLoadFont();
  692. X! extern void                       XRotUnloadFont();
  693. X! extern int                        XRotTextWidth();
  694. X! extern int                        XRotTextHeight();
  695. X! extern void                       XRotDrawString();
  696. X! extern void                       XRotDrawImageString();
  697. X! extern void                       XRotDrawAlignedString();
  698. X! extern void                       XRotDrawAlignedImageString();
  699. X  
  700. X  
  701. X  
  702. X  
  703. X--- 1,79 ----
  704. X! /* ************************************************************************ */
  705. X  
  706. X  
  707. X+ /* Header file for the `xvertext 5.0' routines.
  708. X  
  709. X!    Copyright (c) 1993 Alan Richardson (mppa3@uk.ac.sussex.syma) */
  710. X  
  711. X  
  712. X! /* ************************************************************************ */
  713. X  
  714. X! #ifndef _XVERTEXT_INCLUDED_ 
  715. X! #define _XVERTEXT_INCLUDED_
  716. X  
  717. X  
  718. X! #define XV_VERSION      5.0
  719. X! #define XV_COPYRIGHT \
  720. X!       "xvertext routines Copyright (c) 1993 Alan Richardson"
  721. X  
  722. X  
  723. X! /* ---------------------------------------------------------------------- */
  724. X  
  725. X  
  726. X! /* text alignment */
  727. X  
  728. X+ #define NONE             0
  729. X+ #define TLEFT            1
  730. X+ #define TCENTRE          2
  731. X+ #define TRIGHT           3
  732. X+ #define MLEFT            4
  733. X+ #define MCENTRE          5
  734. X+ #define MRIGHT           6
  735. X+ #define BLEFT            7
  736. X+ #define BCENTRE          8
  737. X+ #define BRIGHT           9
  738. X  
  739. X+ 
  740. X  /* ---------------------------------------------------------------------- */
  741. X  
  742. X+ /* this shoulf be C++ compliant, thanks to 
  743. X+      vlp@latina.inesc.pt (Vasco Lopes Paulo) */
  744. X  
  745. X! #if defined(__cplusplus) || defined(c_plusplus)
  746. X  
  747. X+ extern "C" {
  748. X+ float   XRotVersion(char*, int);
  749. X+ void    XRotSetMagnification(float);
  750. X+ void    XRotSetBoundingBoxPad(int);
  751. X+ int     XRotDrawString(Display*, XFontStruct*, float,
  752. X+                        Drawable, GC, int, int, char*);
  753. X+ int     XRotDrawImageString(Display*, XFontStruct*, float,
  754. X+                             Drawable, GC, int, int, char*);
  755. X+ int     XRotDrawAlignedString(Display*, XFontStruct*, float,
  756. X+                               Drawable, GC, int, int, char*, int);
  757. X+ int     XRotDrawAlignedImageString(Display*, XFontStruct*, float,
  758. X+                                    Drawable, GC, int, int, char*, int);
  759. X+ XPoint *XRotTextExtents(Display*, XFontStruct*, float,
  760. X+             int, int, char*, int);
  761. X+ }
  762. X+ 
  763. X+ #else
  764. X+ 
  765. X+ extern float   XRotVersion();
  766. X+ extern void    XRotSetMagnification();
  767. X+ extern void    XRotSetBoundingBoxPad();
  768. X+ extern int     XRotDrawString();
  769. X+ extern int     XRotDrawImageString();
  770. X+ extern int     XRotDrawAlignedString();
  771. X+ extern int     XRotDrawAlignedImageString();
  772. X+ extern XPoint *XRotTextExtents();
  773. X+ 
  774. X+ #endif /* __cplusplus */
  775. X+ 
  776. X+ /* ---------------------------------------------------------------------- */
  777. X+ 
  778. X+ 
  779. X+ #endif /* _XVERTEXT_INCLUDED_ */
  780. X  
  781. X  
  782. X  
  783. Xdiff -rc xfig.2.1.7a/w_rulers.c xfig.2.1.8/w_rulers.c
  784. X*** xfig.2.1.7a/w_rulers.c    Fri Mar 19 16:19:42 1993
  785. X--- xfig.2.1.8/w_rulers.c    Tue Aug 31 14:00:52 1993
  786. X***************
  787. X*** 226,233 ****
  788. X      {"SetUnit", (XtActionProc) unit_panel_set},
  789. X  };
  790. X  
  791. X! static Widget    unit_popup, form, cancel, set, beside, below, newvalue,
  792. X!         label;
  793. X  
  794. X  /* handle unit/scale settings */
  795. X  
  796. X--- 226,232 ----
  797. X      {"SetUnit", (XtActionProc) unit_panel_set},
  798. X  };
  799. X  
  800. X! static Widget    unit_popup, form, cancel, set, beside, below, label;
  801. X  
  802. X  /* handle unit/scale settings */
  803. X  
  804. X***************
  805. X*** 252,258 ****
  806. X      XButtonEvent   *ev;
  807. X  {
  808. X      int old_rul_unit;
  809. X-     char        buf[32];
  810. X  
  811. X      old_rul_unit = appres.INCHES;
  812. X      appres.INCHES = rul_unit_setting ? 1 : 0;
  813. X--- 251,256 ----
  814. X***************
  815. X*** 276,283 ****
  816. X          appres.INCHES ? "in" : "cm", appres.user_scale);
  817. X      }
  818. X  
  819. X!     if (old_rul_unit != appres.INCHES)
  820. X      reset_rulers();
  821. X      unit_panel_dismiss();
  822. X  }
  823. X  
  824. X--- 274,285 ----
  825. X          appres.INCHES ? "in" : "cm", appres.user_scale);
  826. X      }
  827. X  
  828. X!     if (old_rul_unit != appres.INCHES) {
  829. X!     /* change the label in the widget */
  830. X!     FirstArg(XtNlabel, appres.INCHES ? "in" : "cm");
  831. X!     SetValues(unitbox_sw);
  832. X      reset_rulers();
  833. X+     }
  834. X      unit_panel_dismiss();
  835. X  }
  836. X  
  837. Xdiff -rc xfig.2.1.7a/w_setup.c xfig.2.1.8/w_setup.c
  838. X*** xfig.2.1.7a/w_setup.c    Fri Feb 19 14:16:05 1993
  839. X--- xfig.2.1.8/w_setup.c    Tue Jul 20 09:32:19 1993
  840. X***************
  841. X*** 15,20 ****
  842. X--- 15,22 ----
  843. X  #include "w_setup.h"
  844. X  #include "w_util.h"
  845. X  
  846. X+ #define    NUM_DRAW_SW 16 /* kludge - shouldn't have to edit this by hand */
  847. X+ 
  848. X  int        TOOL_WD, TOOL_HT;
  849. X  int        CMDPANEL_WD, CMDPANEL_HT = 22;
  850. X  int        MODEPANEL_WD, MODEPANEL_HT;
  851. X***************
  852. X*** 68,77 ****
  853. X      if (CMDPANEL_WD < 5 * NUM_CMD_SW)
  854. X      CMDPANEL_WD = 5 * NUM_CMD_SW;
  855. X      MSGFORM_WD = CMDPANEL_WD;
  856. X! 
  857. X!     MODEPANEL_SPACE = CANVAS_HT + RULER_WD -
  858. X!     SW_PER_COL * (MODE_SW_HT + INTERNAL_BW);
  859. X      if (MODEPANEL_SPACE < 2)
  860. X      MODEPANEL_SPACE = 2;
  861. X-     INDPANEL_WD = MODEPANEL_WD + CANVAS_WD + SIDERULER_WD + INTERNAL_BW*2;
  862. X  }
  863. X--- 70,79 ----
  864. X      if (CMDPANEL_WD < 5 * NUM_CMD_SW)
  865. X      CMDPANEL_WD = 5 * NUM_CMD_SW;
  866. X      MSGFORM_WD = CMDPANEL_WD;
  867. X!     INDPANEL_WD = MODEPANEL_WD + CANVAS_WD + SIDERULER_WD + INTERNAL_BW*2;
  868. X!     MODEPANEL_SPACE = CANVAS_HT + RULER_WD - (MODE_SW_HT + INTERNAL_BW) *
  869. X!     (ceil((double)NUM_DRAW_SW/SW_PER_ROW) +
  870. X!     ceil((double)(NUM_MODE_SW-NUM_DRAW_SW)/SW_PER_ROW));
  871. X      if (MODEPANEL_SPACE < 2)
  872. X      MODEPANEL_SPACE = 2;
  873. X  }
  874. Xdiff -rc xfig.2.1.7a/w_setup.h xfig.2.1.8/w_setup.h
  875. X*** xfig.2.1.7a/w_setup.h    Thu Feb 11 14:55:52 1993
  876. X--- xfig.2.1.8/w_setup.h    Fri Jun 18 18:07:32 1993
  877. X***************
  878. X*** 33,46 ****
  879. X  
  880. X  #define        MAXDEPTH        999
  881. X  
  882. X- #define        SW_PER_ROW_PORT 2    /* switches/row in mode panel */
  883. X- #define        SW_PER_ROW_LAND 2    /* same for landscape mode */
  884. X- #define        SW_PER_COL_PORT 17
  885. X- #define        SW_PER_COL_LAND 17
  886. X- 
  887. X  #define        MODE_SW_HT    32    /* height of a mode switch icon */
  888. X  #define        MODE_SW_WD    36    /* width of a mode switch icon */
  889. X  
  890. X  #define        DEF_INTERNAL_BW        1
  891. X  #define        POPUP_BW        2
  892. X  
  893. X--- 33,43 ----
  894. X  
  895. X  #define        MAXDEPTH        999
  896. X  
  897. X  #define        MODE_SW_HT    32    /* height of a mode switch icon */
  898. X  #define        MODE_SW_WD    36    /* width of a mode switch icon */
  899. X  
  900. X+ #define        DEF_SW_PER_ROW        2 /* def num of btns per row in mode panel */
  901. X+ 
  902. X  #define        DEF_INTERNAL_BW        1
  903. X  #define        POPUP_BW        2
  904. X  
  905. X***************
  906. X*** 56,59 ****
  907. X  extern int    INTERNAL_BW;
  908. X  extern int    TOPRULER_WD, TOPRULER_HT;
  909. X  extern int    SIDERULER_WD, SIDERULER_HT;
  910. X! extern int    SW_PER_ROW, SW_PER_COL;
  911. X--- 53,57 ----
  912. X  extern int    INTERNAL_BW;
  913. X  extern int    TOPRULER_WD, TOPRULER_HT;
  914. X  extern int    SIDERULER_WD, SIDERULER_HT;
  915. X! extern int    SW_PER_ROW;
  916. X! extern int    NUM_MODE_SW;
  917. Xdiff -rc xfig.2.1.7a/w_util.c xfig.2.1.8/w_util.c
  918. X*** xfig.2.1.7a/w_util.c    Tue Mar 23 10:50:45 1993
  919. X--- xfig.2.1.8/w_util.c    Tue Aug 24 16:32:34 1993
  920. X***************
  921. X*** 126,132 ****
  922. X      XtAddEventHandler(query_yes, ButtonReleaseMask, (Boolean) 0,
  923. X                (XtEventHandler)accept_yes, (XtPointer) NULL);
  924. X  
  925. X!     if (query_type == QUERY_YESNO) {
  926. X      ArgCount = 4;
  927. X      NextArg(XtNhorizDistance, 25);
  928. X      NextArg(XtNlabel, "  No  ");
  929. X--- 126,132 ----
  930. X      XtAddEventHandler(query_yes, ButtonReleaseMask, (Boolean) 0,
  931. X                (XtEventHandler)accept_yes, (XtPointer) NULL);
  932. X  
  933. X!     if (query_type == QUERY_YESNO || query_type == QUERY_YESNOCAN) {
  934. X      ArgCount = 4;
  935. X      NextArg(XtNhorizDistance, 25);
  936. X      NextArg(XtNlabel, "  No  ");
  937. X***************
  938. X*** 144,154 ****
  939. X      NextArg(XtNfromHoriz, query_yes);
  940. X      }
  941. X  
  942. X!     NextArg(XtNlabel, "Cancel");
  943. X!     query_cancel = XtCreateManagedWidget("cancel", commandWidgetClass,
  944. X                       query_form, Args, ArgCount);
  945. X!     XtAddEventHandler(query_cancel, ButtonReleaseMask, (Boolean) 0,
  946. X                (XtEventHandler)accept_cancel, (XtPointer) NULL);
  947. X  
  948. X      XtPopup(query_popup, XtGrabExclusive);
  949. X      (void) XSetWMProtocols(XtDisplay(query_popup), XtWindow(query_popup),
  950. X--- 144,156 ----
  951. X      NextArg(XtNfromHoriz, query_yes);
  952. X      }
  953. X  
  954. X!     if (query_type == QUERY_YESCAN || query_type == QUERY_YESNOCAN) {
  955. X!     NextArg(XtNlabel, "Cancel");
  956. X!     query_cancel = XtCreateManagedWidget("cancel", commandWidgetClass,
  957. X                       query_form, Args, ArgCount);
  958. X!     XtAddEventHandler(query_cancel, ButtonReleaseMask, (Boolean) 0,
  959. X                (XtEventHandler)accept_cancel, (XtPointer) NULL);
  960. X+     }
  961. X  
  962. X      XtPopup(query_popup, XtGrabExclusive);
  963. X      (void) XSetWMProtocols(XtDisplay(query_popup), XtWindow(query_popup),
  964. Xdiff -rc xfig.2.1.7a/w_util.h xfig.2.1.8/w_util.h
  965. X*** xfig.2.1.7a/w_util.h    Wed Dec  9 17:37:08 1992
  966. X--- xfig.2.1.8/w_util.h    Tue Aug 24 16:32:46 1993
  967. X***************
  968. X*** 12,19 ****
  969. X  
  970. X  /* constant values used for popup_query */
  971. X  
  972. X! #define QUERY_YES    0
  973. X  #define QUERY_YESNO    1
  974. X  #define RESULT_NO    -1
  975. X  #define RESULT_YES    1
  976. X  #define RESULT_CANCEL    0
  977. X--- 12,20 ----
  978. X  
  979. X  /* constant values used for popup_query */
  980. X  
  981. X! #define QUERY_YESCAN    0
  982. X  #define QUERY_YESNO    1
  983. X+ #define QUERY_YESNOCAN    2
  984. X  #define RESULT_NO    -1
  985. X  #define RESULT_YES    1
  986. X  #define RESULT_CANCEL    0
  987. X***************
  988. X*** 40,46 ****
  989. X   *    }
  990. X   */
  991. X  
  992. X! #include "assert.h"
  993. X  
  994. X  #define ArgCount    _fooArgCount
  995. X  #define Args        _fooArgList
  996. X--- 41,47 ----
  997. X   *    }
  998. X   */
  999. X  
  1000. X! #include <assert.h>
  1001. X  
  1002. X  #define ArgCount    _fooArgCount
  1003. X  #define Args        _fooArgList
  1004. Xdiff -rc xfig.2.1.7a/w_zoom.c xfig.2.1.8/w_zoom.c
  1005. X*** xfig.2.1.7a/w_zoom.c    Wed Jan  6 12:08:49 1993
  1006. X--- xfig.2.1.8/w_zoom.c    Tue Aug 10 14:14:23 1993
  1007. X***************
  1008. X*** 29,36 ****
  1009. X  
  1010. X  /* extern int           gc_thickness[NUMOPS]; */
  1011. X  
  1012. X! static        do_zoom();
  1013. X! static        zoom_up();
  1014. X  static        init_zoombox_drawing();
  1015. X  
  1016. X  static int    (*save_kbd_proc) ();
  1017. X--- 29,35 ----
  1018. X  
  1019. X  /* extern int           gc_thickness[NUMOPS]; */
  1020. X  
  1021. X! static        do_zoom(), cancel_zoom();
  1022. X  static        init_zoombox_drawing();
  1023. X  
  1024. X  static int    (*save_kbd_proc) ();
  1025. X***************
  1026. X*** 104,109 ****
  1027. X--- 103,109 ----
  1028. X      canvas_locmove_proc = my_box;
  1029. X      canvas_leftbut_proc = do_zoom;
  1030. X      canvas_middlebut_proc = canvas_rightbut_proc = null_proc;
  1031. END_OF_FILE
  1032.   if test 28014 -ne `wc -c <'xfig.11'`; then
  1033.     echo shar: \"'xfig.11'\" unpacked with wrong size!
  1034.   fi
  1035.   # end of 'xfig.11'
  1036. fi
  1037. echo shar: End of archive 16 \(of 16\).
  1038. cp /dev/null ark16isdone
  1039. MISSING=""
  1040. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do
  1041.     if test ! -f ark${I}isdone ; then
  1042.     MISSING="${MISSING} ${I}"
  1043.     fi
  1044. done
  1045. if test "${MISSING}" = "" ; then
  1046.     echo You have unpacked all 16 archives.
  1047.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1048.     echo Creating merged patch file xfig.p2
  1049.     cat xfig.[01][0-9] > xfig.p2
  1050.     rm -f xfig.[01][0-9]
  1051. else
  1052.     echo You still must unpack the following archives:
  1053.     echo "        " ${MISSING}
  1054. fi
  1055. exit 0
  1056. exit 0 # Just in case...
  1057. -- 
  1058.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  1059. \X/  Amiga - The only way to fly! |    sources-x@sterling.com
  1060.  "It's intuitively obvious to the |
  1061.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1062.