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
;
298 } textureOptions
[] = {
299 { "FTitleBack", "(solid, black)", N_("[Focused]") },
300 { "UTitleBack", "(solid, gray)", N_("[Unfocused]") },
301 { "PTitleBack", "(solid, \"#616161\")", N_("[Owner of Focused]") },
302 { "ResizebarBack", "(solid, gray)", N_("[Resizebar]") },
303 { "MenuTitleBack", "(solid, black)", N_("[Menu Title]") },
304 { "MenuTextBack", "(solid, gray)", N_("[Menu Item]") },
305 { "IconBack", "(solid, gray)", N_("[Icon]") },
306 { "WorkspaceBack", "(solid, black)", N_("[Background]") }
310 RESIZEBAR_BEVEL
= -1,
343 static const struct {
345 const char *default_value
;
347 { "FTitleColor", "white" },
348 { "UTitleColor", "black" },
349 { "PTitleColor", "white" },
350 { "MenuTitleColor", "white" },
351 { "MenuTextColor", "black" },
352 { "MenuDisabledColor", "#616161" },
353 { "HighlightColor", "white" },
354 { "HighlightTextColor", "black" },
355 { "FrameFocusedBorderColor", "black" },
356 { "FrameBorderColor", "black" },
357 { "FrameSelectedBorderColor", "white" },
358 { "IconTitleColor", "white" },
359 { "IconTitleBack", "black" },
360 { "ClipTitleColor", "black" },
361 { "CClipTitleColor", "#454045" }
364 static WMRect previewPositions
[] = {
366 {{30, 10}, {190, 20}},
368 {{30, 40}, {190, 20}},
370 {{30, 70}, {190, 20}},
372 {{30, 100}, {190, 9}},
374 {{30, 120}, {90, 20}},
376 {{30, 140}, {90, 20 * 4}},
378 {{155, 130}, {64, 64}}
381 #define PBACKGROUND 7
382 #define EVERYTHING 0xff
384 static WMRect previewColorPositions
[] = {
385 {{30, 10}, {190, 20}},
386 {{30, 40}, {190, 20}},
387 {{30, 70}, {190, 20}},
388 {{30, 120}, {90, 20}},
389 {{30, 140}, {90, 20}},
390 {{30, 160}, {90, 20}},
391 {{30, 180}, {90, 20}},
392 {{30, 200}, {90, 20}},
396 {{155, 130}, {64, 64}},
397 {{155, 130}, {64, 64}},
398 {{155, 130}, {64, 64}},
399 {{155, 130}, {64, 64}}
402 static void str2rcolor(RContext
* rc
, const char *name
, RColor
* color
)
406 XParseColor(rc
->dpy
, rc
->cmap
, name
, &xcolor
);
409 color
->red
= xcolor
.red
>> 8;
410 color
->green
= xcolor
.green
>> 8;
411 color
->blue
= xcolor
.blue
>> 8;
414 static void dumpRImage(const char *path
, RImage
* image
)
417 int channels
= (image
->format
== RRGBAFormat
? 4 : 3);
419 f
= fopen(path
, "wb");
424 fprintf(f
, "%02x%02x%1x", image
->width
, image
->height
, channels
);
426 fwrite(image
->data
, 1, image
->width
* image
->height
* channels
, f
);
434 static int isPixmap(WMPropList
* prop
)
439 p
= WMGetFromPLArray(prop
, 0);
440 s
= WMGetFromPLString(p
);
441 if (strcasecmp(&s
[1], "pixmap") == 0)
447 /**********************************************************************/
449 static void drawResizebarBevel(RImage
* img
)
453 int width
= img
->width
;
454 int height
= img
->height
;
458 light
.red
= light
.green
= light
.blue
= 80;
461 dark
.red
= dark
.green
= dark
.blue
= 40;
463 ROperateLine(img
, RSubtractOperation
, 0, 0, width
- 1, 0, &dark
);
464 ROperateLine(img
, RAddOperation
, 0, 1, width
- 1, 1, &light
);
466 ROperateLine(img
, RSubtractOperation
, cwidth
, 2, cwidth
, height
- 1, &dark
);
467 ROperateLine(img
, RAddOperation
, cwidth
+ 1, 2, cwidth
+ 1, height
- 1, &light
);
469 ROperateLine(img
, RSubtractOperation
, width
- cwidth
- 2, 2, width
- cwidth
- 2, height
- 1, &dark
);
470 ROperateLine(img
, RAddOperation
, width
- cwidth
- 1, 2, width
- cwidth
- 1, height
- 1, &light
);
474 static void drawMenuBevel(RImage
* img
)
476 RColor light
, dark
, mid
;
478 int iheight
= img
->height
/ 4;
481 light
.red
= light
.green
= light
.blue
= 80;
484 dark
.red
= dark
.green
= dark
.blue
= 0;
487 mid
.red
= mid
.green
= mid
.blue
= 40;
489 for (i
= 1; i
< 4; i
++) {
490 ROperateLine(img
, RSubtractOperation
, 0, i
* iheight
- 2, img
->width
- 1, i
* iheight
- 2, &mid
);
492 RDrawLine(img
, 0, i
* iheight
- 1, img
->width
- 1, i
* iheight
- 1, &dark
);
494 ROperateLine(img
, RAddOperation
, 1, i
* iheight
, img
->width
- 2, i
* iheight
, &light
);
498 static Pixmap
renderTexture(WMScreen
* scr
, WMPropList
* texture
, int width
, int height
, const char *path
, int border
)
501 RImage
*image
= NULL
;
502 RImage
*timage
= NULL
;
504 RContext
*rc
= WMScreenRContext(scr
);
508 type
= WMGetFromPLString(WMGetFromPLArray(texture
, 0));
510 if (strcasecmp(&type
[1], "pixmap") == 0 ||
511 (strcasecmp(&type
[2], "gradient") == 0 && toupper(type
[0]) == 'T')) {
514 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
515 path
= wfindfileinarray(GetObjectForKey("PixmapPath"), str
);
517 timage
= RLoadImage(rc
, path
, 0);
519 wwarning("could not load file '%s': %s", path
, RMessageForError(RErrorCode
));
522 wwarning("could not find file '%s' for %s of texture", str
, type
);
526 texture
= WMCreatePropListFromDescription("(solid, black)");
531 if (strcasecmp(type
, "solid") == 0) {
533 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
535 str2rcolor(rc
, str
, &rcolor
);
537 image
= RCreateImage(width
, height
, False
);
538 RClearImage(image
, &rcolor
);
539 } else if (strcasecmp(type
, "igradient") == 0) {
543 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
544 str2rcolor(rc
, str
, &c1
[0]);
545 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
546 str2rcolor(rc
, str
, &c1
[1]);
547 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 3));
550 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 4));
551 str2rcolor(rc
, str
, &c2
[0]);
552 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 5));
553 str2rcolor(rc
, str
, &c2
[1]);
554 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 6));
557 image
= RRenderInterwovenGradient(width
, height
, c1
, t1
, c2
, t2
);
558 } else if (strcasecmp(&type
[1], "gradient") == 0) {
559 RGradientStyle style
;
562 switch (toupper(type
[0])) {
564 style
= RVerticalGradient
;
567 style
= RHorizontalGradient
;
570 wwarning("unknow direction in '%s', falling back to diagonal", type
);
572 style
= RDiagonalGradient
;
576 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 1));
577 str2rcolor(rc
, str
, &rcolor
);
578 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
579 str2rcolor(rc
, str
, &rcolor2
);
581 image
= RRenderGradient(width
, height
, &rcolor
, &rcolor2
, style
);
582 } else if (strcasecmp(&type
[2], "gradient") == 0 && toupper(type
[0]) == 'T') {
583 RGradientStyle style
;
588 switch (toupper(type
[1])) {
590 style
= RVerticalGradient
;
593 style
= RHorizontalGradient
;
596 wwarning("unknow direction in '%s', falling back to diagonal", type
);
598 style
= RDiagonalGradient
;
602 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 3));
603 str2rcolor(rc
, str
, &rcolor
);
604 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 4));
605 str2rcolor(rc
, str
, &rcolor2
);
607 grad
= RRenderGradient(width
, height
, &rcolor
, &rcolor2
, style
);
609 image
= RMakeTiledImage(timage
, width
, height
);
610 RReleaseImage(timage
);
612 i
= atoi(WMGetFromPLString(WMGetFromPLArray(texture
, 2)));
614 RCombineImagesWithOpaqueness(image
, grad
, i
);
617 } else if (strcasecmp(&type
[2], "gradient") == 0 && toupper(type
[0]) == 'M') {
618 RGradientStyle style
;
622 switch (toupper(type
[1])) {
624 style
= RVerticalGradient
;
627 style
= RHorizontalGradient
;
630 wwarning("unknow direction in '%s', falling back to diagonal", type
);
632 style
= RDiagonalGradient
;
636 j
= WMGetPropListItemCount(texture
);
639 colors
= wmalloc(j
* sizeof(RColor
*));
641 for (i
= 2; i
< j
; i
++) {
642 str
= WMGetFromPLString(WMGetFromPLArray(texture
, i
));
643 colors
[i
- 2] = wmalloc(sizeof(RColor
));
644 str2rcolor(rc
, str
, colors
[i
- 2]);
646 colors
[i
- 2] = NULL
;
648 image
= RRenderMultiGradient(width
, height
, colors
, style
);
650 for (i
= 0; colors
[i
] != NULL
; i
++)
654 } else if (strcasecmp(&type
[1], "pixmap") == 0) {
657 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
658 str2rcolor(rc
, str
, &color
);
660 switch (toupper(type
[0])) {
662 image
= RMakeTiledImage(timage
, width
, height
);
663 RReleaseImage(timage
);
666 image
= RMakeCenteredImage(timage
, width
, height
, &color
);
667 RReleaseImage(timage
);
672 image
= RScaleImage(timage
, width
, height
);
673 RReleaseImage(timage
);
677 wwarning("type '%s' in not a supported type for a texture", type
);
678 RReleaseImage(timage
);
687 dumpRImage(path
, image
);
691 if (border
== RESIZEBAR_BEVEL
) {
692 drawResizebarBevel(image
);
693 } else if (border
== MENU_BEVEL
) {
694 drawMenuBevel(image
);
695 RBevelImage(image
, RBEV_RAISED2
);
698 RBevelImage(image
, border
);
701 RConvertImage(rc
, image
, &pixmap
);
702 RReleaseImage(image
);
707 static Pixmap
renderMenu(_Panel
* panel
, WMPropList
* texture
, int width
, int iheight
)
709 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
710 Display
*dpy
= WMScreenDisplay(scr
);
712 GC gc
= XCreateGC(dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
715 switch (panel
->menuStyle
) {
717 tmp
= renderTexture(scr
, texture
, width
, iheight
, NULL
, RBEV_RAISED2
);
719 pix
= XCreatePixmap(dpy
, tmp
, width
, iheight
* 4, WMScreenDepth(scr
));
720 for (i
= 0; i
< 4; i
++) {
721 XCopyArea(dpy
, tmp
, pix
, gc
, 0, 0, width
, iheight
, 0, iheight
* i
);
723 XFreePixmap(dpy
, tmp
);
726 pix
= renderTexture(scr
, texture
, width
, iheight
* 4, NULL
, MENU_BEVEL
);
729 pix
= renderTexture(scr
, texture
, width
, iheight
* 4, NULL
, RBEV_RAISED2
);
739 static void renderPreview(_Panel
* panel
, GC gc
, int part
, int relief
)
742 TextureListItem
*titem
;
744 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
746 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[part
]);
747 titem
= (TextureListItem
*) item
->clientData
;
749 pix
= renderTexture(scr
, titem
->prop
,
750 previewPositions
[part
].size
.width
, previewPositions
[part
].size
.height
, NULL
, relief
);
752 XCopyArea(WMScreenDisplay(scr
), pix
, panel
->preview
, gc
, 0, 0,
753 previewPositions
[part
].size
.width
,
754 previewPositions
[part
].size
.height
, previewPositions
[part
].pos
.x
, previewPositions
[part
].pos
.y
);
756 XCopyArea(WMScreenDisplay(scr
), pix
, panel
->previewNoText
, gc
, 0, 0,
757 previewPositions
[part
].size
.width
,
758 previewPositions
[part
].size
.height
, previewPositions
[part
].pos
.x
, previewPositions
[part
].pos
.y
);
760 XFreePixmap(WMScreenDisplay(scr
), pix
);
763 static void updatePreviewBox(_Panel
* panel
, int elements
)
765 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
766 Display
*dpy
= WMScreenDisplay(scr
);
771 gc
= XCreateGC(dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
773 if (panel
->preview
== None
) {
776 panel
->previewNoText
= XCreatePixmap(dpy
, WMWidgetXID(panel
->parent
),
777 240 - 4, 215 - 4, WMScreenDepth(scr
));
778 panel
->previewBack
= XCreatePixmap(dpy
, WMWidgetXID(panel
->parent
),
779 240 - 4, 215 - 4, WMScreenDepth(scr
));
781 p
= WMCreatePixmap(scr
, 240 - 4, 215 - 4, WMScreenDepth(scr
), False
);
782 panel
->preview
= WMGetPixmapXID(p
);
783 WMSetLabelImage(panel
->prevL
, p
);
786 if (elements
& (1 << PBACKGROUND
)) {
788 TextureListItem
*titem
;
791 item
= WMGetListItem(panel
->texLs
,
792 panel
->textureIndex
[PBACKGROUND
]);
793 titem
= (TextureListItem
*) item
->clientData
;
794 tmp
= renderTexture(scr
, titem
->prop
, 240 - 4, 215 - 4, NULL
, 0);
796 XCopyArea(dpy
, tmp
, panel
->preview
, gc
, 0, 0, 240 - 4, 215 -4 , 0, 0);
797 XCopyArea(dpy
, tmp
, panel
->previewNoText
, gc
, 0, 0, 240 - 4, 215 -4 , 0, 0);
798 XCopyArea(dpy
, tmp
, panel
->previewBack
, gc
, 0, 0, 240 - 4, 215 -4 , 0, 0);
799 XFreePixmap(dpy
, tmp
);
802 if (elements
& (1 << PFOCUSED
)) {
803 renderPreview(panel
, gc
, PFOCUSED
, RBEV_RAISED2
);
804 colorUpdate
|= 1 << FTITLE_COL
| 1 << FFBORDER_COL
;
806 if (elements
& (1 << PUNFOCUSED
)) {
807 renderPreview(panel
, gc
, PUNFOCUSED
, RBEV_RAISED2
);
808 colorUpdate
|= 1 << UTITLE_COL
| 1 << FBORDER_COL
;
810 if (elements
& (1 << POWNER
)) {
811 renderPreview(panel
, gc
, POWNER
, RBEV_RAISED2
);
812 colorUpdate
|= 1 << OTITLE_COL
| 1 << FBORDER_COL
;
814 if (elements
& (1 << PRESIZEBAR
)) {
815 renderPreview(panel
, gc
, PRESIZEBAR
, RESIZEBAR_BEVEL
);
816 colorUpdate
|= 1 << FBORDER_COL
;
818 if (elements
& (1 << PMTITLE
)) {
819 renderPreview(panel
, gc
, PMTITLE
, RBEV_RAISED2
);
820 colorUpdate
|= 1 << MTITLE_COL
| 1 << FBORDER_COL
;
822 if (elements
& (1 << PMITEM
)) {
824 TextureListItem
*titem
;
826 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[5]);
827 titem
= (TextureListItem
*) item
->clientData
;
829 pix
= renderMenu(panel
, titem
->prop
,
830 previewPositions
[PMITEM
].size
.width
, previewPositions
[PMITEM
].size
.height
/ 4);
832 XCopyArea(dpy
, pix
, panel
->preview
, gc
, 0, 0,
833 previewPositions
[PMITEM
].size
.width
,
834 previewPositions
[PMITEM
].size
.height
,
835 previewPositions
[PMITEM
].pos
.x
, previewPositions
[PMITEM
].pos
.y
);
837 XCopyArea(dpy
, pix
, panel
->previewNoText
, gc
, 0, 0,
838 previewPositions
[PMITEM
].size
.width
,
839 previewPositions
[PMITEM
].size
.height
,
840 previewPositions
[PMITEM
].pos
.x
, previewPositions
[PMITEM
].pos
.y
);
842 XFreePixmap(dpy
, pix
);
844 colorUpdate
|= 1 << MITEM_COL
| 1 << MDISAB_COL
|
845 1 << MHIGH_COL
| 1 << MHIGHT_COL
|
848 if (elements
& (1 << PICON
)) {
850 TextureListItem
*titem
;
852 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[6]);
853 titem
= (TextureListItem
*) item
->clientData
;
855 renderPreview(panel
, gc
, PICON
, titem
->ispixmap
? 0 : RBEV_RAISED3
);
859 updateColorPreviewBox(panel
, colorUpdate
);
861 WMRedisplayWidget(panel
->prevL
);
866 static void cancelNewTexture(void *data
)
868 _Panel
*panel
= (_Panel
*) data
;
870 HideTexturePanel(panel
->texturePanel
);
873 static char *makeFileName(const char *prefix
)
877 fname
= wstrdup(prefix
);
879 while (access(fname
, F_OK
) == 0) {
883 sprintf(buf
, "%08lx.cache", time(NULL
));
884 fname
= wstrconcat(prefix
, buf
);
890 static void okNewTexture(void *data
)
892 _Panel
*panel
= (_Panel
*) data
;
897 TextureListItem
*titem
;
898 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
900 titem
= wmalloc(sizeof(TextureListItem
));
902 HideTexturePanel(panel
->texturePanel
);
904 name
= GetTexturePanelTextureName(panel
->texturePanel
);
906 prop
= GetTexturePanelTexture(panel
->texturePanel
);
908 str
= WMGetPropListDescription(prop
, False
);
912 titem
->texture
= str
;
913 titem
->selectedFor
= 0;
915 titem
->ispixmap
= isPixmap(prop
);
917 titem
->path
= makeFileName(panel
->fprefix
);
918 titem
->preview
= renderTexture(scr
, prop
, TEXPREV_WIDTH
, TEXPREV_HEIGHT
, titem
->path
, 0);
920 item
= WMAddListItem(panel
->texLs
, "");
921 item
->clientData
= titem
;
923 WMSetListPosition(panel
->texLs
, WMGetListNumberOfRows(panel
->texLs
));
926 static void okEditTexture(void *data
)
928 _Panel
*panel
= (_Panel
*) data
;
933 TextureListItem
*titem
;
935 item
= WMGetListItem(panel
->texLs
, WMGetListSelectedItemRow(panel
->texLs
));
936 titem
= (TextureListItem
*) item
->clientData
;
938 HideTexturePanel(panel
->texturePanel
);
940 if (titem
->current
) {
941 name
= GetTexturePanelTextureName(panel
->texturePanel
);
947 prop
= GetTexturePanelTexture(panel
->texturePanel
);
949 str
= WMGetPropListDescription(prop
, False
);
951 WMReleasePropList(titem
->prop
);
954 titem
->ispixmap
= isPixmap(prop
);
956 wfree(titem
->texture
);
957 titem
->texture
= str
;
959 XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel
->texLs
)), titem
->preview
);
960 titem
->preview
= renderTexture(WMWidgetScreen(panel
->texLs
), titem
->prop
,
961 TEXPREV_WIDTH
, TEXPREV_HEIGHT
, titem
->path
, 0);
963 WMRedisplayWidget(panel
->texLs
);
965 if (titem
->selectedFor
) {
966 if (titem
->selectedFor
& (1 << PBACKGROUND
))
967 updatePreviewBox(panel
, EVERYTHING
);
969 updatePreviewBox(panel
, titem
->selectedFor
);
972 changePage(panel
->secP
, panel
);
975 static void editTexture(WMWidget
* w
, void *data
)
977 _Panel
*panel
= (_Panel
*) data
;
979 TextureListItem
*titem
;
981 /* Parameter not used, but tell the compiler that it is ok */
984 item
= WMGetListItem(panel
->texLs
, WMGetListSelectedItemRow(panel
->texLs
));
985 titem
= (TextureListItem
*) item
->clientData
;
987 SetTexturePanelPixmapPath(panel
->texturePanel
, GetObjectForKey("PixmapPath"));
989 SetTexturePanelTexture(panel
->texturePanel
, titem
->title
, titem
->prop
);
991 SetTexturePanelCancelAction(panel
->texturePanel
, cancelNewTexture
, panel
);
992 SetTexturePanelOkAction(panel
->texturePanel
, okEditTexture
, panel
);
994 ShowTexturePanel(panel
->texturePanel
);
997 static void newTexture(WMWidget
* w
, void *data
)
999 _Panel
*panel
= (_Panel
*) data
;
1001 /* Parameter not used, but tell the compiler that it is ok */
1004 SetTexturePanelPixmapPath(panel
->texturePanel
, GetObjectForKey("PixmapPath"));
1006 SetTexturePanelTexture(panel
->texturePanel
, "New Texture", NULL
);
1008 SetTexturePanelCancelAction(panel
->texturePanel
, cancelNewTexture
, panel
);
1010 SetTexturePanelOkAction(panel
->texturePanel
, okNewTexture
, panel
);
1012 ShowTexturePanel(panel
->texturePanel
);
1015 static void deleteTexture(WMWidget
* w
, void *data
)
1017 _Panel
*panel
= (_Panel
*) data
;
1019 TextureListItem
*titem
;
1023 /* Parameter not used, but tell the compiler that it is ok */
1026 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
1027 row
= WMGetListSelectedItemRow(panel
->texLs
);
1028 item
= WMGetListItem(panel
->texLs
, row
);
1029 titem
= (TextureListItem
*) item
->clientData
;
1031 if (titem
->selectedFor
& (1 << section
)) {
1032 TextureListItem
*titem2
;
1034 panel
->textureIndex
[section
] = section
;
1035 item
= WMGetListItem(panel
->texLs
, section
);
1036 titem2
= (TextureListItem
*) item
->clientData
;
1037 titem2
->selectedFor
|= 1 << section
;
1040 wfree(titem
->title
);
1041 wfree(titem
->texture
);
1042 WMReleasePropList(titem
->prop
);
1044 if (remove(titem
->path
) < 0 && errno
!= ENOENT
) {
1045 werror("could not remove file %s", titem
->path
);
1052 WMRemoveListItem(panel
->texLs
, row
);
1053 WMSetButtonEnabled(panel
->delB
, False
);
1056 static void extractTexture(WMWidget
* w
, void *data
)
1058 _Panel
*panel
= (_Panel
*) data
;
1060 WMOpenPanel
*opanel
;
1061 WMScreen
*scr
= WMWidgetScreen(w
);
1063 opanel
= WMGetOpenPanel(scr
);
1064 WMSetFilePanelCanChooseDirectories(opanel
, False
);
1065 WMSetFilePanelCanChooseFiles(opanel
, True
);
1067 if (WMRunModalFilePanelForDirectory(opanel
, panel
->parent
, wgethomedir(), _("Select File"), NULL
)) {
1068 path
= WMGetFilePanelFileName(opanel
);
1070 OpenExtractPanelFor(panel
);
1076 static void changePage(WMWidget
* w
, void *data
)
1078 _Panel
*panel
= (_Panel
*) data
;
1080 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1081 RContext
*rc
= WMScreenRContext(scr
);
1082 static WMPoint positions
[] = {
1093 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
1095 WMSelectListItem(panel
->texLs
, panel
->textureIndex
[section
]);
1097 WMSetListPosition(panel
->texLs
, panel
->textureIndex
[section
] - 2);
1102 gc
= XCreateGC(rc
->dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
1103 XCopyArea(rc
->dpy
, panel
->previewBack
, panel
->preview
, gc
,
1104 positions
[panel
->oldsection
].x
,
1105 positions
[panel
->oldsection
].y
, 22, 22 ,
1106 positions
[panel
->oldsection
].x
,
1107 positions
[panel
->oldsection
].y
);
1110 panel
->oldsection
= section
;
1111 WMDrawPixmap(panel
->hand
, panel
->preview
, positions
[section
].x
, positions
[section
].y
);
1113 WMRedisplayWidget(panel
->prevL
);
1116 static void previewClick(XEvent
* event
, void *clientData
)
1118 _Panel
*panel
= (_Panel
*) clientData
;
1121 switch (panel
->oldTabItem
) {
1123 for (i
= 0; i
< wlengthof(previewPositions
); i
++) {
1124 if (event
->xbutton
.x
>= previewPositions
[i
].pos
.x
1125 && event
->xbutton
.y
>= previewPositions
[i
].pos
.y
1126 && event
->xbutton
.x
< previewPositions
[i
].pos
.x
1127 + previewPositions
[i
].size
.width
1128 && event
->xbutton
.y
< previewPositions
[i
].pos
.y
+ previewPositions
[i
].size
.height
) {
1130 WMSetPopUpButtonSelectedItem(panel
->secP
, i
);
1131 changePage(panel
->secP
, panel
);
1137 for (i
= 0; i
< WMGetPopUpButtonNumberOfItems(panel
->colP
); i
++) {
1138 if (event
->xbutton
.x
>= previewColorPositions
[i
].pos
.x
1139 && event
->xbutton
.y
>= previewColorPositions
[i
].pos
.y
1140 && event
->xbutton
.x
< previewColorPositions
[i
].pos
.x
1141 + previewColorPositions
[i
].size
.width
1142 && event
->xbutton
.y
< previewColorPositions
[i
].pos
.y
1143 + previewColorPositions
[i
].size
.height
) {
1149 WMSetPopUpButtonSelectedItem(panel
->colP
, i
);
1150 changeColorPage(panel
->colP
, panel
);
1158 static void textureClick(WMWidget
* w
, void *data
)
1160 _Panel
*panel
= (_Panel
*) data
;
1163 TextureListItem
*titem
;
1165 /* Parameter not used, but tell the compiler that it is ok */
1168 i
= WMGetListSelectedItemRow(panel
->texLs
);
1170 item
= WMGetListItem(panel
->texLs
, i
);
1172 titem
= (TextureListItem
*) item
->clientData
;
1174 if (titem
->current
) {
1175 WMSetButtonEnabled(panel
->delB
, False
);
1177 WMSetButtonEnabled(panel
->delB
, True
);
1181 static void textureDoubleClick(WMWidget
* w
, void *data
)
1183 _Panel
*panel
= (_Panel
*) data
;
1186 TextureListItem
*titem
;
1188 /* Parameter not used, but tell the compiler that it is ok */
1191 /* unselect old texture */
1192 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
1194 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[section
]);
1195 titem
= (TextureListItem
*) item
->clientData
;
1196 titem
->selectedFor
&= ~(1 << section
);
1198 /* select new texture */
1199 i
= WMGetListSelectedItemRow(panel
->texLs
);
1201 item
= WMGetListItem(panel
->texLs
, i
);
1203 titem
= (TextureListItem
*) item
->clientData
;
1205 titem
->selectedFor
|= 1 << section
;
1207 panel
->textureIndex
[section
] = i
;
1209 WMRedisplayWidget(panel
->texLs
);
1211 if (section
== PBACKGROUND
)
1212 updatePreviewBox(panel
, EVERYTHING
);
1214 updatePreviewBox(panel
, 1 << section
);
1217 static void paintListItem(WMList
* lPtr
, int index
, Drawable d
, char *text
, int state
, WMRect
* rect
)
1219 _Panel
*panel
= (_Panel
*) WMGetHangedData(lPtr
);
1220 WMScreen
*scr
= WMWidgetScreen(lPtr
);
1221 int width
, height
, x
, y
;
1222 Display
*dpy
= WMScreenDisplay(scr
);
1223 WMColor
*back
= (state
& WLDSSelected
) ? WMWhiteColor(scr
) : WMGrayColor(scr
);
1225 WMColor
*black
= WMBlackColor(scr
);
1226 TextureListItem
*titem
;
1228 /* Parameter not used, but tell the compiler that it is ok */
1231 item
= WMGetListItem(lPtr
, index
);
1232 titem
= (TextureListItem
*) item
->clientData
;
1234 WMReleaseColor(back
);
1235 WMReleaseColor(black
);
1239 width
= rect
->size
.width
;
1240 height
= rect
->size
.height
;
1244 XFillRectangle(dpy
, d
, WMColorGC(back
), x
, y
, width
, height
);
1247 XCopyArea(dpy
, titem
->preview
, d
, WMColorGC(black
), 0, 0,
1248 TEXPREV_WIDTH
, TEXPREV_HEIGHT
, x
+ 5, y
+ 5);
1250 if ((1 << WMGetPopUpButtonSelectedItem(panel
->secP
)) & titem
->selectedFor
)
1251 WMDrawPixmap(panel
->onLed
, d
, x
+ TEXPREV_WIDTH
+ 10, y
+ 6);
1252 else if (titem
->selectedFor
)
1253 WMDrawPixmap(panel
->offLed
, d
, x
+ TEXPREV_WIDTH
+ 10, y
+ 6);
1255 WMDrawString(scr
, d
, black
, panel
->boldFont
,
1256 x
+ TEXPREV_WIDTH
+ 22, y
+ 2, titem
->title
, strlen(titem
->title
));
1258 WMDrawString(scr
, d
, black
, panel
->smallFont
,
1259 x
+ TEXPREV_WIDTH
+ 14, y
+ 18, titem
->texture
, strlen(titem
->texture
));
1261 WMReleaseColor(back
);
1262 WMReleaseColor(black
);
1265 static Pixmap
loadRImage(WMScreen
* scr
, const char *path
)
1273 f
= fopen(path
, "rb");
1277 cnt
= fscanf(f
, "%02x%02x%1x", &w
, &h
, &d
);
1282 image
= RCreateImage(w
, h
, d
== 4);
1283 read_size
= w
* h
* d
;
1284 if (fread(image
->data
, 1, read_size
, f
) == read_size
)
1285 RConvertImage(WMScreenRContext(scr
), image
, &pixmap
);
1291 RReleaseImage(image
);
1296 static void fillTextureList(WMList
* lPtr
)
1298 WMPropList
*textureList
;
1299 WMPropList
*texture
;
1300 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
1301 TextureListItem
*titem
;
1302 WMScreen
*scr
= WMWidgetScreen(lPtr
);
1305 textureList
= WMGetUDObjectForKey(udb
, "TextureList");
1309 for (i
= 0; i
< WMGetPropListItemCount(textureList
); i
++) {
1312 texture
= WMGetFromPLArray(textureList
, i
);
1314 titem
= wmalloc(sizeof(TextureListItem
));
1316 titem
->title
= wstrdup(WMGetFromPLString(WMGetFromPLArray(texture
, 0)));
1317 titem
->prop
= WMRetainPropList(WMGetFromPLArray(texture
, 1));
1318 titem
->texture
= WMGetPropListDescription(titem
->prop
, False
);
1319 titem
->selectedFor
= 0;
1320 titem
->path
= wstrdup(WMGetFromPLString(WMGetFromPLArray(texture
, 2)));
1322 titem
->preview
= loadRImage(scr
, titem
->path
);
1323 if (!titem
->preview
) {
1324 titem
->preview
= renderTexture(scr
, titem
->prop
, TEXPREV_WIDTH
, TEXPREV_HEIGHT
, NULL
, 0);
1326 item
= WMAddListItem(lPtr
, "");
1327 item
->clientData
= titem
;
1331 static void fillColorList(_Panel
* panel
)
1335 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
1336 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1339 list
= WMGetUDObjectForKey(udb
, "ColorList");
1341 for (i
= 0; i
< 24; i
++) {
1342 color
= WMCreateNamedColor(scr
, sampleColors
[i
], False
);
1345 WMSetColorWellColor(panel
->sampW
[i
], color
);
1346 WMReleaseColor(color
);
1351 for (i
= 0; i
< WMIN(24, WMGetPropListItemCount(list
)); i
++) {
1352 c
= WMGetFromPLArray(list
, i
);
1353 if (!c
|| !WMIsPLString(c
))
1355 color
= WMCreateNamedColor(scr
, WMGetFromPLString(c
), False
);
1358 WMSetColorWellColor(panel
->sampW
[i
], color
);
1359 WMReleaseColor(color
);
1364 /*************************************************************************/
1366 static void changeColorPage(WMWidget
* w
, void *data
)
1368 _Panel
*panel
= (_Panel
*) data
;
1370 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1371 RContext
*rc
= WMScreenRContext(scr
);
1372 static WMPoint positions
[] = {
1390 if (panel
->preview
) {
1393 gc
= XCreateGC(rc
->dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
1394 XCopyArea(rc
->dpy
, panel
->previewBack
, panel
->preview
, gc
,
1395 positions
[panel
->oldcsection
].x
,
1396 positions
[panel
->oldcsection
].y
, 22, 22 ,
1397 positions
[panel
->oldcsection
].x
,
1398 positions
[panel
->oldcsection
].y
);
1401 section
= WMGetPopUpButtonSelectedItem(panel
->colP
);
1403 panel
->oldcsection
= section
;
1405 WMDrawPixmap(panel
->hand
, panel
->preview
, positions
[section
].x
, positions
[section
].y
);
1407 if (section
>= ICONT_COL
)
1408 updateColorPreviewBox(panel
, 1 << section
);
1410 WMSetColorWellColor(panel
->colW
, panel
->colors
[section
]);
1412 WMRedisplayWidget(panel
->prevL
);
1416 paintText(WMScreen
* scr
, Drawable d
, WMColor
* color
, WMFont
* font
,
1417 int x
, int y
, int w
, int h
, WMAlignment align
, char *text
)
1419 int l
= strlen(text
);
1426 x
+= w
- 5 - WMWidthOfString(font
, text
, l
);
1430 x
+= (w
- WMWidthOfString(font
, text
, l
)) / 2;
1433 WMDrawString(scr
, d
, color
, font
, x
, y
+ (h
- WMFontHeight(font
)) / 2, text
, l
);
1436 static void updateColorPreviewBox(_Panel
* panel
, int elements
)
1438 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1439 Display
*dpy
= WMScreenDisplay(scr
);
1444 pnot
= panel
->previewNoText
;
1445 gc
= WMColorGC(panel
->colors
[FTITLE_COL
]);
1447 if (elements
& (1 << FTITLE_COL
)) {
1448 XCopyArea(dpy
, pnot
, d
, gc
, 30, 10, 190, 20, 30, 10);
1449 paintText(scr
, d
, panel
->colors
[FTITLE_COL
],
1450 panel
->boldFont
, 30, 10, 190, 20,
1451 panel
->titleAlignment
, _("Focused Window"));
1453 if (elements
& (1 << UTITLE_COL
)) {
1454 XCopyArea(dpy
, pnot
, d
, gc
, 30, 40, 190, 20, 30, 40);
1455 paintText(scr
, d
, panel
->colors
[UTITLE_COL
],
1456 panel
->boldFont
, 30, 40, 190, 20,
1457 panel
->titleAlignment
,
1458 _("Unfocused Window"));
1460 if (elements
& (1 << OTITLE_COL
)) {
1461 XCopyArea(dpy
, pnot
, d
, gc
, 30, 70, 190, 20, 30, 70);
1462 paintText(scr
, d
, panel
->colors
[OTITLE_COL
],
1463 panel
->boldFont
, 30, 70, 190, 20,
1464 panel
->titleAlignment
,
1465 _("Owner of Focused Window"));
1467 if (elements
& (1 << MTITLE_COL
)) {
1468 XCopyArea(dpy
, pnot
, d
, gc
, 30, 120, 90, 20, 30, 120);
1469 paintText(scr
, d
, panel
->colors
[MTITLE_COL
],
1470 panel
->boldFont
, 30, 120, 90, 20, WALeft
,
1473 if (elements
& (1 << MITEM_COL
)) {
1474 XCopyArea(dpy
, pnot
, d
, gc
, 30, 140, 90, 20, 30, 140);
1475 paintText(scr
, d
, panel
->colors
[MITEM_COL
],
1476 panel
->normalFont
, 30, 140, 90, 20, WALeft
,
1478 XCopyArea(dpy
, pnot
, d
, gc
, 30, 200, 90, 20, 30, 200);
1479 paintText(scr
, d
, panel
->colors
[MITEM_COL
],
1480 panel
->normalFont
, 30, 200, 90, 20, WALeft
,
1483 if (elements
& (1 << MDISAB_COL
)) {
1484 XCopyArea(dpy
, pnot
, d
, gc
, 30, 160, 90, 20, 30, 160);
1485 paintText(scr
, d
, panel
->colors
[MDISAB_COL
],
1486 panel
->normalFont
, 30, 160, 90, 20, WALeft
,
1487 _("Disabled Item"));
1489 if (elements
& (1 << MHIGH_COL
)) {
1490 XFillRectangle(WMScreenDisplay(scr
), d
,
1491 WMColorGC(panel
->colors
[MHIGH_COL
]),
1493 XFillRectangle(WMScreenDisplay(scr
), pnot
,
1494 WMColorGC(panel
->colors
[MHIGH_COL
]),
1496 elements
|= 1 << MHIGHT_COL
;
1498 if (elements
& (1 << MHIGHT_COL
)) {
1499 XCopyArea(dpy
, pnot
, d
, gc
, 30, 180, 90, 20, 30, 180);
1500 paintText(scr
, d
, panel
->colors
[MHIGHT_COL
],
1501 panel
->normalFont
, 30, 180, 90, 20, WALeft
,
1504 if (elements
& (1 << FBORDER_COL
)) {
1505 XDrawRectangle(dpy
, pnot
,
1506 WMColorGC(panel
->colors
[FBORDER_COL
]),
1508 XDrawRectangle(dpy
, d
,
1509 WMColorGC(panel
->colors
[FBORDER_COL
]),
1511 XDrawRectangle(dpy
, pnot
,
1512 WMColorGC(panel
->colors
[FBORDER_COL
]),
1514 XDrawRectangle(dpy
, d
,
1515 WMColorGC(panel
->colors
[FBORDER_COL
]),
1517 XDrawLine(dpy
, pnot
,
1518 WMColorGC(panel
->colors
[FBORDER_COL
]),
1521 WMColorGC(panel
->colors
[FBORDER_COL
]),
1523 XDrawLine(dpy
, pnot
,
1524 WMColorGC(panel
->colors
[FBORDER_COL
]),
1527 WMColorGC(panel
->colors
[FBORDER_COL
]),
1529 XDrawLine(dpy
, pnot
,
1530 WMColorGC(panel
->colors
[FBORDER_COL
]),
1531 220, 100, 220, 109);
1533 WMColorGC(panel
->colors
[FBORDER_COL
]),
1534 220, 100, 220, 109);
1535 XDrawLine(dpy
, pnot
,
1536 WMColorGC(panel
->colors
[FBORDER_COL
]),
1539 WMColorGC(panel
->colors
[FBORDER_COL
]),
1541 XDrawLine(dpy
, pnot
,
1542 WMColorGC(panel
->colors
[FBORDER_COL
]),
1545 WMColorGC(panel
->colors
[FBORDER_COL
]),
1547 XDrawLine(dpy
, pnot
,
1548 WMColorGC(panel
->colors
[FBORDER_COL
]),
1549 119, 120, 119, 220);
1551 WMColorGC(panel
->colors
[FBORDER_COL
]),
1552 119, 120, 119, 220);
1555 if (elements
& (1 << FFBORDER_COL
)) {
1556 XDrawRectangle(dpy
, pnot
,
1557 WMColorGC(panel
->colors
[FFBORDER_COL
]),
1559 XDrawRectangle(dpy
, d
,
1560 WMColorGC(panel
->colors
[FFBORDER_COL
]),
1564 if (elements
& (1 << ICONT_COL
) || elements
& (1 << ICONB_COL
)) {
1566 RHSVColor hsv
, hsv2
;
1568 WMColor
*light
, *dim
;
1570 updatePreviewBox(panel
, 1 << PICON
);
1572 rgb
.red
= WMRedComponentOfColor(panel
->colors
[ICONB_COL
]) >> 8;
1573 rgb
.green
= WMGreenComponentOfColor(panel
->colors
[ICONB_COL
]) >> 8;
1574 rgb
.blue
= WMBlueComponentOfColor(panel
->colors
[ICONB_COL
]) >> 8;
1575 RRGBtoHSV(&rgb
, &hsv
);
1576 RHSVtoRGB(&hsv
, &rgb
);
1579 v
= hsv
.value
* 16 / 10;
1580 hsv
.value
= (v
> 255 ? 255 : v
);
1581 RHSVtoRGB(&hsv
, &rgb
);
1582 light
= WMCreateRGBColor(scr
, rgb
.red
<< 8, rgb
.green
<< 8, rgb
.blue
<< 8, False
);
1584 hsv2
.value
= hsv2
.value
/ 2;
1585 RHSVtoRGB(&hsv2
, &rgb
);
1586 dim
= WMCreateRGBColor(scr
, rgb
.red
<< 8, rgb
.green
<< 8, rgb
.blue
<< 8, False
);
1588 XFillRectangle(dpy
, d
, WMColorGC(panel
->colors
[ICONB_COL
]), 156, 131, 62, 11);
1589 XDrawLine(dpy
, d
, WMColorGC(light
), 155, 130, 155, 142);
1590 XDrawLine(dpy
, d
, WMColorGC(light
), 156, 130, 217, 130);
1591 XDrawLine(dpy
, d
, WMColorGC(dim
), 218, 130, 218, 142);
1593 paintText(scr
, d
, panel
->colors
[ICONT_COL
],
1594 panel
->smallFont
, 155, 130, 64, 13, WALeft
,
1599 if (elements
& (1 << CLIP_COL
) || elements
& (1 << CCLIP_COL
)) {
1605 TextureListItem
*titem
;
1609 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[PICON
]);
1610 titem
= (TextureListItem
*) item
->clientData
;
1612 pix
= renderTexture(scr
, titem
->prop
, 64, 64, NULL
, titem
->ispixmap
? 0 : RBEV_RAISED3
);
1613 tile
= RCreateImageFromDrawable(WMScreenRContext(scr
), pix
, None
);
1616 black
.red
= black
.green
= black
.blue
= 0;
1619 dark
.red
= dark
.green
= dark
.blue
= 60;
1622 light
.red
= light
.green
= light
.blue
= 80;
1625 ROperateLine(tile
, RSubtractOperation
, 64 - 1 - 23, 0, 64 - 2, 23 - 1, &dark
);
1626 RDrawLine(tile
, 64 - 1 - 23 - 1, 0, 64 - 1, 23 + 1, &black
);
1627 ROperateLine(tile
, RAddOperation
, 64 - 1 - 23, 2, 64 - 3, 23, &light
);
1630 ROperateLine(tile
, RSubtractOperation
, 64 - 7 - (23 - 15), 4, 64 - 5, 4, &dark
);
1631 ROperateLine(tile
, RSubtractOperation
, 64 - 6 - (23 - 15), 5, 64 - 5, 6 + 23 - 15, &dark
);
1632 ROperateLine(tile
, RAddOperation
, 64 - 5, 4, 64 - 5, 6 + 23 - 15, &light
);
1635 ROperateLine(tile
, RAddOperation
, 2, 64 - 1 - 23 + 2, 23 - 2, 64 - 3, &dark
);
1636 RDrawLine(tile
, 0, 64 - 1 - 23 - 1, 23 + 1, 64 - 1, &black
);
1637 ROperateLine(tile
, RSubtractOperation
, 0, 64 - 1 - 23 - 2, 23 + 1, 64 - 2, &light
);
1640 ROperateLine(tile
, RSubtractOperation
, 4, 64 - 7 - (23 - 15), 4, 64 - 5, &dark
);
1641 ROperateLine(tile
, RSubtractOperation
, 5, 64 - 6 - (23 - 15), 6 + 23 - 15, 64 - 5, &dark
);
1642 ROperateLine(tile
, RAddOperation
, 4, 64 - 5, 6 + 23 - 15, 64 - 5, &light
);
1644 RConvertImage(WMScreenRContext(scr
), tile
, &pix
);
1645 RReleaseImage(tile
);
1647 XCopyArea(dpy
, pix
, d
, gc
, 0, 0, 64, 64, 155, 130);
1648 XFreePixmap(dpy
, pix
);
1650 /* top right arrow */
1651 p
[0].x
= p
[3].x
= 155 + 64 - 5 - (23 - 15);
1652 p
[0].y
= p
[3].y
= 130 + 5;
1653 p
[1].x
= 155 + 64 - 6;
1655 p
[2].x
= 155 + 64 - 6;
1656 p
[2].y
= 130 + 4 + 23 - 15;
1658 XFillPolygon(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 3, Convex
, CoordModeOrigin
);
1659 XDrawLines(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 4, CoordModeOrigin
);
1661 /* bottom left arrow */
1662 p
[0].x
= p
[3].x
= 155 + 5;
1663 p
[0].y
= p
[3].y
= 130 + 64 - 5 - (23 - 15);
1665 p
[1].y
= 130 + 64 - 6;
1666 p
[2].x
= 155 + 4 + 23 - 15;
1667 p
[2].y
= 130 + 64 - 6;
1669 XFillPolygon(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 3, Convex
, CoordModeOrigin
);
1670 XDrawLines(dpy
, d
, WMColorGC(panel
->colors
[CLIP_COL
]), p
, 4, CoordModeOrigin
);
1674 if (elements
& (1 << CLIP_COL
))
1675 paintText(scr
, d
, panel
->colors
[CLIP_COL
],
1676 panel
->boldFont
, 155 + 23, 130 + 64 - 15 - 3, 22, 15, WALeft
,
1679 if (elements
& (1 << CCLIP_COL
)) {
1680 paintText(scr
, d
, panel
->colors
[CCLIP_COL
],
1681 panel
->boldFont
, 155+2, 130 + 2, 26, 15, WALeft
, _("Coll."));
1682 paintText(scr
, d
, panel
->colors
[CCLIP_COL
],
1683 panel
->boldFont
, 155 + 23, 130 + 64 - 15 - 3, 22, 15, WALeft
,
1687 WMRedisplayWidget(panel
->prevL
);
1690 static void colorWellObserver(void *self
, WMNotification
* n
)
1692 _Panel
*panel
= (_Panel
*) self
;
1695 /* Parameter not used, but tell the compiler that it is ok */
1698 p
= WMGetPopUpButtonSelectedItem(panel
->colP
);
1700 WMReleaseColor(panel
->colors
[p
]);
1702 panel
->colors
[p
] = WMRetainColor(WMGetColorWellColor(panel
->colW
));
1704 updateColorPreviewBox(panel
, 1 << p
);
1707 static void changedTabItem(struct WMTabViewDelegate
*self
, WMTabView
* tabView
, WMTabViewItem
* item
)
1709 _Panel
*panel
= self
->data
;
1712 /* Parameter not used, but tell the compiler that it is ok */
1715 i
= WMGetTabViewItemIdentifier(item
);
1718 switch (panel
->oldTabItem
) {
1720 changeColorPage(NULL
, panel
);
1723 changePage(panel
->secP
, panel
);
1726 switch (panel
->oldTabItem
) {
1728 changePage(NULL
, panel
);
1731 changeColorPage(panel
->colP
, panel
);
1734 switch (panel
->oldTabItem
) {
1736 changePage(NULL
, panel
);
1739 changeColorPage(NULL
, panel
);
1745 panel
->oldTabItem
= i
;
1748 /*************************************************************************/
1750 static void menuStyleCallback(WMWidget
* self
, void *data
)
1752 _Panel
*panel
= (_Panel
*) data
;
1754 if (self
== panel
->mstyB
[0]) {
1755 panel
->menuStyle
= MSTYLE_NORMAL
;
1756 updatePreviewBox(panel
, 1 << PMITEM
);
1758 } else if (self
== panel
->mstyB
[1]) {
1759 panel
->menuStyle
= MSTYLE_SINGLE
;
1760 updatePreviewBox(panel
, 1 << PMITEM
);
1762 } else if (self
== panel
->mstyB
[2]) {
1763 panel
->menuStyle
= MSTYLE_FLAT
;
1764 updatePreviewBox(panel
, 1 << PMITEM
);
1768 static void titleAlignCallback(WMWidget
* self
, void *data
)
1770 _Panel
*panel
= (_Panel
*) data
;
1772 if (self
== panel
->taliB
[0]) {
1773 panel
->titleAlignment
= WALeft
;
1774 updatePreviewBox(panel
, 1 << PFOCUSED
| 1 << PUNFOCUSED
| 1 << POWNER
);
1776 } else if (self
== panel
->taliB
[1]) {
1777 panel
->titleAlignment
= WACenter
;
1778 updatePreviewBox(panel
, 1 << PFOCUSED
| 1 << PUNFOCUSED
| 1 << POWNER
);
1780 } else if (self
== panel
->taliB
[2]) {
1781 panel
->titleAlignment
= WARight
;
1782 updatePreviewBox(panel
, 1 << PFOCUSED
| 1 << PUNFOCUSED
| 1 << POWNER
);
1786 static void createPanel(Panel
* p
)
1788 _Panel
*panel
= (_Panel
*) p
;
1790 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
1791 WMTabViewItem
*item
;
1796 panel
->fprefix
= wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
1798 if (access(panel
->fprefix
, F_OK
) != 0) {
1799 if (mkdir(panel
->fprefix
, 0755) < 0) {
1800 werror("%s", panel
->fprefix
);
1805 tmp
= wstrconcat(panel
->fprefix
, "/WPrefs/");
1806 wfree(panel
->fprefix
);
1807 panel
->fprefix
= tmp
;
1808 if (access(panel
->fprefix
, F_OK
) != 0) {
1809 if (mkdir(panel
->fprefix
, 0755) < 0) {
1810 werror("%s", panel
->fprefix
);
1815 panel
->smallFont
= WMSystemFontOfSize(scr
, 10);
1816 panel
->normalFont
= WMSystemFontOfSize(scr
, 12);
1817 panel
->boldFont
= WMBoldSystemFontOfSize(scr
, 12);
1819 panel
->onLed
= WMCreatePixmapFromXPMData(scr
, blueled_xpm
);
1820 panel
->offLed
= WMCreatePixmapFromXPMData(scr
, blueled2_xpm
);
1821 panel
->hand
= WMCreatePixmapFromXPMData(scr
, hand_xpm
);
1823 panel
->box
= WMCreateBox(panel
->parent
);
1824 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
1827 panel
->prevL
= WMCreateLabel(panel
->box
);
1828 WMResizeWidget(panel
->prevL
, 240, FRAME_HEIGHT
- 20);
1829 WMMoveWidget(panel
->prevL
, 15, 10);
1830 WMSetLabelRelief(panel
->prevL
, WRSunken
);
1831 WMSetLabelImagePosition(panel
->prevL
, WIPImageOnly
);
1833 WMCreateEventHandler(WMWidgetView(panel
->prevL
), ButtonPressMask
, previewClick
, panel
);
1837 tabviewDelegate
.data
= panel
;
1839 panel
->tabv
= WMCreateTabView(panel
->box
);
1840 WMResizeWidget(panel
->tabv
, 245, FRAME_HEIGHT
- 20);
1841 WMMoveWidget(panel
->tabv
, 265, 10);
1842 WMSetTabViewDelegate(panel
->tabv
, &tabviewDelegate
);
1844 /*** texture list ***/
1846 panel
->texF
= WMCreateFrame(panel
->box
);
1847 WMSetFrameRelief(panel
->texF
, WRFlat
);
1849 item
= WMCreateTabViewItemWithIdentifier(TAB_TEXTURE
);
1850 WMSetTabViewItemView(item
, WMWidgetView(panel
->texF
));
1851 WMSetTabViewItemLabel(item
, _("Texture"));
1853 WMAddItemInTabView(panel
->tabv
, item
);
1855 panel
->secP
= WMCreatePopUpButton(panel
->texF
);
1856 WMResizeWidget(panel
->secP
, 228, 20);
1857 WMMoveWidget(panel
->secP
, 7, 7);
1858 WMAddPopUpButtonItem(panel
->secP
, _("Titlebar of Focused Window"));
1859 WMAddPopUpButtonItem(panel
->secP
, _("Titlebar of Unfocused Windows"));
1860 WMAddPopUpButtonItem(panel
->secP
, _("Titlebar of Focused Window's Owner"));
1861 WMAddPopUpButtonItem(panel
->secP
, _("Window Resizebar"));
1862 WMAddPopUpButtonItem(panel
->secP
, _("Titlebar of Menus"));
1863 WMAddPopUpButtonItem(panel
->secP
, _("Menu Items"));
1864 WMAddPopUpButtonItem(panel
->secP
, _("Icon Background"));
1865 WMAddPopUpButtonItem(panel
->secP
, _("Workspace Background"));
1867 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
1868 WMSetPopUpButtonAction(panel
->secP
, changePage
, panel
);
1870 panel
->texLs
= WMCreateList(panel
->texF
);
1871 WMResizeWidget(panel
->texLs
, 165, 155);
1872 WMMoveWidget(panel
->texLs
, 70, 33);
1873 WMSetListUserDrawItemHeight(panel
->texLs
, 35);
1874 WMSetListUserDrawProc(panel
->texLs
, paintListItem
);
1875 WMHangData(panel
->texLs
, panel
);
1876 WMSetListAction(panel
->texLs
, textureClick
, panel
);
1877 WMSetListDoubleAction(panel
->texLs
, textureDoubleClick
, panel
);
1879 WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
1880 "for the selected item."), WMWidgetView(panel
->texLs
));
1882 /* command buttons */
1884 font
= WMSystemFontOfSize(scr
, 10);
1886 panel
->newB
= WMCreateCommandButton(panel
->texF
);
1887 WMResizeWidget(panel
->newB
, 57, 39);
1888 WMMoveWidget(panel
->newB
, 7, 33);
1889 WMSetButtonFont(panel
->newB
, font
);
1890 WMSetButtonImagePosition(panel
->newB
, WIPAbove
);
1891 WMSetButtonText(panel
->newB
, _("New"));
1892 WMSetButtonAction(panel
->newB
, newTexture
, panel
);
1893 SetButtonAlphaImage(scr
, panel
->newB
, TNEW_FILE
);
1895 WMSetBalloonTextForView(_("Create a new texture."), WMWidgetView(panel
->newB
));
1897 panel
->ripB
= WMCreateCommandButton(panel
->texF
);
1898 WMResizeWidget(panel
->ripB
, 57, 39);
1899 WMMoveWidget(panel
->ripB
, 7, 72);
1900 WMSetButtonFont(panel
->ripB
, font
);
1901 WMSetButtonImagePosition(panel
->ripB
, WIPAbove
);
1902 WMSetButtonText(panel
->ripB
, _("Extract..."));
1903 WMSetButtonAction(panel
->ripB
, extractTexture
, panel
);
1904 SetButtonAlphaImage(scr
, panel
->ripB
, TEXTR_FILE
);
1906 WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."), WMWidgetView(panel
->ripB
));
1908 WMSetButtonEnabled(panel
->ripB
, False
);
1910 panel
->editB
= WMCreateCommandButton(panel
->texF
);
1911 WMResizeWidget(panel
->editB
, 57, 39);
1912 WMMoveWidget(panel
->editB
, 7, 111);
1913 WMSetButtonFont(panel
->editB
, font
);
1914 WMSetButtonImagePosition(panel
->editB
, WIPAbove
);
1915 WMSetButtonText(panel
->editB
, _("Edit"));
1916 SetButtonAlphaImage(scr
, panel
->editB
, TEDIT_FILE
);
1917 WMSetButtonAction(panel
->editB
, editTexture
, panel
);
1918 WMSetBalloonTextForView(_("Edit the highlighted texture."), WMWidgetView(panel
->editB
));
1920 panel
->delB
= WMCreateCommandButton(panel
->texF
);
1921 WMResizeWidget(panel
->delB
, 57, 38);
1922 WMMoveWidget(panel
->delB
, 7, 150);
1923 WMSetButtonFont(panel
->delB
, font
);
1924 WMSetButtonImagePosition(panel
->delB
, WIPAbove
);
1925 WMSetButtonText(panel
->delB
, _("Delete"));
1926 SetButtonAlphaImage(scr
, panel
->delB
, TDEL_FILE
);
1927 WMSetButtonEnabled(panel
->delB
, False
);
1928 WMSetButtonAction(panel
->delB
, deleteTexture
, panel
);
1929 WMSetBalloonTextForView(_("Delete the highlighted texture."), WMWidgetView(panel
->delB
));
1931 WMReleaseFont(font
);
1933 WMMapSubwidgets(panel
->texF
);
1936 panel
->colF
= WMCreateFrame(panel
->box
);
1937 WMSetFrameRelief(panel
->colF
, WRFlat
);
1939 item
= WMCreateTabViewItemWithIdentifier(TAB_COLOR
);
1940 WMSetTabViewItemView(item
, WMWidgetView(panel
->colF
));
1941 WMSetTabViewItemLabel(item
, _("Color"));
1943 WMAddItemInTabView(panel
->tabv
, item
);
1945 panel
->colP
= WMCreatePopUpButton(panel
->colF
);
1946 WMResizeWidget(panel
->colP
, 228, 20);
1947 WMMoveWidget(panel
->colP
, 7, 7);
1948 WMAddPopUpButtonItem(panel
->colP
, _("Focused Window Title"));
1949 WMAddPopUpButtonItem(panel
->colP
, _("Unfocused Window Title"));
1950 WMAddPopUpButtonItem(panel
->colP
, _("Owner of Focused Window Title"));
1951 WMAddPopUpButtonItem(panel
->colP
, _("Menu Title"));
1952 WMAddPopUpButtonItem(panel
->colP
, _("Menu Item Text"));
1953 WMAddPopUpButtonItem(panel
->colP
, _("Disabled Menu Item Text"));
1954 WMAddPopUpButtonItem(panel
->colP
, _("Menu Highlight Color"));
1955 WMAddPopUpButtonItem(panel
->colP
, _("Highlighted Menu Text Color"));
1956 WMAddPopUpButtonItem(panel
->colP
, _("Focused Window Border Color"));
1957 WMAddPopUpButtonItem(panel
->colP
, _("Window Border Color"));
1958 WMAddPopUpButtonItem(panel
->colP
, _("Selected Window Border Color"));
1959 WMAddPopUpButtonItem(panel
->colP
, _("Miniwindow Title"));
1960 WMAddPopUpButtonItem(panel
->colP
, _("Miniwindow Title Back"));
1961 WMAddPopUpButtonItem(panel
->colP
, _("Clip Title"));
1962 WMAddPopUpButtonItem(panel
->colP
, _("Collapsed Clip Title"));
1964 WMSetPopUpButtonSelectedItem(panel
->colP
, 0);
1966 WMSetPopUpButtonAction(panel
->colP
, changeColorPage
, panel
);
1968 panel
->colW
= WMCreateColorWell(panel
->colF
);
1969 WMResizeWidget(panel
->colW
, 65, 50);
1970 WMMoveWidget(panel
->colW
, 30, 75);
1971 WMAddNotificationObserver(colorWellObserver
, panel
, WMColorWellDidChangeNotification
, panel
->colW
);
1973 for (i
= 0; i
< 4; i
++) {
1975 for (j
= 0; j
< 6; j
++) {
1976 panel
->sampW
[i
+ j
* 4] = WMCreateColorWell(panel
->colF
);
1977 WMResizeWidget(panel
->sampW
[i
+ j
* 4], 22, 22);
1978 WMMoveWidget(panel
->sampW
[i
+ j
* 4], 130 + i
* 22, 40 + j
* 22);
1979 WSetColorWellBordered(panel
->sampW
[i
+ j
* 4], False
);
1983 WMMapSubwidgets(panel
->colF
);
1986 panel
->optF
= WMCreateFrame(panel
->box
);
1987 WMSetFrameRelief(panel
->optF
, WRFlat
);
1989 item
= WMCreateTabViewItemWithIdentifier(TAB_OPTIONS
);
1990 WMSetTabViewItemView(item
, WMWidgetView(panel
->optF
));
1991 WMSetTabViewItemLabel(item
, _("Options"));
1993 WMAddItemInTabView(panel
->tabv
, item
);
1995 panel
->mstyF
= WMCreateFrame(panel
->optF
);
1996 WMResizeWidget(panel
->mstyF
, 215, 85);
1997 WMMoveWidget(panel
->mstyF
, 15, 10);
1998 WMSetFrameTitle(panel
->mstyF
, _("Menu Style"));
2000 for (i
= 0; i
< 3; i
++) {
2004 panel
->mstyB
[i
] = WMCreateButton(panel
->mstyF
, WBTOnOff
);
2005 WMResizeWidget(panel
->mstyB
[i
], 54, 54);
2006 WMMoveWidget(panel
->mstyB
[i
], 15 + i
* 65, 20);
2007 WMSetButtonImagePosition(panel
->mstyB
[i
], WIPImageOnly
);
2008 WMSetButtonAction(panel
->mstyB
[i
], menuStyleCallback
, panel
);
2011 path
= LocateImage(MSTYLE1_FILE
);
2014 path
= LocateImage(MSTYLE2_FILE
);
2017 path
= LocateImage(MSTYLE3_FILE
);
2021 icon
= WMCreatePixmapFromFile(scr
, path
);
2023 WMSetButtonImage(panel
->mstyB
[i
], icon
);
2024 WMReleasePixmap(icon
);
2026 wwarning(_("could not load icon file %s"), path
);
2031 WMGroupButtons(panel
->mstyB
[0], panel
->mstyB
[1]);
2032 WMGroupButtons(panel
->mstyB
[0], panel
->mstyB
[2]);
2034 WMMapSubwidgets(panel
->mstyF
);
2036 panel
->taliF
= WMCreateFrame(panel
->optF
);
2037 WMResizeWidget(panel
->taliF
, 110, 80);
2038 WMMoveWidget(panel
->taliF
, 15, 100);
2039 WMSetFrameTitle(panel
->taliF
, _("Title Alignment"));
2041 for (i
= 0; i
< 3; i
++) {
2042 panel
->taliB
[i
] = WMCreateRadioButton(panel
->taliF
);
2043 WMSetButtonAction(panel
->taliB
[i
], titleAlignCallback
, panel
);
2046 WMSetButtonText(panel
->taliB
[i
], _("Left"));
2049 WMSetButtonText(panel
->taliB
[i
], _("Center"));
2052 WMSetButtonText(panel
->taliB
[i
], _("Right"));
2055 WMResizeWidget(panel
->taliB
[i
], 90, 18);
2056 WMMoveWidget(panel
->taliB
[i
], 10, 15 + 20 * i
);
2058 WMGroupButtons(panel
->taliB
[0], panel
->taliB
[1]);
2059 WMGroupButtons(panel
->taliB
[0], panel
->taliB
[2]);
2061 WMMapSubwidgets(panel
->taliF
);
2063 WMMapSubwidgets(panel
->optF
);
2065 /**/ WMRealizeWidget(panel
->box
);
2066 WMMapSubwidgets(panel
->box
);
2068 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
2072 changePage(panel
->secP
, panel
);
2074 fillTextureList(panel
->texLs
);
2076 fillColorList(panel
);
2078 panel
->texturePanel
= CreateTexturePanel(panel
->parent
);
2081 static void setupTextureFor(WMList
*list
, const char *key
, const char *defValue
, const char *title
, int index
)
2084 TextureListItem
*titem
;
2086 titem
= wmalloc(sizeof(TextureListItem
));
2088 titem
->title
= wstrdup(title
);
2089 titem
->prop
= GetObjectForKey(key
);
2090 if (!titem
->prop
|| !WMIsPLArray(titem
->prop
)) {
2091 /* Maybe also give a error message to stderr that the entry is bad? */
2092 titem
->prop
= WMCreatePropListFromDescription(defValue
);
2094 WMRetainPropList(titem
->prop
);
2096 titem
->texture
= WMGetPropListDescription((WMPropList
*) titem
->prop
, False
);
2098 titem
->selectedFor
= 1 << index
;
2100 titem
->ispixmap
= isPixmap(titem
->prop
);
2102 titem
->preview
= renderTexture(WMWidgetScreen(list
), titem
->prop
, TEXPREV_WIDTH
, TEXPREV_HEIGHT
, NULL
, 0);
2104 item
= WMAddListItem(list
, "");
2105 item
->clientData
= titem
;
2108 static void showData(_Panel
* panel
)
2113 str
= GetStringForKey("MenuStyle");
2114 if (str
&& strcasecmp(str
, "flat") == 0) {
2115 panel
->menuStyle
= MSTYLE_FLAT
;
2116 } else if (str
&& strcasecmp(str
, "singletexture") == 0) {
2117 panel
->menuStyle
= MSTYLE_SINGLE
;
2119 panel
->menuStyle
= MSTYLE_NORMAL
;
2122 str
= GetStringForKey("TitleJustify");
2123 if (str
&& strcasecmp(str
, "left") == 0) {
2124 panel
->titleAlignment
= WALeft
;
2125 } else if (str
&& strcasecmp(str
, "right") == 0) {
2126 panel
->titleAlignment
= WARight
;
2128 panel
->titleAlignment
= WACenter
;
2131 for (i
= 0; i
< wlengthof(colorOptions
); i
++) {
2134 str
= GetStringForKey(colorOptions
[i
].key
);
2136 str
= colorOptions
[i
].default_value
;
2138 if (!(color
= WMCreateNamedColor(WMWidgetScreen(panel
->box
), str
, False
))) {
2139 color
= WMCreateNamedColor(WMWidgetScreen(panel
->box
), "#000000", False
);
2142 panel
->colors
[i
] = color
;
2144 changeColorPage(panel
->colP
, panel
);
2146 for (i
= 0; i
< wlengthof(textureOptions
); i
++) {
2147 setupTextureFor(panel
->texLs
, textureOptions
[i
].key
,
2148 textureOptions
[i
].default_value
, _(textureOptions
[i
].label
), i
);
2149 panel
->textureIndex
[i
] = i
;
2151 updatePreviewBox(panel
, EVERYTHING
);
2153 WMSetButtonSelected(panel
->mstyB
[panel
->menuStyle
], True
);
2154 WMSetButtonSelected(panel
->taliB
[panel
->titleAlignment
], True
);
2157 static void storeData(_Panel
* panel
)
2159 TextureListItem
*titem
;
2163 for (i
= 0; i
< wlengthof(textureOptions
); i
++) {
2164 item
= WMGetListItem(panel
->texLs
, panel
->textureIndex
[i
]);
2165 titem
= (TextureListItem
*) item
->clientData
;
2166 SetObjectForKey(titem
->prop
, textureOptions
[i
].key
);
2169 for (i
= 0; i
< wlengthof(colorOptions
); i
++) {
2172 str
= WMGetColorRGBDescription(panel
->colors
[i
]);
2175 SetStringForKey(str
, colorOptions
[i
].key
);
2180 switch (panel
->menuStyle
) {
2182 SetStringForKey("singletexture", "MenuStyle");
2185 SetStringForKey("flat", "MenuStyle");
2189 SetStringForKey("normal", "MenuStyle");
2192 switch (panel
->titleAlignment
) {
2194 SetStringForKey("left", "TitleJustify");
2197 SetStringForKey("right", "TitleJustify");
2201 SetStringForKey("center", "TitleJustify");
2206 static void prepareForClose(_Panel
* panel
)
2208 WMPropList
*textureList
;
2209 WMPropList
*texture
;
2210 TextureListItem
*titem
;
2212 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
2215 textureList
= WMCreatePLArray(NULL
, NULL
);
2217 /* store list of textures */
2218 for (i
= 8; i
< WMGetListNumberOfRows(panel
->texLs
); i
++) {
2219 item
= WMGetListItem(panel
->texLs
, i
);
2220 titem
= (TextureListItem
*) item
->clientData
;
2222 texture
= WMCreatePLArray(WMCreatePLString(titem
->title
),
2223 WMRetainPropList(titem
->prop
), WMCreatePLString(titem
->path
), NULL
);
2225 WMAddToPLArray(textureList
, texture
);
2228 WMSetUDObjectForKey(udb
, textureList
, "TextureList");
2229 WMReleasePropList(textureList
);
2231 /* store list of colors */
2232 textureList
= WMCreatePLArray(NULL
, NULL
);
2233 for (i
= 0; i
< 24; i
++) {
2237 color
= WMGetColorWellColor(panel
->sampW
[i
]);
2239 str
= WMGetColorRGBDescription(color
);
2240 WMAddToPLArray(textureList
, WMCreatePLString(str
));
2243 WMSetUDObjectForKey(udb
, textureList
, "ColorList");
2244 WMReleasePropList(textureList
);
2246 WMSynchronizeUserDefaults(udb
);
2249 Panel
*InitAppearance(WMWidget
*parent
)
2253 panel
= wmalloc(sizeof(_Panel
));
2255 panel
->sectionName
= _("Appearance Preferences");
2257 panel
->description
= _("Background texture configuration for windows,\n" "menus and icons.");
2259 panel
->parent
= parent
;
2261 panel
->callbacks
.createWidgets
= createPanel
;
2262 panel
->callbacks
.updateDomain
= storeData
;
2263 panel
->callbacks
.prepareForClose
= prepareForClose
;
2265 AddSection(panel
, ICON_FILE
);
2270 /****************************************************************************/
2272 typedef struct ExtractPanel
{
2282 static void OpenExtractPanelFor(_Panel
*panel
)
2284 ExtractPanel
*epanel
;
2287 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
2289 epanel
= wmalloc(sizeof(ExtractPanel
));
2290 epanel
->win
= WMCreatePanelWithStyleForWindow(panel
->parent
, "extract",
2291 WMTitledWindowMask
| WMClosableWindowMask
);
2292 WMResizeWidget(epanel
->win
, 245, 250);
2293 WMSetWindowTitle(epanel
->win
, _("Extract Texture"));
2295 epanel
->label
= WMCreateLabel(epanel
->win
);
2296 WMResizeWidget(epanel
->label
, 225, 18);
2297 WMMoveWidget(epanel
->label
, 10, 10);
2298 WMSetLabelTextAlignment(epanel
->label
, WACenter
);
2299 WMSetLabelRelief(epanel
->label
, WRSunken
);
2301 color
= WMDarkGrayColor(scr
);
2302 WMSetWidgetBackgroundColor(epanel
->label
, color
);
2303 WMReleaseColor(color
);
2305 color
= WMWhiteColor(scr
);
2306 WMSetLabelTextColor(epanel
->label
, color
);
2307 WMReleaseColor(color
);
2309 font
= WMBoldSystemFontOfSize(scr
, 12);
2310 WMSetLabelFont(epanel
->label
, font
);
2311 WMReleaseFont(font
);
2313 WMSetLabelText(epanel
->label
, _("Textures"));
2315 epanel
->list
= WMCreateList(epanel
->win
);
2316 WMResizeWidget(epanel
->list
, 225, 165);
2317 WMMoveWidget(epanel
->list
, 10, 30);
2319 epanel
->closeB
= WMCreateCommandButton(epanel
->win
);
2320 WMResizeWidget(epanel
->closeB
, 74, 24);
2321 WMMoveWidget(epanel
->closeB
, 165, 215);
2322 WMSetButtonText(epanel
->closeB
, _("Close"));
2324 epanel
->extrB
= WMCreateCommandButton(epanel
->win
);
2325 WMResizeWidget(epanel
->extrB
, 74, 24);
2326 WMMoveWidget(epanel
->extrB
, 80, 215);
2327 WMSetButtonText(epanel
->extrB
, _("Extract"));
2329 WMMapSubwidgets(epanel
->win
);
2331 /* take textures from file */
2333 WMRealizeWidget(epanel
->win
);
2335 WMMapWidget(epanel
->win
);