Debian Codegraph @

system/idiserv/src/textdemo.c

raw symbols SCIP
1 /*===========================================================================
2 Copyright (C) 1995-2009 European Southern Observatory (ESO)
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public
15 License along with this program; if not, write to the Free
16 Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
17 MA 02139, USA.
18
19 Correspondence concerning ESO-MIDAS should be addressed as follows:
20 Internet e-mail: [email protected]
21 Postal address: European Southern Observatory
22 Data Management Division
23 Karl-Schwarzschild-Strasse 2
24 D 85748 Garching bei Muenchen
25 GERMANY
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 /* get a list of available fonts */
81
82 /* strcpy(pattern,"-*-*-*-*-*-*-*-*-*-*-*-*-*-*"); */
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; /* default for medium delay */
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 /* waiting loop */
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