34 |
Widget arcolor_preview_widget; |
Widget arcolor_preview_widget; |
35 |
|
|
36 |
void |
void |
37 |
arcolor_allocate_color(XColor *color) |
arcolor_allocate_color (XColor * color) |
38 |
{ |
{ |
39 |
Colormap colormap; |
Colormap colormap; |
40 |
|
|
41 |
/* These options are set often enough, so set them in this generic |
/* These options are set often enough, so set them in this generic |
42 |
function. */ |
function. */ |
43 |
color->flags=DoRed|DoGreen|DoBlue; |
color->flags = DoRed | DoGreen | DoBlue; |
44 |
colormap=DefaultColormap(antiright.display, antiright.screen); |
colormap = DefaultColormap (antiright.display, antiright.screen); |
45 |
XAllocColor(antiright.display,colormap,color); |
XAllocColor (antiright.display, colormap, color); |
46 |
} |
} |
47 |
|
|
48 |
void |
void |
49 |
arcolor_update_preview() |
arcolor_update_preview () |
50 |
{ |
{ |
51 |
XColor color; |
XColor color; |
52 |
char* label_string; |
char *label_string; |
53 |
|
|
54 |
XmScaleGetValue(arcolor_red_widget, (int*)&color.red); |
XmScaleGetValue (arcolor_red_widget, (int *) &color.red); |
55 |
XmScaleGetValue(arcolor_green_widget, (int*)&color.green); |
XmScaleGetValue (arcolor_green_widget, (int *) &color.green); |
56 |
XmScaleGetValue(arcolor_blue_widget, (int*)&color.blue); |
XmScaleGetValue (arcolor_blue_widget, (int *) &color.blue); |
57 |
|
|
58 |
asprintf(&label_string, "rgb:%x/%x/%x", color.red, color.green, color.blue); |
asprintf (&label_string, "rgb:%x/%x/%x", color.red, color.green, |
59 |
antiright_label_string(arcolor_preview_widget, label_string); |
color.blue); |
60 |
free(label_string); |
antiright_label_string (arcolor_preview_widget, label_string); |
61 |
|
free (label_string); |
62 |
color.red=color.red*256; |
|
63 |
color.green=color.green*256; |
color.red = color.red * 256; |
64 |
color.blue=color.blue*256; |
color.green = color.green * 256; |
65 |
|
color.blue = color.blue * 256; |
66 |
arcolor_allocate_color(&color); |
|
67 |
|
arcolor_allocate_color (&color); |
68 |
XtVaSetValues(arcolor_preview_widget, |
|
69 |
XmNbackground, color.pixel, |
XtVaSetValues (arcolor_preview_widget, XmNbackground, color.pixel, NULL); |
|
NULL); |
|
70 |
} |
} |
71 |
|
|
72 |
void |
void |
73 |
antiright_color_scale_cb() |
antiright_color_scale_cb () |
74 |
{ |
{ |
75 |
arcolor_update_preview(); |
arcolor_update_preview (); |
76 |
} |
} |
77 |
|
|
78 |
void |
void |
79 |
arcolor_set_scale_resources() |
arcolor_set_scale_resources () |
80 |
{ |
{ |
81 |
antiright_set(XmNorientation, XmHORIZONTAL); |
antiright_set (XmNorientation, XmHORIZONTAL); |
82 |
antiright_set(XmNmaximum, 255); |
antiright_set (XmNmaximum, 255); |
83 |
antiright_set(XmNwidth, 255); |
antiright_set (XmNwidth, 255); |
84 |
antiright_set(XmNvalue, 0); |
antiright_set (XmNvalue, 0); |
85 |
antiright_set(XmNshowValue, True); |
antiright_set (XmNshowValue, True); |
86 |
} |
} |
87 |
|
|
88 |
Widget |
Widget |
89 |
arcolor_scale(Widget parent_widget, |
arcolor_scale (Widget parent_widget, char *title_string) |
|
char *title_string) |
|
90 |
{ |
{ |
91 |
Widget scale_widget; |
Widget scale_widget; |
92 |
XmString title_motif_string=XmStringCreateLocalized(title_string); |
XmString title_motif_string = XmStringCreateLocalized (title_string); |
93 |
arcolor_set_scale_resources(); |
arcolor_set_scale_resources (); |
94 |
antiright_set(XmNtitleString, (XtArgVal)title_motif_string); |
antiright_set (XmNtitleString, (XtArgVal) title_motif_string); |
95 |
scale_widget=XmCreateScale(parent_widget,"scale_widget", |
scale_widget = XmCreateScale (parent_widget, "scale_widget", |
96 |
antiright.arguments, antiright.arguments_int); |
antiright.arguments, antiright.arguments_int); |
97 |
XmStringFree(title_motif_string); |
XmStringFree (title_motif_string); |
98 |
XtManageChild(scale_widget); |
XtManageChild (scale_widget); |
99 |
|
|
100 |
XtAddCallback(scale_widget, |
XtAddCallback (scale_widget, |
101 |
XmNdragCallback, |
XmNdragCallback, antiright_color_scale_cb, NULL); |
102 |
antiright_color_scale_cb, |
return (scale_widget); |
|
NULL); |
|
|
return(scale_widget); |
|
103 |
} |
} |
104 |
|
|
105 |
|
|
106 |
#endif /* #if XmVERSION > 1 & XmREVISION > 1 */ |
#endif /* #if XmVERSION > 1 & XmREVISION > 1 */ |
107 |
|
|
108 |
void |
void |
109 |
arcolor_select_cb(Widget parent_widget, |
arcolor_select_cb (Widget parent_widget, |
110 |
XtPointer client_data, |
XtPointer client_data, XtPointer call_data) |
111 |
XtPointer call_data) |
{ |
|
{ |
|
112 |
#if XmVERSION > 1 & XmREVISION > 1 |
#if XmVERSION > 1 & XmREVISION > 1 |
113 |
char* color_string; |
char *color_string; |
114 |
ARCLARG; |
ARCLARG; |
115 |
antiright_set(XmNcolorName, (XtArgVal)&color_string); |
antiright_set (XmNcolorName, (XtArgVal) & color_string); |
116 |
XtGetValues((Widget)client_data, |
XtGetValues ((Widget) client_data, |
117 |
antiright.arguments, antiright.arguments_int); |
antiright.arguments, antiright.arguments_int); |
118 |
puts(color_string); |
puts (color_string); |
119 |
free(color_string); |
free (color_string); |
120 |
#else |
#else |
121 |
int red_int; |
int red_int; |
122 |
int green_int; |
int green_int; |
123 |
int blue_int; |
int blue_int; |
|
|
|
|
client_data=NULL; |
|
124 |
|
|
125 |
XmScaleGetValue(arcolor_red_widget, &red_int); |
client_data = NULL; |
126 |
XmScaleGetValue(arcolor_green_widget, &green_int); |
|
127 |
XmScaleGetValue(arcolor_blue_widget, &blue_int); |
XmScaleGetValue (arcolor_red_widget, &red_int); |
128 |
|
XmScaleGetValue (arcolor_green_widget, &green_int); |
129 |
|
XmScaleGetValue (arcolor_blue_widget, &blue_int); |
130 |
|
|
131 |
/* This is the means by which data from this program is |
/* This is the means by which data from this program is |
132 |
obtained. */ |
obtained. */ |
133 |
printf("rgb:%x/%x/%x", red_int, green_int, blue_int); |
printf ("rgb:%x/%x/%x", red_int, green_int, blue_int); |
134 |
fflush(stdout); |
fflush (stdout); |
135 |
#endif |
#endif |
136 |
|
|
137 |
parent_widget=NULL; |
parent_widget = NULL; |
138 |
call_data=NULL; |
call_data = NULL; |
139 |
|
|
140 |
exit(0); |
exit (0); |
141 |
} |
} |
142 |
|
|
143 |
Widget |
Widget |
144 |
arshell_color_widget(Widget parent_widget) |
arshell_color_widget (Widget parent_widget) |
145 |
{ |
{ |
146 |
Widget arcolor_widget; |
Widget arcolor_widget; |
147 |
#if XmVERSION > 1 & XmREVISION > 1 |
#if XmVERSION > 1 & XmREVISION > 1 |
151 |
#endif /* XmVERSION > 1 & XmREVISION > 1 */ |
#endif /* XmVERSION > 1 & XmREVISION > 1 */ |
152 |
|
|
153 |
ARCLARG; |
ARCLARG; |
154 |
antiright_form_positions(0, 100, 0, 100); |
antiright_form_positions (0, 100, 0, 100); |
155 |
arcolor_widget=antiright_form(parent_widget); |
arcolor_widget = antiright_form (parent_widget); |
156 |
|
|
157 |
#if XmVERSION > 1 & XmREVISION > 1 |
#if XmVERSION > 1 & XmREVISION > 1 |
158 |
ARCLARG; |
ARCLARG; |
159 |
antiright_form_positions(0, 95, 0, 100); |
antiright_form_positions (0, 95, 0, 100); |
160 |
color_selector_widget=XmCreateColorSelector(arcolor_widget, |
color_selector_widget = XmCreateColorSelector (arcolor_widget, |
161 |
"color_selector_widget", |
"color_selector_widget", |
162 |
antiright.arguments, |
antiright.arguments, |
163 |
antiright.arguments_int); |
antiright.arguments_int); |
164 |
XtManageChild(color_selector_widget); |
XtManageChild (color_selector_widget); |
165 |
ARCLARG; |
ARCLARG; |
166 |
antiright_form_positions(95, 100, 0, 100); |
antiright_form_positions (95, 100, 0, 100); |
167 |
antiright_button(arcolor_widget, "Select", |
antiright_button (arcolor_widget, "Select", |
168 |
arcolor_select_cb, color_selector_widget); |
arcolor_select_cb, color_selector_widget); |
169 |
#else /* not XmVERSION > 1 & not XmREVISION > 1 */ |
#else /* not XmVERSION > 1 & not XmREVISION > 1 */ |
170 |
ARCLARG; |
ARCLARG; |
171 |
antiright_form_positions(2, 66, 2, 34); |
antiright_form_positions (2, 66, 2, 34); |
172 |
preview_frame_widget=antiright_frame(arcolor_widget, XmSHADOW_IN); |
preview_frame_widget = antiright_frame (arcolor_widget, XmSHADOW_IN); |
173 |
ARCLARG; |
ARCLARG; |
174 |
arcolor_preview_widget=antiright_label(preview_frame_widget, "Color"); |
arcolor_preview_widget = antiright_label (preview_frame_widget, "Color"); |
175 |
ARCLARG; |
ARCLARG; |
176 |
antiright_form_positions(66, 98, 2, 34); |
antiright_form_positions (66, 98, 2, 34); |
177 |
antiright_button(arcolor_widget,"Select",arcolor_select_cb,NULL); |
antiright_button (arcolor_widget, "Select", arcolor_select_cb, NULL); |
178 |
ARCLARG; |
ARCLARG; |
179 |
antiright_form_positions(2, 34, 34, 98); |
antiright_form_positions (2, 34, 34, 98); |
180 |
arcolor_red_widget=arcolor_scale(arcolor_widget, "Red"); |
arcolor_red_widget = arcolor_scale (arcolor_widget, "Red"); |
181 |
ARCLARG; |
ARCLARG; |
182 |
antiright_form_positions(34, 66, 34, 98); |
antiright_form_positions (34, 66, 34, 98); |
183 |
arcolor_green_widget=arcolor_scale(arcolor_widget, "Green"); |
arcolor_green_widget = arcolor_scale (arcolor_widget, "Green"); |
184 |
XtManageChild(arcolor_green_widget); |
XtManageChild (arcolor_green_widget); |
185 |
ARCLARG; |
ARCLARG; |
186 |
antiright_form_positions(66, 98, 34, 98); |
antiright_form_positions (66, 98, 34, 98); |
187 |
arcolor_blue_widget=arcolor_scale(arcolor_widget, "Blue"); |
arcolor_blue_widget = arcolor_scale (arcolor_widget, "Blue"); |
188 |
arcolor_update_preview(); |
arcolor_update_preview (); |
189 |
|
|
190 |
#endif /* XmVERSION > 1 & XmREVISION > 1 */ |
#endif /* XmVERSION > 1 & XmREVISION > 1 */ |
191 |
|
|
192 |
return(arcolor_widget); |
return (arcolor_widget); |
193 |
} |
} |