1 /* TexturePanel.c- texture editting panel
3 * WPrefs - WindowMaker Preferences Program
5 * Copyright (c) 1998, 1999 Alfredo K. Kojima
6 * Copyright (c) 1998 James Thompson
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
34 #include <WINGs/WINGs.h>
38 #include "TexturePanel.h"
40 #define MAX_SECTION_PARTS 5
42 typedef struct _TexturePanel
{
74 /* direction (common) */
80 /*-- Simple Gradient --*/
83 /*-- Textured Gradient --*/
110 WMCallback
*okAction
;
113 WMCallback
*cancelAction
;
117 WMWidget
*sectionParts
[5][MAX_SECTION_PARTS
];
129 #define TYPE_GRADIENT 1
130 #define TYPE_SGRADIENT 2
131 #define TYPE_TGRADIENT 3
132 #define TYPE_PIXMAP 4
136 #define PTYPE_SCALE 1
137 #define PTYPE_CENTER 2
138 #define PTYPE_MAXIMIZE 3
143 *--------------------------------------------------------------------------
145 *--------------------------------------------------------------------------
151 updateGradButtons(TexturePanel
*panel
)
158 colorn
= WMGetListNumberOfRows(panel
->gcolL
);
165 colors
= wmalloc(sizeof(RColor
*)*(colorn
+1));
167 for (i
= 0; i
< colorn
; i
++) {
168 item
= WMGetListItem(panel
->gcolL
, i
);
169 colors
[i
] = (RColor
*)item
->clientData
;
173 image
= RRenderMultiGradient(80, 30, colors
, RHorizontalGradient
);
174 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
176 RReleaseImage(image
);
177 WMSetButtonImage(panel
->dirhB
, pixmap
);
178 WMReleasePixmap(pixmap
);
180 image
= RRenderMultiGradient(80, 30, colors
, RVerticalGradient
);
181 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
183 RReleaseImage(image
);
184 WMSetButtonImage(panel
->dirvB
, pixmap
);
185 WMReleasePixmap(pixmap
);
187 image
= RRenderMultiGradient(80, 30, colors
, RDiagonalGradient
);
188 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
190 RReleaseImage(image
);
191 WMSetButtonImage(panel
->dirdB
, pixmap
);
192 WMReleasePixmap(pixmap
);
201 updateTGradImage(TexturePanel
*panel
)
203 RImage
*image
, *gradient
;
212 color
= WMGetColorWellColor(panel
->tcol1W
);
213 from
.red
= WMRedComponentOfColor(color
)>>8;
214 from
.green
= WMGreenComponentOfColor(color
)>>8;
215 from
.blue
= WMBlueComponentOfColor(color
)>>8;
217 color
= WMGetColorWellColor(panel
->tcol2W
);
218 to
.red
= WMRedComponentOfColor(color
)>>8;
219 to
.green
= WMGreenComponentOfColor(color
)>>8;
220 to
.blue
= WMBlueComponentOfColor(color
)>>8;
222 if (panel
->image
->width
< 141 || panel
->image
->height
< 91) {
223 image
= RMakeTiledImage(panel
->image
, 141, 91);
225 image
= RCloneImage(panel
->image
);
228 if (WMGetButtonSelected(panel
->dirhB
)) {
229 gradient
= RRenderGradient(image
->width
, image
->height
, &from
, &to
,
230 RHorizontalGradient
);
231 } else if (WMGetButtonSelected(panel
->dirvB
)) {
232 gradient
= RRenderGradient(image
->width
, image
->height
, &from
, &to
,
235 gradient
= RRenderGradient(image
->width
, image
->height
, &from
, &to
,
239 RCombineImagesWithOpaqueness(image
, gradient
,
240 WMGetSliderValue(panel
->topaS
));
241 RReleaseImage(gradient
);
242 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->win
),
245 WMSetLabelImage(panel
->imageL
, pixmap
);
246 WMReleasePixmap(pixmap
);
247 WMResizeWidget(panel
->imageL
, image
->width
, image
->height
);
248 RReleaseImage(image
);
253 updateSGradButtons(TexturePanel
*panel
)
261 color
= WMGetColorWellColor(panel
->tcol1W
);
262 from
.red
= WMRedComponentOfColor(color
)>>8;
263 from
.green
= WMGreenComponentOfColor(color
)>>8;
264 from
.blue
= WMBlueComponentOfColor(color
)>>8;
266 color
= WMGetColorWellColor(panel
->tcol2W
);
267 to
.red
= WMRedComponentOfColor(color
)>>8;
268 to
.green
= WMGreenComponentOfColor(color
)>>8;
269 to
.blue
= WMBlueComponentOfColor(color
)>>8;
271 image
= RRenderGradient(80, 30, &from
, &to
, RHorizontalGradient
);
272 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
274 RReleaseImage(image
);
275 WMSetButtonImage(panel
->dirhB
, pixmap
);
276 WMReleasePixmap(pixmap
);
278 image
= RRenderGradient(80, 30, &from
, &to
, RVerticalGradient
);
279 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
281 RReleaseImage(image
);
282 WMSetButtonImage(panel
->dirvB
, pixmap
);
283 WMReleasePixmap(pixmap
);
285 image
= RRenderGradient(80, 30, &from
, &to
, RDiagonalGradient
);
286 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
288 RReleaseImage(image
);
289 WMSetButtonImage(panel
->dirdB
, pixmap
);
290 WMReleasePixmap(pixmap
);
294 /*********** Gradient ************/
297 updateSVSlider(WMSlider
*sPtr
, Bool saturation
, WMFont
*font
, RHSVColor
*hsv
)
301 WMScreen
*scr
= WMWidgetScreen(sPtr
);
309 RHSVtoRGB(&tmp
, &from
);
310 tmp
.saturation
= 255;
311 RHSVtoRGB(&tmp
, &to
);
314 RHSVtoRGB(&tmp
, &from
);
316 RHSVtoRGB(&tmp
, &to
);
318 image
= RRenderGradient(130, 16, &from
, &to
, RHorizontalGradient
);
319 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
320 RReleaseImage(image
);
323 buffer
= wstrdup(_("Saturation"));
325 buffer
= wstrdup(_("Brightness"));
327 if (hsv
->value
< 128 || !saturation
) {
328 WMColor
*col
= WMWhiteColor(scr
);
330 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
331 (16 - WMFontHeight(font
))/2 - 1, buffer
, strlen(buffer
));
334 WMColor
*col
= WMBlackColor(scr
);
336 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
337 (16 - WMFontHeight(font
))/2 - 1, buffer
, strlen(buffer
));
341 WMSetSliderImage(sPtr
, pixmap
);
342 WMReleasePixmap(pixmap
);
347 updateHueSlider(WMSlider
*sPtr
, WMFont
*font
, RHSVColor
*hsv
)
352 WMScreen
*scr
= WMWidgetScreen(sPtr
);
357 for (i
= 0; i
<= 6; i
++) {
358 thsv
.hue
= (360*i
)/6;
359 colors
[i
] = wmalloc(sizeof(RColor
));
360 RHSVtoRGB(&thsv
, colors
[i
]);
364 image
= RRenderMultiGradient(130, 16, colors
, RGRD_HORIZONTAL
);
365 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
366 RReleaseImage(image
);
368 if (hsv
->value
< 128) {
369 WMColor
*col
= WMWhiteColor(scr
);
371 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
372 (16 - WMFontHeight(font
))/2 - 1,
373 _("Hue"), strlen(_("Hue")));
376 WMColor
*col
= WMBlackColor(scr
);
378 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
379 (16 - WMFontHeight(font
))/2 - 1,
380 _("Hue"), strlen(_("Hue")));
383 WMSetSliderImage(sPtr
, pixmap
);
384 WMReleasePixmap(pixmap
);
386 for (i
= 0; i
<= 6; i
++)
393 sliderChangeCallback(WMWidget
*w
, void *data
)
395 TexturePanel
*panel
= (TexturePanel
*)data
;
402 WMScreen
*scr
= WMWidgetScreen(w
);
404 hsv
.hue
= WMGetSliderValue(panel
->ghueS
);
405 hsv
.saturation
= WMGetSliderValue(panel
->gsatS
);
406 hsv
.value
= WMGetSliderValue(panel
->gvalS
);
408 row
= WMGetListSelectedItemRow(panel
->gcolL
);
412 item
= WMGetListItem(panel
->gcolL
, row
);
414 rgb
= (RColor
*)item
->clientData
;
416 RHSVtoRGB(&hsv
, rgb
);
418 sprintf(item
->text
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
421 if (w
== panel
->ghueS
) {
422 updateSVSlider(panel
->gsatS
, True
, panel
->listFont
, &hsv
);
423 updateSVSlider(panel
->gvalS
, False
, panel
->listFont
, &hsv
);
424 } else if (w
== panel
->gsatS
) {
425 updateHueSlider(panel
->ghueS
, panel
->listFont
, &hsv
);
426 updateSVSlider(panel
->gvalS
, False
, panel
->listFont
, &hsv
);
428 updateHueSlider(panel
->ghueS
, panel
->listFont
, &hsv
);
429 updateSVSlider(panel
->gsatS
, True
, panel
->listFont
, &hsv
);
432 rows
= WMGetListNumberOfRows(panel
->gcolL
);
436 colors
= wmalloc(sizeof(RColor
*)*(rows
+1));
438 for (i
= 0; i
< rows
; i
++) {
439 item
= WMGetListItem(panel
->gcolL
, i
);
441 colors
[i
] = (RColor
*)item
->clientData
;
445 if (panel
->gimage
!= None
) {
446 XFreePixmap(WMScreenDisplay(scr
), panel
->gimage
);
449 image
= RRenderMultiGradient(30, i
*WMGetListItemHeight(panel
->gcolL
),
450 colors
, RVerticalGradient
);
451 RConvertImage(WMScreenRContext(scr
), image
, &panel
->gimage
);
452 RReleaseImage(image
);
456 WMRedisplayWidget(panel
->gcolL
);
458 updateGradButtons(panel
);
463 paintGradListItem(WMList
*lPtr
, int index
, Drawable d
, char *text
, int state
,
466 TexturePanel
*panel
= (TexturePanel
*)WMGetHangedData(lPtr
);
467 WMScreen
*scr
= WMWidgetScreen(lPtr
);
468 int width
, height
, x
, y
;
470 WMColor
*white
= WMWhiteColor(scr
);
472 WMColor
*black
= WMBlackColor(scr
);
474 dpy
= WMScreenDisplay(scr
);
476 width
= rect
->size
.width
;
477 height
= rect
->size
.height
;
481 if (state
& WLDSSelected
)
482 XFillRectangle(dpy
, d
, WMColorGC(white
), x
, y
, width
, height
);
484 XClearArea(dpy
, d
, x
, y
, width
, height
, False
);
486 item
= WMGetListItem(lPtr
, index
);
489 XCopyArea(WMScreenDisplay(scr
), panel
->gimage
, d
, WMColorGC(white
),
490 0, height
*index
, 30, height
, x
+ 5, y
);
492 WMDrawString(scr
, d
, WMColorGC(black
), panel
->listFont
,
493 x
+ 40, y
+ 1, text
, strlen(text
));
495 WMReleaseColor(white
);
496 WMReleaseColor(black
);
502 gradAddCallback(WMWidget
*w
, void *data
)
504 TexturePanel
*panel
= (TexturePanel
*)data
;
509 row
= WMGetListSelectedItemRow(panel
->gcolL
) + 1;
510 item
= WMInsertListItem(panel
->gcolL
, row
, "00,00,00");
511 rgb
= wmalloc(sizeof(RColor
));
512 memset(rgb
, 0, sizeof(RColor
));
513 item
->clientData
= rgb
;
515 WMSelectListItem(panel
->gcolL
, row
);
517 updateGradButtons(panel
);
519 sliderChangeCallback(panel
->ghueS
, panel
);
521 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
527 gradClickCallback(WMWidget
*w
, void *data
)
529 TexturePanel
*panel
= (TexturePanel
*)data
;
534 row
= WMGetListSelectedItemRow(w
);
538 item
= WMGetListItem(panel
->gcolL
, row
);
539 RRGBtoHSV((RColor
*)item
->clientData
, &hsv
);
541 WMSetSliderValue(panel
->ghueS
, hsv
.hue
);
542 WMSetSliderValue(panel
->gsatS
, hsv
.saturation
);
543 WMSetSliderValue(panel
->gvalS
, hsv
.value
);
545 sliderChangeCallback(panel
->ghueS
, panel
);
546 sliderChangeCallback(panel
->gsatS
, panel
);
551 gradDeleteCallback(WMWidget
*w
, void *data
)
553 TexturePanel
*panel
= (TexturePanel
*)data
;
557 row
= WMGetListSelectedItemRow(panel
->gcolL
);
561 item
= WMGetListItem(panel
->gcolL
, row
);
562 wfree(item
->clientData
);
564 WMRemoveListItem(panel
->gcolL
, row
);
566 WMSelectListItem(panel
->gcolL
, row
- 1);
568 updateGradButtons(panel
);
570 gradClickCallback(panel
->gcolL
, panel
);
572 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
576 /*************** Simple Gradient ***************/
579 colorWellObserver(void *self
, WMNotification
*n
)
581 updateSGradButtons(self
);
588 opaqChangeCallback(WMWidget
*w
, void *data
)
590 TexturePanel
*panel
= (TexturePanel
*)data
;
592 updateTGradImage(panel
);
595 /****************** Image ******************/
598 updateImage(TexturePanel
*panel
, char *path
)
600 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
606 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
610 message
= wstrconcat(_("Could not load the selected file: "),
611 (char*)RMessageForError(RErrorCode
));
613 WMRunAlertPanel(scr
, panel
->win
, _("Error"), message
,
614 _("OK"), NULL
, NULL
);
617 WMSetButtonEnabled(panel
->okB
, False
);
623 WMSetButtonEnabled(panel
->okB
, True
);
626 RReleaseImage(panel
->image
);
627 panel
->image
= image
;
629 image
= panel
->image
;
632 if (WMGetPopUpButtonSelectedItem(panel
->typeP
) == TYPE_PIXMAP
) {
634 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
636 size
= WMGetPixmapSize(pixmap
);
637 WMSetLabelImage(panel
->imageL
, pixmap
);
638 WMResizeWidget(panel
->imageL
, size
.width
, size
.height
);
640 WMReleasePixmap(pixmap
);
643 updateTGradImage(panel
);
649 browseImageCallback(WMWidget
*w
, void *data
)
651 TexturePanel
*panel
= (TexturePanel
*)data
;
653 WMScreen
*scr
= WMWidgetScreen(w
);
654 static char *ipath
= NULL
;
656 opanel
= WMGetOpenPanel(scr
);
657 WMSetFilePanelCanChooseDirectories(opanel
, False
);
658 WMSetFilePanelCanChooseFiles(opanel
, True
);
661 ipath
= wstrdup(wgethomedir());
663 if (WMRunModalFilePanelForDirectory(opanel
, panel
->win
, ipath
,
664 _("Open Image"), NULL
)) {
665 char *path
, *fullpath
;
668 tmp
= WMGetFilePanelFileName(opanel
);
676 path
= wstrdup(fullpath
);
678 tmp2
= strrchr(fullpath
, '/');
682 tmp
= wfindfileinarray(panel
->pathList
, tmp2
);
685 if (strcmp(fullpath
, tmp
)==0) {
692 if (!RGetImageFileFormat(fullpath
)) {
693 WMRunAlertPanel(scr
, panel
->win
, _("Error"),
694 _("The selected file does not contain a supported image."),
695 _("OK"), NULL
, NULL
);
698 updateImage(panel
, fullpath
);
699 wfree(panel
->imageFile
);
700 panel
->imageFile
= path
;
702 WMSetTextFieldText(panel
->imageT
, path
);
710 buttonCallback(WMWidget
*w
, void *data
)
712 TexturePanel
*panel
= (TexturePanel
*)data
;
714 if (w
== panel
->okB
) {
715 (*panel
->okAction
)(panel
->okData
);
717 (*panel
->cancelAction
)(panel
->cancelData
);
724 changeTypeCallback(WMWidget
*w
, void *data
)
726 TexturePanel
*panel
= (TexturePanel
*)data
;
730 newType
= WMGetPopUpButtonSelectedItem(w
);
731 if (newType
== panel
->currentType
)
734 if (panel
->currentType
>= 0) {
735 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
736 if (panel
->sectionParts
[panel
->currentType
][i
] == NULL
)
738 WMUnmapWidget(panel
->sectionParts
[panel
->currentType
][i
]);
742 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
743 if (panel
->sectionParts
[newType
][i
] == NULL
)
745 WMMapWidget(panel
->sectionParts
[newType
][i
]);
747 panel
->currentType
= newType
;
751 updateSGradButtons(panel
);
752 WMSetButtonEnabled(panel
->okB
, True
);
755 updateGradButtons(panel
);
756 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
)>1);
760 updateImage(panel
, NULL
);
761 WMSetButtonEnabled(panel
->okB
, panel
->image
!=NULL
);
764 WMSetButtonEnabled(panel
->okB
, True
);
771 *--------------------------------------------------------------------------
773 *--------------------------------------------------------------------------
776 DestroyTexturePanel(TexturePanel
*panel
)
783 ShowTexturePanel(TexturePanel
*panel
)
785 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(panel
->win
));
786 Screen
*scr
= DefaultScreenOfDisplay(dpy
);
788 WMSetWindowInitialPosition(panel
->win
,
789 (WidthOfScreen(scr
)-WMWidgetWidth(panel
->win
))/2,
790 (HeightOfScreen(scr
)-WMWidgetHeight(panel
->win
))/2);
791 WMMapWidget(panel
->win
);
796 HideTexturePanel(TexturePanel
*panel
)
798 WMUnmapWidget(panel
->win
);
803 SetTexturePanelOkAction(TexturePanel
*panel
, WMCallback
*action
, void *clientData
)
805 panel
->okAction
= action
;
806 panel
->okData
= clientData
;
811 SetTexturePanelCancelAction(TexturePanel
*panel
, WMCallback
*action
, void *clientData
)
813 panel
->cancelAction
= action
;
814 panel
->cancelData
= clientData
;
819 SetTexturePanelTexture(TexturePanel
*panel
, char *name
, proplist_t texture
)
821 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
829 WMSetTextFieldText(panel
->nameT
, name
);
834 p
= PLGetArrayElement(texture
, 0);
838 type
= PLGetString(p
);
840 /*...............................................*/
841 if (strcasecmp(type
, "solid")==0) {
843 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SOLID
);
845 p
= PLGetArrayElement(texture
, 1);
849 str
= PLGetString(p
);
851 color
= WMCreateNamedColor(scr
, str
, False
);
853 WMSetColorWellColor(panel
->defcW
, color
);
855 WMReleaseColor(color
);
856 /*...............................................*/
857 } else if (strcasecmp(type
, "hgradient")==0
858 || strcasecmp(type
, "vgradient")==0
859 || strcasecmp(type
, "dgradient")==0) {
861 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SGRADIENT
);
863 p
= PLGetArrayElement(texture
, 1);
867 str
= PLGetString(p
);
869 color
= WMCreateNamedColor(scr
, str
, False
);
871 WMSetColorWellColor(panel
->tcol1W
, color
);
873 WMReleaseColor(color
);
875 p
= PLGetArrayElement(texture
, 2);
879 str
= PLGetString(p
);
881 color
= WMCreateNamedColor(scr
, str
, False
);
883 WMSetColorWellColor(panel
->tcol2W
, color
);
885 WMReleaseColor(color
);
888 /*...............................................*/
889 } else if (strcasecmp(type
, "thgradient")==0
890 || strcasecmp(type
, "tvgradient")==0
891 || strcasecmp(type
, "tdgradient")==0) {
894 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_TGRADIENT
);
898 WMSetTextFieldText(panel
->imageT
,
899 PLGetString(PLGetArrayElement(texture
, 1)));
900 if (panel
->imageFile
)
901 wfree(panel
->imageFile
);
902 panel
->imageFile
= wstrdup(PLGetString(PLGetArrayElement(texture
, 1)));
906 sscanf(PLGetString(PLGetArrayElement(texture
, 2)), "%i", &i
);
907 WMSetSliderValue(panel
->topaS
, i
);
909 p
= PLGetArrayElement(texture
, 3);
913 str
= PLGetString(p
);
915 color
= WMCreateNamedColor(scr
, str
, False
);
917 WMSetColorWellColor(panel
->tcol1W
, color
);
919 WMReleaseColor(color
);
921 p
= PLGetArrayElement(texture
, 4);
925 str
= PLGetString(p
);
927 color
= WMCreateNamedColor(scr
, str
, False
);
929 WMSetColorWellColor(panel
->tcol2W
, color
);
931 WMReleaseColor(color
);
933 WMSetTextFieldText(panel
->imageT
,
934 PLGetString(PLGetArrayElement(texture
, 1)));
936 if (panel
->imageFile
)
937 wfree(panel
->imageFile
);
938 if ((panel
->imageFile
= wfindfileinarray(panel
->pathList
,
939 PLGetString(PLGetArrayElement(texture
, 1)))) != NULL
) {
941 panel
->image
= RLoadImage(WMScreenRContext(scr
), panel
->imageFile
, 0);
942 updateTGradImage(panel
);
944 updateSGradButtons(panel
);
945 } else wwarning(_("could not load file '%s': %s"), panel
->imageFile
,
946 RMessageForError(RErrorCode
));
948 /*...............................................*/
949 } else if (strcasecmp(type
, "mhgradient")==0
950 || strcasecmp(type
, "mvgradient")==0
951 || strcasecmp(type
, "mdgradient")==0) {
954 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
955 item
= WMGetListItem(panel
->gcolL
, i
);
956 wfree(item
->clientData
);
958 WMClearList(panel
->gcolL
);
960 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_GRADIENT
);
962 p
= PLGetArrayElement(texture
, 1);
966 str
= PLGetString(p
);
968 color
= WMCreateNamedColor(scr
, str
, False
);
970 WMSetColorWellColor(panel
->defcW
, color
);
972 WMReleaseColor(color
);
974 for (i
= 2; i
< PLGetNumberOfElements(texture
); i
++) {
978 p
= PLGetArrayElement(texture
, i
);
982 str
= PLGetString(p
);
985 XParseColor(WMScreenDisplay(scr
), WMScreenRContext(scr
)->cmap
,
988 rgb
= wmalloc(sizeof(RColor
));
989 rgb
->red
= xcolor
.red
>> 8;
990 rgb
->green
= xcolor
.green
>> 8;
991 rgb
->blue
= xcolor
.blue
>> 8;
992 sprintf(buffer
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
994 item
= WMAddListItem(panel
->gcolL
, buffer
);
995 item
->clientData
= rgb
;
998 sliderChangeCallback(panel
->ghueS
, panel
);
1001 /*...............................................*/
1002 } else if (strcasecmp(type
, "cpixmap")==0
1003 || strcasecmp(type
, "spixmap")==0
1004 || strcasecmp(type
, "mpixmap")==0
1005 || strcasecmp(type
, "tpixmap")==0) {
1007 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_PIXMAP
);
1009 switch (toupper(type
[0])) {
1011 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_CENTER
);
1014 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_SCALE
);
1017 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_MAXIMIZE
);
1021 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_TILE
);
1025 WMSetTextFieldText(panel
->imageT
,
1026 PLGetString(PLGetArrayElement(texture
, 1)));
1028 if (panel
->imageFile
)
1029 wfree(panel
->imageFile
);
1030 panel
->imageFile
= wfindfileinarray(panel
->pathList
,
1031 PLGetString(PLGetArrayElement(texture
, 1)));
1033 color
= WMCreateNamedColor(scr
,
1034 PLGetString(PLGetArrayElement(texture
, 2)), False
);
1035 WMSetColorWellColor(panel
->defcW
, color
);
1036 WMReleaseColor(color
);
1038 updateImage(panel
, panel
->imageFile
);
1041 changeTypeCallback(panel
->typeP
, panel
);
1044 updateGradButtons(panel
);
1046 switch (toupper(gradient
)) {
1048 WMPerformButtonClick(panel
->dirhB
);
1051 WMPerformButtonClick(panel
->dirvB
);
1055 WMPerformButtonClick(panel
->dirdB
);
1063 str
= PLGetDescription(texture
);
1064 wwarning(_("error creating texture %s"), str
);
1072 GetTexturePanelTextureName(TexturePanel
*panel
)
1074 return WMGetTextFieldText(panel
->nameT
);
1081 GetTexturePanelTexture(TexturePanel
*panel
)
1083 proplist_t prop
= NULL
;
1090 switch (WMGetPopUpButtonSelectedItem(panel
->typeP
)) {
1093 color
= WMGetColorWellColor(panel
->defcW
);
1094 str
= WMGetColorRGBDescription(color
);
1095 prop
= PLMakeArrayFromElements(PLMakeString("solid"),
1096 PLMakeString(str
), NULL
);
1102 color
= WMGetColorWellColor(panel
->defcW
);
1103 str
= WMGetColorRGBDescription(color
);
1105 switch (WMGetPopUpButtonSelectedItem(panel
->arrP
)) {
1107 prop
= PLMakeArrayFromElements(PLMakeString("spixmap"),
1108 PLMakeString(panel
->imageFile
),
1109 PLMakeString(str
), NULL
);
1111 case PTYPE_MAXIMIZE
:
1112 prop
= PLMakeArrayFromElements(PLMakeString("mpixmap"),
1113 PLMakeString(panel
->imageFile
),
1114 PLMakeString(str
), NULL
);
1117 prop
= PLMakeArrayFromElements(PLMakeString("cpixmap"),
1118 PLMakeString(panel
->imageFile
),
1119 PLMakeString(str
), NULL
);
1122 prop
= PLMakeArrayFromElements(PLMakeString("tpixmap"),
1123 PLMakeString(panel
->imageFile
),
1124 PLMakeString(str
), NULL
);
1130 case TYPE_TGRADIENT
:
1131 color
= WMGetColorWellColor(panel
->tcol1W
);
1132 str
= WMGetColorRGBDescription(color
);
1134 color
= WMGetColorWellColor(panel
->tcol2W
);
1135 str2
= WMGetColorRGBDescription(color
);
1137 sprintf(buff
, "%i", WMGetSliderValue(panel
->topaS
));
1139 if (WMGetButtonSelected(panel
->dirdB
)) {
1140 prop
= PLMakeArrayFromElements(PLMakeString("tdgradient"),
1141 PLMakeString(panel
->imageFile
),
1144 PLMakeString(str2
), NULL
);
1145 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1146 prop
= PLMakeArrayFromElements(PLMakeString("tvgradient"),
1147 PLMakeString(panel
->imageFile
),
1150 PLMakeString(str2
), NULL
);
1152 prop
= PLMakeArrayFromElements(PLMakeString("thgradient"),
1153 PLMakeString(panel
->imageFile
),
1156 PLMakeString(str2
), NULL
);
1163 case TYPE_SGRADIENT
:
1164 color
= WMGetColorWellColor(panel
->tcol1W
);
1165 str
= WMGetColorRGBDescription(color
);
1167 color
= WMGetColorWellColor(panel
->tcol2W
);
1168 str2
= WMGetColorRGBDescription(color
);
1170 if (WMGetButtonSelected(panel
->dirdB
)) {
1171 prop
= PLMakeArrayFromElements(PLMakeString("dgradient"),
1173 PLMakeString(str2
), NULL
);
1174 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1175 prop
= PLMakeArrayFromElements(PLMakeString("vgradient"),
1177 PLMakeString(str2
), NULL
);
1179 prop
= PLMakeArrayFromElements(PLMakeString("hgradient"),
1181 PLMakeString(str2
), NULL
);
1188 color
= WMGetColorWellColor(panel
->defcW
);
1189 str
= WMGetColorRGBDescription(color
);
1191 if (WMGetButtonSelected(panel
->dirdB
)) {
1192 prop
= PLMakeArrayFromElements(PLMakeString("mdgradient"),
1193 PLMakeString(str
), NULL
);
1194 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1195 prop
= PLMakeArrayFromElements(PLMakeString("mvgradient"),
1196 PLMakeString(str
), NULL
);
1198 prop
= PLMakeArrayFromElements(PLMakeString("mhgradient"),
1199 PLMakeString(str
), NULL
);
1203 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
1207 item
= WMGetListItem(panel
->gcolL
, i
);
1209 rgb
= (RColor
*)item
->clientData
;
1211 sprintf(buff
, "#%02x%02x%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
1213 PLAppendArrayElement(prop
, PLMakeString(buff
));
1225 SetTexturePanelPixmapPath(TexturePanel
*panel
, proplist_t array
)
1227 panel
->pathList
= array
;
1233 CreateTexturePanel(WMWindow
*keyWindow
)
1234 /*CreateTexturePanel(WMScreen *scr)*/
1236 TexturePanel
*panel
;
1237 WMScreen
*scr
= WMWidgetScreen(keyWindow
);
1239 panel
= wmalloc(sizeof(TexturePanel
));
1240 memset(panel
, 0, sizeof(TexturePanel
));
1242 panel
->listFont
= WMSystemFontOfSize(scr
, 12);
1245 panel
->win
= WMCreatePanelWithStyleForWindow(keyWindow
, "texturePanel",
1247 |WMClosableWindowMask
);
1249 panel->win = WMCreateWindowWithStyle(scr, "texturePanel",
1251 |WMClosableWindowMask);
1254 WMResizeWidget(panel
->win
, 325, 423);
1255 WMSetWindowTitle(panel
->win
, _("Texture Panel"));
1256 WMSetWindowCloseAction(panel
->win
, buttonCallback
, panel
);
1260 panel
->nameF
= WMCreateFrame(panel
->win
);
1261 WMResizeWidget(panel
->nameF
, 185, 50);
1262 WMMoveWidget(panel
->nameF
, 15, 10);
1263 WMSetFrameTitle(panel
->nameF
, _("Texture Name"));
1265 panel
->nameT
= WMCreateTextField(panel
->nameF
);
1266 WMResizeWidget(panel
->nameT
, 160, 20);
1267 WMMoveWidget(panel
->nameT
, 12, 18);
1269 WMMapSubwidgets(panel
->nameF
);
1272 panel
->typeP
= WMCreatePopUpButton(panel
->win
);
1273 WMResizeWidget(panel
->typeP
, 185, 20);
1274 WMMoveWidget(panel
->typeP
, 15, 65);
1275 WMAddPopUpButtonItem(panel
->typeP
, _("Solid Color"));
1276 WMAddPopUpButtonItem(panel
->typeP
, _("Gradient Texture"));
1277 WMAddPopUpButtonItem(panel
->typeP
, _("Simple Gradient Texture"));
1278 WMAddPopUpButtonItem(panel
->typeP
, _("Textured Gradient"));
1279 WMAddPopUpButtonItem(panel
->typeP
, _("Image Texture"));
1280 WMSetPopUpButtonSelectedItem(panel
->typeP
, 0);
1281 WMSetPopUpButtonAction(panel
->typeP
, changeTypeCallback
, panel
);
1284 panel
->defcF
= WMCreateFrame(panel
->win
);
1285 WMResizeWidget(panel
->defcF
, 100, 75);
1286 WMMoveWidget(panel
->defcF
, 210, 10);
1287 WMSetFrameTitle(panel
->defcF
, _("Default Color"));
1289 panel
->defcW
= WMCreateColorWell(panel
->defcF
);
1290 WMResizeWidget(panel
->defcW
, 60, 45);
1291 WMMoveWidget(panel
->defcW
, 20, 20);
1293 WMMapSubwidgets(panel
->defcF
);
1295 /****** Gradient ******/
1296 panel
->gcolF
= WMCreateFrame(panel
->win
);
1297 WMResizeWidget(panel
->gcolF
, 295, 205);
1298 WMMoveWidget(panel
->gcolF
, 15, 95);
1299 WMSetFrameTitle(panel
->gcolF
, _("Gradient Colors"));
1301 panel
->gcolL
= WMCreateList(panel
->gcolF
);
1302 WMResizeWidget(panel
->gcolL
, 130, 140);
1303 WMMoveWidget(panel
->gcolL
, 10, 25);
1304 WMHangData(panel
->gcolL
, panel
);
1305 WMSetListUserDrawProc(panel
->gcolL
, paintGradListItem
);
1306 WMSetListAction(panel
->gcolL
, gradClickCallback
, panel
);
1308 panel
->gcolaB
= WMCreateCommandButton(panel
->gcolF
);
1309 WMResizeWidget(panel
->gcolaB
, 64, 24);
1310 WMMoveWidget(panel
->gcolaB
, 10, 170);
1311 WMSetButtonText(panel
->gcolaB
, _("Add"));
1312 WMSetButtonAction(panel
->gcolaB
, gradAddCallback
, panel
);
1314 panel
->gcoldB
= WMCreateCommandButton(panel
->gcolF
);
1315 WMResizeWidget(panel
->gcoldB
, 64, 24);
1316 WMMoveWidget(panel
->gcoldB
, 75, 170);
1317 WMSetButtonText(panel
->gcoldB
, _("Delete"));
1318 WMSetButtonAction(panel
->gcoldB
, gradDeleteCallback
, panel
);
1321 panel
->gbriS
= WMCreateSlider(panel
->gcolF
);
1322 WMResizeWidget(panel
->gbriS
, 130, 16);
1323 WMMoveWidget(panel
->gbriS
, 150, 25);
1324 WMSetSliderKnobThickness(panel
->gbriS
, 8);
1325 WMSetSliderMaxValue(panel
->gbriS
, 100);
1326 WMSetSliderAction(panel
->gbriS
, sliderChangeCallback
, panel
);
1331 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1332 color
= WMDarkGrayColor(scr
);
1333 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
),
1334 WMColorGC(color
), 0, 0, 130, 16);
1335 WMReleaseColor(color
);
1336 color
= WMWhiteColor(color
);
1337 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(color
),
1339 (16 - WMFontHeight(panel
->listFont
))/2 - 1,
1341 WMSetSliderImage(panel
->gbriS
, pixmap
);
1342 WMReleasePixmap(pixmap
);
1345 panel
->gconS
= WMCreateSlider(panel
->gcolF
);
1346 WMResizeWidget(panel
->gconS
, 130, 16);
1347 WMMoveWidget(panel
->gconS
, 150, 50);
1348 WMSetSliderKnobThickness(panel
->gconS
, 8);
1349 WMSetSliderMaxValue(panel
->gconS
, 100);
1350 WMSetSliderAction(panel
->gconS
, sliderChangeCallback
, panel
);
1355 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1356 color
= WMDarkGrayColor(scr
);
1357 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
),
1358 WMColorGC(color
), 0, 0, 130, 16);
1359 WMReleaseColor(color
);
1360 color
= WMWhiteColor(scr
);
1361 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(color
),
1363 (16 - WMFontHeight(panel
->listFont
))/2 - 1,
1365 WMSetSliderImage(panel
->gconS
, pixmap
);
1366 WMReleasePixmap(pixmap
);
1369 panel
->ghueS
= WMCreateSlider(panel
->gcolF
);
1370 WMResizeWidget(panel
->ghueS
, 130, 16);
1371 WMMoveWidget(panel
->ghueS
, 150, 100);
1372 WMSetSliderKnobThickness(panel
->ghueS
, 8);
1373 WMSetSliderMaxValue(panel
->ghueS
, 359);
1374 WMSetSliderAction(panel
->ghueS
, sliderChangeCallback
, panel
);
1376 panel
->gsatS
= WMCreateSlider(panel
->gcolF
);
1377 WMResizeWidget(panel
->gsatS
, 130, 16);
1378 WMMoveWidget(panel
->gsatS
, 150, 125);
1379 WMSetSliderKnobThickness(panel
->gsatS
, 8);
1380 WMSetSliderMaxValue(panel
->gsatS
, 255);
1381 WMSetSliderAction(panel
->gsatS
, sliderChangeCallback
, panel
);
1383 panel
->gvalS
= WMCreateSlider(panel
->gcolF
);
1384 WMResizeWidget(panel
->gvalS
, 130, 16);
1385 WMMoveWidget(panel
->gvalS
, 150, 150);
1386 WMSetSliderKnobThickness(panel
->gvalS
, 8);
1387 WMSetSliderMaxValue(panel
->gvalS
, 255);
1388 WMSetSliderAction(panel
->gvalS
, sliderChangeCallback
, panel
);
1391 WMMapSubwidgets(panel
->gcolF
);
1394 panel
->dirF
= WMCreateFrame(panel
->win
);
1395 WMSetFrameTitle(panel
->dirF
, _("Direction"));
1396 WMResizeWidget(panel
->dirF
, 295, 75);
1397 WMMoveWidget(panel
->dirF
, 15, 305);
1399 panel
->dirvB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1400 WMSetButtonImagePosition(panel
->dirvB
, WIPImageOnly
);
1401 WMResizeWidget(panel
->dirvB
, 90, 40);
1402 WMMoveWidget(panel
->dirvB
, 10, 20);
1404 panel
->dirhB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1405 WMSetButtonImagePosition(panel
->dirhB
, WIPImageOnly
);
1406 WMResizeWidget(panel
->dirhB
, 90, 40);
1407 WMMoveWidget(panel
->dirhB
, 102, 20);
1409 panel
->dirdB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1410 WMSetButtonImagePosition(panel
->dirdB
, WIPImageOnly
);
1411 WMResizeWidget(panel
->dirdB
, 90, 40);
1412 WMMoveWidget(panel
->dirdB
, 194, 20);
1414 WMGroupButtons(panel
->dirvB
, panel
->dirhB
);
1415 WMGroupButtons(panel
->dirvB
, panel
->dirdB
);
1417 WMMapSubwidgets(panel
->dirF
);
1419 /****************** Textured Gradient ******************/
1420 panel
->tcolF
= WMCreateFrame(panel
->win
);
1421 WMResizeWidget(panel
->tcolF
, 100, 135);
1422 WMMoveWidget(panel
->tcolF
, 210, 10);
1423 WMSetFrameTitle(panel
->tcolF
, _("Gradient"));
1425 panel
->tcol1W
= WMCreateColorWell(panel
->tcolF
);
1426 WMResizeWidget(panel
->tcol1W
, 60, 45);
1427 WMMoveWidget(panel
->tcol1W
, 20, 25);
1428 WMAddNotificationObserver(colorWellObserver
, panel
,
1429 WMColorWellDidChangeNotification
, panel
->tcol1W
);
1431 panel
->tcol2W
= WMCreateColorWell(panel
->tcolF
);
1432 WMResizeWidget(panel
->tcol2W
, 60, 45);
1433 WMMoveWidget(panel
->tcol2W
, 20, 75);
1434 WMAddNotificationObserver(colorWellObserver
, panel
,
1435 WMColorWellDidChangeNotification
, panel
->tcol2W
);
1438 panel
->topaF
= WMCreateFrame(panel
->win
);
1439 WMResizeWidget(panel
->topaF
, 185, 50);
1440 WMMoveWidget(panel
->topaF
, 15, 95);
1441 WMSetFrameTitle(panel
->topaF
, _("Gradient Opacity"));
1443 panel
->topaS
= WMCreateSlider(panel
->topaF
);
1444 WMResizeWidget(panel
->topaS
, 155, 18);
1445 WMMoveWidget(panel
->topaS
, 15, 20);
1446 WMSetSliderMaxValue(panel
->topaS
, 255);
1447 WMSetSliderValue(panel
->topaS
, 200);
1448 WMSetSliderContinuous(panel
->topaS
, False
);
1449 WMSetSliderAction(panel
->topaS
, opaqChangeCallback
, panel
);
1451 WMMapSubwidgets(panel
->topaF
);
1458 pixmap
= WMCreatePixmap(scr
, 155, 18, WMScreenDepth(scr
), False
);
1459 p
= WMGetPixmapXID(pixmap
);
1461 color
= WMDarkGrayColor(scr
);
1462 XFillRectangle(WMScreenDisplay(scr
), p
, WMColorGC(color
),
1464 WMReleaseColor(color
);
1466 color
= WMWhiteColor(scr
);
1467 WMDrawString(scr
, p
, WMColorGC(color
), panel
->listFont
,
1469 WMDrawString(scr
, p
, WMColorGC(color
), panel
->listFont
,
1470 153 - WMWidthOfString(panel
->listFont
, "100%", 4), 1,
1472 WMReleaseColor(color
);
1474 WMSetSliderImage(panel
->topaS
, pixmap
);
1475 WMReleasePixmap(pixmap
);
1478 WMMapSubwidgets(panel
->tcolF
);
1480 /****************** Image ******************/
1481 panel
->imageF
= WMCreateFrame(panel
->win
);
1482 WMResizeWidget(panel
->imageF
, 295, 150);
1483 WMMoveWidget(panel
->imageF
, 15, 150);
1484 WMSetFrameTitle(panel
->imageF
, _("Image"));
1486 panel
->imageL
= WMCreateLabel(panel
->imageF
);
1487 WMSetLabelImagePosition(panel
->imageL
, WIPImageOnly
);
1489 panel
->imageT
= WMCreateTextField(panel
->imageF
);
1490 WMResizeWidget(panel
->imageT
, 90, 20);
1491 WMMoveWidget(panel
->imageT
, 190, 25);
1493 panel
->imageV
= WMCreateScrollView(panel
->imageF
);
1494 WMResizeWidget(panel
->imageV
, 165, 115);
1495 WMMoveWidget(panel
->imageV
, 15, 20);
1496 WMSetScrollViewRelief(panel
->imageV
, WRSunken
);
1497 WMSetScrollViewHasHorizontalScroller(panel
->imageV
, True
);
1498 WMSetScrollViewHasVerticalScroller(panel
->imageV
, True
);
1499 WMSetScrollViewContentView(panel
->imageV
, WMWidgetView(panel
->imageL
));
1501 panel
->browB
= WMCreateCommandButton(panel
->imageF
);
1502 WMResizeWidget(panel
->browB
, 90, 24);
1503 WMMoveWidget(panel
->browB
, 190, 50);
1504 WMSetButtonText(panel
->browB
, _("Browse..."));
1505 WMSetButtonAction(panel
->browB
, browseImageCallback
, panel
);
1507 /* panel->dispB = WMCreateCommandButton(panel->imageF);
1508 WMResizeWidget(panel->dispB, 90, 24);
1509 WMMoveWidget(panel->dispB, 190, 80);
1510 WMSetButtonText(panel->dispB, _("Show"));
1513 panel
->arrP
= WMCreatePopUpButton(panel
->imageF
);
1514 WMResizeWidget(panel
->arrP
, 90, 20);
1515 WMMoveWidget(panel
->arrP
, 190, 120);
1516 WMAddPopUpButtonItem(panel
->arrP
, _("Tile"));
1517 WMAddPopUpButtonItem(panel
->arrP
, _("Scale"));
1518 WMAddPopUpButtonItem(panel
->arrP
, _("Center"));
1519 WMAddPopUpButtonItem(panel
->arrP
, _("Maximize"));
1520 WMSetPopUpButtonSelectedItem(panel
->arrP
, 0);
1522 WMMapSubwidgets(panel
->imageF
);
1526 panel
->okB
= WMCreateCommandButton(panel
->win
);
1527 WMResizeWidget(panel
->okB
, 84, 24);
1528 WMMoveWidget(panel
->okB
, 225, 390);
1529 WMSetButtonText(panel
->okB
, _("OK"));
1530 WMSetButtonAction(panel
->okB
, buttonCallback
, panel
);
1532 panel
->cancelB
= WMCreateCommandButton(panel
->win
);
1533 WMResizeWidget(panel
->cancelB
, 84, 24);
1534 WMMoveWidget(panel
->cancelB
, 130, 390);
1535 WMSetButtonText(panel
->cancelB
, _("Cancel"));
1536 WMSetButtonAction(panel
->cancelB
, buttonCallback
, panel
);
1538 WMMapWidget(panel
->nameF
);
1539 WMMapWidget(panel
->typeP
);
1540 WMMapWidget(panel
->okB
);
1541 WMMapWidget(panel
->cancelB
);
1543 WMUnmapWidget(panel
->arrP
);
1545 WMRealizeWidget(panel
->win
);
1547 panel
->currentType
= -1;
1549 panel
->sectionParts
[TYPE_SOLID
][0] = panel
->defcF
;
1551 panel
->sectionParts
[TYPE_GRADIENT
][0] = panel
->defcF
;
1552 panel
->sectionParts
[TYPE_GRADIENT
][1] = panel
->gcolF
;
1553 panel
->sectionParts
[TYPE_GRADIENT
][2] = panel
->dirF
;
1555 panel
->sectionParts
[TYPE_SGRADIENT
][0] = panel
->tcolF
;
1556 panel
->sectionParts
[TYPE_SGRADIENT
][1] = panel
->dirF
;
1558 panel
->sectionParts
[TYPE_TGRADIENT
][0] = panel
->tcolF
;
1559 panel
->sectionParts
[TYPE_TGRADIENT
][1] = panel
->dirF
;
1560 panel
->sectionParts
[TYPE_TGRADIENT
][2] = panel
->imageF
;
1561 panel
->sectionParts
[TYPE_TGRADIENT
][3] = panel
->topaF
;
1562 panel
->sectionParts
[TYPE_TGRADIENT
][4] = panel
->arrP
;
1564 panel
->sectionParts
[TYPE_PIXMAP
][0] = panel
->defcF
;
1565 panel
->sectionParts
[TYPE_PIXMAP
][1] = panel
->imageF
;
1566 panel
->sectionParts
[TYPE_PIXMAP
][2] = panel
->arrP
;
1569 /* setup for first time */
1571 changeTypeCallback(panel
->typeP
, panel
);
1573 sliderChangeCallback(panel
->ghueS
, panel
);
1574 sliderChangeCallback(panel
->gsatS
, panel
);
1582 *--------------------------------------------------------------------------
1584 *--------------------------------------------------------------------------
1589 char *ProgName
= "test";
1592 testOKButton(WMWidget
*self
, void *data
)
1600 TexturePanel
*panel
= (TexturePanel
*)data
;
1601 /* test = GetTexturePanelTextureString(panel); */
1605 dpy
= WMScreenDisplay(WMWidgetScreen(panel
->okB
));
1606 win
= XCreateSimpleWindow(dpy
, DefaultRootWindow(dpy
), 10, 10, 250, 250,
1608 XMapRaised(dpy
, win
);
1611 /* image = RenderTexturePanelTexture(panel, 250, 250); */
1613 RConvertImage(WMScreenRContext(WMWidgetScreen(panel
->okB
)), image
, &pix
);
1615 XCopyArea(dpy
, pix
, win
, (WMScreenRContext(WMWidgetScreen(panel
->okB
)))->copy_gc
, 0, 0, image
->width
, image
->height
,
1622 void testCancelButton(WMWidget
*self
, void *data
){
1623 wwarning("Exiting test....");
1632 int main(int argc
, char **argv
)
1634 TexturePanel
*panel
;
1636 Display
*dpy
= XOpenDisplay("");
1641 WMInitializeApplication("Test", &argc
, argv
);
1644 wfatal("could not open display");
1648 scr
= WMCreateSimpleApplicationScreen(dpy
);
1650 panel
= CreateTexturePanel(scr
);
1652 SetTexturePanelOkAction(panel
,(WMAction
*)testOKButton
,panel
);
1653 SetTexturePanelCancelAction(panel
,(WMAction
*)testCancelButton
,panel
);
1655 SetTexturePanelTexture(panel
, "pinky",
1656 PLGetProplistWithDescription("(mdgradient, pink, red, blue, yellow)"));
1658 ShowTexturePanel(panel
);
1660 WMScreenMainLoop(scr
);