home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-10-21 | 27.8 KB | 1,001 lines |
- +
- /********************* EXPORTS *******************/
-
- int put_msg();
- ***************
- *** 73,88 ****
-
- setup_msg()
- {
- ! Dimension ht;
-
- ! /* set the height of the message panel to the height of the file name panel */
- XtUnmanageChild(msg_panel);
- ! FirstArg(XtNheight, &ht);
- GetValues(name_panel);
- ! FirstArg(XtNheight, ht);
- SetValues(msg_panel);
- /* set the MSGFORM_HT variable so the mouse panel can be resized to fit */
- ! MSGFORM_HT = ht;
- XtManageChild(msg_panel);
- if (msg_win == 0)
- msg_win = XtWindow(msg_panel);
- --- 77,97 ----
-
- setup_msg()
- {
- ! Dimension htm,htf;
-
- ! /* set the height of the message panel and filename panel to the
- ! greater of the two heights */
- XtUnmanageChild(msg_panel);
- ! FirstArg(XtNheight, &htm);
- GetValues(name_panel);
- ! FirstArg(XtNheight, &htf);
- ! GetValues(msg_panel);
- ! htf = max2(htf,htm);
- ! FirstArg(XtNheight, htf);
- SetValues(msg_panel);
- + SetValues(name_panel);
- /* set the MSGFORM_HT variable so the mouse panel can be resized to fit */
- ! MSGFORM_HT = htf;
- XtManageChild(msg_panel);
- if (msg_win == 0)
- msg_win = XtWindow(msg_panel);
- ***************
- *** 95,100 ****
- --- 104,110 ----
- * space, by getting the width of the command panel and subtract the new
- * width of the name_panel to get the new width of the message panel
- */
- +
- update_cur_filename(newname)
- char *newname;
- {
- ***************
- *** 112,120 ****
- --- 122,135 ----
- FirstArg(XtNwidth, &namwid);
- GetValues(name_panel);
- MSGPANEL_WD = MSGFORM_WD-namwid;
- + if (MSGPANEL_WD <= 0)
- + MSGPANEL_WD = 100;
- /* resize the message panel to fit with the new width of the name panel */
- FirstArg(XtNwidth, MSGPANEL_WD);
- SetValues(msg_panel);
- + /* keep the height the same */
- + FirstArg(XtNheight, MSGFORM_HT);
- + SetValues(name_panel);
- XtManageChild(msg_panel);
- XtManageChild(name_panel);
-
- ***************
- *** 122,127 ****
- --- 137,144 ----
- FirstArg(XtNwidth, MSGFORM_WD);
- SetValues(msg_form);
- XtManageChild(msg_form);
- + /* put the filename being edited in the icon */
- + XSetIconName(tool_d, XtWindow(tool), basename(cur_filename));
- }
-
- /* VARARGS1 */
- diff -rc xfig.2.1.7a/w_print.c xfig.2.1.8/w_print.c
- *** xfig.2.1.7a/w_print.c Tue Mar 23 10:21:42 1993
- --- xfig.2.1.8/w_print.c Tue Aug 31 14:20:47 1993
- ***************
- *** 96,103 ****
- var and put it into the widget */
- if (emptyname(printer_val)) {
- printer_val=getenv("PRINTER");
- ! FirstArg(XtNstring, printer_val);
- ! SetValues(printer_text);
- }
- FirstArg(XtNstring, ¶m_val);
- GetValues(param_text);
- --- 96,107 ----
- var and put it into the widget */
- if (emptyname(printer_val)) {
- printer_val=getenv("PRINTER");
- ! if (printer_val == NULL) {
- ! printer_val = "";
- ! } else {
- ! FirstArg(XtNstring, printer_val);
- ! SetValues(printer_text);
- ! }
- }
- FirstArg(XtNstring, ¶m_val);
- GetValues(param_text);
- ***************
- *** 122,128 ****
- char *pr_params;
- {
- if (emptyname(printer)) { /* send to default printer */
- ! #if defined(SYSV) || defined(SVR4)
- sprintf(cmd, "lp %s -oPS %s",
- pr_params,
- shell_protect_string(file));
- --- 126,132 ----
- char *pr_params;
- {
- if (emptyname(printer)) { /* send to default printer */
- ! #if (defined(SYSV) || defined(SVR4)) && !defined(BSDLPR)
- sprintf(cmd, "lp %s -oPS %s",
- pr_params,
- shell_protect_string(file));
- ***************
- *** 135,141 ****
- put_msg("Printing figure on default printer in %s mode ... ",
- print_landscape ? "LANDSCAPE" : "PORTRAIT");
- } else {
- ! #if defined(SYSV) || defined(SVR4)
- sprintf(cmd, "lp %s, -d%s -oPS %s",
- pr_params,
- printer,
- --- 139,145 ----
- put_msg("Printing figure on default printer in %s mode ... ",
- print_landscape ? "LANDSCAPE" : "PORTRAIT");
- } else {
- ! #if (defined(SYSV) || defined(SVR4)) && !defined(BSDLPR)
- sprintf(cmd, "lp %s, -d%s -oPS %s",
- pr_params,
- printer,
- ***************
- *** 160,166 ****
- do_print_batch(w)
- Widget w;
- {
- - DeclareArgs(1);
- float mag;
- FILE *infp,*outfp;
- char tmp_exp_file[32];
- --- 164,169 ----
- ***************
- *** 215,222 ****
- do_clear_batch(w)
- Widget w;
- {
- - DeclareArgs(1);
- -
- unlink(batch_file);
- batch_exists = False;
- num_batch_figures = 0;
- --- 218,223 ----
- ***************
- *** 228,234 ****
-
- update_batch_count()
- {
- ! String num[4];
- DeclareArgs(1);
-
- sprintf(num,"%3d",num_batch_figures);
- --- 229,235 ----
-
- update_batch_count()
- {
- ! char num[4];
- DeclareArgs(1);
-
- sprintf(num,"%3d",num_batch_figures);
- ***************
- *** 272,280 ****
- popup_print_panel(w)
- Widget w;
- {
- - Widget image;
- - Pixmap p;
- - DeclareArgs(10);
- extern Atom wm_delete_window;
-
- set_temp_cursor(wait_cursor);
- --- 273,278 ----
- ***************
- *** 294,299 ****
- --- 292,298 ----
- Widget image;
- Pixmap p;
- DeclareArgs(10);
- + unsigned long fg, bg;
-
- print_w = w;
- XtTranslateCoords(w, (Position) 0, (Position) 0, &xposn, &yposn);
- ***************
- *** 311,323 ****
- print_panel = XtCreateManagedWidget("print_panel", formWidgetClass,
- print_popup, NULL, ZERO);
-
- - p = XCreateBitmapFromData(tool_d, XtWindow(canvas_sw),
- - (char *) printer_ic.data, printer_ic.width, printer_ic.height);
- -
- FirstArg(XtNlabel, " ");
- NextArg(XtNwidth, printer_ic.width);
- NextArg(XtNheight, printer_ic.height);
- - NextArg(XtNbitmap, p);
- NextArg(XtNborderWidth, 0);
- NextArg(XtNinternalWidth, 0);
- NextArg(XtNinternalHeight, 0);
- --- 310,318 ----
- ***************
- *** 325,330 ****
- --- 320,333 ----
- NextArg(XtNresizable, False);
- image = XtCreateManagedWidget("printer_image", labelWidgetClass,
- print_panel, Args, ArgCount);
- + FirstArg(XtNforeground, &fg);
- + NextArg(XtNbackground, &bg);
- + GetValues(image);
- + p = XCreatePixmapFromBitmapData(tool_d, XtWindow(canvas_sw),
- + (char *) printer_ic.data, printer_ic.width, printer_ic.height,
- + fg, bg, DefaultDepthOfScreen(tool_s));
- + FirstArg(XtNbitmap, p);
- + SetValues(image);
-
- FirstArg(XtNlabel, " Magnification%:");
- NextArg(XtNfromVert, image);
- diff -rc xfig.2.1.7a/w_rottext.c xfig.2.1.8/w_rottext.c
- *** xfig.2.1.7a/w_rottext.c Wed Feb 10 10:25:21 1993
- --- xfig.2.1.8/w_rottext.c Mon Sep 13 14:25:40 1993
- ***************
- *** 1,56 ****
- ! /*
- ! * FIG : Facility for Interactive Generation of figures
- ! * Copyright (c) 1992 by Alan Richardson
- *
- ! * "Permission to use, copy, modify, distribute, and sell this software and its
- ! * documentation for any purpose is hereby granted without fee, provided that
- ! * the above copyright notice appear in all copies and that both the copyright
- ! * notice and this permission notice appear in supporting documentation.
- ! * No representations are made about the suitability of this software for
- ! * any purpose. It is provided "as is" without express or implied warranty."
- */
-
- #include "fig.h"
- #include "w_rottext.h"
-
- /* ---------------------------------------------------------------------- */
-
- - #define XROTMAX(a, b) ((a)>(b)?(a):(b))
-
- /* ---------------------------------------------------------------------- */
-
- - char *my_strdup();
- - char *my_strtok();
- - XRotFontStruct *XRotLoadFont();
- - void XRotUnloadFont();
- - int XRotTextWidth();
- - int XRotTextHeight();
- - void XRotDrawString();
- - void XRotDrawImageString();
- - void XRotPaintString();
- - void XRotDrawAlignedString();
- - void XRotDrawAlignedImageString();
- - void XRotPaintAlignedString();
-
- /* ---------------------------------------------------------------------- */
- -
- - /* *** Routine to mimic `strdup()' (some machines don't have it) *** */
-
- - char *my_strdup(str)
- - char *str;
- - {
- - char *s;
-
- ! if(str==NULL) return (char *)NULL;
-
- ! s=(char *)malloc((unsigned)(strlen(str)+1));
- ! if(!s)
- ! { fprintf(stderr, "Error: my_strdup(): Couldn't do malloc\n");
- ! exit(1); }
-
- ! strcpy(s, str);
-
- ! return s;
- }
-
-
- --- 1,162 ----
- ! /* ********************************************************************** */
- !
- ! /* xvertext 5.0, Copyright (c) 1993 Alan Richardson (mppa3@uk.ac.sussex.syma)
- *
- ! * Permission to use, copy, modify, and distribute this software and its
- ! * documentation for any purpose and without fee is hereby granted, provided
- ! * that the above copyright notice appear in all copies and that both the
- ! * copyright notice and this permission notice appear in supporting
- ! * documentation. All work developed as a consequence of the use of
- ! * this program should duly acknowledge such use. No representations are
- ! * made about the suitability of this software for any purpose. It is
- ! * provided "as is" without express or implied warranty.
- */
-
- + /* ********************************************************************** */
- +
- +
- + /* BETTER: xvertext now does rotation at any angle!!
- + *
- + * BEWARE: function arguments have CHANGED since version 2.0!!
- + */
- +
- + /* ********************************************************************** */
- +
- +
- #include "fig.h"
- + #include "resources.h"
- + #include <X11/Xatom.h>
- #include "w_rottext.h"
-
- +
- /* ---------------------------------------------------------------------- */
-
-
- + /* Make sure cache size is set */
- +
- + #ifndef CACHE_SIZE_LIMIT
- + #define CACHE_SIZE_LIMIT 0
- + #endif /*CACHE_SIZE_LIMIT */
- +
- + /* Cache by FID if can't find name because OpenWindows screws up */
- +
- + #define CACHE_FID
- +
- + /* Make sure a cache method is specified */
- +
- + #ifndef CACHE_XIMAGES
- + #ifndef CACHE_BITMAPS
- + #define CACHE_BITMAPS
- + #endif /*CACHE_BITMAPS*/
- + #endif /*CACHE_XIMAGES*/
- +
- +
- /* ---------------------------------------------------------------------- */
-
-
- + /* Debugging macros */
- +
- + #define DEBUG_PRINT1(a) if (appres.DEBUG) printf (a)
- + #define DEBUG_PRINT2(a, b) if (appres.DEBUG) printf (a, b)
- + #define DEBUG_PRINT3(a, b, c) if (appres.DEBUG) printf (a, b, c)
- + #define DEBUG_PRINT4(a, b, c, d) if (appres.DEBUG) printf (a, b, c, d)
- + #define DEBUG_PRINT5(a, b, c, d, e) if (appres.DEBUG) printf (a, b, c, d, e)
- +
- +
- /* ---------------------------------------------------------------------- */
-
-
- ! /* A structure holding everything needed for a rotated string */
-
- ! typedef struct rotated_text_item_template {
- ! Pixmap bitmap;
- ! XImage *ximage;
- !
- ! char *text;
- ! char *font_name;
- ! Font fid;
- ! float angle;
- ! int align;
- ! float magnify;
- !
- ! int cols_in;
- ! int rows_in;
- ! int cols_out;
- ! int rows_out;
- !
- ! int nl;
- ! int max_width;
- ! float *corners_x;
- ! float *corners_y;
- !
- ! long int size;
- ! int cached;
-
- ! struct rotated_text_item_template *next;
- ! } RotatedTextItem;
-
- ! RotatedTextItem *first_text_item=NULL;
- !
- !
- ! /* ---------------------------------------------------------------------- */
- !
- !
- ! /* A structure holding current magnification and bounding box padding */
- !
- ! static struct style_template {
- ! float magnify;
- ! int bbx_pad;
- ! } style={
- ! 1.,
- ! 0
- ! };
- !
- !
- ! /* ---------------------------------------------------------------------- */
- !
- !
- ! static char *my_strdup();
- ! static char *my_strtok();
- !
- ! float XRotVersion();
- ! void XRotSetMagnification();
- ! void XRotSetBoundingBoxPad();
- ! int XRotDrawString();
- ! int XRotDrawImageString();
- ! int XRotDrawAlignedString();
- ! int XRotDrawAlignedImageString();
- ! XPoint *XRotTextExtents();
- !
- ! static XImage *MakeXImage();
- ! static int XRotPaintAlignedString();
- ! static int XRotDrawHorizontalString();
- ! static RotatedTextItem *XRotRetrieveFromCache();
- ! static RotatedTextItem *XRotCreateTextItem();
- ! static void XRotAddToLinkedList();
- ! static void XRotFreeTextItem();
- ! static XImage *XRotMagnifyImage();
- !
- !
- ! /* ---------------------------------------------------------------------- */
- !
- !
- ! /**************************************************************************/
- ! /* Routine to mimic `strdup()' (some machines don't have it) */
- ! /**************************************************************************/
- !
- ! static char *my_strdup(str)
- ! char *str;
- ! {
- ! char *s;
- !
- ! if(str==NULL)
- ! return NULL;
- !
- ! s=(char *)malloc((unsigned)(strlen(str)+1));
- ! if(s!=NULL)
- ! strcpy(s, str);
- !
- ! return s;
- }
-
-
- ***************
- *** 57,331 ****
- /* ---------------------------------------------------------------------- */
-
-
- ! /* *** Routine to replace `strtok' : this one returns a zero
- ! length string if it encounters two consecutive delimiters *** */
-
- ! char *my_strtok(str1, str2)
- ! char *str1, *str2;
- {
- ! char *ret;
- ! int i, j, stop;
- ! static int start, len;
- ! static char *stext;
-
- - if(str2==NULL)
- - { fprintf(stderr, "Error: my_strtok(): null delimiter string\n");
- - exit(1);
- - }
-
- ! /* initialise if str1 not NULL ... */
- ! if(str1!=NULL)
- ! { start=0;
- ! stext=str1;
- ! len=strlen(str1);
- ! }
-
- - /* run out of tokens ? ... */
- - if(start>=len) return (char *)NULL;
-
- ! /* loop through characters ... */
- ! for(i=start; i<len; i++)
- ! {
- ! /* loop through delimiters ... */
- ! stop=0;
- ! for(j=0; j<strlen(str2); j++) if(stext[i]==str2[j]) stop=1;
-
- ! if(stop) break;
- ! }
-
- - stext[i]='\0';
-
- ! ret=stext+start;
-
- - start=i+1;
-
- ! return ret;
- }
-
-
- /* ---------------------------------------------------------------------- */
- -
-
- ! /* *** Load the rotated version of a given font *** */
- !
- ! XRotFontStruct *XRotLoadFont(dpy, fontname, angle)
- ! Display *dpy;
- ! char *fontname;
- ! float angle;
- {
- ! char val;
- ! XImage *I1, *I2;
- ! Pixmap canvas;
- ! Window root;
- ! int screen;
- ! GC font_gc;
- ! char text[3];
- ! XFontStruct *fontstruct;
- ! XRotFontStruct *rotfont;
- ! int ichar, i, j, index, boxlen, dir;
- ! int vert_w, vert_h, vert_len, bit_w, bit_h, bit_len;
- ! int min_char, max_char;
- ! unsigned char *vertdata, *bitdata;
- ! int ascent, descent, lbearing, rbearing;
- ! int on=1, off=0;
-
- - dir=(int)(angle/90.0+0.01);
- - if (dir > 3)
- - dir -= 4;
-
- ! /* useful macros ... */
- ! screen=DefaultScreen(dpy);
- ! root=DefaultRootWindow(dpy);
-
- - /* load the font ... */
- - fontstruct=XLoadQueryFont(dpy, fontname);
- - if(!fontstruct) {
- - fprintf(stderr,
- - "Error: XRotLoadFont(): XServer couldn't load the font `%s'\n",
- - fontname);
- - exit(1);
- - }
- -
- - /* boxlen is the square size that would enclose the largest character */
- - boxlen = max2(fontstruct->max_bounds.rbearing - fontstruct->max_bounds.lbearing,
- - fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent);
- - boxlen *= 2;
-
- ! /* create the depth 1 canvas bitmap ... */
- ! canvas=XCreatePixmap(dpy, root, boxlen, boxlen, 1);
- !
- ! /* create a GC ... */
- ! font_gc=XCreateGC(dpy, canvas, NULL, 0);
- ! XSetBackground(dpy, font_gc, off);
-
- ! XSetFont(dpy, font_gc, fontstruct->fid);
-
- - /* allocate space for rotated font ... */
- - rotfont=(XRotFontStruct *)malloc((unsigned)sizeof(XRotFontStruct));
- - if(!rotfont) {
- - fprintf(stderr,"Error: XRotLoadFont(): Couldn't do malloc\n");
- - exit(1);
- - }
- -
- - /* determine which characters are defined in font ... */
- - min_char=fontstruct->min_char_or_byte2;
- - max_char=fontstruct->max_char_or_byte2;
- -
- - /* we only want printing characters ... */
- - if(min_char<32) min_char=32;
- - if(max_char>126) max_char=126;
- -
- - /* some overall font data ... */
- - rotfont->name=my_strdup(fontname);
- - rotfont->dir=dir;
- - rotfont->min_char=min_char;
- - rotfont->max_char=max_char;
- - rotfont->max_ascent=fontstruct->max_bounds.ascent;
- - rotfont->max_descent=fontstruct->max_bounds.descent;
- - rotfont->height=rotfont->max_ascent+rotfont->max_descent;
- - rotfont->width=fontstruct->max_bounds.width;
-
- ! /* remember xfontstruct for `normal' text ... */
- ! if(dir==0)
- ! rotfont->xfontstruct=fontstruct;
-
- - /* loop through each character ... */
- - for(ichar=min_char; ichar<=max_char; ichar++) {
-
- ! index=ichar-fontstruct->min_char_or_byte2;
- ! /* per char dimensions ... */
- ! ascent= rotfont->per_char[ichar-32].ascent=
- ! fontstruct->per_char[index].ascent;
- ! descent= rotfont->per_char[ichar-32].descent=
- ! fontstruct->per_char[index].descent;
- ! lbearing=rotfont->per_char[ichar-32].lbearing=
- ! fontstruct->per_char[index].lbearing;
- ! rbearing=rotfont->per_char[ichar-32].rbearing=
- ! fontstruct->per_char[index].rbearing;
- ! rotfont->per_char[ichar-32].width=
- ! fontstruct->per_char[index].width;
-
- ! /* no need for the following with normal text */
- ! if (dir == 0)
- ! continue;
-
- - /* some space chars have zero body, but a bitmap can't have ... */
- - if(!ascent && !descent)
- - ascent= rotfont->per_char[ichar-32].ascent= 1;
- - if(!lbearing && !rbearing)
- - rbearing=rotfont->per_char[ichar-32].rbearing=1;
-
- ! /* glyph width and height when vertical ... */
- ! vert_w=rbearing-lbearing;
- ! vert_h=ascent+descent;
-
- - /* width in bytes ... */
- - vert_len=(vert_w-1)/8+1;
- -
- - XSetForeground(dpy, font_gc, off);
- - XFillRectangle(dpy, canvas, font_gc, 0, 0, boxlen, boxlen);
-
- ! /* draw the character centre top right on canvas ... */
- ! sprintf(text, "%c", ichar);
- ! XSetForeground(dpy, font_gc, on);
- ! XDrawImageString(dpy, canvas, font_gc, boxlen/2-lbearing,
- ! boxlen/2-descent, text, 1);
-
- ! /* reserve memory for first XImage ... */
- ! vertdata=(unsigned char *) malloc((unsigned)(vert_len*vert_h));
- ! if(!vertdata) {
- ! fprintf(stderr,"Error: XRotLoadFont(): Couldn't do malloc\n");
- ! exit(1);
- ! }
- !
- ! /* create the XImage ... */
- ! I1=XCreateImage(dpy, DefaultVisual(dpy, screen), 1, XYBitmap,
- ! 0, (char *) vertdata, vert_w, vert_h, 8, 0);
-
- - if(!I1) {
- - fprintf(stderr,"Error: XRotLoadFont(): Couldn't create XImage\n");
- - exit(1);
- - }
- -
- - I1->byte_order=I1->bitmap_bit_order=MSBFirst;
-
- ! /* extract character from canvas ... */
- ! XGetSubImage(dpy, canvas, boxlen/2, boxlen/2-vert_h,
- ! vert_w, vert_h, 1, XYPixmap, I1, 0, 0);
- ! I1->format=XYBitmap;
- !
- ! /* width, height of rotated character ... */
- ! if(dir==2) {
- ! bit_w=vert_w; bit_h=vert_h;
- ! } else {
- ! bit_w=vert_h; bit_h=vert_w;
- ! }
-
- - /* width in bytes ... */
- - bit_len=(bit_w-1)/8+1;
- -
- - rotfont->per_char[ichar-32].glyph.bit_w=bit_w;
- - rotfont->per_char[ichar-32].glyph.bit_h=bit_h;
-
- ! /* reserve memory for the rotated image ... */
- ! bitdata=(unsigned char *)calloc((unsigned)(bit_h*bit_len), 1);
- ! if(!bitdata) {
- ! fprintf(stderr,"Error: XRotLoadFont(): Couldn't do calloc\n");
- ! exit(1);
- ! }
-
- ! /* create the image ... */
- ! I2=XCreateImage(dpy, DefaultVisual(dpy, screen), 1, XYBitmap, 0,
- ! (char *) bitdata, bit_w, bit_h, 8, 0);
- !
- ! if(!I2) {
- ! fprintf(stderr,"Error: XRotLoadFont(): Couldn't create XImage\n");
- ! exit(1);
- ! }
-
- - I2->byte_order=I2->bitmap_bit_order=MSBFirst;
-
- ! /* map vertical data to rotated character ... */
- ! for(j=0; j<bit_h; j++) {
- ! for(i=0; i<bit_w; i++) {
- ! /* map bits ... */
- ! if(dir==1)
- ! val=vertdata[i*vert_len + (vert_w-j-1)/8] & (128>>((vert_w-j-1)%8));
- !
- ! else if(dir==2)
- ! val=vertdata[(vert_h-j-1)*vert_len + (vert_w-i-1)/8] &
- ! (128>>((vert_w-i-1)%8));
- ! else
- ! val=vertdata[(vert_h-i-1)*vert_len + j/8] & (128>>(j%8));
- !
- ! if(val) bitdata[j*bit_len + i/8] =
- ! bitdata[j*bit_len + i/8]|(128>>(i%8));
- ! }
- ! }
- !
- ! /* create this character's bitmap ... */
- ! rotfont->per_char[ichar-32].glyph.bm=
- ! XCreatePixmap(dpy, root, bit_w, bit_h, 1);
- !
- ! /* put the image into the bitmap ... */
- ! XPutImage(dpy, rotfont->per_char[ichar-32].glyph.bm,
- ! font_gc, I2, 0, 0, 0, 0, bit_w, bit_h);
- !
- ! /* free the image and data ... */
- ! XDestroyImage(I1);
- ! XDestroyImage(I2);
- ! free((char *)bitdata);
- ! free((char *)vertdata);
- ! }
-
- - if (dir != 0)
- - XFreeFont(dpy, fontstruct);
-
- ! /* free pixmap and GC ... */
- ! XFreePixmap(dpy, canvas);
- ! XFreeGC(dpy, font_gc);
-
- ! return rotfont;
- }
-
-
- --- 163,382 ----
- /* ---------------------------------------------------------------------- */
-
-
- ! /**************************************************************************/
- ! /* Routine to replace `strtok' : this one returns a zero length string if */
- ! /* it encounters two consecutive delimiters */
- ! /**************************************************************************/
-
- ! static char *my_strtok(str1, str2)
- ! char *str1, *str2;
- {
- ! char *ret;
- ! int i, j, stop;
- ! static int start, len;
- ! static char *stext;
- !
- ! if(str2==NULL)
- ! return NULL;
- !
- ! /* initialise if str1 not NULL */
- ! if(str1!=NULL) {
- ! start=0;
- ! stext=str1;
- ! len=strlen(str1);
- ! }
- !
- ! /* run out of tokens ? */
- ! if(start>=len)
- ! return NULL;
- !
- ! /* loop through characters */
- ! for(i=start; i<len; i++) {
- ! /* loop through delimiters */
- ! stop=0;
- ! for(j=0; j<strlen(str2); j++)
- ! if(stext[i]==str2[j])
- ! stop=1;
- !
- ! if(stop)
- ! break;
- ! }
- !
- ! stext[i]='\0';
- !
- ! ret=stext+start;
- !
- ! start=i+1;
- !
- ! return ret;
- ! }
-
-
- ! /* ---------------------------------------------------------------------- */
-
-
- ! /**************************************************************************/
- ! /* Return version/copyright information */
- ! /**************************************************************************/
-
- ! float XRotVersion(str, n)
- ! char *str;
- ! int n;
- ! {
- ! if(str!=NULL)
- ! strncpy(str, XV_COPYRIGHT, n);
- ! return XV_VERSION;
- ! }
-
-
- ! /* ---------------------------------------------------------------------- */
-
-
- ! /**************************************************************************/
- ! /* Set the font magnification factor for all subsequent operations */
- ! /**************************************************************************/
- !
- ! void XRotSetMagnification(m)
- ! float m;
- ! {
- ! if(m>0.)
- ! style.magnify=m;
- }
-
-
- /* ---------------------------------------------------------------------- */
-
- !
- ! /**************************************************************************/
- ! /* Set the padding used when calculating bounding boxes */
- ! /**************************************************************************/
- !
- ! void XRotSetBoundingBoxPad(p)
- ! int p;
- {
- ! if(p>=0)
- ! style.bbx_pad=p;
- ! }
-
-
- ! /* ---------------------------------------------------------------------- */
-
-
- ! /**************************************************************************/
- ! /* Create an XImage structure and allocate memory for it */
- ! /**************************************************************************/
-
- ! static XImage *MakeXImage(dpy, w, h)
- ! Display *dpy;
- ! int w, h;
- ! {
- ! XImage *I;
- ! char *data;
- !
- ! /* reserve memory for image */
- ! data=(char *)calloc((unsigned)(((w-1)/8+1)*h), 1);
- ! if(data==NULL)
- ! return NULL;
- !
- ! /* create the XImage */
- ! I=XCreateImage(dpy, DefaultVisual(dpy, DefaultScreen(dpy)), 1, XYBitmap,
- ! 0, data, w, h, 8, 0);
- ! if(I==NULL)
- ! return NULL;
- !
- ! I->byte_order=I->bitmap_bit_order=MSBFirst;
- ! return I;
- ! }
-
-
- ! /* ---------------------------------------------------------------------- */
-
-
- ! /**************************************************************************/
- ! /* A front end to XRotPaintAlignedString: */
- ! /* -no alignment, no background */
- ! /**************************************************************************/
-
- ! int XRotDrawString(dpy, font, angle, drawable, gc, x, y, str)
- ! Display *dpy;
- ! XFontStruct *font;
- ! float angle;
- ! Drawable drawable;
- ! GC gc;
- ! int x, y;
- ! char *str;
- ! {
- ! return (XRotPaintAlignedString(dpy, font, angle, drawable, gc,
- ! x, y, str, NONE, 0));
- ! }
-
-
- ! /* ---------------------------------------------------------------------- */
-
-
- ! /**************************************************************************/
- ! /* A front end to XRotPaintAlignedString: */
- ! /* -no alignment, paints background */
- ! /**************************************************************************/
-
- ! int XRotDrawImageString(dpy, font, angle, drawable, gc, x, y, str)
- ! Display *dpy;
- ! XFontStruct *font;
- ! float angle;
- ! Drawable drawable;
- ! GC gc;
- ! int x, y;
- ! char *str;
- ! {
- ! return(XRotPaintAlignedString(dpy, font, angle, drawable, gc,
- ! x, y, str, NONE, 1));
- ! }
-
-
- ! /* ---------------------------------------------------------------------- */
-
-
- ! /**************************************************************************/
- ! /* A front end to XRotPaintAlignedString: */
- ! /* -does alignment, no background */
- ! /**************************************************************************/
-
- ! int XRotDrawAlignedString(dpy, font, angle, drawable, gc, x, y, text, align)
- ! Display *dpy;
- ! XFontStruct *font;
- ! float angle;
- ! Drawable drawable;
- ! GC gc;
- ! int x, y;
- ! char *text;
- ! int align;
- ! {
- ! return(XRotPaintAlignedString(dpy, font, angle, drawable, gc,
- ! x, y, text, align, 0));
- ! }
-
-
- ! /* ---------------------------------------------------------------------- */
-
-
- ! /**************************************************************************/
- ! /* A front end to XRotPaintAlignedString: */
- ! /* -does alignment, paints background */
- ! /**************************************************************************/
-
- ! int XRotDrawAlignedImageString(dpy, font, angle, drawable, gc, x, y, text,
- ! align)
- ! Display *dpy;
- ! XFontStruct *font;
- ! float angle;
- ! Drawable drawable;
- ! GC gc;
- ! int x, y;
- ! char *text;
- ! int align;
- ! {
- ! return(XRotPaintAlignedString(dpy, font, angle, drawable, gc,
- ! x, y, text, align, 1));
- }
-
-
- ***************
- *** 332,608 ****
- /* ---------------------------------------------------------------------- */
-
-
- ! /* *** Free the resources associated with a rotated font *** */
-
- ! void XRotUnloadFont(dpy, rotfont)
- ! Display *dpy;
- ! XRotFontStruct *rotfont;
- {
- ! int ichar;
-
- ! if(rotfont->dir==0) XFreeFont(dpy, rotfont->xfontstruct);
-
- ! else
- ! /* loop through each character, freeing its pixmap ... */
- ! for(ichar=rotfont->min_char-32; ichar<=rotfont->max_char-32; ichar++)
- ! XFreePixmap(dpy, rotfont->per_char[ichar].glyph.bm);
-
- ! /* rotfont should never be referenced again ... */
- ! free((char *)rotfont);
- }
-
-
- /* ---------------------------------------------------------------------- */
- -
-
- - /* *** Return the width of a string *** */
-
- ! int XRotTextWidth(rotfont, str, len)
- ! XRotFontStruct *rotfont;
- ! char *str;
- ! int len;
- {
- ! int i, width=0, ichar;
-
- ! if(str==NULL)
- return 0;
-
- ! if(rotfont->dir==0)
- ! width=XTextWidth(rotfont->xfontstruct, str, len);
-
-