updated icons and layout for appearance section
[wmaker-crm.git] / WPrefs.app / Appearance.c
blobe88dc0edb16f1b8211b317c713b3a36f59fb626d
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;
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 /* */
71 int textureIndex[8];
73 WMFont *smallFont;
74 WMFont *normalFont;
75 WMFont *boldFont;
77 TexturePanel *texturePanel;
79 WMPixmap *onLed;
80 WMPixmap *offLed;
81 WMPixmap *hand;
83 int oldsection;
85 Pixmap preview;
87 char *fprefix;
88 } _Panel;
91 typedef struct {
92 char *title;
93 char *texture;
94 proplist_t prop;
95 Pixmap preview;
97 char *path;
99 char selectedFor;
100 unsigned current:1;
101 unsigned ispixmap:1;
102 } TextureListItem;
105 static void showData(_Panel *panel);
107 static void changePage(WMWidget *w, void *data);
109 static void OpenExtractPanelFor(_Panel *panel, char *path);
111 #define ICON_FILE "appearance"
113 #define TNEW_FILE "tnew"
114 #define TDEL_FILE "tdel"
115 #define TEDIT_FILE "tedit"
116 #define TEXTR_FILE "textr"
120 /* XPM */
121 static char * blueled_xpm[] = {
122 "8 8 17 1",
123 " c None",
124 ". c #020204",
125 "+ c #16B6FC",
126 "@ c #176AFC",
127 "# c #163AFC",
128 "$ c #72D2FC",
129 "% c #224CF4",
130 "& c #76D6FC",
131 "* c #16AAFC",
132 "= c #CEE9FC",
133 "- c #229EFC",
134 "; c #164CFC",
135 "> c #FAFEFC",
136 ", c #2482FC",
137 "' c #1652FC",
138 ") c #1E76FC",
139 "! c #1A60FC",
140 " .... ",
141 " .=>-@. ",
142 ".=>$@@'.",
143 ".=$@!;;.",
144 ".!@*+!#.",
145 ".#'*+*,.",
146 " .@)@,. ",
147 " .... "};
150 /* XPM */
151 static char *blueled2_xpm[] = {
152 /* width height num_colors chars_per_pixel */
153 " 8 8 17 1",
154 /* colors */
155 ". c None",
156 "# c #090909",
157 "a c #4b63a4",
158 "b c #011578",
159 "c c #264194",
160 "d c #04338c",
161 "e c #989dac",
162 "f c #011a7c",
163 "g c #465c9c",
164 "h c #03278a",
165 "i c #6175ac",
166 "j c #011e74",
167 "k c #043a90",
168 "l c #042f94",
169 "m c #0933a4",
170 "n c #022184",
171 "o c #012998",
172 /* pixels */
173 "..####..",
174 ".#aimn#.",
175 "#aechnf#",
176 "#gchnjf#",
177 "#jndknb#",
178 "#bjdddl#",
179 ".#nono#.",
180 "..####.."
183 /* XPM */
184 static char * hand_xpm[] = {
185 "22 21 17 1",
186 " c None",
187 ". c #030305",
188 "+ c #101010",
189 "@ c #535355",
190 "# c #7F7F7E",
191 "$ c #969697",
192 "% c #B5B5B6",
193 "& c #C5C5C6",
194 "* c #D2D2D0",
195 "= c #DCDCDC",
196 "- c #E5E5E4",
197 "; c #ECECEC",
198 "> c #767674",
199 ", c #F2F2F4",
200 "' c #676767",
201 ") c #FDFDFB",
202 "! c #323234",
203 " ",
204 " ..... ",
205 " ..#%&&$. ",
206 " .))),%.......... ",
207 " .)-)),&)))))))))$. ",
208 " .-&))))))))),,,,;;. ",
209 " .=)))))))));-=***&$. ",
210 " .=)))))))),..+..... ",
211 " +=)))))))))-&#. ",
212 " +=)))))))))-%>. ",
213 " +&)))))))))-%'. ",
214 " +$,,))))));... ",
215 " .#%%*;,)),*$>+ ",
216 " .'>$%&&&&$#@. ",
217 " .!'>#$##>'. ",
218 " ..+++++. ",
219 " ",
220 " ##@@@## ",
221 " @@@@@@@@@@@ ",
222 " >>@@@## ",
223 " "};
228 #define FTITLE (1<<0)
229 #define UTITLE (1<<1)
230 #define OTITLE (1<<2)
231 #define RESIZEBAR (1<<3)
232 #define MTITLE (1<<4)
233 #define MITEM (1<<5)
234 #define ICON (1<<6)
235 #define BACK (1<<7)
236 #define EVERYTHING 0xff
239 #define RESIZEBAR_BEVEL -1
240 #define MENU_BEVEL -2
242 #define TEXPREV_WIDTH 40
243 #define TEXPREV_HEIGHT 24
249 static void
250 str2rcolor(RContext *rc, char *name, RColor *color)
252 XColor xcolor;
254 XParseColor(rc->dpy, rc->cmap, name, &xcolor);
256 color->alpha = 255;
257 color->red = xcolor.red >> 8;
258 color->green = xcolor.green >> 8;
259 color->blue = xcolor.blue >> 8;
264 static void
265 dumpRImage(char *path, RImage *image)
267 FILE *f;
269 f = fopen(path, "w");
270 if (!f) {
271 wsyserror(path);
272 return;
274 fprintf(f, "%02x%02x%1x", image->width, image->height,
275 image->data[3]!=NULL ? 4 : 3);
277 fwrite(image->data[0], 1, image->width * image->height, f);
278 fwrite(image->data[1], 1, image->width * image->height, f);
279 fwrite(image->data[2], 1, image->width * image->height, f);
280 if (image->data[3])
281 fwrite(image->data[3], 1, image->width * image->height, f);
283 if (fclose(f) < 0) {
284 wsyserror(path);
290 static int
291 isPixmap(proplist_t prop)
293 proplist_t p;
294 char *s;
296 p = PLGetArrayElement(prop, 0);
297 s = PLGetString(p);
298 if (strcasecmp(&s[1], "pixmap")==0)
299 return 1;
300 else
301 return 0;
305 static void
306 drawResizebarBevel(RImage *img)
308 RColor light;
309 RColor dark;
310 RColor black;
311 int width = img->width;
312 int height = img->height;
313 int cwidth = 28;
315 black.alpha = 255;
316 black.red = black.green = black.blue = 0;
318 light.alpha = 0;
319 light.red = light.green = light.blue = 80;
321 dark.alpha = 0;
322 dark.red = dark.green = dark.blue = 40;
324 ROperateLine(img, RSubtractOperation, 0, 0, width-1, 0, &dark);
325 ROperateLine(img, RAddOperation, 0, 1, width-1, 1, &light);
327 ROperateLine(img, RSubtractOperation, cwidth, 2, cwidth, height-1, &dark);
328 ROperateLine(img, RAddOperation, cwidth+1, 2, cwidth+1, height-1, &light);
330 ROperateLine(img, RSubtractOperation, width-cwidth-2, 2, width-cwidth-2,
331 height-1, &dark);
332 ROperateLine(img, RAddOperation, width-cwidth-1, 2, width-cwidth-1,
333 height-1, &light);
335 RDrawLine(img, 0, height-1, width-1, height-1, &black);
336 RDrawLine(img, 0, 0, 0, height-1, &black);
337 RDrawLine(img, width-1, 0, width-1, height-1, &black);
341 static void
342 drawMenuBevel(RImage *img)
344 RColor light, dark, mid;
345 int i;
346 int iheight = img->height / 3;
348 light.alpha = 0;
349 light.red = light.green = light.blue = 80;
351 dark.alpha = 255;
352 dark.red = dark.green = dark.blue = 0;
354 mid.alpha = 0;
355 mid.red = mid.green = mid.blue = 40;
357 for (i = 1; i < 4; i++) {
358 ROperateLine(img, RSubtractOperation, 0, i*iheight-2,
359 img->width-1, i*iheight-2, &mid);
361 RDrawLine(img, 0, i*iheight-1,
362 img->width-1, i*iheight-1, &dark);
364 ROperateLine(img, RAddOperation, 0, i*iheight,
365 img->width-1, i*iheight, &light);
370 static Pixmap
371 renderTexture(WMScreen *scr, proplist_t texture, int width, int height,
372 char *path, int border)
374 char *type;
375 RImage *image;
376 Pixmap pixmap;
377 RContext *rc = WMScreenRContext(scr);
378 char *str;
379 RColor rcolor;
382 type = PLGetString(PLGetArrayElement(texture, 0));
384 image = RCreateImage(width, height, False);
386 if (strcasecmp(type, "solid")==0) {
388 str = PLGetString(PLGetArrayElement(texture, 1));
390 str2rcolor(rc, str, &rcolor);
392 RClearImage(image, &rcolor);
393 } else if (strcasecmp(&type[1], "gradient")==0) {
394 int style;
395 RColor rcolor2;
397 switch (toupper(type[0])) {
398 case 'V':
399 style = RVerticalGradient;
400 break;
401 case 'H':
402 style = RHorizontalGradient;
403 break;
404 default:
405 case 'D':
406 style = RDiagonalGradient;
407 break;
410 str = PLGetString(PLGetArrayElement(texture, 1));
411 str2rcolor(rc, str, &rcolor);
412 str = PLGetString(PLGetArrayElement(texture, 2));
413 str2rcolor(rc, str, &rcolor2);
415 image = RRenderGradient(width, height, &rcolor, &rcolor2, style);
416 } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='T') {
417 int style;
418 RColor rcolor2;
419 int i;
420 RImage *grad, *timage;
421 char *path;
423 switch (toupper(type[1])) {
424 case 'V':
425 style = RVerticalGradient;
426 break;
427 case 'H':
428 style = RHorizontalGradient;
429 break;
430 default:
431 case 'D':
432 style = RDiagonalGradient;
433 break;
436 str = PLGetString(PLGetArrayElement(texture, 3));
437 str2rcolor(rc, str, &rcolor);
438 str = PLGetString(PLGetArrayElement(texture, 4));
439 str2rcolor(rc, str, &rcolor2);
441 str = PLGetString(PLGetArrayElement(texture, 1));
443 path = wfindfileinarray(GetObjectForKey("PixmapPath"), str);
444 timage = RLoadImage(rc, path, 0);
446 if (!timage) {
447 wwarning("could not load file '%s': %s", path,
448 RMessageForError(RErrorCode));
449 } else {
450 grad = RRenderGradient(width, height, &rcolor, &rcolor2, style);
452 image = RMakeTiledImage(timage, width, height);
453 RDestroyImage(timage);
455 i = atoi(PLGetString(PLGetArrayElement(texture, 2)));
457 RCombineImagesWithOpaqueness(image, grad, i);
458 RDestroyImage(grad);
460 } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='M') {
461 int style;
462 RColor **colors;
463 int i, j;
465 switch (toupper(type[1])) {
466 case 'V':
467 style = RVerticalGradient;
468 break;
469 case 'H':
470 style = RHorizontalGradient;
471 break;
472 default:
473 case 'D':
474 style = RDiagonalGradient;
475 break;
478 j = PLGetNumberOfElements(texture);
480 if (j > 0) {
481 colors = wmalloc(j * sizeof(RColor*));
483 for (i = 2; i < j; i++) {
484 str = PLGetString(PLGetArrayElement(texture, i));
485 colors[i-2] = wmalloc(sizeof(RColor));
486 str2rcolor(rc, str, colors[i-2]);
488 colors[i-2] = NULL;
490 image = RRenderMultiGradient(width, height, colors, style);
492 for (i = 0; colors[i]!=NULL; i++)
493 free(colors[i]);
494 free(colors);
496 } else if (strcasecmp(&type[1], "pixmap")==0) {
497 RImage *timage = NULL;
498 char *path;
499 RColor color;
501 str = PLGetString(PLGetArrayElement(texture, 1));
503 path = wfindfileinarray(GetObjectForKey("PixmapPath"), str);
504 if (path)
505 timage = RLoadImage(rc, path, 0);
507 if (!timage) {
508 wwarning("could not load file '%s': %s", path ? path : str,
509 RMessageForError(RErrorCode));
510 } else {
511 str = PLGetString(PLGetArrayElement(texture, 2));
512 str2rcolor(rc, str, &color);
514 switch (toupper(type[0])) {
515 case 'T':
516 image = RMakeTiledImage(timage, width, height);
517 RDestroyImage(timage);
518 timage = image;
519 break;
520 case 'C':
521 image = RMakeCenteredImage(timage, width, height, &color);
522 RDestroyImage(timage);
523 timage = image;
524 break;
525 case 'S':
526 case 'M':
527 image = RScaleImage(timage, width, height);
528 RDestroyImage(timage);
529 timage = image;
530 break;
534 free(path);
537 if (!image)
538 return None;
540 if (path) {
541 dumpRImage(path, image);
544 if (border < 0) {
545 if (border == RESIZEBAR_BEVEL) {
546 drawResizebarBevel(image);
547 } else if (border == MENU_BEVEL) {
548 drawMenuBevel(image);
550 } else if (border) {
551 RBevelImage(image, border);
554 RConvertImage(rc, image, &pixmap);
555 RDestroyImage(image);
557 return pixmap;
561 static Pixmap
562 renderMenu(_Panel *panel, proplist_t texture, int width, int iheight)
564 WMScreen *scr = WMWidgetScreen(panel->win);
565 Display *dpy = WMScreenDisplay(scr);
566 Pixmap pix, tmp;
567 char *str;
568 GC gc = XCreateGC(dpy, WMWidgetXID(panel->win), 0, NULL);
571 str = GetStringForKey("MenuStyle");
572 if (!str || strcasecmp(str, "normal")==0) {
573 int i;
575 tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
577 pix = XCreatePixmap(dpy, tmp, width, iheight*4, WMScreenDepth(scr));
578 for (i = 0; i < 4; i++) {
579 XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight,
580 0, iheight*i);
582 XFreePixmap(dpy, tmp);
583 } else if (strcasecmp(str, "flat")==0) {
584 pix = renderTexture(scr, texture, width, iheight*4, NULL, RBEV_RAISED2);
585 } else {
586 pix = renderTexture(scr, texture, width, iheight*4, NULL, MENU_BEVEL);
589 XFreeGC(dpy, gc);
591 return pix;
595 static void
596 updatePreviewBox(_Panel *panel, int elements)
598 WMScreen *scr = WMWidgetScreen(panel->win);
599 Display *dpy = WMScreenDisplay(scr);
600 /* RContext *rc = WMScreenRContext(scr);*/
601 int refresh = 0;
602 Pixmap pix;
603 GC gc;
604 WMListItem *item;
605 TextureListItem *titem;
607 gc = XCreateGC(dpy, WMWidgetXID(panel->win), 0, NULL);
610 if (!panel->preview) {
611 WMColor *color;
613 panel->preview = XCreatePixmap(dpy, WMWidgetXID(panel->win),
614 240-4, 215-4, WMScreenDepth(scr));
616 color = WMGrayColor(scr);
617 XFillRectangle(dpy, panel->preview, WMColorGC(color),
618 0, 0, 240-4, 215-4);
619 WMReleaseColor(color);
621 refresh = -1;
624 if (elements & FTITLE) {
625 item = WMGetListItem(panel->texLs, panel->textureIndex[0]);
626 titem = (TextureListItem*)item->clientData;
628 pix = renderTexture(scr, titem->prop, 190, 20, NULL, RBEV_RAISED2);
630 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 10);
632 XFreePixmap(dpy, pix);
634 if (elements & UTITLE) {
635 item = WMGetListItem(panel->texLs, panel->textureIndex[1]);
636 titem = (TextureListItem*)item->clientData;
638 pix = renderTexture(scr, titem->prop, 190, 20, NULL, RBEV_RAISED2);
640 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 40);
642 XFreePixmap(dpy, pix);
644 if (elements & OTITLE) {
645 item = WMGetListItem(panel->texLs, panel->textureIndex[2]);
646 titem = (TextureListItem*)item->clientData;
648 pix = renderTexture(scr, titem->prop, 190, 20, NULL, RBEV_RAISED2);
650 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 70);
652 XFreePixmap(dpy, pix);
654 if (elements & RESIZEBAR) {
655 item = WMGetListItem(panel->texLs, panel->textureIndex[3]);
656 titem = (TextureListItem*)item->clientData;
658 pix = renderTexture(scr, titem->prop, 190, 9, NULL, RESIZEBAR_BEVEL);
660 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 210, 20, 30, 100);
662 XFreePixmap(dpy, pix);
664 if (elements & MTITLE) {
665 item = WMGetListItem(panel->texLs, panel->textureIndex[4]);
666 titem = (TextureListItem*)item->clientData;
668 pix = renderTexture(scr, titem->prop, 90, 20, NULL, RBEV_RAISED2);
670 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 90, 20, 30, 120);
672 XFreePixmap(dpy, pix);
674 if (elements & MITEM) {
675 item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
676 titem = (TextureListItem*)item->clientData;
678 pix = renderMenu(panel, titem->prop, 90, 18);
680 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 90, 18*4, 30, 140);
682 XFreePixmap(dpy, pix);
684 if (elements & (MITEM|MTITLE)) {
685 XDrawLine(dpy, panel->preview, gc, 29, 120, 29, 120+18*4+20);
686 XDrawLine(dpy, panel->preview, gc, 29, 119, 119, 119);
689 if (elements & ICON) {
690 item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
691 titem = (TextureListItem*)item->clientData;
693 pix = renderTexture(scr, titem->prop, 64, 64, NULL,
694 titem->ispixmap ? 0 : RBEV_RAISED3);
696 XCopyArea(dpy, pix, panel->preview, gc, 0, 0, 64, 64, 155, 130);
698 XFreePixmap(dpy, pix);
701 if (refresh < 0) {
702 WMPixmap *p;
703 p = WMCreatePixmapFromXPixmaps(scr, panel->preview, None,
704 240-4, 215-4, WMScreenDepth(scr));
706 WMSetLabelImage(panel->prevL, p);
707 WMReleasePixmap(p);
708 } else {
709 WMRedisplayWidget(panel->prevL);
712 XFreeGC(dpy, gc);
718 static void
719 cancelNewTexture(void *data)
721 _Panel *panel = (_Panel*)data;
723 HideTexturePanel(panel->texturePanel);
729 static char*
730 makeFileName(char *prefix)
732 char *fname;
734 fname = wstrdup(prefix);
736 while (access(fname, F_OK)==0) {
737 char buf[30];
739 free(fname);
740 sprintf(buf, "%08lx.cache", time(NULL));
741 fname = wstrappend(prefix, buf);
744 return fname;
750 static void
751 okNewTexture(void *data)
753 _Panel *panel = (_Panel*)data;
754 WMListItem *item;
755 char *name;
756 char *str;
757 proplist_t prop;
758 TextureListItem *titem;
759 WMScreen *scr = WMWidgetScreen(panel->win);
761 titem = wmalloc(sizeof(TextureListItem));
762 memset(titem, 0, sizeof(TextureListItem));
764 HideTexturePanel(panel->texturePanel);
766 name = GetTexturePanelTextureName(panel->texturePanel);
768 prop = GetTexturePanelTexture(panel->texturePanel);
770 str = PLGetDescription(prop);
772 titem->title = name;
773 titem->prop = prop;
774 titem->texture = str;
775 titem->selectedFor = 0;
777 titem->ispixmap = isPixmap(prop);
779 titem->path = makeFileName(panel->fprefix);
780 titem->preview = renderTexture(scr, prop, TEXPREV_WIDTH, TEXPREV_HEIGHT,
781 titem->path, 0);
783 item = WMAddListItem(panel->texLs, "");
784 item->clientData = titem;
786 WMSetListPosition(panel->texLs, WMGetListNumberOfRows(panel->texLs));
790 static void
791 okEditTexture(void *data)
793 _Panel *panel = (_Panel*)data;
794 WMListItem *item;
795 char *name;
796 char *str;
797 proplist_t prop;
798 TextureListItem *titem;
800 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
801 titem = (TextureListItem*)item->clientData;
803 HideTexturePanel(panel->texturePanel);
805 if (titem->current) {
806 name = GetTexturePanelTextureName(panel->texturePanel);
808 free(titem->title);
809 titem->title = name;
812 prop = GetTexturePanelTexture(panel->texturePanel);
814 str = PLGetDescription(prop);
816 PLRelease(titem->prop);
817 titem->prop = prop;
819 titem->ispixmap = isPixmap(prop);
821 free(titem->texture);
822 titem->texture = str;
824 XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel->texLs)), titem->preview);
825 titem->preview = renderTexture(WMWidgetScreen(panel->texLs), titem->prop,
826 TEXPREV_WIDTH, TEXPREV_HEIGHT,
827 titem->path, 0);
829 WMRedisplayWidget(panel->texLs);
831 if (titem->selectedFor)
832 updatePreviewBox(panel, titem->selectedFor);
834 changePage(panel->secP, panel);
839 static void
840 editTexture(WMWidget *w, void *data)
842 _Panel *panel = (_Panel*)data;
843 WMListItem *item;
844 TextureListItem *titem;
846 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
847 titem = (TextureListItem*)item->clientData;
849 SetTexturePanelPixmapPath(panel->texturePanel,
850 GetObjectForKey("PixmapPath"));
852 SetTexturePanelTexture(panel->texturePanel, titem->title, titem->prop);
854 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
855 SetTexturePanelOkAction(panel->texturePanel, okEditTexture, panel);
857 ShowTexturePanel(panel->texturePanel);
862 static void
863 newTexture(WMWidget *w, void *data)
865 _Panel *panel = (_Panel*)data;
867 SetTexturePanelPixmapPath(panel->texturePanel,
868 GetObjectForKey("PixmapPath"));
870 SetTexturePanelTexture(panel->texturePanel, "New Texture", NULL);
872 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
874 SetTexturePanelOkAction(panel->texturePanel, okNewTexture, panel);
876 ShowTexturePanel(panel->texturePanel);
881 static void
882 deleteTexture(WMWidget *w, void *data)
884 _Panel *panel = (_Panel*)data;
885 WMListItem *item;
886 TextureListItem *titem;
887 int row;
888 int section;
890 section = WMGetPopUpButtonSelectedItem(panel->secP);
891 row = WMGetListSelectedItemRow(panel->texLs);
892 item = WMGetListItem(panel->texLs, row);
893 titem = (TextureListItem*)item->clientData;
895 if (titem->selectedFor & (1 << section)) {
896 TextureListItem *titem2;
898 panel->textureIndex[section] = section;
899 item = WMGetListItem(panel->texLs, section);
900 titem2 = (TextureListItem*)item->clientData;
901 titem2->selectedFor |= 1 << section;
904 free(titem->title);
905 free(titem->texture);
906 PLRelease(titem->prop);
907 if (titem->path) {
908 if (remove(titem->path) < 0 && errno != ENOENT) {
909 wsyserror("could not remove file %s", titem->path);
911 free(titem->path);
914 free(titem);
916 WMRemoveListItem(panel->texLs, row);
917 WMSetButtonEnabled(panel->delB, False);
923 static void
924 extractTexture(WMWidget *w, void *data)
926 _Panel *panel = (_Panel*)data;
927 char *path;
928 WMOpenPanel *opanel;
929 WMScreen *scr = WMWidgetScreen(w);
931 opanel = WMGetOpenPanel(scr);
932 WMSetFilePanelCanChooseDirectories(opanel, False);
933 WMSetFilePanelCanChooseFiles(opanel, True);
935 if (WMRunModalFilePanelForDirectory(opanel, panel->win, wgethomedir(),
936 _("Select File"), NULL)) {
937 path = WMGetFilePanelFileName(opanel);
939 OpenExtractPanelFor(panel, path);
941 free(path);
946 static void
947 changePage(WMWidget *w, void *data)
949 _Panel *panel = (_Panel*)data;
950 int section;
951 WMListItem *item;
952 TextureListItem *titem;
953 WMScreen *scr = WMWidgetScreen(w);
954 RContext *rc = WMScreenRContext(scr);
955 static WMPoint positions[] = {
956 {5, 10},
957 {5, 40},
958 {5, 70},
959 {5, 100},
960 {5, 120},
961 {5, 160},
962 {130, 150}
965 section = WMGetPopUpButtonSelectedItem(panel->secP);
967 WMSelectListItem(panel->texLs, panel->textureIndex[section]);
969 WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2);
971 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
973 titem = (TextureListItem*)item->clientData;
976 WMColor *color;
978 color = WMGrayColor(scr);
979 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
980 positions[panel->oldsection].x,
981 positions[panel->oldsection].y, 22, 22);
982 WMReleaseColor(color);
984 panel->oldsection = section;
985 WMDrawPixmap(panel->hand, panel->preview, positions[section].x,
986 positions[section].y);
988 WMRedisplayWidget(panel->prevL);
993 static void
994 previewClick(XEvent *event, void *clientData)
996 _Panel *panel = (_Panel*)clientData;
997 int i;
998 static WMRect parts[] = {
999 {{30,10},{190, 20}},
1000 {{30,40},{190,20}},
1001 {{30,70},{190,20}},
1002 {{30,100},{190,9}},
1003 {{30,120},{90,20}},
1004 {{30,140},{90,18*4}},
1005 {{155,130},{64,64}}
1008 for (i = 0; i < 7; i++) {
1009 if (event->xbutton.x >= parts[i].pos.x
1010 && event->xbutton.y >= parts[i].pos.y
1011 && event->xbutton.x < parts[i].pos.x + parts[i].size.width
1012 && event->xbutton.y < parts[i].pos.y + parts[i].size.height) {
1014 WMSetPopUpButtonSelectedItem(panel->secP, i);
1015 changePage(panel->secP, panel);
1016 return;
1022 static void
1023 textureClick(WMWidget *w, void *data)
1025 _Panel *panel = (_Panel*)data;
1026 int i;
1027 WMListItem *item;
1028 TextureListItem *titem;
1030 i = WMGetListSelectedItemRow(panel->texLs);
1032 item = WMGetListItem(panel->texLs, i);
1034 titem = (TextureListItem*)item->clientData;
1036 if (titem->current) {
1037 WMSetButtonEnabled(panel->delB, False);
1038 } else {
1039 WMSetButtonEnabled(panel->delB, True);
1045 static void
1046 textureDoubleClick(WMWidget *w, void *data)
1048 _Panel *panel = (_Panel*)data;
1049 int i, section;
1050 WMListItem *item;
1051 TextureListItem *titem;
1053 /* unselect old texture */
1054 section = WMGetPopUpButtonSelectedItem(panel->secP);
1056 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
1057 titem = (TextureListItem*)item->clientData;
1058 titem->selectedFor &= ~(1 << section);
1060 /* select new texture */
1061 i = WMGetListSelectedItemRow(panel->texLs);
1063 item = WMGetListItem(panel->texLs, i);
1065 titem = (TextureListItem*)item->clientData;
1067 titem->selectedFor |= 1<<section;
1069 panel->textureIndex[section] = i;
1071 WMRedisplayWidget(panel->texLs);
1073 updatePreviewBox(panel, 1<<section);
1079 static void
1080 paintListItem(WMList *lPtr, int index, Drawable d, char *text, int state,
1081 WMRect *rect)
1083 _Panel *panel = (_Panel*)WMGetHangedData(lPtr);
1084 WMScreen *scr = WMWidgetScreen(lPtr);
1085 int width, height, x, y;
1086 Display *dpy = WMScreenDisplay(scr);
1087 WMColor *white = WMWhiteColor(scr);
1088 WMListItem *item;
1089 WMColor *black = WMBlackColor(scr);
1090 TextureListItem *titem;
1092 width = rect->size.width;
1093 height = rect->size.height;
1094 x = rect->pos.x;
1095 y = rect->pos.y;
1097 if (state & WLDSSelected)
1098 XFillRectangle(dpy, d, WMColorGC(white), x, y, width, height);
1099 else
1100 XClearArea(dpy, d, x, y, width, height, False);
1102 item = WMGetListItem(lPtr, index);
1103 titem = (TextureListItem*)item->clientData;
1105 if (titem->preview)
1106 XCopyArea(dpy, titem->preview, d, WMColorGC(black), 0, 0, TEXPREV_WIDTH,
1107 TEXPREV_HEIGHT, x + 5, y + 5);
1109 if ((1 << WMGetPopUpButtonSelectedItem(panel->secP)) & titem->selectedFor)
1110 WMDrawPixmap(panel->onLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1111 else if (titem->selectedFor)
1112 WMDrawPixmap(panel->offLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1114 WMDrawString(scr, d, WMColorGC(black), panel->boldFont,
1115 x + TEXPREV_WIDTH + 22, y + 2, titem->title,
1116 strlen(titem->title));
1118 WMDrawString(scr, d, WMColorGC(black), panel->smallFont,
1119 x + TEXPREV_WIDTH + 14, y + 18, titem->texture,
1120 strlen(titem->texture));
1123 WMReleaseColor(white);
1124 WMReleaseColor(black);
1129 static Pixmap
1130 loadRImage(WMScreen *scr, char *path)
1132 FILE *f;
1133 RImage *image;
1134 int w, h, d;
1135 int i;
1136 Pixmap pixmap;
1138 f = fopen(path, "r");
1139 if (!f)
1140 return None;
1142 fscanf(f, "%02x%02x%1x", &w, &h, &d);
1144 image = RCreateImage(w, h, d == 4);
1145 for (i = 0; i < d; i++) {
1146 fread(image->data[i], 1, w*h, f);
1148 fclose(f);
1150 RConvertImage(WMScreenRContext(scr), image, &pixmap);
1151 RDestroyImage(image);
1153 return pixmap;
1158 static void
1159 fillTextureList(WMList *lPtr)
1161 proplist_t textureList;
1162 proplist_t texture;
1163 WMUserDefaults *udb = WMGetStandardUserDefaults();
1164 int i;
1165 TextureListItem *titem;
1166 WMScreen *scr = WMWidgetScreen(lPtr);
1168 textureList = WMGetUDObjectForKey(udb, "TextureList");
1169 if (!textureList)
1170 return;
1172 for (i = 0; i < PLGetNumberOfElements(textureList); i++) {
1173 WMListItem *item;
1175 texture = PLGetArrayElement(textureList, i);
1177 titem = wmalloc(sizeof(TextureListItem));
1178 memset(titem, 0, sizeof(TextureListItem));
1180 titem->title = wstrdup(PLGetString(PLGetArrayElement(texture, 0)));
1181 titem->prop = PLRetain(PLGetArrayElement(texture, 1));
1182 titem->texture = PLGetDescription(titem->prop);
1183 titem->selectedFor = 0;
1184 titem->path = wstrdup(PLGetString(PLGetArrayElement(texture, 2)));
1186 titem->preview = loadRImage(scr, titem->path);
1187 if (!titem->preview) {
1188 titem->preview = renderTexture(scr, titem->prop, TEXPREV_WIDTH,
1189 TEXPREV_HEIGHT, NULL, 0);
1191 item = WMAddListItem(lPtr, "");
1192 item->clientData = titem;
1197 static void
1198 createPanel(Panel *p)
1200 _Panel *panel = (_Panel*)p;
1201 WMFont *font;
1202 WMScreen *scr = WMWidgetScreen(panel->win);
1203 WMTabViewItem *item;
1205 char *tmp;
1206 Bool ok = True;
1208 panel->fprefix = wstrappend(wusergnusteppath(), "/.AppInfo");
1210 if (access(panel->fprefix, F_OK)!=0) {
1211 if (mkdir(panel->fprefix, 0755) < 0) {
1212 wsyserror(panel->fprefix);
1213 ok = False;
1216 if (ok) {
1217 tmp = wstrappend(panel->fprefix, "/WPrefs/");
1218 free(panel->fprefix);
1219 panel->fprefix = tmp;
1220 if (access(panel->fprefix, F_OK)!=0) {
1221 if (mkdir(panel->fprefix, 0755) < 0) {
1222 wsyserror(panel->fprefix);
1227 panel->smallFont = WMSystemFontOfSize(scr, 10);
1228 panel->normalFont = WMSystemFontOfSize(scr, 12);
1229 panel->boldFont = WMBoldSystemFontOfSize(scr, 12);
1231 panel->onLed = WMCreatePixmapFromXPMData(scr, blueled_xpm);
1232 panel->offLed = WMCreatePixmapFromXPMData(scr, blueled2_xpm);
1233 panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm);
1235 panel->frame = WMCreateFrame(panel->win);
1236 WMResizeWidget(panel->frame, FRAME_WIDTH, FRAME_HEIGHT);
1237 WMMoveWidget(panel->frame, FRAME_LEFT, FRAME_TOP);
1239 /* preview box */
1240 panel->prevL = WMCreateLabel(panel->frame);
1241 WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT - 20);
1242 WMMoveWidget(panel->prevL, 15, 10);
1243 WMSetLabelRelief(panel->prevL, WRSunken);
1244 WMSetLabelImagePosition(panel->prevL, WIPImageOnly);
1246 WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask,
1247 previewClick, panel);
1250 /* tabview */
1252 panel->tabv = WMCreateTabView(panel->frame);
1253 WMResizeWidget(panel->tabv, 245, FRAME_HEIGHT - 20);
1254 WMMoveWidget(panel->tabv, 265, 10);
1256 /*** texture list ***/
1258 panel->texF = WMCreateFrame(panel->frame);
1259 WMSetFrameRelief(panel->texF, WRFlat);
1261 item = WMCreateTabViewItemWithIdentifier(0);
1262 WMSetTabViewItemView(item, WMWidgetView(panel->texF));
1263 WMSetTabViewItemLabel(item, _("Texture"));
1265 WMAddItemInTabView(panel->tabv, item);
1268 panel->secP = WMCreatePopUpButton(panel->texF);
1269 WMResizeWidget(panel->secP, 228, 20);
1270 WMMoveWidget(panel->secP, 7, 7);
1271 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1272 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window"));
1273 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Unfocused Windows"));
1274 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window's Owner"));
1275 WMAddPopUpButtonItem(panel->secP, _("Window Resizebar"));
1276 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
1277 WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
1278 WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
1279 /* WMAddPopUpButtonItem(panel->secP, _("Workspace Backgrounds"));
1281 WMSetPopUpButtonAction(panel->secP, changePage, panel);
1283 panel->texLs = WMCreateList(panel->texF);
1284 WMResizeWidget(panel->texLs, 165, 155);
1285 WMMoveWidget(panel->texLs, 70, 33);
1286 WMSetListUserDrawItemHeight(panel->texLs, 35);
1287 WMSetListUserDrawProc(panel->texLs, paintListItem);
1288 WMHangData(panel->texLs, panel);
1289 WMSetListAction(panel->texLs, textureClick, panel);
1290 WMSetListDoubleAction(panel->texLs, textureDoubleClick, panel);
1292 WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
1293 "for the selected item."),
1294 WMWidgetView(panel->texLs));
1296 /* command buttons */
1298 font = WMSystemFontOfSize(scr, 10);
1301 panel->newB = WMCreateCommandButton(panel->texF);
1302 WMResizeWidget(panel->newB, 57, 39);
1303 WMMoveWidget(panel->newB, 7, 33);
1304 WMSetButtonFont(panel->newB, font);
1305 WMSetButtonImagePosition(panel->newB, WIPAbove);
1306 WMSetButtonText(panel->newB, _("New"));
1307 WMSetButtonAction(panel->newB, newTexture, panel);
1308 SetButtonAlphaImage(scr, panel->newB, TNEW_FILE);
1310 WMSetBalloonTextForView(_("Create a new texture."),
1311 WMWidgetView(panel->newB));
1313 panel->ripB = WMCreateCommandButton(panel->texF);
1314 WMResizeWidget(panel->ripB, 57, 39);
1315 WMMoveWidget(panel->ripB, 7, 72);
1316 WMSetButtonFont(panel->ripB, font);
1317 WMSetButtonImagePosition(panel->ripB, WIPAbove);
1318 WMSetButtonText(panel->ripB, _("Extract..."));
1319 WMSetButtonAction(panel->ripB, extractTexture, panel);
1320 SetButtonAlphaImage(scr, panel->ripB, TEXTR_FILE);
1322 WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."),
1323 WMWidgetView(panel->ripB));
1325 WMSetButtonEnabled(panel->ripB, False);
1327 panel->editB = WMCreateCommandButton(panel->texF);
1328 WMResizeWidget(panel->editB, 57, 39);
1329 WMMoveWidget(panel->editB, 7, 111);
1330 WMSetButtonFont(panel->editB, font);
1331 WMSetButtonImagePosition(panel->editB, WIPAbove);
1332 WMSetButtonText(panel->editB, _("Edit"));
1333 SetButtonAlphaImage(scr, panel->editB, TEDIT_FILE);
1334 WMSetButtonAction(panel->editB, editTexture, panel);
1335 WMSetBalloonTextForView(_("Edit the highlighted texture."),
1336 WMWidgetView(panel->editB));
1338 panel->delB = WMCreateCommandButton(panel->texF);
1339 WMResizeWidget(panel->delB, 57, 38);
1340 WMMoveWidget(panel->delB, 7, 150);
1341 WMSetButtonFont(panel->delB, font);
1342 WMSetButtonImagePosition(panel->delB, WIPAbove);
1343 WMSetButtonText(panel->delB, _("Delete"));
1344 SetButtonAlphaImage(scr, panel->delB, TDEL_FILE);
1345 WMSetButtonEnabled(panel->delB, False);
1346 WMSetButtonAction(panel->delB, deleteTexture, panel);
1347 WMSetBalloonTextForView(_("Delete the highlighted texture."),
1348 WMWidgetView(panel->delB));
1350 WMReleaseFont(font);
1352 WMMapSubwidgets(panel->texF);
1354 /*** colors ***/
1355 panel->colF = WMCreateFrame(panel->frame);
1356 WMSetFrameRelief(panel->colF, WRFlat);
1358 item = WMCreateTabViewItemWithIdentifier(1);
1359 WMSetTabViewItemView(item, WMWidgetView(panel->colF));
1360 WMSetTabViewItemLabel(item, _("Color"));
1362 WMAddItemInTabView(panel->tabv, item);
1365 /**/
1367 WMRealizeWidget(panel->frame);
1368 WMMapSubwidgets(panel->frame);
1370 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1372 showData(panel);
1374 changePage(panel->secP, panel);
1376 fillTextureList(panel->texLs);
1378 panel->texturePanel = CreateTexturePanel(panel->win);
1383 static void
1384 setupTextureFor(WMList *list, char *key, char *defValue, char *title,
1385 int index)
1387 WMListItem *item;
1388 TextureListItem *titem;
1390 titem = wmalloc(sizeof(TextureListItem));
1391 memset(titem, 0, sizeof(TextureListItem));
1393 titem->title = wstrdup(title);
1394 titem->prop = GetObjectForKey(key);
1395 if (!titem->prop) {
1396 titem->prop = PLGetProplistWithDescription(defValue);
1397 } else {
1398 PLRetain(titem->prop);
1400 titem->texture = PLGetDescription((proplist_t)titem->prop);
1401 titem->current = 1;
1402 titem->selectedFor = 1<<index;
1404 titem->ispixmap = isPixmap(titem->prop);
1406 titem->preview = renderTexture(WMWidgetScreen(list), titem->prop,
1407 TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0);
1409 item = WMAddListItem(list, "");
1410 item->clientData = titem;
1415 static void
1416 showData(_Panel *panel)
1418 int i = 0;
1420 setupTextureFor(panel->texLs, "FTitleBack", "(solid, black)",
1421 "[Focused]", i);
1422 panel->textureIndex[i] = i++;
1424 setupTextureFor(panel->texLs, "UTitleBack", "(solid, gray)",
1425 "[Unfocused]", i);
1426 panel->textureIndex[i] = i++;
1428 setupTextureFor(panel->texLs, "PTitleBack", "(solid, \"#616161\")",
1429 "[Owner of Focused]", i);
1430 panel->textureIndex[i] = i++;
1432 setupTextureFor(panel->texLs, "ResizebarBack", "(solid, gray)",
1433 "[Resizebar]", i);
1434 panel->textureIndex[i] = i++;
1436 setupTextureFor(panel->texLs, "MenuTitleBack", "(solid, black)",
1437 "[Menu Title]", i);
1438 panel->textureIndex[i] = i++;
1440 setupTextureFor(panel->texLs, "MenuTextBack", "(solid, gray)",
1441 "[Menu Item]", i);
1442 panel->textureIndex[i] = i++;
1444 setupTextureFor(panel->texLs, "IconBack", "(solid, gray)", "[Icon]", i);
1445 panel->textureIndex[i] = i++;
1447 setupTextureFor(panel->texLs, "WorkspaceBack", "(solid, black)",
1448 "[Workspace]", i);
1449 panel->textureIndex[i] = i++;
1452 updatePreviewBox(panel, EVERYTHING);
1457 static void
1458 storeData(_Panel *panel)
1460 TextureListItem *titem;
1461 WMListItem *item;
1463 item = WMGetListItem(panel->texLs, panel->textureIndex[0]);
1464 titem = (TextureListItem*)item->clientData;
1465 SetObjectForKey(titem->prop, "FTitleBack");
1467 item = WMGetListItem(panel->texLs, panel->textureIndex[1]);
1468 titem = (TextureListItem*)item->clientData;
1469 SetObjectForKey(titem->prop, "UTitleBack");
1471 item = WMGetListItem(panel->texLs, panel->textureIndex[2]);
1472 titem = (TextureListItem*)item->clientData;
1473 SetObjectForKey(titem->prop, "PTitleBack");
1475 item = WMGetListItem(panel->texLs, panel->textureIndex[3]);
1476 titem = (TextureListItem*)item->clientData;
1477 SetObjectForKey(titem->prop, "ResizebarBack");
1479 item = WMGetListItem(panel->texLs, panel->textureIndex[4]);
1480 titem = (TextureListItem*)item->clientData;
1481 SetObjectForKey(titem->prop, "MenuTitleBack");
1483 item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
1484 titem = (TextureListItem*)item->clientData;
1485 SetObjectForKey(titem->prop, "MenuTextBack");
1487 item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
1488 titem = (TextureListItem*)item->clientData;
1489 SetObjectForKey(titem->prop, "IconBack");
1493 static void
1494 prepareForClose(_Panel *panel)
1496 proplist_t textureList;
1497 proplist_t texture;
1498 int i;
1499 TextureListItem *titem;
1500 WMListItem *item;
1501 WMUserDefaults *udb = WMGetStandardUserDefaults();
1503 textureList = PLMakeArrayFromElements(NULL, NULL);
1505 /* store list of textures */
1506 for (i = 7; i < WMGetListNumberOfRows(panel->texLs); i++) {
1507 item = WMGetListItem(panel->texLs, i);
1508 titem = (TextureListItem*)item->clientData;
1510 texture = PLMakeArrayFromElements(PLMakeString(titem->title),
1511 PLRetain(titem->prop),
1512 PLMakeString(titem->path),
1513 NULL);
1515 PLAppendArrayElement(textureList, texture);
1518 WMSetUDObjectForKey(udb, textureList, "TextureList");
1519 PLRelease(textureList);
1521 WMSynchronizeUserDefaults(udb);
1526 Panel*
1527 InitAppearance(WMScreen *scr, WMWindow *win)
1529 _Panel *panel;
1531 panel = wmalloc(sizeof(_Panel));
1532 memset(panel, 0, sizeof(_Panel));
1534 panel->sectionName = _("Appearance Preferences");
1536 panel->description = _("Background texture configuration for windows,\n"
1537 "menus and icons.");
1539 panel->win = win;
1541 panel->callbacks.createWidgets = createPanel;
1542 panel->callbacks.updateDomain = storeData;
1543 panel->callbacks.prepareForClose = prepareForClose;
1545 AddSection(panel, ICON_FILE);
1547 return panel;
1552 /****************************************************************************/
1556 typedef struct ExtractPanel {
1557 WMWindow *win;
1559 WMLabel *label;
1560 WMList *list;
1562 WMButton *closeB;
1563 WMButton *extrB;
1564 } ExtractPanel;
1568 static void
1569 OpenExtractPanelFor(_Panel *panel, char *path)
1571 ExtractPanel *epanel;
1572 WMColor *color;
1573 WMFont *font;
1574 WMScreen *scr = WMWidgetScreen(panel->win);
1576 epanel = wmalloc(sizeof(ExtractPanel));
1577 epanel->win = WMCreatePanelWithStyleForWindow(panel->win, "extract",
1578 WMTitledWindowMask
1579 |WMClosableWindowMask);
1580 WMResizeWidget(epanel->win, 245, 250);
1581 WMSetWindowTitle(epanel->win, _("Extract Texture"));
1583 epanel->label = WMCreateLabel(epanel->win);
1584 WMResizeWidget(epanel->label, 225, 18);
1585 WMMoveWidget(epanel->label, 10, 10);
1586 WMSetLabelTextAlignment(epanel->label, WACenter);
1587 WMSetLabelRelief(epanel->label, WRSunken);
1589 color = WMDarkGrayColor(scr);
1590 WMSetWidgetBackgroundColor(epanel->label, color);
1591 WMReleaseColor(color);
1593 color = WMWhiteColor(scr);
1594 WMSetLabelTextColor(epanel->label, color);
1595 WMReleaseColor(color);
1597 font = WMBoldSystemFontOfSize(scr, 12);
1598 WMSetLabelFont(epanel->label, font);
1599 WMReleaseFont(font);
1601 WMSetLabelText(epanel->label, _("Textures"));
1603 epanel->list = WMCreateList(epanel->win);
1604 WMResizeWidget(epanel->list, 225, 165);
1605 WMMoveWidget(epanel->list, 10, 30);
1609 epanel->closeB = WMCreateCommandButton(epanel->win);
1610 WMResizeWidget(epanel->closeB, 74, 24);
1611 WMMoveWidget(epanel->closeB, 165, 215);
1612 WMSetButtonText(epanel->closeB, _("Close"));
1614 epanel->extrB = WMCreateCommandButton(epanel->win);
1615 WMResizeWidget(epanel->extrB, 74, 24);
1616 WMMoveWidget(epanel->extrB, 80, 215);
1617 WMSetButtonText(epanel->extrB, _("Extract"));
1619 WMMapSubwidgets(epanel->win);
1622 /* take textures from file */
1626 WMRealizeWidget(epanel->win);
1628 WMMapWidget(epanel->win);