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,
39 #include "TexturePanel.h"
42 #define MAX_SECTION_PARTS 4
44 typedef struct _TexturePanel
{
76 /* direction (common) */
82 /*-- Simple Gradient --*/
85 /*-- Textured Gradient --*/
112 WMCallback
*okAction
;
115 WMCallback
*cancelAction
;
119 WMWidget
*sectionParts
[5][MAX_SECTION_PARTS
];
131 #define TYPE_GRADIENT 1
132 #define TYPE_SGRADIENT 2
133 #define TYPE_TGRADIENT 3
134 #define TYPE_PIXMAP 4
138 #define PTYPE_SCALE 1
139 #define PTYPE_CENTER 2
140 #define PTYPE_MAXIMIZE 3
145 *--------------------------------------------------------------------------
147 *--------------------------------------------------------------------------
153 updateGradButtons(TexturePanel
*panel
)
160 colorn
= WMGetListNumberOfRows(panel
->gcolL
);
167 colors
= wmalloc(sizeof(RColor
*)*(colorn
+1));
169 for (i
= 0; i
< colorn
; i
++) {
170 item
= WMGetListItem(panel
->gcolL
, i
);
171 colors
[i
] = (RColor
*)item
->clientData
;
175 image
= RRenderMultiGradient(80, 30, colors
, RHorizontalGradient
);
176 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
178 RDestroyImage(image
);
179 WMSetButtonImage(panel
->dirhB
, pixmap
);
180 WMReleasePixmap(pixmap
);
182 image
= RRenderMultiGradient(80, 30, colors
, RVerticalGradient
);
183 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
185 RDestroyImage(image
);
186 WMSetButtonImage(panel
->dirvB
, pixmap
);
187 WMReleasePixmap(pixmap
);
189 image
= RRenderMultiGradient(80, 30, colors
, RDiagonalGradient
);
190 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
192 RDestroyImage(image
);
193 WMSetButtonImage(panel
->dirdB
, pixmap
);
194 WMReleasePixmap(pixmap
);
203 updateTGradImage(TexturePanel
*panel
)
205 RImage
*image
, *gradient
;
214 color
= WMGetColorWellColor(panel
->tcol1W
);
215 from
.red
= WMRedComponentOfColor(color
)>>8;
216 from
.green
= WMGreenComponentOfColor(color
)>>8;
217 from
.blue
= WMBlueComponentOfColor(color
)>>8;
219 color
= WMGetColorWellColor(panel
->tcol2W
);
220 to
.red
= WMRedComponentOfColor(color
)>>8;
221 to
.green
= WMGreenComponentOfColor(color
)>>8;
222 to
.blue
= WMBlueComponentOfColor(color
)>>8;
224 if (panel
->image
->width
< 141 || panel
->image
->height
< 91) {
225 image
= RMakeTiledImage(panel
->image
, 141, 91);
227 image
= RCloneImage(panel
->image
);
230 if (WMGetButtonSelected(panel
->dirhB
)) {
231 gradient
= RRenderGradient(image
->width
, image
->height
, &from
, &to
,
232 RHorizontalGradient
);
233 } else if (WMGetButtonSelected(panel
->dirvB
)) {
234 gradient
= RRenderGradient(image
->width
, image
->height
, &from
, &to
,
237 gradient
= RRenderGradient(image
->width
, image
->height
, &from
, &to
,
241 RCombineImagesWithOpaqueness(image
, gradient
,
242 WMGetSliderValue(panel
->topaS
));
243 RDestroyImage(gradient
);
244 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->win
),
247 WMSetLabelImage(panel
->imageL
, pixmap
);
248 WMResizeWidget(panel
->imageL
, image
->width
, image
->height
);
249 RDestroyImage(image
);
254 updateSGradButtons(TexturePanel
*panel
)
262 color
= WMGetColorWellColor(panel
->tcol1W
);
263 from
.red
= WMRedComponentOfColor(color
)>>8;
264 from
.green
= WMGreenComponentOfColor(color
)>>8;
265 from
.blue
= WMBlueComponentOfColor(color
)>>8;
267 color
= WMGetColorWellColor(panel
->tcol2W
);
268 to
.red
= WMRedComponentOfColor(color
)>>8;
269 to
.green
= WMGreenComponentOfColor(color
)>>8;
270 to
.blue
= WMBlueComponentOfColor(color
)>>8;
272 image
= RRenderGradient(80, 30, &from
, &to
, RHorizontalGradient
);
273 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
275 RDestroyImage(image
);
276 WMSetButtonImage(panel
->dirhB
, pixmap
);
277 WMReleasePixmap(pixmap
);
279 image
= RRenderGradient(80, 30, &from
, &to
, RVerticalGradient
);
280 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
282 RDestroyImage(image
);
283 WMSetButtonImage(panel
->dirvB
, pixmap
);
284 WMReleasePixmap(pixmap
);
286 image
= RRenderGradient(80, 30, &from
, &to
, RDiagonalGradient
);
287 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
289 RDestroyImage(image
);
290 WMSetButtonImage(panel
->dirdB
, pixmap
);
291 WMReleasePixmap(pixmap
);
295 /*********** Gradient ************/
298 updateSVSlider(WMSlider
*sPtr
, Bool saturation
, WMFont
*font
, RHSVColor
*hsv
)
302 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 RDestroyImage(image
);
322 if (hsv
->value
< 128 || !saturation
) {
323 WMColor
*col
= WMWhiteColor(scr
);
325 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
326 (16 - WMFontHeight(font
))/2 - 1,
327 saturation
? "Saturation" : "Brightness", 10);
330 WMColor
*col
= WMBlackColor(scr
);
332 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
333 (16 - WMFontHeight(font
))/2 - 1,
334 saturation
? "Saturation" : "Brightness", 10);
337 WMSetSliderImage(sPtr
, pixmap
);
338 WMReleasePixmap(pixmap
);
343 updateHueSlider(WMSlider
*sPtr
, WMFont
*font
, RHSVColor
*hsv
)
348 WMScreen
*scr
= WMWidgetScreen(sPtr
);
353 for (i
= 0; i
<= 6; i
++) {
354 thsv
.hue
= (360*i
)/6;
355 colors
[i
] = wmalloc(sizeof(RColor
));
356 RHSVtoRGB(&thsv
, colors
[i
]);
360 image
= RRenderMultiGradient(130, 16, colors
, RGRD_HORIZONTAL
);
361 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
362 RDestroyImage(image
);
364 if (hsv
->value
< 128) {
365 WMColor
*col
= WMWhiteColor(scr
);
367 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
368 (16 - WMFontHeight(font
))/2 - 1, "Hue", 3);
371 WMColor
*col
= WMBlackColor(scr
);
373 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
374 (16 - WMFontHeight(font
))/2 - 1, "Hue", 3);
377 WMSetSliderImage(sPtr
, pixmap
);
378 WMReleasePixmap(pixmap
);
380 for (i
= 0; i
<= 6; i
++)
387 sliderChangeCallback(WMWidget
*w
, void *data
)
389 TexturePanel
*panel
= (TexturePanel
*)data
;
390 RHSVColor hsv
, *hsvp
;
396 WMScreen
*scr
= WMWidgetScreen(w
);
398 hsv
.hue
= WMGetSliderValue(panel
->ghueS
);
399 hsv
.saturation
= WMGetSliderValue(panel
->gsatS
);
400 hsv
.value
= WMGetSliderValue(panel
->gvalS
);
402 row
= WMGetListSelectedItemRow(panel
->gcolL
);
406 item
= WMGetListItem(panel
->gcolL
, row
);
408 rgb
= (RColor
*)item
->clientData
;
410 RHSVtoRGB(&hsv
, rgb
);
412 sprintf(item
->text
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
415 if (w
== panel
->ghueS
) {
416 updateSVSlider(panel
->gsatS
, True
, panel
->listFont
, &hsv
);
417 updateSVSlider(panel
->gvalS
, False
, panel
->listFont
, &hsv
);
418 } else if (w
== panel
->gsatS
) {
419 updateHueSlider(panel
->ghueS
, panel
->listFont
, &hsv
);
420 updateSVSlider(panel
->gvalS
, False
, panel
->listFont
, &hsv
);
422 updateHueSlider(panel
->ghueS
, panel
->listFont
, &hsv
);
423 updateSVSlider(panel
->gsatS
, True
, panel
->listFont
, &hsv
);
426 rows
= WMGetListNumberOfRows(panel
->gcolL
);
430 colors
= wmalloc(sizeof(RColor
*)*(rows
+1));
432 for (i
= 0; i
< rows
; i
++) {
433 item
= WMGetListItem(panel
->gcolL
, i
);
435 colors
[i
] = (RColor
*)item
->clientData
;
439 if (panel
->gimage
!= None
) {
440 XFreePixmap(WMScreenDisplay(scr
), panel
->gimage
);
443 image
= RRenderMultiGradient(30, i
*WMGetListItemHeight(panel
->gcolL
),
444 colors
, RVerticalGradient
);
445 RConvertImage(WMScreenRContext(scr
), image
, &panel
->gimage
);
446 RDestroyImage(image
);
450 WMRedisplayWidget(panel
->gcolL
);
452 updateGradButtons(panel
);
457 paintGradListItem(WMList
*lPtr
, int index
, Drawable d
, char *text
, int state
,
460 TexturePanel
*panel
= (TexturePanel
*)WMGetHangedData(lPtr
);
461 WMScreen
*scr
= WMWidgetScreen(lPtr
);
462 int width
, height
, x
, y
;
464 WMColor
*white
= WMWhiteColor(scr
);
466 WMColor
*black
= WMBlackColor(scr
);
468 dpy
= WMScreenDisplay(scr
);
470 width
= rect
->size
.width
;
471 height
= rect
->size
.height
;
475 if (state
& WLDSSelected
)
476 XFillRectangle(dpy
, d
, WMColorGC(white
), x
, y
, width
, height
);
478 XClearArea(dpy
, d
, x
, y
, width
, height
, False
);
480 item
= WMGetListItem(lPtr
, index
);
483 XCopyArea(WMScreenDisplay(scr
), panel
->gimage
, d
, WMColorGC(white
),
484 0, height
*index
, 30, height
, x
+ 5, y
);
486 WMDrawString(scr
, d
, WMColorGC(black
), panel
->listFont
,
487 x
+ 40, y
+ 1, text
, strlen(text
));
489 WMReleaseColor(white
);
490 WMReleaseColor(black
);
496 gradAddCallback(WMWidget
*w
, void *data
)
498 TexturePanel
*panel
= (TexturePanel
*)data
;
503 row
= WMGetListSelectedItemRow(panel
->gcolL
) + 1;
504 item
= WMInsertListItem(panel
->gcolL
, row
, "00,00,00");
505 rgb
= wmalloc(sizeof(RColor
));
506 memset(rgb
, 0, sizeof(RColor
));
507 item
->clientData
= rgb
;
509 WMSelectListItem(panel
->gcolL
, row
);
511 updateGradButtons(panel
);
513 sliderChangeCallback(panel
->ghueS
, panel
);
519 gradClickCallback(WMWidget
*w
, void *data
)
521 TexturePanel
*panel
= (TexturePanel
*)data
;
526 row
= WMGetListSelectedItemRow(w
);
530 item
= WMGetListItem(panel
->gcolL
, row
);
531 RRGBtoHSV((RColor
*)item
->clientData
, &hsv
);
533 WMSetSliderValue(panel
->ghueS
, hsv
.hue
);
534 WMSetSliderValue(panel
->gsatS
, hsv
.saturation
);
535 WMSetSliderValue(panel
->gvalS
, hsv
.value
);
537 sliderChangeCallback(panel
->ghueS
, panel
);
538 sliderChangeCallback(panel
->gsatS
, panel
);
543 gradDeleteCallback(WMWidget
*w
, void *data
)
545 TexturePanel
*panel
= (TexturePanel
*)data
;
549 row
= WMGetListSelectedItemRow(panel
->gcolL
);
553 item
= WMGetListItem(panel
->gcolL
, row
);
554 free(item
->clientData
);
556 WMRemoveListItem(panel
->gcolL
, row
);
558 WMSelectListItem(panel
->gcolL
, row
- 1);
560 updateGradButtons(panel
);
562 gradClickCallback(panel
->gcolL
, panel
);
566 /*************** Simple Gradient ***************/
569 colorWellObserver(void *self
, WMNotification
*n
)
571 updateSGradButtons(self
);
578 opaqChangeCallback(WMWidget
*w
, void *data
)
580 TexturePanel
*panel
= (TexturePanel
*)data
;
582 updateTGradImage(panel
);
585 /****************** Image ******************/
588 updateImage(TexturePanel
*panel
, char *path
)
590 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
591 RImage
*image
, *scaled
;
596 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
600 message
= wstrappend(_("Could not load the selected file: "),
601 (char*)RMessageForError(RErrorCode
));
603 WMRunAlertPanel(scr
, panel
->win
, _("Error"), message
,
604 _("OK"), NULL
, NULL
);
609 RDestroyImage(panel
->image
);
610 panel
->image
= image
;
612 image
= panel
->image
;
615 if (WMGetPopUpButtonSelectedItem(panel
->typeP
) == TYPE_PIXMAP
) {
617 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
619 size
= WMGetPixmapSize(pixmap
);
620 WMSetLabelImage(panel
->imageL
, pixmap
);
621 WMResizeWidget(panel
->imageL
, size
.width
, size
.height
);
623 WMReleasePixmap(pixmap
);
626 updateTGradImage(panel
);
632 browseImageCallback(WMWidget
*w
, void *data
)
634 TexturePanel
*panel
= (TexturePanel
*)data
;
636 WMScreen
*scr
= WMWidgetScreen(w
);
637 static char *ipath
= NULL
;
639 opanel
= WMGetOpenPanel(scr
);
640 WMSetFilePanelCanChooseDirectories(opanel
, False
);
641 WMSetFilePanelCanChooseFiles(opanel
, True
);
644 ipath
= wstrdup(wgethomedir());
646 if (WMRunModalFilePanelForDirectory(opanel
, panel
->win
, ipath
,
647 "Open Image", NULL
)) {
648 char *path
, *fullpath
;
651 tmp
= WMGetFilePanelFileName(opanel
);
659 path
= wstrdup(fullpath
);
661 tmp2
= strrchr(fullpath
, '/');
665 tmp
= wfindfileinarray(panel
->pathList
, tmp2
);
668 if (strcmp(fullpath
, tmp
)==0) {
675 if (!RGetImageFileFormat(fullpath
)) {
676 WMRunAlertPanel(scr
, panel
->win
, _("Error"),
677 _("The selected file does not contain a supported image."),
678 _("OK"), NULL
, NULL
);
681 updateImage(panel
, fullpath
);
682 free(panel
->imageFile
);
683 panel
->imageFile
= path
;
685 WMSetTextFieldText(panel
->imageT
, path
);
693 buttonCallback(WMWidget
*w
, void *data
)
695 TexturePanel
*panel
= (TexturePanel
*)data
;
697 if (w
== panel
->okB
) {
698 (*panel
->okAction
)(panel
->okData
);
700 (*panel
->cancelAction
)(panel
->cancelData
);
707 changeTypeCallback(WMWidget
*w
, void *data
)
709 TexturePanel
*panel
= (TexturePanel
*)data
;
713 newType
= WMGetPopUpButtonSelectedItem(w
);
714 if (newType
== panel
->currentType
)
717 if (panel
->currentType
>= 0) {
718 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
719 if (panel
->sectionParts
[panel
->currentType
][i
] == NULL
)
721 WMUnmapWidget(panel
->sectionParts
[panel
->currentType
][i
]);
725 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
726 if (panel
->sectionParts
[newType
][i
] == NULL
)
728 WMMapWidget(panel
->sectionParts
[newType
][i
]);
730 panel
->currentType
= newType
;
734 updateSGradButtons(panel
);
737 updateGradButtons(panel
);
741 updateImage(panel
, NULL
);
748 *--------------------------------------------------------------------------
750 *--------------------------------------------------------------------------
753 DestroyTexturePanel(TexturePanel
*panel
)
760 ShowTexturePanel(TexturePanel
*panel
)
762 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(panel
->win
));
763 Screen
*scr
= DefaultScreenOfDisplay(dpy
);
765 WMSetWindowUPosition(panel
->win
,
766 (WidthOfScreen(scr
)-WMWidgetWidth(panel
->win
))/2,
767 (HeightOfScreen(scr
)-WMWidgetHeight(panel
->win
))/2);
768 WMMapWidget(panel
->win
);
773 HideTexturePanel(TexturePanel
*panel
)
775 WMUnmapWidget(panel
->win
);
780 SetTexturePanelOkAction(TexturePanel
*panel
, WMCallback
*action
, void *clientData
)
782 panel
->okAction
= action
;
783 panel
->okData
= clientData
;
788 SetTexturePanelCancelAction(TexturePanel
*panel
, WMCallback
*action
, void *clientData
)
790 panel
->cancelAction
= action
;
791 panel
->cancelData
= clientData
;
796 SetTexturePanelTexture(TexturePanel
*panel
, char *name
, proplist_t texture
)
798 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
806 WMSetTextFieldText(panel
->nameT
, name
);
811 p
= PLGetArrayElement(texture
, 0);
815 type
= PLGetString(p
);
817 /*...............................................*/
818 if (strcasecmp(type
, "solid")==0) {
820 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SOLID
);
822 p
= PLGetArrayElement(texture
, 1);
826 str
= PLGetString(p
);
828 color
= WMCreateNamedColor(scr
, str
, False
);
830 WMSetColorWellColor(panel
->defcW
, color
);
832 WMReleaseColor(color
);
833 /*...............................................*/
834 } else if (strcasecmp(type
, "hgradient")==0
835 || strcasecmp(type
, "vgradient")==0
836 || strcasecmp(type
, "dgradient")==0) {
838 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SGRADIENT
);
840 p
= PLGetArrayElement(texture
, 1);
844 str
= PLGetString(p
);
846 color
= WMCreateNamedColor(scr
, str
, False
);
848 WMSetColorWellColor(panel
->tcol1W
, color
);
850 WMReleaseColor(color
);
852 p
= PLGetArrayElement(texture
, 2);
856 str
= PLGetString(p
);
858 color
= WMCreateNamedColor(scr
, str
, False
);
860 WMSetColorWellColor(panel
->tcol2W
, color
);
862 WMReleaseColor(color
);
865 /*...............................................*/
866 } else if (strcasecmp(type
, "thgradient")==0
867 || strcasecmp(type
, "tvgradient")==0
868 || strcasecmp(type
, "tdgradient")==0) {
871 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_TGRADIENT
);
875 WMSetTextFieldText(panel
->imageT
,
876 PLGetString(PLGetArrayElement(texture
, 1)));
877 if (panel
->imageFile
)
878 free(panel
->imageFile
);
879 panel
->imageFile
= wstrdup(PLGetString(PLGetArrayElement(texture
, 1)));
883 sscanf(PLGetString(PLGetArrayElement(texture
, 2)), "%i", &i
);
884 WMSetSliderValue(panel
->topaS
, i
);
886 p
= PLGetArrayElement(texture
, 3);
890 str
= PLGetString(p
);
892 color
= WMCreateNamedColor(scr
, str
, False
);
894 WMSetColorWellColor(panel
->tcol1W
, color
);
896 WMReleaseColor(color
);
898 p
= PLGetArrayElement(texture
, 4);
902 str
= PLGetString(p
);
904 color
= WMCreateNamedColor(scr
, str
, False
);
906 WMSetColorWellColor(panel
->tcol2W
, color
);
908 WMReleaseColor(color
);
910 WMSetTextFieldText(panel
->imageT
,
911 PLGetString(PLGetArrayElement(texture
, 1)));
913 if (panel
->imageFile
)
914 free(panel
->imageFile
);
915 panel
->imageFile
= wfindfileinarray(panel
->pathList
,
916 PLGetString(PLGetArrayElement(texture
, 1)));
918 panel
->image
= RLoadImage(WMScreenRContext(scr
), panel
->imageFile
, 0);
919 updateTGradImage(panel
);
921 updateSGradButtons(panel
);
923 /*...............................................*/
924 } else if (strcasecmp(type
, "mhgradient")==0
925 || strcasecmp(type
, "mvgradient")==0
926 || strcasecmp(type
, "mdgradient")==0) {
929 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
930 item
= WMGetListItem(panel
->gcolL
, i
);
931 free(item
->clientData
);
933 WMClearList(panel
->gcolL
);
935 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_GRADIENT
);
937 p
= PLGetArrayElement(texture
, 1);
941 str
= PLGetString(p
);
943 color
= WMCreateNamedColor(scr
, str
, False
);
945 WMSetColorWellColor(panel
->defcW
, color
);
947 WMReleaseColor(color
);
949 for (i
= 2; i
< PLGetNumberOfElements(texture
); i
++) {
953 p
= PLGetArrayElement(texture
, i
);
957 str
= PLGetString(p
);
960 XParseColor(WMScreenDisplay(scr
), WMScreenRContext(scr
)->cmap
,
963 rgb
= wmalloc(sizeof(RColor
));
964 rgb
->red
= xcolor
.red
>> 8;
965 rgb
->green
= xcolor
.green
>> 8;
966 rgb
->blue
= xcolor
.blue
>> 8;
967 sprintf(buffer
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
969 item
= WMAddListItem(panel
->gcolL
, buffer
);
970 item
->clientData
= rgb
;
973 sliderChangeCallback(panel
->ghueS
, panel
);
976 /*...............................................*/
977 } else if (strcasecmp(type
, "cpixmap")==0
978 || strcasecmp(type
, "spixmap")==0
979 || strcasecmp(type
, "mpixmap")==0
980 || strcasecmp(type
, "tpixmap")==0) {
982 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_PIXMAP
);
984 switch (toupper(type
[0])) {
986 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_CENTER
);
989 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_SCALE
);
992 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_MAXIMIZE
);
996 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_TILE
);
1000 WMSetTextFieldText(panel
->imageT
,
1001 PLGetString(PLGetArrayElement(texture
, 1)));
1003 if (panel
->imageFile
)
1004 free(panel
->imageFile
);
1005 panel
->imageFile
= wfindfileinarray(panel
->pathList
,
1006 PLGetString(PLGetArrayElement(texture
, 1)));
1008 color
= WMCreateNamedColor(scr
,
1009 PLGetString(PLGetArrayElement(texture
, 2)), False
);
1010 WMSetColorWellColor(panel
->defcW
, color
);
1011 WMReleaseColor(color
);
1013 updateImage(panel
, panel
->imageFile
);
1016 changeTypeCallback(panel
->typeP
, panel
);
1019 updateGradButtons(panel
);
1021 switch (toupper(gradient
)) {
1023 WMPerformButtonClick(panel
->dirhB
);
1026 WMPerformButtonClick(panel
->dirvB
);
1030 WMPerformButtonClick(panel
->dirdB
);
1038 str
= PLGetDescription(texture
);
1039 wwarning("error creating texture %s", str
);
1047 GetTexturePanelTextureName(TexturePanel
*panel
)
1049 return WMGetTextFieldText(panel
->nameT
);
1056 GetTexturePanelTexture(TexturePanel
*panel
)
1058 proplist_t prop
= NULL
;
1065 switch (WMGetPopUpButtonSelectedItem(panel
->typeP
)) {
1068 color
= WMGetColorWellColor(panel
->defcW
);
1069 str
= WMGetColorRGBDescription(color
);
1070 prop
= PLMakeArrayFromElements(PLMakeString("solid"),
1071 PLMakeString(str
), NULL
);
1077 color
= WMGetColorWellColor(panel
->defcW
);
1078 str
= WMGetColorRGBDescription(color
);
1080 switch (WMGetPopUpButtonSelectedItem(panel
->arrP
)) {
1082 prop
= PLMakeArrayFromElements(PLMakeString("spixmap"),
1083 PLMakeString(panel
->imageFile
),
1084 PLMakeString(str
), NULL
);
1086 case PTYPE_MAXIMIZE
:
1087 prop
= PLMakeArrayFromElements(PLMakeString("mpixmap"),
1088 PLMakeString(panel
->imageFile
),
1089 PLMakeString(str
), NULL
);
1092 prop
= PLMakeArrayFromElements(PLMakeString("cpixmap"),
1093 PLMakeString(panel
->imageFile
),
1094 PLMakeString(str
), NULL
);
1097 prop
= PLMakeArrayFromElements(PLMakeString("tpixmap"),
1098 PLMakeString(panel
->imageFile
),
1099 PLMakeString(str
), NULL
);
1105 case TYPE_TGRADIENT
:
1106 color
= WMGetColorWellColor(panel
->tcol1W
);
1107 str
= WMGetColorRGBDescription(color
);
1109 color
= WMGetColorWellColor(panel
->tcol2W
);
1110 str2
= WMGetColorRGBDescription(color
);
1112 sprintf(buff
, "%i", WMGetSliderValue(panel
->topaS
));
1114 if (WMGetButtonSelected(panel
->dirdB
)) {
1115 prop
= PLMakeArrayFromElements(PLMakeString("tdgradient"),
1116 PLMakeString(panel
->imageFile
),
1119 PLMakeString(str2
), NULL
);
1120 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1121 prop
= PLMakeArrayFromElements(PLMakeString("tvgradient"),
1122 PLMakeString(panel
->imageFile
),
1125 PLMakeString(str2
), NULL
);
1127 prop
= PLMakeArrayFromElements(PLMakeString("thgradient"),
1128 PLMakeString(panel
->imageFile
),
1131 PLMakeString(str2
), NULL
);
1138 case TYPE_SGRADIENT
:
1139 color
= WMGetColorWellColor(panel
->tcol1W
);
1140 str
= WMGetColorRGBDescription(color
);
1142 color
= WMGetColorWellColor(panel
->tcol2W
);
1143 str2
= WMGetColorRGBDescription(color
);
1145 if (WMGetButtonSelected(panel
->dirdB
)) {
1146 prop
= PLMakeArrayFromElements(PLMakeString("dgradient"),
1148 PLMakeString(str2
), NULL
);
1149 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1150 prop
= PLMakeArrayFromElements(PLMakeString("vgradient"),
1152 PLMakeString(str2
), NULL
);
1154 prop
= PLMakeArrayFromElements(PLMakeString("hgradient"),
1156 PLMakeString(str2
), NULL
);
1163 color
= WMGetColorWellColor(panel
->defcW
);
1164 str
= WMGetColorRGBDescription(color
);
1166 if (WMGetButtonSelected(panel
->dirdB
)) {
1167 prop
= PLMakeArrayFromElements(PLMakeString("mdgradient"),
1168 PLMakeString(str
), NULL
);
1169 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1170 prop
= PLMakeArrayFromElements(PLMakeString("mvgradient"),
1171 PLMakeString(str
), NULL
);
1173 prop
= PLMakeArrayFromElements(PLMakeString("mhgradient"),
1174 PLMakeString(str
), NULL
);
1178 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
1182 item
= WMGetListItem(panel
->gcolL
, i
);
1184 rgb
= (RColor
*)item
->clientData
;
1186 sprintf(buff
, "#%02x%02x%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
1188 PLAppendArrayElement(prop
, PLMakeString(buff
));
1200 SetTexturePanelPixmapPath(TexturePanel
*panel
, proplist_t array
)
1202 panel
->pathList
= array
;
1208 CreateTexturePanel(WMWindow
*keyWindow
)
1209 /*CreateTexturePanel(WMScreen *scr)*/
1211 TexturePanel
*panel
;
1212 WMScreen
*scr
= WMWidgetScreen(keyWindow
);
1214 panel
= wmalloc(sizeof(TexturePanel
));
1215 memset(panel
, 0, sizeof(TexturePanel
));
1217 panel
->listFont
= WMSystemFontOfSize(scr
, 12);
1220 panel
->win
= WMCreatePanelWithStyleForWindow(keyWindow
, "texturePanel",
1222 |WMClosableWindowMask
);
1224 panel->win = WMCreateWindowWithStyle(scr, "texturePanel",
1226 |WMClosableWindowMask);
1229 WMResizeWidget(panel
->win
, 325, 423);
1230 WMSetWindowTitle(panel
->win
, _("Texture Panel"));
1231 WMSetWindowCloseAction(panel
->win
, buttonCallback
, panel
);
1235 panel
->nameF
= WMCreateFrame(panel
->win
);
1236 WMResizeWidget(panel
->nameF
, 185, 50);
1237 WMMoveWidget(panel
->nameF
, 15, 10);
1238 WMSetFrameTitle(panel
->nameF
, _("Texture Name"));
1240 panel
->nameT
= WMCreateTextField(panel
->nameF
);
1241 WMResizeWidget(panel
->nameT
, 160, 20);
1242 WMMoveWidget(panel
->nameT
, 12, 18);
1244 WMMapSubwidgets(panel
->nameF
);
1247 panel
->typeP
= WMCreatePopUpButton(panel
->win
);
1248 WMResizeWidget(panel
->typeP
, 185, 20);
1249 WMMoveWidget(panel
->typeP
, 15, 65);
1250 WMAddPopUpButtonItem(panel
->typeP
, _("Solid Color"));
1251 WMAddPopUpButtonItem(panel
->typeP
, _("Gradient Texture"));
1252 WMAddPopUpButtonItem(panel
->typeP
, _("Simple Gradient Texture"));
1253 WMAddPopUpButtonItem(panel
->typeP
, _("Textured Gradient"));
1254 WMAddPopUpButtonItem(panel
->typeP
, _("Image Texture"));
1255 WMSetPopUpButtonSelectedItem(panel
->typeP
, 0);
1256 WMSetPopUpButtonAction(panel
->typeP
, changeTypeCallback
, panel
);
1259 panel
->defcF
= WMCreateFrame(panel
->win
);
1260 WMResizeWidget(panel
->defcF
, 100, 75);
1261 WMMoveWidget(panel
->defcF
, 210, 10);
1262 WMSetFrameTitle(panel
->defcF
, _("Default Color"));
1264 panel
->defcW
= WMCreateColorWell(panel
->defcF
);
1265 WMResizeWidget(panel
->defcW
, 60, 45);
1266 WMMoveWidget(panel
->defcW
, 20, 20);
1268 WMMapSubwidgets(panel
->defcF
);
1270 /****** Gradient ******/
1271 panel
->gcolF
= WMCreateFrame(panel
->win
);
1272 WMResizeWidget(panel
->gcolF
, 295, 205);
1273 WMMoveWidget(panel
->gcolF
, 15, 95);
1274 WMSetFrameTitle(panel
->gcolF
, _("Gradient Colors"));
1276 panel
->gcolL
= WMCreateList(panel
->gcolF
);
1277 WMResizeWidget(panel
->gcolL
, 130, 140);
1278 WMMoveWidget(panel
->gcolL
, 10, 25);
1279 WMHangData(panel
->gcolL
, panel
);
1280 WMSetListUserDrawProc(panel
->gcolL
, paintGradListItem
);
1281 WMSetListAction(panel
->gcolL
, gradClickCallback
, panel
);
1283 panel
->gcolaB
= WMCreateCommandButton(panel
->gcolF
);
1284 WMResizeWidget(panel
->gcolaB
, 64, 24);
1285 WMMoveWidget(panel
->gcolaB
, 10, 170);
1286 WMSetButtonText(panel
->gcolaB
, _("Add"));
1287 WMSetButtonAction(panel
->gcolaB
, gradAddCallback
, panel
);
1289 panel
->gcoldB
= WMCreateCommandButton(panel
->gcolF
);
1290 WMResizeWidget(panel
->gcoldB
, 64, 24);
1291 WMMoveWidget(panel
->gcoldB
, 75, 170);
1292 WMSetButtonText(panel
->gcoldB
, _("Delete"));
1293 WMSetButtonAction(panel
->gcoldB
, gradDeleteCallback
, panel
);
1296 panel
->gbriS
= WMCreateSlider(panel
->gcolF
);
1297 WMResizeWidget(panel
->gbriS
, 130, 16);
1298 WMMoveWidget(panel
->gbriS
, 150, 25);
1299 WMSetSliderKnobThickness(panel
->gbriS
, 8);
1300 WMSetSliderMaxValue(panel
->gbriS
, 100);
1301 WMSetSliderAction(panel
->gbriS
, sliderChangeCallback
, panel
);
1306 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1307 color
= WMDarkGrayColor(scr
);
1308 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
),
1309 WMColorGC(color
), 0, 0, 130, 16);
1310 WMReleaseColor(color
);
1311 color
= WMWhiteColor(color
);
1312 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(color
),
1314 (16 - WMFontHeight(panel
->listFont
))/2 - 1,
1316 WMSetSliderImage(panel
->gbriS
, pixmap
);
1317 WMReleasePixmap(pixmap
);
1320 panel
->gconS
= WMCreateSlider(panel
->gcolF
);
1321 WMResizeWidget(panel
->gconS
, 130, 16);
1322 WMMoveWidget(panel
->gconS
, 150, 50);
1323 WMSetSliderKnobThickness(panel
->gconS
, 8);
1324 WMSetSliderMaxValue(panel
->gconS
, 100);
1325 WMSetSliderAction(panel
->gconS
, sliderChangeCallback
, panel
);
1330 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1331 color
= WMDarkGrayColor(scr
);
1332 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
),
1333 WMColorGC(color
), 0, 0, 130, 16);
1334 WMReleaseColor(color
);
1335 color
= WMWhiteColor(scr
);
1336 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(color
),
1338 (16 - WMFontHeight(panel
->listFont
))/2 - 1,
1340 WMSetSliderImage(panel
->gconS
, pixmap
);
1341 WMReleasePixmap(pixmap
);
1344 panel
->ghueS
= WMCreateSlider(panel
->gcolF
);
1345 WMResizeWidget(panel
->ghueS
, 130, 16);
1346 WMMoveWidget(panel
->ghueS
, 150, 100);
1347 WMSetSliderKnobThickness(panel
->ghueS
, 8);
1348 WMSetSliderMaxValue(panel
->ghueS
, 359);
1349 WMSetSliderAction(panel
->ghueS
, sliderChangeCallback
, panel
);
1351 panel
->gsatS
= WMCreateSlider(panel
->gcolF
);
1352 WMResizeWidget(panel
->gsatS
, 130, 16);
1353 WMMoveWidget(panel
->gsatS
, 150, 125);
1354 WMSetSliderKnobThickness(panel
->gsatS
, 8);
1355 WMSetSliderMaxValue(panel
->gsatS
, 255);
1356 WMSetSliderAction(panel
->gsatS
, sliderChangeCallback
, panel
);
1358 panel
->gvalS
= WMCreateSlider(panel
->gcolF
);
1359 WMResizeWidget(panel
->gvalS
, 130, 16);
1360 WMMoveWidget(panel
->gvalS
, 150, 150);
1361 WMSetSliderKnobThickness(panel
->gvalS
, 8);
1362 WMSetSliderMaxValue(panel
->gvalS
, 255);
1363 WMSetSliderAction(panel
->gvalS
, sliderChangeCallback
, panel
);
1366 WMMapSubwidgets(panel
->gcolF
);
1369 panel
->dirF
= WMCreateFrame(panel
->win
);
1370 WMSetFrameTitle(panel
->dirF
, _("Direction"));
1371 WMResizeWidget(panel
->dirF
, 295, 75);
1372 WMMoveWidget(panel
->dirF
, 15, 305);
1374 panel
->dirvB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1375 WMSetButtonImagePosition(panel
->dirvB
, WIPImageOnly
);
1376 WMResizeWidget(panel
->dirvB
, 90, 40);
1377 WMMoveWidget(panel
->dirvB
, 10, 20);
1379 panel
->dirhB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1380 WMSetButtonImagePosition(panel
->dirhB
, WIPImageOnly
);
1381 WMResizeWidget(panel
->dirhB
, 90, 40);
1382 WMMoveWidget(panel
->dirhB
, 102, 20);
1384 panel
->dirdB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1385 WMSetButtonImagePosition(panel
->dirdB
, WIPImageOnly
);
1386 WMResizeWidget(panel
->dirdB
, 90, 40);
1387 WMMoveWidget(panel
->dirdB
, 194, 20);
1389 WMGroupButtons(panel
->dirvB
, panel
->dirhB
);
1390 WMGroupButtons(panel
->dirvB
, panel
->dirdB
);
1392 WMMapSubwidgets(panel
->dirF
);
1394 /****************** Textured Gradient ******************/
1395 panel
->tcolF
= WMCreateFrame(panel
->win
);
1396 WMResizeWidget(panel
->tcolF
, 100, 135);
1397 WMMoveWidget(panel
->tcolF
, 210, 10);
1398 WMSetFrameTitle(panel
->tcolF
, _("Gradient"));
1400 panel
->tcol1W
= WMCreateColorWell(panel
->tcolF
);
1401 WMResizeWidget(panel
->tcol1W
, 60, 45);
1402 WMMoveWidget(panel
->tcol1W
, 20, 25);
1403 WMAddNotificationObserver(colorWellObserver
, panel
,
1404 WMColorWellDidChangeNotification
, panel
->tcol1W
);
1406 panel
->tcol2W
= WMCreateColorWell(panel
->tcolF
);
1407 WMResizeWidget(panel
->tcol2W
, 60, 45);
1408 WMMoveWidget(panel
->tcol2W
, 20, 75);
1409 WMAddNotificationObserver(colorWellObserver
, panel
,
1410 WMColorWellDidChangeNotification
, panel
->tcol2W
);
1413 panel
->topaF
= WMCreateFrame(panel
->win
);
1414 WMResizeWidget(panel
->topaF
, 185, 50);
1415 WMMoveWidget(panel
->topaF
, 15, 95);
1416 WMSetFrameTitle(panel
->topaF
, _("Gradient Opacity"));
1418 panel
->topaS
= WMCreateSlider(panel
->topaF
);
1419 WMResizeWidget(panel
->topaS
, 155, 18);
1420 WMMoveWidget(panel
->topaS
, 15, 20);
1421 WMSetSliderMaxValue(panel
->topaS
, 255);
1422 WMSetSliderValue(panel
->topaS
, 200);
1423 WMSetSliderContinuous(panel
->topaS
, False
);
1424 WMSetSliderAction(panel
->topaS
, opaqChangeCallback
, panel
);
1426 WMMapSubwidgets(panel
->topaF
);
1433 pixmap
= WMCreatePixmap(scr
, 155, 18, WMScreenDepth(scr
), False
);
1434 p
= WMGetPixmapXID(pixmap
);
1436 color
= WMDarkGrayColor(scr
);
1437 XFillRectangle(WMScreenDisplay(scr
), p
, WMColorGC(color
),
1439 WMReleaseColor(color
);
1441 color
= WMWhiteColor(scr
);
1442 WMDrawString(scr
, p
, WMColorGC(color
), panel
->listFont
,
1444 WMDrawString(scr
, p
, WMColorGC(color
), panel
->listFont
,
1445 153 - WMWidthOfString(panel
->listFont
, "100%", 4), 1,
1447 WMReleaseColor(color
);
1449 WMSetSliderImage(panel
->topaS
, pixmap
);
1450 WMReleasePixmap(pixmap
);
1453 WMMapSubwidgets(panel
->tcolF
);
1455 /****************** Image ******************/
1456 panel
->imageF
= WMCreateFrame(panel
->win
);
1457 WMResizeWidget(panel
->imageF
, 295, 150);
1458 WMMoveWidget(panel
->imageF
, 15, 150);
1459 WMSetFrameTitle(panel
->imageF
, _("Image"));
1461 panel
->imageL
= WMCreateLabel(panel
->imageF
);
1462 WMSetLabelImagePosition(panel
->imageL
, WIPImageOnly
);
1464 panel
->imageT
= WMCreateTextField(panel
->imageF
);
1465 WMResizeWidget(panel
->imageT
, 90, 20);
1466 WMMoveWidget(panel
->imageT
, 190, 25);
1468 panel
->imageV
= WMCreateScrollView(panel
->imageF
);
1469 WMResizeWidget(panel
->imageV
, 165, 115);
1470 WMMoveWidget(panel
->imageV
, 15, 20);
1471 WMSetScrollViewRelief(panel
->imageV
, WRSunken
);
1472 WMSetScrollViewHasHorizontalScroller(panel
->imageV
, True
);
1473 WMSetScrollViewHasVerticalScroller(panel
->imageV
, True
);
1474 WMSetScrollViewContentView(panel
->imageV
, WMWidgetView(panel
->imageL
));
1476 panel
->browB
= WMCreateCommandButton(panel
->imageF
);
1477 WMResizeWidget(panel
->browB
, 90, 24);
1478 WMMoveWidget(panel
->browB
, 190, 50);
1479 WMSetButtonText(panel
->browB
, _("Browse..."));
1480 WMSetButtonAction(panel
->browB
, browseImageCallback
, panel
);
1482 /* panel->dispB = WMCreateCommandButton(panel->imageF);
1483 WMResizeWidget(panel->dispB, 90, 24);
1484 WMMoveWidget(panel->dispB, 190, 80);
1485 WMSetButtonText(panel->dispB, _("Show"));
1488 panel
->arrP
= WMCreatePopUpButton(panel
->imageF
);
1489 WMResizeWidget(panel
->arrP
, 90, 20);
1490 WMMoveWidget(panel
->arrP
, 190, 120);
1491 WMAddPopUpButtonItem(panel
->arrP
, _("Tile"));
1492 WMAddPopUpButtonItem(panel
->arrP
, _("Scale"));
1493 WMAddPopUpButtonItem(panel
->arrP
, _("Center"));
1494 WMAddPopUpButtonItem(panel
->arrP
, _("Maximize"));
1495 WMSetPopUpButtonSelectedItem(panel
->arrP
, 0);
1497 WMMapSubwidgets(panel
->imageF
);
1501 panel
->okB
= WMCreateCommandButton(panel
->win
);
1502 WMResizeWidget(panel
->okB
, 84, 24);
1503 WMMoveWidget(panel
->okB
, 225, 390);
1504 WMSetButtonText(panel
->okB
, _("OK"));
1505 WMSetButtonAction(panel
->okB
, buttonCallback
, panel
);
1507 panel
->cancelB
= WMCreateCommandButton(panel
->win
);
1508 WMResizeWidget(panel
->cancelB
, 84, 24);
1509 WMMoveWidget(panel
->cancelB
, 130, 390);
1510 WMSetButtonText(panel
->cancelB
, _("Cancel"));
1511 WMSetButtonAction(panel
->cancelB
, buttonCallback
, panel
);
1513 WMMapWidget(panel
->nameF
);
1514 WMMapWidget(panel
->typeP
);
1515 WMMapWidget(panel
->okB
);
1516 WMMapWidget(panel
->cancelB
);
1518 WMUnmapWidget(panel
->arrP
);
1520 WMRealizeWidget(panel
->win
);
1522 panel
->currentType
= -1;
1524 panel
->sectionParts
[TYPE_SOLID
][0] = panel
->defcF
;
1526 panel
->sectionParts
[TYPE_GRADIENT
][0] = panel
->defcF
;
1527 panel
->sectionParts
[TYPE_GRADIENT
][1] = panel
->gcolF
;
1528 panel
->sectionParts
[TYPE_GRADIENT
][2] = panel
->dirF
;
1530 panel
->sectionParts
[TYPE_SGRADIENT
][0] = panel
->tcolF
;
1531 panel
->sectionParts
[TYPE_SGRADIENT
][1] = panel
->dirF
;
1533 panel
->sectionParts
[TYPE_TGRADIENT
][0] = panel
->tcolF
;
1534 panel
->sectionParts
[TYPE_TGRADIENT
][1] = panel
->dirF
;
1535 panel
->sectionParts
[TYPE_TGRADIENT
][2] = panel
->imageF
;
1536 panel
->sectionParts
[TYPE_TGRADIENT
][3] = panel
->topaF
;
1537 panel
->sectionParts
[TYPE_TGRADIENT
][4] = panel
->arrP
;
1539 panel
->sectionParts
[TYPE_PIXMAP
][0] = panel
->defcF
;
1540 panel
->sectionParts
[TYPE_PIXMAP
][1] = panel
->imageF
;
1541 panel
->sectionParts
[TYPE_PIXMAP
][2] = panel
->arrP
;
1544 /* setup for first time */
1546 changeTypeCallback(panel
->typeP
, panel
);
1548 sliderChangeCallback(panel
->ghueS
, panel
);
1549 sliderChangeCallback(panel
->gsatS
, panel
);
1557 *--------------------------------------------------------------------------
1559 *--------------------------------------------------------------------------
1564 char *ProgName
= "test";
1567 testOKButton(WMWidget
*self
, void *data
)
1575 TexturePanel
*panel
= (TexturePanel
*)data
;
1576 /* test = GetTexturePanelTextureString(panel); */
1580 dpy
= WMScreenDisplay(WMWidgetScreen(panel
->okB
));
1581 win
= XCreateSimpleWindow(dpy
, DefaultRootWindow(dpy
), 10, 10, 250, 250,
1583 XMapRaised(dpy
, win
);
1586 /* image = RenderTexturePanelTexture(panel, 250, 250); */
1588 RConvertImage(WMScreenRContext(WMWidgetScreen(panel
->okB
)), image
, &pix
);
1590 XCopyArea(dpy
, pix
, win
, (WMScreenRContext(WMWidgetScreen(panel
->okB
)))->copy_gc
, 0, 0, image
->width
, image
->height
,
1597 void testCancelButton(WMWidget
*self
, void *data
){
1598 wwarning("Exiting test....");
1607 int main(int argc
, char **argv
)
1609 TexturePanel
*panel
;
1611 Display
*dpy
= XOpenDisplay("");
1616 WMInitializeApplication("Test", &argc
, argv
);
1619 wfatal("could not open display");
1623 scr
= WMCreateSimpleApplicationScreen(dpy
);
1625 panel
= CreateTexturePanel(scr
);
1627 SetTexturePanelOkAction(panel
,(WMAction
*)testOKButton
,panel
);
1628 SetTexturePanelCancelAction(panel
,(WMAction
*)testCancelButton
,panel
);
1630 SetTexturePanelTexture(panel
, "pinky",
1631 PLGetProplistWithDescription("(mdgradient, pink, red, blue, yellow)"));
1633 ShowTexturePanel(panel
);
1635 WMScreenMainLoop(scr
);