WPrefs: Marked args as unused for compiler in WINGs callback code
[wmaker-crm.git] / WPrefs.app / Appearance.c
blob11f90c7fc34f4292a495f93f5fd388f571226f72
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, const char *path);
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 char *textureOptions[] = {
296 "FTitleBack", "(solid, black)", "[Focused]",
297 "UTitleBack", "(solid, gray)", "[Unfocused]",
298 "PTitleBack", "(solid, \"#616161\")", "[Owner of Focused]",
299 "ResizebarBack", "(solid, gray)", "[Resizebar]",
300 "MenuTitleBack", "(solid, black)", "[Menu Title]",
301 "MenuTextBack", "(solid, gray)", "[Menu Item]",
302 "IconBack", "(solid, gray)", "[Icon]"
305 #define RESIZEBAR_BEVEL -1
306 #define MENU_BEVEL -2
308 #define TEXPREV_WIDTH 40
309 #define TEXPREV_HEIGHT 24
311 #define MSTYLE_NORMAL 0
312 #define MSTYLE_SINGLE 1
313 #define MSTYLE_FLAT 2
315 #define FTITLE_COL (1<<0)
316 #define UTITLE_COL (1<<1)
317 #define OTITLE_COL (1<<2)
318 #define MTITLE_COL (1<<3)
319 #define MITEM_COL (1<<4)
320 #define MDISAB_COL (1<<5)
321 #define MHIGH_COL (1<<6)
322 #define MHIGHT_COL (1<<7)
323 #define ICONT_COL (1<<8)
324 #define ICONB_COL (1<<9)
325 #define CLIP_COL (1<<10)
326 #define CCLIP_COL (1<<11)
328 static char *colorOptions[] = {
329 "FTitleColor", "white",
330 "UTitleColor", "black",
331 "PTitleColor", "white",
332 "MenuTitleColor", "white",
333 "MenuTextColor", "black",
334 "MenuDisabledColor", "#616161",
335 "HighlightColor", "white",
336 "HighlightTextColor", "black",
337 "IconTitleColor", "white",
338 "IconTitleBack", "black",
339 "ClipTitleColor", "black",
340 "CClipTitleColor", "#454045"
343 static WMRect previewPositions[] = {
344 #define PFOCUSED 0
345 {{30, 10}, {190, 20}},
346 #define PUNFOCUSED 1
347 {{30, 40}, {190, 20}},
348 #define POWNER 2
349 {{30, 70}, {190, 20}},
350 #define PRESIZEBAR 3
351 {{30, 100}, {190, 9}},
352 #define PMTITLE 4
353 {{30, 120}, {90, 20}},
354 #define PMITEM 5
355 {{30, 140}, {90, 20 * 4}},
356 #define PICON 6
357 {{155, 130}, {64, 64}}
360 #define EVERYTHING 0xff
362 static WMRect previewColorPositions[] = {
363 {{30, 10}, {190, 20}},
364 {{30, 40}, {190, 20}},
365 {{30, 70}, {190, 20}},
366 {{30, 120}, {90, 20}},
367 {{30, 140}, {90, 20}},
368 {{30, 160}, {90, 20}},
369 {{30, 180}, {90, 20}},
370 {{30, 200}, {90, 20}},
371 {{155, 130}, {64, 64}},
372 {{155, 130}, {64, 64}},
373 {{155, 130}, {64, 64}},
374 {{155, 130}, {64, 64}}
377 static void str2rcolor(RContext * rc, const char *name, RColor * color)
379 XColor xcolor;
381 XParseColor(rc->dpy, rc->cmap, name, &xcolor);
383 color->alpha = 255;
384 color->red = xcolor.red >> 8;
385 color->green = xcolor.green >> 8;
386 color->blue = xcolor.blue >> 8;
389 static void dumpRImage(const char *path, RImage * image)
391 FILE *f;
392 int channels = (image->format == RRGBAFormat ? 4 : 3);
394 f = fopen(path, "wb");
395 if (!f) {
396 werror("%s", path);
397 return;
399 fprintf(f, "%02x%02x%1x", image->width, image->height, channels);
401 fwrite(image->data, 1, image->width * image->height * channels, f);
403 fsync(fileno(f));
404 if (fclose(f) < 0) {
405 werror("%s", path);
409 static int isPixmap(WMPropList * prop)
411 WMPropList *p;
412 char *s;
414 p = WMGetFromPLArray(prop, 0);
415 s = WMGetFromPLString(p);
416 if (strcasecmp(&s[1], "pixmap") == 0)
417 return 1;
418 else
419 return 0;
422 /**********************************************************************/
424 static void drawResizebarBevel(RImage * img)
426 RColor light;
427 RColor dark;
428 RColor black;
429 int width = img->width;
430 int height = img->height;
431 int cwidth = 28;
433 black.alpha = 255;
434 black.red = black.green = black.blue = 0;
436 light.alpha = 0;
437 light.red = light.green = light.blue = 80;
439 dark.alpha = 0;
440 dark.red = dark.green = dark.blue = 40;
442 ROperateLine(img, RSubtractOperation, 0, 0, width - 1, 0, &dark);
443 ROperateLine(img, RAddOperation, 0, 1, width - 1, 1, &light);
445 ROperateLine(img, RSubtractOperation, cwidth, 2, cwidth, height - 1, &dark);
446 ROperateLine(img, RAddOperation, cwidth + 1, 2, cwidth + 1, height - 1, &light);
448 ROperateLine(img, RSubtractOperation, width - cwidth - 2, 2, width - cwidth - 2, height - 1, &dark);
449 ROperateLine(img, RAddOperation, width - cwidth - 1, 2, width - cwidth - 1, height - 1, &light);
451 RDrawLine(img, 0, height - 1, width - 1, height - 1, &black);
452 RDrawLine(img, 0, 0, 0, height - 1, &black);
453 RDrawLine(img, width - 1, 0, width - 1, height - 1, &black);
456 static void drawMenuBevel(RImage * img)
458 RColor light, dark, mid;
459 int i;
460 int iheight = img->height / 4;
462 light.alpha = 0;
463 light.red = light.green = light.blue = 80;
465 dark.alpha = 255;
466 dark.red = dark.green = dark.blue = 0;
468 mid.alpha = 0;
469 mid.red = mid.green = mid.blue = 40;
471 for (i = 1; i < 4; i++) {
472 ROperateLine(img, RSubtractOperation, 0, i * iheight - 2, img->width - 1, i * iheight - 2, &mid);
474 RDrawLine(img, 0, i * iheight - 1, img->width - 1, i * iheight - 1, &dark);
476 ROperateLine(img, RAddOperation, 1, i * iheight, img->width - 2, i * iheight, &light);
480 static Pixmap renderTexture(WMScreen * scr, WMPropList * texture, int width, int height, const char *path, int border)
482 char *type;
483 RImage *image = NULL;
484 Pixmap pixmap;
485 RContext *rc = WMScreenRContext(scr);
486 char *str;
487 RColor rcolor;
489 type = WMGetFromPLString(WMGetFromPLArray(texture, 0));
491 if (strcasecmp(type, "solid") == 0) {
493 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
495 str2rcolor(rc, str, &rcolor);
497 image = RCreateImage(width, height, False);
498 RClearImage(image, &rcolor);
499 } else if (strcasecmp(type, "igradient") == 0) {
500 int t1, t2;
501 RColor c1[2], c2[2];
503 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
504 str2rcolor(rc, str, &c1[0]);
505 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
506 str2rcolor(rc, str, &c1[1]);
507 str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
508 t1 = atoi(str);
510 str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
511 str2rcolor(rc, str, &c2[0]);
512 str = WMGetFromPLString(WMGetFromPLArray(texture, 5));
513 str2rcolor(rc, str, &c2[1]);
514 str = WMGetFromPLString(WMGetFromPLArray(texture, 6));
515 t2 = atoi(str);
517 image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2);
518 } else if (strcasecmp(&type[1], "gradient") == 0) {
519 int style;
520 RColor rcolor2;
522 switch (toupper(type[0])) {
523 case 'V':
524 style = RVerticalGradient;
525 break;
526 case 'H':
527 style = RHorizontalGradient;
528 break;
529 default:
530 case 'D':
531 style = RDiagonalGradient;
532 break;
535 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
536 str2rcolor(rc, str, &rcolor);
537 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
538 str2rcolor(rc, str, &rcolor2);
540 image = RRenderGradient(width, height, &rcolor, &rcolor2, style);
541 } else if (strcasecmp(&type[2], "gradient") == 0 && toupper(type[0]) == 'T') {
542 int style;
543 RColor rcolor2;
544 int i;
545 RImage *grad, *timage = NULL;
546 char *path;
548 switch (toupper(type[1])) {
549 case 'V':
550 style = RVerticalGradient;
551 break;
552 case 'H':
553 style = RHorizontalGradient;
554 break;
555 default:
556 case 'D':
557 style = RDiagonalGradient;
558 break;
561 str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
562 str2rcolor(rc, str, &rcolor);
563 str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
564 str2rcolor(rc, str, &rcolor2);
566 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
568 if ((path = wfindfileinarray(GetObjectForKey("PixmapPath"), str)) != NULL)
569 timage = RLoadImage(rc, path, 0);
571 if (!path || !timage) {
572 wwarning("could not load file '%s': %s", path, RMessageForError(RErrorCode));
573 } else {
574 grad = RRenderGradient(width, height, &rcolor, &rcolor2, style);
576 image = RMakeTiledImage(timage, width, height);
577 RReleaseImage(timage);
579 i = atoi(WMGetFromPLString(WMGetFromPLArray(texture, 2)));
581 RCombineImagesWithOpaqueness(image, grad, i);
582 RReleaseImage(grad);
584 } else if (strcasecmp(&type[2], "gradient") == 0 && toupper(type[0]) == 'M') {
585 int style;
586 RColor **colors;
587 int i, j;
589 switch (toupper(type[1])) {
590 case 'V':
591 style = RVerticalGradient;
592 break;
593 case 'H':
594 style = RHorizontalGradient;
595 break;
596 default:
597 case 'D':
598 style = RDiagonalGradient;
599 break;
602 j = WMGetPropListItemCount(texture);
604 if (j > 0) {
605 colors = wmalloc(j * sizeof(RColor *));
607 for (i = 2; i < j; i++) {
608 str = WMGetFromPLString(WMGetFromPLArray(texture, i));
609 colors[i - 2] = wmalloc(sizeof(RColor));
610 str2rcolor(rc, str, colors[i - 2]);
612 colors[i - 2] = NULL;
614 image = RRenderMultiGradient(width, height, colors, style);
616 for (i = 0; colors[i] != NULL; i++)
617 wfree(colors[i]);
618 wfree(colors);
620 } else if (strcasecmp(&type[1], "pixmap") == 0) {
621 RImage *timage = NULL;
622 char *path;
623 RColor color;
625 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
627 if ((path = wfindfileinarray(GetObjectForKey("PixmapPath"), str)) != NULL)
628 timage = RLoadImage(rc, path, 0);
630 if (!path || !timage) {
631 wwarning("could not load file '%s': %s", path ? path : str, RMessageForError(RErrorCode));
632 } else {
633 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
634 str2rcolor(rc, str, &color);
636 switch (toupper(type[0])) {
637 case 'T':
638 image = RMakeTiledImage(timage, width, height);
639 RReleaseImage(timage);
640 timage = image;
641 break;
642 case 'C':
643 image = RMakeCenteredImage(timage, width, height, &color);
644 RReleaseImage(timage);
645 timage = image;
646 break;
647 case 'S':
648 case 'M':
649 image = RScaleImage(timage, width, height);
650 RReleaseImage(timage);
651 timage = image;
652 break;
656 wfree(path);
659 if (!image)
660 return None;
662 if (path) {
663 dumpRImage(path, image);
666 if (border < 0) {
667 if (border == RESIZEBAR_BEVEL) {
668 drawResizebarBevel(image);
669 } else if (border == MENU_BEVEL) {
670 drawMenuBevel(image);
671 RBevelImage(image, RBEV_RAISED2);
673 } else if (border) {
674 RBevelImage(image, border);
677 RConvertImage(rc, image, &pixmap);
678 RReleaseImage(image);
680 return pixmap;
683 static Pixmap renderMenu(_Panel * panel, WMPropList * texture, int width, int iheight)
685 WMScreen *scr = WMWidgetScreen(panel->parent);
686 Display *dpy = WMScreenDisplay(scr);
687 Pixmap pix, tmp;
688 GC gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
689 int i;
691 switch (panel->menuStyle) {
692 case MSTYLE_NORMAL:
693 tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
695 pix = XCreatePixmap(dpy, tmp, width, iheight * 4, WMScreenDepth(scr));
696 for (i = 0; i < 4; i++) {
697 XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight * i);
699 XFreePixmap(dpy, tmp);
700 break;
701 case MSTYLE_SINGLE:
702 pix = renderTexture(scr, texture, width, iheight * 4, NULL, MENU_BEVEL);
703 break;
704 case MSTYLE_FLAT:
705 pix = renderTexture(scr, texture, width, iheight * 4, NULL, RBEV_RAISED2);
706 break;
707 default:
708 pix = None;
710 XFreeGC(dpy, gc);
712 return pix;
715 static void renderPreview(_Panel * panel, GC gc, int part, int relief)
717 WMListItem *item;
718 TextureListItem *titem;
719 Pixmap pix;
720 WMScreen *scr = WMWidgetScreen(panel->box);
722 item = WMGetListItem(panel->texLs, panel->textureIndex[part]);
723 titem = (TextureListItem *) item->clientData;
725 pix = renderTexture(scr, titem->prop,
726 previewPositions[part].size.width, previewPositions[part].size.height, NULL, relief);
728 XCopyArea(WMScreenDisplay(scr), pix, panel->preview, gc, 0, 0,
729 previewPositions[part].size.width,
730 previewPositions[part].size.height, previewPositions[part].pos.x, previewPositions[part].pos.y);
732 XCopyArea(WMScreenDisplay(scr), pix, panel->previewNoText, gc, 0, 0,
733 previewPositions[part].size.width,
734 previewPositions[part].size.height, previewPositions[part].pos.x, previewPositions[part].pos.y);
736 XFreePixmap(WMScreenDisplay(scr), pix);
739 static void updatePreviewBox(_Panel * panel, int elements)
741 WMScreen *scr = WMWidgetScreen(panel->parent);
742 Display *dpy = WMScreenDisplay(scr);
743 Pixmap pix;
744 GC gc;
745 int colorUpdate = 0;
746 WMColor *black = WMBlackColor(scr);
748 gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
750 if (panel->preview == None) {
751 WMColor *color;
752 WMPixmap *p;
754 panel->previewNoText = XCreatePixmap(dpy, WMWidgetXID(panel->parent),
755 240 - 4, 215 - 4, WMScreenDepth(scr));
757 p = WMCreatePixmap(scr, 240 - 4, 215 - 4, WMScreenDepth(scr), False);
758 panel->preview = WMGetPixmapXID(p);
759 WMSetLabelImage(panel->prevL, p);
760 WMReleasePixmap(p);
762 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
763 XFillRectangle(dpy, panel->preview, WMColorGC(color), 0, 0, 240 - 4, 215 - 4);
764 XFillRectangle(dpy, panel->previewNoText, WMColorGC(color), 0, 0, 240 - 4, 215 - 4);
765 WMReleaseColor(color);
768 if (elements & (1 << PFOCUSED)) {
769 renderPreview(panel, gc, PFOCUSED, RBEV_RAISED2);
770 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
771 previewPositions[PFOCUSED].pos.x - 1,
772 previewPositions[PFOCUSED].pos.y - 1,
773 previewPositions[PFOCUSED].size.width, previewPositions[PFOCUSED].size.height);
774 XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black),
775 previewPositions[PFOCUSED].pos.x - 1,
776 previewPositions[PFOCUSED].pos.y - 1,
777 previewPositions[PFOCUSED].size.width, previewPositions[PFOCUSED].size.height);
778 colorUpdate |= FTITLE_COL;
780 if (elements & (1 << PUNFOCUSED)) {
781 renderPreview(panel, gc, PUNFOCUSED, RBEV_RAISED2);
782 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
783 previewPositions[PUNFOCUSED].pos.x - 1,
784 previewPositions[PUNFOCUSED].pos.y - 1,
785 previewPositions[PUNFOCUSED].size.width, previewPositions[PUNFOCUSED].size.height);
786 XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black),
787 previewPositions[PUNFOCUSED].pos.x - 1,
788 previewPositions[PUNFOCUSED].pos.y - 1,
789 previewPositions[PUNFOCUSED].size.width, previewPositions[PUNFOCUSED].size.height);
790 colorUpdate |= UTITLE_COL;
792 if (elements & (1 << POWNER)) {
793 renderPreview(panel, gc, POWNER, RBEV_RAISED2);
794 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
795 previewPositions[POWNER].pos.x - 1,
796 previewPositions[POWNER].pos.y - 1,
797 previewPositions[POWNER].size.width, previewPositions[POWNER].size.height);
798 XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black),
799 previewPositions[POWNER].pos.x - 1,
800 previewPositions[POWNER].pos.y - 1,
801 previewPositions[POWNER].size.width, previewPositions[POWNER].size.height);
802 colorUpdate |= OTITLE_COL;
804 if (elements & (1 << PRESIZEBAR)) {
805 renderPreview(panel, gc, PRESIZEBAR, RESIZEBAR_BEVEL);
807 if (elements & (1 << PMTITLE)) {
808 renderPreview(panel, gc, PMTITLE, RBEV_RAISED2);
809 colorUpdate |= MTITLE_COL;
811 if (elements & (1 << PMITEM)) {
812 WMListItem *item;
813 TextureListItem *titem;
815 item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
816 titem = (TextureListItem *) item->clientData;
818 pix = renderMenu(panel, titem->prop,
819 previewPositions[PMITEM].size.width, previewPositions[PMITEM].size.height / 4);
821 XCopyArea(dpy, pix, panel->preview, gc, 0, 0,
822 previewPositions[PMITEM].size.width,
823 previewPositions[PMITEM].size.height,
824 previewPositions[PMITEM].pos.x, previewPositions[PMITEM].pos.y);
826 XCopyArea(dpy, pix, panel->previewNoText, gc, 0, 0,
827 previewPositions[PMITEM].size.width,
828 previewPositions[PMITEM].size.height,
829 previewPositions[PMITEM].pos.x, previewPositions[PMITEM].pos.y);
831 XFreePixmap(dpy, pix);
833 colorUpdate |= MITEM_COL | MDISAB_COL | MHIGH_COL | MHIGHT_COL;
835 if (elements & (1 << PMITEM | 1 << PMTITLE)) {
836 XDrawLine(dpy, panel->preview, gc, 29, 120, 29, 120 + 20 * 4 + 20);
837 XDrawLine(dpy, panel->preview, gc, 29, 119, 119, 119);
839 XDrawLine(dpy, panel->previewNoText, gc, 29, 120, 29, 120 + 20 * 4 + 20);
840 XDrawLine(dpy, panel->previewNoText, gc, 29, 119, 119, 119);
842 if (elements & (1 << PICON)) {
843 WMListItem *item;
844 TextureListItem *titem;
846 item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
847 titem = (TextureListItem *) item->clientData;
849 renderPreview(panel, gc, PICON, titem->ispixmap ? 0 : RBEV_RAISED3);
851 colorUpdate |= ICONT_COL | ICONB_COL | CLIP_COL | CCLIP_COL;
854 if (colorUpdate)
855 updateColorPreviewBox(panel, colorUpdate);
856 else
857 WMRedisplayWidget(panel->prevL);
859 XFreeGC(dpy, gc);
860 WMReleaseColor(black);
863 static void cancelNewTexture(void *data)
865 _Panel *panel = (_Panel *) data;
867 HideTexturePanel(panel->texturePanel);
870 static char *makeFileName(const char *prefix)
872 char *fname;
874 fname = wstrdup(prefix);
876 while (access(fname, F_OK) == 0) {
877 char buf[30];
879 wfree(fname);
880 sprintf(buf, "%08lx.cache", time(NULL));
881 fname = wstrconcat(prefix, buf);
884 return fname;
887 static void okNewTexture(void *data)
889 _Panel *panel = (_Panel *) data;
890 WMListItem *item;
891 char *name;
892 char *str;
893 WMPropList *prop;
894 TextureListItem *titem;
895 WMScreen *scr = WMWidgetScreen(panel->parent);
897 titem = wmalloc(sizeof(TextureListItem));
899 HideTexturePanel(panel->texturePanel);
901 name = GetTexturePanelTextureName(panel->texturePanel);
903 prop = GetTexturePanelTexture(panel->texturePanel);
905 str = WMGetPropListDescription(prop, False);
907 titem->title = name;
908 titem->prop = prop;
909 titem->texture = str;
910 titem->selectedFor = 0;
912 titem->ispixmap = isPixmap(prop);
914 titem->path = makeFileName(panel->fprefix);
915 titem->preview = renderTexture(scr, prop, TEXPREV_WIDTH, TEXPREV_HEIGHT, titem->path, 0);
917 item = WMAddListItem(panel->texLs, "");
918 item->clientData = titem;
920 WMSetListPosition(panel->texLs, WMGetListNumberOfRows(panel->texLs));
923 static void okEditTexture(void *data)
925 _Panel *panel = (_Panel *) data;
926 WMListItem *item;
927 char *name;
928 char *str;
929 WMPropList *prop;
930 TextureListItem *titem;
932 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
933 titem = (TextureListItem *) item->clientData;
935 HideTexturePanel(panel->texturePanel);
937 if (titem->current) {
938 name = GetTexturePanelTextureName(panel->texturePanel);
940 wfree(titem->title);
941 titem->title = name;
944 prop = GetTexturePanelTexture(panel->texturePanel);
946 str = WMGetPropListDescription(prop, False);
948 WMReleasePropList(titem->prop);
949 titem->prop = prop;
951 titem->ispixmap = isPixmap(prop);
953 wfree(titem->texture);
954 titem->texture = str;
956 XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel->texLs)), titem->preview);
957 titem->preview = renderTexture(WMWidgetScreen(panel->texLs), titem->prop,
958 TEXPREV_WIDTH, TEXPREV_HEIGHT, titem->path, 0);
960 WMRedisplayWidget(panel->texLs);
962 if (titem->selectedFor)
963 updatePreviewBox(panel, titem->selectedFor);
965 changePage(panel->secP, panel);
968 static void editTexture(WMWidget * w, void *data)
970 _Panel *panel = (_Panel *) data;
971 WMListItem *item;
972 TextureListItem *titem;
974 /* Parameter not used, but tell the compiler that it is ok */
975 (void) w;
977 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
978 titem = (TextureListItem *) item->clientData;
980 SetTexturePanelPixmapPath(panel->texturePanel, GetObjectForKey("PixmapPath"));
982 SetTexturePanelTexture(panel->texturePanel, titem->title, titem->prop);
984 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
985 SetTexturePanelOkAction(panel->texturePanel, okEditTexture, panel);
987 ShowTexturePanel(panel->texturePanel);
990 static void newTexture(WMWidget * w, void *data)
992 _Panel *panel = (_Panel *) data;
994 /* Parameter not used, but tell the compiler that it is ok */
995 (void) w;
997 SetTexturePanelPixmapPath(panel->texturePanel, GetObjectForKey("PixmapPath"));
999 SetTexturePanelTexture(panel->texturePanel, "New Texture", NULL);
1001 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
1003 SetTexturePanelOkAction(panel->texturePanel, okNewTexture, panel);
1005 ShowTexturePanel(panel->texturePanel);
1008 static void deleteTexture(WMWidget * w, void *data)
1010 _Panel *panel = (_Panel *) data;
1011 WMListItem *item;
1012 TextureListItem *titem;
1013 int row;
1014 int section;
1016 /* Parameter not used, but tell the compiler that it is ok */
1017 (void) w;
1019 section = WMGetPopUpButtonSelectedItem(panel->secP);
1020 row = WMGetListSelectedItemRow(panel->texLs);
1021 item = WMGetListItem(panel->texLs, row);
1022 titem = (TextureListItem *) item->clientData;
1024 if (titem->selectedFor & (1 << section)) {
1025 TextureListItem *titem2;
1027 panel->textureIndex[section] = section;
1028 item = WMGetListItem(panel->texLs, section);
1029 titem2 = (TextureListItem *) item->clientData;
1030 titem2->selectedFor |= 1 << section;
1033 wfree(titem->title);
1034 wfree(titem->texture);
1035 WMReleasePropList(titem->prop);
1036 if (titem->path) {
1037 if (remove(titem->path) < 0 && errno != ENOENT) {
1038 werror("could not remove file %s", titem->path);
1040 wfree(titem->path);
1043 wfree(titem);
1045 WMRemoveListItem(panel->texLs, row);
1046 WMSetButtonEnabled(panel->delB, False);
1049 static void extractTexture(WMWidget * w, void *data)
1051 _Panel *panel = (_Panel *) data;
1052 char *path;
1053 WMOpenPanel *opanel;
1054 WMScreen *scr = WMWidgetScreen(w);
1056 opanel = WMGetOpenPanel(scr);
1057 WMSetFilePanelCanChooseDirectories(opanel, False);
1058 WMSetFilePanelCanChooseFiles(opanel, True);
1060 if (WMRunModalFilePanelForDirectory(opanel, panel->parent, wgethomedir(), _("Select File"), NULL)) {
1061 path = WMGetFilePanelFileName(opanel);
1063 OpenExtractPanelFor(panel, path);
1065 wfree(path);
1069 static void changePage(WMWidget * w, void *data)
1071 _Panel *panel = (_Panel *) data;
1072 int section;
1073 WMScreen *scr = WMWidgetScreen(panel->box);
1074 RContext *rc = WMScreenRContext(scr);
1075 static WMPoint positions[] = {
1076 {5, 10},
1077 {5, 40},
1078 {5, 70},
1079 {5, 100},
1080 {5, 120},
1081 {5, 160},
1082 {130, 150}
1085 if (w) {
1086 section = WMGetPopUpButtonSelectedItem(panel->secP);
1088 WMSelectListItem(panel->texLs, panel->textureIndex[section]);
1090 WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2);
1093 WMColor *color;
1095 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
1096 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
1097 positions[panel->oldsection].x, positions[panel->oldsection].y, 22, 22);
1098 WMReleaseColor(color);
1100 if (w) {
1101 panel->oldsection = section;
1102 WMDrawPixmap(panel->hand, panel->preview, positions[section].x, positions[section].y);
1104 WMRedisplayWidget(panel->prevL);
1107 static void previewClick(XEvent * event, void *clientData)
1109 _Panel *panel = (_Panel *) clientData;
1110 int i;
1112 switch (panel->oldTabItem) {
1113 case 0:
1114 for (i = 0; i < sizeof(previewPositions) / sizeof(previewPositions[0]); i++) {
1115 if (event->xbutton.x >= previewPositions[i].pos.x
1116 && event->xbutton.y >= previewPositions[i].pos.y
1117 && event->xbutton.x < previewPositions[i].pos.x
1118 + previewPositions[i].size.width
1119 && event->xbutton.y < previewPositions[i].pos.y + previewPositions[i].size.height) {
1121 WMSetPopUpButtonSelectedItem(panel->secP, i);
1122 changePage(panel->secP, panel);
1123 return;
1126 break;
1127 case 1:
1128 for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->colP); i++) {
1129 if (event->xbutton.x >= previewColorPositions[i].pos.x
1130 && event->xbutton.y >= previewColorPositions[i].pos.y
1131 && event->xbutton.x < previewColorPositions[i].pos.x
1132 + previewColorPositions[i].size.width
1133 && event->xbutton.y < previewColorPositions[i].pos.y
1134 + previewColorPositions[i].size.height) {
1136 /* yuck kluge */
1137 if (i == 7)
1138 i = 4;
1140 WMSetPopUpButtonSelectedItem(panel->colP, i);
1141 changeColorPage(panel->colP, panel);
1142 return;
1145 break;
1149 static void textureClick(WMWidget * w, void *data)
1151 _Panel *panel = (_Panel *) data;
1152 int i;
1153 WMListItem *item;
1154 TextureListItem *titem;
1156 /* Parameter not used, but tell the compiler that it is ok */
1157 (void) w;
1159 i = WMGetListSelectedItemRow(panel->texLs);
1161 item = WMGetListItem(panel->texLs, i);
1163 titem = (TextureListItem *) item->clientData;
1165 if (titem->current) {
1166 WMSetButtonEnabled(panel->delB, False);
1167 } else {
1168 WMSetButtonEnabled(panel->delB, True);
1172 static void textureDoubleClick(WMWidget * w, void *data)
1174 _Panel *panel = (_Panel *) data;
1175 int i, section;
1176 WMListItem *item;
1177 TextureListItem *titem;
1179 /* Parameter not used, but tell the compiler that it is ok */
1180 (void) w;
1182 /* unselect old texture */
1183 section = WMGetPopUpButtonSelectedItem(panel->secP);
1185 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
1186 titem = (TextureListItem *) item->clientData;
1187 titem->selectedFor &= ~(1 << section);
1189 /* select new texture */
1190 i = WMGetListSelectedItemRow(panel->texLs);
1192 item = WMGetListItem(panel->texLs, i);
1194 titem = (TextureListItem *) item->clientData;
1196 titem->selectedFor |= 1 << section;
1198 panel->textureIndex[section] = i;
1200 WMRedisplayWidget(panel->texLs);
1202 updatePreviewBox(panel, 1 << section);
1205 static void paintListItem(WMList * lPtr, int index, Drawable d, char *text, int state, WMRect * rect)
1207 _Panel *panel = (_Panel *) WMGetHangedData(lPtr);
1208 WMScreen *scr = WMWidgetScreen(lPtr);
1209 int width, height, x, y;
1210 Display *dpy = WMScreenDisplay(scr);
1211 WMColor *back = (state & WLDSSelected) ? WMWhiteColor(scr) : WMGrayColor(scr);
1212 WMListItem *item;
1213 WMColor *black = WMBlackColor(scr);
1214 TextureListItem *titem;
1216 /* Parameter not used, but tell the compiler that it is ok */
1217 (void) text;
1219 item = WMGetListItem(lPtr, index);
1220 titem = (TextureListItem *) item->clientData;
1221 if (!titem) {
1222 WMReleaseColor(back);
1223 WMReleaseColor(black);
1224 return;
1227 width = rect->size.width;
1228 height = rect->size.height;
1229 x = rect->pos.x;
1230 y = rect->pos.y;
1232 XFillRectangle(dpy, d, WMColorGC(back), x, y, width, height);
1234 if (titem->preview)
1235 XCopyArea(dpy, titem->preview, d, WMColorGC(black), 0, 0,
1236 TEXPREV_WIDTH, TEXPREV_HEIGHT, x + 5, y + 5);
1238 if ((1 << WMGetPopUpButtonSelectedItem(panel->secP)) & titem->selectedFor)
1239 WMDrawPixmap(panel->onLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1240 else if (titem->selectedFor)
1241 WMDrawPixmap(panel->offLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1243 WMDrawString(scr, d, black, panel->boldFont,
1244 x + TEXPREV_WIDTH + 22, y + 2, titem->title, strlen(titem->title));
1246 WMDrawString(scr, d, black, panel->smallFont,
1247 x + TEXPREV_WIDTH + 14, y + 18, titem->texture, strlen(titem->texture));
1249 WMReleaseColor(back);
1250 WMReleaseColor(black);
1253 static Pixmap loadRImage(WMScreen * scr, const char *path)
1255 FILE *f;
1256 RImage *image;
1257 int w, h, d;
1258 Pixmap pixmap;
1260 f = fopen(path, "rb");
1261 if (!f)
1262 return None;
1264 fscanf(f, "%02x%02x%1x", &w, &h, &d);
1266 image = RCreateImage(w, h, d == 4);
1267 fread(image->data, 1, w * h * d, f);
1268 fclose(f);
1270 RConvertImage(WMScreenRContext(scr), image, &pixmap);
1271 RReleaseImage(image);
1273 return pixmap;
1276 static void fillTextureList(WMList * lPtr)
1278 WMPropList *textureList;
1279 WMPropList *texture;
1280 WMUserDefaults *udb = WMGetStandardUserDefaults();
1281 TextureListItem *titem;
1282 WMScreen *scr = WMWidgetScreen(lPtr);
1283 int i;
1285 textureList = WMGetUDObjectForKey(udb, "TextureList");
1286 if (!textureList)
1287 return;
1289 for (i = 0; i < WMGetPropListItemCount(textureList); i++) {
1290 WMListItem *item;
1292 texture = WMGetFromPLArray(textureList, i);
1294 titem = wmalloc(sizeof(TextureListItem));
1296 titem->title = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 0)));
1297 titem->prop = WMRetainPropList(WMGetFromPLArray(texture, 1));
1298 titem->texture = WMGetPropListDescription(titem->prop, False);
1299 titem->selectedFor = 0;
1300 titem->path = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 2)));
1302 titem->preview = loadRImage(scr, titem->path);
1303 if (!titem->preview) {
1304 titem->preview = renderTexture(scr, titem->prop, TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0);
1306 item = WMAddListItem(lPtr, "");
1307 item->clientData = titem;
1311 static void fillColorList(_Panel * panel)
1313 WMColor *color;
1314 WMPropList *list;
1315 WMUserDefaults *udb = WMGetStandardUserDefaults();
1316 WMScreen *scr = WMWidgetScreen(panel->box);
1317 int i;
1319 list = WMGetUDObjectForKey(udb, "ColorList");
1320 if (!list) {
1321 for (i = 0; i < 24; i++) {
1322 color = WMCreateNamedColor(scr, sampleColors[i], False);
1323 if (!color)
1324 continue;
1325 WMSetColorWellColor(panel->sampW[i], color);
1326 WMReleaseColor(color);
1328 } else {
1329 WMPropList *c;
1331 for (i = 0; i < WMIN(24, WMGetPropListItemCount(list)); i++) {
1332 c = WMGetFromPLArray(list, i);
1333 if (!c || !WMIsPLString(c))
1334 continue;
1335 color = WMCreateNamedColor(scr, WMGetFromPLString(c), False);
1336 if (!color)
1337 continue;
1338 WMSetColorWellColor(panel->sampW[i], color);
1339 WMReleaseColor(color);
1344 /*************************************************************************/
1346 static void changeColorPage(WMWidget * w, void *data)
1348 _Panel *panel = (_Panel *) data;
1349 int section;
1350 WMScreen *scr = WMWidgetScreen(panel->box);
1351 RContext *rc = WMScreenRContext(scr);
1352 static WMPoint positions[] = {
1353 {5, 10},
1354 {5, 40},
1355 {5, 70},
1356 {5, 120},
1357 {5, 140},
1358 {5, 160},
1359 {5, 180},
1360 {5, 180},
1361 {130, 140},
1362 {130, 140},
1363 {130, 140},
1364 {130, 140}
1367 if (panel->preview) {
1368 WMColor *color;
1370 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
1371 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
1372 positions[panel->oldcsection].x, positions[panel->oldcsection].y, 22, 22);
1373 WMReleaseColor(color);
1375 if (w) {
1376 section = WMGetPopUpButtonSelectedItem(panel->colP);
1378 panel->oldcsection = section;
1379 if (panel->preview)
1380 WMDrawPixmap(panel->hand, panel->preview, positions[section].x, positions[section].y);
1382 section = WMGetPopUpButtonSelectedItem(panel->colP);
1384 WMSetColorWellColor(panel->colW, panel->colors[section]);
1386 WMRedisplayWidget(panel->prevL);
1389 static void
1390 paintText(WMScreen * scr, Drawable d, WMColor * color, WMFont * font,
1391 int x, int y, int w, int h, WMAlignment align, char *text)
1393 int l = strlen(text);
1395 switch (align) {
1396 case WALeft:
1397 x += 5;
1398 break;
1399 case WARight:
1400 x += w - 5 - WMWidthOfString(font, text, l);
1401 break;
1402 default:
1403 case WACenter:
1404 x += (w - WMWidthOfString(font, text, l)) / 2;
1405 break;
1407 WMDrawString(scr, d, color, font, x, y + (h - WMFontHeight(font)) / 2, text, l);
1410 static void updateColorPreviewBox(_Panel * panel, int elements)
1412 WMScreen *scr = WMWidgetScreen(panel->box);
1413 Display *dpy = WMScreenDisplay(scr);
1414 Pixmap d, pnot;
1415 GC gc;
1417 d = panel->preview;
1418 pnot = panel->previewNoText;
1419 gc = WMColorGC(panel->colors[0]);
1421 if (elements & FTITLE_COL) {
1422 XCopyArea(dpy, pnot, d, gc, 30, 10, 190, 20, 30, 10);
1423 paintText(scr, d, panel->colors[0], panel->boldFont, 30, 10, 190, 20,
1424 panel->titleAlignment, _("Focused Window"));
1426 if (elements & UTITLE_COL) {
1427 XCopyArea(dpy, pnot, d, gc, 30, 40, 190, 20, 30, 40);
1428 paintText(scr, d, panel->colors[1], panel->boldFont, 30, 40, 190, 20,
1429 panel->titleAlignment, _("Unfocused Window"));
1431 if (elements & OTITLE_COL) {
1432 XCopyArea(dpy, pnot, d, gc, 30, 70, 190, 20, 30, 70);
1433 paintText(scr, d, panel->colors[2], panel->boldFont, 30, 70, 190, 20,
1434 panel->titleAlignment, _("Owner of Focused Window"));
1436 if (elements & MTITLE_COL) {
1437 XCopyArea(dpy, pnot, d, gc, 30, 120, 90, 20, 30, 120);
1438 paintText(scr, d, panel->colors[3], panel->boldFont, 30, 120, 90, 20, WALeft, _("Menu Title"));
1440 if (elements & MITEM_COL) {
1441 XCopyArea(dpy, pnot, d, gc, 30, 140, 90, 20, 30, 140);
1442 paintText(scr, d, panel->colors[4], panel->normalFont, 30, 140, 90, 20, WALeft, _("Normal Item"));
1443 XCopyArea(dpy, pnot, d, gc, 30, 200, 90, 20, 30, 200);
1444 paintText(scr, d, panel->colors[4], panel->normalFont, 30, 200, 90, 20, WALeft, _("Normal Item"));
1446 if (elements & MDISAB_COL) {
1447 XCopyArea(dpy, pnot, d, gc, 30, 160, 90, 20, 30, 160);
1448 paintText(scr, d, panel->colors[5], panel->normalFont, 30, 160, 90, 20,
1449 WALeft, _("Disabled Item"));
1451 if (elements & MHIGH_COL) {
1452 XFillRectangle(WMScreenDisplay(scr), d, WMColorGC(panel->colors[6]), 31, 181, 87, 17);
1453 XFillRectangle(WMScreenDisplay(scr), pnot, WMColorGC(panel->colors[6]), 31, 181, 87, 17);
1454 elements |= MHIGHT_COL;
1456 if (elements & MHIGHT_COL) {
1457 XCopyArea(dpy, pnot, d, gc, 30, 180, 90, 20, 30, 180);
1458 paintText(scr, d, panel->colors[7], panel->normalFont, 30, 180, 90, 20, WALeft, _("Highlighted"));
1461 if (elements & ICONT_COL) {
1462 WRITE(_("Focused Window"), panel->colors[8], panel->boldFont,
1463 155, 130, 64);
1465 if (elements & ICONB_COL) {
1466 WRITE(_("Focused Window"), panel->colors[9], panel->boldFont,
1467 0, 0, 30);
1469 if (elements & CLIP_COL) {
1470 WRITE(_("Focused Window"), panel->colors[10], panel->boldFont,
1471 0, 0, 30);
1473 if (elements & CCLIP_COL) {
1474 WRITE(_("Focused Window"), panel->colors[11], panel->boldFont,
1475 0, 0, 30);
1478 WMRedisplayWidget(panel->prevL);
1481 static void colorWellObserver(void *self, WMNotification * n)
1483 _Panel *panel = (_Panel *) self;
1484 int p;
1486 /* Parameter not used, but tell the compiler that it is ok */
1487 (void) n;
1489 p = WMGetPopUpButtonSelectedItem(panel->colP);
1491 WMReleaseColor(panel->colors[p]);
1493 panel->colors[p] = WMRetainColor(WMGetColorWellColor(panel->colW));
1495 updateColorPreviewBox(panel, 1 << p);
1498 static void changedTabItem(struct WMTabViewDelegate *self, WMTabView * tabView, WMTabViewItem * item)
1500 _Panel *panel = self->data;
1501 int i;
1503 /* Parameter not used, but tell the compiler that it is ok */
1504 (void) tabView;
1506 i = WMGetTabViewItemIdentifier(item);
1507 switch (i) {
1508 case 0:
1509 switch (panel->oldTabItem) {
1510 case 1:
1511 changeColorPage(NULL, panel);
1512 break;
1514 changePage(panel->secP, panel);
1515 break;
1516 case 1:
1517 switch (panel->oldTabItem) {
1518 case 0:
1519 changePage(NULL, panel);
1520 break;
1522 changeColorPage(panel->colP, panel);
1523 break;
1524 case 3:
1525 switch (panel->oldTabItem) {
1526 case 0:
1527 changePage(NULL, panel);
1528 break;
1529 case 1:
1530 changeColorPage(NULL, panel);
1531 break;
1533 break;
1536 panel->oldTabItem = i;
1539 /*************************************************************************/
1541 static void menuStyleCallback(WMWidget * self, void *data)
1543 _Panel *panel = (_Panel *) data;
1545 if (self == panel->mstyB[0]) {
1546 panel->menuStyle = MSTYLE_NORMAL;
1547 updatePreviewBox(panel, 1 << PMITEM);
1549 } else if (self == panel->mstyB[1]) {
1550 panel->menuStyle = MSTYLE_SINGLE;
1551 updatePreviewBox(panel, 1 << PMITEM);
1553 } else if (self == panel->mstyB[2]) {
1554 panel->menuStyle = MSTYLE_FLAT;
1555 updatePreviewBox(panel, 1 << PMITEM);
1559 static void titleAlignCallback(WMWidget * self, void *data)
1561 _Panel *panel = (_Panel *) data;
1563 if (self == panel->taliB[0]) {
1564 panel->titleAlignment = WALeft;
1565 updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER);
1567 } else if (self == panel->taliB[1]) {
1568 panel->titleAlignment = WACenter;
1569 updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER);
1571 } else if (self == panel->taliB[2]) {
1572 panel->titleAlignment = WARight;
1573 updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER);
1577 static void createPanel(Panel * p)
1579 _Panel *panel = (_Panel *) p;
1580 WMFont *font;
1581 WMScreen *scr = WMWidgetScreen(panel->parent);
1582 WMTabViewItem *item;
1583 int i;
1584 char *tmp;
1585 Bool ok = True;
1587 panel->fprefix = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
1589 if (access(panel->fprefix, F_OK) != 0) {
1590 if (mkdir(panel->fprefix, 0755) < 0) {
1591 werror("%s", panel->fprefix);
1592 ok = False;
1595 if (ok) {
1596 tmp = wstrconcat(panel->fprefix, "/WPrefs/");
1597 wfree(panel->fprefix);
1598 panel->fprefix = tmp;
1599 if (access(panel->fprefix, F_OK) != 0) {
1600 if (mkdir(panel->fprefix, 0755) < 0) {
1601 werror("%s", panel->fprefix);
1606 panel->smallFont = WMSystemFontOfSize(scr, 10);
1607 panel->normalFont = WMSystemFontOfSize(scr, 12);
1608 panel->boldFont = WMBoldSystemFontOfSize(scr, 12);
1610 panel->onLed = WMCreatePixmapFromXPMData(scr, blueled_xpm);
1611 panel->offLed = WMCreatePixmapFromXPMData(scr, blueled2_xpm);
1612 panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm);
1614 panel->box = WMCreateBox(panel->parent);
1615 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
1617 /* preview box */
1618 panel->prevL = WMCreateLabel(panel->box);
1619 WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT - 20);
1620 WMMoveWidget(panel->prevL, 15, 10);
1621 WMSetLabelRelief(panel->prevL, WRSunken);
1622 WMSetLabelImagePosition(panel->prevL, WIPImageOnly);
1624 WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask, previewClick, panel);
1626 /* tabview */
1628 tabviewDelegate.data = panel;
1630 panel->tabv = WMCreateTabView(panel->box);
1631 WMResizeWidget(panel->tabv, 245, FRAME_HEIGHT - 20);
1632 WMMoveWidget(panel->tabv, 265, 10);
1633 WMSetTabViewDelegate(panel->tabv, &tabviewDelegate);
1635 /*** texture list ***/
1637 panel->texF = WMCreateFrame(panel->box);
1638 WMSetFrameRelief(panel->texF, WRFlat);
1640 item = WMCreateTabViewItemWithIdentifier(0);
1641 WMSetTabViewItemView(item, WMWidgetView(panel->texF));
1642 WMSetTabViewItemLabel(item, _("Texture"));
1644 WMAddItemInTabView(panel->tabv, item);
1646 panel->secP = WMCreatePopUpButton(panel->texF);
1647 WMResizeWidget(panel->secP, 228, 20);
1648 WMMoveWidget(panel->secP, 7, 7);
1649 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window"));
1650 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Unfocused Windows"));
1651 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window's Owner"));
1652 WMAddPopUpButtonItem(panel->secP, _("Window Resizebar"));
1653 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
1654 WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
1655 WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
1656 /* WMAddPopUpButtonItem(panel->secP, _("Workspace Backgrounds"));
1658 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1659 WMSetPopUpButtonAction(panel->secP, changePage, panel);
1661 panel->texLs = WMCreateList(panel->texF);
1662 WMResizeWidget(panel->texLs, 165, 155);
1663 WMMoveWidget(panel->texLs, 70, 33);
1664 WMSetListUserDrawItemHeight(panel->texLs, 35);
1665 WMSetListUserDrawProc(panel->texLs, paintListItem);
1666 WMHangData(panel->texLs, panel);
1667 WMSetListAction(panel->texLs, textureClick, panel);
1668 WMSetListDoubleAction(panel->texLs, textureDoubleClick, panel);
1670 WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
1671 "for the selected item."), WMWidgetView(panel->texLs));
1673 /* command buttons */
1675 font = WMSystemFontOfSize(scr, 10);
1677 panel->newB = WMCreateCommandButton(panel->texF);
1678 WMResizeWidget(panel->newB, 57, 39);
1679 WMMoveWidget(panel->newB, 7, 33);
1680 WMSetButtonFont(panel->newB, font);
1681 WMSetButtonImagePosition(panel->newB, WIPAbove);
1682 WMSetButtonText(panel->newB, _("New"));
1683 WMSetButtonAction(panel->newB, newTexture, panel);
1684 SetButtonAlphaImage(scr, panel->newB, TNEW_FILE, NULL, NULL);
1686 WMSetBalloonTextForView(_("Create a new texture."), WMWidgetView(panel->newB));
1688 panel->ripB = WMCreateCommandButton(panel->texF);
1689 WMResizeWidget(panel->ripB, 57, 39);
1690 WMMoveWidget(panel->ripB, 7, 72);
1691 WMSetButtonFont(panel->ripB, font);
1692 WMSetButtonImagePosition(panel->ripB, WIPAbove);
1693 WMSetButtonText(panel->ripB, _("Extract..."));
1694 WMSetButtonAction(panel->ripB, extractTexture, panel);
1695 SetButtonAlphaImage(scr, panel->ripB, TEXTR_FILE, NULL, NULL);
1697 WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."), WMWidgetView(panel->ripB));
1699 WMSetButtonEnabled(panel->ripB, False);
1701 panel->editB = WMCreateCommandButton(panel->texF);
1702 WMResizeWidget(panel->editB, 57, 39);
1703 WMMoveWidget(panel->editB, 7, 111);
1704 WMSetButtonFont(panel->editB, font);
1705 WMSetButtonImagePosition(panel->editB, WIPAbove);
1706 WMSetButtonText(panel->editB, _("Edit"));
1707 SetButtonAlphaImage(scr, panel->editB, TEDIT_FILE, NULL, NULL);
1708 WMSetButtonAction(panel->editB, editTexture, panel);
1709 WMSetBalloonTextForView(_("Edit the highlighted texture."), WMWidgetView(panel->editB));
1711 panel->delB = WMCreateCommandButton(panel->texF);
1712 WMResizeWidget(panel->delB, 57, 38);
1713 WMMoveWidget(panel->delB, 7, 150);
1714 WMSetButtonFont(panel->delB, font);
1715 WMSetButtonImagePosition(panel->delB, WIPAbove);
1716 WMSetButtonText(panel->delB, _("Delete"));
1717 SetButtonAlphaImage(scr, panel->delB, TDEL_FILE, NULL, NULL);
1718 WMSetButtonEnabled(panel->delB, False);
1719 WMSetButtonAction(panel->delB, deleteTexture, panel);
1720 WMSetBalloonTextForView(_("Delete the highlighted texture."), WMWidgetView(panel->delB));
1722 WMReleaseFont(font);
1724 WMMapSubwidgets(panel->texF);
1726 /*** colors ***/
1727 panel->colF = WMCreateFrame(panel->box);
1728 WMSetFrameRelief(panel->colF, WRFlat);
1730 item = WMCreateTabViewItemWithIdentifier(1);
1731 WMSetTabViewItemView(item, WMWidgetView(panel->colF));
1732 WMSetTabViewItemLabel(item, _("Color"));
1734 WMAddItemInTabView(panel->tabv, item);
1736 panel->colP = WMCreatePopUpButton(panel->colF);
1737 WMResizeWidget(panel->colP, 228, 20);
1738 WMMoveWidget(panel->colP, 7, 7);
1739 WMAddPopUpButtonItem(panel->colP, _("Focused Window Title"));
1740 WMAddPopUpButtonItem(panel->colP, _("Unfocused Window Title"));
1741 WMAddPopUpButtonItem(panel->colP, _("Owner of Focused Window Title"));
1742 WMAddPopUpButtonItem(panel->colP, _("Menu Title"));
1743 WMAddPopUpButtonItem(panel->colP, _("Menu Item Text"));
1744 WMAddPopUpButtonItem(panel->colP, _("Disabled Menu Item Text"));
1745 WMAddPopUpButtonItem(panel->colP, _("Menu Highlight Color"));
1746 WMAddPopUpButtonItem(panel->colP, _("Highlighted Menu Text Color"));
1748 WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title"));
1749 WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title Back"));
1750 WMAddPopUpButtonItem(panel->colP, _("Clip Title"));
1751 WMAddPopUpButtonItem(panel->colP, _("Collapsed Clip Title"));
1754 WMSetPopUpButtonSelectedItem(panel->colP, 0);
1756 WMSetPopUpButtonAction(panel->colP, changeColorPage, panel);
1758 panel->colW = WMCreateColorWell(panel->colF);
1759 WMResizeWidget(panel->colW, 65, 50);
1760 WMMoveWidget(panel->colW, 30, 75);
1761 WMAddNotificationObserver(colorWellObserver, panel, WMColorWellDidChangeNotification, panel->colW);
1763 for (i = 0; i < 4; i++) {
1764 int j;
1765 for (j = 0; j < 6; j++) {
1766 panel->sampW[i + j * 4] = WMCreateColorWell(panel->colF);
1767 WMResizeWidget(panel->sampW[i + j * 4], 22, 22);
1768 WMMoveWidget(panel->sampW[i + j * 4], 130 + i * 22, 40 + j * 22);
1769 WSetColorWellBordered(panel->sampW[i + j * 4], False);
1773 WMMapSubwidgets(panel->colF);
1775 #ifdef unfinished
1776 /*** root bg ***/
1778 panel->bgF = WMCreateFrame(panel->box);
1779 WMSetFrameRelief(panel->bgF, WRFlat);
1781 item = WMCreateTabViewItemWithIdentifier(2);
1782 WMSetTabViewItemView(item, WMWidgetView(panel->bgF));
1783 WMSetTabViewItemLabel(item, _("Background"));
1785 WMAddItemInTabView(panel->tabv, item);
1787 panel->bgprevL = WMCreateLabel(panel->bgF);
1788 WMResizeWidget(panel->bgprevL, 230, 155);
1789 WMMoveWidget(panel->bgprevL, 5, 5);
1790 WMSetLabelRelief(panel->bgprevL, WRSunken);
1792 panel->selbgB = WMCreateCommandButton(panel->bgF);
1793 WMMoveWidget(panel->selbgB, 5, 165);
1794 WMResizeWidget(panel->selbgB, 100, 24);
1795 WMSetButtonText(panel->selbgB, _("Browse..."));
1797 WMMapSubwidgets(panel->bgF);
1798 #endif /* unfinished */
1799 /*** options ***/
1800 panel->optF = WMCreateFrame(panel->box);
1801 WMSetFrameRelief(panel->optF, WRFlat);
1803 item = WMCreateTabViewItemWithIdentifier(3);
1804 WMSetTabViewItemView(item, WMWidgetView(panel->optF));
1805 WMSetTabViewItemLabel(item, _("Options"));
1807 WMAddItemInTabView(panel->tabv, item);
1809 panel->mstyF = WMCreateFrame(panel->optF);
1810 WMResizeWidget(panel->mstyF, 215, 85);
1811 WMMoveWidget(panel->mstyF, 15, 10);
1812 WMSetFrameTitle(panel->mstyF, _("Menu Style"));
1814 for (i = 0; i < 3; i++) {
1815 WMPixmap *icon;
1816 char *path;
1818 panel->mstyB[i] = WMCreateButton(panel->mstyF, WBTOnOff);
1819 WMResizeWidget(panel->mstyB[i], 54, 54);
1820 WMMoveWidget(panel->mstyB[i], 15 + i * 65, 20);
1821 WMSetButtonImagePosition(panel->mstyB[i], WIPImageOnly);
1822 WMSetButtonAction(panel->mstyB[i], menuStyleCallback, panel);
1823 switch (i) {
1824 case 0:
1825 path = LocateImage(MSTYLE1_FILE);
1826 break;
1827 case 1:
1828 path = LocateImage(MSTYLE2_FILE);
1829 break;
1830 case 2:
1831 path = LocateImage(MSTYLE3_FILE);
1832 break;
1834 if (path) {
1835 icon = WMCreatePixmapFromFile(scr, path);
1836 if (icon) {
1837 WMSetButtonImage(panel->mstyB[i], icon);
1838 WMReleasePixmap(icon);
1839 } else {
1840 wwarning(_("could not load icon file %s"), path);
1842 wfree(path);
1845 WMGroupButtons(panel->mstyB[0], panel->mstyB[1]);
1846 WMGroupButtons(panel->mstyB[0], panel->mstyB[2]);
1848 WMMapSubwidgets(panel->mstyF);
1850 panel->taliF = WMCreateFrame(panel->optF);
1851 WMResizeWidget(panel->taliF, 110, 80);
1852 WMMoveWidget(panel->taliF, 15, 100);
1853 WMSetFrameTitle(panel->taliF, _("Title Alignment"));
1855 for (i = 0; i < 3; i++) {
1856 panel->taliB[i] = WMCreateRadioButton(panel->taliF);
1857 WMSetButtonAction(panel->taliB[i], titleAlignCallback, panel);
1858 switch (i) {
1859 case 0:
1860 WMSetButtonText(panel->taliB[i], _("Left"));
1861 break;
1862 case 1:
1863 WMSetButtonText(panel->taliB[i], _("Center"));
1864 break;
1865 case 2:
1866 WMSetButtonText(panel->taliB[i], _("Right"));
1867 break;
1869 WMResizeWidget(panel->taliB[i], 90, 18);
1870 WMMoveWidget(panel->taliB[i], 10, 15 + 20 * i);
1872 WMGroupButtons(panel->taliB[0], panel->taliB[1]);
1873 WMGroupButtons(panel->taliB[0], panel->taliB[2]);
1875 WMMapSubwidgets(panel->taliF);
1877 WMMapSubwidgets(panel->optF);
1879 /**/ WMRealizeWidget(panel->box);
1880 WMMapSubwidgets(panel->box);
1882 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1884 showData(panel);
1886 changePage(panel->secP, panel);
1888 fillTextureList(panel->texLs);
1890 fillColorList(panel);
1892 panel->texturePanel = CreateTexturePanel(panel->parent);
1895 static void setupTextureFor(WMList * list, const char *key, char *defValue, const char *title, int index)
1897 WMListItem *item;
1898 TextureListItem *titem;
1900 titem = wmalloc(sizeof(TextureListItem));
1902 titem->title = wstrdup(title);
1903 titem->prop = GetObjectForKey(key);
1904 if (!titem->prop || !WMIsPLArray(titem->prop)) {
1905 /* Maybe also give a error message to stderr that the entry is bad? */
1906 titem->prop = WMCreatePropListFromDescription(defValue);
1907 } else {
1908 WMRetainPropList(titem->prop);
1910 titem->texture = WMGetPropListDescription((WMPropList *) titem->prop, False);
1911 titem->current = 1;
1912 titem->selectedFor = 1 << index;
1914 titem->ispixmap = isPixmap(titem->prop);
1916 titem->preview = renderTexture(WMWidgetScreen(list), titem->prop, TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0);
1918 item = WMAddListItem(list, "");
1919 item->clientData = titem;
1922 static void showData(_Panel * panel)
1924 int i;
1925 char *str;
1927 str = GetStringForKey("MenuStyle");
1928 if (str && strcasecmp(str, "flat") == 0) {
1929 panel->menuStyle = MSTYLE_FLAT;
1930 } else if (str && strcasecmp(str, "singletexture") == 0) {
1931 panel->menuStyle = MSTYLE_SINGLE;
1932 } else {
1933 panel->menuStyle = MSTYLE_NORMAL;
1936 str = GetStringForKey("TitleJustify");
1937 if (str && strcasecmp(str, "left") == 0) {
1938 panel->titleAlignment = WALeft;
1939 } else if (str && strcasecmp(str, "right") == 0) {
1940 panel->titleAlignment = WARight;
1941 } else {
1942 panel->titleAlignment = WACenter;
1945 for (i = 0; i < sizeof(colorOptions) / (2 * sizeof(char *)); i++) {
1946 WMColor *color;
1948 str = GetStringForKey(colorOptions[i * 2]);
1949 if (!str)
1950 str = colorOptions[i * 2 + 1];
1952 if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) {
1953 color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False);
1956 panel->colors[i] = color;
1958 changeColorPage(panel->colP, panel);
1960 for (i = 0; i < sizeof(textureOptions) / (3 * sizeof(char *)); i++) {
1961 setupTextureFor(panel->texLs, textureOptions[i * 3],
1962 textureOptions[i * 3 + 1], textureOptions[i * 3 + 2], i);
1963 panel->textureIndex[i] = i;
1965 updatePreviewBox(panel, EVERYTHING);
1967 WMSetButtonSelected(panel->mstyB[panel->menuStyle], True);
1968 WMSetButtonSelected(panel->taliB[panel->titleAlignment], True);
1971 static void storeData(_Panel * panel)
1973 TextureListItem *titem;
1974 WMListItem *item;
1975 int i;
1977 for (i = 0; i < sizeof(textureOptions) / (sizeof(char *) * 3); i++) {
1978 item = WMGetListItem(panel->texLs, panel->textureIndex[i]);
1979 titem = (TextureListItem *) item->clientData;
1980 SetObjectForKey(titem->prop, textureOptions[i * 3]);
1983 for (i = 0; i < 8; i++) {
1984 char *str;
1986 str = WMGetColorRGBDescription(panel->colors[i]);
1988 if (str) {
1989 SetStringForKey(str, colorOptions[i * 2]);
1990 wfree(str);
1994 switch (panel->menuStyle) {
1995 case MSTYLE_SINGLE:
1996 SetStringForKey("singletexture", "MenuStyle");
1997 break;
1998 case MSTYLE_FLAT:
1999 SetStringForKey("flat", "MenuStyle");
2000 break;
2001 default:
2002 case MSTYLE_NORMAL:
2003 SetStringForKey("normal", "MenuStyle");
2004 break;
2006 switch (panel->titleAlignment) {
2007 case WALeft:
2008 SetStringForKey("left", "TitleJustify");
2009 break;
2010 case WARight:
2011 SetStringForKey("right", "TitleJustify");
2012 break;
2013 default:
2014 case WACenter:
2015 SetStringForKey("center", "TitleJustify");
2016 break;
2020 static void prepareForClose(_Panel * panel)
2022 WMPropList *textureList;
2023 WMPropList *texture;
2024 TextureListItem *titem;
2025 WMListItem *item;
2026 WMUserDefaults *udb = WMGetStandardUserDefaults();
2027 int i;
2029 textureList = WMCreatePLArray(NULL, NULL);
2031 /* store list of textures */
2032 for (i = 7; i < WMGetListNumberOfRows(panel->texLs); i++) {
2033 item = WMGetListItem(panel->texLs, i);
2034 titem = (TextureListItem *) item->clientData;
2036 texture = WMCreatePLArray(WMCreatePLString(titem->title),
2037 WMRetainPropList(titem->prop), WMCreatePLString(titem->path), NULL);
2039 WMAddToPLArray(textureList, texture);
2042 WMSetUDObjectForKey(udb, textureList, "TextureList");
2043 WMReleasePropList(textureList);
2045 /* store list of colors */
2046 textureList = WMCreatePLArray(NULL, NULL);
2047 for (i = 0; i < 24; i++) {
2048 WMColor *color;
2049 char *str;
2051 color = WMGetColorWellColor(panel->sampW[i]);
2053 str = WMGetColorRGBDescription(color);
2054 WMAddToPLArray(textureList, WMCreatePLString(str));
2055 wfree(str);
2057 WMSetUDObjectForKey(udb, textureList, "ColorList");
2058 WMReleasePropList(textureList);
2060 WMSynchronizeUserDefaults(udb);
2063 Panel *InitAppearance(WMScreen *scr, WMWidget *parent)
2065 _Panel *panel;
2067 panel = wmalloc(sizeof(_Panel));
2069 panel->sectionName = _("Appearance Preferences");
2071 panel->description = _("Background texture configuration for windows,\n" "menus and icons.");
2073 panel->parent = parent;
2075 panel->callbacks.createWidgets = createPanel;
2076 panel->callbacks.updateDomain = storeData;
2077 panel->callbacks.prepareForClose = prepareForClose;
2079 AddSection(panel, ICON_FILE);
2081 return panel;
2084 /****************************************************************************/
2086 typedef struct ExtractPanel {
2087 WMWindow *win;
2089 WMLabel *label;
2090 WMList *list;
2092 WMButton *closeB;
2093 WMButton *extrB;
2094 } ExtractPanel;
2096 static void OpenExtractPanelFor(_Panel * panel, const char *path)
2098 ExtractPanel *epanel;
2099 WMColor *color;
2100 WMFont *font;
2101 WMScreen *scr = WMWidgetScreen(panel->parent);
2103 epanel = wmalloc(sizeof(ExtractPanel));
2104 epanel->win = WMCreatePanelWithStyleForWindow(panel->parent, "extract",
2105 WMTitledWindowMask | WMClosableWindowMask);
2106 WMResizeWidget(epanel->win, 245, 250);
2107 WMSetWindowTitle(epanel->win, _("Extract Texture"));
2109 epanel->label = WMCreateLabel(epanel->win);
2110 WMResizeWidget(epanel->label, 225, 18);
2111 WMMoveWidget(epanel->label, 10, 10);
2112 WMSetLabelTextAlignment(epanel->label, WACenter);
2113 WMSetLabelRelief(epanel->label, WRSunken);
2115 color = WMDarkGrayColor(scr);
2116 WMSetWidgetBackgroundColor(epanel->label, color);
2117 WMReleaseColor(color);
2119 color = WMWhiteColor(scr);
2120 WMSetLabelTextColor(epanel->label, color);
2121 WMReleaseColor(color);
2123 font = WMBoldSystemFontOfSize(scr, 12);
2124 WMSetLabelFont(epanel->label, font);
2125 WMReleaseFont(font);
2127 WMSetLabelText(epanel->label, _("Textures"));
2129 epanel->list = WMCreateList(epanel->win);
2130 WMResizeWidget(epanel->list, 225, 165);
2131 WMMoveWidget(epanel->list, 10, 30);
2133 epanel->closeB = WMCreateCommandButton(epanel->win);
2134 WMResizeWidget(epanel->closeB, 74, 24);
2135 WMMoveWidget(epanel->closeB, 165, 215);
2136 WMSetButtonText(epanel->closeB, _("Close"));
2138 epanel->extrB = WMCreateCommandButton(epanel->win);
2139 WMResizeWidget(epanel->extrB, 74, 24);
2140 WMMoveWidget(epanel->extrB, 80, 215);
2141 WMSetButtonText(epanel->extrB, _("Extract"));
2143 WMMapSubwidgets(epanel->win);
2145 /* take textures from file */
2147 WMRealizeWidget(epanel->win);
2149 WMMapWidget(epanel->win);