Mercurial > hg > aim92
comparison xaim/xreview.c @ 0:5242703e91d3 tip
Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author | tomwalters |
---|---|
date | Fri, 20 May 2011 15:19:45 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:5242703e91d3 |
---|---|
1 /* | |
2 Copyright (c) Applied Psychology Unit, Medical Research Council. 1993 | |
3 =========================================================================== | |
4 | |
5 Permission to use, copy, modify, and distribute this software without fee | |
6 is hereby granted for research purposes, provided that this copyright | |
7 notice appears in all copies and in all supporting documentation, and that | |
8 the software is not redistributed for any fee (except for a nominal | |
9 shipping charge). Anyone wanting to incorporate all or part of this | |
10 software in a commercial product must obtain a license from the Medical | |
11 Research Council. | |
12 | |
13 The MRC makes no representations about the suitability of this | |
14 software for any purpose. It is provided "as is" without express or | |
15 implied warranty. | |
16 | |
17 THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING | |
18 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | |
19 THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES | |
20 OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
21 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |
22 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
23 SOFTWARE. | |
24 */ | |
25 | |
26 /* | |
27 * xreview | |
28 * ---------- | |
29 * | |
30 * A program for animating an AIM 'cartoon bitmap'. | |
31 * Requires X windows, but most varieties, r4, r5, Sun OpenWindows | |
32 * (but see also the makefile) | |
33 * | |
34 * The underlying algorithm is: | |
35 * 1. load the entire cartoon into memory, as one contiguos block. | |
36 * 2. compute, and save, the memory locations of each frame's start. | |
37 * 3. Set the memory pointer of an XImage structure to the first one, and draw | |
38 * 4. Reset the pointer to the next frame, and redraw ... | |
39 * 5. Continue for however many frames there are. | |
40 * | |
41 * | |
42 * | |
43 * A large proportion of this was inspired by the "basic window" | |
44 * program of the O'Reilly X manuals, vol 1. More inspiritaion came from | |
45 * John Holdsworth's code. | |
46 * | |
47 * | |
48 * M.Akeroyd July 1993. version 1.00 | |
49 * | |
50 * revisions: MAA: Christmas 1993. rewrites for public release, also some | |
51 * bug fixes. | |
52 * Includes the linux hacks. | |
53 */ | |
54 | |
55 | |
56 #include <X11/Xlib.h> | |
57 #include <X11/Xutil.h> | |
58 #include <X11/Xos.h> | |
59 #include <X11/Xatom.h> | |
60 #include <X11/Xmu/Xmu.h> | |
61 #include <X11/keysym.h> | |
62 #include <X11/cursorfont.h> | |
63 | |
64 #include <stdio.h> | |
65 #include <string.h> | |
66 #include <stdlib.h> | |
67 #include <math.h> | |
68 #include <time.h> | |
69 | |
70 #include "xreview.h" | |
71 #include "./stipple_a" /* for the Control Window background */ | |
72 | |
73 | |
74 | |
75 | |
76 /* Function declarations */ | |
77 /*-------------------------------------------------------------------------*/ | |
78 | |
79 void parsecommandline (int argc, char *argv[], char inputfn[], char titlestring[], char fontname[]); | |
80 int readheader(FILE *inputfp, char filefn[]); | |
81 FILE *open_file (char filefn[], FILE *dir_default, int streamtype); | |
82 void close_files (FILE *fp); | |
83 | |
84 | |
85 void initialise_control_window(char *inputfn, char *titlestring, FILE *inputfp, char *argv[], int argc); | |
86 void initialise_axes_window(char *inputfn, char *titlestring, FILE *inputfp, char *argv[], int argc); | |
87 void initialise_buttons(); | |
88 void initialise_image(); | |
89 | |
90 | |
91 void drawimage(int frame); | |
92 void drawtext(Window win, GC gc, XFontStruct *font_info, unsigned int width, \ | |
93 unsigned int height, char *text); | |
94 void drawbutton(Window control_win, Window button_local, GC *button_local_gc,\ | |
95 int width, int height, char *text, int fill_ground, \ | |
96 int text_ground); | |
97 void flashbutton(Window top_win, Window button_local, GC *button_local_gc, \ | |
98 int width, int height, char *text); | |
99 | |
100 void initialise_X_screen(); | |
101 void load_font(); | |
102 | |
103 | |
104 | |
105 /* Data arrays: global */ | |
106 /*-------------------------------------------------------------------------*/ | |
107 | |
108 char *data_pointer; | |
109 char *data_pointer_sideways; | |
110 long location[MAX_FRAMES]; /* frames: a reasonably big number */ | |
111 int frame = 1; /* start frame */ | |
112 FILE *inputfp; | |
113 char inputfn[MAX_STRING_LENGTH]; | |
114 | |
115 /* .ctn header */ | |
116 /*-------------------------------------------------------------------------*/ | |
117 | |
118 char header[MAX_LINES_HEADER][MAX_LINE_LENGTH]; | |
119 int header_lines; | |
120 | |
121 int no_frames; | |
122 int frameheight; /* number of channels */ | |
123 int framewidth_samples; /* pwidth + nwidth * samplerate */ | |
124 int frameshift_samples; /* frstep_aid * samplerate */ | |
125 double frstep_aid; /* msecs */ | |
126 double pwidth; /* msecs */ | |
127 double nwidth; /* msecs: NEGATIVE */ | |
128 int width_ctn; /* pixels */ | |
129 int height_ctn; /* pixels */ | |
130 int x_ctn; /* pixels */ | |
131 int y_ctn; /* pixels */ | |
132 long samplerate; /* samples per sec */ | |
133 int mincf; /* Hz */ | |
134 int maxcf; /* Hz */ | |
135 | |
136 | |
137 /* misc */ | |
138 /*-------------------------------------------------------------------------*/ | |
139 | |
140 char progname[MAX_STRING_LENGTH]; | |
141 char fontname[MAX_STRING_LENGTH]; | |
142 char display_name[MAX_STRING_LENGTH]; | |
143 | |
144 int verboseflag = OFF; /* -v option */ | |
145 int axes_xflag = OFF; /* -image_x option */ | |
146 int axes_yflag = OFF; /* -image_y option */ | |
147 int controls_xflag = OFF; /* -controls_x option */ | |
148 int controls_yflag = OFF; /* -controls_y option */ | |
149 int titleflag = OFF; /* -title option */ | |
150 int bytesflag = OFF; /* -lsb, -msb options */ | |
151 int bitmap_pad_flag = OFF; /* ditto */ | |
152 int new_axes_x, new_axes_y; | |
153 int new_control_x, new_control_y; | |
154 int controlwindowflag = OFF; /* -controls option */ | |
155 double scale = 1.0; | |
156 | |
157 long waittime_millisecs = 1; /* time to wait imbetween frames */ | |
158 long waittime_microsecs ; | |
159 | |
160 int animate_start = 1; /* animation start frame */ | |
161 int animate_stop = 9999; /* animation end frame: gets set to EOF */ | |
162 int animate_skip = 1; /* animation skip */ | |
163 | |
164 int sidewaysflag = OFF; | |
165 | |
166 | |
167 | |
168 /* X variables */ | |
169 /*-------------------------------------------------------------------------*/ | |
170 /* There are 3 classes of window: | |
171 * "axes window": where the cartoon itself is. Called "axes" for historical | |
172 * reasons. Button presses cause (1) animations, or (2) mapping | |
173 * of the Controls Window, or (3) exit. This window CANNOT | |
174 * be resized. | |
175 * Used, reasonably interchangealby, with 'image' | |
176 * "controls window": where the Animation Control buttons are. Button presses | |
177 * --- if not on a 'button' --- do nothing. This window | |
178 * can't be resized either. | |
179 * "buttons": there are lots of them. eg button_startf. These are subwindows | |
180 * of the Controls Window. Pressing the left mouse button causes | |
181 * something exciting to happen. | |
182 * There are also 'information buttons', which say things | |
183 * like the filename, number of frames, etc. Pressing one of these | |
184 * doesn't do anything. | |
185 */ | |
186 | |
187 Display *display; | |
188 int screen_num; | |
189 Screen *screen_ptr; | |
190 int depth = 1; | |
191 unsigned int display_width_X, display_height_X; | |
192 unsigned int display_width, display_height; | |
193 | |
194 Pixmap stipple_pixmap; | |
195 | |
196 | |
197 /* Windows */ | |
198 | |
199 toplevelWindow axes; | |
200 toplevelWindow control; | |
201 | |
202 buttonWindow button_quit, button_close; | |
203 buttonWindow button_animate; | |
204 buttonWindow button_startf, button_startb, button_stopf, button_stopb; | |
205 buttonWindow button_skipf, button_skipb, button_faster, button_slower; | |
206 buttonWindow button_firstframe, button_lastframe, button_middle; | |
207 buttonWindow button_stepb, button_stepbb; | |
208 buttonWindow button_stepf, button_stepff; | |
209 buttonWindow info_speed, info_start, info_stop, info_skip; | |
210 buttonWindow info_title, info_frame; | |
211 buttonWindow info_time, info_freq, info_frstep; | |
212 | |
213 XFontStruct *font_info; | |
214 int pointsize = DEFAULT_POINTSIZE; | |
215 GC button_gc; | |
216 int button_borderwidth = 0; | |
217 | |
218 XImage *reviewimage; | |
219 int reviewimage_bytesperline = BYTES_PER_LINE; | |
220 int reviewimage_bitmap_pad = BITMAP_PAD; | |
221 | |
222 Cursor cursor; | |
223 | |
224 XEvent report; | |
225 int depthflag = MONO; /* assume a monochrome screen */ | |
226 int planemask = 0x1; /* works with my colour sparc */ | |
227 int xsyncflag = OFF; | |
228 int reversevideoflag = OFF; /* gets set to ON if DECstation */ | |
229 int byteorderflag = SERVER; /* ie, the physical screen */ | |
230 | |
231 | |
232 | |
233 | |
234 | |
235 /* ...................... Main ..............................*/ | |
236 /* .........................................................................*/ | |
237 /* .........................................................................*/ | |
238 | |
239 | |
240 | |
241 | |
242 void main (int argc, char *argv[]) | |
243 { | |
244 int n; | |
245 int header_bytes = 0; | |
246 int alreadydrawnflag = OFF; | |
247 | |
248 char titlestring[MAX_STRING_LENGTH]; | |
249 char tempstring[MAX_STRING_LENGTH]; | |
250 | |
251 | |
252 int required_bytes; | |
253 long status; | |
254 long starttime, localtime; | |
255 long x; | |
256 | |
257 | |
258 /*-----------------------------*/ | |
259 | |
260 strcpy(progname, argv[0]); | |
261 strcpy(fontname, ""); | |
262 strcpy(inputfn, ""); | |
263 strcpy(titlestring, ""); | |
264 | |
265 /* Machine specific defaults */ | |
266 #ifdef HOST_SPARC | |
267 byteorderflag = SUN; | |
268 reversevideoflag = OFF; | |
269 #endif | |
270 #ifdef HOST_DECSTATION | |
271 byteorderflag = DEC; | |
272 reversevideoflag = ON; | |
273 #endif | |
274 #ifdef HOST_LINUXPC | |
275 byteorderflag = DEC; | |
276 reversevideoflag = ON; | |
277 #endif | |
278 | |
279 parsecommandline(argc, argv, inputfn, titlestring, fontname); | |
280 | |
281 /*-----------------------------*/ | |
282 | |
283 /* Open Display: this also finds the screen size */ | |
284 initialise_X_screen(); | |
285 | |
286 /*-----------------------------*/ | |
287 | |
288 | |
289 if (xsyncflag == ON) { | |
290 XSynchronize(display, True); | |
291 fprintf(stderr, "XSynchronize on \n");} | |
292 | |
293 inputfp = open_file(inputfn, stdin, READ); | |
294 header_bytes = readheader(inputfp, inputfn); | |
295 | |
296 /*-----------------------------*/ | |
297 | |
298 /* define bytes_per_line of the XImage. This seems to be, at least on a | |
299 * Colour SS-10, to be | |
300 * (width-1) | |
301 * ( --------- +1 ) *4 | |
302 * 32 | |
303 * where the INTEGER part of the division is all that is needed. | |
304 * | |
305 * Examples: | |
306 * width=100 to 128 bytes=16 (100 is the smallest AIM window allowed.- | |
307 * 129 -- 160 20 | |
308 * 161 -- 192 24 | |
309 * 193 -- 224 28 | |
310 */ | |
311 | |
312 reviewimage_bytesperline = (int) ((int) ((width_ctn -1) / 32) +1) *4; | |
313 | |
314 /*-----------------------------*/ | |
315 | |
316 /* Allocate lots of space: | |
317 * no of frames by .ctn size | |
318 */ | |
319 | |
320 if (depthflag == MONO) | |
321 depth = 1; | |
322 else | |
323 depth = DefaultDepth(display, screen_num); | |
324 | |
325 required_bytes = no_frames*height_ctn*reviewimage_bytesperline*depth; | |
326 | |
327 if (verboseflag == ON) { | |
328 fprintf(stderr, "xreview : reserving %i * %i * %i = %i bytes.\n", no_frames, (height_ctn*reviewimage_bytesperline), depth, required_bytes); } | |
329 | |
330 data_pointer = (char *) malloc((size_t) required_bytes); | |
331 if (data_pointer == NULL) { | |
332 fprintf(stderr, "xreview : unable to allocate %i bytes for XImage.\n", required_bytes); | |
333 fclose(inputfp); | |
334 exit(-1);} | |
335 | |
336 /* sideways scroll */ | |
337 if (sidewaysflag == ON) { | |
338 required_bytes = no_frames*height_ctn*reviewimage_bytesperline*depth; | |
339 if (verboseflag == ON) { | |
340 fprintf(stderr, "xreview : reserving %i * %i = %i bytes.\n", (no_frames*height_ctn*reviewimage_bytesperline), depth, required_bytes); } | |
341 data_pointer_sideways = (char *) malloc((size_t) required_bytes); | |
342 if (data_pointer_sideways == NULL) { | |
343 fprintf(stderr, "xreview : unable to allocate %i bytes for XImage.\n", required_bytes); | |
344 fclose(inputfp); | |
345 exit(-1);}} | |
346 | |
347 /*-----------------------------*/ | |
348 | |
349 /* load .ctn data */ | |
350 loaddata(inputfp); | |
351 close_files(inputfp); | |
352 if (animate_stop == 9999) | |
353 animate_stop = no_frames; | |
354 | |
355 if (sidewaysflag == ON) { | |
356 for (x=location[0]; x<=location[0]+required_bytes-1; x++) | |
357 data_pointer_sideways[x] = data_pointer[x];} | |
358 | |
359 /*-----------------------------*/ | |
360 | |
361 /* Find a font, in this order: | |
362 * 1. command-line | |
363 * 2. Times family | |
364 * 3. Lucida family. | |
365 * If can't find any, should crash. | |
366 */ | |
367 | |
368 font_info = NULL; | |
369 | |
370 if ((strcmp(fontname, "") == 0 ) || | |
371 ((font_info = XLoadQueryFont(display, fontname)) == NULL)) { | |
372 sprintf(fontname, "-adobe-times-medium-r-normal--%i-*-*-*-*-*-*-*", pointsize); | |
373 if ((font_info = XLoadQueryFont(display, fontname)) == NULL) { | |
374 sprintf(fontname, "-b&h-lucida-medium-r-normal-sans-%i-*-*-*-*-*-*-*", pointsize); | |
375 if ((font_info = XLoadQueryFont(display, fontname)) == NULL) { | |
376 fprintf(stderr, "xreview : unable to find fonts.\n"); | |
377 exit(-1); }}} | |
378 | |
379 /*-----------------------------*/ | |
380 | |
381 /* define a cursor */ | |
382 cursor = XCreateFontCursor(display, XC_top_left_arrow); | |
383 | |
384 /*-----------------------------*/ | |
385 | |
386 initialise_axes_window(inputfn, titlestring, inputfp, argv, argc); | |
387 XMapWindow(display, axes.win); | |
388 | |
389 /* define the background pixmap */ | |
390 stipple_pixmap = XCreatePixmapFromBitmapData(display, \ | |
391 RootWindow(display, screen_num), stipple_a_bits, \ | |
392 stipple_a_width, stipple_a_height, \ | |
393 BlackPixel(display, screen_num), \ | |
394 WhitePixel(display, screen_num), \ | |
395 DefaultDepth(display, screen_num)); | |
396 | |
397 initialise_control_window(inputfn, titlestring, inputfp, argv, argc); | |
398 if (controlwindowflag == ON) | |
399 XMapWindow(display, control.win); | |
400 | |
401 initialise_buttons(); | |
402 | |
403 initialise_image(); | |
404 | |
405 /*------------------------------*/ | |
406 | |
407 | |
408 | |
409 /*----------------------------- | |
410 * EVENT LOOP | |
411 *----------------------------- | |
412 */ | |
413 | |
414 | |
415 | |
416 while (1) { | |
417 XNextEvent(display, &report); | |
418 | |
419 if (report.xany.window == axes.win) | |
420 switch_axes(); | |
421 else if (report.xany.window == control.win) | |
422 switch_control(); | |
423 else | |
424 switch_buttons(); | |
425 | |
426 } /* while */ | |
427 | |
428 | |
429 /*---------------------------------------------------------*/ | |
430 | |
431 | |
432 } /* main */ | |
433 | |
434 | |
435 | |
436 | |
437 | |
438 /*......................................................................*/ | |
439 /*......................................................................*/ | |
440 | |
441 | |
442 | |
443 | |
444 | |
445 void parsecommandline(int argc, char *argv[], char inputfn[], char titlestring[], char fontname[]) | |
446 { | |
447 int x=1, helpflag = OFF; | |
448 int control_width =0; | |
449 char control_size[MAX_STRING_LENGTH]; | |
450 | |
451 strcpy(control_size, ""); | |
452 | |
453 while (x < argc){ | |
454 if (!strcmp(argv[x], "-input")) {strcpy(inputfn, argv[x+1]); x+=2;} | |
455 else if (!strcmp(argv[x], "-inp")) {strcpy(inputfn, argv[x+1]); x+=2;} | |
456 else if (!strcmp(argv[x], "-i")) {strcpy(inputfn, argv[x+1]); x+=2;} | |
457 | |
458 else if (!strcmp(argv[x], "-help")) {helpflag = ON; x+=1;} | |
459 else if (!strcmp(argv[x], "-h")) {helpflag = ON; x+=1;} | |
460 else if (!strcmp(argv[x], "-verbose")) {verboseflag = ON; x+=1;} | |
461 else if (!strcmp(argv[x], "-ver")) {verboseflag = ON; x+=1;} | |
462 else if (!strcmp(argv[x], "-v")) {verboseflag = ON; x+=1;} | |
463 | |
464 else if (!strcmp(argv[x], "-side")) {sidewaysflag = ON; x+=1;} | |
465 else if (!strcmp(argv[x], "-sideways")) {sidewaysflag = ON; x+=1;} | |
466 else if (!strcmp(argv[x], "-controls")) {controlwindowflag = ON; x+=1;} | |
467 else if (!strcmp(argv[x], "-con")) {controlwindowflag = ON; x+=1;} | |
468 else if (!strcmp(argv[x], "-c")) {controlwindowflag = ON; x+=1;} | |
469 else if (!strcmp(argv[x], "-controls_x")) {controls_xflag = ON; new_control_x = atoi(argv[x+1]); x+=2;} | |
470 else if (!strcmp(argv[x], "-cx")) {controls_xflag = ON; new_control_x = atoi(argv[x+1]); x+=2;} | |
471 else if (!strcmp(argv[x], "-controls_y")) {controls_yflag = ON; new_control_y = atoi(argv[x+1]); x+=2;} | |
472 else if (!strcmp(argv[x], "-cy")) {controls_yflag = ON; new_control_y = atoi(argv[x+1]); x+=2;} | |
473 else if (!strcmp(argv[x], "-image_x")) {axes_xflag = ON; new_axes_x = atoi(argv[x+1]); x+=2;} | |
474 else if (!strcmp(argv[x], "-ix")) {axes_xflag = ON; new_axes_x = atoi(argv[x+1]); x+=2;} | |
475 else if (!strcmp(argv[x], "-image_y")) {axes_yflag = ON; new_axes_y = atoi(argv[x+1]); x+=2;} | |
476 else if (!strcmp(argv[x], "-iy")) {axes_yflag = ON; new_axes_y = atoi(argv[x+1]); x+=2;} | |
477 else if (!strcmp(argv[x], "-controls_scale")) {scale = atof(argv[x+1]); x+=2;} | |
478 else if (!strcmp(argv[x], "-cscale")) {scale = atof(argv[x+1]); x+=2;} | |
479 else if (!strcmp(argv[x], "-controls_width")) {control_width = atoi(argv[x+1]); x+=2;} | |
480 else if (!strcmp(argv[x], "-cw")) {control_width = atoi(argv[x+1]); x+=2;} | |
481 else if (!strcmp(argv[x], "-controls_size")) {strcpy(control_size, argv[x+1]); x+=2;} | |
482 else if (!strcmp(argv[x], "-csize")) {strcpy(control_size, argv[x+1]); x+=2;} | |
483 | |
484 else if (!strcmp(argv[x], "-display")) {strcpy(display_name, argv[x+1]); x+=2;} | |
485 else if (!strcmp(argv[x], "-d")) {strcpy(display_name, argv[x+1]); x+=2;} | |
486 else if (!strcmp(argv[x], "-font")) {strcpy(fontname, argv[x+1]); x+=2;} | |
487 else if (!strcmp(argv[x], "-fn")) {strcpy(fontname, argv[x+1]); x+=2;} | |
488 else if (!strcmp(argv[x], "-point")) {pointsize = atoi(argv[x+1]); x+=2;} | |
489 else if (!strcmp(argv[x], "-p")) {pointsize = atoi(argv[x+1]); x+=2;} | |
490 | |
491 else if (!strcmp(argv[x], "-wait")) {waittime_millisecs = atol(argv[x+1]); x+=2;} | |
492 else if (!strcmp(argv[x], "-w")) {waittime_millisecs = atol(argv[x+1]); x+=2;} | |
493 else if (!strcmp(argv[x], "-speed")) {waittime_millisecs = atol(argv[x+1]); x+=2;} | |
494 else if (!strcmp(argv[x], "-start")) {animate_start = atoi(argv[x+1]); x+=2;} | |
495 else if (!strcmp(argv[x], "-stop")) {animate_stop = atoi(argv[x+1]); x+=2;} | |
496 else if (!strcmp(argv[x], "-skip")) {animate_skip = atoi(argv[x+1]); x+=2;} | |
497 else if (!strcmp(argv[x], "-frame")) {frame = atoi(argv[x+1]); x+=2;} | |
498 else if (!strcmp(argv[x], "-fra")) {frame = atoi(argv[x+1]); x+=2;} | |
499 | |
500 else if (!strcmp(argv[x], "-title")) {titleflag = ON; strcpy(titlestring, argv[x+1]); x+=2;} | |
501 else if (!strcmp(argv[x], "-tit")) {titleflag = ON; strcpy(titlestring, argv[x+1]); x+=2;} | |
502 else if (!strcmp(argv[x], "-t")) {titleflag = ON; strcpy(titlestring, argv[x+1]); x+=2;} | |
503 else if (!strcmp(argv[x], "-mono")) {depthflag = MONO; x+=1;} | |
504 else if (!strcmp(argv[x], "-colour")) {depthflag = COLOUR; planemask = AllPlanes; x+=1; } | |
505 else if (!strcmp(argv[x], "-planemask")) {planemask = atoi(argv[x+1]); x+=2;} | |
506 else if (!strcmp(argv[x], "-xsync")) {xsyncflag = ON; x+=1;} | |
507 else if (!strcmp(argv[x], "-rv")) {if (reversevideoflag == ON) | |
508 reversevideoflag = OFF; | |
509 else | |
510 reversevideoflag = ON; | |
511 x+=1;} | |
512 else if (!strcmp(argv[x], "-lsb")) {byteorderflag = DEC; x+=1;} | |
513 else if (!strcmp(argv[x], "-msb")) {byteorderflag = SUN; x+=1;} | |
514 else if (!strcmp(argv[x], "-dec")) {byteorderflag = DEC; reversevideoflag = ON; x+=1;} | |
515 else if (!strcmp(argv[x], "-sun")) {byteorderflag = SUN; reversevideoflag = OFF; x+=1;} | |
516 else if (x = (argc-1)) {strcpy(inputfn, argv[x]); x+=1;} | |
517 | |
518 else {fprintf(stderr, "xreview: unknown option %s\n", argv[x]); | |
519 exit(-1);} | |
520 | |
521 } | |
522 | |
523 if (helpflag == ON) | |
524 { | |
525 fprintf(stderr, "\n"); | |
526 fprintf(stderr, "--------------------------------------------------------------------------------\n"); | |
527 fprintf(stderr, " xreview\n"); | |
528 fprintf(stderr, "--------------------------------------------------------------------------------\n\n"); | |
529 fprintf(stderr, " usage: xreview -input 'filename.ctn' <options> \n"); | |
530 fprintf(stderr, " or xreview <options> 'filename.ctn' \n"); | |
531 fprintf(stderr, " or cat 'filename.ctn' | xreview <options> \n\n\n"); | |
532 fprintf(stderr, " Command line options Abbrev.\n"); | |
533 fprintf(stderr, "--------------------------------------------------------------------------------\n"); | |
534 fprintf(stderr, "-input <.ctn file> Input file (default = stdin). -i\n"); | |
535 fprintf(stderr, "\n"); | |
536 fprintf(stderr, "-controls Map Controls window. -con\n"); | |
537 fprintf(stderr, "-controls_x <int> Controls window position (pixels). -cx\n"); | |
538 fprintf(stderr, "-controls_y <int> Controls window position (pixels). -cy\n"); | |
539 fprintf(stderr, "-controls_width <int> Controls window width (pixels). -cw\n"); | |
540 fprintf(stderr, "-controls_scale <flt> Scale factor for size of Controls Window. -cscale\n"); | |
541 fprintf(stderr, "-controls_size Controls Window size: 'tiny', 'small' or 'normal'. -csize\n"); | |
542 fprintf(stderr, "-image_x <int> Image position (pixels). -ix\n"); | |
543 fprintf(stderr, "-image_y <int> Image position (pixels). -iy\n"); | |
544 fprintf(stderr, "\n"); | |
545 fprintf(stderr, "-display <string> X Display server to use. -d\n"); | |
546 fprintf(stderr, "-font <string> Font. -fn\n"); | |
547 fprintf(stderr, "-point <int> Point-size of default font (Times, medium weight). -p\n"); | |
548 fprintf(stderr, "-title <string> Title of Image window & icon. -t\n"); | |
549 fprintf(stderr, "-mono Assume Monochrome (single-plane) cartoons. (default) \n"); | |
550 fprintf(stderr, "-colour Assume Colour (multiplane) cartoons. \n"); | |
551 fprintf(stderr, "-planemask <int> Value of PlaneMask for copying XImage (default=1) \n"); | |
552 fprintf(stderr, "-rv Reverse-video the cartoon window colours. \n"); | |
553 fprintf(stderr, "-lsb Assume cartoon's bit & byte orders are LSBFirst (ie, DEC).\n"); | |
554 fprintf(stderr, "-msb Assume cartoon's bit & byte orders are MSBFirst (ie, Sun).\n"); | |
555 fprintf(stderr, "-dec Alias for -lsb -rv \n"); | |
556 fprintf(stderr, "-sun Alias for -msb \n"); | |
557 fprintf(stderr, "\n"); | |
558 fprintf(stderr, "-speed <int> Wait-time between frames (msecs) (default = %i). -speed\n", waittime_millisecs); | |
559 fprintf(stderr, "-start <int> Animation start (frames) (default=1). -start\n"); | |
560 fprintf(stderr, "-stop <int> Animation stop (frames) (default=last frame). -stop\n"); | |
561 fprintf(stderr, "-skip <int> Animation skip (frames) (default=1). -skip\n"); | |
562 fprintf(stderr, "-frame <int> Initial display frame (default=1). -fra\n"); | |
563 fprintf(stderr, "-sideways Scroll cartoon sideways (right->left) -side\n"); | |
564 fprintf(stderr, "\n"); | |
565 fprintf(stderr, "-verbose Print some running information (to stderr). -v\n"); | |
566 fprintf(stderr, "-help Print this page (to stderr). -h\n"); | |
567 fprintf(stderr, "\n\n" ); | |
568 fprintf(stderr, " Image Window Controls \n"); | |
569 fprintf(stderr, "--------------------------------------------------------------------------------\n"); | |
570 fprintf(stderr, " Left button Animate cartoon. \n"); | |
571 fprintf(stderr, " Middle button Map Controls window. \n"); | |
572 fprintf(stderr, " Right button Quit. \n\n"); | |
573 fprintf(stderr, " SPACE or RET Animate cartoon. \n"); | |
574 fprintf(stderr, " F or f Set speed faster by x2. \n"); | |
575 fprintf(stderr, " S or s Set speed slower by x2. \n"); | |
576 fprintf(stderr, " N or n Next frame. \n"); | |
577 fprintf(stderr, " P or p Previous frame. \n"); | |
578 fprintf(stderr, " Q or q Quit. \n"); | |
579 fprintf(stderr, "\n\n"); | |
580 exit(-1);} | |
581 | |
582 if (strcmp(control_size, "") != 0){ | |
583 if (strcmp(control_size, "normal") == 0) { | |
584 scale=1.00; | |
585 pointsize=18;} | |
586 else if (strcmp(control_size, "small") == 0) { | |
587 scale=0.80; | |
588 pointsize=14;} | |
589 else if (strcmp(control_size, "tiny") == 0) { | |
590 scale=0.60; | |
591 pointsize=10;} | |
592 else { | |
593 fprintf(stderr, "xreview : illegal control_size value.\n"); | |
594 exit(-1);} | |
595 } | |
596 | |
597 if (control_width != 0) | |
598 scale = (double) control_width / CONTROL_WIDTH; | |
599 | |
600 | |
601 } | |
602 | |
603 | |
604 /* The end.*/ | |
605 | |
606 | |
607 /*-------------------------------------------------------------------------*/ | |
608 /*-------------------------------------------------------------------------*/ | |
609 | |
610 | |
611 | |
612 | |
613 | |
614 |