WINGs: Added 'const' attribute to function 'WMCreateHashTable'
[wmaker-crm.git] / WPrefs.app / Appearance.c
blobc9ff1820cc2fecb8f4a3926bd7f3e47122f1abca
1 /* Apperance.c- color/texture for titlebar etc.
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1999-2003 Alfredo K. Kojima
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 along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "WPrefs.h"
24 #include <unistd.h>
25 #include <errno.h>
26 #include <ctype.h>
27 #include <time.h>
28 #include <sys/stat.h>
29 #include <sys/types.h>
30 #include <fcntl.h>
32 #include "TexturePanel.h"
34 typedef struct _Panel {
35 WMBox *box;
36 char *sectionName;
38 char *description;
40 CallbackRec callbacks;
42 WMWidget *parent;
44 WMLabel *prevL;
46 WMTabView *tabv;
48 /* texture list */
49 WMFrame *texF;
50 WMList *texLs;
52 WMPopUpButton *secP;
54 WMButton *newB;
55 WMButton *editB;
56 WMButton *ripB;
57 WMButton *delB;
59 /* text color */
60 WMFrame *colF;
62 WMPopUpButton *colP;
63 WMColor *colors[14];
65 WMColorWell *colW;
67 WMColorWell *sampW[24];
69 /* options */
70 WMFrame *optF;
72 WMFrame *mstyF;
73 WMButton *mstyB[3];
75 WMFrame *taliF;
76 WMButton *taliB[3];
78 /* root bg */
79 WMFrame *bgF;
81 WMLabel *bgprevL;
82 WMButton *selbgB;
84 WMPopUpButton *modeB[3];
86 /* */
88 int textureIndex[8];
90 WMFont *smallFont;
91 WMFont *normalFont;
92 WMFont *boldFont;
94 TexturePanel *texturePanel;
96 WMPixmap *onLed;
97 WMPixmap *offLed;
98 WMPixmap *hand;
100 int oldsection;
101 int oldcsection;
103 char oldTabItem;
105 int menuStyle;
107 int titleAlignment;
109 Pixmap preview;
110 Pixmap previewNoText;
112 char *fprefix;
113 } _Panel;
115 typedef struct {
116 char *title;
117 char *texture;
118 WMPropList *prop;
119 Pixmap preview;
121 char *path;
123 char selectedFor;
124 unsigned current:1;
125 unsigned ispixmap:1;
126 } TextureListItem;
128 static void updateColorPreviewBox(_Panel * panel, int elements);
130 static void showData(_Panel * panel);
132 static void changePage(WMWidget * w, void *data);
134 static void changeColorPage(WMWidget * w, void *data);
136 static void OpenExtractPanelFor(_Panel *panel);
138 static void changedTabItem(struct WMTabViewDelegate *self, WMTabView * tabView, WMTabViewItem * item);
140 static WMTabViewDelegate tabviewDelegate = {
141 NULL,
142 NULL, /* didChangeNumberOfItems */
143 changedTabItem, /* didSelectItem */
144 NULL, /* shouldSelectItem */
145 NULL /* willSelectItem */
148 #define ICON_FILE "appearance"
150 #define TNEW_FILE "tnew"
151 #define TDEL_FILE "tdel"
152 #define TEDIT_FILE "tedit"
153 #define TEXTR_FILE "textr"
155 #define MSTYLE1_FILE "msty1"
156 #define MSTYLE2_FILE "msty2"
157 #define MSTYLE3_FILE "msty3"
159 /* XPM */
160 static char *blueled_xpm[] = {
161 "8 8 17 1",
162 " c None",
163 ". c #020204",
164 "+ c #16B6FC",
165 "@ c #176AFC",
166 "# c #163AFC",
167 "$ c #72D2FC",
168 "% c #224CF4",
169 "& c #76D6FC",
170 "* c #16AAFC",
171 "= c #CEE9FC",
172 "- c #229EFC",
173 "; c #164CFC",
174 "> c #FAFEFC",
175 ", c #2482FC",
176 "' c #1652FC",
177 ") c #1E76FC",
178 "! c #1A60FC",
179 " .... ",
180 " .=>-@. ",
181 ".=>$@@'.",
182 ".=$@!;;.",
183 ".!@*+!#.",
184 ".#'*+*,.",
185 " .@)@,. ",
186 " .... "
189 /* XPM */
190 static char *blueled2_xpm[] = {
191 /* width height num_colors chars_per_pixel */
192 " 8 8 17 1",
193 /* colors */
194 ". c None",
195 "# c #090909",
196 "a c #4b63a4",
197 "b c #011578",
198 "c c #264194",
199 "d c #04338c",
200 "e c #989dac",
201 "f c #011a7c",
202 "g c #465c9c",
203 "h c #03278a",
204 "i c #6175ac",
205 "j c #011e74",
206 "k c #043a90",
207 "l c #042f94",
208 "m c #0933a4",
209 "n c #022184",
210 "o c #012998",
211 /* pixels */
212 "..####..",
213 ".#aimn#.",
214 "#aechnf#",
215 "#gchnjf#",
216 "#jndknb#",
217 "#bjdddl#",
218 ".#nono#.",
219 "..####.."
222 /* XPM */
223 static char *hand_xpm[] = {
224 "22 21 19 1",
225 " c None",
226 ". c #030305",
227 "+ c #7F7F7E",
228 "@ c #B5B5B6",
229 "# c #C5C5C6",
230 "$ c #969697",
231 "% c #FDFDFB",
232 "& c #F2F2F4",
233 "* c #E5E5E4",
234 "= c #ECECEC",
235 "- c #DCDCDC",
236 "; c #D2D2D0",
237 "> c #101010",
238 ", c #767674",
239 "' c #676767",
240 ") c #535355",
241 "! c #323234",
242 "~ c #3E3C56",
243 "{ c #333147",
244 " ",
245 " ..... ",
246 " ..+@##$. ",
247 " .%%%&@.......... ",
248 " .%*%%&#%%%%%%%%%$. ",
249 " .*#%%%%%%%%%&&&&==. ",
250 " .-%%%%%%%%%=*-;;;#$. ",
251 " .-%%%%%%%%&..>..... ",
252 " >-%%%%%%%%%*#+. ",
253 " >-%%%%%%%%%*@,. ",
254 " >#%%%%%%%%%*@'. ",
255 " >$&&%%%%%%=... ",
256 " .+@@;=&%%&;$,> ",
257 " .',$@####$+). ",
258 " .!',+$++,'. ",
259 " ..>>>>>. ",
260 " ",
261 " ~~{{{~~ ",
262 " {{{{{{{{{{{ ",
263 " ~~{{{~~ ",
267 static char *sampleColors[] = {
268 "black",
269 "#292929",
270 "#525252",
271 "#848484",
272 "#adadad",
273 "#d6d6d6",
274 "white",
275 "#d6d68c",
276 "#d6a57b",
277 "#8cd68c",
278 "#8cd6ce",
279 "#d68c8c",
280 "#8c9cd6",
281 "#bd86d6",
282 "#d68cbd",
283 "#d64a4a",
284 "#4a5ad6",
285 "#4ad6ce",
286 "#4ad65a",
287 "#ced64a",
288 "#d6844a",
289 "#8ad631",
290 "#ce29c6",
291 "#ce2973",
292 "black"
295 static const struct {
296 const char *key;
297 const char *default_value;
298 const char *label;
299 } textureOptions[] = {
300 { "FTitleBack", "(solid, black)", N_("[Focused]") },
301 { "UTitleBack", "(solid, gray)", N_("[Unfocused]") },
302 { "PTitleBack", "(solid, \"#616161\")", N_("[Owner of Focused]") },
303 { "ResizebarBack", "(solid, gray)", N_("[Resizebar]") },
304 { "MenuTitleBack", "(solid, black)", N_("[Menu Title]") },
305 { "MenuTextBack", "(solid, gray)", N_("[Menu Item]") },
306 { "IconBack", "(solid, gray)", N_("[Icon]") }
309 #define RESIZEBAR_BEVEL -1
310 #define MENU_BEVEL -2
312 #define TEXPREV_WIDTH 40
313 #define TEXPREV_HEIGHT 24
315 #define MSTYLE_NORMAL 0
316 #define MSTYLE_SINGLE 1
317 #define MSTYLE_FLAT 2
319 #define FTITLE_COL (1<<0)
320 #define UTITLE_COL (1<<1)
321 #define OTITLE_COL (1<<2)
322 #define MTITLE_COL (1<<3)
323 #define MITEM_COL (1<<4)
324 #define MDISAB_COL (1<<5)
325 #define MHIGH_COL (1<<6)
326 #define MHIGHT_COL (1<<7)
327 #define ICONT_COL (1<<8)
328 #define ICONB_COL (1<<9)
329 #define CLIP_COL (1<<10)
330 #define CCLIP_COL (1<<11)
332 static const struct {
333 const char *key;
334 const char *default_value;
335 } colorOptions[] = {
336 { "FTitleColor", "white" },
337 { "UTitleColor", "black" },
338 { "PTitleColor", "white" },
339 { "MenuTitleColor", "white" },
340 { "MenuTextColor", "black" },
341 { "MenuDisabledColor", "#616161" },
342 { "HighlightColor", "white" },
343 { "HighlightTextColor", "black" },
344 { "IconTitleColor", "white" },
345 { "IconTitleBack", "black" },
346 { "ClipTitleColor", "black" },
347 { "CClipTitleColor", "#454045" }
350 static WMRect previewPositions[] = {
351 #define PFOCUSED 0
352 {{30, 10}, {190, 20}},
353 #define PUNFOCUSED 1
354 {{30, 40}, {190, 20}},
355 #define POWNER 2
356 {{30, 70}, {190, 20}},
357 #define PRESIZEBAR 3
358 {{30, 100}, {190, 9}},
359 #define PMTITLE 4
360 {{30, 120}, {90, 20}},
361 #define PMITEM 5
362 {{30, 140}, {90, 20 * 4}},
363 #define PICON 6
364 {{155, 130}, {64, 64}}
367 #define EVERYTHING 0xff
369 static WMRect previewColorPositions[] = {
370 {{30, 10}, {190, 20}},
371 {{30, 40}, {190, 20}},
372 {{30, 70}, {190, 20}},
373 {{30, 120}, {90, 20}},
374 {{30, 140}, {90, 20}},
375 {{30, 160}, {90, 20}},
376 {{30, 180}, {90, 20}},
377 {{30, 200}, {90, 20}},
378 {{155, 130}, {64, 64}},
379 {{155, 130}, {64, 64}},
380 {{155, 130}, {64, 64}},
381 {{155, 130}, {64, 64}}
384 static void str2rcolor(RContext * rc, const char *name, RColor * color)
386 XColor xcolor;
388 XParseColor(rc->dpy, rc->cmap, name, &xcolor);
390 color->alpha = 255;
391 color->red = xcolor.red >> 8;
392 color->green = xcolor.green >> 8;
393 color->blue = xcolor.blue >> 8;
396 static void dumpRImage(const char *path, RImage * image)
398 FILE *f;
399 int channels = (image->format == RRGBAFormat ? 4 : 3);
401 f = fopen(path, "wb");
402 if (!f) {
403 werror("%s", path);
404 return;
406 fprintf(f, "%02x%02x%1x", image->width, image->height, channels);
408 fwrite(image->data, 1, image->width * image->height * channels, f);
410 fsync(fileno(f));
411 if (fclose(f) < 0) {
412 werror("%s", path);
416 static int isPixmap(WMPropList * prop)
418 WMPropList *p;
419 char *s;
421 p = WMGetFromPLArray(prop, 0);
422 s = WMGetFromPLString(p);
423 if (strcasecmp(&s[1], "pixmap") == 0)
424 return 1;
425 else
426 return 0;
429 /**********************************************************************/
431 static void drawResizebarBevel(RImage * img)
433 RColor light;
434 RColor dark;
435 RColor black;
436 int width = img->width;
437 int height = img->height;
438 int cwidth = 28;
440 black.alpha = 255;
441 black.red = black.green = black.blue = 0;
443 light.alpha = 0;
444 light.red = light.green = light.blue = 80;
446 dark.alpha = 0;
447 dark.red = dark.green = dark.blue = 40;
449 ROperateLine(img, RSubtractOperation, 0, 0, width - 1, 0, &dark);
450 ROperateLine(img, RAddOperation, 0, 1, width - 1, 1, &light);
452 ROperateLine(img, RSubtractOperation, cwidth, 2, cwidth, height - 1, &dark);
453 ROperateLine(img, RAddOperation, cwidth + 1, 2, cwidth + 1, height - 1, &light);
455 ROperateLine(img, RSubtractOperation, width - cwidth - 2, 2, width - cwidth - 2, height - 1, &dark);
456 ROperateLine(img, RAddOperation, width - cwidth - 1, 2, width - cwidth - 1, height - 1, &light);
458 RDrawLine(img, 0, height - 1, width - 1, height - 1, &black);
459 RDrawLine(img, 0, 0, 0, height - 1, &black);
460 RDrawLine(img, width - 1, 0, width - 1, height - 1, &black);
463 static void drawMenuBevel(RImage * img)
465 RColor light, dark, mid;
466 int i;
467 int iheight = img->height / 4;
469 light.alpha = 0;
470 light.red = light.green = light.blue = 80;
472 dark.alpha = 255;
473 dark.red = dark.green = dark.blue = 0;
475 mid.alpha = 0;
476 mid.red = mid.green = mid.blue = 40;
478 for (i = 1; i < 4; i++) {
479 ROperateLine(img, RSubtractOperation, 0, i * iheight - 2, img->width - 1, i * iheight - 2, &mid);
481 RDrawLine(img, 0, i * iheight - 1, img->width - 1, i * iheight - 1, &dark);
483 ROperateLine(img, RAddOperation, 1, i * iheight, img->width - 2, i * iheight, &light);
487 static Pixmap renderTexture(WMScreen * scr, WMPropList * texture, int width, int height, const char *path, int border)
489 char *type;
490 RImage *image = NULL;
491 Pixmap pixmap;
492 RContext *rc = WMScreenRContext(scr);
493 char *str;
494 RColor rcolor;
496 type = WMGetFromPLString(WMGetFromPLArray(texture, 0));
498 if (strcasecmp(type, "solid") == 0) {
500 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
502 str2rcolor(rc, str, &rcolor);
504 image = RCreateImage(width, height, False);
505 RClearImage(image, &rcolor);
506 } else if (strcasecmp(type, "igradient") == 0) {
507 int t1, t2;
508 RColor c1[2], c2[2];
510 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
511 str2rcolor(rc, str, &c1[0]);
512 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
513 str2rcolor(rc, str, &c1[1]);
514 str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
515 t1 = atoi(str);
517 str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
518 str2rcolor(rc, str, &c2[0]);
519 str = WMGetFromPLString(WMGetFromPLArray(texture, 5));
520 str2rcolor(rc, str, &c2[1]);
521 str = WMGetFromPLString(WMGetFromPLArray(texture, 6));
522 t2 = atoi(str);
524 image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2);
525 } else if (strcasecmp(&type[1], "gradient") == 0) {
526 int style;
527 RColor rcolor2;
529 switch (toupper(type[0])) {
530 case 'V':
531 style = RVerticalGradient;
532 break;
533 case 'H':
534 style = RHorizontalGradient;
535 break;
536 default:
537 case 'D':
538 style = RDiagonalGradient;
539 break;
542 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
543 str2rcolor(rc, str, &rcolor);
544 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
545 str2rcolor(rc, str, &rcolor2);
547 image = RRenderGradient(width, height, &rcolor, &rcolor2, style);
548 } else if (strcasecmp(&type[2], "gradient") == 0 && toupper(type[0]) == 'T') {
549 int style;
550 RColor rcolor2;
551 int i;
552 RImage *grad, *timage = NULL;
553 char *path;
555 switch (toupper(type[1])) {
556 case 'V':
557 style = RVerticalGradient;
558 break;
559 case 'H':
560 style = RHorizontalGradient;
561 break;
562 default:
563 case 'D':
564 style = RDiagonalGradient;
565 break;
568 str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
569 str2rcolor(rc, str, &rcolor);
570 str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
571 str2rcolor(rc, str, &rcolor2);
573 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
575 if ((path = wfindfileinarray(GetObjectForKey("PixmapPath"), str)) != NULL)
576 timage = RLoadImage(rc, path, 0);
578 if (!path || !timage) {
579 wwarning("could not load file '%s': %s", path, RMessageForError(RErrorCode));
580 } else {
581 grad = RRenderGradient(width, height, &rcolor, &rcolor2, style);
583 image = RMakeTiledImage(timage, width, height);
584 RReleaseImage(timage);
586 i = atoi(WMGetFromPLString(WMGetFromPLArray(texture, 2)));
588 RCombineImagesWithOpaqueness(image, grad, i);
589 RReleaseImage(grad);
591 } else if (strcasecmp(&type[2], "gradient") == 0 && toupper(type[0]) == 'M') {
592 int style;
593 RColor **colors;
594 int i, j;
596 switch (toupper(type[1])) {
597 case 'V':
598 style = RVerticalGradient;
599 break;
600 case 'H':
601 style = RHorizontalGradient;
602 break;
603 default:
604 case 'D':
605 style = RDiagonalGradient;
606 break;
609 j = WMGetPropListItemCount(texture);
611 if (j > 0) {
612 colors = wmalloc(j * sizeof(RColor *));
614 for (i = 2; i < j; i++) {
615 str = WMGetFromPLString(WMGetFromPLArray(texture, i));
616 colors[i - 2] = wmalloc(sizeof(RColor));
617 str2rcolor(rc, str, colors[i - 2]);
619 colors[i - 2] = NULL;
621 image = RRenderMultiGradient(width, height, colors, style);
623 for (i = 0; colors[i] != NULL; i++)
624 wfree(colors[i]);
625 wfree(colors);
627 } else if (strcasecmp(&type[1], "pixmap") == 0) {
628 RImage *timage = NULL;
629 char *path;
630 RColor color;
632 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
634 if ((path = wfindfileinarray(GetObjectForKey("PixmapPath"), str)) != NULL)
635 timage = RLoadImage(rc, path, 0);
637 if (!path || !timage) {
638 wwarning("could not load file '%s': %s", path ? path : str, RMessageForError(RErrorCode));
639 } else {
640 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
641 str2rcolor(rc, str, &color);
643 switch (toupper(type[0])) {
644 case 'T':
645 image = RMakeTiledImage(timage, width, height);
646 RReleaseImage(timage);
647 timage = image;
648 break;
649 case 'C':
650 image = RMakeCenteredImage(timage, width, height, &color);
651 RReleaseImage(timage);
652 timage = image;
653 break;
654 case 'S':
655 case 'M':
656 image = RScaleImage(timage, width, height);
657 RReleaseImage(timage);
658 timage = image;
659 break;
663 wfree(path);
666 if (!image)
667 return None;
669 if (path) {
670 dumpRImage(path, image);
673 if (border < 0) {
674 if (border == RESIZEBAR_BEVEL) {
675 drawResizebarBevel(image);
676 } else if (border == MENU_BEVEL) {
677 drawMenuBevel(image);
678 RBevelImage(image, RBEV_RAISED2);
680 } else if (border) {
681 RBevelImage(image, border);
684 RConvertImage(rc, image, &pixmap);
685 RReleaseImage(image);
687 return pixmap;
690 static Pixmap renderMenu(_Panel * panel, WMPropList * texture, int width, int iheight)
692 WMScreen *scr = WMWidgetScreen(panel->parent);
693 Display *dpy = WMScreenDisplay(scr);
694 Pixmap pix, tmp;
695 GC gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
696 int i;
698 switch (panel->menuStyle) {
699 case MSTYLE_NORMAL:
700 tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
702 pix = XCreatePixmap(dpy, tmp, width, iheight * 4, WMScreenDepth(scr));
703 for (i = 0; i < 4; i++) {
704 XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight * i);
706 XFreePixmap(dpy, tmp);
707 break;
708 case MSTYLE_SINGLE:
709 pix = renderTexture(scr, texture, width, iheight * 4, NULL, MENU_BEVEL);
710 break;
711 case MSTYLE_FLAT:
712 pix = renderTexture(scr, texture, width, iheight * 4, NULL, RBEV_RAISED2);
713 break;
714 default:
715 pix = None;
717 XFreeGC(dpy, gc);
719 return pix;
722 static void renderPreview(_Panel * panel, GC gc, int part, int relief)
724 WMListItem *item;
725 TextureListItem *titem;
726 Pixmap pix;
727 WMScreen *scr = WMWidgetScreen(panel->box);
729 item = WMGetListItem(panel->texLs, panel->textureIndex[part]);
730 titem = (TextureListItem *) item->clientData;
732 pix = renderTexture(scr, titem->prop,
733 previewPositions[part].size.width, previewPositions[part].size.height, NULL, relief);
735 XCopyArea(WMScreenDisplay(scr), pix, panel->preview, gc, 0, 0,
736 previewPositions[part].size.width,
737 previewPositions[part].size.height, previewPositions[part].pos.x, previewPositions[part].pos.y);
739 XCopyArea(WMScreenDisplay(scr), pix, panel->previewNoText, gc, 0, 0,
740 previewPositions[part].size.width,
741 previewPositions[part].size.height, previewPositions[part].pos.x, previewPositions[part].pos.y);
743 XFreePixmap(WMScreenDisplay(scr), pix);
746 static void updatePreviewBox(_Panel * panel, int elements)
748 WMScreen *scr = WMWidgetScreen(panel->parent);
749 Display *dpy = WMScreenDisplay(scr);
750 Pixmap pix;
751 GC gc;
752 int colorUpdate = 0;
753 WMColor *black = WMBlackColor(scr);
755 gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
757 if (panel->preview == None) {
758 WMColor *color;
759 WMPixmap *p;
761 panel->previewNoText = XCreatePixmap(dpy, WMWidgetXID(panel->parent),
762 240 - 4, 215 - 4, WMScreenDepth(scr));
764 p = WMCreatePixmap(scr, 240 - 4, 215 - 4, WMScreenDepth(scr), False);
765 panel->preview = WMGetPixmapXID(p);
766 WMSetLabelImage(panel->prevL, p);
767 WMReleasePixmap(p);
769 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
770 XFillRectangle(dpy, panel->preview, WMColorGC(color), 0, 0, 240 - 4, 215 - 4);
771 XFillRectangle(dpy, panel->previewNoText, WMColorGC(color), 0, 0, 240 - 4, 215 - 4);
772 WMReleaseColor(color);
775 if (elements & (1 << PFOCUSED)) {
776 renderPreview(panel, gc, PFOCUSED, RBEV_RAISED2);
777 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
778 previewPositions[PFOCUSED].pos.x - 1,
779 previewPositions[PFOCUSED].pos.y - 1,
780 previewPositions[PFOCUSED].size.width, previewPositions[PFOCUSED].size.height);
781 XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black),
782 previewPositions[PFOCUSED].pos.x - 1,
783 previewPositions[PFOCUSED].pos.y - 1,
784 previewPositions[PFOCUSED].size.width, previewPositions[PFOCUSED].size.height);
785 colorUpdate |= FTITLE_COL;
787 if (elements & (1 << PUNFOCUSED)) {
788 renderPreview(panel, gc, PUNFOCUSED, RBEV_RAISED2);
789 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
790 previewPositions[PUNFOCUSED].pos.x - 1,
791 previewPositions[PUNFOCUSED].pos.y - 1,
792 previewPositions[PUNFOCUSED].size.width, previewPositions[PUNFOCUSED].size.height);
793 XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black),
794 previewPositions[PUNFOCUSED].pos.x - 1,
795 previewPositions[PUNFOCUSED].pos.y - 1,
796 previewPositions[PUNFOCUSED].size.width, previewPositions[PUNFOCUSED].size.height);
797 colorUpdate |= UTITLE_COL;
799 if (elements & (1 << POWNER)) {
800 renderPreview(panel, gc, POWNER, RBEV_RAISED2);
801 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
802 previewPositions[POWNER].pos.x - 1,
803 previewPositions[POWNER].pos.y - 1,
804 previewPositions[POWNER].size.width, previewPositions[POWNER].size.height);
805 XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black),
806 previewPositions[POWNER].pos.x - 1,
807 previewPositions[POWNER].pos.y - 1,
808 previewPositions[POWNER].size.width, previewPositions[POWNER].size.height);
809 colorUpdate |= OTITLE_COL;
811 if (elements & (1 << PRESIZEBAR)) {
812 renderPreview(panel, gc, PRESIZEBAR, RESIZEBAR_BEVEL);
814 if (elements & (1 << PMTITLE)) {
815 renderPreview(panel, gc, PMTITLE, RBEV_RAISED2);
816 colorUpdate |= MTITLE_COL;
818 if (elements & (1 << PMITEM)) {
819 WMListItem *item;
820 TextureListItem *titem;
822 item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
823 titem = (TextureListItem *) item->clientData;
825 pix = renderMenu(panel, titem->prop,
826 previewPositions[PMITEM].size.width, previewPositions[PMITEM].size.height / 4);
828 XCopyArea(dpy, pix, panel->preview, gc, 0, 0,
829 previewPositions[PMITEM].size.width,
830 previewPositions[PMITEM].size.height,
831 previewPositions[PMITEM].pos.x, previewPositions[PMITEM].pos.y);
833 XCopyArea(dpy, pix, panel->previewNoText, gc, 0, 0,
834 previewPositions[PMITEM].size.width,
835 previewPositions[PMITEM].size.height,
836 previewPositions[PMITEM].pos.x, previewPositions[PMITEM].pos.y);
838 XFreePixmap(dpy, pix);
840 colorUpdate |= MITEM_COL | MDISAB_COL | MHIGH_COL | MHIGHT_COL;
842 if (elements & (1 << PMITEM | 1 << PMTITLE)) {
843 XDrawLine(dpy, panel->preview, gc, 29, 120, 29, 120 + 20 * 4 + 20);
844 XDrawLine(dpy, panel->preview, gc, 29, 119, 119, 119);
846 XDrawLine(dpy, panel->previewNoText, gc, 29, 120, 29, 120 + 20 * 4 + 20);
847 XDrawLine(dpy, panel->previewNoText, gc, 29, 119, 119, 119);
849 if (elements & (1 << PICON)) {
850 WMListItem *item;
851 TextureListItem *titem;
853 item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
854 titem = (TextureListItem *) item->clientData;
856 renderPreview(panel, gc, PICON, titem->ispixmap ? 0 : RBEV_RAISED3);
858 colorUpdate |= ICONT_COL | ICONB_COL | CLIP_COL | CCLIP_COL;
861 if (colorUpdate)
862 updateColorPreviewBox(panel, colorUpdate);
863 else
864 WMRedisplayWidget(panel->prevL);
866 XFreeGC(dpy, gc);
867 WMReleaseColor(black);
870 static void cancelNewTexture(void *data)
872 _Panel *panel = (_Panel *) data;
874 HideTexturePanel(panel->texturePanel);
877 static char *makeFileName(const char *prefix)
879 char *fname;
881 fname = wstrdup(prefix);
883 while (access(fname, F_OK) == 0) {
884 char buf[30];
886 wfree(fname);
887 sprintf(buf, "%08lx.cache", time(NULL));
888 fname = wstrconcat(prefix, buf);
891 return fname;
894 static void okNewTexture(void *data)
896 _Panel *panel = (_Panel *) data;
897 WMListItem *item;
898 char *name;
899 char *str;
900 WMPropList *prop;
901 TextureListItem *titem;
902 WMScreen *scr = WMWidgetScreen(panel->parent);
904 titem = wmalloc(sizeof(TextureListItem));
906 HideTexturePanel(panel->texturePanel);
908 name = GetTexturePanelTextureName(panel->texturePanel);
910 prop = GetTexturePanelTexture(panel->texturePanel);
912 str = WMGetPropListDescription(prop, False);
914 titem->title = name;
915 titem->prop = prop;
916 titem->texture = str;
917 titem->selectedFor = 0;
919 titem->ispixmap = isPixmap(prop);
921 titem->path = makeFileName(panel->fprefix);
922 titem->preview = renderTexture(scr, prop, TEXPREV_WIDTH, TEXPREV_HEIGHT, titem->path, 0);
924 item = WMAddListItem(panel->texLs, "");
925 item->clientData = titem;
927 WMSetListPosition(panel->texLs, WMGetListNumberOfRows(panel->texLs));
930 static void okEditTexture(void *data)
932 _Panel *panel = (_Panel *) data;
933 WMListItem *item;
934 char *name;
935 char *str;
936 WMPropList *prop;
937 TextureListItem *titem;
939 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
940 titem = (TextureListItem *) item->clientData;
942 HideTexturePanel(panel->texturePanel);
944 if (titem->current) {
945 name = GetTexturePanelTextureName(panel->texturePanel);
947 wfree(titem->title);
948 titem->title = name;
951 prop = GetTexturePanelTexture(panel->texturePanel);
953 str = WMGetPropListDescription(prop, False);
955 WMReleasePropList(titem->prop);
956 titem->prop = prop;
958 titem->ispixmap = isPixmap(prop);
960 wfree(titem->texture);
961 titem->texture = str;
963 XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel->texLs)), titem->preview);
964 titem->preview = renderTexture(WMWidgetScreen(panel->texLs), titem->prop,
965 TEXPREV_WIDTH, TEXPREV_HEIGHT, titem->path, 0);
967 WMRedisplayWidget(panel->texLs);
969 if (titem->selectedFor)
970 updatePreviewBox(panel, titem->selectedFor);
972 changePage(panel->secP, panel);
975 static void editTexture(WMWidget * w, void *data)
977 _Panel *panel = (_Panel *) data;
978 WMListItem *item;
979 TextureListItem *titem;
981 /* Parameter not used, but tell the compiler that it is ok */
982 (void) w;
984 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
985 titem = (TextureListItem *) item->clientData;
987 SetTexturePanelPixmapPath(panel->texturePanel, GetObjectForKey("PixmapPath"));
989 SetTexturePanelTexture(panel->texturePanel, titem->title, titem->prop);
991 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
992 SetTexturePanelOkAction(panel->texturePanel, okEditTexture, panel);
994 ShowTexturePanel(panel->texturePanel);
997 static void newTexture(WMWidget * w, void *data)
999 _Panel *panel = (_Panel *) data;
1001 /* Parameter not used, but tell the compiler that it is ok */
1002 (void) w;
1004 SetTexturePanelPixmapPath(panel->texturePanel, GetObjectForKey("PixmapPath"));
1006 SetTexturePanelTexture(panel->texturePanel, "New Texture", NULL);
1008 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
1010 SetTexturePanelOkAction(panel->texturePanel, okNewTexture, panel);
1012 ShowTexturePanel(panel->texturePanel);
1015 static void deleteTexture(WMWidget * w, void *data)
1017 _Panel *panel = (_Panel *) data;
1018 WMListItem *item;
1019 TextureListItem *titem;
1020 int row;
1021 int section;
1023 /* Parameter not used, but tell the compiler that it is ok */
1024 (void) w;
1026 section = WMGetPopUpButtonSelectedItem(panel->secP);
1027 row = WMGetListSelectedItemRow(panel->texLs);
1028 item = WMGetListItem(panel->texLs, row);
1029 titem = (TextureListItem *) item->clientData;
1031 if (titem->selectedFor & (1 << section)) {
1032 TextureListItem *titem2;
1034 panel->textureIndex[section] = section;
1035 item = WMGetListItem(panel->texLs, section);
1036 titem2 = (TextureListItem *) item->clientData;
1037 titem2->selectedFor |= 1 << section;
1040 wfree(titem->title);
1041 wfree(titem->texture);
1042 WMReleasePropList(titem->prop);
1043 if (titem->path) {
1044 if (remove(titem->path) < 0 && errno != ENOENT) {
1045 werror("could not remove file %s", titem->path);
1047 wfree(titem->path);
1050 wfree(titem);
1052 WMRemoveListItem(panel->texLs, row);
1053 WMSetButtonEnabled(panel->delB, False);
1056 static void extractTexture(WMWidget * w, void *data)
1058 _Panel *panel = (_Panel *) data;
1059 char *path;
1060 WMOpenPanel *opanel;
1061 WMScreen *scr = WMWidgetScreen(w);
1063 opanel = WMGetOpenPanel(scr);
1064 WMSetFilePanelCanChooseDirectories(opanel, False);
1065 WMSetFilePanelCanChooseFiles(opanel, True);
1067 if (WMRunModalFilePanelForDirectory(opanel, panel->parent, wgethomedir(), _("Select File"), NULL)) {
1068 path = WMGetFilePanelFileName(opanel);
1070 OpenExtractPanelFor(panel);
1072 wfree(path);
1076 static void changePage(WMWidget * w, void *data)
1078 _Panel *panel = (_Panel *) data;
1079 int section;
1080 WMScreen *scr = WMWidgetScreen(panel->box);
1081 RContext *rc = WMScreenRContext(scr);
1082 static WMPoint positions[] = {
1083 {5, 10},
1084 {5, 40},
1085 {5, 70},
1086 {5, 100},
1087 {5, 120},
1088 {5, 160},
1089 {130, 150}
1092 if (w) {
1093 section = WMGetPopUpButtonSelectedItem(panel->secP);
1095 WMSelectListItem(panel->texLs, panel->textureIndex[section]);
1097 WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2);
1100 WMColor *color;
1102 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
1103 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
1104 positions[panel->oldsection].x, positions[panel->oldsection].y, 22, 22);
1105 WMReleaseColor(color);
1107 if (w) {
1108 panel->oldsection = section;
1109 WMDrawPixmap(panel->hand, panel->preview, positions[section].x, positions[section].y);
1111 WMRedisplayWidget(panel->prevL);
1114 static void previewClick(XEvent * event, void *clientData)
1116 _Panel *panel = (_Panel *) clientData;
1117 int i;
1119 switch (panel->oldTabItem) {
1120 case 0:
1121 for (i = 0; i < wlengthof(previewPositions); i++) {
1122 if (event->xbutton.x >= previewPositions[i].pos.x
1123 && event->xbutton.y >= previewPositions[i].pos.y
1124 && event->xbutton.x < previewPositions[i].pos.x
1125 + previewPositions[i].size.width
1126 && event->xbutton.y < previewPositions[i].pos.y + previewPositions[i].size.height) {
1128 WMSetPopUpButtonSelectedItem(panel->secP, i);
1129 changePage(panel->secP, panel);
1130 return;
1133 break;
1134 case 1:
1135 for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->colP); i++) {
1136 if (event->xbutton.x >= previewColorPositions[i].pos.x
1137 && event->xbutton.y >= previewColorPositions[i].pos.y
1138 && event->xbutton.x < previewColorPositions[i].pos.x
1139 + previewColorPositions[i].size.width
1140 && event->xbutton.y < previewColorPositions[i].pos.y
1141 + previewColorPositions[i].size.height) {
1143 /* yuck kluge */
1144 if (i == 7)
1145 i = 4;
1147 WMSetPopUpButtonSelectedItem(panel->colP, i);
1148 changeColorPage(panel->colP, panel);
1149 return;
1152 break;
1156 static void textureClick(WMWidget * w, void *data)
1158 _Panel *panel = (_Panel *) data;
1159 int i;
1160 WMListItem *item;
1161 TextureListItem *titem;
1163 /* Parameter not used, but tell the compiler that it is ok */
1164 (void) w;
1166 i = WMGetListSelectedItemRow(panel->texLs);
1168 item = WMGetListItem(panel->texLs, i);
1170 titem = (TextureListItem *) item->clientData;
1172 if (titem->current) {
1173 WMSetButtonEnabled(panel->delB, False);
1174 } else {
1175 WMSetButtonEnabled(panel->delB, True);
1179 static void textureDoubleClick(WMWidget * w, void *data)
1181 _Panel *panel = (_Panel *) data;
1182 int i, section;
1183 WMListItem *item;
1184 TextureListItem *titem;
1186 /* Parameter not used, but tell the compiler that it is ok */
1187 (void) w;
1189 /* unselect old texture */
1190 section = WMGetPopUpButtonSelectedItem(panel->secP);
1192 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
1193 titem = (TextureListItem *) item->clientData;
1194 titem->selectedFor &= ~(1 << section);
1196 /* select new texture */
1197 i = WMGetListSelectedItemRow(panel->texLs);
1199 item = WMGetListItem(panel->texLs, i);
1201 titem = (TextureListItem *) item->clientData;
1203 titem->selectedFor |= 1 << section;
1205 panel->textureIndex[section] = i;
1207 WMRedisplayWidget(panel->texLs);
1209 updatePreviewBox(panel, 1 << section);
1212 static void paintListItem(WMList * lPtr, int index, Drawable d, char *text, int state, WMRect * rect)
1214 _Panel *panel = (_Panel *) WMGetHangedData(lPtr);
1215 WMScreen *scr = WMWidgetScreen(lPtr);
1216 int width, height, x, y;
1217 Display *dpy = WMScreenDisplay(scr);
1218 WMColor *back = (state & WLDSSelected) ? WMWhiteColor(scr) : WMGrayColor(scr);
1219 WMListItem *item;
1220 WMColor *black = WMBlackColor(scr);
1221 TextureListItem *titem;
1223 /* Parameter not used, but tell the compiler that it is ok */
1224 (void) text;
1226 item = WMGetListItem(lPtr, index);
1227 titem = (TextureListItem *) item->clientData;
1228 if (!titem) {
1229 WMReleaseColor(back);
1230 WMReleaseColor(black);
1231 return;
1234 width = rect->size.width;
1235 height = rect->size.height;
1236 x = rect->pos.x;
1237 y = rect->pos.y;
1239 XFillRectangle(dpy, d, WMColorGC(back), x, y, width, height);
1241 if (titem->preview)
1242 XCopyArea(dpy, titem->preview, d, WMColorGC(black), 0, 0,
1243 TEXPREV_WIDTH, TEXPREV_HEIGHT, x + 5, y + 5);
1245 if ((1 << WMGetPopUpButtonSelectedItem(panel->secP)) & titem->selectedFor)
1246 WMDrawPixmap(panel->onLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1247 else if (titem->selectedFor)
1248 WMDrawPixmap(panel->offLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1250 WMDrawString(scr, d, black, panel->boldFont,
1251 x + TEXPREV_WIDTH + 22, y + 2, titem->title, strlen(titem->title));
1253 WMDrawString(scr, d, black, panel->smallFont,
1254 x + TEXPREV_WIDTH + 14, y + 18, titem->texture, strlen(titem->texture));
1256 WMReleaseColor(back);
1257 WMReleaseColor(black);
1260 static Pixmap loadRImage(WMScreen * scr, const char *path)
1262 FILE *f;
1263 RImage *image;
1264 int w, h, d;
1265 Pixmap pixmap;
1267 f = fopen(path, "rb");
1268 if (!f)
1269 return None;
1271 fscanf(f, "%02x%02x%1x", &w, &h, &d);
1273 image = RCreateImage(w, h, d == 4);
1274 fread(image->data, 1, w * h * d, f);
1275 fclose(f);
1277 RConvertImage(WMScreenRContext(scr), image, &pixmap);
1278 RReleaseImage(image);
1280 return pixmap;
1283 static void fillTextureList(WMList * lPtr)
1285 WMPropList *textureList;
1286 WMPropList *texture;
1287 WMUserDefaults *udb = WMGetStandardUserDefaults();
1288 TextureListItem *titem;
1289 WMScreen *scr = WMWidgetScreen(lPtr);
1290 int i;
1292 textureList = WMGetUDObjectForKey(udb, "TextureList");
1293 if (!textureList)
1294 return;
1296 for (i = 0; i < WMGetPropListItemCount(textureList); i++) {
1297 WMListItem *item;
1299 texture = WMGetFromPLArray(textureList, i);
1301 titem = wmalloc(sizeof(TextureListItem));
1303 titem->title = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 0)));
1304 titem->prop = WMRetainPropList(WMGetFromPLArray(texture, 1));
1305 titem->texture = WMGetPropListDescription(titem->prop, False);
1306 titem->selectedFor = 0;
1307 titem->path = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 2)));
1309 titem->preview = loadRImage(scr, titem->path);
1310 if (!titem->preview) {
1311 titem->preview = renderTexture(scr, titem->prop, TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0);
1313 item = WMAddListItem(lPtr, "");
1314 item->clientData = titem;
1318 static void fillColorList(_Panel * panel)
1320 WMColor *color;
1321 WMPropList *list;
1322 WMUserDefaults *udb = WMGetStandardUserDefaults();
1323 WMScreen *scr = WMWidgetScreen(panel->box);
1324 int i;
1326 list = WMGetUDObjectForKey(udb, "ColorList");
1327 if (!list) {
1328 for (i = 0; i < 24; i++) {
1329 color = WMCreateNamedColor(scr, sampleColors[i], False);
1330 if (!color)
1331 continue;
1332 WMSetColorWellColor(panel->sampW[i], color);
1333 WMReleaseColor(color);
1335 } else {
1336 WMPropList *c;
1338 for (i = 0; i < WMIN(24, WMGetPropListItemCount(list)); i++) {
1339 c = WMGetFromPLArray(list, i);
1340 if (!c || !WMIsPLString(c))
1341 continue;
1342 color = WMCreateNamedColor(scr, WMGetFromPLString(c), False);
1343 if (!color)
1344 continue;
1345 WMSetColorWellColor(panel->sampW[i], color);
1346 WMReleaseColor(color);
1351 /*************************************************************************/
1353 static void changeColorPage(WMWidget * w, void *data)
1355 _Panel *panel = (_Panel *) data;
1356 int section;
1357 WMScreen *scr = WMWidgetScreen(panel->box);
1358 RContext *rc = WMScreenRContext(scr);
1359 static WMPoint positions[] = {
1360 {5, 10},
1361 {5, 40},
1362 {5, 70},
1363 {5, 120},
1364 {5, 140},
1365 {5, 160},
1366 {5, 180},
1367 {5, 180},
1368 {130, 140},
1369 {130, 140},
1370 {130, 140},
1371 {130, 140}
1374 if (panel->preview) {
1375 WMColor *color;
1377 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
1378 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
1379 positions[panel->oldcsection].x, positions[panel->oldcsection].y, 22, 22);
1380 WMReleaseColor(color);
1382 if (w) {
1383 section = WMGetPopUpButtonSelectedItem(panel->colP);
1385 panel->oldcsection = section;
1386 if (panel->preview)
1387 WMDrawPixmap(panel->hand, panel->preview, positions[section].x, positions[section].y);
1389 section = WMGetPopUpButtonSelectedItem(panel->colP);
1391 WMSetColorWellColor(panel->colW, panel->colors[section]);
1393 WMRedisplayWidget(panel->prevL);
1396 static void
1397 paintText(WMScreen * scr, Drawable d, WMColor * color, WMFont * font,
1398 int x, int y, int w, int h, WMAlignment align, char *text)
1400 int l = strlen(text);
1402 switch (align) {
1403 case WALeft:
1404 x += 5;
1405 break;
1406 case WARight:
1407 x += w - 5 - WMWidthOfString(font, text, l);
1408 break;
1409 default:
1410 case WACenter:
1411 x += (w - WMWidthOfString(font, text, l)) / 2;
1412 break;
1414 WMDrawString(scr, d, color, font, x, y + (h - WMFontHeight(font)) / 2, text, l);
1417 static void updateColorPreviewBox(_Panel * panel, int elements)
1419 WMScreen *scr = WMWidgetScreen(panel->box);
1420 Display *dpy = WMScreenDisplay(scr);
1421 Pixmap d, pnot;
1422 GC gc;
1424 d = panel->preview;
1425 pnot = panel->previewNoText;
1426 gc = WMColorGC(panel->colors[0]);
1428 if (elements & FTITLE_COL) {
1429 XCopyArea(dpy, pnot, d, gc, 30, 10, 190, 20, 30, 10);
1430 paintText(scr, d, panel->colors[0], panel->boldFont, 30, 10, 190, 20,
1431 panel->titleAlignment, _("Focused Window"));
1433 if (elements & UTITLE_COL) {
1434 XCopyArea(dpy, pnot, d, gc, 30, 40, 190, 20, 30, 40);
1435 paintText(scr, d, panel->colors[1], panel->boldFont, 30, 40, 190, 20,
1436 panel->titleAlignment, _("Unfocused Window"));
1438 if (elements & OTITLE_COL) {
1439 XCopyArea(dpy, pnot, d, gc, 30, 70, 190, 20, 30, 70);
1440 paintText(scr, d, panel->colors[2], panel->boldFont, 30, 70, 190, 20,
1441 panel->titleAlignment, _("Owner of Focused Window"));
1443 if (elements & MTITLE_COL) {
1444 XCopyArea(dpy, pnot, d, gc, 30, 120, 90, 20, 30, 120);
1445 paintText(scr, d, panel->colors[3], panel->boldFont, 30, 120, 90, 20, WALeft, _("Menu Title"));
1447 if (elements & MITEM_COL) {
1448 XCopyArea(dpy, pnot, d, gc, 30, 140, 90, 20, 30, 140);
1449 paintText(scr, d, panel->colors[4], panel->normalFont, 30, 140, 90, 20, WALeft, _("Normal Item"));
1450 XCopyArea(dpy, pnot, d, gc, 30, 200, 90, 20, 30, 200);
1451 paintText(scr, d, panel->colors[4], panel->normalFont, 30, 200, 90, 20, WALeft, _("Normal Item"));
1453 if (elements & MDISAB_COL) {
1454 XCopyArea(dpy, pnot, d, gc, 30, 160, 90, 20, 30, 160);
1455 paintText(scr, d, panel->colors[5], panel->normalFont, 30, 160, 90, 20,
1456 WALeft, _("Disabled Item"));
1458 if (elements & MHIGH_COL) {
1459 XFillRectangle(WMScreenDisplay(scr), d, WMColorGC(panel->colors[6]), 31, 181, 87, 17);
1460 XFillRectangle(WMScreenDisplay(scr), pnot, WMColorGC(panel->colors[6]), 31, 181, 87, 17);
1461 elements |= MHIGHT_COL;
1463 if (elements & MHIGHT_COL) {
1464 XCopyArea(dpy, pnot, d, gc, 30, 180, 90, 20, 30, 180);
1465 paintText(scr, d, panel->colors[7], panel->normalFont, 30, 180, 90, 20, WALeft, _("Highlighted"));
1468 if (elements & ICONT_COL) {
1469 WRITE(_("Focused Window"), panel->colors[8], panel->boldFont,
1470 155, 130, 64);
1472 if (elements & ICONB_COL) {
1473 WRITE(_("Focused Window"), panel->colors[9], panel->boldFont,
1474 0, 0, 30);
1476 if (elements & CLIP_COL) {
1477 WRITE(_("Focused Window"), panel->colors[10], panel->boldFont,
1478 0, 0, 30);
1480 if (elements & CCLIP_COL) {
1481 WRITE(_("Focused Window"), panel->colors[11], panel->boldFont,
1482 0, 0, 30);
1485 WMRedisplayWidget(panel->prevL);
1488 static void colorWellObserver(void *self, WMNotification * n)
1490 _Panel *panel = (_Panel *) self;
1491 int p;
1493 /* Parameter not used, but tell the compiler that it is ok */
1494 (void) n;
1496 p = WMGetPopUpButtonSelectedItem(panel->colP);
1498 WMReleaseColor(panel->colors[p]);
1500 panel->colors[p] = WMRetainColor(WMGetColorWellColor(panel->colW));
1502 updateColorPreviewBox(panel, 1 << p);
1505 static void changedTabItem(struct WMTabViewDelegate *self, WMTabView * tabView, WMTabViewItem * item)
1507 _Panel *panel = self->data;
1508 int i;
1510 /* Parameter not used, but tell the compiler that it is ok */
1511 (void) tabView;
1513 i = WMGetTabViewItemIdentifier(item);
1514 switch (i) {
1515 case 0:
1516 switch (panel->oldTabItem) {
1517 case 1:
1518 changeColorPage(NULL, panel);
1519 break;
1521 changePage(panel->secP, panel);
1522 break;
1523 case 1:
1524 switch (panel->oldTabItem) {
1525 case 0:
1526 changePage(NULL, panel);
1527 break;
1529 changeColorPage(panel->colP, panel);
1530 break;
1531 case 3:
1532 switch (panel->oldTabItem) {
1533 case 0:
1534 changePage(NULL, panel);
1535 break;
1536 case 1:
1537 changeColorPage(NULL, panel);
1538 break;
1540 break;
1543 panel->oldTabItem = i;
1546 /*************************************************************************/
1548 static void menuStyleCallback(WMWidget * self, void *data)
1550 _Panel *panel = (_Panel *) data;
1552 if (self == panel->mstyB[0]) {
1553 panel->menuStyle = MSTYLE_NORMAL;
1554 updatePreviewBox(panel, 1 << PMITEM);
1556 } else if (self == panel->mstyB[1]) {
1557 panel->menuStyle = MSTYLE_SINGLE;
1558 updatePreviewBox(panel, 1 << PMITEM);
1560 } else if (self == panel->mstyB[2]) {
1561 panel->menuStyle = MSTYLE_FLAT;
1562 updatePreviewBox(panel, 1 << PMITEM);
1566 static void titleAlignCallback(WMWidget * self, void *data)
1568 _Panel *panel = (_Panel *) data;
1570 if (self == panel->taliB[0]) {
1571 panel->titleAlignment = WALeft;
1572 updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER);
1574 } else if (self == panel->taliB[1]) {
1575 panel->titleAlignment = WACenter;
1576 updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER);
1578 } else if (self == panel->taliB[2]) {
1579 panel->titleAlignment = WARight;
1580 updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER);
1584 static void createPanel(Panel * p)
1586 _Panel *panel = (_Panel *) p;
1587 WMFont *font;
1588 WMScreen *scr = WMWidgetScreen(panel->parent);
1589 WMTabViewItem *item;
1590 int i;
1591 char *tmp;
1592 Bool ok = True;
1594 panel->fprefix = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
1596 if (access(panel->fprefix, F_OK) != 0) {
1597 if (mkdir(panel->fprefix, 0755) < 0) {
1598 werror("%s", panel->fprefix);
1599 ok = False;
1602 if (ok) {
1603 tmp = wstrconcat(panel->fprefix, "/WPrefs/");
1604 wfree(panel->fprefix);
1605 panel->fprefix = tmp;
1606 if (access(panel->fprefix, F_OK) != 0) {
1607 if (mkdir(panel->fprefix, 0755) < 0) {
1608 werror("%s", panel->fprefix);
1613 panel->smallFont = WMSystemFontOfSize(scr, 10);
1614 panel->normalFont = WMSystemFontOfSize(scr, 12);
1615 panel->boldFont = WMBoldSystemFontOfSize(scr, 12);
1617 panel->onLed = WMCreatePixmapFromXPMData(scr, blueled_xpm);
1618 panel->offLed = WMCreatePixmapFromXPMData(scr, blueled2_xpm);
1619 panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm);
1621 panel->box = WMCreateBox(panel->parent);
1622 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
1624 /* preview box */
1625 panel->prevL = WMCreateLabel(panel->box);
1626 WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT - 20);
1627 WMMoveWidget(panel->prevL, 15, 10);
1628 WMSetLabelRelief(panel->prevL, WRSunken);
1629 WMSetLabelImagePosition(panel->prevL, WIPImageOnly);
1631 WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask, previewClick, panel);
1633 /* tabview */
1635 tabviewDelegate.data = panel;
1637 panel->tabv = WMCreateTabView(panel->box);
1638 WMResizeWidget(panel->tabv, 245, FRAME_HEIGHT - 20);
1639 WMMoveWidget(panel->tabv, 265, 10);
1640 WMSetTabViewDelegate(panel->tabv, &tabviewDelegate);
1642 /*** texture list ***/
1644 panel->texF = WMCreateFrame(panel->box);
1645 WMSetFrameRelief(panel->texF, WRFlat);
1647 item = WMCreateTabViewItemWithIdentifier(0);
1648 WMSetTabViewItemView(item, WMWidgetView(panel->texF));
1649 WMSetTabViewItemLabel(item, _("Texture"));
1651 WMAddItemInTabView(panel->tabv, item);
1653 panel->secP = WMCreatePopUpButton(panel->texF);
1654 WMResizeWidget(panel->secP, 228, 20);
1655 WMMoveWidget(panel->secP, 7, 7);
1656 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window"));
1657 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Unfocused Windows"));
1658 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window's Owner"));
1659 WMAddPopUpButtonItem(panel->secP, _("Window Resizebar"));
1660 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
1661 WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
1662 WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
1663 /* WMAddPopUpButtonItem(panel->secP, _("Workspace Backgrounds"));
1665 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1666 WMSetPopUpButtonAction(panel->secP, changePage, panel);
1668 panel->texLs = WMCreateList(panel->texF);
1669 WMResizeWidget(panel->texLs, 165, 155);
1670 WMMoveWidget(panel->texLs, 70, 33);
1671 WMSetListUserDrawItemHeight(panel->texLs, 35);
1672 WMSetListUserDrawProc(panel->texLs, paintListItem);
1673 WMHangData(panel->texLs, panel);
1674 WMSetListAction(panel->texLs, textureClick, panel);
1675 WMSetListDoubleAction(panel->texLs, textureDoubleClick, panel);
1677 WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
1678 "for the selected item."), WMWidgetView(panel->texLs));
1680 /* command buttons */
1682 font = WMSystemFontOfSize(scr, 10);
1684 panel->newB = WMCreateCommandButton(panel->texF);
1685 WMResizeWidget(panel->newB, 57, 39);
1686 WMMoveWidget(panel->newB, 7, 33);
1687 WMSetButtonFont(panel->newB, font);
1688 WMSetButtonImagePosition(panel->newB, WIPAbove);
1689 WMSetButtonText(panel->newB, _("New"));
1690 WMSetButtonAction(panel->newB, newTexture, panel);
1691 SetButtonAlphaImage(scr, panel->newB, TNEW_FILE, NULL, NULL);
1693 WMSetBalloonTextForView(_("Create a new texture."), WMWidgetView(panel->newB));
1695 panel->ripB = WMCreateCommandButton(panel->texF);
1696 WMResizeWidget(panel->ripB, 57, 39);
1697 WMMoveWidget(panel->ripB, 7, 72);
1698 WMSetButtonFont(panel->ripB, font);
1699 WMSetButtonImagePosition(panel->ripB, WIPAbove);
1700 WMSetButtonText(panel->ripB, _("Extract..."));
1701 WMSetButtonAction(panel->ripB, extractTexture, panel);
1702 SetButtonAlphaImage(scr, panel->ripB, TEXTR_FILE, NULL, NULL);
1704 WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."), WMWidgetView(panel->ripB));
1706 WMSetButtonEnabled(panel->ripB, False);
1708 panel->editB = WMCreateCommandButton(panel->texF);
1709 WMResizeWidget(panel->editB, 57, 39);
1710 WMMoveWidget(panel->editB, 7, 111);
1711 WMSetButtonFont(panel->editB, font);
1712 WMSetButtonImagePosition(panel->editB, WIPAbove);
1713 WMSetButtonText(panel->editB, _("Edit"));
1714 SetButtonAlphaImage(scr, panel->editB, TEDIT_FILE, NULL, NULL);
1715 WMSetButtonAction(panel->editB, editTexture, panel);
1716 WMSetBalloonTextForView(_("Edit the highlighted texture."), WMWidgetView(panel->editB));
1718 panel->delB = WMCreateCommandButton(panel->texF);
1719 WMResizeWidget(panel->delB, 57, 38);
1720 WMMoveWidget(panel->delB, 7, 150);
1721 WMSetButtonFont(panel->delB, font);
1722 WMSetButtonImagePosition(panel->delB, WIPAbove);
1723 WMSetButtonText(panel->delB, _("Delete"));
1724 SetButtonAlphaImage(scr, panel->delB, TDEL_FILE, NULL, NULL);
1725 WMSetButtonEnabled(panel->delB, False);
1726 WMSetButtonAction(panel->delB, deleteTexture, panel);
1727 WMSetBalloonTextForView(_("Delete the highlighted texture."), WMWidgetView(panel->delB));
1729 WMReleaseFont(font);
1731 WMMapSubwidgets(panel->texF);
1733 /*** colors ***/
1734 panel->colF = WMCreateFrame(panel->box);
1735 WMSetFrameRelief(panel->colF, WRFlat);
1737 item = WMCreateTabViewItemWithIdentifier(1);
1738 WMSetTabViewItemView(item, WMWidgetView(panel->colF));
1739 WMSetTabViewItemLabel(item, _("Color"));
1741 WMAddItemInTabView(panel->tabv, item);
1743 panel->colP = WMCreatePopUpButton(panel->colF);
1744 WMResizeWidget(panel->colP, 228, 20);
1745 WMMoveWidget(panel->colP, 7, 7);
1746 WMAddPopUpButtonItem(panel->colP, _("Focused Window Title"));
1747 WMAddPopUpButtonItem(panel->colP, _("Unfocused Window Title"));
1748 WMAddPopUpButtonItem(panel->colP, _("Owner of Focused Window Title"));
1749 WMAddPopUpButtonItem(panel->colP, _("Menu Title"));
1750 WMAddPopUpButtonItem(panel->colP, _("Menu Item Text"));
1751 WMAddPopUpButtonItem(panel->colP, _("Disabled Menu Item Text"));
1752 WMAddPopUpButtonItem(panel->colP, _("Menu Highlight Color"));
1753 WMAddPopUpButtonItem(panel->colP, _("Highlighted Menu Text Color"));
1755 WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title"));
1756 WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title Back"));
1757 WMAddPopUpButtonItem(panel->colP, _("Clip Title"));
1758 WMAddPopUpButtonItem(panel->colP, _("Collapsed Clip Title"));
1761 WMSetPopUpButtonSelectedItem(panel->colP, 0);
1763 WMSetPopUpButtonAction(panel->colP, changeColorPage, panel);
1765 panel->colW = WMCreateColorWell(panel->colF);
1766 WMResizeWidget(panel->colW, 65, 50);
1767 WMMoveWidget(panel->colW, 30, 75);
1768 WMAddNotificationObserver(colorWellObserver, panel, WMColorWellDidChangeNotification, panel->colW);
1770 for (i = 0; i < 4; i++) {
1771 int j;
1772 for (j = 0; j < 6; j++) {
1773 panel->sampW[i + j * 4] = WMCreateColorWell(panel->colF);
1774 WMResizeWidget(panel->sampW[i + j * 4], 22, 22);
1775 WMMoveWidget(panel->sampW[i + j * 4], 130 + i * 22, 40 + j * 22);
1776 WSetColorWellBordered(panel->sampW[i + j * 4], False);
1780 WMMapSubwidgets(panel->colF);
1782 #ifdef unfinished
1783 /*** root bg ***/
1785 panel->bgF = WMCreateFrame(panel->box);
1786 WMSetFrameRelief(panel->bgF, WRFlat);
1788 item = WMCreateTabViewItemWithIdentifier(2);
1789 WMSetTabViewItemView(item, WMWidgetView(panel->bgF));
1790 WMSetTabViewItemLabel(item, _("Background"));
1792 WMAddItemInTabView(panel->tabv, item);
1794 panel->bgprevL = WMCreateLabel(panel->bgF);
1795 WMResizeWidget(panel->bgprevL, 230, 155);
1796 WMMoveWidget(panel->bgprevL, 5, 5);
1797 WMSetLabelRelief(panel->bgprevL, WRSunken);
1799 panel->selbgB = WMCreateCommandButton(panel->bgF);
1800 WMMoveWidget(panel->selbgB, 5, 165);
1801 WMResizeWidget(panel->selbgB, 100, 24);
1802 WMSetButtonText(panel->selbgB, _("Browse..."));
1804 WMMapSubwidgets(panel->bgF);
1805 #endif /* unfinished */
1806 /*** options ***/
1807 panel->optF = WMCreateFrame(panel->box);
1808 WMSetFrameRelief(panel->optF, WRFlat);
1810 item = WMCreateTabViewItemWithIdentifier(3);
1811 WMSetTabViewItemView(item, WMWidgetView(panel->optF));
1812 WMSetTabViewItemLabel(item, _("Options"));
1814 WMAddItemInTabView(panel->tabv, item);
1816 panel->mstyF = WMCreateFrame(panel->optF);
1817 WMResizeWidget(panel->mstyF, 215, 85);
1818 WMMoveWidget(panel->mstyF, 15, 10);
1819 WMSetFrameTitle(panel->mstyF, _("Menu Style"));
1821 for (i = 0; i < 3; i++) {
1822 WMPixmap *icon;
1823 char *path;
1825 panel->mstyB[i] = WMCreateButton(panel->mstyF, WBTOnOff);
1826 WMResizeWidget(panel->mstyB[i], 54, 54);
1827 WMMoveWidget(panel->mstyB[i], 15 + i * 65, 20);
1828 WMSetButtonImagePosition(panel->mstyB[i], WIPImageOnly);
1829 WMSetButtonAction(panel->mstyB[i], menuStyleCallback, panel);
1830 switch (i) {
1831 case 0:
1832 path = LocateImage(MSTYLE1_FILE);
1833 break;
1834 case 1:
1835 path = LocateImage(MSTYLE2_FILE);
1836 break;
1837 case 2:
1838 path = LocateImage(MSTYLE3_FILE);
1839 break;
1841 if (path) {
1842 icon = WMCreatePixmapFromFile(scr, path);
1843 if (icon) {
1844 WMSetButtonImage(panel->mstyB[i], icon);
1845 WMReleasePixmap(icon);
1846 } else {
1847 wwarning(_("could not load icon file %s"), path);
1849 wfree(path);
1852 WMGroupButtons(panel->mstyB[0], panel->mstyB[1]);
1853 WMGroupButtons(panel->mstyB[0], panel->mstyB[2]);
1855 WMMapSubwidgets(panel->mstyF);
1857 panel->taliF = WMCreateFrame(panel->optF);
1858 WMResizeWidget(panel->taliF, 110, 80);
1859 WMMoveWidget(panel->taliF, 15, 100);
1860 WMSetFrameTitle(panel->taliF, _("Title Alignment"));
1862 for (i = 0; i < 3; i++) {
1863 panel->taliB[i] = WMCreateRadioButton(panel->taliF);
1864 WMSetButtonAction(panel->taliB[i], titleAlignCallback, panel);
1865 switch (i) {
1866 case 0:
1867 WMSetButtonText(panel->taliB[i], _("Left"));
1868 break;
1869 case 1:
1870 WMSetButtonText(panel->taliB[i], _("Center"));
1871 break;
1872 case 2:
1873 WMSetButtonText(panel->taliB[i], _("Right"));
1874 break;
1876 WMResizeWidget(panel->taliB[i], 90, 18);
1877 WMMoveWidget(panel->taliB[i], 10, 15 + 20 * i);
1879 WMGroupButtons(panel->taliB[0], panel->taliB[1]);
1880 WMGroupButtons(panel->taliB[0], panel->taliB[2]);
1882 WMMapSubwidgets(panel->taliF);
1884 WMMapSubwidgets(panel->optF);
1886 /**/ WMRealizeWidget(panel->box);
1887 WMMapSubwidgets(panel->box);
1889 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1891 showData(panel);
1893 changePage(panel->secP, panel);
1895 fillTextureList(panel->texLs);
1897 fillColorList(panel);
1899 panel->texturePanel = CreateTexturePanel(panel->parent);
1902 static void setupTextureFor(WMList *list, const char *key, const char *defValue, const char *title, int index)
1904 WMListItem *item;
1905 TextureListItem *titem;
1907 titem = wmalloc(sizeof(TextureListItem));
1909 titem->title = wstrdup(title);
1910 titem->prop = GetObjectForKey(key);
1911 if (!titem->prop || !WMIsPLArray(titem->prop)) {
1912 /* Maybe also give a error message to stderr that the entry is bad? */
1913 titem->prop = WMCreatePropListFromDescription(defValue);
1914 } else {
1915 WMRetainPropList(titem->prop);
1917 titem->texture = WMGetPropListDescription((WMPropList *) titem->prop, False);
1918 titem->current = 1;
1919 titem->selectedFor = 1 << index;
1921 titem->ispixmap = isPixmap(titem->prop);
1923 titem->preview = renderTexture(WMWidgetScreen(list), titem->prop, TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0);
1925 item = WMAddListItem(list, "");
1926 item->clientData = titem;
1929 static void showData(_Panel * panel)
1931 int i;
1932 const char *str;
1934 str = GetStringForKey("MenuStyle");
1935 if (str && strcasecmp(str, "flat") == 0) {
1936 panel->menuStyle = MSTYLE_FLAT;
1937 } else if (str && strcasecmp(str, "singletexture") == 0) {
1938 panel->menuStyle = MSTYLE_SINGLE;
1939 } else {
1940 panel->menuStyle = MSTYLE_NORMAL;
1943 str = GetStringForKey("TitleJustify");
1944 if (str && strcasecmp(str, "left") == 0) {
1945 panel->titleAlignment = WALeft;
1946 } else if (str && strcasecmp(str, "right") == 0) {
1947 panel->titleAlignment = WARight;
1948 } else {
1949 panel->titleAlignment = WACenter;
1952 for (i = 0; i < wlengthof(colorOptions); i++) {
1953 WMColor *color;
1955 str = GetStringForKey(colorOptions[i].key);
1956 if (!str)
1957 str = colorOptions[i].default_value;
1959 if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) {
1960 color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False);
1963 panel->colors[i] = color;
1965 changeColorPage(panel->colP, panel);
1967 for (i = 0; i < wlengthof(textureOptions); i++) {
1968 setupTextureFor(panel->texLs, textureOptions[i].key,
1969 textureOptions[i].default_value, _(textureOptions[i].label), i);
1970 panel->textureIndex[i] = i;
1972 updatePreviewBox(panel, EVERYTHING);
1974 WMSetButtonSelected(panel->mstyB[panel->menuStyle], True);
1975 WMSetButtonSelected(panel->taliB[panel->titleAlignment], True);
1978 static void storeData(_Panel * panel)
1980 TextureListItem *titem;
1981 WMListItem *item;
1982 int i;
1984 for (i = 0; i < wlengthof(textureOptions); i++) {
1985 item = WMGetListItem(panel->texLs, panel->textureIndex[i]);
1986 titem = (TextureListItem *) item->clientData;
1987 SetObjectForKey(titem->prop, textureOptions[i].key);
1990 for (i = 0; i < 8; i++) {
1991 char *str;
1993 str = WMGetColorRGBDescription(panel->colors[i]);
1995 if (str) {
1996 SetStringForKey(str, colorOptions[i].key);
1997 wfree(str);
2001 switch (panel->menuStyle) {
2002 case MSTYLE_SINGLE:
2003 SetStringForKey("singletexture", "MenuStyle");
2004 break;
2005 case MSTYLE_FLAT:
2006 SetStringForKey("flat", "MenuStyle");
2007 break;
2008 default:
2009 case MSTYLE_NORMAL:
2010 SetStringForKey("normal", "MenuStyle");
2011 break;
2013 switch (panel->titleAlignment) {
2014 case WALeft:
2015 SetStringForKey("left", "TitleJustify");
2016 break;
2017 case WARight:
2018 SetStringForKey("right", "TitleJustify");
2019 break;
2020 default:
2021 case WACenter:
2022 SetStringForKey("center", "TitleJustify");
2023 break;
2027 static void prepareForClose(_Panel * panel)
2029 WMPropList *textureList;
2030 WMPropList *texture;
2031 TextureListItem *titem;
2032 WMListItem *item;
2033 WMUserDefaults *udb = WMGetStandardUserDefaults();
2034 int i;
2036 textureList = WMCreatePLArray(NULL, NULL);
2038 /* store list of textures */
2039 for (i = 7; i < WMGetListNumberOfRows(panel->texLs); i++) {
2040 item = WMGetListItem(panel->texLs, i);
2041 titem = (TextureListItem *) item->clientData;
2043 texture = WMCreatePLArray(WMCreatePLString(titem->title),
2044 WMRetainPropList(titem->prop), WMCreatePLString(titem->path), NULL);
2046 WMAddToPLArray(textureList, texture);
2049 WMSetUDObjectForKey(udb, textureList, "TextureList");
2050 WMReleasePropList(textureList);
2052 /* store list of colors */
2053 textureList = WMCreatePLArray(NULL, NULL);
2054 for (i = 0; i < 24; i++) {
2055 WMColor *color;
2056 char *str;
2058 color = WMGetColorWellColor(panel->sampW[i]);
2060 str = WMGetColorRGBDescription(color);
2061 WMAddToPLArray(textureList, WMCreatePLString(str));
2062 wfree(str);
2064 WMSetUDObjectForKey(udb, textureList, "ColorList");
2065 WMReleasePropList(textureList);
2067 WMSynchronizeUserDefaults(udb);
2070 Panel *InitAppearance(WMWidget *parent)
2072 _Panel *panel;
2074 panel = wmalloc(sizeof(_Panel));
2076 panel->sectionName = _("Appearance Preferences");
2078 panel->description = _("Background texture configuration for windows,\n" "menus and icons.");
2080 panel->parent = parent;
2082 panel->callbacks.createWidgets = createPanel;
2083 panel->callbacks.updateDomain = storeData;
2084 panel->callbacks.prepareForClose = prepareForClose;
2086 AddSection(panel, ICON_FILE);
2088 return panel;
2091 /****************************************************************************/
2093 typedef struct ExtractPanel {
2094 WMWindow *win;
2096 WMLabel *label;
2097 WMList *list;
2099 WMButton *closeB;
2100 WMButton *extrB;
2101 } ExtractPanel;
2103 static void OpenExtractPanelFor(_Panel *panel)
2105 ExtractPanel *epanel;
2106 WMColor *color;
2107 WMFont *font;
2108 WMScreen *scr = WMWidgetScreen(panel->parent);
2110 epanel = wmalloc(sizeof(ExtractPanel));
2111 epanel->win = WMCreatePanelWithStyleForWindow(panel->parent, "extract",
2112 WMTitledWindowMask | WMClosableWindowMask);
2113 WMResizeWidget(epanel->win, 245, 250);
2114 WMSetWindowTitle(epanel->win, _("Extract Texture"));
2116 epanel->label = WMCreateLabel(epanel->win);
2117 WMResizeWidget(epanel->label, 225, 18);
2118 WMMoveWidget(epanel->label, 10, 10);
2119 WMSetLabelTextAlignment(epanel->label, WACenter);
2120 WMSetLabelRelief(epanel->label, WRSunken);
2122 color = WMDarkGrayColor(scr);
2123 WMSetWidgetBackgroundColor(epanel->label, color);
2124 WMReleaseColor(color);
2126 color = WMWhiteColor(scr);
2127 WMSetLabelTextColor(epanel->label, color);
2128 WMReleaseColor(color);
2130 font = WMBoldSystemFontOfSize(scr, 12);
2131 WMSetLabelFont(epanel->label, font);
2132 WMReleaseFont(font);
2134 WMSetLabelText(epanel->label, _("Textures"));
2136 epanel->list = WMCreateList(epanel->win);
2137 WMResizeWidget(epanel->list, 225, 165);
2138 WMMoveWidget(epanel->list, 10, 30);
2140 epanel->closeB = WMCreateCommandButton(epanel->win);
2141 WMResizeWidget(epanel->closeB, 74, 24);
2142 WMMoveWidget(epanel->closeB, 165, 215);
2143 WMSetButtonText(epanel->closeB, _("Close"));
2145 epanel->extrB = WMCreateCommandButton(epanel->win);
2146 WMResizeWidget(epanel->extrB, 74, 24);
2147 WMMoveWidget(epanel->extrB, 80, 215);
2148 WMSetButtonText(epanel->extrB, _("Extract"));
2150 WMMapSubwidgets(epanel->win);
2152 /* take textures from file */
2154 WMRealizeWidget(epanel->win);
2156 WMMapWidget(epanel->win);