added contrib/ directory, updated WPrefs and wmsetbg for smoothed
[wmaker-crm.git] / WPrefs.app / Appearance.c
blobd99daefe321043480a9779c1e662069d83f04253
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 = NULL;
491 char *path;
492 RColor color;
494 str = PLGetString(PLGetArrayElement(texture, 1));
496 path = wfindfileinarray(GetObjectForKey("PixmapPath"), str);
497 if (path)
498 timage = RLoadImage(rc, path, 0);
500 if (!timage) {
501 wwarning("could not load file '%s': %s", path ? path : str,
502 RMessageForError(RErrorCode));
503 } else {
504 str = PLGetString(PLGetArrayElement(texture, 2));
505 str2rcolor(rc, str, &color);
507 switch (toupper(type[0])) {
508 case 'T':
509 image = RMakeTiledImage(timage, width, height);
510 RDestroyImage(timage);
511 timage = image;
512 break;
513 case 'C':
514 image = RMakeCenteredImage(timage, width, height, &color);
515 RDestroyImage(timage);
516 timage = image;
517 break;
518 case 'S':
519 case 'M':
520 image = RScaleImage(timage, width, height);
521 RDestroyImage(timage);
522 timage = image;
523 break;
527 free(path);
530 if (!image)
531 return None;
533 if (path) {
534 dumpRImage(path, image);
537 if (border < 0) {
538 if (border == RESIZEBAR_BEVEL) {
539 drawResizebarBevel(image);
540 } else if (border == MENU_BEVEL) {
541 drawMenuBevel(image);
543 } else if (border) {
544 RBevelImage(image, border);
547 RConvertImage(rc, image, &pixmap);
548 RDestroyImage(image);
550 return pixmap;
554 static Pixmap
555 renderMenu(_Panel *panel, proplist_t texture, int width, int iheight)
557 WMScreen *scr = WMWidgetScreen(panel->win);
558 Display *dpy = WMScreenDisplay(scr);
559 Pixmap pix, tmp;
560 char *str;
561 GC gc = XCreateGC(dpy, WMWidgetXID(panel->win), 0, NULL);
564 str = GetStringForKey("MenuStyle");
565 if (!str || strcasecmp(str, "normal")==0) {
566 int i;
568 tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
570 pix = XCreatePixmap(dpy, tmp, width, iheight*3,
571 WMScreenDepth(scr));
572 for (i = 0; i < 3; i++) {
573 XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight,
574 0, iheight*i);
576 XFreePixmap(dpy, tmp);
577 } else if (strcasecmp(str, "flat")==0) {
578 pix = renderTexture(scr, texture, width, iheight*3, NULL, RBEV_RAISED2);
579 } else {
580 pix = renderTexture(scr, texture, width, iheight*3, NULL, MENU_BEVEL);
583 XFreeGC(dpy, gc);
585 return pix;
589 static void
590 updatePreviewBox(_Panel *panel, int elements)
592 WMScreen *scr = WMWidgetScreen(panel->win);
593 Display *dpy = WMScreenDisplay(scr);
594 /* RContext *rc = WMScreenRContext(scr);*/
595 int refresh = 0;
596 Pixmap pix;
597 GC gc;
598 WMListItem *item;
599 TextureListItem *titem;
601 gc = XCreateGC(dpy, WMWidgetXID(panel->win), 0, NULL);
604 if (!panel->preview) {
605 WMColor *color;
607 panel->preview = XCreatePixmap(dpy, WMWidgetXID(panel->win),
608 260-4, 165-4, WMScreenDepth(scr));
610 color = WMGrayColor(scr);
611 XFillRectangle(dpy, panel->preview, WMColorGC(color),
612 0, 0, 260-4, 165-4);
613 WMReleaseColor(color);
615 refresh = -1;
618 if (elements & FTITLE) {
619 item = WMGetListItem(panel->texLs, panel->textureIndex[0]);
620 titem = (TextureListItem*)item->clientData;
622 pix = renderTexture(scr, titem->prop, 210, 20, NULL, RBEV_RAISED2);
624 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 5);
626 XFreePixmap(dpy, pix);
628 if (elements & UTITLE) {
629 item = WMGetListItem(panel->texLs, panel->textureIndex[1]);
630 titem = (TextureListItem*)item->clientData;
632 pix = renderTexture(scr, titem->prop, 210, 20, NULL, RBEV_RAISED2);
634 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 30);
636 XFreePixmap(dpy, pix);
638 if (elements & OTITLE) {
639 item = WMGetListItem(panel->texLs, panel->textureIndex[2]);
640 titem = (TextureListItem*)item->clientData;
642 pix = renderTexture(scr, titem->prop, 210, 20, NULL, RBEV_RAISED2);
644 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 55);
646 XFreePixmap(dpy, pix);
648 if (elements & RESIZEBAR) {
649 item = WMGetListItem(panel->texLs, panel->textureIndex[3]);
650 titem = (TextureListItem*)item->clientData;
652 pix = renderTexture(scr, titem->prop, 210, 9, NULL, RESIZEBAR_BEVEL);
654 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 80);
656 XFreePixmap(dpy, pix);
658 if (elements & MTITLE) {
659 item = WMGetListItem(panel->texLs, panel->textureIndex[4]);
660 titem = (TextureListItem*)item->clientData;
662 pix = renderTexture(scr, titem->prop, 100, 20, NULL, RBEV_RAISED2);
664 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 100, 20, 30, 95);
666 XFreePixmap(dpy, pix);
668 if (elements & MITEM) {
669 item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
670 titem = (TextureListItem*)item->clientData;
672 pix = renderMenu(panel, titem->prop, 100, 18);
674 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 100, 18*3, 30, 115);
676 XFreePixmap(dpy, pix);
678 if (elements & (MITEM|MTITLE)) {
679 XDrawLine(dpy, panel->preview, gc, 29, 95, 29, 115+36+20);
680 XDrawLine(dpy, panel->preview, gc, 29, 94, 129, 94);
683 if (elements & ICON) {
684 item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
685 titem = (TextureListItem*)item->clientData;
687 pix = renderTexture(scr, titem->prop, 64, 64, NULL,
688 titem->ispixmap ? 0 : RBEV_RAISED3);
690 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 64, 64, 170, 95);
692 XFreePixmap(dpy, pix);
696 if (refresh < 0) {
697 WMPixmap *p;
698 p = WMCreatePixmapFromXPixmaps(scr, panel->preview, None,
699 260-4, 165-4, WMScreenDepth(scr));
701 WMSetLabelImage(panel->prevL, p);
702 WMReleasePixmap(p);
703 } else {
704 WMRedisplayWidget(panel->prevL);
707 XFreeGC(dpy, gc);
713 static void
714 cancelNewTexture(void *data)
716 _Panel *panel = (_Panel*)data;
718 HideTexturePanel(panel->texturePanel);
724 static char*
725 makeFileName(char *prefix)
727 char *fname;
729 fname = wstrdup(prefix);
731 while (access(fname, F_OK)==0) {
732 char buf[30];
734 free(fname);
735 sprintf(buf, "%08lx.cache", time(NULL));
736 fname = wstrappend(prefix, buf);
739 return fname;
745 static void
746 okNewTexture(void *data)
748 _Panel *panel = (_Panel*)data;
749 WMListItem *item;
750 char *name;
751 char *str;
752 proplist_t prop;
753 TextureListItem *titem;
754 WMScreen *scr = WMWidgetScreen(panel->win);
756 titem = wmalloc(sizeof(TextureListItem));
757 memset(titem, 0, sizeof(TextureListItem));
759 HideTexturePanel(panel->texturePanel);
761 name = GetTexturePanelTextureName(panel->texturePanel);
763 prop = GetTexturePanelTexture(panel->texturePanel);
765 str = PLGetDescription(prop);
767 titem->title = name;
768 titem->prop = prop;
769 titem->texture = str;
770 titem->selectedFor = 0;
772 titem->ispixmap = isPixmap(prop);
774 titem->path = makeFileName(panel->fprefix);
775 titem->preview = renderTexture(scr, prop, TEXPREV_WIDTH, TEXPREV_HEIGHT,
776 titem->path, 0);
778 item = WMAddListItem(panel->texLs, "");
779 item->clientData = titem;
781 WMSetListPosition(panel->texLs, WMGetListNumberOfRows(panel->texLs));
785 static void
786 okEditTexture(void *data)
788 _Panel *panel = (_Panel*)data;
789 WMListItem *item;
790 char *name;
791 char *str;
792 proplist_t prop;
793 TextureListItem *titem;
795 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
796 titem = (TextureListItem*)item->clientData;
798 HideTexturePanel(panel->texturePanel);
800 if (titem->current) {
801 name = GetTexturePanelTextureName(panel->texturePanel);
803 free(titem->title);
804 titem->title = name;
807 prop = GetTexturePanelTexture(panel->texturePanel);
809 str = PLGetDescription(prop);
811 PLRelease(titem->prop);
812 titem->prop = prop;
814 titem->ispixmap = isPixmap(prop);
816 free(titem->texture);
817 titem->texture = str;
819 XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel->texLs)), titem->preview);
820 titem->preview = renderTexture(WMWidgetScreen(panel->texLs), titem->prop,
821 TEXPREV_WIDTH, TEXPREV_HEIGHT,
822 titem->path, 0);
824 WMRedisplayWidget(panel->texLs);
826 if (titem->selectedFor)
827 updatePreviewBox(panel, titem->selectedFor);
829 changePage(panel->secP, panel);
834 static void
835 editTexture(WMWidget *w, void *data)
837 _Panel *panel = (_Panel*)data;
838 WMListItem *item;
839 TextureListItem *titem;
841 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
842 titem = (TextureListItem*)item->clientData;
844 SetTexturePanelPixmapPath(panel->texturePanel,
845 GetObjectForKey("PixmapPath"));
847 SetTexturePanelTexture(panel->texturePanel, titem->title, titem->prop);
849 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
850 SetTexturePanelOkAction(panel->texturePanel, okEditTexture, panel);
852 ShowTexturePanel(panel->texturePanel);
857 static void
858 newTexture(WMWidget *w, void *data)
860 _Panel *panel = (_Panel*)data;
862 SetTexturePanelPixmapPath(panel->texturePanel,
863 GetObjectForKey("PixmapPath"));
865 SetTexturePanelTexture(panel->texturePanel, "New Texture", NULL);
867 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
869 SetTexturePanelOkAction(panel->texturePanel, okNewTexture, panel);
871 ShowTexturePanel(panel->texturePanel);
876 static void
877 deleteTexture(WMWidget *w, void *data)
879 _Panel *panel = (_Panel*)data;
880 WMListItem *item;
881 TextureListItem *titem;
882 int row;
883 int section;
885 section = WMGetPopUpButtonSelectedItem(panel->secP);
886 row = WMGetListSelectedItemRow(panel->texLs);
887 item = WMGetListItem(panel->texLs, row);
888 titem = (TextureListItem*)item->clientData;
890 if (titem->selectedFor & (1 << section)) {
891 TextureListItem *titem2;
893 panel->textureIndex[section] = section;
894 item = WMGetListItem(panel->texLs, section);
895 titem2 = (TextureListItem*)item->clientData;
896 titem2->selectedFor |= 1 << section;
899 free(titem->title);
900 free(titem->texture);
901 PLRelease(titem->prop);
902 if (titem->path) {
903 if (remove(titem->path) < 0 && errno != ENOENT) {
904 wsyserror("could not remove file %s", titem->path);
906 free(titem->path);
909 free(titem);
911 WMRemoveListItem(panel->texLs, row);
912 WMSetButtonEnabled(panel->delB, False);
918 static void
919 extractTexture(WMWidget *w, void *data)
921 _Panel *panel = (_Panel*)data;
922 char *path;
923 WMOpenPanel *opanel;
924 WMScreen *scr = WMWidgetScreen(w);
926 opanel = WMGetOpenPanel(scr);
927 WMSetFilePanelCanChooseDirectories(opanel, False);
928 WMSetFilePanelCanChooseFiles(opanel, True);
930 if (WMRunModalFilePanelForDirectory(opanel, panel->win, wgethomedir(),
931 _("Select File"), NULL)) {
932 path = WMGetFilePanelFileName(opanel);
934 OpenExtractPanelFor(panel, path);
936 free(path);
941 static void
942 changePage(WMWidget *w, void *data)
944 _Panel *panel = (_Panel*)data;
945 int section;
946 WMListItem *item;
947 TextureListItem *titem;
948 char *str;
949 WMScreen *scr = WMWidgetScreen(w);
950 RContext *rc = WMScreenRContext(scr);
951 static WMPoint positions[] = {
952 {5, 5},
953 {5, 30},
954 {5, 55},
955 {5, 80},
956 {5, 95},
957 {5, 130},
958 {145, 110}
961 section = WMGetPopUpButtonSelectedItem(panel->secP);
963 WMSelectListItem(panel->texLs, panel->textureIndex[section]);
965 WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2);
967 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
969 titem = (TextureListItem*)item->clientData;
971 str = wmalloc(strlen(titem->title) + strlen(titem->texture) + 4);
972 sprintf(str, "%s: %s", titem->title, titem->texture);
973 WMSetLabelText(panel->texsL, str);
974 free(str);
977 WMColor *color;
979 color = WMGrayColor(scr);
980 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
981 positions[panel->oldsection].x,
982 positions[panel->oldsection].y, 22, 22);
983 WMReleaseColor(color);
985 panel->oldsection = section;
986 WMDrawPixmap(panel->hand, panel->preview, positions[section].x,
987 positions[section].y);
989 WMRedisplayWidget(panel->prevL);
994 static void
995 previewClick(XEvent *event, void *clientData)
997 _Panel *panel = (_Panel*)clientData;
998 int i;
999 static WMRect parts[] = {
1000 {{30, 5},{210, 20}},
1001 {{30,30},{210,20}},
1002 {{30,55},{210,20}},
1003 {{30,80},{210,9}},
1004 {{30,95},{100,20}},
1005 {{30,115},{100,60}},
1006 {{170,90},{64,64}}
1009 for (i = 0; i < 7; i++) {
1010 if (event->xbutton.x >= parts[i].pos.x
1011 && event->xbutton.y >= parts[i].pos.y
1012 && event->xbutton.x < parts[i].pos.x + parts[i].size.width
1013 && event->xbutton.y < parts[i].pos.y + parts[i].size.height) {
1015 WMSetPopUpButtonSelectedItem(panel->secP, i);
1016 changePage(panel->secP, panel);
1017 return;
1023 static void
1024 textureClick(WMWidget *w, void *data)
1026 _Panel *panel = (_Panel*)data;
1027 int i;
1028 WMListItem *item;
1029 TextureListItem *titem;
1031 i = WMGetListSelectedItemRow(panel->texLs);
1033 item = WMGetListItem(panel->texLs, i);
1035 titem = (TextureListItem*)item->clientData;
1037 if (titem->current) {
1038 WMSetButtonEnabled(panel->delB, False);
1039 } else {
1040 WMSetButtonEnabled(panel->delB, True);
1046 static void
1047 textureDoubleClick(WMWidget *w, void *data)
1049 _Panel *panel = (_Panel*)data;
1050 int i, section;
1051 WMListItem *item;
1052 TextureListItem *titem;
1053 char *str;
1055 /* unselect old texture */
1056 section = WMGetPopUpButtonSelectedItem(panel->secP);
1058 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
1059 titem = (TextureListItem*)item->clientData;
1060 titem->selectedFor &= ~(1 << section);
1062 /* select new texture */
1063 i = WMGetListSelectedItemRow(panel->texLs);
1065 item = WMGetListItem(panel->texLs, i);
1067 titem = (TextureListItem*)item->clientData;
1069 titem->selectedFor |= 1<<section;
1071 panel->textureIndex[section] = i;
1073 WMRedisplayWidget(panel->texLs);
1075 str = wmalloc(strlen(titem->title) + strlen(titem->texture) + 4);
1076 sprintf(str, "%s: %s", titem->title, titem->texture);
1077 WMSetLabelText(panel->texsL, str);
1078 free(str);
1080 updatePreviewBox(panel, 1<<section);
1086 static void
1087 paintListItem(WMList *lPtr, int index, Drawable d, char *text, int state,
1088 WMRect *rect)
1090 _Panel *panel = (_Panel*)WMGetHangedData(lPtr);
1091 WMScreen *scr = WMWidgetScreen(lPtr);
1092 int width, height, x, y;
1093 Display *dpy = WMScreenDisplay(scr);
1094 WMColor *white = WMWhiteColor(scr);
1095 WMListItem *item;
1096 WMColor *black = WMBlackColor(scr);
1097 TextureListItem *titem;
1099 width = rect->size.width;
1100 height = rect->size.height;
1101 x = rect->pos.x;
1102 y = rect->pos.y;
1104 if (state & WLDSSelected)
1105 XFillRectangle(dpy, d, WMColorGC(white), x, y, width, height);
1106 else
1107 XClearArea(dpy, d, x, y, width, height, False);
1109 item = WMGetListItem(lPtr, index);
1110 titem = (TextureListItem*)item->clientData;
1112 if (titem->preview)
1113 XCopyArea(dpy, titem->preview, d, WMColorGC(black), 0, 0, TEXPREV_WIDTH,
1114 TEXPREV_HEIGHT, x + 5, y + 5);
1116 if ((1 << WMGetPopUpButtonSelectedItem(panel->secP)) & titem->selectedFor)
1117 WMDrawPixmap(panel->onLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1118 else if (titem->selectedFor)
1119 WMDrawPixmap(panel->offLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1121 WMDrawString(scr, d, WMColorGC(black), panel->boldFont,
1122 x + TEXPREV_WIDTH + 22, y + 2, titem->title,
1123 strlen(titem->title));
1125 WMDrawString(scr, d, WMColorGC(black), panel->smallFont,
1126 x + TEXPREV_WIDTH + 14, y + 18, titem->texture,
1127 strlen(titem->texture));
1130 WMReleaseColor(white);
1131 WMReleaseColor(black);
1136 static Pixmap
1137 loadRImage(WMScreen *scr, char *path)
1139 FILE *f;
1140 RImage *image;
1141 int w, h, d;
1142 int i;
1143 Pixmap pixmap;
1145 f = fopen(path, "r");
1146 if (!f)
1147 return None;
1149 fscanf(f, "%02x%02x%1x", &w, &h, &d);
1151 image = RCreateImage(w, h, d == 4);
1152 for (i = 0; i < d; i++) {
1153 fread(image->data[i], 1, w*h, f);
1155 fclose(f);
1157 RConvertImage(WMScreenRContext(scr), image, &pixmap);
1158 RDestroyImage(image);
1160 return pixmap;
1165 static void
1166 fillTextureList(WMList *lPtr)
1168 proplist_t textureList;
1169 proplist_t texture;
1170 WMUserDefaults *udb = WMGetStandardUserDefaults();
1171 int i;
1172 TextureListItem *titem;
1173 WMScreen *scr = WMWidgetScreen(lPtr);
1175 textureList = WMGetUDObjectForKey(udb, "TextureList");
1176 if (!textureList)
1177 return;
1179 for (i = 0; i < PLGetNumberOfElements(textureList); i++) {
1180 WMListItem *item;
1182 texture = PLGetArrayElement(textureList, i);
1184 titem = wmalloc(sizeof(TextureListItem));
1185 memset(titem, 0, sizeof(TextureListItem));
1187 titem->title = wstrdup(PLGetString(PLGetArrayElement(texture, 0)));
1188 titem->prop = PLRetain(PLGetArrayElement(texture, 1));
1189 titem->texture = PLGetDescription(titem->prop);
1190 titem->selectedFor = 0;
1191 titem->path = wstrdup(PLGetString(PLGetArrayElement(texture, 2)));
1193 titem->preview = loadRImage(scr, titem->path);
1194 if (!titem->preview) {
1195 titem->preview = renderTexture(scr, titem->prop, TEXPREV_WIDTH,
1196 TEXPREV_HEIGHT, NULL, 0);
1198 item = WMAddListItem(lPtr, "");
1199 item->clientData = titem;
1204 static void
1205 createPanel(Panel *p)
1207 _Panel *panel = (_Panel*)p;
1208 WMColor *color;
1209 WMFont *font;
1210 WMScreen *scr = WMWidgetScreen(panel->win);
1212 char *tmp;
1213 Bool ok = True;
1215 panel->fprefix = wstrappend(wusergnusteppath(), "/.AppInfo");
1217 if (access(panel->fprefix, F_OK)!=0) {
1218 if (mkdir(panel->fprefix, 0755) < 0) {
1219 wsyserror(panel->fprefix);
1220 ok = False;
1223 if (ok) {
1224 tmp = wstrappend(panel->fprefix, "/WPrefs/");
1225 free(panel->fprefix);
1226 panel->fprefix = tmp;
1227 if (access(panel->fprefix, F_OK)!=0) {
1228 if (mkdir(panel->fprefix, 0755) < 0) {
1229 wsyserror(panel->fprefix);
1234 panel->smallFont = WMSystemFontOfSize(scr, 10);
1235 panel->normalFont = WMSystemFontOfSize(scr, 12);
1236 panel->boldFont = WMBoldSystemFontOfSize(scr, 12);
1238 panel->onLed = WMCreatePixmapFromXPMData(scr, blueled_xpm);
1239 panel->offLed = WMCreatePixmapFromXPMData(scr, blueled2_xpm);
1240 panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm);
1242 panel->frame = WMCreateFrame(panel->win);
1243 WMResizeWidget(panel->frame, FRAME_WIDTH, FRAME_HEIGHT);
1244 WMMoveWidget(panel->frame, FRAME_LEFT, FRAME_TOP);
1246 /* preview box */
1247 panel->prevL = WMCreateLabel(panel->frame);
1248 WMResizeWidget(panel->prevL, 260, 165);
1249 WMMoveWidget(panel->prevL, 15, 10);
1250 WMSetLabelRelief(panel->prevL, WRSunken);
1251 WMSetLabelImagePosition(panel->prevL, WIPImageOnly);
1253 WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask,
1254 previewClick, panel);
1257 panel->secP = WMCreatePopUpButton(panel->frame);
1258 WMResizeWidget(panel->secP, 260, 20);
1259 WMMoveWidget(panel->secP, 15, 180);
1260 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1261 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window"));
1262 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Unfocused Windows"));
1263 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window's Owner"));
1264 WMAddPopUpButtonItem(panel->secP, _("Window Resizebar"));
1265 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
1266 WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
1267 WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
1268 /* WMAddPopUpButtonItem(panel->secP, _("Workspace Backgrounds"));
1270 WMSetPopUpButtonAction(panel->secP, changePage, panel);
1273 panel->texsL = WMCreateLabel(panel->frame);
1274 WMResizeWidget(panel->texsL, 260, 20);
1275 WMMoveWidget(panel->texsL, 15, 205);
1276 WMSetLabelWraps(panel->texsL, False);
1278 /* texture list */
1279 font = WMBoldSystemFontOfSize(scr, 12);
1281 panel->texL = WMCreateLabel(panel->frame);
1282 WMResizeWidget(panel->texL, 225, 18);
1283 WMMoveWidget(panel->texL, 285, 10);
1284 WMSetLabelFont(panel->texL, font);
1285 WMSetLabelText(panel->texL, _("Textures"));
1286 WMSetLabelRelief(panel->texL, WRSunken);
1287 WMSetLabelTextAlignment(panel->texL, WACenter);
1288 color = WMDarkGrayColor(scr);
1289 WMSetWidgetBackgroundColor(panel->texL, color);
1290 WMReleaseColor(color);
1291 color = WMWhiteColor(scr);
1292 WMSetLabelTextColor(panel->texL, color);
1293 WMReleaseColor(color);
1295 WMReleaseFont(font);
1297 panel->texLs = WMCreateList(panel->frame);
1298 WMResizeWidget(panel->texLs, 225, 144);
1299 WMMoveWidget(panel->texLs, 285, 30);
1300 WMSetListUserDrawItemHeight(panel->texLs, 35);
1301 WMSetListUserDrawProc(panel->texLs, paintListItem);
1302 WMHangData(panel->texLs, panel);
1303 WMSetListAction(panel->texLs, textureClick, panel);
1304 WMSetListDoubleAction(panel->texLs, textureDoubleClick, panel);
1306 WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
1307 "for the selected item."),
1308 WMWidgetView(panel->texLs));
1310 /* command buttons */
1312 font = WMSystemFontOfSize(scr, 10);
1315 panel->newB = WMCreateCommandButton(panel->frame);
1316 WMResizeWidget(panel->newB, 56, 48);
1317 WMMoveWidget(panel->newB, 285, 180);
1318 WMSetButtonFont(panel->newB, font);
1319 WMSetButtonImagePosition(panel->newB, WIPAbove);
1320 WMSetButtonText(panel->newB, _("New"));
1321 WMSetButtonAction(panel->newB, newTexture, panel);
1322 SetButtonAlphaImage(scr, panel->newB, TNEW_FILE);
1324 WMSetBalloonTextForView(_("Create a new texture."),
1325 WMWidgetView(panel->newB));
1327 panel->ripB = WMCreateCommandButton(panel->frame);
1328 WMResizeWidget(panel->ripB, 56, 48);
1329 WMMoveWidget(panel->ripB, 341, 180);
1330 WMSetButtonFont(panel->ripB, font);
1331 WMSetButtonImagePosition(panel->ripB, WIPAbove);
1332 WMSetButtonText(panel->ripB, _("Extract..."));
1333 WMSetButtonAction(panel->ripB, extractTexture, panel);
1334 SetButtonAlphaImage(scr, panel->ripB, TEXTR_FILE);
1336 WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."),
1337 WMWidgetView(panel->ripB));
1339 WMSetButtonEnabled(panel->ripB, False);
1341 panel->editB = WMCreateCommandButton(panel->frame);
1342 WMResizeWidget(panel->editB, 56, 48);
1343 WMMoveWidget(panel->editB, 397, 180);
1344 WMSetButtonFont(panel->editB, font);
1345 WMSetButtonImagePosition(panel->editB, WIPAbove);
1346 WMSetButtonText(panel->editB, _("Edit"));
1347 SetButtonAlphaImage(scr, panel->editB, TEDIT_FILE);
1348 WMSetButtonAction(panel->editB, editTexture, panel);
1349 WMSetBalloonTextForView(_("Edit the highlighted texture."),
1350 WMWidgetView(panel->editB));
1352 panel->delB = WMCreateCommandButton(panel->frame);
1353 WMResizeWidget(panel->delB, 56, 48);
1354 WMMoveWidget(panel->delB, 453, 180);
1355 WMSetButtonFont(panel->delB, font);
1356 WMSetButtonImagePosition(panel->delB, WIPAbove);
1357 WMSetButtonText(panel->delB, _("Delete"));
1358 SetButtonAlphaImage(scr, panel->delB, TDEL_FILE);
1359 WMSetButtonEnabled(panel->delB, False);
1360 WMSetButtonAction(panel->delB, deleteTexture, panel);
1361 WMSetBalloonTextForView(_("Delete the highlighted texture."),
1362 WMWidgetView(panel->delB));
1364 WMReleaseFont(font);
1366 /**/
1368 WMRealizeWidget(panel->frame);
1369 WMMapSubwidgets(panel->frame);
1371 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1373 showData(panel);
1375 changePage(panel->secP, panel);
1377 fillTextureList(panel->texLs);
1379 panel->texturePanel = CreateTexturePanel(panel->win);
1384 static void
1385 setupTextureFor(WMList *list, char *key, char *defValue, char *title,
1386 int index)
1388 WMListItem *item;
1389 TextureListItem *titem;
1391 titem = wmalloc(sizeof(TextureListItem));
1392 memset(titem, 0, sizeof(TextureListItem));
1394 titem->title = wstrdup(title);
1395 titem->prop = GetObjectForKey(key);
1396 if (!titem->prop) {
1397 titem->prop = PLGetProplistWithDescription(defValue);
1398 } else {
1399 PLRetain(titem->prop);
1401 titem->texture = PLGetDescription((proplist_t)titem->prop);
1402 titem->current = 1;
1403 titem->selectedFor = 1<<index;
1405 titem->ispixmap = isPixmap(titem->prop);
1407 titem->preview = renderTexture(WMWidgetScreen(list), titem->prop,
1408 TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0);
1410 item = WMAddListItem(list, "");
1411 item->clientData = titem;
1416 static void
1417 showData(_Panel *panel)
1419 int i = 0;
1421 setupTextureFor(panel->texLs, "FTitleBack", "(solid, black)",
1422 "[Focused]", i);
1423 panel->textureIndex[i] = i++;
1425 setupTextureFor(panel->texLs, "UTitleBack", "(solid, gray)",
1426 "[Unfocused]", i);
1427 panel->textureIndex[i] = i++;
1429 setupTextureFor(panel->texLs, "PTitleBack", "(solid, \"#616161\")",
1430 "[Owner of Focused]", i);
1431 panel->textureIndex[i] = i++;
1433 setupTextureFor(panel->texLs, "ResizebarBack", "(solid, gray)",
1434 "[Resizebar]", i);
1435 panel->textureIndex[i] = i++;
1437 setupTextureFor(panel->texLs, "MenuTitleBack", "(solid, black)",
1438 "[Menu Title]", i);
1439 panel->textureIndex[i] = i++;
1441 setupTextureFor(panel->texLs, "MenuTextBack", "(solid, gray)",
1442 "[Menu Item]", i);
1443 panel->textureIndex[i] = i++;
1445 setupTextureFor(panel->texLs, "IconBack", "(solid, gray)", "[Icon]", i);
1446 panel->textureIndex[i] = i++;
1448 setupTextureFor(panel->texLs, "WorkspaceBack", "(solid, black)",
1449 "[Workspace]", i);
1450 panel->textureIndex[i] = i++;
1453 updatePreviewBox(panel, EVERYTHING);
1458 static void
1459 storeData(_Panel *panel)
1461 TextureListItem *titem;
1462 WMListItem *item;
1464 item = WMGetListItem(panel->texLs, panel->textureIndex[0]);
1465 titem = (TextureListItem*)item->clientData;
1466 SetObjectForKey(titem->prop, "FTitleBack");
1468 item = WMGetListItem(panel->texLs, panel->textureIndex[1]);
1469 titem = (TextureListItem*)item->clientData;
1470 SetObjectForKey(titem->prop, "UTitleBack");
1472 item = WMGetListItem(panel->texLs, panel->textureIndex[2]);
1473 titem = (TextureListItem*)item->clientData;
1474 SetObjectForKey(titem->prop, "PTitleBack");
1476 item = WMGetListItem(panel->texLs, panel->textureIndex[3]);
1477 titem = (TextureListItem*)item->clientData;
1478 SetObjectForKey(titem->prop, "ResizebarBack");
1480 item = WMGetListItem(panel->texLs, panel->textureIndex[4]);
1481 titem = (TextureListItem*)item->clientData;
1482 SetObjectForKey(titem->prop, "MenuTitleBack");
1484 item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
1485 titem = (TextureListItem*)item->clientData;
1486 SetObjectForKey(titem->prop, "MenuTextBack");
1488 item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
1489 titem = (TextureListItem*)item->clientData;
1490 SetObjectForKey(titem->prop, "IconBack");
1494 static void
1495 prepareForClose(_Panel *panel)
1497 proplist_t textureList;
1498 proplist_t texture;
1499 int i;
1500 TextureListItem *titem;
1501 WMListItem *item;
1502 WMUserDefaults *udb = WMGetStandardUserDefaults();
1504 textureList = PLMakeArrayFromElements(NULL, NULL);
1506 /* store list of textures */
1507 for (i = 7; i < WMGetListNumberOfRows(panel->texLs); i++) {
1508 item = WMGetListItem(panel->texLs, i);
1509 titem = (TextureListItem*)item->clientData;
1511 texture = PLMakeArrayFromElements(PLMakeString(titem->title),
1512 PLRetain(titem->prop),
1513 PLMakeString(titem->path),
1514 NULL);
1516 PLAppendArrayElement(textureList, texture);
1519 WMSetUDObjectForKey(udb, textureList, "TextureList");
1520 PLRelease(textureList);
1522 WMSynchronizeUserDefaults(udb);
1527 Panel*
1528 InitAppearance(WMScreen *scr, WMWindow *win)
1530 _Panel *panel;
1532 panel = wmalloc(sizeof(_Panel));
1533 memset(panel, 0, sizeof(_Panel));
1535 panel->sectionName = _("Appearance Preferences");
1537 panel->description = _("Background texture configuration for windows,\n"
1538 "menus and icons.");
1540 panel->win = win;
1542 panel->callbacks.createWidgets = createPanel;
1543 panel->callbacks.updateDomain = storeData;
1544 panel->callbacks.prepareForClose = prepareForClose;
1546 AddSection(panel, ICON_FILE);
1548 return panel;
1553 /****************************************************************************/
1557 typedef struct ExtractPanel {
1558 WMWindow *win;
1560 WMLabel *label;
1561 WMList *list;
1563 WMButton *closeB;
1564 WMButton *extrB;
1565 } ExtractPanel;
1569 static void
1570 OpenExtractPanelFor(_Panel *panel, char *path)
1572 ExtractPanel *epanel;
1573 WMColor *color;
1574 WMFont *font;
1575 WMScreen *scr = WMWidgetScreen(panel->win);
1577 epanel = wmalloc(sizeof(ExtractPanel));
1578 epanel->win = WMCreatePanelWithStyleForWindow(panel->win, "extract",
1579 WMTitledWindowMask
1580 |WMClosableWindowMask);
1581 WMResizeWidget(epanel->win, 245, 250);
1582 WMSetWindowTitle(epanel->win, _("Extract Texture"));
1584 epanel->label = WMCreateLabel(epanel->win);
1585 WMResizeWidget(epanel->label, 225, 18);
1586 WMMoveWidget(epanel->label, 10, 10);
1587 WMSetLabelTextAlignment(epanel->label, WACenter);
1588 WMSetLabelRelief(epanel->label, WRSunken);
1590 color = WMDarkGrayColor(scr);
1591 WMSetWidgetBackgroundColor(epanel->label, color);
1592 WMReleaseColor(color);
1594 color = WMWhiteColor(scr);
1595 WMSetLabelTextColor(epanel->label, color);
1596 WMReleaseColor(color);
1598 font = WMBoldSystemFontOfSize(scr, 12);
1599 WMSetLabelFont(epanel->label, font);
1600 WMReleaseFont(font);
1602 WMSetLabelText(epanel->label, _("Textures"));
1604 epanel->list = WMCreateList(epanel->win);
1605 WMResizeWidget(epanel->list, 225, 165);
1606 WMMoveWidget(epanel->list, 10, 30);
1610 epanel->closeB = WMCreateCommandButton(epanel->win);
1611 WMResizeWidget(epanel->closeB, 74, 24);
1612 WMMoveWidget(epanel->closeB, 165, 215);
1613 WMSetButtonText(epanel->closeB, _("Close"));
1615 epanel->extrB = WMCreateCommandButton(epanel->win);
1616 WMResizeWidget(epanel->extrB, 74, 24);
1617 WMMoveWidget(epanel->extrB, 80, 215);
1618 WMSetButtonText(epanel->extrB, _("Extract"));
1620 WMMapSubwidgets(epanel->win);
1623 /* take textures from file */
1627 WMRealizeWidget(epanel->win);
1629 WMMapWidget(epanel->win);