23 |
#include "library.h" |
#include "library.h" |
24 |
#include <locale.h> |
#include <locale.h> |
25 |
|
|
26 |
|
|
27 |
/* Set the icon and window title of a particular widget. */ |
/* Set the icon and window title of a particular widget. */ |
28 |
void |
void |
29 |
antiright_set_widget_title(Widget widget, const char* name) |
antiright_set_widget_title(Widget widget, const char* name) |
41 |
antiright_set_widget_title(antiright.parent_widget, name); |
antiright_set_widget_title(antiright.parent_widget, name); |
42 |
} |
} |
43 |
|
|
44 |
void |
Pixmap |
45 |
antiright_set_widget_icon_resource(Widget widget, String resource, |
antiright_file_to_bitmap(char *filename) |
|
unsigned char bits[], |
|
|
int width, int height) |
|
46 |
{ |
{ |
47 |
ARCLARG; |
Pixmap bitmap; |
48 |
antiright_set(resource, (XtArgVal)XCreateBitmapFromData(antiright.display, |
int width, height, x_hot, y_hot; |
49 |
antiright.root_window, |
XReadBitmapFile(antiright.display, antiright.root_window, filename, |
50 |
(const char*)bits, |
&width, &height, &bitmap, &x_hot, &y_hot); |
51 |
width, height)); |
return(bitmap); |
52 |
antiright_set_values(widget); |
} |
53 |
ARCLARG; |
|
54 |
|
char * |
55 |
|
antiright_get_file_extension(char *filename) |
56 |
|
{ |
57 |
|
char *extension=(char*)xmalloc(4); |
58 |
|
unsigned int filename_length=strlen(filename); |
59 |
|
unsigned int counter=filename_length-3; |
60 |
|
unsigned int extension_counter=0; |
61 |
|
|
62 |
|
|
63 |
|
while(counter < filename_length) |
64 |
|
{ |
65 |
|
extension[extension_counter]=filename[counter]; |
66 |
|
counter++; |
67 |
|
extension_counter++; |
68 |
|
} |
69 |
|
extension[extension_counter]='\0'; |
70 |
|
return(extension); |
71 |
|
} |
72 |
|
|
73 |
|
XpmAttributes |
74 |
|
antiright_setup_pixmap_attributes_for_widget(Widget widget) |
75 |
|
{ |
76 |
|
Pixel background; |
77 |
|
XpmAttributes attributes; |
78 |
|
XpmColorSymbol symbol; |
79 |
|
XtVaGetValues(widget, XmNbackground, &background, NULL); |
80 |
|
symbol.name=NULL; |
81 |
|
symbol.value="none"; |
82 |
|
symbol.pixel=background; |
83 |
|
attributes.colorsymbols=&symbol; |
84 |
|
attributes.numsymbols=1; |
85 |
|
attributes.valuemask=XpmColorSymbols; |
86 |
|
return(attributes); |
87 |
} |
} |
88 |
|
|
|
/* Set the icon bitmap. */ |
|
89 |
void |
void |
90 |
antiright_set_icon(unsigned char bits[]) |
antiright_set_widget_pixmaps(Widget label, Pixmap bitmap) |
91 |
{ |
{ |
92 |
antiright_set_widget_icon_resource(antiright.parent_widget, XmNiconPixmap, |
XtVaSetValues(label, |
93 |
bits, 48, 48); |
XmNlabelType, XmPIXMAP, |
94 |
|
XmNlabelPixmap, bitmap, |
95 |
|
XmNiconPixmap, bitmap, |
96 |
|
NULL); |
97 |
|
#if XmVERSION > 1 & XmREVISION > 1 |
98 |
|
XtVaSetValues(label, XmNpixmap, bitmap, NULL); |
99 |
|
#endif /* XmVERSION > 1 & XmREVISION > 1 */ |
100 |
|
} |
101 |
|
void |
102 |
|
antiright_set_pixmap_from_data(Widget widget, char **data) |
103 |
|
{ |
104 |
|
Pixmap bitmap; |
105 |
|
XpmAttributes attributes; |
106 |
|
attributes=antiright_setup_pixmap_attributes_for_widget(widget); |
107 |
|
XpmCreatePixmapFromData(antiright.display, antiright.root_window, |
108 |
|
data, &bitmap, NULL, &attributes); |
109 |
|
antiright_set_widget_pixmaps(widget, bitmap); |
110 |
|
} |
111 |
|
|
112 |
|
void |
113 |
|
antiright_set_bitmap_from_file(Widget label, char* filename) |
114 |
|
{ |
115 |
|
Pixmap bitmap; |
116 |
|
char *extension=antiright_get_file_extension(filename); |
117 |
|
|
118 |
|
if(!strncmp(extension, "xpm", 3)) /* File is a pixmap. */ |
119 |
|
{ |
120 |
|
XpmAttributes attributes; |
121 |
|
attributes=antiright_setup_pixmap_attributes_for_widget(label); |
122 |
|
XpmReadFileToPixmap(antiright.display, antiright.root_window, |
123 |
|
filename, &bitmap, NULL, &attributes); |
124 |
|
} |
125 |
|
else /* File is a bitmap. */ |
126 |
|
{ |
127 |
|
bitmap=antiright_file_to_bitmap(filename); |
128 |
|
} |
129 |
|
free(extension); |
130 |
|
antiright_set_widget_pixmaps(label, bitmap); |
131 |
} |
} |
132 |
|
|
133 |
void |
void |
193 |
void |
void |
194 |
antiright_initialize_application(int* argc, |
antiright_initialize_application(int* argc, |
195 |
char** argv, |
char** argv, |
196 |
const char* name, |
const char* name) |
|
unsigned char bits[]) |
|
197 |
{ |
{ |
198 |
antiright_setup_xt(argc, argv); |
antiright_setup_xt(argc, argv); |
199 |
antiright_initialize_antiright_data(); |
antiright_initialize_antiright_data(); |
|
antiright_set_icon(bits); |
|
200 |
antiright_set_title(name); |
antiright_set_title(name); |
201 |
antiright_system("ACE -c &"); |
antiright_system("ACE -c &"); |
202 |
} |
} |