1 /*
2  * Copyright (C) 1990 Regents of the University of California.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation for any purpose is hereby granted without fee,
6  * provided that the above copyright notice appear in all copies and that
7  * both that copyright notice and this permission notice appear in
8  * supporting documentation, and that the name of the University of
9  * California not be used in advertising or publicity pertaining to
10  * distribution of the software without specific, written prior
11  * permission.  the University of California makes no representations
12  * about the suitability of this software for any purpose.  It is provided
13  * "as is" without express or implied warranty.
14  */
15 
16 # include <X11/Intrinsic.h>
17 # include <X11/StringDefs.h>
18 # include <X11/Xaw/Label.h>
19 
20 # include "cdrom_globs.h"
21 
22 # include "circle0a.xbm"
23 # include "circle0b.xbm"
24 # include "circle0c.xbm"
25 # include "circle0d.xbm"
26 # include "circle0e.xbm"
27 # include "circle0f.xbm"
28 # include "circle0g.xbm"
29 # include "circle0h.xbm"
30 # include "circle00.xbm"
31 
32 static Widget	leds_label_widget;
33 
34 # define NUM_LEDS	8
35 
36 static Pixmap	leds_pixmaps[NUM_LEDS];
37 static Pixmap	leds_pixmap;
38 
39 void
leds_update(Direction)40 leds_update(Direction)
41 int	Direction;
42 {
43 	static int	ctr = 1;
44 	Arg		args[1];
45 	Pixmap		leds;
46 
47 
48 	if (Direction == BACKWARDS)
49 	    leds = leds_pixmaps[(ctr += NUM_LEDS - 1) % NUM_LEDS];
50 	else
51 	    leds = leds_pixmaps[ctr++ % NUM_LEDS];
52 
53 	XtSetArg(args[0], XtNbitmap, (XtArgVal) leds);
54 	XtSetValues(leds_label_widget, args, 1);
55 }
56 
57 void
leds_stop()58 leds_stop() {
59 	Arg		args[1];
60 
61 	XtSetArg(args[0], XtNbitmap, (XtArgVal) leds_pixmap);
62 	XtSetValues(leds_label_widget, args, 1);
63 }
64 
65 void
leds_label_setup(parent_widget)66 leds_label_setup(parent_widget)
67 	Widget		parent_widget;
68 {
69 	Arg		args[1];
70 
71 	leds_label_widget = XtCreateManagedWidget("ledsLabel",
72 						  labelWidgetClass,
73 						  parent_widget,
74 						  (ArgList) NULL, 0);
75 
76 	leds_pixmaps[0] = XCreateBitmapFromData(XtDisplay(leds_label_widget),
77 						rootwin(leds_label_widget),
78 						circle0a_bits,
79 						circle0a_width, circle0a_height);
80 	leds_pixmaps[1] = XCreateBitmapFromData(XtDisplay(leds_label_widget),
81 						rootwin(leds_label_widget),
82 						circle0b_bits,
83 						circle0b_width, circle0b_height);
84 	leds_pixmaps[2] = XCreateBitmapFromData(XtDisplay(leds_label_widget),
85 						rootwin(leds_label_widget),
86 						circle0c_bits,
87 						circle0c_width, circle0c_height);
88 	leds_pixmaps[3] = XCreateBitmapFromData(XtDisplay(leds_label_widget),
89 						rootwin(leds_label_widget),
90 						circle0d_bits,
91 						circle0d_width, circle0d_height);
92 	leds_pixmaps[4] = XCreateBitmapFromData(XtDisplay(leds_label_widget),
93 						rootwin(leds_label_widget),
94 						circle0e_bits,
95 						circle0e_width, circle0e_height);
96 	leds_pixmaps[5] = XCreateBitmapFromData(XtDisplay(leds_label_widget),
97 						rootwin(leds_label_widget),
98 						circle0f_bits,
99 						circle0f_width, circle0f_height);
100 	leds_pixmaps[6] = XCreateBitmapFromData(XtDisplay(leds_label_widget),
101 						rootwin(leds_label_widget),
102 						circle0g_bits,
103 						circle0g_width, circle0g_height);
104 	leds_pixmaps[7] = XCreateBitmapFromData(XtDisplay(leds_label_widget),
105 						rootwin(leds_label_widget),
106 						circle0h_bits,
107 						circle0h_width, circle0h_height);
108 
109 	leds_pixmap = XCreateBitmapFromData(XtDisplay(leds_label_widget),
110 					     rootwin(leds_label_widget),
111 					     circle00_bits,
112 					     circle00_width, circle00_height);
113 
114 	XtSetArg(args[0], XtNbitmap, (XtArgVal) leds_pixmap);
115 	XtSetValues(leds_label_widget, args, 1);
116 }
117