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"
34 typedef struct _Panel
{
40 CallbackRec callbacks
;
67 WMColorWell
*sampW
[24];
86 TexturePanel
*texturePanel
;
102 Pixmap previewNoText
;
127 static void updateColorPreviewBox(_Panel
* panel
, int elements
);
129 static void showData(_Panel
* panel
);
131 static void changePage(WMWidget
* w
, void *data
);
133 static void changeColorPage(WMWidget
* w
, void *data
);
135 static void OpenExtractPanelFor(_Panel
*panel
);
137 static void changedTabItem(struct WMTabViewDelegate
*self
, WMTabView
* tabView
, WMTabViewItem
* item
);
139 static WMTabViewDelegate tabviewDelegate
= {
141 NULL
, /* didChangeNumberOfItems */
142 changedTabItem
, /* didSelectItem */
143 NULL
, /* shouldSelectItem */
144 NULL
/* willSelectItem */
147 #define ICON_FILE "appearance"
149 #define TNEW_FILE "tnew"
150 #define TDEL_FILE "tdel"
151 #define TEDIT_FILE "tedit"
152 #define TEXTR_FILE "textr"
154 #define MSTYLE1_FILE "msty1"
155 #define MSTYLE2_FILE "msty2"
156 #define MSTYLE3_FILE "msty3"
159 static char *blueled_xpm
[] = {
189 static char *blueled2_xpm
[] = {
190 /* width height num_colors chars_per_pixel */
222 static char *hand_xpm
[] = {
246 " .%%%&@.......... ",
247 " .%*%%&#%%%%%%%%%$. ",
248 " .*#%%%%%%%%%&&&&==. ",
249 " .-%%%%%%%%%=*-;;;#$. ",
250 " .-%%%%%%%%&..>..... ",
266 static char *sampleColors
[] = {
294 static const struct {
296 const char *default_value
;
297 const char *texture_label
; /* text used when displaying the list of textures */
298 WMRect preview
; /* The rectangle where the corresponding object is displayed */
299 WMPoint hand
; /* The coordinate where the hand is drawn when pointing this item */
300 const char *popup_label
; /* text used for the popup button with the list of editable items */
301 } textureOptions
[] = {
304 { "FTitleBack", "(solid, black)", N_("[Focused]"),
305 { { 30, 10 }, { 190, 20 } }, { 5, 10 }, N_("Titlebar of Focused Window") },
308 { "UTitleBack", "(solid, gray)", N_("[Unfocused]"),
309 { { 30, 40 }, { 190, 20 } }, { 5, 40 }, N_("Titlebar of Unfocused Windows") },
312 { "PTitleBack", "(solid, \"#616161\")", N_("[Owner of Focused]"),
313 { { 30, 70 }, { 190, 20 } }, { 5, 70 }, N_("Titlebar of Focused Window's Owner") },
316 { "ResizebarBack", "(solid, gray)", N_("[Resizebar]"),
317 { { 30, 100 }, { 190, 9 } }, { 5, 100 }, N_("Window Resizebar") },
320 { "MenuTitleBack", "(solid, black)", N_("[Menu Title]"),
321 { { 30, 120 }, { 90, 20 } }, { 5, 120 }, N_("Titlebar of Menus") },
324 { "MenuTextBack", "(solid, gray)", N_("[Menu Item]"),
325 { { 30, 140 }, { 90, 20 * 4 } }, { 5, 160 }, N_("Menu Items") },
328 { "IconBack", "(solid, gray)", N_("[Icon]"),
329 { { 155, 130 }, { 64, 64 } }, { 130, 150 }, N_("Icon Background") },
331 #define PBACKGROUND 7
332 { "WorkspaceBack", "(solid, black)", N_("[Background]"),
333 { { -1, -1}, { 0, 0 } }, { -22, -21 }, N_("Workspace Background") }
335 #define EVERYTHING 0xff
339 RESIZEBAR_BEVEL
= -1,
372 static const struct {
374 const char *default_value
;
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 */
379 /* Related to Window titles */
380 { "FTitleColor", "white", N_("Focused Window Title"),
381 { { 30, 10 }, { 190, 20 } }, { 5, 10 } },
382 { "UTitleColor", "black", N_("Unfocused Window Title"),
383 { { 30, 40 }, { 190, 20 } }, { 5, 40 } },
384 { "PTitleColor", "white", N_("Owner of Focused Window Title"),
385 { { 30, 70 }, { 190, 20 } }, { 5, 70 } },
387 /* Related to Menus */
388 { "MenuTitleColor", "white", N_("Menu Title") ,
389 { { 30, 120 }, { 90, 20 } }, { 5, 120 } },
390 { "MenuTextColor", "black", N_("Menu Item Text") ,
391 { { 30, 140 }, { 90, 20 } }, { 5, 140 } },
392 { "MenuDisabledColor", "#616161", N_("Disabled Menu Item Text") ,
393 { { 30, 160 }, { 90, 20 } }, { 5, 160 } },
394 { "HighlightColor", "white", N_("Menu Highlight Color") ,
395 { { 30, 180 }, { 90, 20 } }, { 5, 180 } },
396 { "HighlightTextColor", "black", N_("Highlighted Menu Text Color") ,
397 { { 30, 200 }, { 90, 20 } }, { 5, 180 } },
399 * yuck kluge: the coordinate for HighlightTextColor are actually those of the last "Normal item"
400 * at the bottom when user clicks it, the "yuck kluge" in the function 'previewClick' will swap it
401 * for the MenuTextColor selection as user would expect
403 * Note that the entries are reffered by their index for performance
406 /* Related to Window's border */
407 { "FrameFocusedBorderColor", "black", N_("Focused Window Border Color") ,
408 { { 0, 0 }, { 0, 0 } }, { -22, -21 } },
409 { "FrameBorderColor", "black", N_("Window Border Color") ,
410 { { 0, 0 }, { 0, 0 } }, { -22, -21 } },
411 { "FrameSelectedBorderColor", "white", N_("Selected Window Border Color") ,
412 { { 0, 0 }, { 0, 0 } }, { -22, -21 } },
414 /* Related to Icons and Clip */
415 { "IconTitleColor", "white", N_("Miniwindow Title") ,
416 { { 155, 130 }, { 64, 64 } }, { 130, 132 } },
417 { "IconTitleBack", "black", N_("Miniwindow Title Back") ,
418 { { 155, 130 }, { 64, 64 } }, { 130, 132 } },
419 { "ClipTitleColor", "black", N_("Clip Title") ,
420 { { 155, 130 }, { 64, 64 } }, { 130, 132 } },
421 { "CClipTitleColor", "#454045", N_("Collapsed Clip Title") ,
422 { { 155, 130 }, { 64, 64 } }, { 130, 132 } }
426 static void str2rcolor(RContext
* rc
, const char *name
, RColor
* color
)
430 XParseColor(rc
->dpy
, rc
->cmap
, name
, &xcolor
);
433 color
->red
= xcolor
.red
>> 8;
434 color
->green
= xcolor
.green
>> 8;
435 color
->blue
= xcolor
.blue
>> 8;
438 static void dumpRImage(const char *path
, RImage
* image
)
441 int channels
= (image
->format
== RRGBAFormat
? 4 : 3);
443 f
= fopen(path
, "wb");
448 fprintf(f
, "%02x%02x%1x", image
->width
, image
->height
, channels
);
450 fwrite(image
->data
, 1, image
->width
* image
->height
* channels
, f
);
458 static int isPixmap(WMPropList
* prop
)
463 p
= WMGetFromPLArray(prop
, 0);
464 s
= WMGetFromPLString(p
);
465 if (strcasecmp(&s
[1], "pixmap") == 0)
471 /**********************************************************************/
473 static void drawResizebarBevel(RImage
* img
)
477 int width
= img
->width
;
478 int height
= img
->height
;
482 light
.red
= light
.green
= light
.blue
= 80;
485 dark
.red
= dark
.green
= dark
.blue
= 40;
487 ROperateLine(img
, RSubtractOperation
, 0, 0, width
- 1, 0, &dark
);
488 ROperateLine(img
, RAddOperation
, 0, 1, width
- 1, 1, &light
);
490 ROperateLine(img
, RSubtractOperation
, cwidth
, 2, cwidth
, height
- 1, &dark
);
491 ROperateLine(img
, RAddOperation
, cwidth
+ 1, 2, cwidth
+ 1, height
- 1, &light
);
493 ROperateLine(img
, RSubtractOperation
, width
- cwidth
- 2, 2, width
- cwidth
- 2, height
- 1, &dark
);
494 ROperateLine(img
, RAddOperation
, width
- cwidth
- 1, 2, width
- cwidth
- 1, height
- 1, &light
);
498 static void drawMenuBevel(RImage
* img
)
500 RColor light
, dark
, mid
;
502 int iheight
= img
->height
/ 4;
505 light
.red
= light
.green
= light
.blue
= 80;
508 dark
.red
= dark
.green
= dark
.blue
= 0;
511 mid
.red
= mid
.green
= mid
.blue
= 40;
513 for (i
= 1; i
< 4; i
++) {
514 ROperateLine(img
, RSubtractOperation
, 0, i
* iheight
- 2, img
->width
- 1, i
* iheight
- 2, &mid
);
516 RDrawLine(img
, 0, i
* iheight
- 1, img
->width
- 1, i
* iheight
- 1, &dark
);
518 ROperateLine(img
, RAddOperation
, 1, i
* iheight
, img
->width
- 2, i
* iheight
, &light
);
522 static Pixmap
renderTexture(WMScreen
* scr
, WMPropList
* texture
, int width
, int height
, const char *path
, int border
)
525 RImage
*image
= NULL
;
526 RImage
*timage
= NULL
;
528 RContext
*rc
= WMScreenRContext(scr
);
532 type
= WMGetFromPLString(WMGetFromPLArray(texture
, 0));
534 if (strcasecmp(&type
[1], "pixmap") == 0 ||
535 (strcasecmp(&type
[2], "gradient") == 0 && toupper(type
[0]) == 'T')) {
538 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
539 path
= wfindfileinarray(GetObjectForKey("PixmapPath"), str
);
541 timage
= RLoadImage(rc
, path
, 0);
543 wwarning("could not load file '%s': %s", path
, RMessageForError(RErrorCode
));
546 wwarning("could not find file '%s' for %s of texture", str
, type
);
550 texture
= WMCreatePropListFromDescription("(solid, black)");
555 if (strcasecmp(type
, "solid") == 0) {
557 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
559 str2rcolor(rc
, str
, &rcolor
);
561 image
= RCreateImage(width
, height
, False
);
562 RClearImage(image
, &rcolor
);
563 } else if (strcasecmp(type
, "igradient") == 0) {
567 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
568 str2rcolor(rc
, str
, &c1
[0]);
569 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
570 str2rcolor(rc
, str
, &c1
[1]);
571 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 3));
574 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 4));
575 str2rcolor(rc
, str
, &c2
[0]);
576 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 5));
577 str2rcolor(rc
, str
, &c2
[1]);
578 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 6));
581 image
= RRenderInterwovenGradient(width
, height
, c1
, t1
, c2
, t2
);
582 } else if (strcasecmp(&type
[1], "gradient") == 0) {
583 RGradientStyle style
;
586 switch (toupper(type
[0])) {
588 style
= RVerticalGradient
;
591 style
= RHorizontalGradient
;
594 wwarning("unknow direction in '%s', falling back to diagonal", type
);
596 style
= RDiagonalGradient
;
600 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
601 str2rcolor(rc
, str
, &rcolor
);
602 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
603 str2rcolor(rc
, str
, &rcolor2
);
605 image
= RRenderGradient(width
, height
, &rcolor
, &rcolor2
, style
);
606 } else if (strcasecmp(&type
[2], "gradient") == 0 && toupper(type
[0]) == 'T') {
607 RGradientStyle style
;
612 switch (toupper(type
[1])) {
614 style
= RVerticalGradient
;
617 style
= RHorizontalGradient
;
620 wwarning("unknow direction in '%s', falling back to diagonal", type
);
622 style
= RDiagonalGradient
;
626 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 3));
627 str2rcolor(rc
, str
, &rcolor
);
628 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 4));
629 str2rcolor(rc
, str
, &rcolor2
);
631 grad
= RRenderGradient(width
, height
, &rcolor
, &rcolor2
, style
);
633 image
= RMakeTiledImage(timage
, width
, height
);
634 RReleaseImage(timage
);
636 i
= atoi(WMGetFromPLString(WMGetFromPLArray(texture
, 2)));
638 RCombineImagesWithOpaqueness(image
, grad
, i
);
641 } else if (strcasecmp(&type
[2], "gradient") == 0 && toupper(type
[0]) == 'M') {
642 RGradientStyle style
;
646 switch (toupper(type
[1])) {
648 style
= RVerticalGradient
;
651 style
= RHorizontalGradient
;
654 wwarning("unknow direction in '%s', falling back to diagonal", type
);
656 style
= RDiagonalGradient
;
660 j
= WMGetPropListItemCount(texture
);
663 colors
= wmalloc(j
* sizeof(RColor
*));
665 for (i
= 2; i
< j
; i
++) {
666 str
= WMGetFromPLString(WMGetFromPLArray(texture
, i
));
667 colors
[i
- 2] = wmalloc(sizeof(RColor
));
668 str2rcolor(rc
, str
, colors
[i
- 2]);
670 colors
[i
- 2] = NULL
;
672 image
= RRenderMultiGradient(width
, height
, colors
, style
);
674 for (i
= 0; colors
[i
] != NULL
; i
++)
678 } else if (strcasecmp(&type
[1], "pixmap") == 0) {
681 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
682 str2rcolor(rc
, str
, &color
);
684 switch (toupper(type
[0])) {
686 image
= RMakeTiledImage(timage
, width
, height
);
687 RReleaseImage(timage
);
690 image
= RMakeCenteredImage(timage
, width
, height
, &color
);
691 RReleaseImage(timage
);
696 image
= RScaleImage(timage
, width
, height
);
697 RReleaseImage(timage
);
701 wwarning("type '%s' in not a supported type for a texture", type
);
702 RReleaseImage(timage
);
711 dumpRImage(path
, image
);
715 if (border
== RESIZEBAR_BEVEL
) {
716 drawResizebarBevel(image
);
717 } else if (border
== MENU_BEVEL
) {
718 drawMenuBevel(image
);
719 RBevelImage(image
, RBEV_RAISED2
);
722 RBevelImage(image
, border
);
725 RConvertImage(rc
, image
, &pixmap
);
726 RReleaseImage(image
);
731 static Pixmap
renderMenu(_Panel
* panel
, WMPropList
* texture
, int width
, int iheight
)
733 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
734 Display
*dpy
= WMScreenDisplay(scr
);
736 GC gc
= XCreateGC(dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
739 switch (panel
->menuStyle
) {
741 tmp
= renderTexture(scr
, texture
, width
, iheight
, NULL
, RBEV_RAISED2
);
743 pix
= XCreatePixmap(dpy
, tmp
, width
, iheight
* 4, WMScreenDepth(scr
));
744 for (i
= 0; i
< 4; i
++) {
745 XCopyArea(dpy
, tmp
, pix
, gc
, 0, 0, width
, iheight
, 0, iheight
* i
);
747 XFreePixmap(dpy
, tmp
);
750 pix
= renderTexture(scr
, texture
, width
, iheight
* 4, NULL
, MENU_BEVEL
);
753 pix
= renderTexture(scr
, texture
, width
, iheight
* 4, NULL
, RBEV_RAISED2
);
763 static void renderPreview(_Panel
* panel
, GC gc
, int part
, int relief
)
766 TextureListItem
*titem
;
768 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
770 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[part
]);
771 titem
= (TextureListItem
*) item
->clientData
;
773 pix
= renderTexture(scr
, titem
->prop
,
774 textureOptions
[part
].preview
.size
.width
, textureOptions
[part
].preview
.size
.height
,
777 XCopyArea(WMScreenDisplay(scr
), pix
, panel
->preview
, gc
, 0, 0,
778 textureOptions
[part
].preview
.size
.width
, textureOptions
[part
].preview
.size
.height
,
779 textureOptions
[part
].preview
.pos
.x
, textureOptions
[part
].preview
.pos
.y
);
781 XCopyArea(WMScreenDisplay(scr
), pix
, panel
->previewNoText
, gc
, 0, 0,
782 textureOptions
[part
].preview
.size
.width
, textureOptions
[part
].preview
.size
.height
,
783 textureOptions
[part
].preview
.pos
.x
, textureOptions
[part
].preview
.pos
.y
);
785 XFreePixmap(WMScreenDisplay(scr
), pix
);
788 static void updatePreviewBox(_Panel
* panel
, int elements
)
790 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
791 Display
*dpy
= WMScreenDisplay(scr
);
796 gc
= XCreateGC(dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
798 if (panel
->preview
== None
) {
801 panel
->previewNoText
= XCreatePixmap(dpy
, WMWidgetXID(panel
->parent
),
802 240 - 4, 215 - 4, WMScreenDepth(scr
));
803 panel
->previewBack
= XCreatePixmap(dpy
, WMWidgetXID(panel
->parent
),
804 240 - 4, 215 - 4, WMScreenDepth(scr
));
806 p
= WMCreatePixmap(scr
, 240 - 4, 215 - 4, WMScreenDepth(scr
), False
);
807 panel
->preview
= WMGetPixmapXID(p
);
808 WMSetLabelImage(panel
->prevL
, p
);
811 if (elements
& (1 << PBACKGROUND
)) {
813 TextureListItem
*titem
;
816 item
= WMGetListItem(panel
->texLs
,
817 panel
->textureIndex
[PBACKGROUND
]);
818 titem
= (TextureListItem
*) item
->clientData
;
819 tmp
= renderTexture(scr
, titem
->prop
, 240 - 4, 215 - 4, NULL
, 0);
821 XCopyArea(dpy
, tmp
, panel
->preview
, gc
, 0, 0, 240 - 4, 215 -4 , 0, 0);
822 XCopyArea(dpy
, tmp
, panel
->previewNoText
, gc
, 0, 0, 240 - 4, 215 -4 , 0, 0);
823 XCopyArea(dpy
, tmp
, panel
->previewBack
, gc
, 0, 0, 240 - 4, 215 -4 , 0, 0);
824 XFreePixmap(dpy
, tmp
);
827 if (elements
& (1 << PFOCUSED
)) {
828 renderPreview(panel
, gc
, PFOCUSED
, RBEV_RAISED2
);
829 colorUpdate
|= 1 << FTITLE_COL
| 1 << FFBORDER_COL
;
831 if (elements
& (1 << PUNFOCUSED
)) {
832 renderPreview(panel
, gc
, PUNFOCUSED
, RBEV_RAISED2
);
833 colorUpdate
|= 1 << UTITLE_COL
| 1 << FBORDER_COL
;
835 if (elements
& (1 << POWNER
)) {
836 renderPreview(panel
, gc
, POWNER
, RBEV_RAISED2
);
837 colorUpdate
|= 1 << OTITLE_COL
| 1 << FBORDER_COL
;
839 if (elements
& (1 << PRESIZEBAR
)) {
840 renderPreview(panel
, gc
, PRESIZEBAR
, RESIZEBAR_BEVEL
);
841 colorUpdate
|= 1 << FBORDER_COL
;
843 if (elements
& (1 << PMTITLE
)) {
844 renderPreview(panel
, gc
, PMTITLE
, RBEV_RAISED2
);
845 colorUpdate
|= 1 << MTITLE_COL
| 1 << FBORDER_COL
;
847 if (elements
& (1 << PMITEM
)) {
849 TextureListItem
*titem
;
851 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[5]);
852 titem
= (TextureListItem
*) item
->clientData
;
854 pix
= renderMenu(panel
, titem
->prop
,
855 textureOptions
[PMITEM
].preview
.size
.width
,
856 textureOptions
[PMITEM
].preview
.size
.height
/ 4);
858 XCopyArea(dpy
, pix
, panel
->preview
, gc
, 0, 0,
859 textureOptions
[PMITEM
].preview
.size
.width
, textureOptions
[PMITEM
].preview
.size
.height
,
860 textureOptions
[PMITEM
].preview
.pos
.x
, textureOptions
[PMITEM
].preview
.pos
.y
);
862 XCopyArea(dpy
, pix
, panel
->previewNoText
, gc
, 0, 0,
863 textureOptions
[PMITEM
].preview
.size
.width
, textureOptions
[PMITEM
].preview
.size
.height
,
864 textureOptions
[PMITEM
].preview
.pos
.x
, textureOptions
[PMITEM
].preview
.pos
.y
);
866 XFreePixmap(dpy
, pix
);
868 colorUpdate
|= 1 << MITEM_COL
| 1 << MDISAB_COL
|
869 1 << MHIGH_COL
| 1 << MHIGHT_COL
|
872 if (elements
& (1 << PICON
)) {
874 TextureListItem
*titem
;
876 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[6]);
877 titem
= (TextureListItem
*) item
->clientData
;
879 renderPreview(panel
, gc
, PICON
, titem
->ispixmap
? 0 : RBEV_RAISED3
);
883 updateColorPreviewBox(panel
, colorUpdate
);
885 WMRedisplayWidget(panel
->prevL
);
890 static void cancelNewTexture(void *data
)
892 _Panel
*panel
= (_Panel
*) data
;
894 HideTexturePanel(panel
->texturePanel
);
897 static char *makeFileName(const char *prefix
)
901 fname
= wstrdup(prefix
);
903 while (access(fname
, F_OK
) == 0) {
907 sprintf(buf
, "%08lx.cache", time(NULL
));
908 fname
= wstrconcat(prefix
, buf
);
914 static void okNewTexture(void *data
)
916 _Panel
*panel
= (_Panel
*) data
;
921 TextureListItem
*titem
;
922 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
924 titem
= wmalloc(sizeof(TextureListItem
));
926 HideTexturePanel(panel
->texturePanel
);
928 name
= GetTexturePanelTextureName(panel
->texturePanel
);
930 prop
= GetTexturePanelTexture(panel
->texturePanel
);
932 str
= WMGetPropListDescription(prop
, False
);
936 titem
->texture
= str
;
937 titem
->selectedFor
= 0;
939 titem
->ispixmap
= isPixmap(prop
);
941 titem
->path
= makeFileName(panel
->fprefix
);
942 titem
->preview
= renderTexture(scr
, prop
, TEXPREV_WIDTH
, TEXPREV_HEIGHT
, titem
->path
, 0);
944 item
= WMAddListItem(panel
->texLs
, "");
945 item
->clientData
= titem
;
947 WMSetListPosition(panel
->texLs
, WMGetListNumberOfRows(panel
->texLs
));
950 static void okEditTexture(void *data
)
952 _Panel
*panel
= (_Panel
*) data
;
957 TextureListItem
*titem
;
959 item
= WMGetListItem(panel
->texLs
, WMGetListSelectedItemRow(panel
->texLs
));
960 titem
= (TextureListItem
*) item
->clientData
;
962 HideTexturePanel(panel
->texturePanel
);
964 if (titem
->current
) {
965 name
= GetTexturePanelTextureName(panel
->texturePanel
);
971 prop
= GetTexturePanelTexture(panel
->texturePanel
);
973 str
= WMGetPropListDescription(prop
, False
);
975 WMReleasePropList(titem
->prop
);
978 titem
->ispixmap
= isPixmap(prop
);
980 wfree(titem
->texture
);
981 titem
->texture
= str
;
983 XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel
->texLs
)), titem
->preview
);
984 titem
->preview
= renderTexture(WMWidgetScreen(panel
->texLs
), titem
->prop
,
985 TEXPREV_WIDTH
, TEXPREV_HEIGHT
, titem
->path
, 0);
987 WMRedisplayWidget(panel
->texLs
);
989 if (titem
->selectedFor
) {
990 if (titem
->selectedFor
& (1 << PBACKGROUND
))
991 updatePreviewBox(panel
, EVERYTHING
);
993 updatePreviewBox(panel
, titem
->selectedFor
);
996 changePage(panel
->secP
, panel
);
999 static void editTexture(WMWidget
* w
, void *data
)
1001 _Panel
*panel
= (_Panel
*) data
;
1003 TextureListItem
*titem
;
1005 /* Parameter not used, but tell the compiler that it is ok */
1008 item
= WMGetListItem(panel
->texLs
, WMGetListSelectedItemRow(panel
->texLs
));
1009 titem
= (TextureListItem
*) item
->clientData
;
1011 SetTexturePanelPixmapPath(panel
->texturePanel
, GetObjectForKey("PixmapPath"));
1013 SetTexturePanelTexture(panel
->texturePanel
, titem
->title
, titem
->prop
);
1015 SetTexturePanelCancelAction(panel
->texturePanel
, cancelNewTexture
, panel
);
1016 SetTexturePanelOkAction(panel
->texturePanel
, okEditTexture
, panel
);
1018 ShowTexturePanel(panel
->texturePanel
);
1021 static void newTexture(WMWidget
* w
, void *data
)
1023 _Panel
*panel
= (_Panel
*) data
;
1025 /* Parameter not used, but tell the compiler that it is ok */
1028 SetTexturePanelPixmapPath(panel
->texturePanel
, GetObjectForKey("PixmapPath"));
1030 SetTexturePanelTexture(panel
->texturePanel
, "New Texture", NULL
);
1032 SetTexturePanelCancelAction(panel
->texturePanel
, cancelNewTexture
, panel
);
1034 SetTexturePanelOkAction(panel
->texturePanel
, okNewTexture
, panel
);
1036 ShowTexturePanel(panel
->texturePanel
);
1039 static void deleteTexture(WMWidget
* w
, void *data
)
1041 _Panel
*panel
= (_Panel
*) data
;
1043 TextureListItem
*titem
;
1047 /* Parameter not used, but tell the compiler that it is ok */
1050 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
1051 row
= WMGetListSelectedItemRow(panel
->texLs
);
1052 item
= WMGetListItem(panel
->texLs
, row
);
1053 titem
= (TextureListItem
*) item
->clientData
;
1055 if (titem
->selectedFor
& (1 << section
)) {
1056 TextureListItem
*titem2
;
1058 panel
->textureIndex
[section
] = section
;
1059 item
= WMGetListItem(panel
->texLs
, section
);
1060 titem2
= (TextureListItem
*) item
->clientData
;
1061 titem2
->selectedFor
|= 1 << section
;
1064 wfree(titem
->title
);
1065 wfree(titem
->texture
);
1066 WMReleasePropList(titem
->prop
);
1068 if (remove(titem
->path
) < 0 && errno
!= ENOENT
) {
1069 werror("could not remove file %s", titem
->path
);
1076 WMRemoveListItem(panel
->texLs
, row
);
1077 WMSetButtonEnabled(panel
->delB
, False
);
1080 static void extractTexture(WMWidget
* w
, void *data
)
1082 _Panel
*panel
= (_Panel
*) data
;
1084 WMOpenPanel
*opanel
;
1085 WMScreen
*scr
= WMWidgetScreen(w
);
1087 opanel
= WMGetOpenPanel(scr
);
1088 WMSetFilePanelCanChooseDirectories(opanel
, False
);
1089 WMSetFilePanelCanChooseFiles(opanel
, True
);
1091 if (WMRunModalFilePanelForDirectory(opanel
, panel
->parent
, wgethomedir(), _("Select File"), NULL
)) {
1092 path
= WMGetFilePanelFileName(opanel
);
1094 OpenExtractPanelFor(panel
);
1100 static void changePage(WMWidget
* w
, void *data
)
1102 _Panel
*panel
= (_Panel
*) data
;
1104 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1105 RContext
*rc
= WMScreenRContext(scr
);
1108 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
1110 WMSelectListItem(panel
->texLs
, panel
->textureIndex
[section
]);
1112 WMSetListPosition(panel
->texLs
, panel
->textureIndex
[section
] - 2);
1117 gc
= XCreateGC(rc
->dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
1118 XCopyArea(rc
->dpy
, panel
->previewBack
, panel
->preview
, gc
,
1119 textureOptions
[panel
->oldsection
].hand
.x
, textureOptions
[panel
->oldsection
].hand
.y
, 22, 22,
1120 textureOptions
[panel
->oldsection
].hand
.x
, textureOptions
[panel
->oldsection
].hand
.y
);
1123 panel
->oldsection
= section
;
1124 WMDrawPixmap(panel
->hand
, panel
->preview
, textureOptions
[section
].hand
.x
, textureOptions
[section
].hand
.y
);
1126 WMRedisplayWidget(panel
->prevL
);
1129 static void previewClick(XEvent
* event
, void *clientData
)
1131 _Panel
*panel
= (_Panel
*) clientData
;
1134 switch (panel
->oldTabItem
) {
1136 for (i
= 0; i
< wlengthof(textureOptions
); i
++) {
1137 if (event
->xbutton
.x
>= textureOptions
[i
].preview
.pos
.x
&&
1138 event
->xbutton
.y
>= textureOptions
[i
].preview
.pos
.y
&&
1139 event
->xbutton
.x
< textureOptions
[i
].preview
.pos
.x
+ textureOptions
[i
].preview
.size
.width
&&
1140 event
->xbutton
.y
< textureOptions
[i
].preview
.pos
.y
+ textureOptions
[i
].preview
.size
.height
) {
1142 WMSetPopUpButtonSelectedItem(panel
->secP
, i
);
1143 changePage(panel
->secP
, panel
);
1149 for (i
= 0; i
< WMGetPopUpButtonNumberOfItems(panel
->colP
); i
++) {
1150 if (event
->xbutton
.x
>= colorOptions
[i
].preview
.pos
.x
&&
1151 event
->xbutton
.y
>= colorOptions
[i
].preview
.pos
.y
&&
1152 event
->xbutton
.x
< colorOptions
[i
].preview
.pos
.x
+ colorOptions
[i
].preview
.size
.width
&&
1153 event
->xbutton
.y
< colorOptions
[i
].preview
.pos
.y
+ colorOptions
[i
].preview
.size
.height
) {
1156 * yuck kluge: the entry #7 is HighlightTextColor which does not have actually a
1157 * display area, but are reused to make the last "Normal Item" menu entry actually
1158 * pick the same color item as the other similar item displayed, which corresponds
1164 WMSetPopUpButtonSelectedItem(panel
->colP
, i
);
1165 changeColorPage(panel
->colP
, panel
);
1173 static void textureClick(WMWidget
* w
, void *data
)
1175 _Panel
*panel
= (_Panel
*) data
;
1178 TextureListItem
*titem
;
1180 /* Parameter not used, but tell the compiler that it is ok */
1183 i
= WMGetListSelectedItemRow(panel
->texLs
);
1185 item
= WMGetListItem(panel
->texLs
, i
);
1187 titem
= (TextureListItem
*) item
->clientData
;
1189 if (titem
->current
) {
1190 WMSetButtonEnabled(panel
->delB
, False
);
1192 WMSetButtonEnabled(panel
->delB
, True
);
1196 static void textureDoubleClick(WMWidget
* w
, void *data
)
1198 _Panel
*panel
= (_Panel
*) data
;
1201 TextureListItem
*titem
;
1203 /* Parameter not used, but tell the compiler that it is ok */
1206 /* unselect old texture */
1207 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
1209 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[section
]);
1210 titem
= (TextureListItem
*) item
->clientData
;
1211 titem
->selectedFor
&= ~(1 << section
);
1213 /* select new texture */
1214 i
= WMGetListSelectedItemRow(panel
->texLs
);
1216 item
= WMGetListItem(panel
->texLs
, i
);
1218 titem
= (TextureListItem
*) item
->clientData
;
1220 titem
->selectedFor
|= 1 << section
;
1222 panel
->textureIndex
[section
] = i
;
1224 WMRedisplayWidget(panel
->texLs
);
1226 if (section
== PBACKGROUND
)
1227 updatePreviewBox(panel
, EVERYTHING
);
1229 updatePreviewBox(panel
, 1 << section
);
1232 static void paintListItem(WMList
* lPtr
, int index
, Drawable d
, char *text
, int state
, WMRect
* rect
)
1234 _Panel
*panel
= (_Panel
*) WMGetHangedData(lPtr
);
1235 WMScreen
*scr
= WMWidgetScreen(lPtr
);
1236 int width
, height
, x
, y
;
1237 Display
*dpy
= WMScreenDisplay(scr
);
1238 WMColor
*back
= (state
& WLDSSelected
) ? WMWhiteColor(scr
) : WMGrayColor(scr
);
1240 WMColor
*black
= WMBlackColor(scr
);
1241 TextureListItem
*titem
;
1243 /* Parameter not used, but tell the compiler that it is ok */
1246 item
= WMGetListItem(lPtr
, index
);
1247 titem
= (TextureListItem
*) item
->clientData
;
1249 WMReleaseColor(back
);
1250 WMReleaseColor(black
);
1254 width
= rect
->size
.width
;
1255 height
= rect
->size
.height
;
1259 XFillRectangle(dpy
, d
, WMColorGC(back
), x
, y
, width
, height
);
1262 XCopyArea(dpy
, titem
->preview
, d
, WMColorGC(black
), 0, 0,
1263 TEXPREV_WIDTH
, TEXPREV_HEIGHT
, x
+ 5, y
+ 5);
1265 if ((1 << WMGetPopUpButtonSelectedItem(panel
->secP
)) & titem
->selectedFor
)
1266 WMDrawPixmap(panel
->onLed
, d
, x
+ TEXPREV_WIDTH
+ 10, y
+ 6);
1267 else if (titem
->selectedFor
)
1268 WMDrawPixmap(panel
->offLed
, d
, x
+ TEXPREV_WIDTH
+ 10, y
+ 6);
1270 WMDrawString(scr
, d
, black
, panel
->boldFont
,
1271 x
+ TEXPREV_WIDTH
+ 22, y
+ 2, titem
->title
, strlen(titem
->title
));
1273 WMDrawString(scr
, d
, black
, panel
->smallFont
,
1274 x
+ TEXPREV_WIDTH
+ 14, y
+ 18, titem
->texture
, strlen(titem
->texture
));
1276 WMReleaseColor(back
);
1277 WMReleaseColor(black
);
1280 static Pixmap
loadRImage(WMScreen
* scr
, const char *path
)
1288 f
= fopen(path
, "rb");
1292 cnt
= fscanf(f
, "%02x%02x%1x", &w
, &h
, &d
);
1297 image
= RCreateImage(w
, h
, d
== 4);
1298 read_size
= w
* h
* d
;
1299 if (fread(image
->data
, 1, read_size
, f
) == read_size
)
1300 RConvertImage(WMScreenRContext(scr
), image
, &pixmap
);
1306 RReleaseImage(image
);
1311 static void fillTextureList(WMList
* lPtr
)
1313 WMPropList
*textureList
;
1314 WMPropList
*texture
;
1315 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
1316 TextureListItem
*titem
;
1317 WMScreen
*scr
= WMWidgetScreen(lPtr
);
1320 textureList
= WMGetUDObjectForKey(udb
, "TextureList");
1324 for (i
= 0; i
< WMGetPropListItemCount(textureList
); i
++) {
1327 texture
= WMGetFromPLArray(textureList
, i
);
1329 titem
= wmalloc(sizeof(TextureListItem
));
1331 titem
->title
= wstrdup(WMGetFromPLString(WMGetFromPLArray(texture
, 0)));
1332 titem
->prop
= WMRetainPropList(WMGetFromPLArray(texture
, 1));
1333 titem
->texture
= WMGetPropListDescription(titem
->prop
, False
);
1334 titem
->selectedFor
= 0;
1335 titem
->path
= wstrdup(WMGetFromPLString(WMGetFromPLArray(texture
, 2)));
1337 titem
->preview
= loadRImage(scr
, titem
->path
);
1338 if (!titem
->preview
) {
1339 titem
->preview
= renderTexture(scr
, titem
->prop
, TEXPREV_WIDTH
, TEXPREV_HEIGHT
, NULL
, 0);
1341 item
= WMAddListItem(lPtr
, "");
1342 item
->clientData
= titem
;
1346 static void fillColorList(_Panel
* panel
)
1350 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
1351 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1354 list
= WMGetUDObjectForKey(udb
, "ColorList");
1356 for (i
= 0; i
< 24; i
++) {
1357 color
= WMCreateNamedColor(scr
, sampleColors
[i
], False
);
1360 WMSetColorWellColor(panel
->sampW
[i
], color
);
1361 WMReleaseColor(color
);
1366 for (i
= 0; i
< WMIN(24, WMGetPropListItemCount(list
)); i
++) {
1367 c
= WMGetFromPLArray(list
, i
);
1368 if (!c
|| !WMIsPLString(c
))
1370 color
= WMCreateNamedColor(scr
, WMGetFromPLString(c
), False
);
1373 WMSetColorWellColor(panel
->sampW
[i
], color
);
1374 WMReleaseColor(color
);
1379 /*************************************************************************/
1381 static void changeColorPage(WMWidget
* w
, void *data
)
1383 _Panel
*panel
= (_Panel
*) data
;
1385 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1386 RContext
*rc
= WMScreenRContext(scr
);
1388 if (panel
->preview
) {
1391 gc
= XCreateGC(rc
->dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
1392 XCopyArea(rc
->dpy
, panel
->previewBack
, panel
->preview
, gc
,
1393 colorOptions
[panel
->oldcsection
].hand
.x
,
1394 colorOptions
[panel
->oldcsection
].hand
.y
, 22, 22 ,
1395 colorOptions
[panel
->oldcsection
].hand
.x
,
1396 colorOptions
[panel
->oldcsection
].hand
.y
);
1399 section
= WMGetPopUpButtonSelectedItem(panel
->colP
);
1401 panel
->oldcsection
= section
;
1403 WMDrawPixmap(panel
->hand
, panel
->preview
,
1404 colorOptions
[section
].hand
.x
, colorOptions
[section
].hand
.y
);
1406 if (section
>= ICONT_COL
)
1407 updateColorPreviewBox(panel
, 1 << section
);
1409 WMSetColorWellColor(panel
->colW
, panel
->colors
[section
]);
1411 WMRedisplayWidget(panel
->prevL
);
1415 paintText(WMScreen
* scr
, Drawable d
, WMColor
* color
, WMFont
* font
,
1416 int x
, int y
, int w
, int h
, WMAlignment align
, char *text
)
1418 int l
= strlen(text
);
1425 x
+= w
- 5 - WMWidthOfString(font
, text
, l
);
1429 x
+= (w
- WMWidthOfString(font
, text
, l
)) / 2;
1432 WMDrawString(scr
, d
, color
, font
, x
, y
+ (h
- WMFontHeight(font
)) / 2, text
, l
);
1435 static void updateColorPreviewBox(_Panel
* panel
, int elements
)
1437 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1438 Display
*dpy
= WMScreenDisplay(scr
);
1443 pnot
= panel
->previewNoText
;
1444 gc
= WMColorGC(panel
->colors
[FTITLE_COL
]);
1446 if (elements
& (1 << FTITLE_COL
)) {
1447 XCopyArea(dpy
, pnot
, d
, gc
, 30, 10, 190, 20, 30, 10);
1448 paintText(scr
, d
, panel
->colors
[FTITLE_COL
],
1449 panel
->boldFont
, 30, 10, 190, 20,
1450 panel
->titleAlignment
, _("Focused Window"));
1452 if (elements
& (1 << UTITLE_COL
)) {
1453 XCopyArea(dpy
, pnot
, d
, gc
, 30, 40, 190, 20, 30, 40);
1454 paintText(scr
, d
, panel
->colors
[UTITLE_COL
],
1455 panel
->boldFont
, 30, 40, 190, 20,
1456 panel
->titleAlignment
,
1457 _("Unfocused Window"));
1459 if (elements
& (1 << OTITLE_COL
)) {
1460 XCopyArea(dpy
, pnot
, d
, gc
, 30, 70, 190, 20, 30, 70);
1461 paintText(scr
, d
, panel
->colors
[OTITLE_COL
],
1462 panel
->boldFont
, 30, 70, 190, 20,
1463 panel
->titleAlignment
,
1464 _("Owner of Focused Window"));
1466 if (elements
& (1 << MTITLE_COL
)) {
1467 XCopyArea(dpy
, pnot
, d
, gc
, 30, 120, 90, 20, 30, 120);
1468 paintText(scr
, d
, panel
->colors
[MTITLE_COL
],
1469 panel
->boldFont
, 30, 120, 90, 20, WALeft
,
1472 if (elements
& (1 << MITEM_COL
)) {
1473 XCopyArea(dpy
, pnot
, d
, gc
, 30, 140, 90, 20, 30, 140);
1474 paintText(scr
, d
, panel
->colors
[MITEM_COL
],
1475 panel
->normalFont
, 30, 140, 90, 20, WALeft
,
1477 XCopyArea(dpy
, pnot
, d
, gc
, 30, 200, 90, 20, 30, 200);
1478 paintText(scr
, d
, panel
->colors
[MITEM_COL
],
1479 panel
->normalFont
, 30, 200, 90, 20, WALeft
,
1482 if (elements
& (1 << MDISAB_COL
)) {
1483 XCopyArea(dpy
, pnot
, d
, gc
, 30, 160, 90, 20, 30, 160);
1484 paintText(scr
, d
, panel
->colors
[MDISAB_COL
],
1485 panel
->normalFont
, 30, 160, 90, 20, WALeft
,
1486 _("Disabled Item"));
1488 if (elements
& (1 << MHIGH_COL
)) {
1489 XFillRectangle(WMScreenDisplay(scr
), d
,
1490 WMColorGC(panel
->colors
[MHIGH_COL
]),
1492 XFillRectangle(WMScreenDisplay(scr
), pnot
,
1493 WMColorGC(panel
->colors
[MHIGH_COL
]),
1495 elements
|= 1 << MHIGHT_COL
;
1497 if (elements
& (1 << MHIGHT_COL
)) {
1498 XCopyArea(dpy
, pnot
, d
, gc
, 30, 180, 90, 20, 30, 180);
1499 paintText(scr
, d
, panel
->colors
[MHIGHT_COL
],
1500 panel
->normalFont
, 30, 180, 90, 20, WALeft
,
1503 if (elements
& (1 << FBORDER_COL
)) {
1504 XDrawRectangle(dpy
, pnot
,
1505 WMColorGC(panel
->colors
[FBORDER_COL
]),
1507 XDrawRectangle(dpy
, d
,
1508 WMColorGC(panel
->colors
[FBORDER_COL
]),
1510 XDrawRectangle(dpy
, pnot
,
1511 WMColorGC(panel
->colors
[FBORDER_COL
]),
1513 XDrawRectangle(dpy
, d
,
1514 WMColorGC(panel
->colors
[FBORDER_COL
]),
1516 XDrawLine(dpy
, pnot
,
1517 WMColorGC(panel
->colors
[FBORDER_COL
]),
1520 WMColorGC(panel
->colors
[FBORDER_COL
]),
1522 XDrawLine(dpy
, pnot
,
1523 WMColorGC(panel
->colors
[FBORDER_COL
]),
1526 WMColorGC(panel
->colors
[FBORDER_COL
]),
1528 XDrawLine(dpy
, pnot
,
1529 WMColorGC(panel
->colors
[FBORDER_COL
]),
1530 220, 100, 220, 109);
1532 WMColorGC(panel
->colors
[FBORDER_COL
]),
1533 220, 100, 220, 109);
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 119, 120, 119, 220);
1550 WMColorGC(panel
->colors
[FBORDER_COL
]),
1551 119, 120, 119, 220);
1554 if (elements
& (1 << FFBORDER_COL
)) {
1555 XDrawRectangle(dpy
, pnot
,
1556 WMColorGC(panel
->colors
[FFBORDER_COL
]),
1558 XDrawRectangle(dpy
, d
,
1559 WMColorGC(panel
->colors
[FFBORDER_COL
]),
1563 if (elements
& (1 << ICONT_COL
) || elements
& (1 << ICONB_COL
)) {
1565 RHSVColor hsv
, hsv2
;
1567 WMColor
*light
, *dim
;
1569 updatePreviewBox(panel
, 1 << PICON
);
1571 rgb
.red
= WMRedComponentOfColor(panel
->colors
[ICONB_COL
]) >> 8;
1572 rgb
.green
= WMGreenComponentOfColor(panel
->colors
[ICONB_COL
]) >> 8;
1573 rgb
.blue
= WMBlueComponentOfColor(panel
->colors
[ICONB_COL
]) >> 8;
1574 RRGBtoHSV(&rgb
, &hsv
);
1575 RHSVtoRGB(&hsv
, &rgb
);
1578 v
= hsv
.value
* 16 / 10;
1579 hsv
.value
= (v
> 255 ? 255 : v
);
1580 RHSVtoRGB(&hsv
, &rgb
);
1581 light
= WMCreateRGBColor(scr
, rgb
.red
<< 8, rgb
.green
<< 8, rgb
.blue
<< 8, False
);
1583 hsv2
.value
= hsv2
.value
/ 2;
1584 RHSVtoRGB(&hsv2
, &rgb
);
1585 dim
= WMCreateRGBColor(scr
, rgb
.red
<< 8, rgb
.green
<< 8, rgb
.blue
<< 8, False
);
1587 XFillRectangle(dpy
, d
, WMColorGC(panel
->colors
[ICONB_COL
]), 156, 131, 62, 11);
1588 XDrawLine(dpy
, d
, WMColorGC(light
), 155, 130, 155, 142);
1589 XDrawLine(dpy
, d
, WMColorGC(light
), 156, 130, 217, 130);
1590 XDrawLine(dpy
, d
, WMColorGC(dim
), 218, 130, 218, 142);
1592 paintText(scr
, d
, panel
->colors
[ICONT_COL
],
1593 panel
->smallFont
, 155, 130, 64, 13, WALeft
,
1598 if (elements
& (1 << CLIP_COL
) || elements
& (1 << CCLIP_COL
)) {
1604 TextureListItem
*titem
;
1608 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[PICON
]);
1609 titem
= (TextureListItem
*) item
->clientData
;
1611 pix
= renderTexture(scr
, titem
->prop
, 64, 64, NULL
, titem
->ispixmap
? 0 : RBEV_RAISED3
);
1612 tile
= RCreateImageFromDrawable(WMScreenRContext(scr
), pix
, None
);
1615 black
.red
= black
.green
= black
.blue
= 0;
1618 dark
.red
= dark
.green
= dark
.blue
= 60;
1621 light
.red
= light
.green
= light
.blue
= 80;
1624 ROperateLine(tile
, RSubtractOperation
, 64 - 1 - 23, 0, 64 - 2, 23 - 1, &dark
);
1625 RDrawLine(tile
, 64 - 1 - 23 - 1, 0, 64 - 1, 23 + 1, &black
);
1626 ROperateLine(tile
, RAddOperation
, 64 - 1 - 23, 2, 64 - 3, 23, &light
);
1629 ROperateLine(tile
, RSubtractOperation
, 64 - 7 - (23 - 15), 4, 64 - 5, 4, &dark
);
1630 ROperateLine(tile
, RSubtractOperation
, 64 - 6 - (23 - 15), 5, 64 - 5, 6 + 23 - 15, &dark
);
1631 ROperateLine(tile
, RAddOperation
, 64 - 5, 4, 64 - 5, 6 + 23 - 15, &light
);
1634 ROperateLine(tile
, RAddOperation
, 2, 64 - 1 - 23 + 2, 23 - 2, 64 - 3, &dark
);
1635 RDrawLine(tile
, 0, 64 - 1 - 23 - 1, 23 + 1, 64 - 1, &black
);
1636 ROperateLine(tile
, RSubtractOperation
, 0, 64 - 1 - 23 - 2, 23 + 1, 64 - 2, &light
);
1639 ROperateLine(tile
, RSubtractOperation
, 4, 64 - 7 - (23 - 15), 4, 64 - 5, &dark
);
1640 ROperateLine(tile
, RSubtractOperation
, 5, 64 - 6 - (23 - 15), 6 + 23 - 15, 64 - 5, &dark
);
1641 ROperateLine(tile
, RAddOperation
, 4, 64 - 5, 6 + 23 - 15, 64 - 5, &light
);
1643 RConvertImage(WMScreenRContext(scr
), tile
, &pix
);
1644 RReleaseImage(tile
);
1646 XCopyArea(dpy
, pix
, d
, gc
, 0, 0, 64, 64, 155, 130);
1647 XFreePixmap(dpy
, pix
);
1649 /* top right arrow */
1650 p
[0].x
= p
[3].x
= 155 + 64 - 5 - (23 - 15);
1651 p
[0].y
= p
[3].y
= 130 + 5;
1652 p
[1].x
= 155 + 64 - 6;
1654 p
[2].x
= 155 + 64 - 6;
1655 p
[2].y
= 130 + 4 + 23 - 15;
1657 XFillPolygon(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 3, Convex
, CoordModeOrigin
);
1658 XDrawLines(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 4, CoordModeOrigin
);
1660 /* bottom left arrow */
1661 p
[0].x
= p
[3].x
= 155 + 5;
1662 p
[0].y
= p
[3].y
= 130 + 64 - 5 - (23 - 15);
1664 p
[1].y
= 130 + 64 - 6;
1665 p
[2].x
= 155 + 4 + 23 - 15;
1666 p
[2].y
= 130 + 64 - 6;
1668 XFillPolygon(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 3, Convex
, CoordModeOrigin
);
1669 XDrawLines(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 4, CoordModeOrigin
);
1673 if (elements
& (1 << CLIP_COL
))
1674 paintText(scr
, d
, panel
->colors
[CLIP_COL
],
1675 panel
->boldFont
, 155 + 23, 130 + 64 - 15 - 3, 22, 15, WALeft
,
1678 if (elements
& (1 << CCLIP_COL
)) {
1679 paintText(scr
, d
, panel
->colors
[CCLIP_COL
],
1680 panel
->boldFont
, 155+2, 130 + 2, 26, 15, WALeft
, _("Coll."));
1681 paintText(scr
, d
, panel
->colors
[CCLIP_COL
],
1682 panel
->boldFont
, 155 + 23, 130 + 64 - 15 - 3, 22, 15, WALeft
,
1686 WMRedisplayWidget(panel
->prevL
);
1689 static void colorWellObserver(void *self
, WMNotification
* n
)
1691 _Panel
*panel
= (_Panel
*) self
;
1694 /* Parameter not used, but tell the compiler that it is ok */
1697 p
= WMGetPopUpButtonSelectedItem(panel
->colP
);
1699 WMReleaseColor(panel
->colors
[p
]);
1701 panel
->colors
[p
] = WMRetainColor(WMGetColorWellColor(panel
->colW
));
1703 updateColorPreviewBox(panel
, 1 << p
);
1706 static void changedTabItem(struct WMTabViewDelegate
*self
, WMTabView
* tabView
, WMTabViewItem
* item
)
1708 _Panel
*panel
= self
->data
;
1711 /* Parameter not used, but tell the compiler that it is ok */
1714 i
= WMGetTabViewItemIdentifier(item
);
1717 switch (panel
->oldTabItem
) {
1719 changeColorPage(NULL
, panel
);
1722 changePage(panel
->secP
, panel
);
1725 switch (panel
->oldTabItem
) {
1727 changePage(NULL
, panel
);
1730 changeColorPage(panel
->colP
, panel
);
1733 switch (panel
->oldTabItem
) {
1735 changePage(NULL
, panel
);
1738 changeColorPage(NULL
, panel
);
1744 panel
->oldTabItem
= i
;
1747 /*************************************************************************/
1749 static void menuStyleCallback(WMWidget
* self
, void *data
)
1751 _Panel
*panel
= (_Panel
*) data
;
1753 if (self
== panel
->mstyB
[0]) {
1754 panel
->menuStyle
= MSTYLE_NORMAL
;
1755 updatePreviewBox(panel
, 1 << PMITEM
);
1757 } else if (self
== panel
->mstyB
[1]) {
1758 panel
->menuStyle
= MSTYLE_SINGLE
;
1759 updatePreviewBox(panel
, 1 << PMITEM
);
1761 } else if (self
== panel
->mstyB
[2]) {
1762 panel
->menuStyle
= MSTYLE_FLAT
;
1763 updatePreviewBox(panel
, 1 << PMITEM
);
1767 static void titleAlignCallback(WMWidget
* self
, void *data
)
1769 _Panel
*panel
= (_Panel
*) data
;
1771 if (self
== panel
->taliB
[0]) {
1772 panel
->titleAlignment
= WALeft
;
1773 updatePreviewBox(panel
, 1 << PFOCUSED
| 1 << PUNFOCUSED
| 1 << POWNER
);
1775 } else if (self
== panel
->taliB
[1]) {
1776 panel
->titleAlignment
= WACenter
;
1777 updatePreviewBox(panel
, 1 << PFOCUSED
| 1 << PUNFOCUSED
| 1 << POWNER
);
1779 } else if (self
== panel
->taliB
[2]) {
1780 panel
->titleAlignment
= WARight
;
1781 updatePreviewBox(panel
, 1 << PFOCUSED
| 1 << PUNFOCUSED
| 1 << POWNER
);
1785 static void createPanel(Panel
* p
)
1787 _Panel
*panel
= (_Panel
*) p
;
1789 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
1790 WMTabViewItem
*item
;
1795 panel
->fprefix
= wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
1797 if (access(panel
->fprefix
, F_OK
) != 0) {
1798 if (mkdir(panel
->fprefix
, 0755) < 0) {
1799 werror("%s", panel
->fprefix
);
1804 tmp
= wstrconcat(panel
->fprefix
, "/WPrefs/");
1805 wfree(panel
->fprefix
);
1806 panel
->fprefix
= tmp
;
1807 if (access(panel
->fprefix
, F_OK
) != 0) {
1808 if (mkdir(panel
->fprefix
, 0755) < 0) {
1809 werror("%s", panel
->fprefix
);
1814 panel
->smallFont
= WMSystemFontOfSize(scr
, 10);
1815 panel
->normalFont
= WMSystemFontOfSize(scr
, 12);
1816 panel
->boldFont
= WMBoldSystemFontOfSize(scr
, 12);
1818 panel
->onLed
= WMCreatePixmapFromXPMData(scr
, blueled_xpm
);
1819 panel
->offLed
= WMCreatePixmapFromXPMData(scr
, blueled2_xpm
);
1820 panel
->hand
= WMCreatePixmapFromXPMData(scr
, hand_xpm
);
1822 panel
->box
= WMCreateBox(panel
->parent
);
1823 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
1826 panel
->prevL
= WMCreateLabel(panel
->box
);
1827 WMResizeWidget(panel
->prevL
, 240, FRAME_HEIGHT
- 20);
1828 WMMoveWidget(panel
->prevL
, 15, 10);
1829 WMSetLabelRelief(panel
->prevL
, WRSunken
);
1830 WMSetLabelImagePosition(panel
->prevL
, WIPImageOnly
);
1832 WMCreateEventHandler(WMWidgetView(panel
->prevL
), ButtonPressMask
, previewClick
, panel
);
1836 tabviewDelegate
.data
= panel
;
1838 panel
->tabv
= WMCreateTabView(panel
->box
);
1839 WMResizeWidget(panel
->tabv
, 245, FRAME_HEIGHT
- 20);
1840 WMMoveWidget(panel
->tabv
, 265, 10);
1841 WMSetTabViewDelegate(panel
->tabv
, &tabviewDelegate
);
1843 /*** texture list ***/
1845 panel
->texF
= WMCreateFrame(panel
->box
);
1846 WMSetFrameRelief(panel
->texF
, WRFlat
);
1848 item
= WMCreateTabViewItemWithIdentifier(TAB_TEXTURE
);
1849 WMSetTabViewItemView(item
, WMWidgetView(panel
->texF
));
1850 WMSetTabViewItemLabel(item
, _("Texture"));
1852 WMAddItemInTabView(panel
->tabv
, item
);
1854 panel
->secP
= WMCreatePopUpButton(panel
->texF
);
1855 WMResizeWidget(panel
->secP
, 228, 20);
1856 WMMoveWidget(panel
->secP
, 7, 7);
1858 for (i
= 0; i
< wlengthof(textureOptions
); i
++)
1859 WMAddPopUpButtonItem(panel
->secP
, _(textureOptions
[i
].popup_label
));
1861 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
1862 WMSetPopUpButtonAction(panel
->secP
, changePage
, panel
);
1864 panel
->texLs
= WMCreateList(panel
->texF
);
1865 WMResizeWidget(panel
->texLs
, 165, 155);
1866 WMMoveWidget(panel
->texLs
, 70, 33);
1867 WMSetListUserDrawItemHeight(panel
->texLs
, 35);
1868 WMSetListUserDrawProc(panel
->texLs
, paintListItem
);
1869 WMHangData(panel
->texLs
, panel
);
1870 WMSetListAction(panel
->texLs
, textureClick
, panel
);
1871 WMSetListDoubleAction(panel
->texLs
, textureDoubleClick
, panel
);
1873 WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
1874 "for the selected item."), WMWidgetView(panel
->texLs
));
1876 /* command buttons */
1878 font
= WMSystemFontOfSize(scr
, 10);
1880 panel
->newB
= WMCreateCommandButton(panel
->texF
);
1881 WMResizeWidget(panel
->newB
, 57, 39);
1882 WMMoveWidget(panel
->newB
, 7, 33);
1883 WMSetButtonFont(panel
->newB
, font
);
1884 WMSetButtonImagePosition(panel
->newB
, WIPAbove
);
1885 WMSetButtonText(panel
->newB
, _("New"));
1886 WMSetButtonAction(panel
->newB
, newTexture
, panel
);
1887 SetButtonAlphaImage(scr
, panel
->newB
, TNEW_FILE
);
1889 WMSetBalloonTextForView(_("Create a new texture."), WMWidgetView(panel
->newB
));
1891 panel
->ripB
= WMCreateCommandButton(panel
->texF
);
1892 WMResizeWidget(panel
->ripB
, 57, 39);
1893 WMMoveWidget(panel
->ripB
, 7, 72);
1894 WMSetButtonFont(panel
->ripB
, font
);
1895 WMSetButtonImagePosition(panel
->ripB
, WIPAbove
);
1896 WMSetButtonText(panel
->ripB
, _("Extract..."));
1897 WMSetButtonAction(panel
->ripB
, extractTexture
, panel
);
1898 SetButtonAlphaImage(scr
, panel
->ripB
, TEXTR_FILE
);
1900 WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."), WMWidgetView(panel
->ripB
));
1902 WMSetButtonEnabled(panel
->ripB
, False
);
1904 panel
->editB
= WMCreateCommandButton(panel
->texF
);
1905 WMResizeWidget(panel
->editB
, 57, 39);
1906 WMMoveWidget(panel
->editB
, 7, 111);
1907 WMSetButtonFont(panel
->editB
, font
);
1908 WMSetButtonImagePosition(panel
->editB
, WIPAbove
);
1909 WMSetButtonText(panel
->editB
, _("Edit"));
1910 SetButtonAlphaImage(scr
, panel
->editB
, TEDIT_FILE
);
1911 WMSetButtonAction(panel
->editB
, editTexture
, panel
);
1912 WMSetBalloonTextForView(_("Edit the highlighted texture."), WMWidgetView(panel
->editB
));
1914 panel
->delB
= WMCreateCommandButton(panel
->texF
);
1915 WMResizeWidget(panel
->delB
, 57, 38);
1916 WMMoveWidget(panel
->delB
, 7, 150);
1917 WMSetButtonFont(panel
->delB
, font
);
1918 WMSetButtonImagePosition(panel
->delB
, WIPAbove
);
1919 WMSetButtonText(panel
->delB
, _("Delete"));
1920 SetButtonAlphaImage(scr
, panel
->delB
, TDEL_FILE
);
1921 WMSetButtonEnabled(panel
->delB
, False
);
1922 WMSetButtonAction(panel
->delB
, deleteTexture
, panel
);
1923 WMSetBalloonTextForView(_("Delete the highlighted texture."), WMWidgetView(panel
->delB
));
1925 WMReleaseFont(font
);
1927 WMMapSubwidgets(panel
->texF
);
1930 panel
->colF
= WMCreateFrame(panel
->box
);
1931 WMSetFrameRelief(panel
->colF
, WRFlat
);
1933 item
= WMCreateTabViewItemWithIdentifier(TAB_COLOR
);
1934 WMSetTabViewItemView(item
, WMWidgetView(panel
->colF
));
1935 WMSetTabViewItemLabel(item
, _("Color"));
1937 WMAddItemInTabView(panel
->tabv
, item
);
1939 panel
->colP
= WMCreatePopUpButton(panel
->colF
);
1940 WMResizeWidget(panel
->colP
, 228, 20);
1941 WMMoveWidget(panel
->colP
, 7, 7);
1943 for (i
= 0; i
< wlengthof(colorOptions
); i
++)
1944 WMAddPopUpButtonItem(panel
->colP
, _(colorOptions
[i
].label
));
1946 WMSetPopUpButtonSelectedItem(panel
->colP
, 0);
1948 WMSetPopUpButtonAction(panel
->colP
, changeColorPage
, panel
);
1950 panel
->colW
= WMCreateColorWell(panel
->colF
);
1951 WMResizeWidget(panel
->colW
, 65, 50);
1952 WMMoveWidget(panel
->colW
, 30, 75);
1953 WMAddNotificationObserver(colorWellObserver
, panel
, WMColorWellDidChangeNotification
, panel
->colW
);
1955 for (i
= 0; i
< 4; i
++) {
1957 for (j
= 0; j
< 6; j
++) {
1958 panel
->sampW
[i
+ j
* 4] = WMCreateColorWell(panel
->colF
);
1959 WMResizeWidget(panel
->sampW
[i
+ j
* 4], 22, 22);
1960 WMMoveWidget(panel
->sampW
[i
+ j
* 4], 130 + i
* 22, 40 + j
* 22);
1961 WSetColorWellBordered(panel
->sampW
[i
+ j
* 4], False
);
1965 WMMapSubwidgets(panel
->colF
);
1968 panel
->optF
= WMCreateFrame(panel
->box
);
1969 WMSetFrameRelief(panel
->optF
, WRFlat
);
1971 item
= WMCreateTabViewItemWithIdentifier(TAB_OPTIONS
);
1972 WMSetTabViewItemView(item
, WMWidgetView(panel
->optF
));
1973 WMSetTabViewItemLabel(item
, _("Options"));
1975 WMAddItemInTabView(panel
->tabv
, item
);
1977 panel
->mstyF
= WMCreateFrame(panel
->optF
);
1978 WMResizeWidget(panel
->mstyF
, 215, 85);
1979 WMMoveWidget(panel
->mstyF
, 15, 10);
1980 WMSetFrameTitle(panel
->mstyF
, _("Menu Style"));
1982 for (i
= 0; i
< 3; i
++) {
1986 panel
->mstyB
[i
] = WMCreateButton(panel
->mstyF
, WBTOnOff
);
1987 WMResizeWidget(panel
->mstyB
[i
], 54, 54);
1988 WMMoveWidget(panel
->mstyB
[i
], 15 + i
* 65, 20);
1989 WMSetButtonImagePosition(panel
->mstyB
[i
], WIPImageOnly
);
1990 WMSetButtonAction(panel
->mstyB
[i
], menuStyleCallback
, panel
);
1993 path
= LocateImage(MSTYLE1_FILE
);
1996 path
= LocateImage(MSTYLE2_FILE
);
1999 path
= LocateImage(MSTYLE3_FILE
);
2003 icon
= WMCreatePixmapFromFile(scr
, path
);
2005 WMSetButtonImage(panel
->mstyB
[i
], icon
);
2006 WMReleasePixmap(icon
);
2008 wwarning(_("could not load icon file %s"), path
);
2013 WMGroupButtons(panel
->mstyB
[0], panel
->mstyB
[1]);
2014 WMGroupButtons(panel
->mstyB
[0], panel
->mstyB
[2]);
2016 WMMapSubwidgets(panel
->mstyF
);
2018 panel
->taliF
= WMCreateFrame(panel
->optF
);
2019 WMResizeWidget(panel
->taliF
, 110, 80);
2020 WMMoveWidget(panel
->taliF
, 15, 100);
2021 WMSetFrameTitle(panel
->taliF
, _("Title Alignment"));
2023 for (i
= 0; i
< 3; i
++) {
2024 panel
->taliB
[i
] = WMCreateRadioButton(panel
->taliF
);
2025 WMSetButtonAction(panel
->taliB
[i
], titleAlignCallback
, panel
);
2028 WMSetButtonText(panel
->taliB
[i
], _("Left"));
2031 WMSetButtonText(panel
->taliB
[i
], _("Center"));
2034 WMSetButtonText(panel
->taliB
[i
], _("Right"));
2037 WMResizeWidget(panel
->taliB
[i
], 90, 18);
2038 WMMoveWidget(panel
->taliB
[i
], 10, 15 + 20 * i
);
2040 WMGroupButtons(panel
->taliB
[0], panel
->taliB
[1]);
2041 WMGroupButtons(panel
->taliB
[0], panel
->taliB
[2]);
2043 WMMapSubwidgets(panel
->taliF
);
2045 WMMapSubwidgets(panel
->optF
);
2047 /**/ WMRealizeWidget(panel
->box
);
2048 WMMapSubwidgets(panel
->box
);
2050 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
2054 changePage(panel
->secP
, panel
);
2056 fillTextureList(panel
->texLs
);
2058 fillColorList(panel
);
2060 panel
->texturePanel
= CreateTexturePanel(panel
->parent
);
2063 static void setupTextureFor(WMList
*list
, const char *key
, const char *defValue
, const char *title
, int index
)
2066 TextureListItem
*titem
;
2068 titem
= wmalloc(sizeof(TextureListItem
));
2070 titem
->title
= wstrdup(title
);
2071 titem
->prop
= GetObjectForKey(key
);
2072 if (!titem
->prop
|| !WMIsPLArray(titem
->prop
)) {
2073 /* Maybe also give a error message to stderr that the entry is bad? */
2074 titem
->prop
= WMCreatePropListFromDescription(defValue
);
2076 WMRetainPropList(titem
->prop
);
2078 titem
->texture
= WMGetPropListDescription((WMPropList
*) titem
->prop
, False
);
2080 titem
->selectedFor
= 1 << index
;
2082 titem
->ispixmap
= isPixmap(titem
->prop
);
2084 titem
->preview
= renderTexture(WMWidgetScreen(list
), titem
->prop
, TEXPREV_WIDTH
, TEXPREV_HEIGHT
, NULL
, 0);
2086 item
= WMAddListItem(list
, "");
2087 item
->clientData
= titem
;
2090 static void showData(_Panel
* panel
)
2095 str
= GetStringForKey("MenuStyle");
2096 if (str
&& strcasecmp(str
, "flat") == 0) {
2097 panel
->menuStyle
= MSTYLE_FLAT
;
2098 } else if (str
&& strcasecmp(str
, "singletexture") == 0) {
2099 panel
->menuStyle
= MSTYLE_SINGLE
;
2101 panel
->menuStyle
= MSTYLE_NORMAL
;
2104 str
= GetStringForKey("TitleJustify");
2105 if (str
&& strcasecmp(str
, "left") == 0) {
2106 panel
->titleAlignment
= WALeft
;
2107 } else if (str
&& strcasecmp(str
, "right") == 0) {
2108 panel
->titleAlignment
= WARight
;
2110 panel
->titleAlignment
= WACenter
;
2113 for (i
= 0; i
< wlengthof(colorOptions
); i
++) {
2116 str
= GetStringForKey(colorOptions
[i
].key
);
2118 str
= colorOptions
[i
].default_value
;
2120 if (!(color
= WMCreateNamedColor(WMWidgetScreen(panel
->box
), str
, False
))) {
2121 color
= WMCreateNamedColor(WMWidgetScreen(panel
->box
), "#000000", False
);
2124 panel
->colors
[i
] = color
;
2126 changeColorPage(panel
->colP
, panel
);
2128 for (i
= 0; i
< wlengthof(textureOptions
); i
++) {
2129 setupTextureFor(panel
->texLs
, textureOptions
[i
].key
,
2130 textureOptions
[i
].default_value
, _(textureOptions
[i
].texture_label
), i
);
2131 panel
->textureIndex
[i
] = i
;
2133 updatePreviewBox(panel
, EVERYTHING
);
2135 WMSetButtonSelected(panel
->mstyB
[panel
->menuStyle
], True
);
2136 WMSetButtonSelected(panel
->taliB
[panel
->titleAlignment
], True
);
2139 static void storeData(_Panel
* panel
)
2141 TextureListItem
*titem
;
2145 for (i
= 0; i
< wlengthof(textureOptions
); i
++) {
2146 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[i
]);
2147 titem
= (TextureListItem
*) item
->clientData
;
2148 SetObjectForKey(titem
->prop
, textureOptions
[i
].key
);
2151 for (i
= 0; i
< wlengthof(colorOptions
); i
++) {
2154 str
= WMGetColorRGBDescription(panel
->colors
[i
]);
2157 SetStringForKey(str
, colorOptions
[i
].key
);
2162 switch (panel
->menuStyle
) {
2164 SetStringForKey("singletexture", "MenuStyle");
2167 SetStringForKey("flat", "MenuStyle");
2171 SetStringForKey("normal", "MenuStyle");
2174 switch (panel
->titleAlignment
) {
2176 SetStringForKey("left", "TitleJustify");
2179 SetStringForKey("right", "TitleJustify");
2183 SetStringForKey("center", "TitleJustify");
2188 static void prepareForClose(_Panel
* panel
)
2190 WMPropList
*textureList
;
2191 WMPropList
*texture
;
2192 TextureListItem
*titem
;
2194 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
2197 textureList
= WMCreatePLArray(NULL
, NULL
);
2199 /* store list of textures */
2200 for (i
= 8; i
< WMGetListNumberOfRows(panel
->texLs
); i
++) {
2201 item
= WMGetListItem(panel
->texLs
, i
);
2202 titem
= (TextureListItem
*) item
->clientData
;
2204 texture
= WMCreatePLArray(WMCreatePLString(titem
->title
),
2205 WMRetainPropList(titem
->prop
), WMCreatePLString(titem
->path
), NULL
);
2207 WMAddToPLArray(textureList
, texture
);
2210 WMSetUDObjectForKey(udb
, textureList
, "TextureList");
2211 WMReleasePropList(textureList
);
2213 /* store list of colors */
2214 textureList
= WMCreatePLArray(NULL
, NULL
);
2215 for (i
= 0; i
< 24; i
++) {
2219 color
= WMGetColorWellColor(panel
->sampW
[i
]);
2221 str
= WMGetColorRGBDescription(color
);
2222 WMAddToPLArray(textureList
, WMCreatePLString(str
));
2225 WMSetUDObjectForKey(udb
, textureList
, "ColorList");
2226 WMReleasePropList(textureList
);
2228 WMSynchronizeUserDefaults(udb
);
2231 Panel
*InitAppearance(WMWidget
*parent
)
2235 panel
= wmalloc(sizeof(_Panel
));
2237 panel
->sectionName
= _("Appearance Preferences");
2239 panel
->description
= _("Background texture configuration for windows,\n" "menus and icons.");
2241 panel
->parent
= parent
;
2243 panel
->callbacks
.createWidgets
= createPanel
;
2244 panel
->callbacks
.updateDomain
= storeData
;
2245 panel
->callbacks
.prepareForClose
= prepareForClose
;
2247 AddSection(panel
, ICON_FILE
);
2252 /****************************************************************************/
2254 typedef struct ExtractPanel
{
2264 static void OpenExtractPanelFor(_Panel
*panel
)
2266 ExtractPanel
*epanel
;
2269 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
2271 epanel
= wmalloc(sizeof(ExtractPanel
));
2272 epanel
->win
= WMCreatePanelWithStyleForWindow(panel
->parent
, "extract",
2273 WMTitledWindowMask
| WMClosableWindowMask
);
2274 WMResizeWidget(epanel
->win
, 245, 250);
2275 WMSetWindowTitle(epanel
->win
, _("Extract Texture"));
2277 epanel
->label
= WMCreateLabel(epanel
->win
);
2278 WMResizeWidget(epanel
->label
, 225, 18);
2279 WMMoveWidget(epanel
->label
, 10, 10);
2280 WMSetLabelTextAlignment(epanel
->label
, WACenter
);
2281 WMSetLabelRelief(epanel
->label
, WRSunken
);
2283 color
= WMDarkGrayColor(scr
);
2284 WMSetWidgetBackgroundColor(epanel
->label
, color
);
2285 WMReleaseColor(color
);
2287 color
= WMWhiteColor(scr
);
2288 WMSetLabelTextColor(epanel
->label
, color
);
2289 WMReleaseColor(color
);
2291 font
= WMBoldSystemFontOfSize(scr
, 12);
2292 WMSetLabelFont(epanel
->label
, font
);
2293 WMReleaseFont(font
);
2295 WMSetLabelText(epanel
->label
, _("Textures"));
2297 epanel
->list
= WMCreateList(epanel
->win
);
2298 WMResizeWidget(epanel
->list
, 225, 165);
2299 WMMoveWidget(epanel
->list
, 10, 30);
2301 epanel
->closeB
= WMCreateCommandButton(epanel
->win
);
2302 WMResizeWidget(epanel
->closeB
, 74, 24);
2303 WMMoveWidget(epanel
->closeB
, 165, 215);
2304 WMSetButtonText(epanel
->closeB
, _("Close"));
2306 epanel
->extrB
= WMCreateCommandButton(epanel
->win
);
2307 WMResizeWidget(epanel
->extrB
, 74, 24);
2308 WMMoveWidget(epanel
->extrB
, 80, 215);
2309 WMSetButtonText(epanel
->extrB
, _("Extract"));
2311 WMMapSubwidgets(epanel
->win
);
2313 /* take textures from file */
2315 WMRealizeWidget(epanel
->win
);
2317 WMMapWidget(epanel
->win
);