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.
29 #include <sys/types.h>
32 #include "TexturePanel.h"
37 const char *default_value
;
39 WMRect preview
; /* The rectangle where the corresponding object is displayed */
40 WMPoint hand
; /* The coordinate where the hand is drawn when pointing this item */
42 /* Related to Window titles */
43 { "FTitleColor", "white", N_("Focused Window Title"),
44 { { 30, 10 }, { 190, 20 } }, { 5, 10 } },
45 { "UTitleColor", "black", N_("Unfocused Window Title"),
46 { { 30, 40 }, { 190, 20 } }, { 5, 40 } },
47 { "PTitleColor", "white", N_("Owner of Focused Window Title"),
48 { { 30, 70 }, { 190, 20 } }, { 5, 70 } },
50 /* Related to Menus */
51 { "MenuTitleColor", "white", N_("Menu Title") ,
52 { { 30, 120 }, { 90, 20 } }, { 5, 120 } },
53 { "MenuTextColor", "black", N_("Menu Item Text") ,
54 { { 30, 140 }, { 90, 20 } }, { 5, 140 } },
55 { "MenuDisabledColor", "#616161", N_("Disabled Menu Item Text") ,
56 { { 30, 160 }, { 90, 20 } }, { 5, 160 } },
57 { "HighlightColor", "white", N_("Menu Highlight Color") ,
58 { { 30, 180 }, { 90, 20 } }, { 5, 180 } },
59 { "HighlightTextColor", "black", N_("Highlighted Menu Text Color") ,
60 { { 30, 200 }, { 90, 20 } }, { 5, 180 } },
62 * yuck kluge: the coordinate for HighlightTextColor are actually those of the last "Normal item"
63 * at the bottom when user clicks it, the "yuck kluge" in the function 'previewClick' will swap it
64 * for the MenuTextColor selection as user would expect
66 * Note that the entries are reffered by their index for performance
69 /* Related to Window's border */
70 { "FrameFocusedBorderColor", "black", N_("Focused Window Border Color") ,
71 { { 0, 0 }, { 0, 0 } }, { -22, -21 } },
72 { "FrameBorderColor", "black", N_("Window Border Color") ,
73 { { 0, 0 }, { 0, 0 } }, { -22, -21 } },
74 { "FrameSelectedBorderColor", "white", N_("Selected Window Border Color") ,
75 { { 0, 0 }, { 0, 0 } }, { -22, -21 } },
77 /* Related to Icons and Clip */
78 { "IconTitleColor", "white", N_("Miniwindow Title") ,
79 { { 155, 130 }, { 64, 64 } }, { 130, 132 } },
80 { "IconTitleBack", "black", N_("Miniwindow Title Back") ,
81 { { 155, 130 }, { 64, 64 } }, { 130, 132 } },
82 { "ClipTitleColor", "black", N_("Clip Title") ,
83 { { 155, 130 }, { 64, 64 } }, { 130, 132 } },
84 { "CClipTitleColor", "#454045", N_("Collapsed Clip Title") ,
85 { { 155, 130 }, { 64, 64 } }, { 130, 132 } }
88 /********************************************************************/
97 const char *file_name
;
99 [MSTYLE_NORMAL
] { "normal", "msty1" },
100 [MSTYLE_SINGLE
] { "singletexture", "msty2" },
101 [MSTYLE_FLAT
] { "flat", "msty3" }
104 /********************************************************************/
105 static const struct {
107 const char *db_value
;
108 } wintitle_align
[] = {
109 [WALeft
] { N_("Left"), "left" },
110 [WACenter
] { N_("Center"), "center" },
111 [WARight
] { N_("Right"), "right" }
114 /********************************************************************/
115 typedef struct _Panel
{
121 CallbackRec callbacks
;
144 WMColor
*colors
[wlengthof_nocheck(colorOptions
)];
148 WMColorWell
*sampW
[24];
154 WMButton
*mstyB
[wlengthof_nocheck(menu_style
)];
157 WMButton
*taliB
[wlengthof_nocheck(wintitle_align
)];
167 TexturePanel
*texturePanel
;
178 menu_style_index menuStyle
;
180 WMAlignment titleAlignment
;
183 Pixmap previewNoText
;
208 static void updateColorPreviewBox(_Panel
* panel
, int elements
);
210 static void showData(_Panel
* panel
);
212 static void changePage(WMWidget
* w
, void *data
);
214 static void changeColorPage(WMWidget
* w
, void *data
);
216 static void OpenExtractPanelFor(_Panel
*panel
);
218 static void changedTabItem(struct WMTabViewDelegate
*self
, WMTabView
* tabView
, WMTabViewItem
* item
);
220 static WMTabViewDelegate tabviewDelegate
= {
222 NULL
, /* didChangeNumberOfItems */
223 changedTabItem
, /* didSelectItem */
224 NULL
, /* shouldSelectItem */
225 NULL
/* willSelectItem */
228 #define ICON_FILE "appearance"
230 #define TNEW_FILE "tnew"
231 #define TDEL_FILE "tdel"
232 #define TEDIT_FILE "tedit"
233 #define TEXTR_FILE "textr"
236 static char *blueled_xpm
[] = {
266 static char *blueled2_xpm
[] = {
267 /* width height num_colors chars_per_pixel */
299 static char *hand_xpm
[] = {
323 " .%%%&@.......... ",
324 " .%*%%&#%%%%%%%%%$. ",
325 " .*#%%%%%%%%%&&&&==. ",
326 " .-%%%%%%%%%=*-;;;#$. ",
327 " .-%%%%%%%%&..>..... ",
343 static char *sampleColors
[] = {
371 static const struct {
373 const char *default_value
;
374 const char *texture_label
; /* text used when displaying the list of textures */
375 WMRect preview
; /* The rectangle where the corresponding object is displayed */
376 WMPoint hand
; /* The coordinate where the hand is drawn when pointing this item */
377 const char *popup_label
; /* text used for the popup button with the list of editable items */
378 } textureOptions
[] = {
381 { "FTitleBack", "(solid, black)", N_("[Focused]"),
382 { { 30, 10 }, { 190, 20 } }, { 5, 10 }, N_("Titlebar of Focused Window") },
385 { "UTitleBack", "(solid, gray)", N_("[Unfocused]"),
386 { { 30, 40 }, { 190, 20 } }, { 5, 40 }, N_("Titlebar of Unfocused Windows") },
389 { "PTitleBack", "(solid, \"#616161\")", N_("[Owner of Focused]"),
390 { { 30, 70 }, { 190, 20 } }, { 5, 70 }, N_("Titlebar of Focused Window's Owner") },
393 { "ResizebarBack", "(solid, gray)", N_("[Resizebar]"),
394 { { 30, 100 }, { 190, 9 } }, { 5, 100 }, N_("Window Resizebar") },
397 { "MenuTitleBack", "(solid, black)", N_("[Menu Title]"),
398 { { 30, 120 }, { 90, 20 } }, { 5, 120 }, N_("Titlebar of Menus") },
401 { "MenuTextBack", "(solid, gray)", N_("[Menu Item]"),
402 { { 30, 140 }, { 90, 20 * 4 } }, { 5, 160 }, N_("Menu Items") },
405 { "IconBack", "(solid, gray)", N_("[Icon]"),
406 { { 155, 130 }, { 64, 64 } }, { 130, 150 }, N_("Icon Background") },
408 #define PBACKGROUND 7
409 { "WorkspaceBack", "(solid, black)", N_("[Background]"),
410 { { -1, -1}, { 0, 0 } }, { -22, -21 }, N_("Workspace Background") }
412 #define EVERYTHING 0xff
416 RESIZEBAR_BEVEL
= -1,
444 static void str2rcolor(RContext
* rc
, const char *name
, RColor
* color
)
448 XParseColor(rc
->dpy
, rc
->cmap
, name
, &xcolor
);
451 color
->red
= xcolor
.red
>> 8;
452 color
->green
= xcolor
.green
>> 8;
453 color
->blue
= xcolor
.blue
>> 8;
456 static void dumpRImage(const char *path
, RImage
* image
)
459 int channels
= (image
->format
== RRGBAFormat
? 4 : 3);
461 f
= fopen(path
, "wb");
466 fprintf(f
, "%02x%02x%1x", image
->width
, image
->height
, channels
);
468 fwrite(image
->data
, 1, image
->width
* image
->height
* channels
, f
);
476 static int isPixmap(WMPropList
* prop
)
481 p
= WMGetFromPLArray(prop
, 0);
482 s
= WMGetFromPLString(p
);
483 if (strcasecmp(&s
[1], "pixmap") == 0)
489 /**********************************************************************/
491 static void drawResizebarBevel(RImage
* img
)
495 int width
= img
->width
;
496 int height
= img
->height
;
500 light
.red
= light
.green
= light
.blue
= 80;
503 dark
.red
= dark
.green
= dark
.blue
= 40;
505 ROperateLine(img
, RSubtractOperation
, 0, 0, width
- 1, 0, &dark
);
506 ROperateLine(img
, RAddOperation
, 0, 1, width
- 1, 1, &light
);
508 ROperateLine(img
, RSubtractOperation
, cwidth
, 2, cwidth
, height
- 1, &dark
);
509 ROperateLine(img
, RAddOperation
, cwidth
+ 1, 2, cwidth
+ 1, height
- 1, &light
);
511 ROperateLine(img
, RSubtractOperation
, width
- cwidth
- 2, 2, width
- cwidth
- 2, height
- 1, &dark
);
512 ROperateLine(img
, RAddOperation
, width
- cwidth
- 1, 2, width
- cwidth
- 1, height
- 1, &light
);
516 static void drawMenuBevel(RImage
* img
)
518 RColor light
, dark
, mid
;
520 int iheight
= img
->height
/ 4;
523 light
.red
= light
.green
= light
.blue
= 80;
526 dark
.red
= dark
.green
= dark
.blue
= 0;
529 mid
.red
= mid
.green
= mid
.blue
= 40;
531 for (i
= 1; i
< 4; i
++) {
532 ROperateLine(img
, RSubtractOperation
, 0, i
* iheight
- 2, img
->width
- 1, i
* iheight
- 2, &mid
);
534 RDrawLine(img
, 0, i
* iheight
- 1, img
->width
- 1, i
* iheight
- 1, &dark
);
536 ROperateLine(img
, RAddOperation
, 1, i
* iheight
, img
->width
- 2, i
* iheight
, &light
);
540 static Pixmap
renderTexture(WMScreen
* scr
, WMPropList
* texture
, int width
, int height
, const char *path
, int border
)
543 RImage
*image
= NULL
;
544 RImage
*timage
= NULL
;
546 RContext
*rc
= WMScreenRContext(scr
);
550 type
= WMGetFromPLString(WMGetFromPLArray(texture
, 0));
552 if (strcasecmp(&type
[1], "pixmap") == 0 ||
553 (strcasecmp(&type
[2], "gradient") == 0 && toupper(type
[0]) == 'T')) {
556 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
557 path
= wfindfileinarray(GetObjectForKey("PixmapPath"), str
);
559 timage
= RLoadImage(rc
, path
, 0);
561 wwarning("could not load file '%s': %s", path
, RMessageForError(RErrorCode
));
564 wwarning("could not find file '%s' for %s of texture", str
, type
);
568 texture
= WMCreatePropListFromDescription("(solid, black)");
573 if (strcasecmp(type
, "solid") == 0) {
575 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
577 str2rcolor(rc
, str
, &rcolor
);
579 image
= RCreateImage(width
, height
, False
);
580 RClearImage(image
, &rcolor
);
581 } else if (strcasecmp(type
, "igradient") == 0) {
585 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
586 str2rcolor(rc
, str
, &c1
[0]);
587 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
588 str2rcolor(rc
, str
, &c1
[1]);
589 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 3));
592 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 4));
593 str2rcolor(rc
, str
, &c2
[0]);
594 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 5));
595 str2rcolor(rc
, str
, &c2
[1]);
596 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 6));
599 image
= RRenderInterwovenGradient(width
, height
, c1
, t1
, c2
, t2
);
600 } else if (strcasecmp(&type
[1], "gradient") == 0) {
601 RGradientStyle style
;
604 switch (toupper(type
[0])) {
606 style
= RVerticalGradient
;
609 style
= RHorizontalGradient
;
612 wwarning("unknow direction in '%s', falling back to diagonal", type
);
614 style
= RDiagonalGradient
;
618 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
619 str2rcolor(rc
, str
, &rcolor
);
620 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
621 str2rcolor(rc
, str
, &rcolor2
);
623 image
= RRenderGradient(width
, height
, &rcolor
, &rcolor2
, style
);
624 } else if (strcasecmp(&type
[2], "gradient") == 0 && toupper(type
[0]) == 'T') {
625 RGradientStyle style
;
630 switch (toupper(type
[1])) {
632 style
= RVerticalGradient
;
635 style
= RHorizontalGradient
;
638 wwarning("unknow direction in '%s', falling back to diagonal", type
);
640 style
= RDiagonalGradient
;
644 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 3));
645 str2rcolor(rc
, str
, &rcolor
);
646 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 4));
647 str2rcolor(rc
, str
, &rcolor2
);
649 grad
= RRenderGradient(width
, height
, &rcolor
, &rcolor2
, style
);
651 image
= RMakeTiledImage(timage
, width
, height
);
652 RReleaseImage(timage
);
654 i
= atoi(WMGetFromPLString(WMGetFromPLArray(texture
, 2)));
656 RCombineImagesWithOpaqueness(image
, grad
, i
);
659 } else if (strcasecmp(&type
[2], "gradient") == 0 && toupper(type
[0]) == 'M') {
660 RGradientStyle style
;
664 switch (toupper(type
[1])) {
666 style
= RVerticalGradient
;
669 style
= RHorizontalGradient
;
672 wwarning("unknow direction in '%s', falling back to diagonal", type
);
674 style
= RDiagonalGradient
;
678 j
= WMGetPropListItemCount(texture
);
681 colors
= wmalloc(j
* sizeof(RColor
*));
683 for (i
= 2; i
< j
; i
++) {
684 str
= WMGetFromPLString(WMGetFromPLArray(texture
, i
));
685 colors
[i
- 2] = wmalloc(sizeof(RColor
));
686 str2rcolor(rc
, str
, colors
[i
- 2]);
688 colors
[i
- 2] = NULL
;
690 image
= RRenderMultiGradient(width
, height
, colors
, style
);
692 for (i
= 0; colors
[i
] != NULL
; i
++)
696 } else if (strcasecmp(&type
[1], "pixmap") == 0) {
699 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
700 str2rcolor(rc
, str
, &color
);
702 switch (toupper(type
[0])) {
704 image
= RMakeTiledImage(timage
, width
, height
);
705 RReleaseImage(timage
);
708 image
= RMakeCenteredImage(timage
, width
, height
, &color
);
709 RReleaseImage(timage
);
714 image
= RScaleImage(timage
, width
, height
);
715 RReleaseImage(timage
);
719 wwarning("type '%s' in not a supported type for a texture", type
);
720 RReleaseImage(timage
);
729 dumpRImage(path
, image
);
733 if (border
== RESIZEBAR_BEVEL
) {
734 drawResizebarBevel(image
);
735 } else if (border
== MENU_BEVEL
) {
736 drawMenuBevel(image
);
737 RBevelImage(image
, RBEV_RAISED2
);
740 RBevelImage(image
, border
);
743 RConvertImage(rc
, image
, &pixmap
);
744 RReleaseImage(image
);
749 static Pixmap
renderMenu(_Panel
* panel
, WMPropList
* texture
, int width
, int iheight
)
751 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
752 Display
*dpy
= WMScreenDisplay(scr
);
754 GC gc
= XCreateGC(dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
757 switch (panel
->menuStyle
) {
759 tmp
= renderTexture(scr
, texture
, width
, iheight
, NULL
, RBEV_RAISED2
);
761 pix
= XCreatePixmap(dpy
, tmp
, width
, iheight
* 4, WMScreenDepth(scr
));
762 for (i
= 0; i
< 4; i
++) {
763 XCopyArea(dpy
, tmp
, pix
, gc
, 0, 0, width
, iheight
, 0, iheight
* i
);
765 XFreePixmap(dpy
, tmp
);
768 pix
= renderTexture(scr
, texture
, width
, iheight
* 4, NULL
, MENU_BEVEL
);
771 pix
= renderTexture(scr
, texture
, width
, iheight
* 4, NULL
, RBEV_RAISED2
);
781 static void renderPreview(_Panel
* panel
, GC gc
, int part
, int relief
)
784 TextureListItem
*titem
;
786 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
788 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[part
]);
789 titem
= (TextureListItem
*) item
->clientData
;
791 pix
= renderTexture(scr
, titem
->prop
,
792 textureOptions
[part
].preview
.size
.width
, textureOptions
[part
].preview
.size
.height
,
795 XCopyArea(WMScreenDisplay(scr
), pix
, panel
->preview
, gc
, 0, 0,
796 textureOptions
[part
].preview
.size
.width
, textureOptions
[part
].preview
.size
.height
,
797 textureOptions
[part
].preview
.pos
.x
, textureOptions
[part
].preview
.pos
.y
);
799 XCopyArea(WMScreenDisplay(scr
), pix
, panel
->previewNoText
, gc
, 0, 0,
800 textureOptions
[part
].preview
.size
.width
, textureOptions
[part
].preview
.size
.height
,
801 textureOptions
[part
].preview
.pos
.x
, textureOptions
[part
].preview
.pos
.y
);
803 XFreePixmap(WMScreenDisplay(scr
), pix
);
806 static void updatePreviewBox(_Panel
* panel
, int elements
)
808 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
809 Display
*dpy
= WMScreenDisplay(scr
);
814 gc
= XCreateGC(dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
816 if (panel
->preview
== None
) {
819 panel
->previewNoText
= XCreatePixmap(dpy
, WMWidgetXID(panel
->parent
),
820 240 - 4, 215 - 4, WMScreenDepth(scr
));
821 panel
->previewBack
= XCreatePixmap(dpy
, WMWidgetXID(panel
->parent
),
822 240 - 4, 215 - 4, WMScreenDepth(scr
));
824 p
= WMCreatePixmap(scr
, 240 - 4, 215 - 4, WMScreenDepth(scr
), False
);
825 panel
->preview
= WMGetPixmapXID(p
);
826 WMSetLabelImage(panel
->prevL
, p
);
829 if (elements
& (1 << PBACKGROUND
)) {
831 TextureListItem
*titem
;
834 item
= WMGetListItem(panel
->texLs
,
835 panel
->textureIndex
[PBACKGROUND
]);
836 titem
= (TextureListItem
*) item
->clientData
;
837 tmp
= renderTexture(scr
, titem
->prop
, 240 - 4, 215 - 4, NULL
, 0);
839 XCopyArea(dpy
, tmp
, panel
->preview
, gc
, 0, 0, 240 - 4, 215 -4 , 0, 0);
840 XCopyArea(dpy
, tmp
, panel
->previewNoText
, gc
, 0, 0, 240 - 4, 215 -4 , 0, 0);
841 XCopyArea(dpy
, tmp
, panel
->previewBack
, gc
, 0, 0, 240 - 4, 215 -4 , 0, 0);
842 XFreePixmap(dpy
, tmp
);
845 if (elements
& (1 << PFOCUSED
)) {
846 renderPreview(panel
, gc
, PFOCUSED
, RBEV_RAISED2
);
847 colorUpdate
|= 1 << FTITLE_COL
| 1 << FFBORDER_COL
;
849 if (elements
& (1 << PUNFOCUSED
)) {
850 renderPreview(panel
, gc
, PUNFOCUSED
, RBEV_RAISED2
);
851 colorUpdate
|= 1 << UTITLE_COL
| 1 << FBORDER_COL
;
853 if (elements
& (1 << POWNER
)) {
854 renderPreview(panel
, gc
, POWNER
, RBEV_RAISED2
);
855 colorUpdate
|= 1 << OTITLE_COL
| 1 << FBORDER_COL
;
857 if (elements
& (1 << PRESIZEBAR
)) {
858 renderPreview(panel
, gc
, PRESIZEBAR
, RESIZEBAR_BEVEL
);
859 colorUpdate
|= 1 << FBORDER_COL
;
861 if (elements
& (1 << PMTITLE
)) {
862 renderPreview(panel
, gc
, PMTITLE
, RBEV_RAISED2
);
863 colorUpdate
|= 1 << MTITLE_COL
| 1 << FBORDER_COL
;
865 if (elements
& (1 << PMITEM
)) {
867 TextureListItem
*titem
;
869 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[5]);
870 titem
= (TextureListItem
*) item
->clientData
;
872 pix
= renderMenu(panel
, titem
->prop
,
873 textureOptions
[PMITEM
].preview
.size
.width
,
874 textureOptions
[PMITEM
].preview
.size
.height
/ 4);
876 XCopyArea(dpy
, pix
, panel
->preview
, gc
, 0, 0,
877 textureOptions
[PMITEM
].preview
.size
.width
, textureOptions
[PMITEM
].preview
.size
.height
,
878 textureOptions
[PMITEM
].preview
.pos
.x
, textureOptions
[PMITEM
].preview
.pos
.y
);
880 XCopyArea(dpy
, pix
, panel
->previewNoText
, gc
, 0, 0,
881 textureOptions
[PMITEM
].preview
.size
.width
, textureOptions
[PMITEM
].preview
.size
.height
,
882 textureOptions
[PMITEM
].preview
.pos
.x
, textureOptions
[PMITEM
].preview
.pos
.y
);
884 XFreePixmap(dpy
, pix
);
886 colorUpdate
|= 1 << MITEM_COL
| 1 << MDISAB_COL
|
887 1 << MHIGH_COL
| 1 << MHIGHT_COL
|
890 if (elements
& (1 << PICON
)) {
892 TextureListItem
*titem
;
894 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[6]);
895 titem
= (TextureListItem
*) item
->clientData
;
897 renderPreview(panel
, gc
, PICON
, titem
->ispixmap
? 0 : RBEV_RAISED3
);
901 updateColorPreviewBox(panel
, colorUpdate
);
903 WMRedisplayWidget(panel
->prevL
);
908 static void cancelNewTexture(void *data
)
910 _Panel
*panel
= (_Panel
*) data
;
912 HideTexturePanel(panel
->texturePanel
);
915 static char *makeFileName(const char *prefix
)
919 fname
= wstrdup(prefix
);
921 while (access(fname
, F_OK
) == 0) {
925 sprintf(buf
, "%08lx.cache", time(NULL
));
926 fname
= wstrconcat(prefix
, buf
);
932 static void okNewTexture(void *data
)
934 _Panel
*panel
= (_Panel
*) data
;
939 TextureListItem
*titem
;
940 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
942 titem
= wmalloc(sizeof(TextureListItem
));
944 HideTexturePanel(panel
->texturePanel
);
946 name
= GetTexturePanelTextureName(panel
->texturePanel
);
948 prop
= GetTexturePanelTexture(panel
->texturePanel
);
950 str
= WMGetPropListDescription(prop
, False
);
954 titem
->texture
= str
;
955 titem
->selectedFor
= 0;
957 titem
->ispixmap
= isPixmap(prop
);
959 titem
->path
= makeFileName(panel
->fprefix
);
960 titem
->preview
= renderTexture(scr
, prop
, TEXPREV_WIDTH
, TEXPREV_HEIGHT
, titem
->path
, 0);
962 item
= WMAddListItem(panel
->texLs
, "");
963 item
->clientData
= titem
;
965 WMSetListPosition(panel
->texLs
, WMGetListNumberOfRows(panel
->texLs
));
968 static void okEditTexture(void *data
)
970 _Panel
*panel
= (_Panel
*) data
;
975 TextureListItem
*titem
;
977 item
= WMGetListItem(panel
->texLs
, WMGetListSelectedItemRow(panel
->texLs
));
978 titem
= (TextureListItem
*) item
->clientData
;
980 HideTexturePanel(panel
->texturePanel
);
982 if (titem
->current
) {
983 name
= GetTexturePanelTextureName(panel
->texturePanel
);
989 prop
= GetTexturePanelTexture(panel
->texturePanel
);
991 str
= WMGetPropListDescription(prop
, False
);
993 WMReleasePropList(titem
->prop
);
996 titem
->ispixmap
= isPixmap(prop
);
998 wfree(titem
->texture
);
999 titem
->texture
= str
;
1001 XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel
->texLs
)), titem
->preview
);
1002 titem
->preview
= renderTexture(WMWidgetScreen(panel
->texLs
), titem
->prop
,
1003 TEXPREV_WIDTH
, TEXPREV_HEIGHT
, titem
->path
, 0);
1005 WMRedisplayWidget(panel
->texLs
);
1007 if (titem
->selectedFor
) {
1008 if (titem
->selectedFor
& (1 << PBACKGROUND
))
1009 updatePreviewBox(panel
, EVERYTHING
);
1011 updatePreviewBox(panel
, titem
->selectedFor
);
1014 changePage(panel
->secP
, panel
);
1017 static void editTexture(WMWidget
* w
, void *data
)
1019 _Panel
*panel
= (_Panel
*) data
;
1021 TextureListItem
*titem
;
1023 /* Parameter not used, but tell the compiler that it is ok */
1026 item
= WMGetListItem(panel
->texLs
, WMGetListSelectedItemRow(panel
->texLs
));
1027 titem
= (TextureListItem
*) item
->clientData
;
1029 SetTexturePanelPixmapPath(panel
->texturePanel
, GetObjectForKey("PixmapPath"));
1031 SetTexturePanelTexture(panel
->texturePanel
, titem
->title
, titem
->prop
);
1033 SetTexturePanelCancelAction(panel
->texturePanel
, cancelNewTexture
, panel
);
1034 SetTexturePanelOkAction(panel
->texturePanel
, okEditTexture
, panel
);
1036 ShowTexturePanel(panel
->texturePanel
);
1039 static void newTexture(WMWidget
* w
, void *data
)
1041 _Panel
*panel
= (_Panel
*) data
;
1043 /* Parameter not used, but tell the compiler that it is ok */
1046 SetTexturePanelPixmapPath(panel
->texturePanel
, GetObjectForKey("PixmapPath"));
1048 SetTexturePanelTexture(panel
->texturePanel
, "New Texture", NULL
);
1050 SetTexturePanelCancelAction(panel
->texturePanel
, cancelNewTexture
, panel
);
1052 SetTexturePanelOkAction(panel
->texturePanel
, okNewTexture
, panel
);
1054 ShowTexturePanel(panel
->texturePanel
);
1057 static void deleteTexture(WMWidget
* w
, void *data
)
1059 _Panel
*panel
= (_Panel
*) data
;
1061 TextureListItem
*titem
;
1065 /* Parameter not used, but tell the compiler that it is ok */
1068 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
1069 row
= WMGetListSelectedItemRow(panel
->texLs
);
1070 item
= WMGetListItem(panel
->texLs
, row
);
1071 titem
= (TextureListItem
*) item
->clientData
;
1073 if (titem
->selectedFor
& (1 << section
)) {
1074 TextureListItem
*titem2
;
1076 panel
->textureIndex
[section
] = section
;
1077 item
= WMGetListItem(panel
->texLs
, section
);
1078 titem2
= (TextureListItem
*) item
->clientData
;
1079 titem2
->selectedFor
|= 1 << section
;
1082 wfree(titem
->title
);
1083 wfree(titem
->texture
);
1084 WMReleasePropList(titem
->prop
);
1086 if (remove(titem
->path
) < 0 && errno
!= ENOENT
) {
1087 werror("could not remove file %s", titem
->path
);
1094 WMRemoveListItem(panel
->texLs
, row
);
1095 WMSetButtonEnabled(panel
->delB
, False
);
1098 static void extractTexture(WMWidget
* w
, void *data
)
1100 _Panel
*panel
= (_Panel
*) data
;
1102 WMOpenPanel
*opanel
;
1103 WMScreen
*scr
= WMWidgetScreen(w
);
1105 opanel
= WMGetOpenPanel(scr
);
1106 WMSetFilePanelCanChooseDirectories(opanel
, False
);
1107 WMSetFilePanelCanChooseFiles(opanel
, True
);
1109 if (WMRunModalFilePanelForDirectory(opanel
, panel
->parent
, wgethomedir(), _("Select File"), NULL
)) {
1110 path
= WMGetFilePanelFileName(opanel
);
1112 OpenExtractPanelFor(panel
);
1118 static void changePage(WMWidget
* w
, void *data
)
1120 _Panel
*panel
= (_Panel
*) data
;
1122 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1123 RContext
*rc
= WMScreenRContext(scr
);
1126 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
1128 WMSelectListItem(panel
->texLs
, panel
->textureIndex
[section
]);
1130 WMSetListPosition(panel
->texLs
, panel
->textureIndex
[section
] - 2);
1135 gc
= XCreateGC(rc
->dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
1136 XCopyArea(rc
->dpy
, panel
->previewBack
, panel
->preview
, gc
,
1137 textureOptions
[panel
->oldsection
].hand
.x
, textureOptions
[panel
->oldsection
].hand
.y
, 22, 22,
1138 textureOptions
[panel
->oldsection
].hand
.x
, textureOptions
[panel
->oldsection
].hand
.y
);
1141 panel
->oldsection
= section
;
1142 WMDrawPixmap(panel
->hand
, panel
->preview
, textureOptions
[section
].hand
.x
, textureOptions
[section
].hand
.y
);
1144 WMRedisplayWidget(panel
->prevL
);
1147 static void previewClick(XEvent
* event
, void *clientData
)
1149 _Panel
*panel
= (_Panel
*) clientData
;
1152 switch (panel
->oldTabItem
) {
1154 for (i
= 0; i
< wlengthof(textureOptions
); i
++) {
1155 if (event
->xbutton
.x
>= textureOptions
[i
].preview
.pos
.x
&&
1156 event
->xbutton
.y
>= textureOptions
[i
].preview
.pos
.y
&&
1157 event
->xbutton
.x
< textureOptions
[i
].preview
.pos
.x
+ textureOptions
[i
].preview
.size
.width
&&
1158 event
->xbutton
.y
< textureOptions
[i
].preview
.pos
.y
+ textureOptions
[i
].preview
.size
.height
) {
1160 WMSetPopUpButtonSelectedItem(panel
->secP
, i
);
1161 changePage(panel
->secP
, panel
);
1167 for (i
= 0; i
< WMGetPopUpButtonNumberOfItems(panel
->colP
); i
++) {
1168 if (event
->xbutton
.x
>= colorOptions
[i
].preview
.pos
.x
&&
1169 event
->xbutton
.y
>= colorOptions
[i
].preview
.pos
.y
&&
1170 event
->xbutton
.x
< colorOptions
[i
].preview
.pos
.x
+ colorOptions
[i
].preview
.size
.width
&&
1171 event
->xbutton
.y
< colorOptions
[i
].preview
.pos
.y
+ colorOptions
[i
].preview
.size
.height
) {
1174 * yuck kluge: the entry #7 is HighlightTextColor which does not have actually a
1175 * display area, but are reused to make the last "Normal Item" menu entry actually
1176 * pick the same color item as the other similar item displayed, which corresponds
1182 WMSetPopUpButtonSelectedItem(panel
->colP
, i
);
1183 changeColorPage(panel
->colP
, panel
);
1191 static void textureClick(WMWidget
* w
, void *data
)
1193 _Panel
*panel
= (_Panel
*) data
;
1196 TextureListItem
*titem
;
1198 /* Parameter not used, but tell the compiler that it is ok */
1201 i
= WMGetListSelectedItemRow(panel
->texLs
);
1203 item
= WMGetListItem(panel
->texLs
, i
);
1205 titem
= (TextureListItem
*) item
->clientData
;
1207 if (titem
->current
) {
1208 WMSetButtonEnabled(panel
->delB
, False
);
1210 WMSetButtonEnabled(panel
->delB
, True
);
1214 static void textureDoubleClick(WMWidget
* w
, void *data
)
1216 _Panel
*panel
= (_Panel
*) data
;
1219 TextureListItem
*titem
;
1221 /* Parameter not used, but tell the compiler that it is ok */
1224 /* unselect old texture */
1225 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
1227 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[section
]);
1228 titem
= (TextureListItem
*) item
->clientData
;
1229 titem
->selectedFor
&= ~(1 << section
);
1231 /* select new texture */
1232 i
= WMGetListSelectedItemRow(panel
->texLs
);
1234 item
= WMGetListItem(panel
->texLs
, i
);
1236 titem
= (TextureListItem
*) item
->clientData
;
1238 titem
->selectedFor
|= 1 << section
;
1240 panel
->textureIndex
[section
] = i
;
1242 WMRedisplayWidget(panel
->texLs
);
1244 if (section
== PBACKGROUND
)
1245 updatePreviewBox(panel
, EVERYTHING
);
1247 updatePreviewBox(panel
, 1 << section
);
1250 static void paintListItem(WMList
* lPtr
, int index
, Drawable d
, char *text
, int state
, WMRect
* rect
)
1252 _Panel
*panel
= (_Panel
*) WMGetHangedData(lPtr
);
1253 WMScreen
*scr
= WMWidgetScreen(lPtr
);
1254 int width
, height
, x
, y
;
1255 Display
*dpy
= WMScreenDisplay(scr
);
1256 WMColor
*back
= (state
& WLDSSelected
) ? WMWhiteColor(scr
) : WMGrayColor(scr
);
1258 WMColor
*black
= WMBlackColor(scr
);
1259 TextureListItem
*titem
;
1261 /* Parameter not used, but tell the compiler that it is ok */
1264 item
= WMGetListItem(lPtr
, index
);
1265 titem
= (TextureListItem
*) item
->clientData
;
1267 WMReleaseColor(back
);
1268 WMReleaseColor(black
);
1272 width
= rect
->size
.width
;
1273 height
= rect
->size
.height
;
1277 XFillRectangle(dpy
, d
, WMColorGC(back
), x
, y
, width
, height
);
1280 XCopyArea(dpy
, titem
->preview
, d
, WMColorGC(black
), 0, 0,
1281 TEXPREV_WIDTH
, TEXPREV_HEIGHT
, x
+ 5, y
+ 5);
1283 if ((1 << WMGetPopUpButtonSelectedItem(panel
->secP
)) & titem
->selectedFor
)
1284 WMDrawPixmap(panel
->onLed
, d
, x
+ TEXPREV_WIDTH
+ 10, y
+ 6);
1285 else if (titem
->selectedFor
)
1286 WMDrawPixmap(panel
->offLed
, d
, x
+ TEXPREV_WIDTH
+ 10, y
+ 6);
1288 WMDrawString(scr
, d
, black
, panel
->boldFont
,
1289 x
+ TEXPREV_WIDTH
+ 22, y
+ 2, titem
->title
, strlen(titem
->title
));
1291 WMDrawString(scr
, d
, black
, panel
->smallFont
,
1292 x
+ TEXPREV_WIDTH
+ 14, y
+ 18, titem
->texture
, strlen(titem
->texture
));
1294 WMReleaseColor(back
);
1295 WMReleaseColor(black
);
1298 static Pixmap
loadRImage(WMScreen
* scr
, const char *path
)
1306 f
= fopen(path
, "rb");
1310 cnt
= fscanf(f
, "%02x%02x%1x", &w
, &h
, &d
);
1315 image
= RCreateImage(w
, h
, d
== 4);
1316 read_size
= w
* h
* d
;
1317 if (fread(image
->data
, 1, read_size
, f
) == read_size
)
1318 RConvertImage(WMScreenRContext(scr
), image
, &pixmap
);
1324 RReleaseImage(image
);
1329 static void fillTextureList(WMList
* lPtr
)
1331 WMPropList
*textureList
;
1332 WMPropList
*texture
;
1333 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
1334 TextureListItem
*titem
;
1335 WMScreen
*scr
= WMWidgetScreen(lPtr
);
1338 textureList
= WMGetUDObjectForKey(udb
, "TextureList");
1342 for (i
= 0; i
< WMGetPropListItemCount(textureList
); i
++) {
1345 texture
= WMGetFromPLArray(textureList
, i
);
1347 titem
= wmalloc(sizeof(TextureListItem
));
1349 titem
->title
= wstrdup(WMGetFromPLString(WMGetFromPLArray(texture
, 0)));
1350 titem
->prop
= WMRetainPropList(WMGetFromPLArray(texture
, 1));
1351 titem
->texture
= WMGetPropListDescription(titem
->prop
, False
);
1352 titem
->selectedFor
= 0;
1353 titem
->path
= wstrdup(WMGetFromPLString(WMGetFromPLArray(texture
, 2)));
1355 titem
->preview
= loadRImage(scr
, titem
->path
);
1356 if (!titem
->preview
) {
1357 titem
->preview
= renderTexture(scr
, titem
->prop
, TEXPREV_WIDTH
, TEXPREV_HEIGHT
, NULL
, 0);
1359 item
= WMAddListItem(lPtr
, "");
1360 item
->clientData
= titem
;
1364 static void fillColorList(_Panel
* panel
)
1368 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
1369 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1372 list
= WMGetUDObjectForKey(udb
, "ColorList");
1374 for (i
= 0; i
< 24; i
++) {
1375 color
= WMCreateNamedColor(scr
, sampleColors
[i
], False
);
1378 WMSetColorWellColor(panel
->sampW
[i
], color
);
1379 WMReleaseColor(color
);
1384 for (i
= 0; i
< WMIN(24, WMGetPropListItemCount(list
)); i
++) {
1385 c
= WMGetFromPLArray(list
, i
);
1386 if (!c
|| !WMIsPLString(c
))
1388 color
= WMCreateNamedColor(scr
, WMGetFromPLString(c
), False
);
1391 WMSetColorWellColor(panel
->sampW
[i
], color
);
1392 WMReleaseColor(color
);
1397 /*************************************************************************/
1399 static void changeColorPage(WMWidget
* w
, void *data
)
1401 _Panel
*panel
= (_Panel
*) data
;
1403 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1404 RContext
*rc
= WMScreenRContext(scr
);
1406 if (panel
->preview
) {
1409 gc
= XCreateGC(rc
->dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
1410 XCopyArea(rc
->dpy
, panel
->previewBack
, panel
->preview
, gc
,
1411 colorOptions
[panel
->oldcsection
].hand
.x
,
1412 colorOptions
[panel
->oldcsection
].hand
.y
, 22, 22 ,
1413 colorOptions
[panel
->oldcsection
].hand
.x
,
1414 colorOptions
[panel
->oldcsection
].hand
.y
);
1417 section
= WMGetPopUpButtonSelectedItem(panel
->colP
);
1419 panel
->oldcsection
= section
;
1421 WMDrawPixmap(panel
->hand
, panel
->preview
,
1422 colorOptions
[section
].hand
.x
, colorOptions
[section
].hand
.y
);
1424 if (section
>= ICONT_COL
)
1425 updateColorPreviewBox(panel
, 1 << section
);
1427 WMSetColorWellColor(panel
->colW
, panel
->colors
[section
]);
1429 WMRedisplayWidget(panel
->prevL
);
1433 paintText(WMScreen
* scr
, Drawable d
, WMColor
* color
, WMFont
* font
,
1434 int x
, int y
, int w
, int h
, WMAlignment align
, char *text
)
1436 int l
= strlen(text
);
1443 x
+= w
- 5 - WMWidthOfString(font
, text
, l
);
1447 x
+= (w
- WMWidthOfString(font
, text
, l
)) / 2;
1450 WMDrawString(scr
, d
, color
, font
, x
, y
+ (h
- WMFontHeight(font
)) / 2, text
, l
);
1453 static void updateColorPreviewBox(_Panel
* panel
, int elements
)
1455 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1456 Display
*dpy
= WMScreenDisplay(scr
);
1461 pnot
= panel
->previewNoText
;
1462 gc
= WMColorGC(panel
->colors
[FTITLE_COL
]);
1464 if (elements
& (1 << FTITLE_COL
)) {
1465 XCopyArea(dpy
, pnot
, d
, gc
, 30, 10, 190, 20, 30, 10);
1466 paintText(scr
, d
, panel
->colors
[FTITLE_COL
],
1467 panel
->boldFont
, 30, 10, 190, 20,
1468 panel
->titleAlignment
, _("Focused Window"));
1470 if (elements
& (1 << UTITLE_COL
)) {
1471 XCopyArea(dpy
, pnot
, d
, gc
, 30, 40, 190, 20, 30, 40);
1472 paintText(scr
, d
, panel
->colors
[UTITLE_COL
],
1473 panel
->boldFont
, 30, 40, 190, 20,
1474 panel
->titleAlignment
,
1475 _("Unfocused Window"));
1477 if (elements
& (1 << OTITLE_COL
)) {
1478 XCopyArea(dpy
, pnot
, d
, gc
, 30, 70, 190, 20, 30, 70);
1479 paintText(scr
, d
, panel
->colors
[OTITLE_COL
],
1480 panel
->boldFont
, 30, 70, 190, 20,
1481 panel
->titleAlignment
,
1482 _("Owner of Focused Window"));
1484 if (elements
& (1 << MTITLE_COL
)) {
1485 XCopyArea(dpy
, pnot
, d
, gc
, 30, 120, 90, 20, 30, 120);
1486 paintText(scr
, d
, panel
->colors
[MTITLE_COL
],
1487 panel
->boldFont
, 30, 120, 90, 20, WALeft
,
1490 if (elements
& (1 << MITEM_COL
)) {
1491 XCopyArea(dpy
, pnot
, d
, gc
, 30, 140, 90, 20, 30, 140);
1492 paintText(scr
, d
, panel
->colors
[MITEM_COL
],
1493 panel
->normalFont
, 30, 140, 90, 20, WALeft
,
1495 XCopyArea(dpy
, pnot
, d
, gc
, 30, 200, 90, 20, 30, 200);
1496 paintText(scr
, d
, panel
->colors
[MITEM_COL
],
1497 panel
->normalFont
, 30, 200, 90, 20, WALeft
,
1500 if (elements
& (1 << MDISAB_COL
)) {
1501 XCopyArea(dpy
, pnot
, d
, gc
, 30, 160, 90, 20, 30, 160);
1502 paintText(scr
, d
, panel
->colors
[MDISAB_COL
],
1503 panel
->normalFont
, 30, 160, 90, 20, WALeft
,
1504 _("Disabled Item"));
1506 if (elements
& (1 << MHIGH_COL
)) {
1507 XFillRectangle(WMScreenDisplay(scr
), d
,
1508 WMColorGC(panel
->colors
[MHIGH_COL
]),
1510 XFillRectangle(WMScreenDisplay(scr
), pnot
,
1511 WMColorGC(panel
->colors
[MHIGH_COL
]),
1513 elements
|= 1 << MHIGHT_COL
;
1515 if (elements
& (1 << MHIGHT_COL
)) {
1516 XCopyArea(dpy
, pnot
, d
, gc
, 30, 180, 90, 20, 30, 180);
1517 paintText(scr
, d
, panel
->colors
[MHIGHT_COL
],
1518 panel
->normalFont
, 30, 180, 90, 20, WALeft
,
1521 if (elements
& (1 << FBORDER_COL
)) {
1522 XDrawRectangle(dpy
, pnot
,
1523 WMColorGC(panel
->colors
[FBORDER_COL
]),
1525 XDrawRectangle(dpy
, d
,
1526 WMColorGC(panel
->colors
[FBORDER_COL
]),
1528 XDrawRectangle(dpy
, pnot
,
1529 WMColorGC(panel
->colors
[FBORDER_COL
]),
1531 XDrawRectangle(dpy
, d
,
1532 WMColorGC(panel
->colors
[FBORDER_COL
]),
1534 XDrawLine(dpy
, pnot
,
1535 WMColorGC(panel
->colors
[FBORDER_COL
]),
1538 WMColorGC(panel
->colors
[FBORDER_COL
]),
1540 XDrawLine(dpy
, pnot
,
1541 WMColorGC(panel
->colors
[FBORDER_COL
]),
1544 WMColorGC(panel
->colors
[FBORDER_COL
]),
1546 XDrawLine(dpy
, pnot
,
1547 WMColorGC(panel
->colors
[FBORDER_COL
]),
1548 220, 100, 220, 109);
1550 WMColorGC(panel
->colors
[FBORDER_COL
]),
1551 220, 100, 220, 109);
1552 XDrawLine(dpy
, pnot
,
1553 WMColorGC(panel
->colors
[FBORDER_COL
]),
1556 WMColorGC(panel
->colors
[FBORDER_COL
]),
1558 XDrawLine(dpy
, pnot
,
1559 WMColorGC(panel
->colors
[FBORDER_COL
]),
1562 WMColorGC(panel
->colors
[FBORDER_COL
]),
1564 XDrawLine(dpy
, pnot
,
1565 WMColorGC(panel
->colors
[FBORDER_COL
]),
1566 119, 120, 119, 220);
1568 WMColorGC(panel
->colors
[FBORDER_COL
]),
1569 119, 120, 119, 220);
1572 if (elements
& (1 << FFBORDER_COL
)) {
1573 XDrawRectangle(dpy
, pnot
,
1574 WMColorGC(panel
->colors
[FFBORDER_COL
]),
1576 XDrawRectangle(dpy
, d
,
1577 WMColorGC(panel
->colors
[FFBORDER_COL
]),
1581 if (elements
& (1 << ICONT_COL
) || elements
& (1 << ICONB_COL
)) {
1583 RHSVColor hsv
, hsv2
;
1585 WMColor
*light
, *dim
;
1587 updatePreviewBox(panel
, 1 << PICON
);
1589 rgb
.red
= WMRedComponentOfColor(panel
->colors
[ICONB_COL
]) >> 8;
1590 rgb
.green
= WMGreenComponentOfColor(panel
->colors
[ICONB_COL
]) >> 8;
1591 rgb
.blue
= WMBlueComponentOfColor(panel
->colors
[ICONB_COL
]) >> 8;
1592 RRGBtoHSV(&rgb
, &hsv
);
1593 RHSVtoRGB(&hsv
, &rgb
);
1596 v
= hsv
.value
* 16 / 10;
1597 hsv
.value
= (v
> 255 ? 255 : v
);
1598 RHSVtoRGB(&hsv
, &rgb
);
1599 light
= WMCreateRGBColor(scr
, rgb
.red
<< 8, rgb
.green
<< 8, rgb
.blue
<< 8, False
);
1601 hsv2
.value
= hsv2
.value
/ 2;
1602 RHSVtoRGB(&hsv2
, &rgb
);
1603 dim
= WMCreateRGBColor(scr
, rgb
.red
<< 8, rgb
.green
<< 8, rgb
.blue
<< 8, False
);
1605 XFillRectangle(dpy
, d
, WMColorGC(panel
->colors
[ICONB_COL
]), 156, 131, 62, 11);
1606 XDrawLine(dpy
, d
, WMColorGC(light
), 155, 130, 155, 142);
1607 XDrawLine(dpy
, d
, WMColorGC(light
), 156, 130, 217, 130);
1608 XDrawLine(dpy
, d
, WMColorGC(dim
), 218, 130, 218, 142);
1610 paintText(scr
, d
, panel
->colors
[ICONT_COL
],
1611 panel
->smallFont
, 155, 130, 64, 13, WALeft
,
1616 if (elements
& (1 << CLIP_COL
) || elements
& (1 << CCLIP_COL
)) {
1622 TextureListItem
*titem
;
1626 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[PICON
]);
1627 titem
= (TextureListItem
*) item
->clientData
;
1629 pix
= renderTexture(scr
, titem
->prop
, 64, 64, NULL
, titem
->ispixmap
? 0 : RBEV_RAISED3
);
1630 tile
= RCreateImageFromDrawable(WMScreenRContext(scr
), pix
, None
);
1633 black
.red
= black
.green
= black
.blue
= 0;
1636 dark
.red
= dark
.green
= dark
.blue
= 60;
1639 light
.red
= light
.green
= light
.blue
= 80;
1642 ROperateLine(tile
, RSubtractOperation
, 64 - 1 - 23, 0, 64 - 2, 23 - 1, &dark
);
1643 RDrawLine(tile
, 64 - 1 - 23 - 1, 0, 64 - 1, 23 + 1, &black
);
1644 ROperateLine(tile
, RAddOperation
, 64 - 1 - 23, 2, 64 - 3, 23, &light
);
1647 ROperateLine(tile
, RSubtractOperation
, 64 - 7 - (23 - 15), 4, 64 - 5, 4, &dark
);
1648 ROperateLine(tile
, RSubtractOperation
, 64 - 6 - (23 - 15), 5, 64 - 5, 6 + 23 - 15, &dark
);
1649 ROperateLine(tile
, RAddOperation
, 64 - 5, 4, 64 - 5, 6 + 23 - 15, &light
);
1652 ROperateLine(tile
, RAddOperation
, 2, 64 - 1 - 23 + 2, 23 - 2, 64 - 3, &dark
);
1653 RDrawLine(tile
, 0, 64 - 1 - 23 - 1, 23 + 1, 64 - 1, &black
);
1654 ROperateLine(tile
, RSubtractOperation
, 0, 64 - 1 - 23 - 2, 23 + 1, 64 - 2, &light
);
1657 ROperateLine(tile
, RSubtractOperation
, 4, 64 - 7 - (23 - 15), 4, 64 - 5, &dark
);
1658 ROperateLine(tile
, RSubtractOperation
, 5, 64 - 6 - (23 - 15), 6 + 23 - 15, 64 - 5, &dark
);
1659 ROperateLine(tile
, RAddOperation
, 4, 64 - 5, 6 + 23 - 15, 64 - 5, &light
);
1661 RConvertImage(WMScreenRContext(scr
), tile
, &pix
);
1662 RReleaseImage(tile
);
1664 XCopyArea(dpy
, pix
, d
, gc
, 0, 0, 64, 64, 155, 130);
1665 XFreePixmap(dpy
, pix
);
1667 /* top right arrow */
1668 p
[0].x
= p
[3].x
= 155 + 64 - 5 - (23 - 15);
1669 p
[0].y
= p
[3].y
= 130 + 5;
1670 p
[1].x
= 155 + 64 - 6;
1672 p
[2].x
= 155 + 64 - 6;
1673 p
[2].y
= 130 + 4 + 23 - 15;
1675 XFillPolygon(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 3, Convex
, CoordModeOrigin
);
1676 XDrawLines(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 4, CoordModeOrigin
);
1678 /* bottom left arrow */
1679 p
[0].x
= p
[3].x
= 155 + 5;
1680 p
[0].y
= p
[3].y
= 130 + 64 - 5 - (23 - 15);
1682 p
[1].y
= 130 + 64 - 6;
1683 p
[2].x
= 155 + 4 + 23 - 15;
1684 p
[2].y
= 130 + 64 - 6;
1686 XFillPolygon(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 3, Convex
, CoordModeOrigin
);
1687 XDrawLines(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 4, CoordModeOrigin
);
1691 if (elements
& (1 << CLIP_COL
))
1692 paintText(scr
, d
, panel
->colors
[CLIP_COL
],
1693 panel
->boldFont
, 155 + 23, 130 + 64 - 15 - 3, 22, 15, WALeft
,
1696 if (elements
& (1 << CCLIP_COL
)) {
1697 paintText(scr
, d
, panel
->colors
[CCLIP_COL
],
1698 panel
->boldFont
, 155+2, 130 + 2, 26, 15, WALeft
, _("Coll."));
1699 paintText(scr
, d
, panel
->colors
[CCLIP_COL
],
1700 panel
->boldFont
, 155 + 23, 130 + 64 - 15 - 3, 22, 15, WALeft
,
1704 WMRedisplayWidget(panel
->prevL
);
1707 static void colorWellObserver(void *self
, WMNotification
* n
)
1709 _Panel
*panel
= (_Panel
*) self
;
1712 /* Parameter not used, but tell the compiler that it is ok */
1715 p
= WMGetPopUpButtonSelectedItem(panel
->colP
);
1717 WMReleaseColor(panel
->colors
[p
]);
1719 panel
->colors
[p
] = WMRetainColor(WMGetColorWellColor(panel
->colW
));
1721 updateColorPreviewBox(panel
, 1 << p
);
1724 static void changedTabItem(struct WMTabViewDelegate
*self
, WMTabView
* tabView
, WMTabViewItem
* item
)
1726 _Panel
*panel
= self
->data
;
1729 /* Parameter not used, but tell the compiler that it is ok */
1732 i
= WMGetTabViewItemIdentifier(item
);
1735 switch (panel
->oldTabItem
) {
1737 changeColorPage(NULL
, panel
);
1740 changePage(panel
->secP
, panel
);
1743 switch (panel
->oldTabItem
) {
1745 changePage(NULL
, panel
);
1748 changeColorPage(panel
->colP
, panel
);
1751 switch (panel
->oldTabItem
) {
1753 changePage(NULL
, panel
);
1756 changeColorPage(NULL
, panel
);
1762 panel
->oldTabItem
= i
;
1765 /*************************************************************************/
1767 static void menuStyleCallback(WMWidget
* self
, void *data
)
1769 _Panel
*panel
= (_Panel
*) data
;
1772 for (i
= 0; i
< wlengthof(menu_style
); i
++) {
1773 if (self
== panel
->mstyB
[i
]) {
1774 panel
->menuStyle
= i
;
1779 updatePreviewBox(panel
, 1 << PMITEM
);
1782 static void titleAlignCallback(WMWidget
* self
, void *data
)
1784 _Panel
*panel
= (_Panel
*) data
;
1787 for (align
= 0; align
< wlengthof(wintitle_align
); align
++) {
1788 if (self
== panel
->taliB
[align
]) {
1789 panel
->titleAlignment
= align
;
1794 updatePreviewBox(panel
, 1 << PFOCUSED
| 1 << PUNFOCUSED
| 1 << POWNER
);
1797 static void createPanel(Panel
* p
)
1799 _Panel
*panel
= (_Panel
*) p
;
1801 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
1802 WMTabViewItem
*item
;
1807 panel
->fprefix
= wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
1809 if (access(panel
->fprefix
, F_OK
) != 0) {
1810 if (mkdir(panel
->fprefix
, 0755) < 0) {
1811 werror("%s", panel
->fprefix
);
1816 tmp
= wstrconcat(panel
->fprefix
, "/WPrefs/");
1817 wfree(panel
->fprefix
);
1818 panel
->fprefix
= tmp
;
1819 if (access(panel
->fprefix
, F_OK
) != 0) {
1820 if (mkdir(panel
->fprefix
, 0755) < 0) {
1821 werror("%s", panel
->fprefix
);
1826 panel
->smallFont
= WMSystemFontOfSize(scr
, 10);
1827 panel
->normalFont
= WMSystemFontOfSize(scr
, 12);
1828 panel
->boldFont
= WMBoldSystemFontOfSize(scr
, 12);
1830 panel
->onLed
= WMCreatePixmapFromXPMData(scr
, blueled_xpm
);
1831 panel
->offLed
= WMCreatePixmapFromXPMData(scr
, blueled2_xpm
);
1832 panel
->hand
= WMCreatePixmapFromXPMData(scr
, hand_xpm
);
1834 panel
->box
= WMCreateBox(panel
->parent
);
1835 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
1838 panel
->prevL
= WMCreateLabel(panel
->box
);
1839 WMResizeWidget(panel
->prevL
, 240, FRAME_HEIGHT
- 20);
1840 WMMoveWidget(panel
->prevL
, 15, 10);
1841 WMSetLabelRelief(panel
->prevL
, WRSunken
);
1842 WMSetLabelImagePosition(panel
->prevL
, WIPImageOnly
);
1844 WMCreateEventHandler(WMWidgetView(panel
->prevL
), ButtonPressMask
, previewClick
, panel
);
1848 tabviewDelegate
.data
= panel
;
1850 panel
->tabv
= WMCreateTabView(panel
->box
);
1851 WMResizeWidget(panel
->tabv
, 245, FRAME_HEIGHT
- 20);
1852 WMMoveWidget(panel
->tabv
, 265, 10);
1853 WMSetTabViewDelegate(panel
->tabv
, &tabviewDelegate
);
1855 /*** texture list ***/
1857 panel
->texF
= WMCreateFrame(panel
->box
);
1858 WMSetFrameRelief(panel
->texF
, WRFlat
);
1860 item
= WMCreateTabViewItemWithIdentifier(TAB_TEXTURE
);
1861 WMSetTabViewItemView(item
, WMWidgetView(panel
->texF
));
1862 WMSetTabViewItemLabel(item
, _("Texture"));
1864 WMAddItemInTabView(panel
->tabv
, item
);
1866 panel
->secP
= WMCreatePopUpButton(panel
->texF
);
1867 WMResizeWidget(panel
->secP
, 228, 20);
1868 WMMoveWidget(panel
->secP
, 7, 7);
1870 for (i
= 0; i
< wlengthof(textureOptions
); i
++)
1871 WMAddPopUpButtonItem(panel
->secP
, _(textureOptions
[i
].popup_label
));
1873 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
1874 WMSetPopUpButtonAction(panel
->secP
, changePage
, panel
);
1876 panel
->texLs
= WMCreateList(panel
->texF
);
1877 WMResizeWidget(panel
->texLs
, 165, 155);
1878 WMMoveWidget(panel
->texLs
, 70, 33);
1879 WMSetListUserDrawItemHeight(panel
->texLs
, 35);
1880 WMSetListUserDrawProc(panel
->texLs
, paintListItem
);
1881 WMHangData(panel
->texLs
, panel
);
1882 WMSetListAction(panel
->texLs
, textureClick
, panel
);
1883 WMSetListDoubleAction(panel
->texLs
, textureDoubleClick
, panel
);
1885 WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
1886 "for the selected item."), WMWidgetView(panel
->texLs
));
1888 /* command buttons */
1890 font
= WMSystemFontOfSize(scr
, 10);
1892 panel
->newB
= WMCreateCommandButton(panel
->texF
);
1893 WMResizeWidget(panel
->newB
, 57, 39);
1894 WMMoveWidget(panel
->newB
, 7, 33);
1895 WMSetButtonFont(panel
->newB
, font
);
1896 WMSetButtonImagePosition(panel
->newB
, WIPAbove
);
1897 WMSetButtonText(panel
->newB
, _("New"));
1898 WMSetButtonAction(panel
->newB
, newTexture
, panel
);
1899 SetButtonAlphaImage(scr
, panel
->newB
, TNEW_FILE
);
1901 WMSetBalloonTextForView(_("Create a new texture."), WMWidgetView(panel
->newB
));
1903 panel
->ripB
= WMCreateCommandButton(panel
->texF
);
1904 WMResizeWidget(panel
->ripB
, 57, 39);
1905 WMMoveWidget(panel
->ripB
, 7, 72);
1906 WMSetButtonFont(panel
->ripB
, font
);
1907 WMSetButtonImagePosition(panel
->ripB
, WIPAbove
);
1908 WMSetButtonText(panel
->ripB
, _("Extract..."));
1909 WMSetButtonAction(panel
->ripB
, extractTexture
, panel
);
1910 SetButtonAlphaImage(scr
, panel
->ripB
, TEXTR_FILE
);
1912 WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."), WMWidgetView(panel
->ripB
));
1914 WMSetButtonEnabled(panel
->ripB
, False
);
1916 panel
->editB
= WMCreateCommandButton(panel
->texF
);
1917 WMResizeWidget(panel
->editB
, 57, 39);
1918 WMMoveWidget(panel
->editB
, 7, 111);
1919 WMSetButtonFont(panel
->editB
, font
);
1920 WMSetButtonImagePosition(panel
->editB
, WIPAbove
);
1921 WMSetButtonText(panel
->editB
, _("Edit"));
1922 SetButtonAlphaImage(scr
, panel
->editB
, TEDIT_FILE
);
1923 WMSetButtonAction(panel
->editB
, editTexture
, panel
);
1924 WMSetBalloonTextForView(_("Edit the highlighted texture."), WMWidgetView(panel
->editB
));
1926 panel
->delB
= WMCreateCommandButton(panel
->texF
);
1927 WMResizeWidget(panel
->delB
, 57, 38);
1928 WMMoveWidget(panel
->delB
, 7, 150);
1929 WMSetButtonFont(panel
->delB
, font
);
1930 WMSetButtonImagePosition(panel
->delB
, WIPAbove
);
1931 WMSetButtonText(panel
->delB
, _("Delete"));
1932 SetButtonAlphaImage(scr
, panel
->delB
, TDEL_FILE
);
1933 WMSetButtonEnabled(panel
->delB
, False
);
1934 WMSetButtonAction(panel
->delB
, deleteTexture
, panel
);
1935 WMSetBalloonTextForView(_("Delete the highlighted texture."), WMWidgetView(panel
->delB
));
1937 WMReleaseFont(font
);
1939 WMMapSubwidgets(panel
->texF
);
1942 panel
->colF
= WMCreateFrame(panel
->box
);
1943 WMSetFrameRelief(panel
->colF
, WRFlat
);
1945 item
= WMCreateTabViewItemWithIdentifier(TAB_COLOR
);
1946 WMSetTabViewItemView(item
, WMWidgetView(panel
->colF
));
1947 WMSetTabViewItemLabel(item
, _("Color"));
1949 WMAddItemInTabView(panel
->tabv
, item
);
1951 panel
->colP
= WMCreatePopUpButton(panel
->colF
);
1952 WMResizeWidget(panel
->colP
, 228, 20);
1953 WMMoveWidget(panel
->colP
, 7, 7);
1955 for (i
= 0; i
< wlengthof(colorOptions
); i
++)
1956 WMAddPopUpButtonItem(panel
->colP
, _(colorOptions
[i
].label
));
1958 WMSetPopUpButtonSelectedItem(panel
->colP
, 0);
1960 WMSetPopUpButtonAction(panel
->colP
, changeColorPage
, panel
);
1962 panel
->colW
= WMCreateColorWell(panel
->colF
);
1963 WMResizeWidget(panel
->colW
, 65, 50);
1964 WMMoveWidget(panel
->colW
, 30, 75);
1965 WMAddNotificationObserver(colorWellObserver
, panel
, WMColorWellDidChangeNotification
, panel
->colW
);
1967 for (i
= 0; i
< 4; i
++) {
1969 for (j
= 0; j
< 6; j
++) {
1970 panel
->sampW
[i
+ j
* 4] = WMCreateColorWell(panel
->colF
);
1971 WMResizeWidget(panel
->sampW
[i
+ j
* 4], 22, 22);
1972 WMMoveWidget(panel
->sampW
[i
+ j
* 4], 130 + i
* 22, 40 + j
* 22);
1973 WSetColorWellBordered(panel
->sampW
[i
+ j
* 4], False
);
1977 WMMapSubwidgets(panel
->colF
);
1980 panel
->optF
= WMCreateFrame(panel
->box
);
1981 WMSetFrameRelief(panel
->optF
, WRFlat
);
1983 item
= WMCreateTabViewItemWithIdentifier(TAB_OPTIONS
);
1984 WMSetTabViewItemView(item
, WMWidgetView(panel
->optF
));
1985 WMSetTabViewItemLabel(item
, _("Options"));
1987 WMAddItemInTabView(panel
->tabv
, item
);
1989 panel
->mstyF
= WMCreateFrame(panel
->optF
);
1990 WMResizeWidget(panel
->mstyF
, 215, 85);
1991 WMMoveWidget(panel
->mstyF
, 15, 10);
1992 WMSetFrameTitle(panel
->mstyF
, _("Menu Style"));
1994 for (i
= 0; i
< wlengthof(menu_style
); i
++) {
1998 panel
->mstyB
[i
] = WMCreateButton(panel
->mstyF
, WBTOnOff
);
1999 WMResizeWidget(panel
->mstyB
[i
], 54, 54);
2000 WMMoveWidget(panel
->mstyB
[i
], 15 + i
* 65, 20);
2001 WMSetButtonImagePosition(panel
->mstyB
[i
], WIPImageOnly
);
2002 WMSetButtonAction(panel
->mstyB
[i
], menuStyleCallback
, panel
);
2003 path
= LocateImage(menu_style
[i
].file_name
);
2005 icon
= WMCreatePixmapFromFile(scr
, path
);
2007 WMSetButtonImage(panel
->mstyB
[i
], icon
);
2008 WMReleasePixmap(icon
);
2010 wwarning(_("could not load icon file %s"), path
);
2015 WMGroupButtons(panel
->mstyB
[0], panel
->mstyB
[1]);
2016 WMGroupButtons(panel
->mstyB
[0], panel
->mstyB
[2]);
2018 WMMapSubwidgets(panel
->mstyF
);
2020 panel
->taliF
= WMCreateFrame(panel
->optF
);
2021 WMResizeWidget(panel
->taliF
, 110, 80);
2022 WMMoveWidget(panel
->taliF
, 15, 100);
2023 WMSetFrameTitle(panel
->taliF
, _("Title Alignment"));
2025 for (i
= 0; i
< wlengthof(wintitle_align
); i
++) {
2026 panel
->taliB
[i
] = WMCreateRadioButton(panel
->taliF
);
2027 WMSetButtonAction(panel
->taliB
[i
], titleAlignCallback
, panel
);
2028 WMSetButtonText(panel
->taliB
[i
], _(wintitle_align
[i
].label
));
2029 WMResizeWidget(panel
->taliB
[i
], 90, 18);
2030 WMMoveWidget(panel
->taliB
[i
], 10, 15 + 20 * i
);
2032 WMGroupButtons(panel
->taliB
[0], panel
->taliB
[1]);
2033 WMGroupButtons(panel
->taliB
[0], panel
->taliB
[2]);
2035 WMMapSubwidgets(panel
->taliF
);
2037 WMMapSubwidgets(panel
->optF
);
2039 /**/ WMRealizeWidget(panel
->box
);
2040 WMMapSubwidgets(panel
->box
);
2042 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
2046 changePage(panel
->secP
, panel
);
2048 fillTextureList(panel
->texLs
);
2050 fillColorList(panel
);
2052 panel
->texturePanel
= CreateTexturePanel(panel
->parent
);
2055 static void setupTextureFor(WMList
*list
, const char *key
, const char *defValue
, const char *title
, int index
)
2058 TextureListItem
*titem
;
2060 titem
= wmalloc(sizeof(TextureListItem
));
2062 titem
->title
= wstrdup(title
);
2063 titem
->prop
= GetObjectForKey(key
);
2064 if (!titem
->prop
|| !WMIsPLArray(titem
->prop
)) {
2065 /* Maybe also give a error message to stderr that the entry is bad? */
2066 titem
->prop
= WMCreatePropListFromDescription(defValue
);
2068 WMRetainPropList(titem
->prop
);
2070 titem
->texture
= WMGetPropListDescription((WMPropList
*) titem
->prop
, False
);
2072 titem
->selectedFor
= 1 << index
;
2074 titem
->ispixmap
= isPixmap(titem
->prop
);
2076 titem
->preview
= renderTexture(WMWidgetScreen(list
), titem
->prop
, TEXPREV_WIDTH
, TEXPREV_HEIGHT
, NULL
, 0);
2078 item
= WMAddListItem(list
, "");
2079 item
->clientData
= titem
;
2082 static void showData(_Panel
* panel
)
2087 str
= GetStringForKey("MenuStyle");
2088 panel
->menuStyle
= MSTYLE_NORMAL
;
2090 for (i
= 0; i
< wlengthof(menu_style
); i
++) {
2091 if (strcasecmp(str
, menu_style
[i
].db_value
) == 0) {
2092 panel
->menuStyle
= i
;
2098 str
= GetStringForKey("TitleJustify");
2099 panel
->titleAlignment
= WACenter
;
2103 for (align
= 0; align
< wlengthof(wintitle_align
); align
++) {
2104 if (strcasecmp(str
, wintitle_align
[align
].db_value
) == 0) {
2105 panel
->titleAlignment
= align
;
2111 for (i
= 0; i
< wlengthof(colorOptions
); i
++) {
2114 str
= GetStringForKey(colorOptions
[i
].key
);
2116 str
= colorOptions
[i
].default_value
;
2118 if (!(color
= WMCreateNamedColor(WMWidgetScreen(panel
->box
), str
, False
))) {
2119 color
= WMCreateNamedColor(WMWidgetScreen(panel
->box
), "#000000", False
);
2122 panel
->colors
[i
] = color
;
2124 changeColorPage(panel
->colP
, panel
);
2126 for (i
= 0; i
< wlengthof(textureOptions
); i
++) {
2127 setupTextureFor(panel
->texLs
, textureOptions
[i
].key
,
2128 textureOptions
[i
].default_value
, _(textureOptions
[i
].texture_label
), i
);
2129 panel
->textureIndex
[i
] = i
;
2131 updatePreviewBox(panel
, EVERYTHING
);
2133 WMSetButtonSelected(panel
->mstyB
[panel
->menuStyle
], True
);
2134 WMSetButtonSelected(panel
->taliB
[panel
->titleAlignment
], True
);
2137 static void storeData(_Panel
* panel
)
2139 TextureListItem
*titem
;
2143 for (i
= 0; i
< wlengthof(textureOptions
); i
++) {
2144 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[i
]);
2145 titem
= (TextureListItem
*) item
->clientData
;
2146 SetObjectForKey(titem
->prop
, textureOptions
[i
].key
);
2149 for (i
= 0; i
< wlengthof(colorOptions
); i
++) {
2152 str
= WMGetColorRGBDescription(panel
->colors
[i
]);
2155 SetStringForKey(str
, colorOptions
[i
].key
);
2160 SetStringForKey(menu_style
[panel
->menuStyle
].db_value
, "MenuStyle");
2161 SetStringForKey(wintitle_align
[panel
->titleAlignment
].db_value
, "TitleJustify");
2164 static void prepareForClose(_Panel
* panel
)
2166 WMPropList
*textureList
;
2167 WMPropList
*texture
;
2168 TextureListItem
*titem
;
2170 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
2173 textureList
= WMCreatePLArray(NULL
, NULL
);
2175 /* store list of textures */
2176 for (i
= 8; i
< WMGetListNumberOfRows(panel
->texLs
); i
++) {
2177 item
= WMGetListItem(panel
->texLs
, i
);
2178 titem
= (TextureListItem
*) item
->clientData
;
2180 texture
= WMCreatePLArray(WMCreatePLString(titem
->title
),
2181 WMRetainPropList(titem
->prop
), WMCreatePLString(titem
->path
), NULL
);
2183 WMAddToPLArray(textureList
, texture
);
2186 WMSetUDObjectForKey(udb
, textureList
, "TextureList");
2187 WMReleasePropList(textureList
);
2189 /* store list of colors */
2190 textureList
= WMCreatePLArray(NULL
, NULL
);
2191 for (i
= 0; i
< 24; i
++) {
2195 color
= WMGetColorWellColor(panel
->sampW
[i
]);
2197 str
= WMGetColorRGBDescription(color
);
2198 WMAddToPLArray(textureList
, WMCreatePLString(str
));
2201 WMSetUDObjectForKey(udb
, textureList
, "ColorList");
2202 WMReleasePropList(textureList
);
2204 WMSynchronizeUserDefaults(udb
);
2207 Panel
*InitAppearance(WMWidget
*parent
)
2211 panel
= wmalloc(sizeof(_Panel
));
2213 panel
->sectionName
= _("Appearance Preferences");
2215 panel
->description
= _("Background texture configuration for windows,\n" "menus and icons.");
2217 panel
->parent
= parent
;
2219 panel
->callbacks
.createWidgets
= createPanel
;
2220 panel
->callbacks
.updateDomain
= storeData
;
2221 panel
->callbacks
.prepareForClose
= prepareForClose
;
2223 AddSection(panel
, ICON_FILE
);
2228 /****************************************************************************/
2230 typedef struct ExtractPanel
{
2240 static void OpenExtractPanelFor(_Panel
*panel
)
2242 ExtractPanel
*epanel
;
2245 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
2247 epanel
= wmalloc(sizeof(ExtractPanel
));
2248 epanel
->win
= WMCreatePanelWithStyleForWindow(panel
->parent
, "extract",
2249 WMTitledWindowMask
| WMClosableWindowMask
);
2250 WMResizeWidget(epanel
->win
, 245, 250);
2251 WMSetWindowTitle(epanel
->win
, _("Extract Texture"));
2253 epanel
->label
= WMCreateLabel(epanel
->win
);
2254 WMResizeWidget(epanel
->label
, 225, 18);
2255 WMMoveWidget(epanel
->label
, 10, 10);
2256 WMSetLabelTextAlignment(epanel
->label
, WACenter
);
2257 WMSetLabelRelief(epanel
->label
, WRSunken
);
2259 color
= WMDarkGrayColor(scr
);
2260 WMSetWidgetBackgroundColor(epanel
->label
, color
);
2261 WMReleaseColor(color
);
2263 color
= WMWhiteColor(scr
);
2264 WMSetLabelTextColor(epanel
->label
, color
);
2265 WMReleaseColor(color
);
2267 font
= WMBoldSystemFontOfSize(scr
, 12);
2268 WMSetLabelFont(epanel
->label
, font
);
2269 WMReleaseFont(font
);
2271 WMSetLabelText(epanel
->label
, _("Textures"));
2273 epanel
->list
= WMCreateList(epanel
->win
);
2274 WMResizeWidget(epanel
->list
, 225, 165);
2275 WMMoveWidget(epanel
->list
, 10, 30);
2277 epanel
->closeB
= WMCreateCommandButton(epanel
->win
);
2278 WMResizeWidget(epanel
->closeB
, 74, 24);
2279 WMMoveWidget(epanel
->closeB
, 165, 215);
2280 WMSetButtonText(epanel
->closeB
, _("Close"));
2282 epanel
->extrB
= WMCreateCommandButton(epanel
->win
);
2283 WMResizeWidget(epanel
->extrB
, 74, 24);
2284 WMMoveWidget(epanel
->extrB
, 80, 215);
2285 WMSetButtonText(epanel
->extrB
, _("Extract"));
2287 WMMapSubwidgets(epanel
->win
);
2289 /* take textures from file */
2291 WMRealizeWidget(epanel
->win
);
2293 WMMapWidget(epanel
->win
);