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>
33 #include "TexturePanel.h"
38 const char *default_value
;
40 WMRect preview
; /* The rectangle where the corresponding object is displayed */
41 WMPoint hand
; /* The coordinate where the hand is drawn when pointing this item */
43 /* Related to Window titles */
44 { "FTitleColor", "white", N_("Focused Window Title"),
45 { { 30, 10 }, { 190, 20 } }, { 5, 10 } },
46 { "UTitleColor", "black", N_("Unfocused Window Title"),
47 { { 30, 40 }, { 190, 20 } }, { 5, 40 } },
48 { "PTitleColor", "white", N_("Owner of Focused Window Title"),
49 { { 30, 70 }, { 190, 20 } }, { 5, 70 } },
51 /* Related to Menus */
52 { "MenuTitleColor", "white", N_("Menu Title") ,
53 { { 30, 120 }, { 90, 20 } }, { 5, 120 } },
54 { "MenuTextColor", "black", N_("Menu Item Text") ,
55 { { 30, 140 }, { 90, 20 } }, { 5, 140 } },
56 { "MenuDisabledColor", "#616161", N_("Disabled Menu Item Text") ,
57 { { 30, 160 }, { 90, 20 } }, { 5, 160 } },
58 { "HighlightColor", "white", N_("Menu Highlight Color") ,
59 { { 30, 180 }, { 90, 20 } }, { 5, 180 } },
60 { "HighlightTextColor", "black", N_("Highlighted Menu Text Color") ,
61 { { 30, 200 }, { 90, 20 } }, { 5, 180 } },
63 * yuck kluge: the coordinate for HighlightTextColor are actually those of the last "Normal item"
64 * at the bottom when user clicks it, the "yuck kluge" in the function 'previewClick' will swap it
65 * for the MenuTextColor selection as user would expect
67 * Note that the entries are reffered by their index for performance
70 /* Related to Window's border */
71 { "FrameFocusedBorderColor", "black", N_("Focused Window Border Color") ,
72 { { 0, 0 }, { 0, 0 } }, { -22, -21 } },
73 { "FrameBorderColor", "black", N_("Window Border Color") ,
74 { { 0, 0 }, { 0, 0 } }, { -22, -21 } },
75 { "FrameSelectedBorderColor", "white", N_("Selected Window Border Color") ,
76 { { 0, 0 }, { 0, 0 } }, { -22, -21 } },
78 /* Related to Icons and Clip */
79 { "IconTitleColor", "white", N_("Miniwindow Title") ,
80 { { 155, 130 }, { 64, 64 } }, { 130, 132 } },
81 { "IconTitleBack", "black", N_("Miniwindow Title Back") ,
82 { { 155, 130 }, { 64, 64 } }, { 130, 132 } },
83 { "ClipTitleColor", "black", N_("Clip Title") ,
84 { { 155, 130 }, { 64, 64 } }, { 130, 132 } },
85 { "CClipTitleColor", "#454045", N_("Collapsed Clip Title") ,
86 { { 155, 130 }, { 64, 64 } }, { 130, 132 } }
89 /********************************************************************/
98 const char *file_name
;
100 [MSTYLE_NORMAL
] = { "normal", "msty1" },
101 [MSTYLE_SINGLE
] = { "singletexture", "msty2" },
102 [MSTYLE_FLAT
] = { "flat", "msty3" }
105 /********************************************************************/
106 static const struct {
108 const char *db_value
;
109 } wintitle_align
[] = {
110 [WALeft
] = { N_("Left"), "left" },
111 [WACenter
] = { N_("Center"), "center" },
112 [WARight
] = { N_("Right"), "right" }
115 /********************************************************************/
116 static const char *const sample_colors
[] = {
143 /********************************************************************/
144 typedef struct _Panel
{
150 CallbackRec callbacks
;
173 WMColor
*colors
[wlengthof_nocheck(colorOptions
)];
177 WMColorWell
*sampW
[wlengthof_nocheck(sample_colors
)];
183 WMButton
*mstyB
[wlengthof_nocheck(menu_style
)];
186 WMButton
*taliB
[wlengthof_nocheck(wintitle_align
)];
196 TexturePanel
*texturePanel
;
207 menu_style_index menuStyle
;
209 WMAlignment titleAlignment
;
212 Pixmap previewNoText
;
237 static void updateColorPreviewBox(_Panel
* panel
, int elements
);
239 static void showData(_Panel
* panel
);
241 static void changePage(WMWidget
* w
, void *data
);
243 static void changeColorPage(WMWidget
* w
, void *data
);
245 static void OpenExtractPanelFor(_Panel
*panel
);
247 static void changedTabItem(struct WMTabViewDelegate
*self
, WMTabView
* tabView
, WMTabViewItem
* item
);
249 static WMTabViewDelegate tabviewDelegate
= {
251 NULL
, /* didChangeNumberOfItems */
252 changedTabItem
, /* didSelectItem */
253 NULL
, /* shouldSelectItem */
254 NULL
/* willSelectItem */
257 #define ICON_FILE "appearance"
259 #define TNEW_FILE "tnew"
260 #define TDEL_FILE "tdel"
261 #define TEDIT_FILE "tedit"
262 #define TEXTR_FILE "textr"
265 static char *blueled_xpm
[] = {
295 static char *blueled2_xpm
[] = {
296 /* width height num_colors chars_per_pixel */
328 static char *hand_xpm
[] = {
352 " .%%%&@.......... ",
353 " .%*%%&#%%%%%%%%%$. ",
354 " .*#%%%%%%%%%&&&&==. ",
355 " .-%%%%%%%%%=*-;;;#$. ",
356 " .-%%%%%%%%&..>..... ",
372 static const struct {
374 const char *default_value
;
375 const char *texture_label
; /* text used when displaying the list of textures */
376 WMRect preview
; /* The rectangle where the corresponding object is displayed */
377 WMPoint hand
; /* The coordinate where the hand is drawn when pointing this item */
378 const char *popup_label
; /* text used for the popup button with the list of editable items */
379 } textureOptions
[] = {
382 { "FTitleBack", "(solid, black)", N_("[Focused]"),
383 { { 30, 10 }, { 190, 20 } }, { 5, 10 }, N_("Titlebar of Focused Window") },
386 { "UTitleBack", "(solid, gray)", N_("[Unfocused]"),
387 { { 30, 40 }, { 190, 20 } }, { 5, 40 }, N_("Titlebar of Unfocused Windows") },
390 { "PTitleBack", "(solid, \"#616161\")", N_("[Owner of Focused]"),
391 { { 30, 70 }, { 190, 20 } }, { 5, 70 }, N_("Titlebar of Focused Window's Owner") },
394 { "ResizebarBack", "(solid, gray)", N_("[Resizebar]"),
395 { { 30, 100 }, { 190, 9 } }, { 5, 100 }, N_("Window Resizebar") },
398 { "MenuTitleBack", "(solid, black)", N_("[Menu Title]"),
399 { { 30, 120 }, { 90, 20 } }, { 5, 120 }, N_("Titlebar of Menus") },
402 { "MenuTextBack", "(solid, gray)", N_("[Menu Item]"),
403 { { 30, 140 }, { 90, 20 * 4 } }, { 5, 160 }, N_("Menu Items") },
406 { "IconBack", "(solid, gray)", N_("[Icon]"),
407 { { 155, 130 }, { 64, 64 } }, { 130, 150 }, N_("Icon Background") },
409 #define PBACKGROUND 7
410 { "WorkspaceBack", "(solid, black)", N_("[Background]"),
411 { { -1, -1}, { 0, 0 } }, { -22, -21 }, N_("Workspace Background") }
413 #define EVERYTHING 0xff
417 RESIZEBAR_BEVEL
= -1,
445 static void str2rcolor(RContext
* rc
, const char *name
, RColor
* color
)
449 XParseColor(rc
->dpy
, rc
->cmap
, name
, &xcolor
);
452 color
->red
= xcolor
.red
>> 8;
453 color
->green
= xcolor
.green
>> 8;
454 color
->blue
= xcolor
.blue
>> 8;
457 static void dumpRImage(const char *path
, RImage
* image
)
460 int channels
= (image
->format
== RRGBAFormat
? 4 : 3);
462 f
= fopen(path
, "wb");
467 fprintf(f
, "%02x%02x%1x", image
->width
, image
->height
, channels
);
469 fwrite(image
->data
, 1, image
->width
* image
->height
* channels
, f
);
477 static int isPixmap(WMPropList
* prop
)
482 p
= WMGetFromPLArray(prop
, 0);
483 s
= WMGetFromPLString(p
);
484 if (strcasecmp(&s
[1], "pixmap") == 0)
490 /**********************************************************************/
492 static void drawResizebarBevel(RImage
* img
)
496 int width
= img
->width
;
497 int height
= img
->height
;
501 light
.red
= light
.green
= light
.blue
= 80;
504 dark
.red
= dark
.green
= dark
.blue
= 40;
506 ROperateLine(img
, RSubtractOperation
, 0, 0, width
- 1, 0, &dark
);
507 ROperateLine(img
, RAddOperation
, 0, 1, width
- 1, 1, &light
);
509 ROperateLine(img
, RSubtractOperation
, cwidth
, 2, cwidth
, height
- 1, &dark
);
510 ROperateLine(img
, RAddOperation
, cwidth
+ 1, 2, cwidth
+ 1, height
- 1, &light
);
512 ROperateLine(img
, RSubtractOperation
, width
- cwidth
- 2, 2, width
- cwidth
- 2, height
- 1, &dark
);
513 ROperateLine(img
, RAddOperation
, width
- cwidth
- 1, 2, width
- cwidth
- 1, height
- 1, &light
);
517 static void drawMenuBevel(RImage
* img
)
519 RColor light
, dark
, mid
;
521 int iheight
= img
->height
/ 4;
524 light
.red
= light
.green
= light
.blue
= 80;
527 dark
.red
= dark
.green
= dark
.blue
= 0;
530 mid
.red
= mid
.green
= mid
.blue
= 40;
532 for (i
= 1; i
< 4; i
++) {
533 ROperateLine(img
, RSubtractOperation
, 0, i
* iheight
- 2, img
->width
- 1, i
* iheight
- 2, &mid
);
535 RDrawLine(img
, 0, i
* iheight
- 1, img
->width
- 1, i
* iheight
- 1, &dark
);
537 ROperateLine(img
, RAddOperation
, 1, i
* iheight
, img
->width
- 2, i
* iheight
, &light
);
541 static Pixmap
renderTexture(WMScreen
* scr
, WMPropList
* texture
, int width
, int height
, const char *path
, int border
)
544 RImage
*image
= NULL
;
545 RImage
*timage
= NULL
;
547 RContext
*rc
= WMScreenRContext(scr
);
551 type
= WMGetFromPLString(WMGetFromPLArray(texture
, 0));
553 if (strcasecmp(&type
[1], "pixmap") == 0 ||
554 (strcasecmp(&type
[2], "gradient") == 0 && toupper(type
[0]) == 'T')) {
557 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
558 path
= wfindfileinarray(GetObjectForKey("PixmapPath"), str
);
560 timage
= RLoadImage(rc
, path
, 0);
562 wwarning("could not load file '%s': %s", path
, RMessageForError(RErrorCode
));
565 wwarning("could not find file '%s' for %s of texture", str
, type
);
569 texture
= WMCreatePropListFromDescription("(solid, black)");
574 if (strcasecmp(type
, "solid") == 0) {
576 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
578 str2rcolor(rc
, str
, &rcolor
);
580 image
= RCreateImage(width
, height
, False
);
581 RClearImage(image
, &rcolor
);
582 } else if (strcasecmp(type
, "igradient") == 0) {
586 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
587 str2rcolor(rc
, str
, &c1
[0]);
588 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
589 str2rcolor(rc
, str
, &c1
[1]);
590 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 3));
593 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 4));
594 str2rcolor(rc
, str
, &c2
[0]);
595 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 5));
596 str2rcolor(rc
, str
, &c2
[1]);
597 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 6));
600 image
= RRenderInterwovenGradient(width
, height
, c1
, t1
, c2
, t2
);
601 } else if (strcasecmp(&type
[1], "gradient") == 0) {
602 RGradientStyle style
;
605 switch (toupper(type
[0])) {
607 style
= RVerticalGradient
;
610 style
= RHorizontalGradient
;
613 wwarning("unknow direction in '%s', falling back to diagonal", type
);
615 style
= RDiagonalGradient
;
619 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
620 str2rcolor(rc
, str
, &rcolor
);
621 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
622 str2rcolor(rc
, str
, &rcolor2
);
624 image
= RRenderGradient(width
, height
, &rcolor
, &rcolor2
, style
);
625 } else if (strcasecmp(&type
[2], "gradient") == 0 && toupper(type
[0]) == 'T') {
626 RGradientStyle style
;
631 switch (toupper(type
[1])) {
633 style
= RVerticalGradient
;
636 style
= RHorizontalGradient
;
639 wwarning("unknow direction in '%s', falling back to diagonal", type
);
641 style
= RDiagonalGradient
;
645 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 3));
646 str2rcolor(rc
, str
, &rcolor
);
647 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 4));
648 str2rcolor(rc
, str
, &rcolor2
);
650 grad
= RRenderGradient(width
, height
, &rcolor
, &rcolor2
, style
);
652 image
= RMakeTiledImage(timage
, width
, height
);
653 RReleaseImage(timage
);
655 i
= atoi(WMGetFromPLString(WMGetFromPLArray(texture
, 2)));
657 RCombineImagesWithOpaqueness(image
, grad
, i
);
660 } else if (strcasecmp(&type
[2], "gradient") == 0 && toupper(type
[0]) == 'M') {
661 RGradientStyle style
;
665 switch (toupper(type
[1])) {
667 style
= RVerticalGradient
;
670 style
= RHorizontalGradient
;
673 wwarning("unknow direction in '%s', falling back to diagonal", type
);
675 style
= RDiagonalGradient
;
679 j
= WMGetPropListItemCount(texture
);
682 colors
= wmalloc(j
* sizeof(RColor
*));
684 for (i
= 2; i
< j
; i
++) {
685 str
= WMGetFromPLString(WMGetFromPLArray(texture
, i
));
686 colors
[i
- 2] = wmalloc(sizeof(RColor
));
687 str2rcolor(rc
, str
, colors
[i
- 2]);
689 colors
[i
- 2] = NULL
;
691 image
= RRenderMultiGradient(width
, height
, colors
, style
);
693 for (i
= 0; colors
[i
] != NULL
; i
++)
697 } else if (strcasecmp(&type
[1], "pixmap") == 0) {
700 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
701 str2rcolor(rc
, str
, &color
);
703 switch (toupper(type
[0])) {
705 image
= RMakeTiledImage(timage
, width
, height
);
706 RReleaseImage(timage
);
709 image
= RMakeCenteredImage(timage
, width
, height
, &color
);
710 RReleaseImage(timage
);
715 image
= RScaleImage(timage
, width
, height
);
716 RReleaseImage(timage
);
720 wwarning("type '%s' in not a supported type for a texture", type
);
721 RReleaseImage(timage
);
730 dumpRImage(path
, image
);
734 if (border
== RESIZEBAR_BEVEL
) {
735 drawResizebarBevel(image
);
736 } else if (border
== MENU_BEVEL
) {
737 drawMenuBevel(image
);
738 RBevelImage(image
, RBEV_RAISED2
);
741 RBevelImage(image
, border
);
744 RConvertImage(rc
, image
, &pixmap
);
745 RReleaseImage(image
);
750 static Pixmap
renderMenu(_Panel
* panel
, WMPropList
* texture
, int width
, int iheight
)
752 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
753 Display
*dpy
= WMScreenDisplay(scr
);
755 GC gc
= XCreateGC(dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
758 switch (panel
->menuStyle
) {
760 tmp
= renderTexture(scr
, texture
, width
, iheight
, NULL
, RBEV_RAISED2
);
762 pix
= XCreatePixmap(dpy
, tmp
, width
, iheight
* 4, WMScreenDepth(scr
));
763 for (i
= 0; i
< 4; i
++) {
764 XCopyArea(dpy
, tmp
, pix
, gc
, 0, 0, width
, iheight
, 0, iheight
* i
);
766 XFreePixmap(dpy
, tmp
);
769 pix
= renderTexture(scr
, texture
, width
, iheight
* 4, NULL
, MENU_BEVEL
);
772 pix
= renderTexture(scr
, texture
, width
, iheight
* 4, NULL
, RBEV_RAISED2
);
782 static void renderPreview(_Panel
* panel
, GC gc
, int part
, int relief
)
785 TextureListItem
*titem
;
787 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
789 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[part
]);
790 titem
= (TextureListItem
*) item
->clientData
;
792 pix
= renderTexture(scr
, titem
->prop
,
793 textureOptions
[part
].preview
.size
.width
, textureOptions
[part
].preview
.size
.height
,
796 XCopyArea(WMScreenDisplay(scr
), pix
, panel
->preview
, gc
, 0, 0,
797 textureOptions
[part
].preview
.size
.width
, textureOptions
[part
].preview
.size
.height
,
798 textureOptions
[part
].preview
.pos
.x
, textureOptions
[part
].preview
.pos
.y
);
800 XCopyArea(WMScreenDisplay(scr
), pix
, panel
->previewNoText
, gc
, 0, 0,
801 textureOptions
[part
].preview
.size
.width
, textureOptions
[part
].preview
.size
.height
,
802 textureOptions
[part
].preview
.pos
.x
, textureOptions
[part
].preview
.pos
.y
);
804 XFreePixmap(WMScreenDisplay(scr
), pix
);
807 static void updatePreviewBox(_Panel
* panel
, int elements
)
809 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
810 Display
*dpy
= WMScreenDisplay(scr
);
815 gc
= XCreateGC(dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
817 if (panel
->preview
== None
) {
820 panel
->previewNoText
= XCreatePixmap(dpy
, WMWidgetXID(panel
->parent
),
821 240 - 4, 215 - 4, WMScreenDepth(scr
));
822 panel
->previewBack
= XCreatePixmap(dpy
, WMWidgetXID(panel
->parent
),
823 240 - 4, 215 - 4, WMScreenDepth(scr
));
825 p
= WMCreatePixmap(scr
, 240 - 4, 215 - 4, WMScreenDepth(scr
), False
);
826 panel
->preview
= WMGetPixmapXID(p
);
827 WMSetLabelImage(panel
->prevL
, p
);
830 if (elements
& (1 << PBACKGROUND
)) {
832 TextureListItem
*titem
;
835 item
= WMGetListItem(panel
->texLs
,
836 panel
->textureIndex
[PBACKGROUND
]);
837 titem
= (TextureListItem
*) item
->clientData
;
838 tmp
= renderTexture(scr
, titem
->prop
, 240 - 4, 215 - 4, NULL
, 0);
840 XCopyArea(dpy
, tmp
, panel
->preview
, gc
, 0, 0, 240 - 4, 215 -4 , 0, 0);
841 XCopyArea(dpy
, tmp
, panel
->previewNoText
, gc
, 0, 0, 240 - 4, 215 -4 , 0, 0);
842 XCopyArea(dpy
, tmp
, panel
->previewBack
, gc
, 0, 0, 240 - 4, 215 -4 , 0, 0);
843 XFreePixmap(dpy
, tmp
);
846 if (elements
& (1 << PFOCUSED
)) {
847 renderPreview(panel
, gc
, PFOCUSED
, RBEV_RAISED2
);
848 colorUpdate
|= 1 << FTITLE_COL
| 1 << FFBORDER_COL
;
850 if (elements
& (1 << PUNFOCUSED
)) {
851 renderPreview(panel
, gc
, PUNFOCUSED
, RBEV_RAISED2
);
852 colorUpdate
|= 1 << UTITLE_COL
| 1 << FBORDER_COL
;
854 if (elements
& (1 << POWNER
)) {
855 renderPreview(panel
, gc
, POWNER
, RBEV_RAISED2
);
856 colorUpdate
|= 1 << OTITLE_COL
| 1 << FBORDER_COL
;
858 if (elements
& (1 << PRESIZEBAR
)) {
859 renderPreview(panel
, gc
, PRESIZEBAR
, RESIZEBAR_BEVEL
);
860 colorUpdate
|= 1 << FBORDER_COL
;
862 if (elements
& (1 << PMTITLE
)) {
863 renderPreview(panel
, gc
, PMTITLE
, RBEV_RAISED2
);
864 colorUpdate
|= 1 << MTITLE_COL
| 1 << FBORDER_COL
;
866 if (elements
& (1 << PMITEM
)) {
868 TextureListItem
*titem
;
870 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[5]);
871 titem
= (TextureListItem
*) item
->clientData
;
873 pix
= renderMenu(panel
, titem
->prop
,
874 textureOptions
[PMITEM
].preview
.size
.width
,
875 textureOptions
[PMITEM
].preview
.size
.height
/ 4);
877 XCopyArea(dpy
, pix
, panel
->preview
, gc
, 0, 0,
878 textureOptions
[PMITEM
].preview
.size
.width
, textureOptions
[PMITEM
].preview
.size
.height
,
879 textureOptions
[PMITEM
].preview
.pos
.x
, textureOptions
[PMITEM
].preview
.pos
.y
);
881 XCopyArea(dpy
, pix
, panel
->previewNoText
, gc
, 0, 0,
882 textureOptions
[PMITEM
].preview
.size
.width
, textureOptions
[PMITEM
].preview
.size
.height
,
883 textureOptions
[PMITEM
].preview
.pos
.x
, textureOptions
[PMITEM
].preview
.pos
.y
);
885 XFreePixmap(dpy
, pix
);
887 colorUpdate
|= 1 << MITEM_COL
| 1 << MDISAB_COL
|
888 1 << MHIGH_COL
| 1 << MHIGHT_COL
|
891 if (elements
& (1 << PICON
)) {
893 TextureListItem
*titem
;
895 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[6]);
896 titem
= (TextureListItem
*) item
->clientData
;
898 renderPreview(panel
, gc
, PICON
, titem
->ispixmap
? 0 : RBEV_RAISED3
);
902 updateColorPreviewBox(panel
, colorUpdate
);
904 WMRedisplayWidget(panel
->prevL
);
909 static void cancelNewTexture(void *data
)
911 _Panel
*panel
= (_Panel
*) data
;
913 HideTexturePanel(panel
->texturePanel
);
916 static char *makeFileName(const char *prefix
)
920 fname
= wstrdup(prefix
);
922 while (access(fname
, F_OK
) == 0) {
926 sprintf(buf
, "%08lx.cache", time(NULL
));
927 fname
= wstrconcat(prefix
, buf
);
933 static void okNewTexture(void *data
)
935 _Panel
*panel
= (_Panel
*) data
;
940 TextureListItem
*titem
;
941 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
943 titem
= wmalloc(sizeof(TextureListItem
));
945 HideTexturePanel(panel
->texturePanel
);
947 name
= GetTexturePanelTextureName(panel
->texturePanel
);
949 prop
= GetTexturePanelTexture(panel
->texturePanel
);
951 str
= WMGetPropListDescription(prop
, False
);
955 titem
->texture
= str
;
956 titem
->selectedFor
= 0;
958 titem
->ispixmap
= isPixmap(prop
);
960 titem
->path
= makeFileName(panel
->fprefix
);
961 titem
->preview
= renderTexture(scr
, prop
, TEXPREV_WIDTH
, TEXPREV_HEIGHT
, titem
->path
, 0);
963 item
= WMAddListItem(panel
->texLs
, "");
964 item
->clientData
= titem
;
966 WMSetListPosition(panel
->texLs
, WMGetListNumberOfRows(panel
->texLs
));
969 static void okEditTexture(void *data
)
971 _Panel
*panel
= (_Panel
*) data
;
976 TextureListItem
*titem
;
978 item
= WMGetListItem(panel
->texLs
, WMGetListSelectedItemRow(panel
->texLs
));
979 titem
= (TextureListItem
*) item
->clientData
;
981 HideTexturePanel(panel
->texturePanel
);
983 if (titem
->current
) {
984 name
= GetTexturePanelTextureName(panel
->texturePanel
);
990 prop
= GetTexturePanelTexture(panel
->texturePanel
);
992 str
= WMGetPropListDescription(prop
, False
);
994 WMReleasePropList(titem
->prop
);
997 titem
->ispixmap
= isPixmap(prop
);
999 wfree(titem
->texture
);
1000 titem
->texture
= str
;
1002 XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel
->texLs
)), titem
->preview
);
1003 titem
->preview
= renderTexture(WMWidgetScreen(panel
->texLs
), titem
->prop
,
1004 TEXPREV_WIDTH
, TEXPREV_HEIGHT
, titem
->path
, 0);
1006 WMRedisplayWidget(panel
->texLs
);
1008 if (titem
->selectedFor
) {
1009 if (titem
->selectedFor
& (1 << PBACKGROUND
))
1010 updatePreviewBox(panel
, EVERYTHING
);
1012 updatePreviewBox(panel
, titem
->selectedFor
);
1015 changePage(panel
->secP
, panel
);
1018 static void editTexture(WMWidget
* w
, void *data
)
1020 _Panel
*panel
= (_Panel
*) data
;
1022 TextureListItem
*titem
;
1024 /* Parameter not used, but tell the compiler that it is ok */
1027 item
= WMGetListItem(panel
->texLs
, WMGetListSelectedItemRow(panel
->texLs
));
1028 titem
= (TextureListItem
*) item
->clientData
;
1030 SetTexturePanelPixmapPath(panel
->texturePanel
, GetObjectForKey("PixmapPath"));
1032 SetTexturePanelTexture(panel
->texturePanel
, titem
->title
, titem
->prop
);
1034 SetTexturePanelCancelAction(panel
->texturePanel
, cancelNewTexture
, panel
);
1035 SetTexturePanelOkAction(panel
->texturePanel
, okEditTexture
, panel
);
1037 ShowTexturePanel(panel
->texturePanel
);
1040 static void newTexture(WMWidget
* w
, void *data
)
1042 _Panel
*panel
= (_Panel
*) data
;
1044 /* Parameter not used, but tell the compiler that it is ok */
1047 SetTexturePanelPixmapPath(panel
->texturePanel
, GetObjectForKey("PixmapPath"));
1049 SetTexturePanelTexture(panel
->texturePanel
, "New Texture", NULL
);
1051 SetTexturePanelCancelAction(panel
->texturePanel
, cancelNewTexture
, panel
);
1053 SetTexturePanelOkAction(panel
->texturePanel
, okNewTexture
, panel
);
1055 ShowTexturePanel(panel
->texturePanel
);
1058 static void deleteTexture(WMWidget
* w
, void *data
)
1060 _Panel
*panel
= (_Panel
*) data
;
1062 TextureListItem
*titem
;
1066 /* Parameter not used, but tell the compiler that it is ok */
1069 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
1070 row
= WMGetListSelectedItemRow(panel
->texLs
);
1071 item
= WMGetListItem(panel
->texLs
, row
);
1072 titem
= (TextureListItem
*) item
->clientData
;
1074 if (titem
->selectedFor
& (1 << section
)) {
1075 TextureListItem
*titem2
;
1077 panel
->textureIndex
[section
] = section
;
1078 item
= WMGetListItem(panel
->texLs
, section
);
1079 titem2
= (TextureListItem
*) item
->clientData
;
1080 titem2
->selectedFor
|= 1 << section
;
1083 wfree(titem
->title
);
1084 wfree(titem
->texture
);
1085 WMReleasePropList(titem
->prop
);
1087 if (remove(titem
->path
) < 0 && errno
!= ENOENT
) {
1088 werror("could not remove file %s", titem
->path
);
1095 WMRemoveListItem(panel
->texLs
, row
);
1096 WMSetButtonEnabled(panel
->delB
, False
);
1099 static void extractTexture(WMWidget
* w
, void *data
)
1101 _Panel
*panel
= (_Panel
*) data
;
1103 WMOpenPanel
*opanel
;
1104 WMScreen
*scr
= WMWidgetScreen(w
);
1106 opanel
= WMGetOpenPanel(scr
);
1107 WMSetFilePanelCanChooseDirectories(opanel
, False
);
1108 WMSetFilePanelCanChooseFiles(opanel
, True
);
1110 if (WMRunModalFilePanelForDirectory(opanel
, panel
->parent
, wgethomedir(), _("Select File"), NULL
)) {
1111 path
= WMGetFilePanelFileName(opanel
);
1113 OpenExtractPanelFor(panel
);
1119 static void changePage(WMWidget
* w
, void *data
)
1121 _Panel
*panel
= (_Panel
*) data
;
1123 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1124 RContext
*rc
= WMScreenRContext(scr
);
1127 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
1129 WMSelectListItem(panel
->texLs
, panel
->textureIndex
[section
]);
1131 WMSetListPosition(panel
->texLs
, panel
->textureIndex
[section
] - 2);
1136 gc
= XCreateGC(rc
->dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
1137 XCopyArea(rc
->dpy
, panel
->previewBack
, panel
->preview
, gc
,
1138 textureOptions
[panel
->oldsection
].hand
.x
, textureOptions
[panel
->oldsection
].hand
.y
, 22, 22,
1139 textureOptions
[panel
->oldsection
].hand
.x
, textureOptions
[panel
->oldsection
].hand
.y
);
1142 panel
->oldsection
= section
;
1143 WMDrawPixmap(panel
->hand
, panel
->preview
, textureOptions
[section
].hand
.x
, textureOptions
[section
].hand
.y
);
1145 WMRedisplayWidget(panel
->prevL
);
1148 static void previewClick(XEvent
* event
, void *clientData
)
1150 _Panel
*panel
= (_Panel
*) clientData
;
1153 switch (panel
->oldTabItem
) {
1155 for (i
= 0; i
< wlengthof(textureOptions
); i
++) {
1156 if (event
->xbutton
.x
>= textureOptions
[i
].preview
.pos
.x
&&
1157 event
->xbutton
.y
>= textureOptions
[i
].preview
.pos
.y
&&
1158 event
->xbutton
.x
< textureOptions
[i
].preview
.pos
.x
+ textureOptions
[i
].preview
.size
.width
&&
1159 event
->xbutton
.y
< textureOptions
[i
].preview
.pos
.y
+ textureOptions
[i
].preview
.size
.height
) {
1161 WMSetPopUpButtonSelectedItem(panel
->secP
, i
);
1162 changePage(panel
->secP
, panel
);
1168 for (i
= 0; i
< WMGetPopUpButtonNumberOfItems(panel
->colP
); i
++) {
1169 if (event
->xbutton
.x
>= colorOptions
[i
].preview
.pos
.x
&&
1170 event
->xbutton
.y
>= colorOptions
[i
].preview
.pos
.y
&&
1171 event
->xbutton
.x
< colorOptions
[i
].preview
.pos
.x
+ colorOptions
[i
].preview
.size
.width
&&
1172 event
->xbutton
.y
< colorOptions
[i
].preview
.pos
.y
+ colorOptions
[i
].preview
.size
.height
) {
1175 * yuck kluge: the entry #7 is HighlightTextColor which does not have actually a
1176 * display area, but are reused to make the last "Normal Item" menu entry actually
1177 * pick the same color item as the other similar item displayed, which corresponds
1183 WMSetPopUpButtonSelectedItem(panel
->colP
, i
);
1184 changeColorPage(panel
->colP
, panel
);
1192 static void textureClick(WMWidget
* w
, void *data
)
1194 _Panel
*panel
= (_Panel
*) data
;
1197 TextureListItem
*titem
;
1199 /* Parameter not used, but tell the compiler that it is ok */
1202 i
= WMGetListSelectedItemRow(panel
->texLs
);
1204 item
= WMGetListItem(panel
->texLs
, i
);
1206 titem
= (TextureListItem
*) item
->clientData
;
1208 if (titem
->current
) {
1209 WMSetButtonEnabled(panel
->delB
, False
);
1211 WMSetButtonEnabled(panel
->delB
, True
);
1215 static void textureDoubleClick(WMWidget
* w
, void *data
)
1217 _Panel
*panel
= (_Panel
*) data
;
1220 TextureListItem
*titem
;
1222 /* Parameter not used, but tell the compiler that it is ok */
1225 /* unselect old texture */
1226 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
1228 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[section
]);
1229 titem
= (TextureListItem
*) item
->clientData
;
1230 titem
->selectedFor
&= ~(1 << section
);
1232 /* select new texture */
1233 i
= WMGetListSelectedItemRow(panel
->texLs
);
1235 item
= WMGetListItem(panel
->texLs
, i
);
1237 titem
= (TextureListItem
*) item
->clientData
;
1239 titem
->selectedFor
|= 1 << section
;
1241 panel
->textureIndex
[section
] = i
;
1243 WMRedisplayWidget(panel
->texLs
);
1245 if (section
== PBACKGROUND
)
1246 updatePreviewBox(panel
, EVERYTHING
);
1248 updatePreviewBox(panel
, 1 << section
);
1251 static void paintListItem(WMList
* lPtr
, int index
, Drawable d
, char *text
, int state
, WMRect
* rect
)
1253 _Panel
*panel
= (_Panel
*) WMGetHangedData(lPtr
);
1254 WMScreen
*scr
= WMWidgetScreen(lPtr
);
1255 int width
, height
, x
, y
;
1256 Display
*dpy
= WMScreenDisplay(scr
);
1257 WMColor
*back
= (state
& WLDSSelected
) ? WMWhiteColor(scr
) : WMGrayColor(scr
);
1259 WMColor
*black
= WMBlackColor(scr
);
1260 TextureListItem
*titem
;
1262 /* Parameter not used, but tell the compiler that it is ok */
1265 item
= WMGetListItem(lPtr
, index
);
1266 titem
= (TextureListItem
*) item
->clientData
;
1268 WMReleaseColor(back
);
1269 WMReleaseColor(black
);
1273 width
= rect
->size
.width
;
1274 height
= rect
->size
.height
;
1278 XFillRectangle(dpy
, d
, WMColorGC(back
), x
, y
, width
, height
);
1281 XCopyArea(dpy
, titem
->preview
, d
, WMColorGC(black
), 0, 0,
1282 TEXPREV_WIDTH
, TEXPREV_HEIGHT
, x
+ 5, y
+ 5);
1284 if ((1 << WMGetPopUpButtonSelectedItem(panel
->secP
)) & titem
->selectedFor
)
1285 WMDrawPixmap(panel
->onLed
, d
, x
+ TEXPREV_WIDTH
+ 10, y
+ 6);
1286 else if (titem
->selectedFor
)
1287 WMDrawPixmap(panel
->offLed
, d
, x
+ TEXPREV_WIDTH
+ 10, y
+ 6);
1289 WMDrawString(scr
, d
, black
, panel
->boldFont
,
1290 x
+ TEXPREV_WIDTH
+ 22, y
+ 2, titem
->title
, strlen(titem
->title
));
1292 WMDrawString(scr
, d
, black
, panel
->smallFont
,
1293 x
+ TEXPREV_WIDTH
+ 14, y
+ 18, titem
->texture
, strlen(titem
->texture
));
1295 WMReleaseColor(back
);
1296 WMReleaseColor(black
);
1299 static Pixmap
loadRImage(WMScreen
* scr
, const char *path
)
1307 f
= fopen(path
, "rb");
1311 cnt
= fscanf(f
, "%02x%02x%1x", &w
, &h
, &d
);
1313 wwarning(_("could not read size of image from '%s', ignoring"), path
);
1317 if (d
< 3 || d
> 4) {
1318 wwarning(_("image \"%s\" has an invalid depth of %d, ignoring"), path
, d
);
1322 image
= RCreateImage(w
, h
, d
== 4);
1323 if (image
== NULL
) {
1324 wwarning(_("could not create RImage for \"%s\": %s"),
1325 path
, RMessageForError(RErrorCode
));
1329 read_size
= w
* h
* d
;
1330 if (fread(image
->data
, 1, read_size
, f
) == read_size
)
1331 RConvertImage(WMScreenRContext(scr
), image
, &pixmap
);
1337 RReleaseImage(image
);
1342 static void fillTextureList(WMList
* lPtr
)
1344 WMPropList
*textureList
;
1345 WMPropList
*texture
;
1346 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
1347 TextureListItem
*titem
;
1348 WMScreen
*scr
= WMWidgetScreen(lPtr
);
1351 textureList
= WMGetUDObjectForKey(udb
, "TextureList");
1355 for (i
= 0; i
< WMGetPropListItemCount(textureList
); i
++) {
1358 texture
= WMGetFromPLArray(textureList
, i
);
1360 titem
= wmalloc(sizeof(TextureListItem
));
1362 titem
->title
= wstrdup(WMGetFromPLString(WMGetFromPLArray(texture
, 0)));
1363 titem
->prop
= WMRetainPropList(WMGetFromPLArray(texture
, 1));
1364 titem
->texture
= WMGetPropListDescription(titem
->prop
, False
);
1365 titem
->selectedFor
= 0;
1366 titem
->path
= wstrdup(WMGetFromPLString(WMGetFromPLArray(texture
, 2)));
1368 titem
->preview
= loadRImage(scr
, titem
->path
);
1369 if (!titem
->preview
) {
1370 titem
->preview
= renderTexture(scr
, titem
->prop
, TEXPREV_WIDTH
, TEXPREV_HEIGHT
, NULL
, 0);
1372 item
= WMAddListItem(lPtr
, "");
1373 item
->clientData
= titem
;
1377 static void fillColorList(_Panel
* panel
)
1381 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
1382 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1385 list
= WMGetUDObjectForKey(udb
, "ColorList");
1387 for (i
= 0; i
< wlengthof(sample_colors
); i
++) {
1388 color
= WMCreateNamedColor(scr
, sample_colors
[i
], False
);
1391 WMSetColorWellColor(panel
->sampW
[i
], color
);
1392 WMReleaseColor(color
);
1397 for (i
= 0; i
< WMIN(wlengthof(sample_colors
), WMGetPropListItemCount(list
)); i
++) {
1398 c
= WMGetFromPLArray(list
, i
);
1399 if (!c
|| !WMIsPLString(c
))
1401 color
= WMCreateNamedColor(scr
, WMGetFromPLString(c
), False
);
1404 WMSetColorWellColor(panel
->sampW
[i
], color
);
1405 WMReleaseColor(color
);
1410 /*************************************************************************/
1412 static void changeColorPage(WMWidget
* w
, void *data
)
1414 _Panel
*panel
= (_Panel
*) data
;
1416 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1417 RContext
*rc
= WMScreenRContext(scr
);
1419 if (panel
->preview
) {
1422 gc
= XCreateGC(rc
->dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
1423 XCopyArea(rc
->dpy
, panel
->previewBack
, panel
->preview
, gc
,
1424 colorOptions
[panel
->oldcsection
].hand
.x
,
1425 colorOptions
[panel
->oldcsection
].hand
.y
, 22, 22 ,
1426 colorOptions
[panel
->oldcsection
].hand
.x
,
1427 colorOptions
[panel
->oldcsection
].hand
.y
);
1430 section
= WMGetPopUpButtonSelectedItem(panel
->colP
);
1432 panel
->oldcsection
= section
;
1434 WMDrawPixmap(panel
->hand
, panel
->preview
,
1435 colorOptions
[section
].hand
.x
, colorOptions
[section
].hand
.y
);
1437 if (section
>= ICONT_COL
)
1438 updateColorPreviewBox(panel
, 1 << section
);
1440 WMSetColorWellColor(panel
->colW
, panel
->colors
[section
]);
1442 WMRedisplayWidget(panel
->prevL
);
1446 paintText(WMScreen
* scr
, Drawable d
, WMColor
* color
, WMFont
* font
,
1447 int x
, int y
, int w
, int h
, WMAlignment align
, char *text
)
1449 int l
= strlen(text
);
1456 x
+= w
- 5 - WMWidthOfString(font
, text
, l
);
1460 x
+= (w
- WMWidthOfString(font
, text
, l
)) / 2;
1463 WMDrawString(scr
, d
, color
, font
, x
, y
+ (h
- WMFontHeight(font
)) / 2, text
, l
);
1466 static void updateColorPreviewBox(_Panel
* panel
, int elements
)
1468 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1469 Display
*dpy
= WMScreenDisplay(scr
);
1474 pnot
= panel
->previewNoText
;
1475 gc
= WMColorGC(panel
->colors
[FTITLE_COL
]);
1477 if (elements
& (1 << FTITLE_COL
)) {
1478 XCopyArea(dpy
, pnot
, d
, gc
, 30, 10, 190, 20, 30, 10);
1479 paintText(scr
, d
, panel
->colors
[FTITLE_COL
],
1480 panel
->boldFont
, 30, 10, 190, 20,
1481 panel
->titleAlignment
, _("Focused Window"));
1483 if (elements
& (1 << UTITLE_COL
)) {
1484 XCopyArea(dpy
, pnot
, d
, gc
, 30, 40, 190, 20, 30, 40);
1485 paintText(scr
, d
, panel
->colors
[UTITLE_COL
],
1486 panel
->boldFont
, 30, 40, 190, 20,
1487 panel
->titleAlignment
,
1488 _("Unfocused Window"));
1490 if (elements
& (1 << OTITLE_COL
)) {
1491 XCopyArea(dpy
, pnot
, d
, gc
, 30, 70, 190, 20, 30, 70);
1492 paintText(scr
, d
, panel
->colors
[OTITLE_COL
],
1493 panel
->boldFont
, 30, 70, 190, 20,
1494 panel
->titleAlignment
,
1495 _("Owner of Focused Window"));
1497 if (elements
& (1 << MTITLE_COL
)) {
1498 XCopyArea(dpy
, pnot
, d
, gc
, 30, 120, 90, 20, 30, 120);
1499 paintText(scr
, d
, panel
->colors
[MTITLE_COL
],
1500 panel
->boldFont
, 30, 120, 90, 20, WALeft
,
1503 if (elements
& (1 << MITEM_COL
)) {
1504 XCopyArea(dpy
, pnot
, d
, gc
, 30, 140, 90, 20, 30, 140);
1505 paintText(scr
, d
, panel
->colors
[MITEM_COL
],
1506 panel
->normalFont
, 30, 140, 90, 20, WALeft
,
1508 XCopyArea(dpy
, pnot
, d
, gc
, 30, 200, 90, 20, 30, 200);
1509 paintText(scr
, d
, panel
->colors
[MITEM_COL
],
1510 panel
->normalFont
, 30, 200, 90, 20, WALeft
,
1513 if (elements
& (1 << MDISAB_COL
)) {
1514 XCopyArea(dpy
, pnot
, d
, gc
, 30, 160, 90, 20, 30, 160);
1515 paintText(scr
, d
, panel
->colors
[MDISAB_COL
],
1516 panel
->normalFont
, 30, 160, 90, 20, WALeft
,
1517 _("Disabled Item"));
1519 if (elements
& (1 << MHIGH_COL
)) {
1520 XFillRectangle(WMScreenDisplay(scr
), d
,
1521 WMColorGC(panel
->colors
[MHIGH_COL
]),
1523 XFillRectangle(WMScreenDisplay(scr
), pnot
,
1524 WMColorGC(panel
->colors
[MHIGH_COL
]),
1526 elements
|= 1 << MHIGHT_COL
;
1528 if (elements
& (1 << MHIGHT_COL
)) {
1529 XCopyArea(dpy
, pnot
, d
, gc
, 30, 180, 90, 20, 30, 180);
1530 paintText(scr
, d
, panel
->colors
[MHIGHT_COL
],
1531 panel
->normalFont
, 30, 180, 90, 20, WALeft
,
1534 if (elements
& (1 << FBORDER_COL
)) {
1535 XDrawRectangle(dpy
, pnot
,
1536 WMColorGC(panel
->colors
[FBORDER_COL
]),
1538 XDrawRectangle(dpy
, d
,
1539 WMColorGC(panel
->colors
[FBORDER_COL
]),
1541 XDrawRectangle(dpy
, pnot
,
1542 WMColorGC(panel
->colors
[FBORDER_COL
]),
1544 XDrawRectangle(dpy
, d
,
1545 WMColorGC(panel
->colors
[FBORDER_COL
]),
1547 XDrawLine(dpy
, pnot
,
1548 WMColorGC(panel
->colors
[FBORDER_COL
]),
1551 WMColorGC(panel
->colors
[FBORDER_COL
]),
1553 XDrawLine(dpy
, pnot
,
1554 WMColorGC(panel
->colors
[FBORDER_COL
]),
1557 WMColorGC(panel
->colors
[FBORDER_COL
]),
1559 XDrawLine(dpy
, pnot
,
1560 WMColorGC(panel
->colors
[FBORDER_COL
]),
1561 220, 100, 220, 109);
1563 WMColorGC(panel
->colors
[FBORDER_COL
]),
1564 220, 100, 220, 109);
1565 XDrawLine(dpy
, pnot
,
1566 WMColorGC(panel
->colors
[FBORDER_COL
]),
1569 WMColorGC(panel
->colors
[FBORDER_COL
]),
1571 XDrawLine(dpy
, pnot
,
1572 WMColorGC(panel
->colors
[FBORDER_COL
]),
1575 WMColorGC(panel
->colors
[FBORDER_COL
]),
1577 XDrawLine(dpy
, pnot
,
1578 WMColorGC(panel
->colors
[FBORDER_COL
]),
1579 119, 120, 119, 220);
1581 WMColorGC(panel
->colors
[FBORDER_COL
]),
1582 119, 120, 119, 220);
1585 if (elements
& (1 << FFBORDER_COL
)) {
1586 XDrawRectangle(dpy
, pnot
,
1587 WMColorGC(panel
->colors
[FFBORDER_COL
]),
1589 XDrawRectangle(dpy
, d
,
1590 WMColorGC(panel
->colors
[FFBORDER_COL
]),
1594 if (elements
& (1 << ICONT_COL
) || elements
& (1 << ICONB_COL
)) {
1596 RHSVColor hsv
, hsv2
;
1598 WMColor
*light
, *dim
;
1600 updatePreviewBox(panel
, 1 << PICON
);
1602 rgb
.red
= WMRedComponentOfColor(panel
->colors
[ICONB_COL
]) >> 8;
1603 rgb
.green
= WMGreenComponentOfColor(panel
->colors
[ICONB_COL
]) >> 8;
1604 rgb
.blue
= WMBlueComponentOfColor(panel
->colors
[ICONB_COL
]) >> 8;
1605 RRGBtoHSV(&rgb
, &hsv
);
1606 RHSVtoRGB(&hsv
, &rgb
);
1609 v
= hsv
.value
* 16 / 10;
1610 hsv
.value
= (v
> 255 ? 255 : v
);
1611 RHSVtoRGB(&hsv
, &rgb
);
1612 light
= WMCreateRGBColor(scr
, rgb
.red
<< 8, rgb
.green
<< 8, rgb
.blue
<< 8, False
);
1614 hsv2
.value
= hsv2
.value
/ 2;
1615 RHSVtoRGB(&hsv2
, &rgb
);
1616 dim
= WMCreateRGBColor(scr
, rgb
.red
<< 8, rgb
.green
<< 8, rgb
.blue
<< 8, False
);
1618 XFillRectangle(dpy
, d
, WMColorGC(panel
->colors
[ICONB_COL
]), 156, 131, 62, 11);
1619 XDrawLine(dpy
, d
, WMColorGC(light
), 155, 130, 155, 142);
1620 XDrawLine(dpy
, d
, WMColorGC(light
), 156, 130, 217, 130);
1621 XDrawLine(dpy
, d
, WMColorGC(dim
), 218, 130, 218, 142);
1623 paintText(scr
, d
, panel
->colors
[ICONT_COL
],
1624 panel
->smallFont
, 155, 130, 64, 13, WALeft
,
1627 WMReleaseColor(light
);
1628 WMReleaseColor(dim
);
1631 if (elements
& (1 << CLIP_COL
) || elements
& (1 << CCLIP_COL
)) {
1637 TextureListItem
*titem
;
1641 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[PICON
]);
1642 titem
= (TextureListItem
*) item
->clientData
;
1644 pix
= renderTexture(scr
, titem
->prop
, 64, 64, NULL
, titem
->ispixmap
? 0 : RBEV_RAISED3
);
1645 tile
= RCreateImageFromDrawable(WMScreenRContext(scr
), pix
, None
);
1648 black
.red
= black
.green
= black
.blue
= 0;
1651 dark
.red
= dark
.green
= dark
.blue
= 60;
1654 light
.red
= light
.green
= light
.blue
= 80;
1657 ROperateLine(tile
, RSubtractOperation
, 64 - 1 - 23, 0, 64 - 2, 23 - 1, &dark
);
1658 RDrawLine(tile
, 64 - 1 - 23 - 1, 0, 64 - 1, 23 + 1, &black
);
1659 ROperateLine(tile
, RAddOperation
, 64 - 1 - 23, 2, 64 - 3, 23, &light
);
1662 ROperateLine(tile
, RSubtractOperation
, 64 - 7 - (23 - 15), 4, 64 - 5, 4, &dark
);
1663 ROperateLine(tile
, RSubtractOperation
, 64 - 6 - (23 - 15), 5, 64 - 5, 6 + 23 - 15, &dark
);
1664 ROperateLine(tile
, RAddOperation
, 64 - 5, 4, 64 - 5, 6 + 23 - 15, &light
);
1667 ROperateLine(tile
, RAddOperation
, 2, 64 - 1 - 23 + 2, 23 - 2, 64 - 3, &dark
);
1668 RDrawLine(tile
, 0, 64 - 1 - 23 - 1, 23 + 1, 64 - 1, &black
);
1669 ROperateLine(tile
, RSubtractOperation
, 0, 64 - 1 - 23 - 2, 23 + 1, 64 - 2, &light
);
1672 ROperateLine(tile
, RSubtractOperation
, 4, 64 - 7 - (23 - 15), 4, 64 - 5, &dark
);
1673 ROperateLine(tile
, RSubtractOperation
, 5, 64 - 6 - (23 - 15), 6 + 23 - 15, 64 - 5, &dark
);
1674 ROperateLine(tile
, RAddOperation
, 4, 64 - 5, 6 + 23 - 15, 64 - 5, &light
);
1676 RConvertImage(WMScreenRContext(scr
), tile
, &pix
);
1677 RReleaseImage(tile
);
1679 XCopyArea(dpy
, pix
, d
, gc
, 0, 0, 64, 64, 155, 130);
1680 XFreePixmap(dpy
, pix
);
1682 /* top right arrow */
1683 p
[0].x
= p
[3].x
= 155 + 64 - 5 - (23 - 15);
1684 p
[0].y
= p
[3].y
= 130 + 5;
1685 p
[1].x
= 155 + 64 - 6;
1687 p
[2].x
= 155 + 64 - 6;
1688 p
[2].y
= 130 + 4 + 23 - 15;
1690 XFillPolygon(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 3, Convex
, CoordModeOrigin
);
1691 XDrawLines(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 4, CoordModeOrigin
);
1693 /* bottom left arrow */
1694 p
[0].x
= p
[3].x
= 155 + 5;
1695 p
[0].y
= p
[3].y
= 130 + 64 - 5 - (23 - 15);
1697 p
[1].y
= 130 + 64 - 6;
1698 p
[2].x
= 155 + 4 + 23 - 15;
1699 p
[2].y
= 130 + 64 - 6;
1701 XFillPolygon(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 3, Convex
, CoordModeOrigin
);
1702 XDrawLines(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 4, CoordModeOrigin
);
1706 if (elements
& (1 << CLIP_COL
))
1707 paintText(scr
, d
, panel
->colors
[CLIP_COL
],
1708 panel
->boldFont
, 155 + 23, 130 + 64 - 15 - 3, 22, 15, WALeft
,
1711 if (elements
& (1 << CCLIP_COL
)) {
1712 paintText(scr
, d
, panel
->colors
[CCLIP_COL
],
1713 panel
->boldFont
, 155+2, 130 + 2, 26, 15, WALeft
, _("Coll."));
1714 paintText(scr
, d
, panel
->colors
[CCLIP_COL
],
1715 panel
->boldFont
, 155 + 23, 130 + 64 - 15 - 3, 22, 15, WALeft
,
1719 WMRedisplayWidget(panel
->prevL
);
1722 static void colorWellObserver(void *self
, WMNotification
* n
)
1724 _Panel
*panel
= (_Panel
*) self
;
1727 /* Parameter not used, but tell the compiler that it is ok */
1730 p
= WMGetPopUpButtonSelectedItem(panel
->colP
);
1732 WMReleaseColor(panel
->colors
[p
]);
1734 panel
->colors
[p
] = WMRetainColor(WMGetColorWellColor(panel
->colW
));
1736 updateColorPreviewBox(panel
, 1 << p
);
1739 static void changedTabItem(struct WMTabViewDelegate
*self
, WMTabView
* tabView
, WMTabViewItem
* item
)
1741 _Panel
*panel
= self
->data
;
1744 /* Parameter not used, but tell the compiler that it is ok */
1747 i
= WMGetTabViewItemIdentifier(item
);
1750 switch (panel
->oldTabItem
) {
1752 changeColorPage(NULL
, panel
);
1755 changePage(panel
->secP
, panel
);
1758 switch (panel
->oldTabItem
) {
1760 changePage(NULL
, panel
);
1763 changeColorPage(panel
->colP
, panel
);
1766 switch (panel
->oldTabItem
) {
1768 changePage(NULL
, panel
);
1771 changeColorPage(NULL
, panel
);
1777 panel
->oldTabItem
= i
;
1780 /*************************************************************************/
1782 static void menuStyleCallback(WMWidget
* self
, void *data
)
1784 _Panel
*panel
= (_Panel
*) data
;
1787 for (i
= 0; i
< wlengthof(menu_style
); i
++) {
1788 if (self
== panel
->mstyB
[i
]) {
1789 panel
->menuStyle
= i
;
1794 updatePreviewBox(panel
, 1 << PMITEM
);
1797 static void titleAlignCallback(WMWidget
* self
, void *data
)
1799 _Panel
*panel
= (_Panel
*) data
;
1802 for (align
= 0; align
< wlengthof(wintitle_align
); align
++) {
1803 if (self
== panel
->taliB
[align
]) {
1804 panel
->titleAlignment
= align
;
1809 updatePreviewBox(panel
, 1 << PFOCUSED
| 1 << PUNFOCUSED
| 1 << POWNER
);
1812 static void createPanel(Panel
* p
)
1814 _Panel
*panel
= (_Panel
*) p
;
1816 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
1817 WMTabViewItem
*item
;
1822 panel
->fprefix
= wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
1824 if (access(panel
->fprefix
, F_OK
) != 0) {
1825 if (mkdir(panel
->fprefix
, 0755) < 0) {
1826 werror("%s", panel
->fprefix
);
1831 tmp
= wstrconcat(panel
->fprefix
, "/WPrefs/");
1832 wfree(panel
->fprefix
);
1833 panel
->fprefix
= tmp
;
1834 if (access(panel
->fprefix
, F_OK
) != 0) {
1835 if (mkdir(panel
->fprefix
, 0755) < 0) {
1836 werror("%s", panel
->fprefix
);
1841 panel
->smallFont
= WMSystemFontOfSize(scr
, 10);
1842 panel
->normalFont
= WMSystemFontOfSize(scr
, 12);
1843 panel
->boldFont
= WMBoldSystemFontOfSize(scr
, 12);
1845 panel
->onLed
= WMCreatePixmapFromXPMData(scr
, blueled_xpm
);
1846 panel
->offLed
= WMCreatePixmapFromXPMData(scr
, blueled2_xpm
);
1847 panel
->hand
= WMCreatePixmapFromXPMData(scr
, hand_xpm
);
1849 panel
->box
= WMCreateBox(panel
->parent
);
1850 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
1853 panel
->prevL
= WMCreateLabel(panel
->box
);
1854 WMResizeWidget(panel
->prevL
, 240, FRAME_HEIGHT
- 20);
1855 WMMoveWidget(panel
->prevL
, 15, 10);
1856 WMSetLabelRelief(panel
->prevL
, WRSunken
);
1857 WMSetLabelImagePosition(panel
->prevL
, WIPImageOnly
);
1859 WMCreateEventHandler(WMWidgetView(panel
->prevL
), ButtonPressMask
, previewClick
, panel
);
1863 tabviewDelegate
.data
= panel
;
1865 panel
->tabv
= WMCreateTabView(panel
->box
);
1866 WMResizeWidget(panel
->tabv
, 245, FRAME_HEIGHT
- 20);
1867 WMMoveWidget(panel
->tabv
, 265, 10);
1868 WMSetTabViewDelegate(panel
->tabv
, &tabviewDelegate
);
1870 /*** texture list ***/
1872 panel
->texF
= WMCreateFrame(panel
->box
);
1873 WMSetFrameRelief(panel
->texF
, WRFlat
);
1875 item
= WMCreateTabViewItemWithIdentifier(TAB_TEXTURE
);
1876 WMSetTabViewItemView(item
, WMWidgetView(panel
->texF
));
1877 WMSetTabViewItemLabel(item
, _("Texture"));
1879 WMAddItemInTabView(panel
->tabv
, item
);
1881 panel
->secP
= WMCreatePopUpButton(panel
->texF
);
1882 WMResizeWidget(panel
->secP
, 228, 20);
1883 WMMoveWidget(panel
->secP
, 7, 7);
1885 for (i
= 0; i
< wlengthof(textureOptions
); i
++)
1886 WMAddPopUpButtonItem(panel
->secP
, _(textureOptions
[i
].popup_label
));
1888 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
1889 WMSetPopUpButtonAction(panel
->secP
, changePage
, panel
);
1891 panel
->texLs
= WMCreateList(panel
->texF
);
1892 WMResizeWidget(panel
->texLs
, 165, 155);
1893 WMMoveWidget(panel
->texLs
, 70, 33);
1894 WMSetListUserDrawItemHeight(panel
->texLs
, 35);
1895 WMSetListUserDrawProc(panel
->texLs
, paintListItem
);
1896 WMHangData(panel
->texLs
, panel
);
1897 WMSetListAction(panel
->texLs
, textureClick
, panel
);
1898 WMSetListDoubleAction(panel
->texLs
, textureDoubleClick
, panel
);
1900 WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
1901 "for the selected item."), WMWidgetView(panel
->texLs
));
1903 /* command buttons */
1905 font
= WMSystemFontOfSize(scr
, 10);
1907 panel
->newB
= WMCreateCommandButton(panel
->texF
);
1908 WMResizeWidget(panel
->newB
, 57, 39);
1909 WMMoveWidget(panel
->newB
, 7, 33);
1910 WMSetButtonFont(panel
->newB
, font
);
1911 WMSetButtonImagePosition(panel
->newB
, WIPAbove
);
1912 WMSetButtonText(panel
->newB
, _("New"));
1913 WMSetButtonAction(panel
->newB
, newTexture
, panel
);
1914 SetButtonAlphaImage(scr
, panel
->newB
, TNEW_FILE
);
1916 WMSetBalloonTextForView(_("Create a new texture."), WMWidgetView(panel
->newB
));
1918 panel
->ripB
= WMCreateCommandButton(panel
->texF
);
1919 WMResizeWidget(panel
->ripB
, 57, 39);
1920 WMMoveWidget(panel
->ripB
, 7, 72);
1921 WMSetButtonFont(panel
->ripB
, font
);
1922 WMSetButtonImagePosition(panel
->ripB
, WIPAbove
);
1923 WMSetButtonText(panel
->ripB
, _("Extract..."));
1924 WMSetButtonAction(panel
->ripB
, extractTexture
, panel
);
1925 SetButtonAlphaImage(scr
, panel
->ripB
, TEXTR_FILE
);
1927 WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."), WMWidgetView(panel
->ripB
));
1929 WMSetButtonEnabled(panel
->ripB
, False
);
1931 panel
->editB
= WMCreateCommandButton(panel
->texF
);
1932 WMResizeWidget(panel
->editB
, 57, 39);
1933 WMMoveWidget(panel
->editB
, 7, 111);
1934 WMSetButtonFont(panel
->editB
, font
);
1935 WMSetButtonImagePosition(panel
->editB
, WIPAbove
);
1936 WMSetButtonText(panel
->editB
, _("Edit"));
1937 SetButtonAlphaImage(scr
, panel
->editB
, TEDIT_FILE
);
1938 WMSetButtonAction(panel
->editB
, editTexture
, panel
);
1939 WMSetBalloonTextForView(_("Edit the highlighted texture."), WMWidgetView(panel
->editB
));
1941 panel
->delB
= WMCreateCommandButton(panel
->texF
);
1942 WMResizeWidget(panel
->delB
, 57, 38);
1943 WMMoveWidget(panel
->delB
, 7, 150);
1944 WMSetButtonFont(panel
->delB
, font
);
1945 WMSetButtonImagePosition(panel
->delB
, WIPAbove
);
1946 WMSetButtonText(panel
->delB
, _("Delete"));
1947 SetButtonAlphaImage(scr
, panel
->delB
, TDEL_FILE
);
1948 WMSetButtonEnabled(panel
->delB
, False
);
1949 WMSetButtonAction(panel
->delB
, deleteTexture
, panel
);
1950 WMSetBalloonTextForView(_("Delete the highlighted texture."), WMWidgetView(panel
->delB
));
1952 WMReleaseFont(font
);
1954 WMMapSubwidgets(panel
->texF
);
1957 panel
->colF
= WMCreateFrame(panel
->box
);
1958 WMSetFrameRelief(panel
->colF
, WRFlat
);
1960 item
= WMCreateTabViewItemWithIdentifier(TAB_COLOR
);
1961 WMSetTabViewItemView(item
, WMWidgetView(panel
->colF
));
1962 WMSetTabViewItemLabel(item
, _("Color"));
1964 WMAddItemInTabView(panel
->tabv
, item
);
1966 panel
->colP
= WMCreatePopUpButton(panel
->colF
);
1967 WMResizeWidget(panel
->colP
, 228, 20);
1968 WMMoveWidget(panel
->colP
, 7, 7);
1970 for (i
= 0; i
< wlengthof(colorOptions
); i
++)
1971 WMAddPopUpButtonItem(panel
->colP
, _(colorOptions
[i
].label
));
1973 WMSetPopUpButtonSelectedItem(panel
->colP
, 0);
1975 WMSetPopUpButtonAction(panel
->colP
, changeColorPage
, panel
);
1977 panel
->colW
= WMCreateColorWell(panel
->colF
);
1978 WMResizeWidget(panel
->colW
, 65, 50);
1979 WMMoveWidget(panel
->colW
, 30, 75);
1980 WMAddNotificationObserver(colorWellObserver
, panel
, WMColorWellDidChangeNotification
, panel
->colW
);
1982 { /* Distribute the color samples regularly in the right half */
1983 const int parent_width
= 242;
1984 const int parent_height
= 195;
1985 const int available_width
= (parent_width
/ 2) - 7;
1986 const int available_height
= parent_height
- 7 - 20 - 7 - 7;
1987 const int widget_size
= 22;
1989 const int nb_x
= (int) round(sqrt(wlengthof(sample_colors
) * available_width
/ available_height
));
1990 const int nb_y
= (wlengthof(sample_colors
) + nb_x
- 1) / nb_x
;
1992 const int offset_x
= (parent_width
/ 2) + (available_width
- nb_x
* widget_size
) / 2;
1993 const int offset_y
= (7 + 20 + 7) + (available_height
- nb_y
* widget_size
) / 2;
1998 for (i
= 0; i
< wlengthof(sample_colors
); i
++) {
1999 panel
->sampW
[i
] = WMCreateColorWell(panel
->colF
);
2000 WMResizeWidget(panel
->sampW
[i
], widget_size
, widget_size
);
2001 WMMoveWidget(panel
->sampW
[i
], offset_x
+ x
* widget_size
, offset_y
+ y
* widget_size
);
2002 WSetColorWellBordered(panel
->sampW
[i
], False
);
2010 WMMapSubwidgets(panel
->colF
);
2013 panel
->optF
= WMCreateFrame(panel
->box
);
2014 WMSetFrameRelief(panel
->optF
, WRFlat
);
2016 item
= WMCreateTabViewItemWithIdentifier(TAB_OPTIONS
);
2017 WMSetTabViewItemView(item
, WMWidgetView(panel
->optF
));
2018 WMSetTabViewItemLabel(item
, _("Options"));
2020 WMAddItemInTabView(panel
->tabv
, item
);
2022 panel
->mstyF
= WMCreateFrame(panel
->optF
);
2023 WMResizeWidget(panel
->mstyF
, 215, 85);
2024 WMMoveWidget(panel
->mstyF
, 15, 10);
2025 WMSetFrameTitle(panel
->mstyF
, _("Menu Style"));
2027 for (i
= 0; i
< wlengthof(menu_style
); i
++) {
2031 panel
->mstyB
[i
] = WMCreateButton(panel
->mstyF
, WBTOnOff
);
2032 WMResizeWidget(panel
->mstyB
[i
], 54, 54);
2033 WMMoveWidget(panel
->mstyB
[i
], 15 + i
* 65, 20);
2034 WMSetButtonImagePosition(panel
->mstyB
[i
], WIPImageOnly
);
2035 WMSetButtonAction(panel
->mstyB
[i
], menuStyleCallback
, panel
);
2036 path
= LocateImage(menu_style
[i
].file_name
);
2038 icon
= WMCreatePixmapFromFile(scr
, path
);
2040 WMSetButtonImage(panel
->mstyB
[i
], icon
);
2041 WMReleasePixmap(icon
);
2043 wwarning(_("could not load icon file %s"), path
);
2048 WMGroupButtons(panel
->mstyB
[0], panel
->mstyB
[1]);
2049 WMGroupButtons(panel
->mstyB
[0], panel
->mstyB
[2]);
2051 WMMapSubwidgets(panel
->mstyF
);
2053 panel
->taliF
= WMCreateFrame(panel
->optF
);
2054 WMResizeWidget(panel
->taliF
, 110, 80);
2055 WMMoveWidget(panel
->taliF
, 15, 100);
2056 WMSetFrameTitle(panel
->taliF
, _("Title Alignment"));
2058 for (i
= 0; i
< wlengthof(wintitle_align
); i
++) {
2059 panel
->taliB
[i
] = WMCreateRadioButton(panel
->taliF
);
2060 WMSetButtonAction(panel
->taliB
[i
], titleAlignCallback
, panel
);
2061 WMSetButtonText(panel
->taliB
[i
], _(wintitle_align
[i
].label
));
2062 WMResizeWidget(panel
->taliB
[i
], 90, 18);
2063 WMMoveWidget(panel
->taliB
[i
], 10, 15 + 20 * i
);
2065 WMGroupButtons(panel
->taliB
[0], panel
->taliB
[1]);
2066 WMGroupButtons(panel
->taliB
[0], panel
->taliB
[2]);
2068 WMMapSubwidgets(panel
->taliF
);
2070 WMMapSubwidgets(panel
->optF
);
2072 /**/ WMRealizeWidget(panel
->box
);
2073 WMMapSubwidgets(panel
->box
);
2075 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
2079 changePage(panel
->secP
, panel
);
2081 fillTextureList(panel
->texLs
);
2083 fillColorList(panel
);
2085 panel
->texturePanel
= CreateTexturePanel(panel
->parent
);
2088 static void setupTextureFor(WMList
*list
, const char *key
, const char *defValue
, const char *title
, int index
)
2091 TextureListItem
*titem
;
2093 titem
= wmalloc(sizeof(TextureListItem
));
2095 titem
->title
= wstrdup(title
);
2096 titem
->prop
= GetObjectForKey(key
);
2097 if (!titem
->prop
|| !WMIsPLArray(titem
->prop
)) {
2098 /* Maybe also give a error message to stderr that the entry is bad? */
2099 titem
->prop
= WMCreatePropListFromDescription(defValue
);
2101 WMRetainPropList(titem
->prop
);
2103 titem
->texture
= WMGetPropListDescription((WMPropList
*) titem
->prop
, False
);
2105 titem
->selectedFor
= 1 << index
;
2107 titem
->ispixmap
= isPixmap(titem
->prop
);
2109 titem
->preview
= renderTexture(WMWidgetScreen(list
), titem
->prop
, TEXPREV_WIDTH
, TEXPREV_HEIGHT
, NULL
, 0);
2111 item
= WMAddListItem(list
, "");
2112 item
->clientData
= titem
;
2115 static void showData(_Panel
* panel
)
2120 str
= GetStringForKey("MenuStyle");
2121 panel
->menuStyle
= MSTYLE_NORMAL
;
2123 for (i
= 0; i
< wlengthof(menu_style
); i
++) {
2124 if (strcasecmp(str
, menu_style
[i
].db_value
) == 0) {
2125 panel
->menuStyle
= i
;
2131 str
= GetStringForKey("TitleJustify");
2132 panel
->titleAlignment
= WACenter
;
2136 for (align
= 0; align
< wlengthof(wintitle_align
); align
++) {
2137 if (strcasecmp(str
, wintitle_align
[align
].db_value
) == 0) {
2138 panel
->titleAlignment
= align
;
2144 for (i
= 0; i
< wlengthof(colorOptions
); i
++) {
2147 str
= GetStringForKey(colorOptions
[i
].key
);
2149 str
= colorOptions
[i
].default_value
;
2151 if (!(color
= WMCreateNamedColor(WMWidgetScreen(panel
->box
), str
, False
))) {
2152 color
= WMCreateNamedColor(WMWidgetScreen(panel
->box
), "#000000", False
);
2155 panel
->colors
[i
] = color
;
2157 changeColorPage(panel
->colP
, panel
);
2159 for (i
= 0; i
< wlengthof(textureOptions
); i
++) {
2160 setupTextureFor(panel
->texLs
, textureOptions
[i
].key
,
2161 textureOptions
[i
].default_value
, _(textureOptions
[i
].texture_label
), i
);
2162 panel
->textureIndex
[i
] = i
;
2164 updatePreviewBox(panel
, EVERYTHING
);
2166 WMSetButtonSelected(panel
->mstyB
[panel
->menuStyle
], True
);
2167 WMSetButtonSelected(panel
->taliB
[panel
->titleAlignment
], True
);
2170 static void storeData(_Panel
* panel
)
2172 TextureListItem
*titem
;
2176 for (i
= 0; i
< wlengthof(textureOptions
); i
++) {
2177 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[i
]);
2178 titem
= (TextureListItem
*) item
->clientData
;
2179 SetObjectForKey(titem
->prop
, textureOptions
[i
].key
);
2182 for (i
= 0; i
< wlengthof(colorOptions
); i
++) {
2185 str
= WMGetColorRGBDescription(panel
->colors
[i
]);
2188 SetStringForKey(str
, colorOptions
[i
].key
);
2193 SetStringForKey(menu_style
[panel
->menuStyle
].db_value
, "MenuStyle");
2194 SetStringForKey(wintitle_align
[panel
->titleAlignment
].db_value
, "TitleJustify");
2197 static void prepareForClose(_Panel
* panel
)
2199 WMPropList
*textureList
;
2200 WMPropList
*texture
;
2201 TextureListItem
*titem
;
2203 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
2206 textureList
= WMCreatePLArray(NULL
, NULL
);
2208 /* store list of textures */
2209 for (i
= 8; i
< WMGetListNumberOfRows(panel
->texLs
); i
++) {
2210 WMPropList
*pl_title
, *pl_path
;
2212 item
= WMGetListItem(panel
->texLs
, i
);
2213 titem
= (TextureListItem
*) item
->clientData
;
2215 pl_title
= WMCreatePLString(titem
->title
);
2216 pl_path
= WMCreatePLString(titem
->path
);
2217 texture
= WMCreatePLArray(pl_title
, titem
->prop
, pl_path
, NULL
);
2218 WMReleasePropList(pl_title
);
2219 WMReleasePropList(pl_path
);
2221 WMAddToPLArray(textureList
, texture
);
2224 WMSetUDObjectForKey(udb
, textureList
, "TextureList");
2225 WMReleasePropList(textureList
);
2227 /* store list of colors */
2228 textureList
= WMCreatePLArray(NULL
, NULL
);
2229 for (i
= 0; i
< wlengthof(sample_colors
); i
++) {
2232 WMPropList
*pl_color
;
2234 color
= WMGetColorWellColor(panel
->sampW
[i
]);
2236 str
= WMGetColorRGBDescription(color
);
2237 pl_color
= WMCreatePLString(str
);
2238 WMAddToPLArray(textureList
, pl_color
);
2239 WMReleasePropList(pl_color
);
2242 WMSetUDObjectForKey(udb
, textureList
, "ColorList");
2243 WMReleasePropList(textureList
);
2245 WMSynchronizeUserDefaults(udb
);
2248 Panel
*InitAppearance(WMWidget
*parent
)
2252 panel
= wmalloc(sizeof(_Panel
));
2254 panel
->sectionName
= _("Appearance Preferences");
2256 panel
->description
= _("Background texture configuration for windows,\n" "menus and icons.");
2258 panel
->parent
= parent
;
2260 panel
->callbacks
.createWidgets
= createPanel
;
2261 panel
->callbacks
.updateDomain
= storeData
;
2262 panel
->callbacks
.prepareForClose
= prepareForClose
;
2264 AddSection(panel
, ICON_FILE
);
2269 /****************************************************************************/
2271 typedef struct ExtractPanel
{
2281 static void OpenExtractPanelFor(_Panel
*panel
)
2283 ExtractPanel
*epanel
;
2286 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
2288 epanel
= wmalloc(sizeof(ExtractPanel
));
2289 epanel
->win
= WMCreatePanelWithStyleForWindow(panel
->parent
, "extract",
2290 WMTitledWindowMask
| WMClosableWindowMask
);
2291 WMResizeWidget(epanel
->win
, 245, 250);
2292 WMSetWindowTitle(epanel
->win
, _("Extract Texture"));
2294 epanel
->label
= WMCreateLabel(epanel
->win
);
2295 WMResizeWidget(epanel
->label
, 225, 18);
2296 WMMoveWidget(epanel
->label
, 10, 10);
2297 WMSetLabelTextAlignment(epanel
->label
, WACenter
);
2298 WMSetLabelRelief(epanel
->label
, WRSunken
);
2300 color
= WMDarkGrayColor(scr
);
2301 WMSetWidgetBackgroundColor(epanel
->label
, color
);
2302 WMReleaseColor(color
);
2304 color
= WMWhiteColor(scr
);
2305 WMSetLabelTextColor(epanel
->label
, color
);
2306 WMReleaseColor(color
);
2308 font
= WMBoldSystemFontOfSize(scr
, 12);
2309 WMSetLabelFont(epanel
->label
, font
);
2310 WMReleaseFont(font
);
2312 WMSetLabelText(epanel
->label
, _("Textures"));
2314 epanel
->list
= WMCreateList(epanel
->win
);
2315 WMResizeWidget(epanel
->list
, 225, 165);
2316 WMMoveWidget(epanel
->list
, 10, 30);
2318 epanel
->closeB
= WMCreateCommandButton(epanel
->win
);
2319 WMResizeWidget(epanel
->closeB
, 74, 24);
2320 WMMoveWidget(epanel
->closeB
, 165, 215);
2321 WMSetButtonText(epanel
->closeB
, _("Close"));
2323 epanel
->extrB
= WMCreateCommandButton(epanel
->win
);
2324 WMResizeWidget(epanel
->extrB
, 74, 24);
2325 WMMoveWidget(epanel
->extrB
, 80, 215);
2326 WMSetButtonText(epanel
->extrB
, _("Extract"));
2328 WMMapSubwidgets(epanel
->win
);
2330 /* take textures from file */
2332 WMRealizeWidget(epanel
->win
);
2334 WMMapWidget(epanel
->win
);