added balloon help
[wmaker-crm.git] / WPrefs.app / Appearance.c
blobe7e834943c82abf6cb94653b3b00dabe7a67a7ef
1 /* Apperance.c- color/texture for titlebar etc.
2 *
3 * WPrefs - Window Maker Preferences Program
4 *
5 * Copyright (c) 1999 Alfredo K. Kojima
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 * USA.
24 #include "WPrefs.h"
26 #include <unistd.h>
27 #include <errno.h>
28 #include <ctype.h>
29 #include <time.h>
30 #include <sys/stat.h>
31 #include <sys/types.h>
32 #include <fcntl.h>
33 #include <unistd.h>
38 #include "TexturePanel.h"
40 typedef struct _Panel {
41 WMFrame *frame;
42 char *sectionName;
44 char *description;
46 CallbackRec callbacks;
48 WMWindow *win;
50 WMLabel *prevL;
52 WMPopUpButton *secP;
54 /* texture list */
55 WMLabel *texL;
56 WMList *texLs;
57 WMLabel *texsL;
59 WMButton *newB;
60 WMButton *editB;
61 WMButton *ripB;
62 WMButton *delB;
64 int textureIndex[8];
66 WMFont *smallFont;
67 WMFont *normalFont;
68 WMFont *boldFont;
70 TexturePanel *texturePanel;
72 WMPixmap *onLed;
73 WMPixmap *offLed;
74 WMPixmap *hand;
76 int oldsection;
78 Pixmap preview;
80 char *fprefix;
81 } _Panel;
84 typedef struct {
85 char *title;
86 char *texture;
87 proplist_t prop;
88 Pixmap preview;
90 char *path;
92 char selectedFor;
93 unsigned current:1;
94 unsigned ispixmap:1;
95 } TextureListItem;
98 static void showData(_Panel *panel);
100 static void changePage(WMWidget *w, void *data);
102 static void OpenExtractPanelFor(_Panel *panel, char *path);
104 #define ICON_FILE "appearance"
106 #define TNEW_FILE "tnew"
107 #define TDEL_FILE "tdel"
108 #define TEDIT_FILE "tedit"
109 #define TEXTR_FILE "textr"
113 /* XPM */
114 static char * blueled_xpm[] = {
115 "8 8 17 1",
116 " c None",
117 ". c #020204",
118 "+ c #16B6FC",
119 "@ c #176AFC",
120 "# c #163AFC",
121 "$ c #72D2FC",
122 "% c #224CF4",
123 "& c #76D6FC",
124 "* c #16AAFC",
125 "= c #CEE9FC",
126 "- c #229EFC",
127 "; c #164CFC",
128 "> c #FAFEFC",
129 ", c #2482FC",
130 "' c #1652FC",
131 ") c #1E76FC",
132 "! c #1A60FC",
133 " .... ",
134 " .=>-@. ",
135 ".=>$@@'.",
136 ".=$@!;;.",
137 ".!@*+!#.",
138 ".#'*+*,.",
139 " .@)@,. ",
140 " .... "};
143 /* XPM */
144 static char *blueled2_xpm[] = {
145 /* width height num_colors chars_per_pixel */
146 " 8 8 17 1",
147 /* colors */
148 ". c None",
149 "# c #090909",
150 "a c #4b63a4",
151 "b c #011578",
152 "c c #264194",
153 "d c #04338c",
154 "e c #989dac",
155 "f c #011a7c",
156 "g c #465c9c",
157 "h c #03278a",
158 "i c #6175ac",
159 "j c #011e74",
160 "k c #043a90",
161 "l c #042f94",
162 "m c #0933a4",
163 "n c #022184",
164 "o c #012998",
165 /* pixels */
166 "..####..",
167 ".#aimn#.",
168 "#aechnf#",
169 "#gchnjf#",
170 "#jndknb#",
171 "#bjdddl#",
172 ".#nono#.",
173 "..####.."
176 /* XPM */
177 static char * hand_xpm[] = {
178 "22 21 17 1",
179 " c None",
180 ". c #030305",
181 "+ c #101010",
182 "@ c #535355",
183 "# c #7F7F7E",
184 "$ c #969697",
185 "% c #B5B5B6",
186 "& c #C5C5C6",
187 "* c #D2D2D0",
188 "= c #DCDCDC",
189 "- c #E5E5E4",
190 "; c #ECECEC",
191 "> c #767674",
192 ", c #F2F2F4",
193 "' c #676767",
194 ") c #FDFDFB",
195 "! c #323234",
196 " ",
197 " ..... ",
198 " ..#%&&$. ",
199 " .))),%.......... ",
200 " .)-)),&)))))))))$. ",
201 " .-&))))))))),,,,;;. ",
202 " .=)))))))));-=***&$. ",
203 " .=)))))))),..+..... ",
204 " +=)))))))))-&#. ",
205 " +=)))))))))-%>. ",
206 " +&)))))))))-%'. ",
207 " +$,,))))));... ",
208 " .#%%*;,)),*$>+ ",
209 " .'>$%&&&&$#@. ",
210 " .!'>#$##>'. ",
211 " ..+++++. ",
212 " ",
213 " ##@@@## ",
214 " @@@@@@@@@@@ ",
215 " >>@@@## ",
216 " "};
221 #define FTITLE (1<<0)
222 #define UTITLE (1<<1)
223 #define OTITLE (1<<2)
224 #define RESIZEBAR (1<<3)
225 #define MTITLE (1<<4)
226 #define MITEM (1<<5)
227 #define ICON (1<<6)
228 #define BACK (1<<7)
229 #define EVERYTHING 0xff
232 #define RESIZEBAR_BEVEL -1
233 #define MENU_BEVEL -2
235 #define TEXPREV_WIDTH 40
236 #define TEXPREV_HEIGHT 24
242 static void
243 str2rcolor(RContext *rc, char *name, RColor *color)
245 XColor xcolor;
247 XParseColor(rc->dpy, rc->cmap, name, &xcolor);
249 color->alpha = 255;
250 color->red = xcolor.red >> 8;
251 color->green = xcolor.green >> 8;
252 color->blue = xcolor.blue >> 8;
257 static void
258 dumpRImage(char *path, RImage *image)
260 FILE *f;
262 f = fopen(path, "w");
263 if (!f) {
264 wsyserror(path);
265 return;
267 fprintf(f, "%02x%02x%1x", image->width, image->height,
268 image->data[3]!=NULL ? 4 : 3);
270 fwrite(image->data[0], 1, image->width * image->height, f);
271 fwrite(image->data[1], 1, image->width * image->height, f);
272 fwrite(image->data[2], 1, image->width * image->height, f);
273 if (image->data[3])
274 fwrite(image->data[3], 1, image->width * image->height, f);
276 if (fclose(f) < 0) {
277 wsyserror(path);
283 static int
284 isPixmap(proplist_t prop)
286 proplist_t p;
287 char *s;
289 p = PLGetArrayElement(prop, 0);
290 s = PLGetString(p);
291 if (strcasecmp(&s[1], "pixmap")==0)
292 return 1;
293 else
294 return 0;
298 static void
299 drawResizebarBevel(RImage *img)
301 RColor light;
302 RColor dark;
303 RColor black;
304 int width = img->width;
305 int height = img->height;
306 int cwidth = 28;
308 black.alpha = 255;
309 black.red = black.green = black.blue = 0;
311 light.alpha = 0;
312 light.red = light.green = light.blue = 80;
314 dark.alpha = 0;
315 dark.red = dark.green = dark.blue = 40;
317 ROperateLine(img, RSubtractOperation, 0, 0, width-1, 0, &dark);
318 ROperateLine(img, RAddOperation, 0, 1, width-1, 1, &light);
320 ROperateLine(img, RSubtractOperation, cwidth, 2, cwidth, height-1, &dark);
321 ROperateLine(img, RAddOperation, cwidth+1, 2, cwidth+1, height-1, &light);
323 ROperateLine(img, RSubtractOperation, width-cwidth-2, 2, width-cwidth-2,
324 height-1, &dark);
325 ROperateLine(img, RAddOperation, width-cwidth-1, 2, width-cwidth-1,
326 height-1, &light);
328 RDrawLine(img, 0, height-1, width-1, height-1, &black);
329 RDrawLine(img, 0, 0, 0, height-1, &black);
330 RDrawLine(img, width-1, 0, width-1, height-1, &black);
334 static void
335 drawMenuBevel(RImage *img)
337 RColor light, dark, mid;
338 int i;
339 int iheight = img->height / 3;
341 light.alpha = 0;
342 light.red = light.green = light.blue = 80;
344 dark.alpha = 255;
345 dark.red = dark.green = dark.blue = 0;
347 mid.alpha = 0;
348 mid.red = mid.green = mid.blue = 40;
350 for (i = 1; i < 3; i++) {
351 ROperateLine(img, RSubtractOperation, 0, i*iheight-2,
352 img->width-1, i*iheight-2, &mid);
354 RDrawLine(img, 0, i*iheight-1,
355 img->width-1, i*iheight-1, &dark);
357 ROperateLine(img, RAddOperation, 0, i*iheight,
358 img->width-1, i*iheight, &light);
363 static Pixmap
364 renderTexture(WMScreen *scr, proplist_t texture, int width, int height,
365 char *path, int border)
367 char *type;
368 RImage *image;
369 Pixmap pixmap;
370 RContext *rc = WMScreenRContext(scr);
371 char *str;
372 RColor rcolor;
375 type = PLGetString(PLGetArrayElement(texture, 0));
377 image = RCreateImage(width, height, False);
379 if (strcasecmp(type, "solid")==0) {
381 str = PLGetString(PLGetArrayElement(texture, 1));
383 str2rcolor(rc, str, &rcolor);
385 RClearImage(image, &rcolor);
386 } else if (strcasecmp(&type[1], "gradient")==0) {
387 int style;
388 RColor rcolor2;
390 switch (toupper(type[0])) {
391 case 'V':
392 style = RVerticalGradient;
393 break;
394 case 'H':
395 style = RHorizontalGradient;
396 break;
397 default:
398 case 'D':
399 style = RDiagonalGradient;
400 break;
403 str = PLGetString(PLGetArrayElement(texture, 1));
404 str2rcolor(rc, str, &rcolor);
405 str = PLGetString(PLGetArrayElement(texture, 2));
406 str2rcolor(rc, str, &rcolor2);
408 image = RRenderGradient(width, height, &rcolor, &rcolor2, style);
409 } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='T') {
410 int style;
411 RColor rcolor2;
412 int i;
413 RImage *grad, *timage;
414 char *path;
416 switch (toupper(type[1])) {
417 case 'V':
418 style = RVerticalGradient;
419 break;
420 case 'H':
421 style = RHorizontalGradient;
422 break;
423 default:
424 case 'D':
425 style = RDiagonalGradient;
426 break;
429 str = PLGetString(PLGetArrayElement(texture, 3));
430 str2rcolor(rc, str, &rcolor);
431 str = PLGetString(PLGetArrayElement(texture, 4));
432 str2rcolor(rc, str, &rcolor2);
434 str = PLGetString(PLGetArrayElement(texture, 1));
436 path = wfindfileinarray(GetObjectForKey("PixmapPath"), str);
437 timage = RLoadImage(rc, path, 0);
439 if (!timage) {
440 wwarning("could not load file '%s': %s", path,
441 RMessageForError(RErrorCode));
442 } else {
443 grad = RRenderGradient(width, height, &rcolor, &rcolor2, style);
445 image = RMakeTiledImage(timage, width, height);
446 RDestroyImage(timage);
448 i = atoi(PLGetString(PLGetArrayElement(texture, 2)));
450 RCombineImagesWithOpaqueness(image, grad, i);
451 RDestroyImage(grad);
453 } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='M') {
454 int style;
455 RColor **colors;
456 int i, j;
458 switch (toupper(type[1])) {
459 case 'V':
460 style = RVerticalGradient;
461 break;
462 case 'H':
463 style = RHorizontalGradient;
464 break;
465 default:
466 case 'D':
467 style = RDiagonalGradient;
468 break;
471 j = PLGetNumberOfElements(texture);
473 if (j > 0) {
474 colors = wmalloc(j * sizeof(RColor*));
476 for (i = 2; i < j; i++) {
477 str = PLGetString(PLGetArrayElement(texture, i));
478 colors[i-2] = wmalloc(sizeof(RColor));
479 str2rcolor(rc, str, colors[i-2]);
481 colors[i-2] = NULL;
483 image = RRenderMultiGradient(width, height, colors, style);
485 for (i = 0; colors[i]!=NULL; i++)
486 free(colors[i]);
487 free(colors);
489 } else if (strcasecmp(&type[1], "pixmap")==0) {
490 RImage *timage;
491 char *path;
492 RColor color;
494 str = PLGetString(PLGetArrayElement(texture, 1));
496 path = wfindfileinarray(GetObjectForKey("PixmapPath"), str);
497 timage = RLoadImage(rc, path, 0);
499 if (!timage) {
500 wwarning("could not load file '%s': %s", path,
501 RMessageForError(RErrorCode));
502 } else {
503 str = PLGetString(PLGetArrayElement(texture, 2));
504 str2rcolor(rc, str, &color);
506 switch (toupper(type[0])) {
507 case 'T':
508 image = RMakeTiledImage(timage, width, height);
509 RDestroyImage(timage);
510 timage = image;
511 break;
512 case 'C':
513 image = RMakeCenteredImage(timage, width, height, &color);
514 RDestroyImage(timage);
515 timage = image;
516 break;
517 case 'S':
518 case 'M':
519 image = RScaleImage(timage, width, height);
520 RDestroyImage(timage);
521 timage = image;
522 break;
526 free(path);
529 if (!image)
530 return None;
532 if (path) {
533 dumpRImage(path, image);
536 if (border < 0) {
537 if (border == RESIZEBAR_BEVEL) {
538 drawResizebarBevel(image);
539 } else if (border == MENU_BEVEL) {
540 drawMenuBevel(image);
542 } else if (border) {
543 RBevelImage(image, border);
546 RConvertImage(rc, image, &pixmap);
547 RDestroyImage(image);
549 return pixmap;
553 static Pixmap
554 renderMenu(_Panel *panel, proplist_t texture, int width, int iheight)
556 WMScreen *scr = WMWidgetScreen(panel->win);
557 Display *dpy = WMScreenDisplay(scr);
558 Pixmap pix, tmp;
559 char *str;
560 GC gc = XCreateGC(dpy, WMWidgetXID(panel->win), 0, NULL);
563 str = GetStringForKey("MenuStyle");
564 if (!str || strcasecmp(str, "normal")==0) {
565 int i;
567 tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
569 pix = XCreatePixmap(dpy, tmp, width, iheight*3,
570 WMScreenDepth(scr));
571 for (i = 0; i < 3; i++) {
572 XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight,
573 0, iheight*i);
575 XFreePixmap(dpy, tmp);
576 } else if (strcasecmp(str, "flat")==0) {
577 pix = renderTexture(scr, texture, width, iheight*3, NULL, RBEV_RAISED2);
578 } else {
579 pix = renderTexture(scr, texture, width, iheight*3, NULL, MENU_BEVEL);
582 XFreeGC(dpy, gc);
584 return pix;
588 static void
589 updatePreviewBox(_Panel *panel, int elements)
591 WMScreen *scr = WMWidgetScreen(panel->win);
592 Display *dpy = WMScreenDisplay(scr);
593 /* RContext *rc = WMScreenRContext(scr);*/
594 int refresh = 0;
595 Pixmap pix;
596 GC gc;
597 WMListItem *item;
598 TextureListItem *titem;
600 gc = XCreateGC(dpy, WMWidgetXID(panel->win), 0, NULL);
603 if (!panel->preview) {
604 WMColor *color;
606 panel->preview = XCreatePixmap(dpy, WMWidgetXID(panel->win),
607 260-4, 165-4, WMScreenDepth(scr));
609 color = WMGrayColor(scr);
610 XFillRectangle(dpy, panel->preview, WMColorGC(color),
611 0, 0, 260-4, 165-4);
612 WMReleaseColor(color);
614 refresh = -1;
617 if (elements & FTITLE) {
618 item = WMGetListItem(panel->texLs, panel->textureIndex[0]);
619 titem = (TextureListItem*)item->clientData;
621 pix = renderTexture(scr, titem->prop, 210, 20, NULL, RBEV_RAISED2);
623 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 5);
625 XFreePixmap(dpy, pix);
627 if (elements & UTITLE) {
628 item = WMGetListItem(panel->texLs, panel->textureIndex[1]);
629 titem = (TextureListItem*)item->clientData;
631 pix = renderTexture(scr, titem->prop, 210, 20, NULL, RBEV_RAISED2);
633 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 30);
635 XFreePixmap(dpy, pix);
637 if (elements & OTITLE) {
638 item = WMGetListItem(panel->texLs, panel->textureIndex[2]);
639 titem = (TextureListItem*)item->clientData;
641 pix = renderTexture(scr, titem->prop, 210, 20, NULL, RBEV_RAISED2);
643 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 55);
645 XFreePixmap(dpy, pix);
647 if (elements & RESIZEBAR) {
648 item = WMGetListItem(panel->texLs, panel->textureIndex[3]);
649 titem = (TextureListItem*)item->clientData;
651 pix = renderTexture(scr, titem->prop, 210, 9, NULL, RESIZEBAR_BEVEL);
653 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 80);
655 XFreePixmap(dpy, pix);
657 if (elements & MTITLE) {
658 item = WMGetListItem(panel->texLs, panel->textureIndex[4]);
659 titem = (TextureListItem*)item->clientData;
661 pix = renderTexture(scr, titem->prop, 100, 20, NULL, RBEV_RAISED2);
663 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 100, 20, 30, 95);
665 XFreePixmap(dpy, pix);
667 if (elements & MITEM) {
668 item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
669 titem = (TextureListItem*)item->clientData;
671 pix = renderMenu(panel, titem->prop, 100, 18);
673 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 100, 18*3, 30, 115);
675 XFreePixmap(dpy, pix);
677 if (elements & (MITEM|MTITLE)) {
678 XDrawLine(dpy, panel->preview, gc, 29, 95, 29, 115+36+20);
679 XDrawLine(dpy, panel->preview, gc, 29, 94, 129, 94);
682 if (elements & ICON) {
683 item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
684 titem = (TextureListItem*)item->clientData;
686 pix = renderTexture(scr, titem->prop, 64, 64, NULL,
687 titem->ispixmap ? 0 : RBEV_RAISED3);
689 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 64, 64, 170, 95);
691 XFreePixmap(dpy, pix);
695 if (refresh < 0) {
696 WMPixmap *p;
697 p = WMCreatePixmapFromXPixmaps(scr, panel->preview, None,
698 260-4, 165-4, WMScreenDepth(scr));
700 WMSetLabelImage(panel->prevL, p);
701 WMReleasePixmap(p);
702 } else {
703 WMRedisplayWidget(panel->prevL);
706 XFreeGC(dpy, gc);
712 static void
713 cancelNewTexture(void *data)
715 _Panel *panel = (_Panel*)data;
717 HideTexturePanel(panel->texturePanel);
723 static char*
724 makeFileName(char *prefix)
726 char *fname;
728 fname = wstrdup(prefix);
730 while (access(fname, F_OK)==0) {
731 char buf[30];
733 free(fname);
734 sprintf(buf, "%08lx.cache", time(NULL));
735 fname = wstrappend(prefix, buf);
738 return fname;
744 static void
745 okNewTexture(void *data)
747 _Panel *panel = (_Panel*)data;
748 WMListItem *item;
749 char *name;
750 char *str;
751 proplist_t prop;
752 TextureListItem *titem;
753 WMScreen *scr = WMWidgetScreen(panel->win);
755 titem = wmalloc(sizeof(TextureListItem));
756 memset(titem, 0, sizeof(TextureListItem));
758 HideTexturePanel(panel->texturePanel);
760 name = GetTexturePanelTextureName(panel->texturePanel);
762 prop = GetTexturePanelTexture(panel->texturePanel);
764 str = PLGetDescription(prop);
766 titem->title = name;
767 titem->prop = prop;
768 titem->texture = str;
769 titem->selectedFor = 0;
771 titem->ispixmap = isPixmap(prop);
773 titem->path = makeFileName(panel->fprefix);
774 titem->preview = renderTexture(scr, prop, TEXPREV_WIDTH, TEXPREV_HEIGHT,
775 titem->path, 0);
777 item = WMAddListItem(panel->texLs, "");
778 item->clientData = titem;
780 WMSetListPosition(panel->texLs, WMGetListNumberOfRows(panel->texLs));
784 static void
785 okEditTexture(void *data)
787 _Panel *panel = (_Panel*)data;
788 WMListItem *item;
789 char *name;
790 char *str;
791 proplist_t prop;
792 TextureListItem *titem;
794 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
795 titem = (TextureListItem*)item->clientData;
797 HideTexturePanel(panel->texturePanel);
799 if (titem->current) {
800 name = GetTexturePanelTextureName(panel->texturePanel);
802 free(titem->title);
803 titem->title = name;
806 prop = GetTexturePanelTexture(panel->texturePanel);
808 str = PLGetDescription(prop);
810 PLRelease(titem->prop);
811 titem->prop = prop;
813 titem->ispixmap = isPixmap(prop);
815 free(titem->texture);
816 titem->texture = str;
818 XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel->texLs)), titem->preview);
819 titem->preview = renderTexture(WMWidgetScreen(panel->texLs), titem->prop,
820 TEXPREV_WIDTH, TEXPREV_HEIGHT,
821 titem->path, 0);
823 WMRedisplayWidget(panel->texLs);
825 if (titem->selectedFor)
826 updatePreviewBox(panel, titem->selectedFor);
828 changePage(panel->secP, panel);
833 static void
834 editTexture(WMWidget *w, void *data)
836 _Panel *panel = (_Panel*)data;
837 WMListItem *item;
838 TextureListItem *titem;
840 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
841 titem = (TextureListItem*)item->clientData;
843 SetTexturePanelPixmapPath(panel->texturePanel,
844 GetObjectForKey("PixmapPath"));
846 SetTexturePanelTexture(panel->texturePanel, titem->title, titem->prop);
848 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
849 SetTexturePanelOkAction(panel->texturePanel, okEditTexture, panel);
851 ShowTexturePanel(panel->texturePanel);
856 static void
857 newTexture(WMWidget *w, void *data)
859 _Panel *panel = (_Panel*)data;
861 SetTexturePanelPixmapPath(panel->texturePanel,
862 GetObjectForKey("PixmapPath"));
864 SetTexturePanelTexture(panel->texturePanel, "New Texture", NULL);
866 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
868 SetTexturePanelOkAction(panel->texturePanel, okNewTexture, panel);
870 ShowTexturePanel(panel->texturePanel);
875 static void
876 deleteTexture(WMWidget *w, void *data)
878 _Panel *panel = (_Panel*)data;
879 WMListItem *item;
880 TextureListItem *titem;
881 int row;
882 int section;
884 section = WMGetPopUpButtonSelectedItem(panel->secP);
885 row = WMGetListSelectedItemRow(panel->texLs);
886 item = WMGetListItem(panel->texLs, row);
887 titem = (TextureListItem*)item->clientData;
889 if (titem->selectedFor & (1 << section)) {
890 TextureListItem *titem2;
892 panel->textureIndex[section] = section;
893 item = WMGetListItem(panel->texLs, section);
894 titem2 = (TextureListItem*)item->clientData;
895 titem2->selectedFor |= 1 << section;
898 free(titem->title);
899 free(titem->texture);
900 PLRelease(titem->prop);
901 if (titem->path) {
902 if (remove(titem->path) < 0 && errno != ENOENT) {
903 wsyserror("could not remove file %s", titem->path);
905 free(titem->path);
908 free(titem);
910 WMRemoveListItem(panel->texLs, row);
911 WMSetButtonEnabled(panel->delB, False);
917 static void
918 extractTexture(WMWidget *w, void *data)
920 _Panel *panel = (_Panel*)data;
921 char *path;
922 WMOpenPanel *opanel;
923 WMScreen *scr = WMWidgetScreen(w);
925 opanel = WMGetOpenPanel(scr);
926 WMSetFilePanelCanChooseDirectories(opanel, False);
927 WMSetFilePanelCanChooseFiles(opanel, True);
929 if (WMRunModalFilePanelForDirectory(opanel, panel->win, wgethomedir(),
930 _("Select File"), NULL)) {
931 path = WMGetFilePanelFileName(opanel);
933 OpenExtractPanelFor(panel, path);
935 free(path);
940 static void
941 changePage(WMWidget *w, void *data)
943 _Panel *panel = (_Panel*)data;
944 int section;
945 WMListItem *item;
946 TextureListItem *titem;
947 char *str;
948 WMScreen *scr = WMWidgetScreen(w);
949 RContext *rc = WMScreenRContext(scr);
950 static WMPoint positions[] = {
951 {5, 5},
952 {5, 30},
953 {5, 55},
954 {5, 80},
955 {5, 95},
956 {5, 130},
957 {145, 110}
960 section = WMGetPopUpButtonSelectedItem(panel->secP);
962 WMSelectListItem(panel->texLs, panel->textureIndex[section]);
964 WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2);
966 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
968 titem = (TextureListItem*)item->clientData;
970 str = wmalloc(strlen(titem->title) + strlen(titem->texture) + 4);
971 sprintf(str, "%s: %s", titem->title, titem->texture);
972 WMSetLabelText(panel->texsL, str);
973 free(str);
976 WMColor *color;
978 color = WMGrayColor(scr);
979 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
980 positions[panel->oldsection].x,
981 positions[panel->oldsection].y, 22, 22);
982 WMReleaseColor(color);
984 panel->oldsection = section;
985 WMDrawPixmap(panel->hand, panel->preview, positions[section].x,
986 positions[section].y);
988 WMRedisplayWidget(panel->prevL);
993 static void
994 previewClick(XEvent *event, void *clientData)
996 _Panel *panel = (_Panel*)clientData;
997 int i;
998 static WMRect parts[] = {
999 {{30, 5},{210, 20}},
1000 {{30,30},{210,20}},
1001 {{30,55},{210,20}},
1002 {{30,80},{210,9}},
1003 {{30,95},{100,20}},
1004 {{30,115},{100,60}},
1005 {{170,90},{64,64}}
1008 for (i = 0; i < 7; i++) {
1009 if (event->xbutton.x >= parts[i].pos.x
1010 && event->xbutton.y >= parts[i].pos.y
1011 && event->xbutton.x < parts[i].pos.x + parts[i].size.width
1012 && event->xbutton.y < parts[i].pos.y + parts[i].size.height) {
1014 WMSetPopUpButtonSelectedItem(panel->secP, i);
1015 changePage(panel->secP, panel);
1016 return;
1022 static void
1023 textureClick(WMWidget *w, void *data)
1025 _Panel *panel = (_Panel*)data;
1026 int i;
1027 WMListItem *item;
1028 TextureListItem *titem;
1030 i = WMGetListSelectedItemRow(panel->texLs);
1032 item = WMGetListItem(panel->texLs, i);
1034 titem = (TextureListItem*)item->clientData;
1036 if (titem->current) {
1037 WMSetButtonEnabled(panel->delB, False);
1038 } else {
1039 WMSetButtonEnabled(panel->delB, True);
1045 static void
1046 textureDoubleClick(WMWidget *w, void *data)
1048 _Panel *panel = (_Panel*)data;
1049 int i, section;
1050 WMListItem *item;
1051 TextureListItem *titem;
1052 char *str;
1054 /* unselect old texture */
1055 section = WMGetPopUpButtonSelectedItem(panel->secP);
1057 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
1058 titem = (TextureListItem*)item->clientData;
1059 titem->selectedFor &= ~(1 << section);
1061 /* select new texture */
1062 i = WMGetListSelectedItemRow(panel->texLs);
1064 item = WMGetListItem(panel->texLs, i);
1066 titem = (TextureListItem*)item->clientData;
1068 titem->selectedFor |= 1<<section;
1070 panel->textureIndex[section] = i;
1072 WMRedisplayWidget(panel->texLs);
1074 str = wmalloc(strlen(titem->title) + strlen(titem->texture) + 4);
1075 sprintf(str, "%s: %s", titem->title, titem->texture);
1076 WMSetLabelText(panel->texsL, str);
1077 free(str);
1079 updatePreviewBox(panel, 1<<section);
1085 static void
1086 paintListItem(WMList *lPtr, int index, Drawable d, char *text, int state,
1087 WMRect *rect)
1089 _Panel *panel = (_Panel*)WMGetHangedData(lPtr);
1090 WMScreen *scr = WMWidgetScreen(lPtr);
1091 int width, height, x, y;
1092 Display *dpy = WMScreenDisplay(scr);
1093 WMColor *white = WMWhiteColor(scr);
1094 WMListItem *item;
1095 WMColor *black = WMBlackColor(scr);
1096 TextureListItem *titem;
1098 width = rect->size.width;
1099 height = rect->size.height;
1100 x = rect->pos.x;
1101 y = rect->pos.y;
1103 if (state & WLDSSelected)
1104 XFillRectangle(dpy, d, WMColorGC(white), x, y, width, height);
1105 else
1106 XClearArea(dpy, d, x, y, width, height, False);
1108 item = WMGetListItem(lPtr, index);
1109 titem = (TextureListItem*)item->clientData;
1111 if (titem->preview)
1112 XCopyArea(dpy, titem->preview, d, WMColorGC(black), 0, 0, TEXPREV_WIDTH,
1113 TEXPREV_HEIGHT, x + 5, y + 5);
1115 if ((1 << WMGetPopUpButtonSelectedItem(panel->secP)) & titem->selectedFor)
1116 WMDrawPixmap(panel->onLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1117 else if (titem->selectedFor)
1118 WMDrawPixmap(panel->offLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1120 WMDrawString(scr, d, WMColorGC(black), panel->boldFont,
1121 x + TEXPREV_WIDTH + 22, y + 2, titem->title,
1122 strlen(titem->title));
1124 WMDrawString(scr, d, WMColorGC(black), panel->smallFont,
1125 x + TEXPREV_WIDTH + 14, y + 18, titem->texture,
1126 strlen(titem->texture));
1129 WMReleaseColor(white);
1130 WMReleaseColor(black);
1135 static Pixmap
1136 loadRImage(WMScreen *scr, char *path)
1138 FILE *f;
1139 RImage *image;
1140 int w, h, d;
1141 int i;
1142 Pixmap pixmap;
1144 f = fopen(path, "r");
1145 if (!f)
1146 return None;
1148 fscanf(f, "%02x%02x%1x", &w, &h, &d);
1150 image = RCreateImage(w, h, d == 4);
1151 for (i = 0; i < d; i++) {
1152 fread(image->data[i], 1, w*h, f);
1154 fclose(f);
1156 RConvertImage(WMScreenRContext(scr), image, &pixmap);
1157 RDestroyImage(image);
1159 return pixmap;
1164 static void
1165 fillTextureList(WMList *lPtr)
1167 proplist_t textureList;
1168 proplist_t texture;
1169 WMUserDefaults *udb = WMGetStandardUserDefaults();
1170 int i;
1171 TextureListItem *titem;
1172 WMScreen *scr = WMWidgetScreen(lPtr);
1174 textureList = WMGetUDObjectForKey(udb, "TextureList");
1175 if (!textureList)
1176 return;
1178 for (i = 0; i < PLGetNumberOfElements(textureList); i++) {
1179 WMListItem *item;
1181 texture = PLGetArrayElement(textureList, i);
1183 titem = wmalloc(sizeof(TextureListItem));
1184 memset(titem, 0, sizeof(TextureListItem));
1186 titem->title = wstrdup(PLGetString(PLGetArrayElement(texture, 0)));
1187 titem->prop = PLRetain(PLGetArrayElement(texture, 1));
1188 titem->texture = PLGetDescription(titem->prop);
1189 titem->selectedFor = 0;
1190 titem->path = wstrdup(PLGetString(PLGetArrayElement(texture, 2)));
1192 titem->preview = loadRImage(scr, titem->path);
1193 if (!titem->preview) {
1194 titem->preview = renderTexture(scr, titem->prop, TEXPREV_WIDTH,
1195 TEXPREV_HEIGHT, NULL, 0);
1197 item = WMAddListItem(lPtr, "");
1198 item->clientData = titem;
1203 static void
1204 createPanel(Panel *p)
1206 _Panel *panel = (_Panel*)p;
1207 WMColor *color;
1208 WMFont *font;
1209 WMScreen *scr = WMWidgetScreen(panel->win);
1211 char *tmp;
1212 Bool ok = True;
1214 panel->fprefix = wstrappend(wusergnusteppath(), "/.AppInfo");
1216 if (access(panel->fprefix, F_OK)!=0) {
1217 if (mkdir(panel->fprefix, 0755) < 0) {
1218 wsyserror(panel->fprefix);
1219 ok = False;
1222 if (ok) {
1223 tmp = wstrappend(panel->fprefix, "/WPrefs/");
1224 free(panel->fprefix);
1225 panel->fprefix = tmp;
1226 if (access(panel->fprefix, F_OK)!=0) {
1227 if (mkdir(panel->fprefix, 0755) < 0) {
1228 wsyserror(panel->fprefix);
1233 panel->smallFont = WMSystemFontOfSize(scr, 10);
1234 panel->normalFont = WMSystemFontOfSize(scr, 12);
1235 panel->boldFont = WMBoldSystemFontOfSize(scr, 12);
1237 panel->onLed = WMCreatePixmapFromXPMData(scr, blueled_xpm);
1238 panel->offLed = WMCreatePixmapFromXPMData(scr, blueled2_xpm);
1239 panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm);
1241 panel->frame = WMCreateFrame(panel->win);
1242 WMResizeWidget(panel->frame, FRAME_WIDTH, FRAME_HEIGHT);
1243 WMMoveWidget(panel->frame, FRAME_LEFT, FRAME_TOP);
1245 /* preview box */
1246 panel->prevL = WMCreateLabel(panel->frame);
1247 WMResizeWidget(panel->prevL, 260, 165);
1248 WMMoveWidget(panel->prevL, 15, 10);
1249 WMSetLabelRelief(panel->prevL, WRSunken);
1250 WMSetLabelImagePosition(panel->prevL, WIPImageOnly);
1252 WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask,
1253 previewClick, panel);
1256 panel->secP = WMCreatePopUpButton(panel->frame);
1257 WMResizeWidget(panel->secP, 260, 20);
1258 WMMoveWidget(panel->secP, 15, 180);
1259 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1260 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window"));
1261 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Unfocused Windows"));
1262 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window's Owner"));
1263 WMAddPopUpButtonItem(panel->secP, _("Window Resizebar"));
1264 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
1265 WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
1266 WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
1267 /* WMAddPopUpButtonItem(panel->secP, _("Workspace Backgrounds"));
1269 WMSetPopUpButtonAction(panel->secP, changePage, panel);
1272 panel->texsL = WMCreateLabel(panel->frame);
1273 WMResizeWidget(panel->texsL, 260, 20);
1274 WMMoveWidget(panel->texsL, 15, 205);
1275 WMSetLabelWraps(panel->texsL, False);
1277 /* texture list */
1278 font = WMBoldSystemFontOfSize(scr, 12);
1280 panel->texL = WMCreateLabel(panel->frame);
1281 WMResizeWidget(panel->texL, 225, 18);
1282 WMMoveWidget(panel->texL, 285, 10);
1283 WMSetLabelFont(panel->texL, font);
1284 WMSetLabelText(panel->texL, _("Textures"));
1285 WMSetLabelRelief(panel->texL, WRSunken);
1286 WMSetLabelTextAlignment(panel->texL, WACenter);
1287 color = WMDarkGrayColor(scr);
1288 WMSetWidgetBackgroundColor(panel->texL, color);
1289 WMReleaseColor(color);
1290 color = WMWhiteColor(scr);
1291 WMSetLabelTextColor(panel->texL, color);
1292 WMReleaseColor(color);
1294 WMReleaseFont(font);
1296 panel->texLs = WMCreateList(panel->frame);
1297 WMResizeWidget(panel->texLs, 225, 144);
1298 WMMoveWidget(panel->texLs, 285, 30);
1299 WMSetListUserDrawItemHeight(panel->texLs, 35);
1300 WMSetListUserDrawProc(panel->texLs, paintListItem);
1301 WMHangData(panel->texLs, panel);
1302 WMSetListAction(panel->texLs, textureClick, panel);
1303 WMSetListDoubleAction(panel->texLs, textureDoubleClick, panel);
1305 WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
1306 "for the selected item."),
1307 WMWidgetView(panel->texLs));
1309 /* command buttons */
1311 font = WMSystemFontOfSize(scr, 10);
1314 panel->newB = WMCreateCommandButton(panel->frame);
1315 WMResizeWidget(panel->newB, 56, 48);
1316 WMMoveWidget(panel->newB, 285, 180);
1317 WMSetButtonFont(panel->newB, font);
1318 WMSetButtonImagePosition(panel->newB, WIPAbove);
1319 WMSetButtonText(panel->newB, _("New"));
1320 WMSetButtonAction(panel->newB, newTexture, panel);
1321 SetButtonAlphaImage(scr, panel->newB, TNEW_FILE);
1323 WMSetBalloonTextForView(_("Create a new texture."),
1324 WMWidgetView(panel->newB));
1326 panel->ripB = WMCreateCommandButton(panel->frame);
1327 WMResizeWidget(panel->ripB, 56, 48);
1328 WMMoveWidget(panel->ripB, 341, 180);
1329 WMSetButtonFont(panel->ripB, font);
1330 WMSetButtonImagePosition(panel->ripB, WIPAbove);
1331 WMSetButtonText(panel->ripB, _("Extract..."));
1332 WMSetButtonAction(panel->ripB, extractTexture, panel);
1333 SetButtonAlphaImage(scr, panel->ripB, TEXTR_FILE);
1335 WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."),
1336 WMWidgetView(panel->ripB));
1338 WMSetButtonEnabled(panel->ripB, False);
1340 panel->editB = WMCreateCommandButton(panel->frame);
1341 WMResizeWidget(panel->editB, 56, 48);
1342 WMMoveWidget(panel->editB, 397, 180);
1343 WMSetButtonFont(panel->editB, font);
1344 WMSetButtonImagePosition(panel->editB, WIPAbove);
1345 WMSetButtonText(panel->editB, _("Edit"));
1346 SetButtonAlphaImage(scr, panel->editB, TEDIT_FILE);
1347 WMSetButtonAction(panel->editB, editTexture, panel);
1348 WMSetBalloonTextForView(_("Edit the highlighted texture."),
1349 WMWidgetView(panel->editB));
1351 panel->delB = WMCreateCommandButton(panel->frame);
1352 WMResizeWidget(panel->delB, 56, 48);
1353 WMMoveWidget(panel->delB, 453, 180);
1354 WMSetButtonFont(panel->delB, font);
1355 WMSetButtonImagePosition(panel->delB, WIPAbove);
1356 WMSetButtonText(panel->delB, _("Delete"));
1357 SetButtonAlphaImage(scr, panel->delB, TDEL_FILE);
1358 WMSetButtonEnabled(panel->delB, False);
1359 WMSetButtonAction(panel->delB, deleteTexture, panel);
1360 WMSetBalloonTextForView(_("Delete the highlighted texture."),
1361 WMWidgetView(panel->delB));
1363 WMReleaseFont(font);
1365 /**/
1367 WMRealizeWidget(panel->frame);
1368 WMMapSubwidgets(panel->frame);
1370 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1372 showData(panel);
1374 changePage(panel->secP, panel);
1376 fillTextureList(panel->texLs);
1378 panel->texturePanel = CreateTexturePanel(panel->win);
1383 static void
1384 setupTextureFor(WMList *list, char *key, char *defValue, char *title,
1385 int index)
1387 WMListItem *item;
1388 TextureListItem *titem;
1390 titem = wmalloc(sizeof(TextureListItem));
1391 memset(titem, 0, sizeof(TextureListItem));
1393 titem->title = wstrdup(title);
1394 titem->prop = GetObjectForKey(key);
1395 if (!titem->prop) {
1396 titem->prop = PLGetProplistWithDescription(defValue);
1397 } else {
1398 PLRetain(titem->prop);
1400 titem->texture = PLGetDescription((proplist_t)titem->prop);
1401 titem->current = 1;
1402 titem->selectedFor = 1<<index;
1404 titem->ispixmap = isPixmap(titem->prop);
1406 titem->preview = renderTexture(WMWidgetScreen(list), titem->prop,
1407 TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0);
1409 item = WMAddListItem(list, "");
1410 item->clientData = titem;
1415 static void
1416 showData(_Panel *panel)
1418 int i = 0;
1420 setupTextureFor(panel->texLs, "FTitleBack", "(solid, black)",
1421 "[Focused]", i);
1422 panel->textureIndex[i] = i++;
1424 setupTextureFor(panel->texLs, "UTitleBack", "(solid, gray)",
1425 "[Unfocused]", i);
1426 panel->textureIndex[i] = i++;
1428 setupTextureFor(panel->texLs, "PTitleBack", "(solid, \"#616161\")",
1429 "[Owner of Focused]", i);
1430 panel->textureIndex[i] = i++;
1432 setupTextureFor(panel->texLs, "ResizebarBack", "(solid, gray)",
1433 "[Resizebar]", i);
1434 panel->textureIndex[i] = i++;
1436 setupTextureFor(panel->texLs, "MenuTitleBack", "(solid, black)",
1437 "[Menu Title]", i);
1438 panel->textureIndex[i] = i++;
1440 setupTextureFor(panel->texLs, "MenuTextBack", "(solid, gray)",
1441 "[Menu Item]", i);
1442 panel->textureIndex[i] = i++;
1444 setupTextureFor(panel->texLs, "IconBack", "(solid, gray)", "[Icon]", i);
1445 panel->textureIndex[i] = i++;
1447 setupTextureFor(panel->texLs, "WorkspaceBack", "(solid, black)",
1448 "[Workspace]", i);
1449 panel->textureIndex[i] = i++;
1452 updatePreviewBox(panel, EVERYTHING);
1457 static void
1458 storeData(_Panel *panel)
1460 TextureListItem *titem;
1461 WMListItem *item;
1463 item = WMGetListItem(panel->texLs, panel->textureIndex[0]);
1464 titem = (TextureListItem*)item->clientData;
1465 SetObjectForKey(titem->prop, "FTitleBack");
1467 item = WMGetListItem(panel->texLs, panel->textureIndex[1]);
1468 titem = (TextureListItem*)item->clientData;
1469 SetObjectForKey(titem->prop, "UTitleBack");
1471 item = WMGetListItem(panel->texLs, panel->textureIndex[2]);
1472 titem = (TextureListItem*)item->clientData;
1473 SetObjectForKey(titem->prop, "PTitleBack");
1475 item = WMGetListItem(panel->texLs, panel->textureIndex[3]);
1476 titem = (TextureListItem*)item->clientData;
1477 SetObjectForKey(titem->prop, "ResizebarBack");
1479 item = WMGetListItem(panel->texLs, panel->textureIndex[4]);
1480 titem = (TextureListItem*)item->clientData;
1481 SetObjectForKey(titem->prop, "MenuTitleBack");
1483 item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
1484 titem = (TextureListItem*)item->clientData;
1485 SetObjectForKey(titem->prop, "MenuTextBack");
1487 item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
1488 titem = (TextureListItem*)item->clientData;
1489 SetObjectForKey(titem->prop, "IconBack");
1493 static void
1494 prepareForClose(_Panel *panel)
1496 proplist_t textureList;
1497 proplist_t texture;
1498 int i;
1499 TextureListItem *titem;
1500 WMListItem *item;
1501 WMUserDefaults *udb = WMGetStandardUserDefaults();
1503 textureList = PLMakeArrayFromElements(NULL, NULL);
1505 /* store list of textures */
1506 for (i = 7; i < WMGetListNumberOfRows(panel->texLs); i++) {
1507 item = WMGetListItem(panel->texLs, i);
1508 titem = (TextureListItem*)item->clientData;
1510 texture = PLMakeArrayFromElements(PLMakeString(titem->title),
1511 PLRetain(titem->prop),
1512 PLMakeString(titem->path),
1513 NULL);
1515 PLAppendArrayElement(textureList, texture);
1518 WMSetUDObjectForKey(udb, textureList, "TextureList");
1519 PLRelease(textureList);
1521 WMSynchronizeUserDefaults(udb);
1526 Panel*
1527 InitAppearance(WMScreen *scr, WMWindow *win)
1529 _Panel *panel;
1531 panel = wmalloc(sizeof(_Panel));
1532 memset(panel, 0, sizeof(_Panel));
1534 panel->sectionName = _("Appearance Preferences");
1536 panel->description = _("Background texture configuration for windows,\n"
1537 "menus and icons.");
1539 panel->win = win;
1541 panel->callbacks.createWidgets = createPanel;
1542 panel->callbacks.updateDomain = storeData;
1543 panel->callbacks.prepareForClose = prepareForClose;
1545 AddSection(panel, ICON_FILE);
1547 return panel;
1552 /****************************************************************************/
1556 typedef struct ExtractPanel {
1557 WMWindow *win;
1559 WMLabel *label;
1560 WMList *list;
1562 WMButton *closeB;
1563 WMButton *extrB;
1564 } ExtractPanel;
1568 static void
1569 OpenExtractPanelFor(_Panel *panel, char *path)
1571 ExtractPanel *epanel;
1572 WMColor *color;
1573 WMFont *font;
1574 WMScreen *scr = WMWidgetScreen(panel->win);
1576 epanel = wmalloc(sizeof(ExtractPanel));
1577 epanel->win = WMCreatePanelWithStyleForWindow(panel->win, "extract",
1578 WMTitledWindowMask
1579 |WMClosableWindowMask);
1580 WMResizeWidget(epanel->win, 245, 250);
1581 WMSetWindowTitle(epanel->win, _("Extract Texture"));
1583 epanel->label = WMCreateLabel(epanel->win);
1584 WMResizeWidget(epanel->label, 225, 18);
1585 WMMoveWidget(epanel->label, 10, 10);
1586 WMSetLabelTextAlignment(epanel->label, WACenter);
1587 WMSetLabelRelief(epanel->label, WRSunken);
1589 color = WMDarkGrayColor(scr);
1590 WMSetWidgetBackgroundColor(epanel->label, color);
1591 WMReleaseColor(color);
1593 color = WMWhiteColor(scr);
1594 WMSetLabelTextColor(epanel->label, color);
1595 WMReleaseColor(color);
1597 font = WMBoldSystemFontOfSize(scr, 12);
1598 WMSetLabelFont(epanel->label, font);
1599 WMReleaseFont(font);
1601 WMSetLabelText(epanel->label, _("Textures"));
1603 epanel->list = WMCreateList(epanel->win);
1604 WMResizeWidget(epanel->list, 225, 165);
1605 WMMoveWidget(epanel->list, 10, 30);
1609 epanel->closeB = WMCreateCommandButton(epanel->win);
1610 WMResizeWidget(epanel->closeB, 74, 24);
1611 WMMoveWidget(epanel->closeB, 165, 215);
1612 WMSetButtonText(epanel->closeB, _("Close"));
1614 epanel->extrB = WMCreateCommandButton(epanel->win);
1615 WMResizeWidget(epanel->extrB, 74, 24);
1616 WMMoveWidget(epanel->extrB, 80, 215);
1617 WMSetButtonText(epanel->extrB, _("Extract"));
1619 WMMapSubwidgets(epanel->win);
1622 /* take textures from file */
1626 WMRealizeWidget(epanel->win);
1628 WMMapWidget(epanel->win);