| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
# include <stdio.h> |
| 30 |
# include <math.h> |
| 31 |
#include <idi.h> |
| 32 |
#include <x11defs.h> |
| 33 |
|
| 34 |
static int virgin; |
| 35 |
|
| 36 |
extern int OSY_SLEEP(), XSWAP_INT(), XSWAP_SHORT(); |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
void own_test(flag) |
| 42 |
int flag; |
| 43 |
|
| 44 |
{ |
| 45 |
|
| 46 |
if (flag == 1) |
| 47 |
{ |
| 48 |
unsigned int iorig, iout; |
| 49 |
unsigned short int jorig, jout; |
| 50 |
|
| 51 |
iorig = 0xa1b2c3d4; |
| 52 |
iout = XSWAP_INT(iorig); |
| 53 |
(void) printf("input: %x output: %x\n",iorig,iout); |
| 54 |
|
| 55 |
jorig = 0xabcd; |
| 56 |
jout = XSWAP_SHORT(jorig); |
| 57 |
(void) printf("input: %x output: %x\n",jorig,jout); |
| 58 |
} |
| 59 |
|
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
void text_demo(w,kgc) |
| 67 |
Window w; |
| 68 |
GC kgc; |
| 69 |
|
| 70 |
{ |
| 71 |
char cbuf[20]; |
| 72 |
char **fontpntr, *pp, pattern[4]; |
| 73 |
|
| 74 |
int fcount, limi, i; |
| 75 |
|
| 76 |
void show_text(); |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
strcpy(pattern,"*"); |
| 84 |
fontpntr = XListFonts(mydisp[0],pattern,3000,&fcount); |
| 85 |
(void) printf("total no. of available fonts = %d\n",fcount); |
| 86 |
|
| 87 |
limi = 800; |
| 88 |
(void) printf("Enter delay between different fonts, none/small/medium/large: "); |
| 89 |
if (fgets(cbuf,8,stdin) != (char *) 0) |
| 90 |
{ |
| 91 |
if (cbuf[0] == 'n') |
| 92 |
limi = 0; |
| 93 |
else if (cbuf[0] == 's') |
| 94 |
limi = 300; |
| 95 |
else if (cbuf[0] == 'l') |
| 96 |
limi = 2000; |
| 97 |
} |
| 98 |
|
| 99 |
virgin = 0; |
| 100 |
|
| 101 |
for (i=0; i<fcount; i++) |
| 102 |
{ |
| 103 |
pp = *fontpntr++; |
| 104 |
show_text(w,kgc,pp,i,limi); |
| 105 |
virgin = 1; |
| 106 |
} |
| 107 |
|
| 108 |
} |
| 109 |
|
| 110 |
void show_text(w,gc,fontnam,no,waitlim) |
| 111 |
Window w; |
| 112 |
GC gc; |
| 113 |
char *fontnam; |
| 114 |
int no, waitlim; |
| 115 |
|
| 116 |
{ |
| 117 |
char text[64]; |
| 118 |
int x, y, ltxt, mm, kk; |
| 119 |
|
| 120 |
mm = 0; |
| 121 |
if (virgin == 0) |
| 122 |
{ |
| 123 |
x = 0; |
| 124 |
y = 50; |
| 125 |
XClearArea(mydisp[0],w,x,y,0,0,True); |
| 126 |
goto do_it; |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
OSY_SLEEP(waitlim,1); |
| 133 |
|
| 134 |
x = 0; |
| 135 |
mm = no % 4; |
| 136 |
y = 50 + mm*100; |
| 137 |
if (mm == 3) |
| 138 |
kk = 0; |
| 139 |
else |
| 140 |
kk = 100; |
| 141 |
|
| 142 |
XClearArea(mydisp[0],w,x,y,0,kk,True); |
| 143 |
|
| 144 |
do_it: |
| 145 |
(void) printf("(%d): %s\n",no,fontnam); |
| 146 |
(void) sprintf(text,"(%d): Viva Portable Midas...",no); |
| 147 |
|
| 148 |
myfont[0][0] = XLoadQueryFont(mydisp[0],fontnam); |
| 149 |
if (myfont[0][0] == (XFontStruct *) 0) |
| 150 |
(void) printf("Could not load the specified Font - so we skip ...\n"); |
| 151 |
else |
| 152 |
{ |
| 153 |
XSetFont(mydisp[0],gc,myfont[0][0]->fid); |
| 154 |
x = 10; |
| 155 |
y = 100 + mm*100; |
| 156 |
ltxt = (int) strlen(text); |
| 157 |
XDrawString(mydisp[0],w,gc,x,y,text,ltxt); |
| 158 |
XFlush(mydisp[0]); |
| 159 |
XFreeFont(mydisp[0],myfont[0][0]); |
| 160 |
} |
| 161 |
} |
| 162 |
|