Option to disable clip title
[wmaker-crm.git] / WPrefs.app / Appearance.c
blob9107514df17f853898d9c1e872cb59d2ed1ea828
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
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 * USA.
23 #include "WPrefs.h"
25 #include <unistd.h>
26 #include <errno.h>
27 #include <ctype.h>
28 #include <time.h>
29 #include <sys/stat.h>
30 #include <sys/types.h>
31 #include <fcntl.h>
32 #include <unistd.h>
34 #include "TexturePanel.h"
36 typedef struct _Panel {
37 WMBox *box;
38 char *sectionName;
40 char *description;
42 CallbackRec callbacks;
44 WMWidget *parent;
46 WMLabel *prevL;
48 WMTabView *tabv;
50 /* texture list */
51 WMFrame *texF;
52 WMList *texLs;
54 WMPopUpButton *secP;
56 WMButton *newB;
57 WMButton *editB;
58 WMButton *ripB;
59 WMButton *delB;
61 /* text color */
62 WMFrame *colF;
64 WMPopUpButton *colP;
65 WMColor *colors[14];
67 WMColorWell *colW;
69 WMColorWell *sampW[24];
71 /* options */
72 WMFrame *optF;
74 WMFrame *mstyF;
75 WMButton *mstyB[3];
77 WMFrame *taliF;
78 WMButton *taliB[3];
80 /* root bg */
81 WMFrame *bgF;
83 WMLabel *bgprevL;
84 WMButton *selbgB;
86 WMPopUpButton *modeB[3];
88 /* */
90 int textureIndex[8];
92 WMFont *smallFont;
93 WMFont *normalFont;
94 WMFont *boldFont;
96 TexturePanel *texturePanel;
98 WMPixmap *onLed;
99 WMPixmap *offLed;
100 WMPixmap *hand;
102 int oldsection;
103 int oldcsection;
105 char oldTabItem;
107 int menuStyle;
109 int titleAlignment;
111 Pixmap preview;
112 Pixmap previewNoText;
114 char *fprefix;
115 } _Panel;
117 typedef struct {
118 char *title;
119 char *texture;
120 WMPropList *prop;
121 Pixmap preview;
123 char *path;
125 char selectedFor;
126 unsigned current:1;
127 unsigned ispixmap:1;
128 } TextureListItem;
130 static void updateColorPreviewBox(_Panel * panel, int elements);
132 static void showData(_Panel * panel);
134 static void changePage(WMWidget * w, void *data);
136 static void changeColorPage(WMWidget * w, void *data);
138 static void OpenExtractPanelFor(_Panel * panel, char *path);
140 static void changedTabItem(struct WMTabViewDelegate *self, WMTabView * tabView, WMTabViewItem * item);
142 static WMTabViewDelegate tabviewDelegate = {
143 NULL,
144 NULL, /* didChangeNumberOfItems */
145 changedTabItem, /* didSelectItem */
146 NULL, /* shouldSelectItem */
147 NULL /* willSelectItem */
150 #define ICON_FILE "appearance"
152 #define TNEW_FILE "tnew"
153 #define TDEL_FILE "tdel"
154 #define TEDIT_FILE "tedit"
155 #define TEXTR_FILE "textr"
157 #define MSTYLE1_FILE "msty1"
158 #define MSTYLE2_FILE "msty2"
159 #define MSTYLE3_FILE "msty3"
161 /* XPM */
162 static char *blueled_xpm[] = {
163 "8 8 17 1",
164 " c None",
165 ". c #020204",
166 "+ c #16B6FC",
167 "@ c #176AFC",
168 "# c #163AFC",
169 "$ c #72D2FC",
170 "% c #224CF4",
171 "& c #76D6FC",
172 "* c #16AAFC",
173 "= c #CEE9FC",
174 "- c #229EFC",
175 "; c #164CFC",
176 "> c #FAFEFC",
177 ", c #2482FC",
178 "' c #1652FC",
179 ") c #1E76FC",
180 "! c #1A60FC",
181 " .... ",
182 " .=>-@. ",
183 ".=>$@@'.",
184 ".=$@!;;.",
185 ".!@*+!#.",
186 ".#'*+*,.",
187 " .@)@,. ",
188 " .... "
191 /* XPM */
192 static char *blueled2_xpm[] = {
193 /* width height num_colors chars_per_pixel */
194 " 8 8 17 1",
195 /* colors */
196 ". c None",
197 "# c #090909",
198 "a c #4b63a4",
199 "b c #011578",
200 "c c #264194",
201 "d c #04338c",
202 "e c #989dac",
203 "f c #011a7c",
204 "g c #465c9c",
205 "h c #03278a",
206 "i c #6175ac",
207 "j c #011e74",
208 "k c #043a90",
209 "l c #042f94",
210 "m c #0933a4",
211 "n c #022184",
212 "o c #012998",
213 /* pixels */
214 "..####..",
215 ".#aimn#.",
216 "#aechnf#",
217 "#gchnjf#",
218 "#jndknb#",
219 "#bjdddl#",
220 ".#nono#.",
221 "..####.."
224 /* XPM */
225 static char *hand_xpm[] = {
226 "22 21 19 1",
227 " c None",
228 ". c #030305",
229 "+ c #7F7F7E",
230 "@ c #B5B5B6",
231 "# c #C5C5C6",
232 "$ c #969697",
233 "% c #FDFDFB",
234 "& c #F2F2F4",
235 "* c #E5E5E4",
236 "= c #ECECEC",
237 "- c #DCDCDC",
238 "; c #D2D2D0",
239 "> c #101010",
240 ", c #767674",
241 "' c #676767",
242 ") c #535355",
243 "! c #323234",
244 "~ c #3E3C56",
245 "{ c #333147",
246 " ",
247 " ..... ",
248 " ..+@##$. ",
249 " .%%%&@.......... ",
250 " .%*%%&#%%%%%%%%%$. ",
251 " .*#%%%%%%%%%&&&&==. ",
252 " .-%%%%%%%%%=*-;;;#$. ",
253 " .-%%%%%%%%&..>..... ",
254 " >-%%%%%%%%%*#+. ",
255 " >-%%%%%%%%%*@,. ",
256 " >#%%%%%%%%%*@'. ",
257 " >$&&%%%%%%=... ",
258 " .+@@;=&%%&;$,> ",
259 " .',$@####$+). ",
260 " .!',+$++,'. ",
261 " ..>>>>>. ",
262 " ",
263 " ~~{{{~~ ",
264 " {{{{{{{{{{{ ",
265 " ~~{{{~~ ",
269 static char *sampleColors[] = {
270 "black",
271 "#292929",
272 "#525252",
273 "#848484",
274 "#adadad",
275 "#d6d6d6",
276 "white",
277 "#d6d68c",
278 "#d6a57b",
279 "#8cd68c",
280 "#8cd6ce",
281 "#d68c8c",
282 "#8c9cd6",
283 "#bd86d6",
284 "#d68cbd",
285 "#d64a4a",
286 "#4a5ad6",
287 "#4ad6ce",
288 "#4ad65a",
289 "#ced64a",
290 "#d6844a",
291 "#8ad631",
292 "#ce29c6",
293 "#ce2973",
294 "black"
297 static char *textureOptions[] = {
298 "FTitleBack", "(solid, black)", "[Focused]",
299 "UTitleBack", "(solid, gray)", "[Unfocused]",
300 "PTitleBack", "(solid, \"#616161\")", "[Owner of Focused]",
301 "ResizebarBack", "(solid, gray)", "[Resizebar]",
302 "MenuTitleBack", "(solid, black)", "[Menu Title]",
303 "MenuTextBack", "(solid, gray)", "[Menu Item]",
304 "IconBack", "(solid, gray)", "[Icon]"
307 #define RESIZEBAR_BEVEL -1
308 #define MENU_BEVEL -2
310 #define TEXPREV_WIDTH 40
311 #define TEXPREV_HEIGHT 24
313 #define MSTYLE_NORMAL 0
314 #define MSTYLE_SINGLE 1
315 #define MSTYLE_FLAT 2
317 #define FTITLE_COL (1<<0)
318 #define UTITLE_COL (1<<1)
319 #define OTITLE_COL (1<<2)
320 #define MTITLE_COL (1<<3)
321 #define MITEM_COL (1<<4)
322 #define MDISAB_COL (1<<5)
323 #define MHIGH_COL (1<<6)
324 #define MHIGHT_COL (1<<7)
325 #define ICONT_COL (1<<8)
326 #define ICONB_COL (1<<9)
327 #define CLIP_COL (1<<10)
328 #define CCLIP_COL (1<<11)
330 static char *colorOptions[] = {
331 "FTitleColor", "white",
332 "UTitleColor", "black",
333 "PTitleColor", "white",
334 "MenuTitleColor", "white",
335 "MenuTextColor", "black",
336 "MenuDisabledColor", "#616161",
337 "HighlightColor", "white",
338 "HighlightTextColor", "black",
339 "IconTitleColor", "white",
340 "IconTitleBack", "black",
341 "ClipTitleColor", "black",
342 "CClipTitleColor", "#454045"
345 static WMRect previewPositions[] = {
346 #define PFOCUSED 0
347 {{30, 10}, {190, 20}},
348 #define PUNFOCUSED 1
349 {{30, 40}, {190, 20}},
350 #define POWNER 2
351 {{30, 70}, {190, 20}},
352 #define PRESIZEBAR 3
353 {{30, 100}, {190, 9}},
354 #define PMTITLE 4
355 {{30, 120}, {90, 20}},
356 #define PMITEM 5
357 {{30, 140}, {90, 20 * 4}},
358 #define PICON 6
359 {{155, 130}, {64, 64}}
362 #define EVERYTHING 0xff
364 static WMRect previewColorPositions[] = {
365 {{30, 10}, {190, 20}},
366 {{30, 40}, {190, 20}},
367 {{30, 70}, {190, 20}},
368 {{30, 120}, {90, 20}},
369 {{30, 140}, {90, 20}},
370 {{30, 160}, {90, 20}},
371 {{30, 180}, {90, 20}},
372 {{30, 200}, {90, 20}},
373 {{155, 130}, {64, 64}},
374 {{155, 130}, {64, 64}},
375 {{155, 130}, {64, 64}},
376 {{155, 130}, {64, 64}}
379 static void str2rcolor(RContext * rc, char *name, RColor * color)
381 XColor xcolor;
383 XParseColor(rc->dpy, rc->cmap, name, &xcolor);
385 color->alpha = 255;
386 color->red = xcolor.red >> 8;
387 color->green = xcolor.green >> 8;
388 color->blue = xcolor.blue >> 8;
391 static void dumpRImage(char *path, RImage * image)
393 FILE *f;
394 int channels = (image->format == RRGBAFormat ? 4 : 3);
396 f = fopen(path, "wb");
397 if (!f) {
398 wsyserror(path);
399 return;
401 fprintf(f, "%02x%02x%1x", image->width, image->height, channels);
403 fwrite(image->data, 1, image->width * image->height * channels, f);
405 fsync(fileno(f));
406 if (fclose(f) < 0) {
407 wsyserror(path);
411 static int isPixmap(WMPropList * prop)
413 WMPropList *p;
414 char *s;
416 p = WMGetFromPLArray(prop, 0);
417 s = WMGetFromPLString(p);
418 if (strcasecmp(&s[1], "pixmap") == 0)
419 return 1;
420 else
421 return 0;
424 /**********************************************************************/
426 static void drawResizebarBevel(RImage * img)
428 RColor light;
429 RColor dark;
430 RColor black;
431 int width = img->width;
432 int height = img->height;
433 int cwidth = 28;
435 black.alpha = 255;
436 black.red = black.green = black.blue = 0;
438 light.alpha = 0;
439 light.red = light.green = light.blue = 80;
441 dark.alpha = 0;
442 dark.red = dark.green = dark.blue = 40;
444 ROperateLine(img, RSubtractOperation, 0, 0, width - 1, 0, &dark);
445 ROperateLine(img, RAddOperation, 0, 1, width - 1, 1, &light);
447 ROperateLine(img, RSubtractOperation, cwidth, 2, cwidth, height - 1, &dark);
448 ROperateLine(img, RAddOperation, cwidth + 1, 2, cwidth + 1, height - 1, &light);
450 ROperateLine(img, RSubtractOperation, width - cwidth - 2, 2, width - cwidth - 2, height - 1, &dark);
451 ROperateLine(img, RAddOperation, width - cwidth - 1, 2, width - cwidth - 1, height - 1, &light);
453 RDrawLine(img, 0, height - 1, width - 1, height - 1, &black);
454 RDrawLine(img, 0, 0, 0, height - 1, &black);
455 RDrawLine(img, width - 1, 0, width - 1, height - 1, &black);
458 static void drawMenuBevel(RImage * img)
460 RColor light, dark, mid;
461 int i;
462 int iheight = img->height / 4;
464 light.alpha = 0;
465 light.red = light.green = light.blue = 80;
467 dark.alpha = 255;
468 dark.red = dark.green = dark.blue = 0;
470 mid.alpha = 0;
471 mid.red = mid.green = mid.blue = 40;
473 for (i = 1; i < 4; i++) {
474 ROperateLine(img, RSubtractOperation, 0, i * iheight - 2, img->width - 1, i * iheight - 2, &mid);
476 RDrawLine(img, 0, i * iheight - 1, img->width - 1, i * iheight - 1, &dark);
478 ROperateLine(img, RAddOperation, 1, i * iheight, img->width - 2, i * iheight, &light);
482 static Pixmap renderTexture(WMScreen * scr, WMPropList * texture, int width, int height, char *path, int border)
484 char *type;
485 RImage *image = NULL;
486 Pixmap pixmap;
487 RContext *rc = WMScreenRContext(scr);
488 char *str;
489 RColor rcolor;
491 type = WMGetFromPLString(WMGetFromPLArray(texture, 0));
493 if (strcasecmp(type, "solid") == 0) {
495 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
497 str2rcolor(rc, str, &rcolor);
499 image = RCreateImage(width, height, False);
500 RClearImage(image, &rcolor);
501 } else if (strcasecmp(type, "igradient") == 0) {
502 int t1, t2;
503 RColor c1[2], c2[2];
505 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
506 str2rcolor(rc, str, &c1[0]);
507 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
508 str2rcolor(rc, str, &c1[1]);
509 str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
510 t1 = atoi(str);
512 str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
513 str2rcolor(rc, str, &c2[0]);
514 str = WMGetFromPLString(WMGetFromPLArray(texture, 5));
515 str2rcolor(rc, str, &c2[1]);
516 str = WMGetFromPLString(WMGetFromPLArray(texture, 6));
517 t2 = atoi(str);
519 image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2);
520 } else if (strcasecmp(&type[1], "gradient") == 0) {
521 int style;
522 RColor rcolor2;
524 switch (toupper(type[0])) {
525 case 'V':
526 style = RVerticalGradient;
527 break;
528 case 'H':
529 style = RHorizontalGradient;
530 break;
531 default:
532 case 'D':
533 style = RDiagonalGradient;
534 break;
537 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
538 str2rcolor(rc, str, &rcolor);
539 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
540 str2rcolor(rc, str, &rcolor2);
542 image = RRenderGradient(width, height, &rcolor, &rcolor2, style);
543 } else if (strcasecmp(&type[2], "gradient") == 0 && toupper(type[0]) == 'T') {
544 int style;
545 RColor rcolor2;
546 int i;
547 RImage *grad, *timage = NULL;
548 char *path;
550 switch (toupper(type[1])) {
551 case 'V':
552 style = RVerticalGradient;
553 break;
554 case 'H':
555 style = RHorizontalGradient;
556 break;
557 default:
558 case 'D':
559 style = RDiagonalGradient;
560 break;
563 str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
564 str2rcolor(rc, str, &rcolor);
565 str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
566 str2rcolor(rc, str, &rcolor2);
568 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
570 if ((path = wfindfileinarray(GetObjectForKey("PixmapPath"), str)) != NULL)
571 timage = RLoadImage(rc, path, 0);
573 if (!path || !timage) {
574 wwarning("could not load file '%s': %s", path, RMessageForError(RErrorCode));
575 } else {
576 grad = RRenderGradient(width, height, &rcolor, &rcolor2, style);
578 image = RMakeTiledImage(timage, width, height);
579 RReleaseImage(timage);
581 i = atoi(WMGetFromPLString(WMGetFromPLArray(texture, 2)));
583 RCombineImagesWithOpaqueness(image, grad, i);
584 RReleaseImage(grad);
586 } else if (strcasecmp(&type[2], "gradient") == 0 && toupper(type[0]) == 'M') {
587 int style;
588 RColor **colors;
589 int i, j;
591 switch (toupper(type[1])) {
592 case 'V':
593 style = RVerticalGradient;
594 break;
595 case 'H':
596 style = RHorizontalGradient;
597 break;
598 default:
599 case 'D':
600 style = RDiagonalGradient;
601 break;
604 j = WMGetPropListItemCount(texture);
606 if (j > 0) {
607 colors = wmalloc(j * sizeof(RColor *));
609 for (i = 2; i < j; i++) {
610 str = WMGetFromPLString(WMGetFromPLArray(texture, i));
611 colors[i - 2] = wmalloc(sizeof(RColor));
612 str2rcolor(rc, str, colors[i - 2]);
614 colors[i - 2] = NULL;
616 image = RRenderMultiGradient(width, height, colors, style);
618 for (i = 0; colors[i] != NULL; i++)
619 wfree(colors[i]);
620 wfree(colors);
622 } else if (strcasecmp(&type[1], "pixmap") == 0) {
623 RImage *timage = NULL;
624 char *path;
625 RColor color;
627 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
629 if ((path = wfindfileinarray(GetObjectForKey("PixmapPath"), str)) != NULL)
630 timage = RLoadImage(rc, path, 0);
632 if (!path || !timage) {
633 wwarning("could not load file '%s': %s", path ? path : str, RMessageForError(RErrorCode));
634 } else {
635 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
636 str2rcolor(rc, str, &color);
638 switch (toupper(type[0])) {
639 case 'T':
640 image = RMakeTiledImage(timage, width, height);
641 RReleaseImage(timage);
642 timage = image;
643 break;
644 case 'C':
645 image = RMakeCenteredImage(timage, width, height, &color);
646 RReleaseImage(timage);
647 timage = image;
648 break;
649 case 'S':
650 case 'M':
651 image = RScaleImage(timage, width, height);
652 RReleaseImage(timage);
653 timage = image;
654 break;
658 wfree(path);
661 if (!image)
662 return None;
664 if (path) {
665 dumpRImage(path, image);
668 if (border < 0) {
669 if (border == RESIZEBAR_BEVEL) {
670 drawResizebarBevel(image);
671 } else if (border == MENU_BEVEL) {
672 drawMenuBevel(image);
673 RBevelImage(image, RBEV_RAISED2);
675 } else if (border) {
676 RBevelImage(image, border);
679 RConvertImage(rc, image, &pixmap);
680 RReleaseImage(image);
682 return pixmap;
685 static Pixmap renderMenu(_Panel * panel, WMPropList * texture, int width, int iheight)
687 WMScreen *scr = WMWidgetScreen(panel->parent);
688 Display *dpy = WMScreenDisplay(scr);
689 Pixmap pix, tmp;
690 GC gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
691 int i;
693 switch (panel->menuStyle) {
694 case MSTYLE_NORMAL:
695 tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
697 pix = XCreatePixmap(dpy, tmp, width, iheight * 4, WMScreenDepth(scr));
698 for (i = 0; i < 4; i++) {
699 XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight * i);
701 XFreePixmap(dpy, tmp);
702 break;
703 case MSTYLE_SINGLE:
704 pix = renderTexture(scr, texture, width, iheight * 4, NULL, MENU_BEVEL);
705 break;
706 case MSTYLE_FLAT:
707 pix = renderTexture(scr, texture, width, iheight * 4, NULL, RBEV_RAISED2);
708 break;
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(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));
898 memset(titem, 0, sizeof(TextureListItem));
900 HideTexturePanel(panel->texturePanel);
902 name = GetTexturePanelTextureName(panel->texturePanel);
904 prop = GetTexturePanelTexture(panel->texturePanel);
906 str = WMGetPropListDescription(prop, False);
908 titem->title = name;
909 titem->prop = prop;
910 titem->texture = str;
911 titem->selectedFor = 0;
913 titem->ispixmap = isPixmap(prop);
915 titem->path = makeFileName(panel->fprefix);
916 titem->preview = renderTexture(scr, prop, TEXPREV_WIDTH, TEXPREV_HEIGHT, titem->path, 0);
918 item = WMAddListItem(panel->texLs, "");
919 item->clientData = titem;
921 WMSetListPosition(panel->texLs, WMGetListNumberOfRows(panel->texLs));
924 static void okEditTexture(void *data)
926 _Panel *panel = (_Panel *) data;
927 WMListItem *item;
928 char *name;
929 char *str;
930 WMPropList *prop;
931 TextureListItem *titem;
933 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
934 titem = (TextureListItem *) item->clientData;
936 HideTexturePanel(panel->texturePanel);
938 if (titem->current) {
939 name = GetTexturePanelTextureName(panel->texturePanel);
941 wfree(titem->title);
942 titem->title = name;
945 prop = GetTexturePanelTexture(panel->texturePanel);
947 str = WMGetPropListDescription(prop, False);
949 WMReleasePropList(titem->prop);
950 titem->prop = prop;
952 titem->ispixmap = isPixmap(prop);
954 wfree(titem->texture);
955 titem->texture = str;
957 XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel->texLs)), titem->preview);
958 titem->preview = renderTexture(WMWidgetScreen(panel->texLs), titem->prop,
959 TEXPREV_WIDTH, TEXPREV_HEIGHT, titem->path, 0);
961 WMRedisplayWidget(panel->texLs);
963 if (titem->selectedFor)
964 updatePreviewBox(panel, titem->selectedFor);
966 changePage(panel->secP, panel);
969 static void editTexture(WMWidget * w, void *data)
971 _Panel *panel = (_Panel *) data;
972 WMListItem *item;
973 TextureListItem *titem;
975 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
976 titem = (TextureListItem *) item->clientData;
978 SetTexturePanelPixmapPath(panel->texturePanel, GetObjectForKey("PixmapPath"));
980 SetTexturePanelTexture(panel->texturePanel, titem->title, titem->prop);
982 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
983 SetTexturePanelOkAction(panel->texturePanel, okEditTexture, panel);
985 ShowTexturePanel(panel->texturePanel);
988 static void newTexture(WMWidget * w, void *data)
990 _Panel *panel = (_Panel *) data;
992 SetTexturePanelPixmapPath(panel->texturePanel, GetObjectForKey("PixmapPath"));
994 SetTexturePanelTexture(panel->texturePanel, "New Texture", NULL);
996 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
998 SetTexturePanelOkAction(panel->texturePanel, okNewTexture, panel);
1000 ShowTexturePanel(panel->texturePanel);
1003 static void deleteTexture(WMWidget * w, void *data)
1005 _Panel *panel = (_Panel *) data;
1006 WMListItem *item;
1007 TextureListItem *titem;
1008 int row;
1009 int section;
1011 section = WMGetPopUpButtonSelectedItem(panel->secP);
1012 row = WMGetListSelectedItemRow(panel->texLs);
1013 item = WMGetListItem(panel->texLs, row);
1014 titem = (TextureListItem *) item->clientData;
1016 if (titem->selectedFor & (1 << section)) {
1017 TextureListItem *titem2;
1019 panel->textureIndex[section] = section;
1020 item = WMGetListItem(panel->texLs, section);
1021 titem2 = (TextureListItem *) item->clientData;
1022 titem2->selectedFor |= 1 << section;
1025 wfree(titem->title);
1026 wfree(titem->texture);
1027 WMReleasePropList(titem->prop);
1028 if (titem->path) {
1029 if (remove(titem->path) < 0 && errno != ENOENT) {
1030 wsyserror("could not remove file %s", titem->path);
1032 wfree(titem->path);
1035 wfree(titem);
1037 WMRemoveListItem(panel->texLs, row);
1038 WMSetButtonEnabled(panel->delB, False);
1041 static void extractTexture(WMWidget * w, void *data)
1043 _Panel *panel = (_Panel *) data;
1044 char *path;
1045 WMOpenPanel *opanel;
1046 WMScreen *scr = WMWidgetScreen(w);
1048 opanel = WMGetOpenPanel(scr);
1049 WMSetFilePanelCanChooseDirectories(opanel, False);
1050 WMSetFilePanelCanChooseFiles(opanel, True);
1052 if (WMRunModalFilePanelForDirectory(opanel, panel->parent, wgethomedir(), _("Select File"), NULL)) {
1053 path = WMGetFilePanelFileName(opanel);
1055 OpenExtractPanelFor(panel, path);
1057 wfree(path);
1061 static void changePage(WMWidget * w, void *data)
1063 _Panel *panel = (_Panel *) data;
1064 int section;
1065 WMListItem *item;
1066 TextureListItem *titem;
1067 WMScreen *scr = WMWidgetScreen(panel->box);
1068 RContext *rc = WMScreenRContext(scr);
1069 static WMPoint positions[] = {
1070 {5, 10},
1071 {5, 40},
1072 {5, 70},
1073 {5, 100},
1074 {5, 120},
1075 {5, 160},
1076 {130, 150}
1079 if (w) {
1080 section = WMGetPopUpButtonSelectedItem(panel->secP);
1082 WMSelectListItem(panel->texLs, panel->textureIndex[section]);
1084 WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2);
1086 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
1088 titem = (TextureListItem *) item->clientData;
1091 WMColor *color;
1093 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
1094 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
1095 positions[panel->oldsection].x, positions[panel->oldsection].y, 22, 22);
1096 WMReleaseColor(color);
1098 if (w) {
1099 panel->oldsection = section;
1100 WMDrawPixmap(panel->hand, panel->preview, positions[section].x, positions[section].y);
1102 WMRedisplayWidget(panel->prevL);
1105 static void previewClick(XEvent * event, void *clientData)
1107 _Panel *panel = (_Panel *) clientData;
1108 int i;
1110 switch (panel->oldTabItem) {
1111 case 0:
1112 for (i = 0; i < sizeof(previewPositions) / sizeof(WMRect); i++) {
1113 if (event->xbutton.x >= previewPositions[i].pos.x
1114 && event->xbutton.y >= previewPositions[i].pos.y
1115 && event->xbutton.x < previewPositions[i].pos.x
1116 + previewPositions[i].size.width
1117 && event->xbutton.y < previewPositions[i].pos.y + previewPositions[i].size.height) {
1119 WMSetPopUpButtonSelectedItem(panel->secP, i);
1120 changePage(panel->secP, panel);
1121 return;
1124 break;
1125 case 1:
1126 for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->colP); i++) {
1127 if (event->xbutton.x >= previewColorPositions[i].pos.x
1128 && event->xbutton.y >= previewColorPositions[i].pos.y
1129 && event->xbutton.x < previewColorPositions[i].pos.x
1130 + previewColorPositions[i].size.width
1131 && event->xbutton.y < previewColorPositions[i].pos.y
1132 + previewColorPositions[i].size.height) {
1134 /* yuck kluge */
1135 if (i == 7)
1136 i = 4;
1138 WMSetPopUpButtonSelectedItem(panel->colP, i);
1139 changeColorPage(panel->colP, panel);
1140 return;
1143 break;
1147 static void textureClick(WMWidget * w, void *data)
1149 _Panel *panel = (_Panel *) data;
1150 int i;
1151 WMListItem *item;
1152 TextureListItem *titem;
1154 i = WMGetListSelectedItemRow(panel->texLs);
1156 item = WMGetListItem(panel->texLs, i);
1158 titem = (TextureListItem *) item->clientData;
1160 if (titem->current) {
1161 WMSetButtonEnabled(panel->delB, False);
1162 } else {
1163 WMSetButtonEnabled(panel->delB, True);
1167 static void textureDoubleClick(WMWidget * w, void *data)
1169 _Panel *panel = (_Panel *) data;
1170 int i, section;
1171 WMListItem *item;
1172 TextureListItem *titem;
1174 /* unselect old texture */
1175 section = WMGetPopUpButtonSelectedItem(panel->secP);
1177 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
1178 titem = (TextureListItem *) item->clientData;
1179 titem->selectedFor &= ~(1 << section);
1181 /* select new texture */
1182 i = WMGetListSelectedItemRow(panel->texLs);
1184 item = WMGetListItem(panel->texLs, i);
1186 titem = (TextureListItem *) item->clientData;
1188 titem->selectedFor |= 1 << section;
1190 panel->textureIndex[section] = i;
1192 WMRedisplayWidget(panel->texLs);
1194 updatePreviewBox(panel, 1 << section);
1197 static void paintListItem(WMList * lPtr, int index, Drawable d, char *text, int state, WMRect * rect)
1199 _Panel *panel = (_Panel *) WMGetHangedData(lPtr);
1200 WMScreen *scr = WMWidgetScreen(lPtr);
1201 int width, height, x, y;
1202 Display *dpy = WMScreenDisplay(scr);
1203 WMColor *back = (state & WLDSSelected) ? WMWhiteColor(scr) : WMGrayColor(scr);
1204 WMListItem *item;
1205 WMColor *black = WMBlackColor(scr);
1206 TextureListItem *titem;
1208 item = WMGetListItem(lPtr, index);
1209 titem = (TextureListItem *) item->clientData;
1210 if (!titem) {
1211 WMReleaseColor(back);
1212 WMReleaseColor(black);
1213 return;
1216 width = rect->size.width;
1217 height = rect->size.height;
1218 x = rect->pos.x;
1219 y = rect->pos.y;
1221 XFillRectangle(dpy, d, WMColorGC(back), x, y, width, height);
1223 if (titem->preview)
1224 XCopyArea(dpy, titem->preview, d, WMColorGC(black), 0, 0,
1225 TEXPREV_WIDTH, TEXPREV_HEIGHT, x + 5, y + 5);
1227 if ((1 << WMGetPopUpButtonSelectedItem(panel->secP)) & titem->selectedFor)
1228 WMDrawPixmap(panel->onLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1229 else if (titem->selectedFor)
1230 WMDrawPixmap(panel->offLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1232 WMDrawString(scr, d, black, panel->boldFont,
1233 x + TEXPREV_WIDTH + 22, y + 2, titem->title, strlen(titem->title));
1235 WMDrawString(scr, d, black, panel->smallFont,
1236 x + TEXPREV_WIDTH + 14, y + 18, titem->texture, strlen(titem->texture));
1238 WMReleaseColor(back);
1239 WMReleaseColor(black);
1242 static Pixmap loadRImage(WMScreen * scr, char *path)
1244 FILE *f;
1245 RImage *image;
1246 int w, h, d;
1247 Pixmap pixmap;
1249 f = fopen(path, "rb");
1250 if (!f)
1251 return None;
1253 fscanf(f, "%02x%02x%1x", &w, &h, &d);
1255 image = RCreateImage(w, h, d == 4);
1256 fread(image->data, 1, w * h * d, f);
1257 fclose(f);
1259 RConvertImage(WMScreenRContext(scr), image, &pixmap);
1260 RReleaseImage(image);
1262 return pixmap;
1265 static void fillTextureList(WMList * lPtr)
1267 WMPropList *textureList;
1268 WMPropList *texture;
1269 WMUserDefaults *udb = WMGetStandardUserDefaults();
1270 TextureListItem *titem;
1271 WMScreen *scr = WMWidgetScreen(lPtr);
1272 int i;
1274 textureList = WMGetUDObjectForKey(udb, "TextureList");
1275 if (!textureList)
1276 return;
1278 for (i = 0; i < WMGetPropListItemCount(textureList); i++) {
1279 WMListItem *item;
1281 texture = WMGetFromPLArray(textureList, i);
1283 titem = wmalloc(sizeof(TextureListItem));
1284 memset(titem, 0, sizeof(TextureListItem));
1286 titem->title = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 0)));
1287 titem->prop = WMRetainPropList(WMGetFromPLArray(texture, 1));
1288 titem->texture = WMGetPropListDescription(titem->prop, False);
1289 titem->selectedFor = 0;
1290 titem->path = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 2)));
1292 titem->preview = loadRImage(scr, titem->path);
1293 if (!titem->preview) {
1294 titem->preview = renderTexture(scr, titem->prop, TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0);
1296 item = WMAddListItem(lPtr, "");
1297 item->clientData = titem;
1301 static void fillColorList(_Panel * panel)
1303 WMColor *color;
1304 WMPropList *list;
1305 WMUserDefaults *udb = WMGetStandardUserDefaults();
1306 WMScreen *scr = WMWidgetScreen(panel->box);
1307 int i;
1309 list = WMGetUDObjectForKey(udb, "ColorList");
1310 if (!list) {
1311 for (i = 0; i < 24; i++) {
1312 color = WMCreateNamedColor(scr, sampleColors[i], False);
1313 if (!color)
1314 continue;
1315 WMSetColorWellColor(panel->sampW[i], color);
1316 WMReleaseColor(color);
1318 } else {
1319 WMPropList *c;
1321 for (i = 0; i < WMIN(24, WMGetPropListItemCount(list)); i++) {
1322 c = WMGetFromPLArray(list, i);
1323 if (!c || !WMIsPLString(c))
1324 continue;
1325 color = WMCreateNamedColor(scr, WMGetFromPLString(c), False);
1326 if (!color)
1327 continue;
1328 WMSetColorWellColor(panel->sampW[i], color);
1329 WMReleaseColor(color);
1334 /*************************************************************************/
1336 static void changeColorPage(WMWidget * w, void *data)
1338 _Panel *panel = (_Panel *) data;
1339 int section;
1340 WMScreen *scr = WMWidgetScreen(panel->box);
1341 RContext *rc = WMScreenRContext(scr);
1342 static WMPoint positions[] = {
1343 {5, 10},
1344 {5, 40},
1345 {5, 70},
1346 {5, 120},
1347 {5, 140},
1348 {5, 160},
1349 {5, 180},
1350 {5, 180},
1351 {130, 140},
1352 {130, 140},
1353 {130, 140},
1354 {130, 140}
1357 if (panel->preview) {
1358 WMColor *color;
1360 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
1361 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
1362 positions[panel->oldcsection].x, positions[panel->oldcsection].y, 22, 22);
1363 WMReleaseColor(color);
1365 if (w) {
1366 section = WMGetPopUpButtonSelectedItem(panel->colP);
1368 panel->oldcsection = section;
1369 if (panel->preview)
1370 WMDrawPixmap(panel->hand, panel->preview, positions[section].x, positions[section].y);
1372 section = WMGetPopUpButtonSelectedItem(panel->colP);
1374 WMSetColorWellColor(panel->colW, panel->colors[section]);
1376 WMRedisplayWidget(panel->prevL);
1379 static void
1380 paintText(WMScreen * scr, Drawable d, WMColor * color, WMFont * font,
1381 int x, int y, int w, int h, WMAlignment align, char *text)
1383 int l = strlen(text);
1385 switch (align) {
1386 case WALeft:
1387 x += 5;
1388 break;
1389 case WARight:
1390 x += w - 5 - WMWidthOfString(font, text, l);
1391 break;
1392 default:
1393 case WACenter:
1394 x += (w - WMWidthOfString(font, text, l)) / 2;
1395 break;
1397 WMDrawString(scr, d, color, font, x, y + (h - WMFontHeight(font)) / 2, text, l);
1400 static void updateColorPreviewBox(_Panel * panel, int elements)
1402 WMScreen *scr = WMWidgetScreen(panel->box);
1403 Display *dpy = WMScreenDisplay(scr);
1404 Pixmap d, pnot;
1405 GC gc;
1407 d = panel->preview;
1408 pnot = panel->previewNoText;
1409 gc = WMColorGC(panel->colors[0]);
1411 if (elements & FTITLE_COL) {
1412 XCopyArea(dpy, pnot, d, gc, 30, 10, 190, 20, 30, 10);
1413 paintText(scr, d, panel->colors[0], panel->boldFont, 30, 10, 190, 20,
1414 panel->titleAlignment, _("Focused Window"));
1416 if (elements & UTITLE_COL) {
1417 XCopyArea(dpy, pnot, d, gc, 30, 40, 190, 20, 30, 40);
1418 paintText(scr, d, panel->colors[1], panel->boldFont, 30, 40, 190, 20,
1419 panel->titleAlignment, _("Unfocused Window"));
1421 if (elements & OTITLE_COL) {
1422 XCopyArea(dpy, pnot, d, gc, 30, 70, 190, 20, 30, 70);
1423 paintText(scr, d, panel->colors[2], panel->boldFont, 30, 70, 190, 20,
1424 panel->titleAlignment, _("Owner of Focused Window"));
1426 if (elements & MTITLE_COL) {
1427 XCopyArea(dpy, pnot, d, gc, 30, 120, 90, 20, 30, 120);
1428 paintText(scr, d, panel->colors[3], panel->boldFont, 30, 120, 90, 20, WALeft, _("Menu Title"));
1430 if (elements & MITEM_COL) {
1431 XCopyArea(dpy, pnot, d, gc, 30, 140, 90, 20, 30, 140);
1432 paintText(scr, d, panel->colors[4], panel->normalFont, 30, 140, 90, 20, WALeft, _("Normal Item"));
1433 XCopyArea(dpy, pnot, d, gc, 30, 200, 90, 20, 30, 200);
1434 paintText(scr, d, panel->colors[4], panel->normalFont, 30, 200, 90, 20, WALeft, _("Normal Item"));
1436 if (elements & MDISAB_COL) {
1437 XCopyArea(dpy, pnot, d, gc, 30, 160, 90, 20, 30, 160);
1438 paintText(scr, d, panel->colors[5], panel->normalFont, 30, 160, 90, 20,
1439 WALeft, _("Disabled Item"));
1441 if (elements & MHIGH_COL) {
1442 XFillRectangle(WMScreenDisplay(scr), d, WMColorGC(panel->colors[6]), 31, 181, 87, 17);
1443 XFillRectangle(WMScreenDisplay(scr), pnot, WMColorGC(panel->colors[6]), 31, 181, 87, 17);
1444 elements |= MHIGHT_COL;
1446 if (elements & MHIGHT_COL) {
1447 XCopyArea(dpy, pnot, d, gc, 30, 180, 90, 20, 30, 180);
1448 paintText(scr, d, panel->colors[7], panel->normalFont, 30, 180, 90, 20, WALeft, _("Highlighted"));
1451 if (elements & ICONT_COL) {
1452 WRITE(_("Focused Window"), panel->colors[8], panel->boldFont,
1453 155, 130, 64);
1455 if (elements & ICONB_COL) {
1456 WRITE(_("Focused Window"), panel->colors[9], panel->boldFont,
1457 0, 0, 30);
1459 if (elements & CLIP_COL) {
1460 WRITE(_("Focused Window"), panel->colors[10], panel->boldFont,
1461 0, 0, 30);
1463 if (elements & CCLIP_COL) {
1464 WRITE(_("Focused Window"), panel->colors[11], panel->boldFont,
1465 0, 0, 30);
1468 WMRedisplayWidget(panel->prevL);
1471 static void colorWellObserver(void *self, WMNotification * n)
1473 _Panel *panel = (_Panel *) self;
1474 int p;
1476 p = WMGetPopUpButtonSelectedItem(panel->colP);
1478 WMReleaseColor(panel->colors[p]);
1480 panel->colors[p] = WMRetainColor(WMGetColorWellColor(panel->colW));
1482 updateColorPreviewBox(panel, 1 << p);
1485 static void changedTabItem(struct WMTabViewDelegate *self, WMTabView * tabView, WMTabViewItem * item)
1487 _Panel *panel = self->data;
1488 int i;
1490 i = WMGetTabViewItemIdentifier(item);
1491 switch (i) {
1492 case 0:
1493 switch (panel->oldTabItem) {
1494 case 1:
1495 changeColorPage(NULL, panel);
1496 break;
1498 changePage(panel->secP, panel);
1499 break;
1500 case 1:
1501 switch (panel->oldTabItem) {
1502 case 0:
1503 changePage(NULL, panel);
1504 break;
1506 changeColorPage(panel->colP, panel);
1507 break;
1508 case 3:
1509 switch (panel->oldTabItem) {
1510 case 0:
1511 changePage(NULL, panel);
1512 break;
1513 case 1:
1514 changeColorPage(NULL, panel);
1515 break;
1517 break;
1520 panel->oldTabItem = i;
1523 /*************************************************************************/
1525 static void menuStyleCallback(WMWidget * self, void *data)
1527 _Panel *panel = (_Panel *) data;
1529 if (self == panel->mstyB[0]) {
1530 panel->menuStyle = MSTYLE_NORMAL;
1531 updatePreviewBox(panel, 1 << PMITEM);
1533 } else if (self == panel->mstyB[1]) {
1534 panel->menuStyle = MSTYLE_SINGLE;
1535 updatePreviewBox(panel, 1 << PMITEM);
1537 } else if (self == panel->mstyB[2]) {
1538 panel->menuStyle = MSTYLE_FLAT;
1539 updatePreviewBox(panel, 1 << PMITEM);
1543 static void titleAlignCallback(WMWidget * self, void *data)
1545 _Panel *panel = (_Panel *) data;
1547 if (self == panel->taliB[0]) {
1548 panel->titleAlignment = WALeft;
1549 updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER);
1551 } else if (self == panel->taliB[1]) {
1552 panel->titleAlignment = WACenter;
1553 updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER);
1555 } else if (self == panel->taliB[2]) {
1556 panel->titleAlignment = WARight;
1557 updatePreviewBox(panel, 1 << PFOCUSED | 1 << PUNFOCUSED | 1 << POWNER);
1561 static void createPanel(Panel * p)
1563 _Panel *panel = (_Panel *) p;
1564 WMFont *font;
1565 WMScreen *scr = WMWidgetScreen(panel->parent);
1566 WMTabViewItem *item;
1567 int i;
1568 char *tmp;
1569 Bool ok = True;
1571 panel->fprefix = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
1573 if (access(panel->fprefix, F_OK) != 0) {
1574 if (mkdir(panel->fprefix, 0755) < 0) {
1575 wsyserror(panel->fprefix);
1576 ok = False;
1579 if (ok) {
1580 tmp = wstrconcat(panel->fprefix, "/WPrefs/");
1581 wfree(panel->fprefix);
1582 panel->fprefix = tmp;
1583 if (access(panel->fprefix, F_OK) != 0) {
1584 if (mkdir(panel->fprefix, 0755) < 0) {
1585 wsyserror(panel->fprefix);
1590 panel->smallFont = WMSystemFontOfSize(scr, 10);
1591 panel->normalFont = WMSystemFontOfSize(scr, 12);
1592 panel->boldFont = WMBoldSystemFontOfSize(scr, 12);
1594 panel->onLed = WMCreatePixmapFromXPMData(scr, blueled_xpm);
1595 panel->offLed = WMCreatePixmapFromXPMData(scr, blueled2_xpm);
1596 panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm);
1598 panel->box = WMCreateBox(panel->parent);
1599 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
1601 /* preview box */
1602 panel->prevL = WMCreateLabel(panel->box);
1603 WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT - 20);
1604 WMMoveWidget(panel->prevL, 15, 10);
1605 WMSetLabelRelief(panel->prevL, WRSunken);
1606 WMSetLabelImagePosition(panel->prevL, WIPImageOnly);
1608 WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask, previewClick, panel);
1610 /* tabview */
1612 tabviewDelegate.data = panel;
1614 panel->tabv = WMCreateTabView(panel->box);
1615 WMResizeWidget(panel->tabv, 245, FRAME_HEIGHT - 20);
1616 WMMoveWidget(panel->tabv, 265, 10);
1617 WMSetTabViewDelegate(panel->tabv, &tabviewDelegate);
1619 /*** texture list ***/
1621 panel->texF = WMCreateFrame(panel->box);
1622 WMSetFrameRelief(panel->texF, WRFlat);
1624 item = WMCreateTabViewItemWithIdentifier(0);
1625 WMSetTabViewItemView(item, WMWidgetView(panel->texF));
1626 WMSetTabViewItemLabel(item, _("Texture"));
1628 WMAddItemInTabView(panel->tabv, item);
1630 panel->secP = WMCreatePopUpButton(panel->texF);
1631 WMResizeWidget(panel->secP, 228, 20);
1632 WMMoveWidget(panel->secP, 7, 7);
1633 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window"));
1634 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Unfocused Windows"));
1635 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window's Owner"));
1636 WMAddPopUpButtonItem(panel->secP, _("Window Resizebar"));
1637 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
1638 WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
1639 WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
1640 /* WMAddPopUpButtonItem(panel->secP, _("Workspace Backgrounds"));
1642 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1643 WMSetPopUpButtonAction(panel->secP, changePage, panel);
1645 panel->texLs = WMCreateList(panel->texF);
1646 WMResizeWidget(panel->texLs, 165, 155);
1647 WMMoveWidget(panel->texLs, 70, 33);
1648 WMSetListUserDrawItemHeight(panel->texLs, 35);
1649 WMSetListUserDrawProc(panel->texLs, paintListItem);
1650 WMHangData(panel->texLs, panel);
1651 WMSetListAction(panel->texLs, textureClick, panel);
1652 WMSetListDoubleAction(panel->texLs, textureDoubleClick, panel);
1654 WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
1655 "for the selected item."), WMWidgetView(panel->texLs));
1657 /* command buttons */
1659 font = WMSystemFontOfSize(scr, 10);
1661 panel->newB = WMCreateCommandButton(panel->texF);
1662 WMResizeWidget(panel->newB, 57, 39);
1663 WMMoveWidget(panel->newB, 7, 33);
1664 WMSetButtonFont(panel->newB, font);
1665 WMSetButtonImagePosition(panel->newB, WIPAbove);
1666 WMSetButtonText(panel->newB, _("New"));
1667 WMSetButtonAction(panel->newB, newTexture, panel);
1668 SetButtonAlphaImage(scr, panel->newB, TNEW_FILE, NULL, NULL);
1670 WMSetBalloonTextForView(_("Create a new texture."), WMWidgetView(panel->newB));
1672 panel->ripB = WMCreateCommandButton(panel->texF);
1673 WMResizeWidget(panel->ripB, 57, 39);
1674 WMMoveWidget(panel->ripB, 7, 72);
1675 WMSetButtonFont(panel->ripB, font);
1676 WMSetButtonImagePosition(panel->ripB, WIPAbove);
1677 WMSetButtonText(panel->ripB, _("Extract..."));
1678 WMSetButtonAction(panel->ripB, extractTexture, panel);
1679 SetButtonAlphaImage(scr, panel->ripB, TEXTR_FILE, NULL, NULL);
1681 WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."), WMWidgetView(panel->ripB));
1683 WMSetButtonEnabled(panel->ripB, False);
1685 panel->editB = WMCreateCommandButton(panel->texF);
1686 WMResizeWidget(panel->editB, 57, 39);
1687 WMMoveWidget(panel->editB, 7, 111);
1688 WMSetButtonFont(panel->editB, font);
1689 WMSetButtonImagePosition(panel->editB, WIPAbove);
1690 WMSetButtonText(panel->editB, _("Edit"));
1691 SetButtonAlphaImage(scr, panel->editB, TEDIT_FILE, NULL, NULL);
1692 WMSetButtonAction(panel->editB, editTexture, panel);
1693 WMSetBalloonTextForView(_("Edit the highlighted texture."), WMWidgetView(panel->editB));
1695 panel->delB = WMCreateCommandButton(panel->texF);
1696 WMResizeWidget(panel->delB, 57, 38);
1697 WMMoveWidget(panel->delB, 7, 150);
1698 WMSetButtonFont(panel->delB, font);
1699 WMSetButtonImagePosition(panel->delB, WIPAbove);
1700 WMSetButtonText(panel->delB, _("Delete"));
1701 SetButtonAlphaImage(scr, panel->delB, TDEL_FILE, NULL, NULL);
1702 WMSetButtonEnabled(panel->delB, False);
1703 WMSetButtonAction(panel->delB, deleteTexture, panel);
1704 WMSetBalloonTextForView(_("Delete the highlighted texture."), WMWidgetView(panel->delB));
1706 WMReleaseFont(font);
1708 WMMapSubwidgets(panel->texF);
1710 /*** colors ***/
1711 panel->colF = WMCreateFrame(panel->box);
1712 WMSetFrameRelief(panel->colF, WRFlat);
1714 item = WMCreateTabViewItemWithIdentifier(1);
1715 WMSetTabViewItemView(item, WMWidgetView(panel->colF));
1716 WMSetTabViewItemLabel(item, _("Color"));
1718 WMAddItemInTabView(panel->tabv, item);
1720 panel->colP = WMCreatePopUpButton(panel->colF);
1721 WMResizeWidget(panel->colP, 228, 20);
1722 WMMoveWidget(panel->colP, 7, 7);
1723 WMAddPopUpButtonItem(panel->colP, _("Focused Window Title"));
1724 WMAddPopUpButtonItem(panel->colP, _("Unfocused Window Title"));
1725 WMAddPopUpButtonItem(panel->colP, _("Owner of Focused Window Title"));
1726 WMAddPopUpButtonItem(panel->colP, _("Menu Title"));
1727 WMAddPopUpButtonItem(panel->colP, _("Menu Item Text"));
1728 WMAddPopUpButtonItem(panel->colP, _("Disabled Menu Item Text"));
1729 WMAddPopUpButtonItem(panel->colP, _("Menu Highlight Color"));
1730 WMAddPopUpButtonItem(panel->colP, _("Highlighted Menu Text Color"));
1732 WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title"));
1733 WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title Back"));
1734 WMAddPopUpButtonItem(panel->colP, _("Clip Title"));
1735 WMAddPopUpButtonItem(panel->colP, _("Collapsed Clip Title"));
1738 WMSetPopUpButtonSelectedItem(panel->colP, 0);
1740 WMSetPopUpButtonAction(panel->colP, changeColorPage, panel);
1742 panel->colW = WMCreateColorWell(panel->colF);
1743 WMResizeWidget(panel->colW, 65, 50);
1744 WMMoveWidget(panel->colW, 30, 75);
1745 WMAddNotificationObserver(colorWellObserver, panel, WMColorWellDidChangeNotification, panel->colW);
1747 for (i = 0; i < 4; i++) {
1748 int j;
1749 for (j = 0; j < 6; j++) {
1750 panel->sampW[i + j * 4] = WMCreateColorWell(panel->colF);
1751 WMResizeWidget(panel->sampW[i + j * 4], 22, 22);
1752 WMMoveWidget(panel->sampW[i + j * 4], 130 + i * 22, 40 + j * 22);
1753 WSetColorWellBordered(panel->sampW[i + j * 4], False);
1757 WMMapSubwidgets(panel->colF);
1759 #ifdef unfinished
1760 /*** root bg ***/
1762 panel->bgF = WMCreateFrame(panel->box);
1763 WMSetFrameRelief(panel->bgF, WRFlat);
1765 item = WMCreateTabViewItemWithIdentifier(2);
1766 WMSetTabViewItemView(item, WMWidgetView(panel->bgF));
1767 WMSetTabViewItemLabel(item, _("Background"));
1769 WMAddItemInTabView(panel->tabv, item);
1771 panel->bgprevL = WMCreateLabel(panel->bgF);
1772 WMResizeWidget(panel->bgprevL, 230, 155);
1773 WMMoveWidget(panel->bgprevL, 5, 5);
1774 WMSetLabelRelief(panel->bgprevL, WRSunken);
1776 panel->selbgB = WMCreateCommandButton(panel->bgF);
1777 WMMoveWidget(panel->selbgB, 5, 165);
1778 WMResizeWidget(panel->selbgB, 100, 24);
1779 WMSetButtonText(panel->selbgB, _("Browse..."));
1781 WMMapSubwidgets(panel->bgF);
1782 #endif /* unfinished */
1783 /*** options ***/
1784 panel->optF = WMCreateFrame(panel->box);
1785 WMSetFrameRelief(panel->optF, WRFlat);
1787 item = WMCreateTabViewItemWithIdentifier(3);
1788 WMSetTabViewItemView(item, WMWidgetView(panel->optF));
1789 WMSetTabViewItemLabel(item, _("Options"));
1791 WMAddItemInTabView(panel->tabv, item);
1793 panel->mstyF = WMCreateFrame(panel->optF);
1794 WMResizeWidget(panel->mstyF, 215, 85);
1795 WMMoveWidget(panel->mstyF, 15, 10);
1796 WMSetFrameTitle(panel->mstyF, _("Menu Style"));
1798 for (i = 0; i < 3; i++) {
1799 WMPixmap *icon;
1800 char *path;
1802 panel->mstyB[i] = WMCreateButton(panel->mstyF, WBTOnOff);
1803 WMResizeWidget(panel->mstyB[i], 54, 54);
1804 WMMoveWidget(panel->mstyB[i], 15 + i * 65, 20);
1805 WMSetButtonImagePosition(panel->mstyB[i], WIPImageOnly);
1806 WMSetButtonAction(panel->mstyB[i], menuStyleCallback, panel);
1807 switch (i) {
1808 case 0:
1809 path = LocateImage(MSTYLE1_FILE);
1810 break;
1811 case 1:
1812 path = LocateImage(MSTYLE2_FILE);
1813 break;
1814 case 2:
1815 path = LocateImage(MSTYLE3_FILE);
1816 break;
1818 if (path) {
1819 icon = WMCreatePixmapFromFile(scr, path);
1820 if (icon) {
1821 WMSetButtonImage(panel->mstyB[i], icon);
1822 WMReleasePixmap(icon);
1823 } else {
1824 wwarning(_("could not load icon file %s"), path);
1826 wfree(path);
1829 WMGroupButtons(panel->mstyB[0], panel->mstyB[1]);
1830 WMGroupButtons(panel->mstyB[0], panel->mstyB[2]);
1832 WMMapSubwidgets(panel->mstyF);
1834 panel->taliF = WMCreateFrame(panel->optF);
1835 WMResizeWidget(panel->taliF, 110, 80);
1836 WMMoveWidget(panel->taliF, 15, 100);
1837 WMSetFrameTitle(panel->taliF, _("Title Alignment"));
1839 for (i = 0; i < 3; i++) {
1840 panel->taliB[i] = WMCreateRadioButton(panel->taliF);
1841 WMSetButtonAction(panel->taliB[i], titleAlignCallback, panel);
1842 switch (i) {
1843 case 0:
1844 WMSetButtonText(panel->taliB[i], _("Left"));
1845 break;
1846 case 1:
1847 WMSetButtonText(panel->taliB[i], _("Center"));
1848 break;
1849 case 2:
1850 WMSetButtonText(panel->taliB[i], _("Right"));
1851 break;
1853 WMResizeWidget(panel->taliB[i], 90, 18);
1854 WMMoveWidget(panel->taliB[i], 10, 15 + 20 * i);
1856 WMGroupButtons(panel->taliB[0], panel->taliB[1]);
1857 WMGroupButtons(panel->taliB[0], panel->taliB[2]);
1859 WMMapSubwidgets(panel->taliF);
1861 WMMapSubwidgets(panel->optF);
1863 /**/ WMRealizeWidget(panel->box);
1864 WMMapSubwidgets(panel->box);
1866 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1868 showData(panel);
1870 changePage(panel->secP, panel);
1872 fillTextureList(panel->texLs);
1874 fillColorList(panel);
1876 panel->texturePanel = CreateTexturePanel(panel->parent);
1879 static void setupTextureFor(WMList * list, char *key, char *defValue, char *title, int index)
1881 WMListItem *item;
1882 TextureListItem *titem;
1884 titem = wmalloc(sizeof(TextureListItem));
1885 memset(titem, 0, sizeof(TextureListItem));
1887 titem->title = wstrdup(title);
1888 titem->prop = GetObjectForKey(key);
1889 if (!titem->prop || !WMIsPLArray(titem->prop)) {
1890 /* Maybe also give a error message to stderr that the entry is bad? */
1891 titem->prop = WMCreatePropListFromDescription(defValue);
1892 } else {
1893 WMRetainPropList(titem->prop);
1895 titem->texture = WMGetPropListDescription((WMPropList *) titem->prop, False);
1896 titem->current = 1;
1897 titem->selectedFor = 1 << index;
1899 titem->ispixmap = isPixmap(titem->prop);
1901 titem->preview = renderTexture(WMWidgetScreen(list), titem->prop, TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0);
1903 item = WMAddListItem(list, "");
1904 item->clientData = titem;
1907 static void showData(_Panel * panel)
1909 int i;
1910 char *str;
1912 str = GetStringForKey("MenuStyle");
1913 if (str && strcasecmp(str, "flat") == 0) {
1914 panel->menuStyle = MSTYLE_FLAT;
1915 } else if (str && strcasecmp(str, "singletexture") == 0) {
1916 panel->menuStyle = MSTYLE_SINGLE;
1917 } else {
1918 panel->menuStyle = MSTYLE_NORMAL;
1921 str = GetStringForKey("TitleJustify");
1922 if (str && strcasecmp(str, "left") == 0) {
1923 panel->titleAlignment = WALeft;
1924 } else if (str && strcasecmp(str, "right") == 0) {
1925 panel->titleAlignment = WARight;
1926 } else {
1927 panel->titleAlignment = WACenter;
1930 for (i = 0; i < sizeof(colorOptions) / (2 * sizeof(char *)); i++) {
1931 WMColor *color;
1933 str = GetStringForKey(colorOptions[i * 2]);
1934 if (!str)
1935 str = colorOptions[i * 2 + 1];
1937 if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) {
1938 color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False);
1941 panel->colors[i] = color;
1943 changeColorPage(panel->colP, panel);
1945 for (i = 0; i < sizeof(textureOptions) / (3 * sizeof(char *)); i++) {
1946 setupTextureFor(panel->texLs, textureOptions[i * 3],
1947 textureOptions[i * 3 + 1], textureOptions[i * 3 + 2], i);
1948 panel->textureIndex[i] = i;
1950 updatePreviewBox(panel, EVERYTHING);
1952 WMSetButtonSelected(panel->mstyB[panel->menuStyle], True);
1953 WMSetButtonSelected(panel->taliB[panel->titleAlignment], True);
1956 static void storeData(_Panel * panel)
1958 TextureListItem *titem;
1959 WMListItem *item;
1960 int i;
1962 for (i = 0; i < sizeof(textureOptions) / (sizeof(char *) * 3); i++) {
1963 item = WMGetListItem(panel->texLs, panel->textureIndex[i]);
1964 titem = (TextureListItem *) item->clientData;
1965 SetObjectForKey(titem->prop, textureOptions[i * 3]);
1968 for (i = 0; i < 8; i++) {
1969 char *str;
1971 str = WMGetColorRGBDescription(panel->colors[i]);
1973 if (str) {
1974 SetStringForKey(str, colorOptions[i * 2]);
1975 wfree(str);
1979 switch (panel->menuStyle) {
1980 case MSTYLE_SINGLE:
1981 SetStringForKey("singletexture", "MenuStyle");
1982 break;
1983 case MSTYLE_FLAT:
1984 SetStringForKey("flat", "MenuStyle");
1985 break;
1986 default:
1987 case MSTYLE_NORMAL:
1988 SetStringForKey("normal", "MenuStyle");
1989 break;
1991 switch (panel->titleAlignment) {
1992 case WALeft:
1993 SetStringForKey("left", "TitleJustify");
1994 break;
1995 case WARight:
1996 SetStringForKey("right", "TitleJustify");
1997 break;
1998 default:
1999 case WACenter:
2000 SetStringForKey("center", "TitleJustify");
2001 break;
2005 static void prepareForClose(_Panel * panel)
2007 WMPropList *textureList;
2008 WMPropList *texture;
2009 TextureListItem *titem;
2010 WMListItem *item;
2011 WMUserDefaults *udb = WMGetStandardUserDefaults();
2012 int i;
2014 textureList = WMCreatePLArray(NULL, NULL);
2016 /* store list of textures */
2017 for (i = 7; i < WMGetListNumberOfRows(panel->texLs); i++) {
2018 item = WMGetListItem(panel->texLs, i);
2019 titem = (TextureListItem *) item->clientData;
2021 texture = WMCreatePLArray(WMCreatePLString(titem->title),
2022 WMRetainPropList(titem->prop), WMCreatePLString(titem->path), NULL);
2024 WMAddToPLArray(textureList, texture);
2027 WMSetUDObjectForKey(udb, textureList, "TextureList");
2028 WMReleasePropList(textureList);
2030 /* store list of colors */
2031 textureList = WMCreatePLArray(NULL, NULL);
2032 for (i = 0; i < 24; i++) {
2033 WMColor *color;
2034 char *str;
2036 color = WMGetColorWellColor(panel->sampW[i]);
2038 str = WMGetColorRGBDescription(color);
2039 WMAddToPLArray(textureList, WMCreatePLString(str));
2040 wfree(str);
2042 WMSetUDObjectForKey(udb, textureList, "ColorList");
2043 WMReleasePropList(textureList);
2045 WMSynchronizeUserDefaults(udb);
2048 Panel *InitAppearance(WMScreen * scr, WMWindow * win)
2050 _Panel *panel;
2052 panel = wmalloc(sizeof(_Panel));
2053 memset(panel, 0, sizeof(_Panel));
2055 panel->sectionName = _("Appearance Preferences");
2057 panel->description = _("Background texture configuration for windows,\n" "menus and icons.");
2059 panel->parent = win;
2061 panel->callbacks.createWidgets = createPanel;
2062 panel->callbacks.updateDomain = storeData;
2063 panel->callbacks.prepareForClose = prepareForClose;
2065 AddSection(panel, ICON_FILE);
2067 return panel;
2070 /****************************************************************************/
2072 typedef struct ExtractPanel {
2073 WMWindow *win;
2075 WMLabel *label;
2076 WMList *list;
2078 WMButton *closeB;
2079 WMButton *extrB;
2080 } ExtractPanel;
2082 static void OpenExtractPanelFor(_Panel * panel, char *path)
2084 ExtractPanel *epanel;
2085 WMColor *color;
2086 WMFont *font;
2087 WMScreen *scr = WMWidgetScreen(panel->parent);
2089 epanel = wmalloc(sizeof(ExtractPanel));
2090 epanel->win = WMCreatePanelWithStyleForWindow(panel->parent, "extract",
2091 WMTitledWindowMask | WMClosableWindowMask);
2092 WMResizeWidget(epanel->win, 245, 250);
2093 WMSetWindowTitle(epanel->win, _("Extract Texture"));
2095 epanel->label = WMCreateLabel(epanel->win);
2096 WMResizeWidget(epanel->label, 225, 18);
2097 WMMoveWidget(epanel->label, 10, 10);
2098 WMSetLabelTextAlignment(epanel->label, WACenter);
2099 WMSetLabelRelief(epanel->label, WRSunken);
2101 color = WMDarkGrayColor(scr);
2102 WMSetWidgetBackgroundColor(epanel->label, color);
2103 WMReleaseColor(color);
2105 color = WMWhiteColor(scr);
2106 WMSetLabelTextColor(epanel->label, color);
2107 WMReleaseColor(color);
2109 font = WMBoldSystemFontOfSize(scr, 12);
2110 WMSetLabelFont(epanel->label, font);
2111 WMReleaseFont(font);
2113 WMSetLabelText(epanel->label, _("Textures"));
2115 epanel->list = WMCreateList(epanel->win);
2116 WMResizeWidget(epanel->list, 225, 165);
2117 WMMoveWidget(epanel->list, 10, 30);
2119 epanel->closeB = WMCreateCommandButton(epanel->win);
2120 WMResizeWidget(epanel->closeB, 74, 24);
2121 WMMoveWidget(epanel->closeB, 165, 215);
2122 WMSetButtonText(epanel->closeB, _("Close"));
2124 epanel->extrB = WMCreateCommandButton(epanel->win);
2125 WMResizeWidget(epanel->extrB, 74, 24);
2126 WMMoveWidget(epanel->extrB, 80, 215);
2127 WMSetButtonText(epanel->extrB, _("Extract"));
2129 WMMapSubwidgets(epanel->win);
2131 /* take textures from file */
2133 WMRealizeWidget(epanel->win);
2135 WMMapWidget(epanel->win);