For libwraster:
[wmaker-crm.git] / WPrefs.app / Appearance.c
blob86ea04855af5fa12806026754f0a8c503920fab2
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 WMBox *box;
42 char *sectionName;
44 char *description;
46 CallbackRec callbacks;
48 WMWidget *parent;
50 WMLabel *prevL;
53 WMTabView *tabv;
55 /* texture list */
56 WMFrame *texF;
57 WMList *texLs;
59 WMPopUpButton *secP;
61 WMButton *newB;
62 WMButton *editB;
63 WMButton *ripB;
64 WMButton *delB;
66 /* text color */
67 WMFrame *colF;
69 WMPopUpButton *colP;
70 WMColor *colors[14];
72 WMColorWell *colW;
74 WMColorWell *sampW[24];
76 /* options */
77 WMFrame *optF;
79 WMFrame *mstyF;
80 WMButton *mstyB[3];
82 WMFrame *taliF;
83 WMButton *taliB[3];
85 /* root bg */
86 WMFrame *bgF;
88 WMLabel *bgprevL;
89 WMButton *selbgB;
91 WMPopUpButton *modeB[3];
93 /* */
95 int textureIndex[8];
97 WMFont *smallFont;
98 WMFont *normalFont;
99 WMFont *boldFont;
101 TexturePanel *texturePanel;
103 WMPixmap *onLed;
104 WMPixmap *offLed;
105 WMPixmap *hand;
107 int oldsection;
108 int oldcsection;
110 char oldTabItem;
112 char menuStyle;
114 char titleAlignment;
116 Pixmap preview;
118 char *fprefix;
119 } _Panel;
122 typedef struct {
123 char *title;
124 char *texture;
125 proplist_t prop;
126 Pixmap preview;
128 char *path;
130 char selectedFor;
131 unsigned current:1;
132 unsigned ispixmap:1;
133 } TextureListItem;
135 static void updateColorPreviewBox(_Panel *panel, int elements);
137 static void showData(_Panel *panel);
139 static void changePage(WMWidget *w, void *data);
141 static void changeColorPage(WMWidget *w, void *data);
143 static void OpenExtractPanelFor(_Panel *panel, char *path);
147 static void changedTabItem(struct WMTabViewDelegate *self, WMTabView *tabView,
148 WMTabViewItem *item);
152 static WMTabViewDelegate tabviewDelegate = {
153 NULL,
154 NULL, /* didChangeNumberOfItems */
155 changedTabItem, /* didSelectItem */
156 NULL, /* shouldSelectItem */
157 NULL /* willSelectItem */
161 #define ICON_FILE "appearance"
163 #define TNEW_FILE "tnew"
164 #define TDEL_FILE "tdel"
165 #define TEDIT_FILE "tedit"
166 #define TEXTR_FILE "textr"
168 #define MSTYLE1_FILE "msty1"
169 #define MSTYLE2_FILE "msty2"
170 #define MSTYLE3_FILE "msty3"
173 /* XPM */
174 static char * blueled_xpm[] = {
175 "8 8 17 1",
176 " c None",
177 ". c #020204",
178 "+ c #16B6FC",
179 "@ c #176AFC",
180 "# c #163AFC",
181 "$ c #72D2FC",
182 "% c #224CF4",
183 "& c #76D6FC",
184 "* c #16AAFC",
185 "= c #CEE9FC",
186 "- c #229EFC",
187 "; c #164CFC",
188 "> c #FAFEFC",
189 ", c #2482FC",
190 "' c #1652FC",
191 ") c #1E76FC",
192 "! c #1A60FC",
193 " .... ",
194 " .=>-@. ",
195 ".=>$@@'.",
196 ".=$@!;;.",
197 ".!@*+!#.",
198 ".#'*+*,.",
199 " .@)@,. ",
200 " .... "};
203 /* XPM */
204 static char *blueled2_xpm[] = {
205 /* width height num_colors chars_per_pixel */
206 " 8 8 17 1",
207 /* colors */
208 ". c None",
209 "# c #090909",
210 "a c #4b63a4",
211 "b c #011578",
212 "c c #264194",
213 "d c #04338c",
214 "e c #989dac",
215 "f c #011a7c",
216 "g c #465c9c",
217 "h c #03278a",
218 "i c #6175ac",
219 "j c #011e74",
220 "k c #043a90",
221 "l c #042f94",
222 "m c #0933a4",
223 "n c #022184",
224 "o c #012998",
225 /* pixels */
226 "..####..",
227 ".#aimn#.",
228 "#aechnf#",
229 "#gchnjf#",
230 "#jndknb#",
231 "#bjdddl#",
232 ".#nono#.",
233 "..####.."
237 /* XPM */
238 static char * hand_xpm[] = {
239 "22 21 19 1",
240 " c None",
241 ". c #030305",
242 "+ c #7F7F7E",
243 "@ c #B5B5B6",
244 "# c #C5C5C6",
245 "$ c #969697",
246 "% c #FDFDFB",
247 "& c #F2F2F4",
248 "* c #E5E5E4",
249 "= c #ECECEC",
250 "- c #DCDCDC",
251 "; c #D2D2D0",
252 "> c #101010",
253 ", c #767674",
254 "' c #676767",
255 ") c #535355",
256 "! c #323234",
257 "~ c #3E3C56",
258 "{ c #333147",
259 " ",
260 " ..... ",
261 " ..+@##$. ",
262 " .%%%&@.......... ",
263 " .%*%%&#%%%%%%%%%$. ",
264 " .*#%%%%%%%%%&&&&==. ",
265 " .-%%%%%%%%%=*-;;;#$. ",
266 " .-%%%%%%%%&..>..... ",
267 " >-%%%%%%%%%*#+. ",
268 " >-%%%%%%%%%*@,. ",
269 " >#%%%%%%%%%*@'. ",
270 " >$&&%%%%%%=... ",
271 " .+@@;=&%%&;$,> ",
272 " .',$@####$+). ",
273 " .!',+$++,'. ",
274 " ..>>>>>. ",
275 " ",
276 " ~~{{{~~ ",
277 " {{{{{{{{{{{ ",
278 " ~~{{{~~ ",
279 " "};
283 static char *sampleColors[] = {
284 "black",
285 "#292929",
286 "#525252",
287 "#848484",
288 "#adadad",
289 "#d6d6d6",
290 "white",
291 "#d6d68c",
292 "#d6a57b",
293 "#8cd68c",
294 "#8cd6ce",
295 "#d68c8c",
296 "#8c9cd6",
297 "#bd86d6",
298 "#d68cbd",
299 "#d64a4a",
300 "#4a5ad6",
301 "#4ad6ce",
302 "#4ad65a",
303 "#ced64a",
304 "#d6844a",
305 "#8ad631",
306 "#ce29c6",
307 "#ce2973",
308 "black"
312 static char *textureOptions[] = {
313 "FTitleBack", "(solid, black)", "[Focused]",
314 "UTitleBack", "(solid, gray)", "[Unfocused]",
315 "PTitleBack", "(solid, \"#616161\")", "[Owner of Focused]",
316 "ResizebarBack", "(solid, gray)", "[Resizebar]",
317 "MenuTitleBack", "(solid, black)", "[Menu Title]",
318 "MenuTextBack", "(solid, gray)", "[Menu Item]",
319 "IconBack", "(solid, gray)", "[Icon]"
323 #define RESIZEBAR_BEVEL -1
324 #define MENU_BEVEL -2
326 #define TEXPREV_WIDTH 40
327 #define TEXPREV_HEIGHT 24
330 #define MSTYLE_NORMAL 0
331 #define MSTYLE_SINGLE 1
332 #define MSTYLE_FLAT 2
335 #define FTITLE_COL (1<<0)
336 #define UTITLE_COL (1<<1)
337 #define OTITLE_COL (1<<2)
338 #define MTITLE_COL (1<<3)
339 #define MITEM_COL (1<<4)
340 #define MDISAB_COL (1<<5)
341 #define MHIGH_COL (1<<6)
342 #define MHIGHT_COL (1<<7)
343 #define ICONT_COL (1<<8)
344 #define ICONB_COL (1<<9)
345 #define CLIP_COL (1<<10)
346 #define CCLIP_COL (1<<11)
349 static char *colorOptions[] = {
350 "FTitleColor", "white",
351 "UTitleColor", "black",
352 "PTitleColor", "white",
353 "MenuTitleColor", "white",
354 "MenuTextColor", "black",
355 "MenuDisabledColor", "#616161",
356 "HighlightColor", "white",
357 "HighlightTextColor", "black",
358 "IconTitleColor", "white",
359 "IconTitleBack", "black",
360 "ClipTitleColor", "black",
361 "CClipTitleColor", "#454045"
367 static WMRect previewPositions[] = {
368 #define PFOCUSED 0
369 {{30,10},{190, 20}},
370 #define PUNFOCUSED 1
371 {{30,40},{190,20}},
372 #define POWNER 2
373 {{30,70},{190,20}},
374 #define PRESIZEBAR 3
375 {{30,100},{190,9}},
376 #define PMTITLE 4
377 {{30,120},{90,20}},
378 #define PMITEM 5
379 {{30,140},{90,20*4}},
380 #define PICON 6
381 {{155,130},{64,64}}
383 #define EVERYTHING 0xff
386 static WMRect previewColorPositions[] = {
387 {{30,10},{190, 20}},
388 {{30,40},{190,20}},
389 {{30,70},{190,20}},
390 {{30,120},{90,20}},
391 {{30,140},{90,20}},
392 {{30,160},{90,20}},
393 {{30,180},{90,20}},
394 {{30,200},{90,20}},
395 {{155,130},{64,64}},
396 {{155,130},{64,64}},
397 {{155,130},{64,64}},
398 {{155,130},{64,64}}
403 static void
404 str2rcolor(RContext *rc, char *name, RColor *color)
406 XColor xcolor;
408 XParseColor(rc->dpy, rc->cmap, name, &xcolor);
410 color->alpha = 255;
411 color->red = xcolor.red >> 8;
412 color->green = xcolor.green >> 8;
413 color->blue = xcolor.blue >> 8;
417 static void
418 dumpRImage(char *path, RImage *image)
420 FILE *f;
421 int channels = (image->format == RRGBAFormat ? 4 : 3);
423 f = fopen(path, "w");
424 if (!f) {
425 wsyserror(path);
426 return;
428 fprintf(f, "%02x%02x%1x", image->width, image->height, channels);
430 fwrite(image->data, 1, image->width * image->height * channels, f);
432 if (fclose(f) < 0) {
433 wsyserror(path);
439 static int
440 isPixmap(proplist_t prop)
442 proplist_t p;
443 char *s;
445 p = PLGetArrayElement(prop, 0);
446 s = PLGetString(p);
447 if (strcasecmp(&s[1], "pixmap")==0)
448 return 1;
449 else
450 return 0;
454 /**********************************************************************/
456 static void
457 drawResizebarBevel(RImage *img)
459 RColor light;
460 RColor dark;
461 RColor black;
462 int width = img->width;
463 int height = img->height;
464 int cwidth = 28;
466 black.alpha = 255;
467 black.red = black.green = black.blue = 0;
469 light.alpha = 0;
470 light.red = light.green = light.blue = 80;
472 dark.alpha = 0;
473 dark.red = dark.green = dark.blue = 40;
475 ROperateLine(img, RSubtractOperation, 0, 0, width-1, 0, &dark);
476 ROperateLine(img, RAddOperation, 0, 1, width-1, 1, &light);
478 ROperateLine(img, RSubtractOperation, cwidth, 2, cwidth, height-1, &dark);
479 ROperateLine(img, RAddOperation, cwidth+1, 2, cwidth+1, height-1, &light);
481 ROperateLine(img, RSubtractOperation, width-cwidth-2, 2, width-cwidth-2,
482 height-1, &dark);
483 ROperateLine(img, RAddOperation, width-cwidth-1, 2, width-cwidth-1,
484 height-1, &light);
486 RDrawLine(img, 0, height-1, width-1, height-1, &black);
487 RDrawLine(img, 0, 0, 0, height-1, &black);
488 RDrawLine(img, width-1, 0, width-1, height-1, &black);
492 static void
493 drawMenuBevel(RImage *img)
495 RColor light, dark, mid;
496 int i;
497 int iheight = img->height / 4;
499 light.alpha = 0;
500 light.red = light.green = light.blue = 80;
502 dark.alpha = 255;
503 dark.red = dark.green = dark.blue = 0;
505 mid.alpha = 0;
506 mid.red = mid.green = mid.blue = 40;
508 for (i = 1; i < 4; i++) {
509 ROperateLine(img, RSubtractOperation, 0, i*iheight-2,
510 img->width-1, i*iheight-2, &mid);
512 RDrawLine(img, 0, i*iheight-1, img->width-1, i*iheight-1, &dark);
514 ROperateLine(img, RAddOperation, 1, i*iheight,
515 img->width-2, i*iheight, &light);
520 static Pixmap
521 renderTexture(WMScreen *scr, proplist_t texture, int width, int height,
522 char *path, int border)
524 char *type;
525 RImage *image = NULL;
526 Pixmap pixmap;
527 RContext *rc = WMScreenRContext(scr);
528 char *str;
529 RColor rcolor;
532 type = PLGetString(PLGetArrayElement(texture, 0));
534 if (strcasecmp(type, "solid")==0) {
536 str = PLGetString(PLGetArrayElement(texture, 1));
538 str2rcolor(rc, str, &rcolor);
540 image = RCreateImage(width, height, False);
541 RClearImage(image, &rcolor);
542 } else if (strcasecmp(type, "igradient")==0) {
543 int t1, t2;
544 RColor c1[2], c2[2];
546 str = PLGetString(PLGetArrayElement(texture, 1));
547 str2rcolor(rc, str, &c1[0]);
548 str = PLGetString(PLGetArrayElement(texture, 2));
549 str2rcolor(rc, str, &c1[1]);
550 str = PLGetString(PLGetArrayElement(texture, 3));
551 t1 = atoi(str);
553 str = PLGetString(PLGetArrayElement(texture, 4));
554 str2rcolor(rc, str, &c2[0]);
555 str = PLGetString(PLGetArrayElement(texture, 5));
556 str2rcolor(rc, str, &c2[1]);
557 str = PLGetString(PLGetArrayElement(texture, 6));
558 t2 = atoi(str);
560 image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2);
561 } else if (strcasecmp(&type[1], "gradient")==0) {
562 int style;
563 RColor rcolor2;
565 switch (toupper(type[0])) {
566 case 'V':
567 style = RVerticalGradient;
568 break;
569 case 'H':
570 style = RHorizontalGradient;
571 break;
572 default:
573 case 'D':
574 style = RDiagonalGradient;
575 break;
578 str = PLGetString(PLGetArrayElement(texture, 1));
579 str2rcolor(rc, str, &rcolor);
580 str = PLGetString(PLGetArrayElement(texture, 2));
581 str2rcolor(rc, str, &rcolor2);
583 image = RRenderGradient(width, height, &rcolor, &rcolor2, style);
584 } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='T') {
585 int style;
586 RColor rcolor2;
587 int i;
588 RImage *grad, *timage;
589 char *path;
591 switch (toupper(type[1])) {
592 case 'V':
593 style = RVerticalGradient;
594 break;
595 case 'H':
596 style = RHorizontalGradient;
597 break;
598 default:
599 case 'D':
600 style = RDiagonalGradient;
601 break;
604 str = PLGetString(PLGetArrayElement(texture, 3));
605 str2rcolor(rc, str, &rcolor);
606 str = PLGetString(PLGetArrayElement(texture, 4));
607 str2rcolor(rc, str, &rcolor2);
609 str = PLGetString(PLGetArrayElement(texture, 1));
611 if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL)
612 timage = RLoadImage(rc, path, 0);
614 if (!path || !timage) {
615 wwarning("could not load file '%s': %s", path,
616 RMessageForError(RErrorCode));
617 } else {
618 grad = RRenderGradient(width, height, &rcolor, &rcolor2, style);
620 image = RMakeTiledImage(timage, width, height);
621 RReleaseImage(timage);
623 i = atoi(PLGetString(PLGetArrayElement(texture, 2)));
625 RCombineImagesWithOpaqueness(image, grad, i);
626 RReleaseImage(grad);
628 } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='M') {
629 int style;
630 RColor **colors;
631 int i, j;
633 switch (toupper(type[1])) {
634 case 'V':
635 style = RVerticalGradient;
636 break;
637 case 'H':
638 style = RHorizontalGradient;
639 break;
640 default:
641 case 'D':
642 style = RDiagonalGradient;
643 break;
646 j = PLGetNumberOfElements(texture);
648 if (j > 0) {
649 colors = wmalloc(j * sizeof(RColor*));
651 for (i = 2; i < j; i++) {
652 str = PLGetString(PLGetArrayElement(texture, i));
653 colors[i-2] = wmalloc(sizeof(RColor));
654 str2rcolor(rc, str, colors[i-2]);
656 colors[i-2] = NULL;
658 image = RRenderMultiGradient(width, height, colors, style);
660 for (i = 0; colors[i]!=NULL; i++)
661 wfree(colors[i]);
662 wfree(colors);
664 } else if (strcasecmp(&type[1], "pixmap")==0) {
665 RImage *timage = NULL;
666 char *path;
667 RColor color;
669 str = PLGetString(PLGetArrayElement(texture, 1));
671 if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL)
672 timage = RLoadImage(rc, path, 0);
674 if (!path || !timage) {
675 wwarning("could not load file '%s': %s", path ? path : str,
676 RMessageForError(RErrorCode));
677 } else {
678 str = PLGetString(PLGetArrayElement(texture, 2));
679 str2rcolor(rc, str, &color);
681 switch (toupper(type[0])) {
682 case 'T':
683 image = RMakeTiledImage(timage, width, height);
684 RReleaseImage(timage);
685 timage = image;
686 break;
687 case 'C':
688 image = RMakeCenteredImage(timage, width, height, &color);
689 RReleaseImage(timage);
690 timage = image;
691 break;
692 case 'S':
693 case 'M':
694 image = RScaleImage(timage, width, height);
695 RReleaseImage(timage);
696 timage = image;
697 break;
701 wfree(path);
704 if (!image)
705 return None;
707 if (path) {
708 dumpRImage(path, image);
711 if (border < 0) {
712 if (border == RESIZEBAR_BEVEL) {
713 drawResizebarBevel(image);
714 } else if (border == MENU_BEVEL) {
715 drawMenuBevel(image);
716 RBevelImage(image, RBEV_RAISED2);
718 } else if (border) {
719 RBevelImage(image, border);
722 RConvertImage(rc, image, &pixmap);
723 RReleaseImage(image);
725 return pixmap;
729 static Pixmap
730 renderMenu(_Panel *panel, proplist_t texture, int width, int iheight)
732 WMScreen *scr = WMWidgetScreen(panel->parent);
733 Display *dpy = WMScreenDisplay(scr);
734 Pixmap pix, tmp;
735 GC gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
736 int i;
738 switch (panel->menuStyle) {
739 case MSTYLE_NORMAL:
740 tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
742 pix = XCreatePixmap(dpy, tmp, width, iheight*4, WMScreenDepth(scr));
743 for (i = 0; i < 4; i++) {
744 XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight*i);
746 XFreePixmap(dpy, tmp);
747 break;
748 case MSTYLE_SINGLE:
749 pix = renderTexture(scr, texture, width, iheight*4, NULL, MENU_BEVEL);
750 break;
751 case MSTYLE_FLAT:
752 pix = renderTexture(scr, texture, width, iheight*4, NULL, RBEV_RAISED2);
753 break;
755 XFreeGC(dpy, gc);
757 return pix;
761 static void
762 renderPreview(_Panel *panel, GC gc, int part, int relief)
764 WMListItem *item;
765 TextureListItem *titem;
766 Pixmap pix;
767 WMScreen *scr = WMWidgetScreen(panel->box);
769 item = WMGetListItem(panel->texLs, panel->textureIndex[part]);
770 titem = (TextureListItem*)item->clientData;
772 pix = renderTexture(scr, titem->prop,
773 previewPositions[part].size.width,
774 previewPositions[part].size.height,
775 NULL, relief);
777 XCopyArea(WMScreenDisplay(scr), pix, panel->preview, gc, 0, 0,
778 previewPositions[part].size.width,
779 previewPositions[part].size.height,
780 previewPositions[part].pos.x,
781 previewPositions[part].pos.y);
783 XFreePixmap(WMScreenDisplay(scr), pix);
787 static void
788 updatePreviewBox(_Panel *panel, int elements)
790 WMScreen *scr = WMWidgetScreen(panel->parent);
791 Display *dpy = WMScreenDisplay(scr);
792 /* RContext *rc = WMScreenRContext(scr);*/
793 int refresh = 0;
794 Pixmap pix;
795 GC gc;
796 int colorUpdate = 0;
797 WMColor *black = WMBlackColor(scr);
799 gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
802 if (panel->preview == None) {
803 WMColor *color;
805 panel->preview = XCreatePixmap(dpy, WMWidgetXID(panel->parent),
806 240-4, 215-4, WMScreenDepth(scr));
808 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
809 XFillRectangle(dpy, panel->preview, WMColorGC(color),
810 0, 0, 240-4, 215-4);
811 WMReleaseColor(color);
813 refresh = -1;
817 if (elements & (1<<PFOCUSED)) {
818 renderPreview(panel, gc, PFOCUSED, RBEV_RAISED2);
819 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
820 previewPositions[PFOCUSED].pos.x-1,
821 previewPositions[PFOCUSED].pos.y-1,
822 previewPositions[PFOCUSED].size.width,
823 previewPositions[PFOCUSED].size.height);
824 colorUpdate |= FTITLE_COL;
826 if (elements & (1<<PUNFOCUSED)) {
827 renderPreview(panel, gc, PUNFOCUSED, RBEV_RAISED2);
828 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
829 previewPositions[PUNFOCUSED].pos.x-1,
830 previewPositions[PUNFOCUSED].pos.y-1,
831 previewPositions[PUNFOCUSED].size.width,
832 previewPositions[PUNFOCUSED].size.height);
833 colorUpdate |= UTITLE_COL;
835 if (elements & (1<<POWNER)) {
836 renderPreview(panel, gc, POWNER, RBEV_RAISED2);
837 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
838 previewPositions[POWNER].pos.x-1,
839 previewPositions[POWNER].pos.y-1,
840 previewPositions[POWNER].size.width,
841 previewPositions[POWNER].size.height);
842 colorUpdate |= OTITLE_COL;
844 if (elements & (1<<PRESIZEBAR)) {
845 renderPreview(panel, gc, PRESIZEBAR, RESIZEBAR_BEVEL);
847 if (elements & (1<<PMTITLE)) {
848 renderPreview(panel, gc, PMTITLE, RBEV_RAISED2);
849 colorUpdate |= MTITLE_COL;
851 if (elements & (1<<PMITEM)) {
852 WMListItem *item;
853 TextureListItem *titem;
855 item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
856 titem = (TextureListItem*)item->clientData;
858 pix = renderMenu(panel, titem->prop,
859 previewPositions[PMITEM].size.width,
860 previewPositions[PMITEM].size.height/4);
862 XCopyArea(dpy, pix, panel->preview, gc, 0, 0,
863 previewPositions[PMITEM].size.width,
864 previewPositions[PMITEM].size.height,
865 previewPositions[PMITEM].pos.x,
866 previewPositions[PMITEM].pos.y);
868 XFreePixmap(dpy, pix);
870 colorUpdate |= MITEM_COL|MDISAB_COL|MHIGH_COL|MHIGHT_COL;
872 if (elements & (1<<PMITEM|1<<PMTITLE)) {
873 XDrawLine(dpy, panel->preview, gc, 29, 120, 29, 120+20*4+20);
874 XDrawLine(dpy, panel->preview, gc, 29, 119, 119, 119);
876 if (elements & (1<<PICON)) {
877 WMListItem *item;
878 TextureListItem *titem;
880 item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
881 titem = (TextureListItem*)item->clientData;
883 renderPreview(panel, gc, PICON,
884 titem->ispixmap ? 0 : RBEV_RAISED3);
886 colorUpdate |= ICONT_COL|ICONB_COL|CLIP_COL|CCLIP_COL;
888 if (refresh < 0) {
889 WMPixmap *p;
891 p = WMCreatePixmapFromXPixmaps(scr, panel->preview, None,
892 240-4, 215-4, WMScreenDepth(scr));
894 WMSetLabelImage(panel->prevL, p);
895 WMReleasePixmap(p);
897 if (colorUpdate)
898 updateColorPreviewBox(panel, colorUpdate);
899 } else {
900 if (colorUpdate)
901 updateColorPreviewBox(panel, colorUpdate);
902 else
903 WMRedisplayWidget(panel->prevL);
906 XFreeGC(dpy, gc);
907 WMReleaseColor(black);
913 static void
914 cancelNewTexture(void *data)
916 _Panel *panel = (_Panel*)data;
918 HideTexturePanel(panel->texturePanel);
924 static char*
925 makeFileName(char *prefix)
927 char *fname;
929 fname = wstrdup(prefix);
931 while (access(fname, F_OK)==0) {
932 char buf[30];
934 wfree(fname);
935 sprintf(buf, "%08lx.cache", time(NULL));
936 fname = wstrconcat(prefix, buf);
939 return fname;
945 static void
946 okNewTexture(void *data)
948 _Panel *panel = (_Panel*)data;
949 WMListItem *item;
950 char *name;
951 char *str;
952 proplist_t prop;
953 TextureListItem *titem;
954 WMScreen *scr = WMWidgetScreen(panel->parent);
956 titem = wmalloc(sizeof(TextureListItem));
957 memset(titem, 0, sizeof(TextureListItem));
959 HideTexturePanel(panel->texturePanel);
961 name = GetTexturePanelTextureName(panel->texturePanel);
963 prop = GetTexturePanelTexture(panel->texturePanel);
965 str = PLGetDescription(prop);
967 titem->title = name;
968 titem->prop = prop;
969 titem->texture = str;
970 titem->selectedFor = 0;
972 titem->ispixmap = isPixmap(prop);
974 titem->path = makeFileName(panel->fprefix);
975 titem->preview = renderTexture(scr, prop, TEXPREV_WIDTH, TEXPREV_HEIGHT,
976 titem->path, 0);
978 item = WMAddListItem(panel->texLs, "");
979 item->clientData = titem;
981 WMSetListPosition(panel->texLs, WMGetListNumberOfRows(panel->texLs));
985 static void
986 okEditTexture(void *data)
988 _Panel *panel = (_Panel*)data;
989 WMListItem *item;
990 char *name;
991 char *str;
992 proplist_t prop;
993 TextureListItem *titem;
995 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
996 titem = (TextureListItem*)item->clientData;
998 HideTexturePanel(panel->texturePanel);
1000 if (titem->current) {
1001 name = GetTexturePanelTextureName(panel->texturePanel);
1003 wfree(titem->title);
1004 titem->title = name;
1007 prop = GetTexturePanelTexture(panel->texturePanel);
1009 str = PLGetDescription(prop);
1011 PLRelease(titem->prop);
1012 titem->prop = prop;
1014 titem->ispixmap = isPixmap(prop);
1016 wfree(titem->texture);
1017 titem->texture = str;
1019 XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel->texLs)), titem->preview);
1020 titem->preview = renderTexture(WMWidgetScreen(panel->texLs), titem->prop,
1021 TEXPREV_WIDTH, TEXPREV_HEIGHT,
1022 titem->path, 0);
1024 WMRedisplayWidget(panel->texLs);
1026 if (titem->selectedFor)
1027 updatePreviewBox(panel, titem->selectedFor);
1029 changePage(panel->secP, panel);
1034 static void
1035 editTexture(WMWidget *w, void *data)
1037 _Panel *panel = (_Panel*)data;
1038 WMListItem *item;
1039 TextureListItem *titem;
1041 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
1042 titem = (TextureListItem*)item->clientData;
1044 SetTexturePanelPixmapPath(panel->texturePanel,
1045 GetObjectForKey("PixmapPath"));
1047 SetTexturePanelTexture(panel->texturePanel, titem->title, titem->prop);
1049 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
1050 SetTexturePanelOkAction(panel->texturePanel, okEditTexture, panel);
1052 ShowTexturePanel(panel->texturePanel);
1057 static void
1058 newTexture(WMWidget *w, void *data)
1060 _Panel *panel = (_Panel*)data;
1062 SetTexturePanelPixmapPath(panel->texturePanel,
1063 GetObjectForKey("PixmapPath"));
1065 SetTexturePanelTexture(panel->texturePanel, "New Texture", NULL);
1067 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
1069 SetTexturePanelOkAction(panel->texturePanel, okNewTexture, panel);
1071 ShowTexturePanel(panel->texturePanel);
1076 static void
1077 deleteTexture(WMWidget *w, void *data)
1079 _Panel *panel = (_Panel*)data;
1080 WMListItem *item;
1081 TextureListItem *titem;
1082 int row;
1083 int section;
1085 section = WMGetPopUpButtonSelectedItem(panel->secP);
1086 row = WMGetListSelectedItemRow(panel->texLs);
1087 item = WMGetListItem(panel->texLs, row);
1088 titem = (TextureListItem*)item->clientData;
1090 if (titem->selectedFor & (1 << section)) {
1091 TextureListItem *titem2;
1093 panel->textureIndex[section] = section;
1094 item = WMGetListItem(panel->texLs, section);
1095 titem2 = (TextureListItem*)item->clientData;
1096 titem2->selectedFor |= 1 << section;
1099 wfree(titem->title);
1100 wfree(titem->texture);
1101 PLRelease(titem->prop);
1102 if (titem->path) {
1103 if (remove(titem->path) < 0 && errno != ENOENT) {
1104 wsyserror("could not remove file %s", titem->path);
1106 wfree(titem->path);
1109 wfree(titem);
1111 WMRemoveListItem(panel->texLs, row);
1112 WMSetButtonEnabled(panel->delB, False);
1118 static void
1119 extractTexture(WMWidget *w, void *data)
1121 _Panel *panel = (_Panel*)data;
1122 char *path;
1123 WMOpenPanel *opanel;
1124 WMScreen *scr = WMWidgetScreen(w);
1126 opanel = WMGetOpenPanel(scr);
1127 WMSetFilePanelCanChooseDirectories(opanel, False);
1128 WMSetFilePanelCanChooseFiles(opanel, True);
1130 if (WMRunModalFilePanelForDirectory(opanel, panel->parent, wgethomedir(),
1131 _("Select File"), NULL)) {
1132 path = WMGetFilePanelFileName(opanel);
1134 OpenExtractPanelFor(panel, path);
1136 wfree(path);
1141 static void
1142 changePage(WMWidget *w, void *data)
1144 _Panel *panel = (_Panel*)data;
1145 int section;
1146 WMListItem *item;
1147 TextureListItem *titem;
1148 WMScreen *scr = WMWidgetScreen(panel->box);
1149 RContext *rc = WMScreenRContext(scr);
1150 static WMPoint positions[] = {
1151 {5, 10},
1152 {5, 40},
1153 {5, 70},
1154 {5, 100},
1155 {5, 120},
1156 {5, 160},
1157 {130, 150}
1160 if (w) {
1161 section = WMGetPopUpButtonSelectedItem(panel->secP);
1163 WMSelectListItem(panel->texLs, panel->textureIndex[section]);
1165 WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2);
1167 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
1169 titem = (TextureListItem*)item->clientData;
1172 WMColor *color;
1174 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
1175 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
1176 positions[panel->oldsection].x,
1177 positions[panel->oldsection].y, 22, 22);
1178 WMReleaseColor(color);
1180 if (w) {
1181 panel->oldsection = section;
1182 WMDrawPixmap(panel->hand, panel->preview, positions[section].x,
1183 positions[section].y);
1185 WMRedisplayWidget(panel->prevL);
1190 static void
1191 previewClick(XEvent *event, void *clientData)
1193 _Panel *panel = (_Panel*)clientData;
1194 int i;
1196 switch (panel->oldTabItem) {
1197 case 0:
1198 for (i = 0; i < sizeof(previewPositions)/sizeof(WMRect); i++) {
1199 if (event->xbutton.x >= previewPositions[i].pos.x
1200 && event->xbutton.y >= previewPositions[i].pos.y
1201 && event->xbutton.x < previewPositions[i].pos.x
1202 + previewPositions[i].size.width
1203 && event->xbutton.y < previewPositions[i].pos.y
1204 + previewPositions[i].size.height) {
1206 WMSetPopUpButtonSelectedItem(panel->secP, i);
1207 changePage(panel->secP, panel);
1208 return;
1211 break;
1212 case 1:
1213 for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->colP); i++) {
1214 if (event->xbutton.x >= previewColorPositions[i].pos.x
1215 && event->xbutton.y >= previewColorPositions[i].pos.y
1216 && event->xbutton.x < previewColorPositions[i].pos.x
1217 + previewColorPositions[i].size.width
1218 && event->xbutton.y < previewColorPositions[i].pos.y
1219 + previewColorPositions[i].size.height) {
1221 /* yuck kluge */
1222 if (i == 7)
1223 i = 4;
1225 WMSetPopUpButtonSelectedItem(panel->colP, i);
1226 changeColorPage(panel->colP, panel);
1227 return;
1230 break;
1235 static void
1236 textureClick(WMWidget *w, void *data)
1238 _Panel *panel = (_Panel*)data;
1239 int i;
1240 WMListItem *item;
1241 TextureListItem *titem;
1243 i = WMGetListSelectedItemRow(panel->texLs);
1245 item = WMGetListItem(panel->texLs, i);
1247 titem = (TextureListItem*)item->clientData;
1249 if (titem->current) {
1250 WMSetButtonEnabled(panel->delB, False);
1251 } else {
1252 WMSetButtonEnabled(panel->delB, True);
1258 static void
1259 textureDoubleClick(WMWidget *w, void *data)
1261 _Panel *panel = (_Panel*)data;
1262 int i, section;
1263 WMListItem *item;
1264 TextureListItem *titem;
1266 /* unselect old texture */
1267 section = WMGetPopUpButtonSelectedItem(panel->secP);
1269 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
1270 titem = (TextureListItem*)item->clientData;
1271 titem->selectedFor &= ~(1 << section);
1273 /* select new texture */
1274 i = WMGetListSelectedItemRow(panel->texLs);
1276 item = WMGetListItem(panel->texLs, i);
1278 titem = (TextureListItem*)item->clientData;
1280 titem->selectedFor |= 1<<section;
1282 panel->textureIndex[section] = i;
1284 WMRedisplayWidget(panel->texLs);
1286 updatePreviewBox(panel, 1<<section);
1291 static void
1292 paintListItem(WMList *lPtr, int index, Drawable d, char *text, int state,
1293 WMRect *rect)
1295 _Panel *panel = (_Panel*)WMGetHangedData(lPtr);
1296 WMScreen *scr = WMWidgetScreen(lPtr);
1297 int width, height, x, y;
1298 Display *dpy = WMScreenDisplay(scr);
1299 WMColor *white = WMWhiteColor(scr);
1300 WMListItem *item;
1301 WMColor *black = WMBlackColor(scr);
1302 TextureListItem *titem;
1304 item = WMGetListItem(lPtr, index);
1305 titem = (TextureListItem*)item->clientData;
1306 if (!titem) {
1307 WMReleaseColor(white);
1308 WMReleaseColor(black);
1309 return;
1312 width = rect->size.width;
1313 height = rect->size.height;
1314 x = rect->pos.x;
1315 y = rect->pos.y;
1317 if (state & WLDSSelected)
1318 XFillRectangle(dpy, d, WMColorGC(white), x, y, width, height);
1319 else
1320 XClearArea(dpy, d, x, y, width, height, False);
1323 if (titem->preview)
1324 XCopyArea(dpy, titem->preview, d, WMColorGC(black), 0, 0,
1325 TEXPREV_WIDTH, TEXPREV_HEIGHT, x + 5, y + 5);
1327 if ((1 << WMGetPopUpButtonSelectedItem(panel->secP)) & titem->selectedFor)
1328 WMDrawPixmap(panel->onLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1329 else if (titem->selectedFor)
1330 WMDrawPixmap(panel->offLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1332 WMDrawString(scr, d, WMColorGC(black), panel->boldFont,
1333 x + TEXPREV_WIDTH + 22, y + 2, titem->title,
1334 strlen(titem->title));
1336 WMDrawString(scr, d, WMColorGC(black), panel->smallFont,
1337 x + TEXPREV_WIDTH + 14, y + 18, titem->texture,
1338 strlen(titem->texture));
1341 WMReleaseColor(white);
1342 WMReleaseColor(black);
1347 static Pixmap
1348 loadRImage(WMScreen *scr, char *path)
1350 FILE *f;
1351 RImage *image;
1352 int w, h, d;
1353 Pixmap pixmap;
1355 f = fopen(path, "r");
1356 if (!f)
1357 return None;
1359 fscanf(f, "%02x%02x%1x", &w, &h, &d);
1361 image = RCreateImage(w, h, d == 4);
1362 fread(image->data, 1, w*h*d, f);
1363 fclose(f);
1365 RConvertImage(WMScreenRContext(scr), image, &pixmap);
1366 RReleaseImage(image);
1368 return pixmap;
1373 static void
1374 fillTextureList(WMList *lPtr)
1376 proplist_t textureList;
1377 proplist_t texture;
1378 WMUserDefaults *udb = WMGetStandardUserDefaults();
1379 TextureListItem *titem;
1380 WMScreen *scr = WMWidgetScreen(lPtr);
1381 int i;
1383 textureList = WMGetUDObjectForKey(udb, "TextureList");
1384 if (!textureList)
1385 return;
1387 for (i = 0; i < PLGetNumberOfElements(textureList); i++) {
1388 WMListItem *item;
1390 texture = PLGetArrayElement(textureList, i);
1392 titem = wmalloc(sizeof(TextureListItem));
1393 memset(titem, 0, sizeof(TextureListItem));
1395 titem->title = wstrdup(PLGetString(PLGetArrayElement(texture, 0)));
1396 titem->prop = PLRetain(PLGetArrayElement(texture, 1));
1397 titem->texture = PLGetDescription(titem->prop);
1398 titem->selectedFor = 0;
1399 titem->path = wstrdup(PLGetString(PLGetArrayElement(texture, 2)));
1401 titem->preview = loadRImage(scr, titem->path);
1402 if (!titem->preview) {
1403 titem->preview = renderTexture(scr, titem->prop, TEXPREV_WIDTH,
1404 TEXPREV_HEIGHT, NULL, 0);
1406 item = WMAddListItem(lPtr, "");
1407 item->clientData = titem;
1412 static void
1413 fillColorList(_Panel *panel)
1415 WMColor *color;
1416 proplist_t list;
1417 WMUserDefaults *udb = WMGetStandardUserDefaults();
1418 WMScreen *scr = WMWidgetScreen(panel->box);
1419 int i;
1421 list = WMGetUDObjectForKey(udb, "ColorList");
1422 if (!list) {
1423 for (i = 0; i < 24; i++) {
1424 color = WMCreateNamedColor(scr, sampleColors[i], False);
1425 if (!color)
1426 continue;
1427 WMSetColorWellColor(panel->sampW[i], color);
1428 WMReleaseColor(color);
1430 } else {
1431 proplist_t c;
1433 for (i = 0; i < WMIN(24, PLGetNumberOfElements(list)); i++) {
1434 c = PLGetArrayElement(list, i);
1435 if (!c || !PLIsString(c))
1436 continue;
1437 color = WMCreateNamedColor(scr, PLGetString(c), False);
1438 if (!color)
1439 continue;
1440 WMSetColorWellColor(panel->sampW[i], color);
1441 WMReleaseColor(color);
1447 /*************************************************************************/
1450 static void
1451 changeColorPage(WMWidget *w, void *data)
1453 _Panel *panel = (_Panel*)data;
1454 int section;
1455 WMScreen *scr = WMWidgetScreen(panel->box);
1456 RContext *rc = WMScreenRContext(scr);
1457 static WMPoint positions[] = {
1458 {5, 10},
1459 {5, 40},
1460 {5, 70},
1461 {5, 120},
1462 {5, 140},
1463 {5, 160},
1464 {5, 180},
1465 {5, 180},
1466 {130, 140},
1467 {130, 140},
1468 {130, 140},
1469 {130, 140}
1472 if (panel->preview) {
1473 WMColor *color;
1475 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
1476 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
1477 positions[panel->oldcsection].x,
1478 positions[panel->oldcsection].y, 22, 22);
1479 WMReleaseColor(color);
1481 if (w) {
1482 section = WMGetPopUpButtonSelectedItem(panel->colP);
1484 panel->oldcsection = section;
1485 if (panel->preview)
1486 WMDrawPixmap(panel->hand, panel->preview, positions[section].x,
1487 positions[section].y);
1489 section = WMGetPopUpButtonSelectedItem(panel->colP);
1491 WMSetColorWellColor(panel->colW, panel->colors[section]);
1493 WMRedisplayWidget(panel->prevL);
1497 static void
1498 paintText(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
1499 int x, int y, int w, int h, WMAlignment align, char *text)
1501 int l = strlen(text);
1503 switch (align) {
1504 case WALeft:
1505 x += 5;
1506 break;
1507 case WARight:
1508 x += w - 5 - WMWidthOfString(font, text, l);
1509 break;
1510 default:
1511 case WACenter:
1512 x += (w - WMWidthOfString(font, text, l))/2;
1513 break;
1515 WMDrawString(scr, d, WMColorGC(color), font, x,
1516 y + (h - WMFontHeight(font))/2, text, l);
1521 static void
1522 updateColorPreviewBox(_Panel *panel, int elements)
1524 WMScreen *scr = WMWidgetScreen(panel->box);
1525 WMPixmap *pixmap;
1526 Pixmap d;
1528 pixmap = WMGetLabelImage(panel->prevL);
1529 d = WMGetPixmapXID(pixmap);
1531 if (elements & FTITLE_COL) {
1532 paintText(scr, d, panel->colors[0], panel->boldFont, 30, 10, 190, 20,
1533 panel->titleAlignment, _("Focused Window"));
1535 if (elements & UTITLE_COL) {
1536 paintText(scr, d, panel->colors[1], panel->boldFont, 30, 40, 190, 20,
1537 panel->titleAlignment, _("Unfocused Window"));
1539 if (elements & OTITLE_COL) {
1540 paintText(scr, d, panel->colors[2], panel->boldFont, 30, 70, 190, 20,
1541 panel->titleAlignment, _("Owner of Focused Window"));
1543 if (elements & MTITLE_COL) {
1544 paintText(scr, d, panel->colors[3], panel->boldFont, 30, 120, 90, 20,
1545 WALeft, _("Menu Title"));
1547 if (elements & MITEM_COL) {
1548 paintText(scr, d, panel->colors[4], panel->normalFont, 30, 140, 90, 20,
1549 WALeft, _("Normal Item"));
1550 paintText(scr, d, panel->colors[4], panel->normalFont, 30, 200, 90, 20,
1551 WALeft, _("Normal Item"));
1553 if (elements & MDISAB_COL) {
1554 paintText(scr, d, panel->colors[5], panel->normalFont, 30, 160, 90, 20,
1555 WALeft, _("Disabled Item"));
1557 if (elements & MHIGH_COL) {
1558 XFillRectangle(WMScreenDisplay(scr), d, WMColorGC(panel->colors[6]),
1559 31, 181, 87, 17);
1560 elements |= MHIGHT_COL;
1562 if (elements & MHIGHT_COL) {
1563 paintText(scr, d, panel->colors[7], panel->normalFont, 30, 180, 90, 20,
1564 WALeft, _("Highlighted"));
1567 if (elements & ICONT_COL) {
1568 WRITE(_("Focused Window"), panel->colors[8], panel->boldFont,
1569 155, 130, 64);
1571 if (elements & ICONB_COL) {
1572 WRITE(_("Focused Window"), panel->colors[9], panel->boldFont,
1573 0, 0, 30);
1575 if (elements & CLIP_COL) {
1576 WRITE(_("Focused Window"), panel->colors[10], panel->boldFont,
1577 0, 0, 30);
1579 if (elements & CCLIP_COL) {
1580 WRITE(_("Focused Window"), panel->colors[11], panel->boldFont,
1581 0, 0, 30);
1584 WMRedisplayWidget(panel->prevL);
1588 static void
1589 colorWellObserver(void *self, WMNotification *n)
1591 _Panel *panel = (_Panel*)self;
1592 int p;
1594 p = WMGetPopUpButtonSelectedItem(panel->colP);
1596 WMReleaseColor(panel->colors[p]);
1598 panel->colors[p] = WMRetainColor(WMGetColorWellColor(panel->colW));
1600 updateColorPreviewBox(panel, 1<<p);
1604 static void
1605 changedTabItem(struct WMTabViewDelegate *self, WMTabView *tabView,
1606 WMTabViewItem *item)
1608 _Panel *panel = self->data;
1609 int i;
1611 i = WMGetTabViewItemIdentifier(item);
1612 switch (i) {
1613 case 0:
1614 switch (panel->oldTabItem) {
1615 case 1:
1616 changeColorPage(NULL, panel);
1617 break;
1619 changePage(panel->secP, panel);
1620 break;
1621 case 1:
1622 switch (panel->oldTabItem) {
1623 case 0:
1624 changePage(NULL, panel);
1625 break;
1627 changeColorPage(panel->colP, panel);
1628 break;
1629 case 3:
1630 switch (panel->oldTabItem) {
1631 case 0:
1632 changePage(NULL, panel);
1633 break;
1634 case 1:
1635 changeColorPage(NULL, panel);
1636 break;
1638 break;
1641 panel->oldTabItem = i;
1645 /*************************************************************************/
1647 static void
1648 menuStyleCallback(WMWidget *self, void *data)
1650 _Panel *panel = (_Panel*)data;
1652 if (self == panel->mstyB[0]) {
1653 panel->menuStyle = MSTYLE_NORMAL;
1654 updatePreviewBox(panel, 1<<PMITEM);
1656 } else if (self == panel->mstyB[1]) {
1657 panel->menuStyle = MSTYLE_SINGLE;
1658 updatePreviewBox(panel, 1<<PMITEM);
1660 } else if (self == panel->mstyB[2]) {
1661 panel->menuStyle = MSTYLE_FLAT;
1662 updatePreviewBox(panel, 1<<PMITEM);
1667 static void
1668 titleAlignCallback(WMWidget *self, void *data)
1670 _Panel *panel = (_Panel*)data;
1672 if (self == panel->taliB[0]) {
1673 panel->titleAlignment = WALeft;
1674 updatePreviewBox(panel, 1<<PFOCUSED|1<<PUNFOCUSED|1<<POWNER);
1676 } else if (self == panel->taliB[1]) {
1677 panel->titleAlignment = WACenter;
1678 updatePreviewBox(panel, 1<<PFOCUSED|1<<PUNFOCUSED|1<<POWNER);
1680 } else if (self == panel->taliB[2]) {
1681 panel->titleAlignment = WARight;
1682 updatePreviewBox(panel, 1<<PFOCUSED|1<<PUNFOCUSED|1<<POWNER);
1687 static void
1688 createPanel(Panel *p)
1690 _Panel *panel = (_Panel*)p;
1691 WMFont *font;
1692 WMScreen *scr = WMWidgetScreen(panel->parent);
1693 WMTabViewItem *item;
1694 int i;
1695 char *tmp;
1696 Bool ok = True;
1698 panel->fprefix = wstrconcat(wusergnusteppath(), "/.AppInfo");
1700 if (access(panel->fprefix, F_OK)!=0) {
1701 if (mkdir(panel->fprefix, 0755) < 0) {
1702 wsyserror(panel->fprefix);
1703 ok = False;
1706 if (ok) {
1707 tmp = wstrconcat(panel->fprefix, "/WPrefs/");
1708 wfree(panel->fprefix);
1709 panel->fprefix = tmp;
1710 if (access(panel->fprefix, F_OK)!=0) {
1711 if (mkdir(panel->fprefix, 0755) < 0) {
1712 wsyserror(panel->fprefix);
1717 panel->smallFont = WMSystemFontOfSize(scr, 10);
1718 panel->normalFont = WMSystemFontOfSize(scr, 12);
1719 panel->boldFont = WMBoldSystemFontOfSize(scr, 12);
1721 panel->onLed = WMCreatePixmapFromXPMData(scr, blueled_xpm);
1722 panel->offLed = WMCreatePixmapFromXPMData(scr, blueled2_xpm);
1723 panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm);
1725 panel->box = WMCreateBox(panel->parent);
1726 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 0, 0);
1728 /* preview box */
1729 panel->prevL = WMCreateLabel(panel->box);
1730 WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT - 20);
1731 WMMoveWidget(panel->prevL, 15, 10);
1732 WMSetLabelRelief(panel->prevL, WRSunken);
1733 WMSetLabelImagePosition(panel->prevL, WIPImageOnly);
1735 WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask,
1736 previewClick, panel);
1739 /* tabview */
1741 tabviewDelegate.data = panel;
1743 panel->tabv = WMCreateTabView(panel->box);
1744 WMResizeWidget(panel->tabv, 245, FRAME_HEIGHT - 20);
1745 WMMoveWidget(panel->tabv, 265, 10);
1746 WMSetTabViewDelegate(panel->tabv, &tabviewDelegate);
1748 /*** texture list ***/
1750 panel->texF = WMCreateFrame(panel->box);
1751 WMSetFrameRelief(panel->texF, WRFlat);
1753 item = WMCreateTabViewItemWithIdentifier(0);
1754 WMSetTabViewItemView(item, WMWidgetView(panel->texF));
1755 WMSetTabViewItemLabel(item, _("Texture"));
1757 WMAddItemInTabView(panel->tabv, item);
1760 panel->secP = WMCreatePopUpButton(panel->texF);
1761 WMResizeWidget(panel->secP, 228, 20);
1762 WMMoveWidget(panel->secP, 7, 7);
1763 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window"));
1764 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Unfocused Windows"));
1765 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window's Owner"));
1766 WMAddPopUpButtonItem(panel->secP, _("Window Resizebar"));
1767 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
1768 WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
1769 WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
1770 /* WMAddPopUpButtonItem(panel->secP, _("Workspace Backgrounds"));
1772 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1773 WMSetPopUpButtonAction(panel->secP, changePage, panel);
1775 panel->texLs = WMCreateList(panel->texF);
1776 WMResizeWidget(panel->texLs, 165, 155);
1777 WMMoveWidget(panel->texLs, 70, 33);
1778 WMSetListUserDrawItemHeight(panel->texLs, 35);
1779 WMSetListUserDrawProc(panel->texLs, paintListItem);
1780 WMHangData(panel->texLs, panel);
1781 WMSetListAction(panel->texLs, textureClick, panel);
1782 WMSetListDoubleAction(panel->texLs, textureDoubleClick, panel);
1784 WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
1785 "for the selected item."),
1786 WMWidgetView(panel->texLs));
1788 /* command buttons */
1790 font = WMSystemFontOfSize(scr, 10);
1793 panel->newB = WMCreateCommandButton(panel->texF);
1794 WMResizeWidget(panel->newB, 57, 39);
1795 WMMoveWidget(panel->newB, 7, 33);
1796 WMSetButtonFont(panel->newB, font);
1797 WMSetButtonImagePosition(panel->newB, WIPAbove);
1798 WMSetButtonText(panel->newB, _("New"));
1799 WMSetButtonAction(panel->newB, newTexture, panel);
1800 SetButtonAlphaImage(scr, panel->newB, TNEW_FILE, NULL, NULL);
1802 WMSetBalloonTextForView(_("Create a new texture."),
1803 WMWidgetView(panel->newB));
1805 panel->ripB = WMCreateCommandButton(panel->texF);
1806 WMResizeWidget(panel->ripB, 57, 39);
1807 WMMoveWidget(panel->ripB, 7, 72);
1808 WMSetButtonFont(panel->ripB, font);
1809 WMSetButtonImagePosition(panel->ripB, WIPAbove);
1810 WMSetButtonText(panel->ripB, _("Extract..."));
1811 WMSetButtonAction(panel->ripB, extractTexture, panel);
1812 SetButtonAlphaImage(scr, panel->ripB, TEXTR_FILE, NULL, NULL);
1814 WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."),
1815 WMWidgetView(panel->ripB));
1817 WMSetButtonEnabled(panel->ripB, False);
1819 panel->editB = WMCreateCommandButton(panel->texF);
1820 WMResizeWidget(panel->editB, 57, 39);
1821 WMMoveWidget(panel->editB, 7, 111);
1822 WMSetButtonFont(panel->editB, font);
1823 WMSetButtonImagePosition(panel->editB, WIPAbove);
1824 WMSetButtonText(panel->editB, _("Edit"));
1825 SetButtonAlphaImage(scr, panel->editB, TEDIT_FILE, NULL, NULL);
1826 WMSetButtonAction(panel->editB, editTexture, panel);
1827 WMSetBalloonTextForView(_("Edit the highlighted texture."),
1828 WMWidgetView(panel->editB));
1830 panel->delB = WMCreateCommandButton(panel->texF);
1831 WMResizeWidget(panel->delB, 57, 38);
1832 WMMoveWidget(panel->delB, 7, 150);
1833 WMSetButtonFont(panel->delB, font);
1834 WMSetButtonImagePosition(panel->delB, WIPAbove);
1835 WMSetButtonText(panel->delB, _("Delete"));
1836 SetButtonAlphaImage(scr, panel->delB, TDEL_FILE, NULL, NULL);
1837 WMSetButtonEnabled(panel->delB, False);
1838 WMSetButtonAction(panel->delB, deleteTexture, panel);
1839 WMSetBalloonTextForView(_("Delete the highlighted texture."),
1840 WMWidgetView(panel->delB));
1842 WMReleaseFont(font);
1844 WMMapSubwidgets(panel->texF);
1846 /*** colors ***/
1847 panel->colF = WMCreateFrame(panel->box);
1848 WMSetFrameRelief(panel->colF, WRFlat);
1850 item = WMCreateTabViewItemWithIdentifier(1);
1851 WMSetTabViewItemView(item, WMWidgetView(panel->colF));
1852 WMSetTabViewItemLabel(item, _("Color"));
1854 WMAddItemInTabView(panel->tabv, item);
1856 panel->colP = WMCreatePopUpButton(panel->colF);
1857 WMResizeWidget(panel->colP, 228, 20);
1858 WMMoveWidget(panel->colP, 7, 7);
1859 WMAddPopUpButtonItem(panel->colP, _("Focused Window Title"));
1860 WMAddPopUpButtonItem(panel->colP, _("Unfocused Window Title"));
1861 WMAddPopUpButtonItem(panel->colP, _("Owner of Focused Window Title"));
1862 WMAddPopUpButtonItem(panel->colP, _("Menu Title"));
1863 WMAddPopUpButtonItem(panel->colP, _("Menu Item Text"));
1864 WMAddPopUpButtonItem(panel->colP, _("Disabled Menu Item Text"));
1865 WMAddPopUpButtonItem(panel->colP, _("Menu Highlight Color"));
1866 WMAddPopUpButtonItem(panel->colP, _("Highlighted Menu Text Color"));
1868 WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title"));
1869 WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title Back"));
1870 WMAddPopUpButtonItem(panel->colP, _("Clip Title"));
1871 WMAddPopUpButtonItem(panel->colP, _("Collapsed Clip Title"));
1874 WMSetPopUpButtonSelectedItem(panel->colP, 0);
1876 WMSetPopUpButtonAction(panel->colP, changeColorPage, panel);
1879 panel->colW = WMCreateColorWell(panel->colF);
1880 WMResizeWidget(panel->colW, 65, 50);
1881 WMMoveWidget(panel->colW, 30, 75);
1882 WMAddNotificationObserver(colorWellObserver, panel,
1883 WMColorWellDidChangeNotification, panel->colW);
1885 for (i = 0; i < 4; i++) {
1886 int j;
1887 for (j = 0; j < 6; j++) {
1888 panel->sampW[i+j*4] = WMCreateColorWell(panel->colF);
1889 WMResizeWidget(panel->sampW[i+j*4], 22, 22);
1890 WMMoveWidget(panel->sampW[i+j*4], 130 + i*22, 40 + j*22);
1891 WSetColorWellBordered(panel->sampW[i+j*4], False);
1895 WMMapSubwidgets(panel->colF);
1897 #ifdef unfinished
1898 /*** root bg ***/
1900 panel->bgF = WMCreateFrame(panel->box);
1901 WMSetFrameRelief(panel->bgF, WRFlat);
1903 item = WMCreateTabViewItemWithIdentifier(2);
1904 WMSetTabViewItemView(item, WMWidgetView(panel->bgF));
1905 WMSetTabViewItemLabel(item, _("Background"));
1907 WMAddItemInTabView(panel->tabv, item);
1909 panel->bgprevL = WMCreateLabel(panel->bgF);
1910 WMResizeWidget(panel->bgprevL, 230, 155);
1911 WMMoveWidget(panel->bgprevL, 5, 5);
1912 WMSetLabelRelief(panel->bgprevL, WRSunken);
1914 panel->selbgB = WMCreateCommandButton(panel->bgF);
1915 WMMoveWidget(panel->selbgB, 5, 165);
1916 WMResizeWidget(panel->selbgB, 100, 24);
1917 WMSetButtonText(panel->selbgB, _("Browse..."));
1922 WMMapSubwidgets(panel->bgF);
1923 #endif /* unfinished */
1924 /*** options ***/
1925 panel->optF = WMCreateFrame(panel->box);
1926 WMSetFrameRelief(panel->optF, WRFlat);
1928 item = WMCreateTabViewItemWithIdentifier(3);
1929 WMSetTabViewItemView(item, WMWidgetView(panel->optF));
1930 WMSetTabViewItemLabel(item, _("Options"));
1932 WMAddItemInTabView(panel->tabv, item);
1934 panel->mstyF = WMCreateFrame(panel->optF);
1935 WMResizeWidget(panel->mstyF, 215, 85);
1936 WMMoveWidget(panel->mstyF, 15, 10);
1937 WMSetFrameTitle(panel->mstyF, _("Menu Style"));
1939 for (i = 0; i < 3; i++) {
1940 WMPixmap *icon;
1941 char *path;
1943 panel->mstyB[i] = WMCreateButton(panel->mstyF, WBTOnOff);
1944 WMResizeWidget(panel->mstyB[i], 54, 54);
1945 WMMoveWidget(panel->mstyB[i], 15 + i*65, 20);
1946 WMSetButtonImagePosition(panel->mstyB[i], WIPImageOnly);
1947 WMSetButtonAction(panel->mstyB[i], menuStyleCallback, panel);
1948 switch (i) {
1949 case 0:
1950 path = LocateImage(MSTYLE1_FILE);
1951 break;
1952 case 1:
1953 path = LocateImage(MSTYLE2_FILE);
1954 break;
1955 case 2:
1956 path = LocateImage(MSTYLE3_FILE);
1957 break;
1959 if (path) {
1960 icon = WMCreatePixmapFromFile(scr, path);
1961 if (icon) {
1962 WMSetButtonImage(panel->mstyB[i], icon);
1963 WMReleasePixmap(icon);
1964 } else {
1965 wwarning(_("could not load icon file %s"), path);
1967 wfree(path);
1970 WMGroupButtons(panel->mstyB[0], panel->mstyB[1]);
1971 WMGroupButtons(panel->mstyB[0], panel->mstyB[2]);
1973 WMMapSubwidgets(panel->mstyF);
1976 panel->taliF = WMCreateFrame(panel->optF);
1977 WMResizeWidget(panel->taliF, 110, 80);
1978 WMMoveWidget(panel->taliF, 15, 100);
1979 WMSetFrameTitle(panel->taliF, _("Title Alignment"));
1981 for (i = 0; i < 3; i++) {
1982 panel->taliB[i] = WMCreateRadioButton(panel->taliF);
1983 WMSetButtonAction(panel->taliB[i], titleAlignCallback, panel);
1984 switch (i) {
1985 case 0:
1986 WMSetButtonText(panel->taliB[i], _("Left"));
1987 break;
1988 case 1:
1989 WMSetButtonText(panel->taliB[i], _("Center"));
1990 break;
1991 case 2:
1992 WMSetButtonText(panel->taliB[i], _("Right"));
1993 break;
1995 WMResizeWidget(panel->taliB[i], 90, 18);
1996 WMMoveWidget(panel->taliB[i], 10, 15 + 20*i);
1998 WMGroupButtons(panel->taliB[0], panel->taliB[1]);
1999 WMGroupButtons(panel->taliB[0], panel->taliB[2]);
2001 WMMapSubwidgets(panel->taliF);
2003 WMMapSubwidgets(panel->optF);
2005 /**/
2007 WMRealizeWidget(panel->box);
2008 WMMapSubwidgets(panel->box);
2010 WMSetPopUpButtonSelectedItem(panel->secP, 0);
2012 showData(panel);
2014 changePage(panel->secP, panel);
2016 fillTextureList(panel->texLs);
2018 fillColorList(panel);
2020 panel->texturePanel = CreateTexturePanel(panel->parent);
2025 static void
2026 setupTextureFor(WMList *list, char *key, char *defValue, char *title,
2027 int index)
2029 WMListItem *item;
2030 TextureListItem *titem;
2032 titem = wmalloc(sizeof(TextureListItem));
2033 memset(titem, 0, sizeof(TextureListItem));
2035 titem->title = wstrdup(title);
2036 titem->prop = GetObjectForKey(key);
2037 if (!titem->prop || !PLIsArray(titem->prop)) {
2038 /* Maybe also give a error message to stderr that the entry is bad? */
2039 titem->prop = PLGetProplistWithDescription(defValue);
2040 } else {
2041 PLRetain(titem->prop);
2043 titem->texture = PLGetDescription((proplist_t)titem->prop);
2044 titem->current = 1;
2045 titem->selectedFor = 1<<index;
2047 titem->ispixmap = isPixmap(titem->prop);
2049 titem->preview = renderTexture(WMWidgetScreen(list), titem->prop,
2050 TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0);
2052 item = WMAddListItem(list, "");
2053 item->clientData = titem;
2058 static void
2059 showData(_Panel *panel)
2061 int i;
2062 char *str;
2064 str = GetStringForKey("MenuStyle");
2065 if (str && strcasecmp(str, "flat")==0) {
2066 panel->menuStyle = MSTYLE_FLAT;
2067 } else if (str && strcasecmp(str, "singletexture")==0) {
2068 panel->menuStyle = MSTYLE_SINGLE;
2069 } else {
2070 panel->menuStyle = MSTYLE_NORMAL;
2073 str = GetStringForKey("TitleJustify");
2074 if (str && strcasecmp(str, "left")==0) {
2075 panel->titleAlignment = WALeft;
2076 } else if (str && strcasecmp(str, "right")==0) {
2077 panel->titleAlignment = WARight;
2078 } else {
2079 panel->titleAlignment = WACenter;
2082 for (i = 0; i < sizeof(colorOptions)/(2*sizeof(char*)); i++) {
2083 WMColor *color;
2085 str = GetStringForKey(colorOptions[i*2]);
2086 if (!str)
2087 str = colorOptions[i*2+1];
2089 if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) {
2090 color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False);
2093 panel->colors[i] = color;
2095 changeColorPage(panel->colP, panel);
2097 for (i = 0; i < sizeof(textureOptions)/(3*sizeof(char*)); i++) {
2098 setupTextureFor(panel->texLs, textureOptions[i*3],
2099 textureOptions[i*3+1], textureOptions[i*3+2], i);
2100 panel->textureIndex[i] = i;
2102 updatePreviewBox(panel, EVERYTHING);
2104 WMSetButtonSelected(panel->mstyB[panel->menuStyle], True);
2105 WMSetButtonSelected(panel->taliB[panel->titleAlignment], True);
2109 static void
2110 storeData(_Panel *panel)
2112 TextureListItem *titem;
2113 WMListItem *item;
2114 int i;
2116 for (i = 0; i < sizeof(textureOptions)/(sizeof(char*)*3); i++) {
2117 item = WMGetListItem(panel->texLs, panel->textureIndex[i]);
2118 titem = (TextureListItem*)item->clientData;
2119 SetObjectForKey(titem->prop, textureOptions[i*3]);
2122 for (i = 0; i < 8; i++) {
2123 char *str;
2125 str = WMGetColorRGBDescription(panel->colors[i]);
2127 if (str) {
2128 SetStringForKey(str, colorOptions[i*2]);
2129 wfree(str);
2133 switch (panel->menuStyle) {
2134 case MSTYLE_SINGLE:
2135 SetStringForKey("singletexture", "MenuStyle");
2136 break;
2137 case MSTYLE_FLAT:
2138 SetStringForKey("flat", "MenuStyle");
2139 break;
2140 default:
2141 case MSTYLE_NORMAL:
2142 SetStringForKey("normal", "MenuStyle");
2143 break;
2145 switch (panel->titleAlignment) {
2146 case WALeft:
2147 SetStringForKey("left", "TitleJustify");
2148 break;
2149 case WARight:
2150 SetStringForKey("right", "TitleJustify");
2151 break;
2152 default:
2153 case WACenter:
2154 SetStringForKey("center", "TitleJustify");
2155 break;
2160 static void
2161 prepareForClose(_Panel *panel)
2163 proplist_t textureList;
2164 proplist_t texture;
2165 TextureListItem *titem;
2166 WMListItem *item;
2167 WMUserDefaults *udb = WMGetStandardUserDefaults();
2168 int i;
2170 textureList = PLMakeArrayFromElements(NULL, NULL);
2172 /* store list of textures */
2173 for (i = 7; i < WMGetListNumberOfRows(panel->texLs); i++) {
2174 item = WMGetListItem(panel->texLs, i);
2175 titem = (TextureListItem*)item->clientData;
2177 texture = PLMakeArrayFromElements(PLMakeString(titem->title),
2178 PLRetain(titem->prop),
2179 PLMakeString(titem->path),
2180 NULL);
2182 PLAppendArrayElement(textureList, texture);
2185 WMSetUDObjectForKey(udb, textureList, "TextureList");
2186 PLRelease(textureList);
2188 /* store list of colors */
2189 textureList = PLMakeArrayFromElements(NULL, NULL);
2190 for (i = 0; i < 24; i++) {
2191 WMColor *color;
2192 char *str;
2194 color = WMGetColorWellColor(panel->sampW[i]);
2196 str = WMGetColorRGBDescription(color);
2197 PLAppendArrayElement(textureList, PLMakeString(str));
2198 wfree(str);
2200 WMSetUDObjectForKey(udb, textureList, "ColorList");
2201 PLRelease(textureList);
2203 WMSynchronizeUserDefaults(udb);
2208 Panel*
2209 InitAppearance(WMScreen *scr, WMWindow *win)
2211 _Panel *panel;
2213 panel = wmalloc(sizeof(_Panel));
2214 memset(panel, 0, sizeof(_Panel));
2216 panel->sectionName = _("Appearance Preferences");
2218 panel->description = _("Background texture configuration for windows,\n"
2219 "menus and icons.");
2221 panel->parent = win;
2223 panel->callbacks.createWidgets = createPanel;
2224 panel->callbacks.updateDomain = storeData;
2225 panel->callbacks.prepareForClose = prepareForClose;
2227 AddSection(panel, ICON_FILE);
2229 return panel;
2234 /****************************************************************************/
2238 typedef struct ExtractPanel {
2239 WMWindow *win;
2241 WMLabel *label;
2242 WMList *list;
2244 WMButton *closeB;
2245 WMButton *extrB;
2246 } ExtractPanel;
2250 static void
2251 OpenExtractPanelFor(_Panel *panel, char *path)
2253 ExtractPanel *epanel;
2254 WMColor *color;
2255 WMFont *font;
2256 WMScreen *scr = WMWidgetScreen(panel->parent);
2258 epanel = wmalloc(sizeof(ExtractPanel));
2259 epanel->win = WMCreatePanelWithStyleForWindow(panel->parent, "extract",
2260 WMTitledWindowMask
2261 |WMClosableWindowMask);
2262 WMResizeWidget(epanel->win, 245, 250);
2263 WMSetWindowTitle(epanel->win, _("Extract Texture"));
2265 epanel->label = WMCreateLabel(epanel->win);
2266 WMResizeWidget(epanel->label, 225, 18);
2267 WMMoveWidget(epanel->label, 10, 10);
2268 WMSetLabelTextAlignment(epanel->label, WACenter);
2269 WMSetLabelRelief(epanel->label, WRSunken);
2271 color = WMDarkGrayColor(scr);
2272 WMSetWidgetBackgroundColor(epanel->label, color);
2273 WMReleaseColor(color);
2275 color = WMWhiteColor(scr);
2276 WMSetLabelTextColor(epanel->label, color);
2277 WMReleaseColor(color);
2279 font = WMBoldSystemFontOfSize(scr, 12);
2280 WMSetLabelFont(epanel->label, font);
2281 WMReleaseFont(font);
2283 WMSetLabelText(epanel->label, _("Textures"));
2285 epanel->list = WMCreateList(epanel->win);
2286 WMResizeWidget(epanel->list, 225, 165);
2287 WMMoveWidget(epanel->list, 10, 30);
2291 epanel->closeB = WMCreateCommandButton(epanel->win);
2292 WMResizeWidget(epanel->closeB, 74, 24);
2293 WMMoveWidget(epanel->closeB, 165, 215);
2294 WMSetButtonText(epanel->closeB, _("Close"));
2296 epanel->extrB = WMCreateCommandButton(epanel->win);
2297 WMResizeWidget(epanel->extrB, 74, 24);
2298 WMMoveWidget(epanel->extrB, 80, 215);
2299 WMSetButtonText(epanel->extrB, _("Extract"));
2301 WMMapSubwidgets(epanel->win);
2304 /* take textures from file */
2308 WMRealizeWidget(epanel->win);
2310 WMMapWidget(epanel->win);