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
) {
616 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
618 size
= WMGetPixmapSize(pixmap
);
619 WMSetLabelImage(panel
->imageL
, pixmap
);
620 WMResizeWidget(panel
->imageL
, size
.width
, size
.height
);
622 WMReleasePixmap(pixmap
);
624 updateTGradImage(panel
);
630 browseImageCallback(WMWidget
*w
, void *data
)
632 TexturePanel
*panel
= (TexturePanel
*)data
;
634 WMScreen
*scr
= WMWidgetScreen(w
);
635 static char *ipath
= NULL
;
637 opanel
= WMGetOpenPanel(scr
);
638 WMSetFilePanelCanChooseDirectories(opanel
, False
);
639 WMSetFilePanelCanChooseFiles(opanel
, True
);
642 ipath
= wstrdup(wgethomedir());
644 if (WMRunModalFilePanelForDirectory(opanel
, panel
->win
, ipath
,
645 "Open Image", NULL
)) {
646 char *path
, *fullpath
;
649 tmp
= WMGetFilePanelFileName(opanel
);
657 path
= wstrdup(fullpath
);
659 tmp2
= strrchr(fullpath
, '/');
663 tmp
= wfindfileinarray(panel
->pathList
, tmp2
);
666 if (strcmp(fullpath
, tmp
)==0) {
673 if (!RGetImageFileFormat(fullpath
)) {
674 WMRunAlertPanel(scr
, panel
->win
, _("Error"),
675 _("The selected file does not contain a supported image."),
676 _("OK"), NULL
, NULL
);
679 updateImage(panel
, fullpath
);
680 free(panel
->imageFile
);
681 panel
->imageFile
= path
;
683 WMSetTextFieldText(panel
->imageT
, path
);
691 buttonCallback(WMWidget
*w
, void *data
)
693 TexturePanel
*panel
= (TexturePanel
*)data
;
695 if (w
== panel
->okB
) {
696 (*panel
->okAction
)(panel
->okData
);
698 (*panel
->cancelAction
)(panel
->cancelData
);
705 changeTypeCallback(WMWidget
*w
, void *data
)
707 TexturePanel
*panel
= (TexturePanel
*)data
;
711 newType
= WMGetPopUpButtonSelectedItem(w
);
712 if (newType
== panel
->currentType
)
715 if (panel
->currentType
>= 0) {
716 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
717 if (panel
->sectionParts
[panel
->currentType
][i
] == NULL
)
719 WMUnmapWidget(panel
->sectionParts
[panel
->currentType
][i
]);
723 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
724 if (panel
->sectionParts
[newType
][i
] == NULL
)
726 WMMapWidget(panel
->sectionParts
[newType
][i
]);
728 panel
->currentType
= newType
;
732 updateSGradButtons(panel
);
735 updateGradButtons(panel
);
739 updateImage(panel
, NULL
);
746 *--------------------------------------------------------------------------
748 *--------------------------------------------------------------------------
751 DestroyTexturePanel(TexturePanel
*panel
)
758 ShowTexturePanel(TexturePanel
*panel
)
760 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(panel
->win
));
761 Screen
*scr
= DefaultScreenOfDisplay(dpy
);
763 WMSetWindowUPosition(panel
->win
,
764 (WidthOfScreen(scr
)-WMWidgetWidth(panel
->win
))/2,
765 (HeightOfScreen(scr
)-WMWidgetHeight(panel
->win
))/2);
766 WMMapWidget(panel
->win
);
771 HideTexturePanel(TexturePanel
*panel
)
773 WMUnmapWidget(panel
->win
);
778 SetTexturePanelOkAction(TexturePanel
*panel
, WMCallback
*action
, void *clientData
)
780 panel
->okAction
= action
;
781 panel
->okData
= clientData
;
786 SetTexturePanelCancelAction(TexturePanel
*panel
, WMCallback
*action
, void *clientData
)
788 panel
->cancelAction
= action
;
789 panel
->cancelData
= clientData
;
794 SetTexturePanelTexture(TexturePanel
*panel
, char *name
, proplist_t texture
)
796 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
804 WMSetTextFieldText(panel
->nameT
, name
);
809 p
= PLGetArrayElement(texture
, 0);
813 type
= PLGetString(p
);
815 /*...............................................*/
816 if (strcasecmp(type
, "solid")==0) {
818 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SOLID
);
820 p
= PLGetArrayElement(texture
, 1);
824 str
= PLGetString(p
);
826 color
= WMCreateNamedColor(scr
, str
, False
);
828 WMSetColorWellColor(panel
->defcW
, color
);
830 WMReleaseColor(color
);
831 /*...............................................*/
832 } else if (strcasecmp(type
, "hgradient")==0
833 || strcasecmp(type
, "vgradient")==0
834 || strcasecmp(type
, "dgradient")==0) {
836 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SGRADIENT
);
838 p
= PLGetArrayElement(texture
, 1);
842 str
= PLGetString(p
);
844 color
= WMCreateNamedColor(scr
, str
, False
);
846 WMSetColorWellColor(panel
->tcol1W
, color
);
848 WMReleaseColor(color
);
850 p
= PLGetArrayElement(texture
, 2);
854 str
= PLGetString(p
);
856 color
= WMCreateNamedColor(scr
, str
, False
);
858 WMSetColorWellColor(panel
->tcol2W
, color
);
860 WMReleaseColor(color
);
863 /*...............................................*/
864 } else if (strcasecmp(type
, "thgradient")==0
865 || strcasecmp(type
, "tvgradient")==0
866 || strcasecmp(type
, "tdgradient")==0) {
869 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_TGRADIENT
);
873 WMSetTextFieldText(panel
->imageT
,
874 PLGetString(PLGetArrayElement(texture
, 1)));
875 if (panel
->imageFile
)
876 free(panel
->imageFile
);
877 panel
->imageFile
= wstrdup(PLGetString(PLGetArrayElement(texture
, 1)));
881 sscanf(PLGetString(PLGetArrayElement(texture
, 2)), "%i", &i
);
882 WMSetSliderValue(panel
->topaS
, i
);
884 p
= PLGetArrayElement(texture
, 3);
888 str
= PLGetString(p
);
890 color
= WMCreateNamedColor(scr
, str
, False
);
892 WMSetColorWellColor(panel
->tcol1W
, color
);
894 WMReleaseColor(color
);
896 p
= PLGetArrayElement(texture
, 4);
900 str
= PLGetString(p
);
902 color
= WMCreateNamedColor(scr
, str
, False
);
904 WMSetColorWellColor(panel
->tcol2W
, color
);
906 WMReleaseColor(color
);
908 WMSetTextFieldText(panel
->imageT
,
909 PLGetString(PLGetArrayElement(texture
, 1)));
911 if (panel
->imageFile
)
912 free(panel
->imageFile
);
913 panel
->imageFile
= wfindfileinarray(panel
->pathList
,
914 PLGetString(PLGetArrayElement(texture
, 1)));
916 panel
->image
= RLoadImage(WMScreenRContext(scr
), panel
->imageFile
, 0);
917 updateTGradImage(panel
);
919 updateSGradButtons(panel
);
921 /*...............................................*/
922 } else if (strcasecmp(type
, "mhgradient")==0
923 || strcasecmp(type
, "mvgradient")==0
924 || strcasecmp(type
, "mdgradient")==0) {
927 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
928 item
= WMGetListItem(panel
->gcolL
, i
);
929 free(item
->clientData
);
931 WMClearList(panel
->gcolL
);
933 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_GRADIENT
);
935 p
= PLGetArrayElement(texture
, 1);
939 str
= PLGetString(p
);
941 color
= WMCreateNamedColor(scr
, str
, False
);
943 WMSetColorWellColor(panel
->defcW
, color
);
945 WMReleaseColor(color
);
947 for (i
= 2; i
< PLGetNumberOfElements(texture
); i
++) {
951 p
= PLGetArrayElement(texture
, i
);
955 str
= PLGetString(p
);
958 XParseColor(WMScreenDisplay(scr
), WMScreenRContext(scr
)->cmap
,
961 rgb
= wmalloc(sizeof(RColor
));
962 rgb
->red
= xcolor
.red
>> 8;
963 rgb
->green
= xcolor
.green
>> 8;
964 rgb
->blue
= xcolor
.blue
>> 8;
965 sprintf(buffer
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
967 item
= WMAddListItem(panel
->gcolL
, buffer
);
968 item
->clientData
= rgb
;
971 sliderChangeCallback(panel
->ghueS
, panel
);
974 /*...............................................*/
975 } else if (strcasecmp(type
, "cpixmap")==0
976 || strcasecmp(type
, "spixmap")==0
977 || strcasecmp(type
, "mpixmap")==0
978 || strcasecmp(type
, "tpixmap")==0) {
980 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_PIXMAP
);
982 switch (toupper(type
[0])) {
984 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_CENTER
);
987 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_SCALE
);
990 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_MAXIMIZE
);
994 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_TILE
);
998 WMSetTextFieldText(panel
->imageT
,
999 PLGetString(PLGetArrayElement(texture
, 1)));
1001 if (panel
->imageFile
)
1002 free(panel
->imageFile
);
1003 panel
->imageFile
= wfindfileinarray(panel
->pathList
,
1004 PLGetString(PLGetArrayElement(texture
, 1)));
1006 color
= WMCreateNamedColor(scr
,
1007 PLGetString(PLGetArrayElement(texture
, 2)), False
);
1008 WMSetColorWellColor(panel
->defcW
, color
);
1009 WMReleaseColor(color
);
1011 updateImage(panel
, panel
->imageFile
);
1014 changeTypeCallback(panel
->typeP
, panel
);
1017 updateGradButtons(panel
);
1019 switch (toupper(gradient
)) {
1021 WMPerformButtonClick(panel
->dirhB
);
1024 WMPerformButtonClick(panel
->dirvB
);
1028 WMPerformButtonClick(panel
->dirdB
);
1036 str
= PLGetDescription(texture
);
1037 wwarning("error creating texture %s", str
);
1045 GetTexturePanelTextureName(TexturePanel
*panel
)
1047 return WMGetTextFieldText(panel
->nameT
);
1054 GetTexturePanelTexture(TexturePanel
*panel
)
1056 proplist_t prop
= NULL
;
1063 switch (WMGetPopUpButtonSelectedItem(panel
->typeP
)) {
1066 color
= WMGetColorWellColor(panel
->defcW
);
1067 str
= WMGetColorRGBDescription(color
);
1068 prop
= PLMakeArrayFromElements(PLMakeString("solid"),
1069 PLMakeString(str
), NULL
);
1075 color
= WMGetColorWellColor(panel
->defcW
);
1076 str
= WMGetColorRGBDescription(color
);
1078 switch (WMGetPopUpButtonSelectedItem(panel
->arrP
)) {
1080 prop
= PLMakeArrayFromElements(PLMakeString("spixmap"),
1081 PLMakeString(panel
->imageFile
),
1082 PLMakeString(str
), NULL
);
1084 case PTYPE_MAXIMIZE
:
1085 prop
= PLMakeArrayFromElements(PLMakeString("mpixmap"),
1086 PLMakeString(panel
->imageFile
),
1087 PLMakeString(str
), NULL
);
1090 prop
= PLMakeArrayFromElements(PLMakeString("cpixmap"),
1091 PLMakeString(panel
->imageFile
),
1092 PLMakeString(str
), NULL
);
1095 prop
= PLMakeArrayFromElements(PLMakeString("tpixmap"),
1096 PLMakeString(panel
->imageFile
),
1097 PLMakeString(str
), NULL
);
1103 case TYPE_TGRADIENT
:
1104 color
= WMGetColorWellColor(panel
->tcol1W
);
1105 str
= WMGetColorRGBDescription(color
);
1107 color
= WMGetColorWellColor(panel
->tcol2W
);
1108 str2
= WMGetColorRGBDescription(color
);
1110 sprintf(buff
, "%i", WMGetSliderValue(panel
->topaS
));
1112 if (WMGetButtonSelected(panel
->dirdB
)) {
1113 prop
= PLMakeArrayFromElements(PLMakeString("tdgradient"),
1114 PLMakeString(panel
->imageFile
),
1117 PLMakeString(str2
), NULL
);
1118 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1119 prop
= PLMakeArrayFromElements(PLMakeString("tvgradient"),
1120 PLMakeString(panel
->imageFile
),
1123 PLMakeString(str2
), NULL
);
1125 prop
= PLMakeArrayFromElements(PLMakeString("thgradient"),
1126 PLMakeString(panel
->imageFile
),
1129 PLMakeString(str2
), NULL
);
1136 case TYPE_SGRADIENT
:
1137 color
= WMGetColorWellColor(panel
->tcol1W
);
1138 str
= WMGetColorRGBDescription(color
);
1140 color
= WMGetColorWellColor(panel
->tcol2W
);
1141 str2
= WMGetColorRGBDescription(color
);
1143 if (WMGetButtonSelected(panel
->dirdB
)) {
1144 prop
= PLMakeArrayFromElements(PLMakeString("dgradient"),
1146 PLMakeString(str2
), NULL
);
1147 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1148 prop
= PLMakeArrayFromElements(PLMakeString("vgradient"),
1150 PLMakeString(str2
), NULL
);
1152 prop
= PLMakeArrayFromElements(PLMakeString("hgradient"),
1154 PLMakeString(str2
), NULL
);
1161 color
= WMGetColorWellColor(panel
->defcW
);
1162 str
= WMGetColorRGBDescription(color
);
1164 if (WMGetButtonSelected(panel
->dirdB
)) {
1165 prop
= PLMakeArrayFromElements(PLMakeString("mdgradient"),
1166 PLMakeString(str
), NULL
);
1167 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1168 prop
= PLMakeArrayFromElements(PLMakeString("mvgradient"),
1169 PLMakeString(str
), NULL
);
1171 prop
= PLMakeArrayFromElements(PLMakeString("mhgradient"),
1172 PLMakeString(str
), NULL
);
1176 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
1180 item
= WMGetListItem(panel
->gcolL
, i
);
1182 rgb
= (RColor
*)item
->clientData
;
1184 sprintf(buff
, "#%02x%02x%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
1186 PLAppendArrayElement(prop
, PLMakeString(buff
));
1198 SetTexturePanelPixmapPath(TexturePanel
*panel
, proplist_t array
)
1200 panel
->pathList
= array
;
1206 CreateTexturePanel(WMWindow
*keyWindow
)
1207 /*CreateTexturePanel(WMScreen *scr)*/
1209 TexturePanel
*panel
;
1210 WMScreen
*scr
= WMWidgetScreen(keyWindow
);
1212 panel
= wmalloc(sizeof(TexturePanel
));
1213 memset(panel
, 0, sizeof(TexturePanel
));
1215 panel
->listFont
= WMSystemFontOfSize(scr
, 12);
1218 panel
->win
= WMCreatePanelWithStyleForWindow(keyWindow
, "texturePanel",
1220 |WMClosableWindowMask
);
1222 panel->win = WMCreateWindowWithStyle(scr, "texturePanel",
1224 |WMClosableWindowMask);
1227 WMResizeWidget(panel
->win
, 325, 423);
1228 WMSetWindowTitle(panel
->win
, _("Texture Panel"));
1229 WMSetWindowCloseAction(panel
->win
, buttonCallback
, panel
);
1233 panel
->nameF
= WMCreateFrame(panel
->win
);
1234 WMResizeWidget(panel
->nameF
, 185, 50);
1235 WMMoveWidget(panel
->nameF
, 15, 10);
1236 WMSetFrameTitle(panel
->nameF
, _("Texture Name"));
1238 panel
->nameT
= WMCreateTextField(panel
->nameF
);
1239 WMResizeWidget(panel
->nameT
, 160, 20);
1240 WMMoveWidget(panel
->nameT
, 12, 18);
1242 WMMapSubwidgets(panel
->nameF
);
1245 panel
->typeP
= WMCreatePopUpButton(panel
->win
);
1246 WMResizeWidget(panel
->typeP
, 185, 20);
1247 WMMoveWidget(panel
->typeP
, 15, 65);
1248 WMAddPopUpButtonItem(panel
->typeP
, _("Solid Color"));
1249 WMAddPopUpButtonItem(panel
->typeP
, _("Gradient Texture"));
1250 WMAddPopUpButtonItem(panel
->typeP
, _("Simple Gradient Texture"));
1251 WMAddPopUpButtonItem(panel
->typeP
, _("Textured Gradient"));
1252 WMAddPopUpButtonItem(panel
->typeP
, _("Image Texture"));
1253 WMSetPopUpButtonSelectedItem(panel
->typeP
, 0);
1254 WMSetPopUpButtonAction(panel
->typeP
, changeTypeCallback
, panel
);
1257 panel
->defcF
= WMCreateFrame(panel
->win
);
1258 WMResizeWidget(panel
->defcF
, 100, 75);
1259 WMMoveWidget(panel
->defcF
, 210, 10);
1260 WMSetFrameTitle(panel
->defcF
, _("Default Color"));
1262 panel
->defcW
= WMCreateColorWell(panel
->defcF
);
1263 WMResizeWidget(panel
->defcW
, 60, 45);
1264 WMMoveWidget(panel
->defcW
, 20, 20);
1266 WMMapSubwidgets(panel
->defcF
);
1268 /****** Gradient ******/
1269 panel
->gcolF
= WMCreateFrame(panel
->win
);
1270 WMResizeWidget(panel
->gcolF
, 295, 205);
1271 WMMoveWidget(panel
->gcolF
, 15, 95);
1272 WMSetFrameTitle(panel
->gcolF
, _("Gradient Colors"));
1274 panel
->gcolL
= WMCreateList(panel
->gcolF
);
1275 WMResizeWidget(panel
->gcolL
, 130, 140);
1276 WMMoveWidget(panel
->gcolL
, 10, 25);
1277 WMHangData(panel
->gcolL
, panel
);
1278 WMSetListUserDrawProc(panel
->gcolL
, paintGradListItem
);
1279 WMSetListAction(panel
->gcolL
, gradClickCallback
, panel
);
1281 panel
->gcolaB
= WMCreateCommandButton(panel
->gcolF
);
1282 WMResizeWidget(panel
->gcolaB
, 64, 24);
1283 WMMoveWidget(panel
->gcolaB
, 10, 170);
1284 WMSetButtonText(panel
->gcolaB
, _("Add"));
1285 WMSetButtonAction(panel
->gcolaB
, gradAddCallback
, panel
);
1287 panel
->gcoldB
= WMCreateCommandButton(panel
->gcolF
);
1288 WMResizeWidget(panel
->gcoldB
, 64, 24);
1289 WMMoveWidget(panel
->gcoldB
, 75, 170);
1290 WMSetButtonText(panel
->gcoldB
, _("Delete"));
1291 WMSetButtonAction(panel
->gcoldB
, gradDeleteCallback
, panel
);
1294 panel
->gbriS
= WMCreateSlider(panel
->gcolF
);
1295 WMResizeWidget(panel
->gbriS
, 130, 16);
1296 WMMoveWidget(panel
->gbriS
, 150, 25);
1297 WMSetSliderKnobThickness(panel
->gbriS
, 8);
1298 WMSetSliderMaxValue(panel
->gbriS
, 100);
1299 WMSetSliderAction(panel
->gbriS
, sliderChangeCallback
, panel
);
1304 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1305 color
= WMDarkGrayColor(scr
);
1306 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
),
1307 WMColorGC(color
), 0, 0, 130, 16);
1308 WMReleaseColor(color
);
1309 color
= WMWhiteColor(color
);
1310 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(color
),
1312 (16 - WMFontHeight(panel
->listFont
))/2 - 1,
1314 WMSetSliderImage(panel
->gbriS
, pixmap
);
1315 WMReleasePixmap(pixmap
);
1318 panel
->gconS
= WMCreateSlider(panel
->gcolF
);
1319 WMResizeWidget(panel
->gconS
, 130, 16);
1320 WMMoveWidget(panel
->gconS
, 150, 50);
1321 WMSetSliderKnobThickness(panel
->gconS
, 8);
1322 WMSetSliderMaxValue(panel
->gconS
, 100);
1323 WMSetSliderAction(panel
->gconS
, sliderChangeCallback
, panel
);
1328 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1329 color
= WMDarkGrayColor(scr
);
1330 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
),
1331 WMColorGC(color
), 0, 0, 130, 16);
1332 WMReleaseColor(color
);
1333 color
= WMWhiteColor(scr
);
1334 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(color
),
1336 (16 - WMFontHeight(panel
->listFont
))/2 - 1,
1338 WMSetSliderImage(panel
->gconS
, pixmap
);
1339 WMReleasePixmap(pixmap
);
1342 panel
->ghueS
= WMCreateSlider(panel
->gcolF
);
1343 WMResizeWidget(panel
->ghueS
, 130, 16);
1344 WMMoveWidget(panel
->ghueS
, 150, 100);
1345 WMSetSliderKnobThickness(panel
->ghueS
, 8);
1346 WMSetSliderMaxValue(panel
->ghueS
, 359);
1347 WMSetSliderAction(panel
->ghueS
, sliderChangeCallback
, panel
);
1349 panel
->gsatS
= WMCreateSlider(panel
->gcolF
);
1350 WMResizeWidget(panel
->gsatS
, 130, 16);
1351 WMMoveWidget(panel
->gsatS
, 150, 125);
1352 WMSetSliderKnobThickness(panel
->gsatS
, 8);
1353 WMSetSliderMaxValue(panel
->gsatS
, 255);
1354 WMSetSliderAction(panel
->gsatS
, sliderChangeCallback
, panel
);
1356 panel
->gvalS
= WMCreateSlider(panel
->gcolF
);
1357 WMResizeWidget(panel
->gvalS
, 130, 16);
1358 WMMoveWidget(panel
->gvalS
, 150, 150);
1359 WMSetSliderKnobThickness(panel
->gvalS
, 8);
1360 WMSetSliderMaxValue(panel
->gvalS
, 255);
1361 WMSetSliderAction(panel
->gvalS
, sliderChangeCallback
, panel
);
1364 WMMapSubwidgets(panel
->gcolF
);
1367 panel
->dirF
= WMCreateFrame(panel
->win
);
1368 WMSetFrameTitle(panel
->dirF
, _("Direction"));
1369 WMResizeWidget(panel
->dirF
, 295, 75);
1370 WMMoveWidget(panel
->dirF
, 15, 305);
1372 panel
->dirvB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1373 WMSetButtonImagePosition(panel
->dirvB
, WIPImageOnly
);
1374 WMResizeWidget(panel
->dirvB
, 90, 40);
1375 WMMoveWidget(panel
->dirvB
, 10, 20);
1377 panel
->dirhB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1378 WMSetButtonImagePosition(panel
->dirhB
, WIPImageOnly
);
1379 WMResizeWidget(panel
->dirhB
, 90, 40);
1380 WMMoveWidget(panel
->dirhB
, 102, 20);
1382 panel
->dirdB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1383 WMSetButtonImagePosition(panel
->dirdB
, WIPImageOnly
);
1384 WMResizeWidget(panel
->dirdB
, 90, 40);
1385 WMMoveWidget(panel
->dirdB
, 194, 20);
1387 WMGroupButtons(panel
->dirvB
, panel
->dirhB
);
1388 WMGroupButtons(panel
->dirvB
, panel
->dirdB
);
1390 WMMapSubwidgets(panel
->dirF
);
1392 /****************** Textured Gradient ******************/
1393 panel
->tcolF
= WMCreateFrame(panel
->win
);
1394 WMResizeWidget(panel
->tcolF
, 100, 135);
1395 WMMoveWidget(panel
->tcolF
, 210, 10);
1396 WMSetFrameTitle(panel
->tcolF
, _("Gradient"));
1398 panel
->tcol1W
= WMCreateColorWell(panel
->tcolF
);
1399 WMResizeWidget(panel
->tcol1W
, 60, 45);
1400 WMMoveWidget(panel
->tcol1W
, 20, 25);
1401 WMAddNotificationObserver(colorWellObserver
, panel
,
1402 WMColorWellDidChangeNotification
, panel
->tcol1W
);
1404 panel
->tcol2W
= WMCreateColorWell(panel
->tcolF
);
1405 WMResizeWidget(panel
->tcol2W
, 60, 45);
1406 WMMoveWidget(panel
->tcol2W
, 20, 75);
1407 WMAddNotificationObserver(colorWellObserver
, panel
,
1408 WMColorWellDidChangeNotification
, panel
->tcol2W
);
1411 panel
->topaF
= WMCreateFrame(panel
->win
);
1412 WMResizeWidget(panel
->topaF
, 185, 50);
1413 WMMoveWidget(panel
->topaF
, 15, 95);
1414 WMSetFrameTitle(panel
->topaF
, _("Gradient Opacity"));
1416 panel
->topaS
= WMCreateSlider(panel
->topaF
);
1417 WMResizeWidget(panel
->topaS
, 155, 18);
1418 WMMoveWidget(panel
->topaS
, 15, 20);
1419 WMSetSliderMaxValue(panel
->topaS
, 255);
1420 WMSetSliderValue(panel
->topaS
, 200);
1421 WMSetSliderContinuous(panel
->topaS
, False
);
1422 WMSetSliderAction(panel
->topaS
, opaqChangeCallback
, panel
);
1424 WMMapSubwidgets(panel
->topaF
);
1431 pixmap
= WMCreatePixmap(scr
, 155, 18, WMScreenDepth(scr
), False
);
1432 p
= WMGetPixmapXID(pixmap
);
1434 color
= WMDarkGrayColor(scr
);
1435 XFillRectangle(WMScreenDisplay(scr
), p
, WMColorGC(color
),
1437 WMReleaseColor(color
);
1439 color
= WMWhiteColor(scr
);
1440 WMDrawString(scr
, p
, WMColorGC(color
), panel
->listFont
,
1442 WMDrawString(scr
, p
, WMColorGC(color
), panel
->listFont
,
1443 153 - WMWidthOfString(panel
->listFont
, "100%", 4), 1,
1445 WMReleaseColor(color
);
1447 WMSetSliderImage(panel
->topaS
, pixmap
);
1448 WMReleasePixmap(pixmap
);
1451 WMMapSubwidgets(panel
->tcolF
);
1453 /****************** Image ******************/
1454 panel
->imageF
= WMCreateFrame(panel
->win
);
1455 WMResizeWidget(panel
->imageF
, 295, 150);
1456 WMMoveWidget(panel
->imageF
, 15, 150);
1457 WMSetFrameTitle(panel
->imageF
, _("Image"));
1459 panel
->imageL
= WMCreateLabel(panel
->imageF
);
1460 WMSetLabelImagePosition(panel
->imageL
, WIPImageOnly
);
1462 panel
->imageT
= WMCreateTextField(panel
->imageF
);
1463 WMResizeWidget(panel
->imageT
, 90, 20);
1464 WMMoveWidget(panel
->imageT
, 190, 25);
1466 panel
->imageV
= WMCreateScrollView(panel
->imageF
);
1467 WMResizeWidget(panel
->imageV
, 165, 115);
1468 WMMoveWidget(panel
->imageV
, 15, 20);
1469 WMSetScrollViewRelief(panel
->imageV
, WRSunken
);
1470 WMSetScrollViewHasHorizontalScroller(panel
->imageV
, True
);
1471 WMSetScrollViewHasVerticalScroller(panel
->imageV
, True
);
1472 WMSetScrollViewContentView(panel
->imageV
, WMWidgetView(panel
->imageL
));
1474 panel
->browB
= WMCreateCommandButton(panel
->imageF
);
1475 WMResizeWidget(panel
->browB
, 90, 24);
1476 WMMoveWidget(panel
->browB
, 190, 50);
1477 WMSetButtonText(panel
->browB
, _("Browse..."));
1478 WMSetButtonAction(panel
->browB
, browseImageCallback
, panel
);
1480 /* panel->dispB = WMCreateCommandButton(panel->imageF);
1481 WMResizeWidget(panel->dispB, 90, 24);
1482 WMMoveWidget(panel->dispB, 190, 80);
1483 WMSetButtonText(panel->dispB, _("Show"));
1486 panel
->arrP
= WMCreatePopUpButton(panel
->imageF
);
1487 WMResizeWidget(panel
->arrP
, 90, 20);
1488 WMMoveWidget(panel
->arrP
, 190, 120);
1489 WMAddPopUpButtonItem(panel
->arrP
, _("Tile"));
1490 WMAddPopUpButtonItem(panel
->arrP
, _("Scale"));
1491 WMAddPopUpButtonItem(panel
->arrP
, _("Center"));
1492 WMAddPopUpButtonItem(panel
->arrP
, _("Maximize"));
1493 WMSetPopUpButtonSelectedItem(panel
->arrP
, 0);
1495 WMMapSubwidgets(panel
->imageF
);
1499 panel
->okB
= WMCreateCommandButton(panel
->win
);
1500 WMResizeWidget(panel
->okB
, 84, 24);
1501 WMMoveWidget(panel
->okB
, 225, 390);
1502 WMSetButtonText(panel
->okB
, _("OK"));
1503 WMSetButtonAction(panel
->okB
, buttonCallback
, panel
);
1505 panel
->cancelB
= WMCreateCommandButton(panel
->win
);
1506 WMResizeWidget(panel
->cancelB
, 84, 24);
1507 WMMoveWidget(panel
->cancelB
, 130, 390);
1508 WMSetButtonText(panel
->cancelB
, _("Cancel"));
1509 WMSetButtonAction(panel
->cancelB
, buttonCallback
, panel
);
1511 WMMapWidget(panel
->nameF
);
1512 WMMapWidget(panel
->typeP
);
1513 WMMapWidget(panel
->okB
);
1514 WMMapWidget(panel
->cancelB
);
1516 WMUnmapWidget(panel
->arrP
);
1518 WMRealizeWidget(panel
->win
);
1520 panel
->currentType
= -1;
1522 panel
->sectionParts
[TYPE_SOLID
][0] = panel
->defcF
;
1524 panel
->sectionParts
[TYPE_GRADIENT
][0] = panel
->defcF
;
1525 panel
->sectionParts
[TYPE_GRADIENT
][1] = panel
->gcolF
;
1526 panel
->sectionParts
[TYPE_GRADIENT
][2] = panel
->dirF
;
1528 panel
->sectionParts
[TYPE_SGRADIENT
][0] = panel
->tcolF
;
1529 panel
->sectionParts
[TYPE_SGRADIENT
][1] = panel
->dirF
;
1531 panel
->sectionParts
[TYPE_TGRADIENT
][0] = panel
->tcolF
;
1532 panel
->sectionParts
[TYPE_TGRADIENT
][1] = panel
->dirF
;
1533 panel
->sectionParts
[TYPE_TGRADIENT
][2] = panel
->imageF
;
1534 panel
->sectionParts
[TYPE_TGRADIENT
][3] = panel
->topaF
;
1535 panel
->sectionParts
[TYPE_TGRADIENT
][4] = panel
->arrP
;
1537 panel
->sectionParts
[TYPE_PIXMAP
][0] = panel
->defcF
;
1538 panel
->sectionParts
[TYPE_PIXMAP
][1] = panel
->imageF
;
1539 panel
->sectionParts
[TYPE_PIXMAP
][2] = panel
->arrP
;
1542 /* setup for first time */
1544 changeTypeCallback(panel
->typeP
, panel
);
1546 sliderChangeCallback(panel
->ghueS
, panel
);
1547 sliderChangeCallback(panel
->gsatS
, panel
);
1555 *--------------------------------------------------------------------------
1557 *--------------------------------------------------------------------------
1562 char *ProgName
= "test";
1565 testOKButton(WMWidget
*self
, void *data
)
1573 TexturePanel
*panel
= (TexturePanel
*)data
;
1574 /* test = GetTexturePanelTextureString(panel); */
1578 dpy
= WMScreenDisplay(WMWidgetScreen(panel
->okB
));
1579 win
= XCreateSimpleWindow(dpy
, DefaultRootWindow(dpy
), 10, 10, 250, 250,
1581 XMapRaised(dpy
, win
);
1584 /* image = RenderTexturePanelTexture(panel, 250, 250); */
1586 RConvertImage(WMScreenRContext(WMWidgetScreen(panel
->okB
)), image
, &pix
);
1588 XCopyArea(dpy
, pix
, win
, (WMScreenRContext(WMWidgetScreen(panel
->okB
)))->copy_gc
, 0, 0, image
->width
, image
->height
,
1595 void testCancelButton(WMWidget
*self
, void *data
){
1596 wwarning("Exiting test....");
1605 int main(int argc
, char **argv
)
1607 TexturePanel
*panel
;
1609 Display
*dpy
= XOpenDisplay("");
1614 WMInitializeApplication("Test", &argc
, argv
);
1617 wfatal("could not open display");
1621 scr
= WMCreateSimpleApplicationScreen(dpy
);
1623 panel
= CreateTexturePanel(scr
);
1625 SetTexturePanelOkAction(panel
,(WMAction
*)testOKButton
,panel
);
1626 SetTexturePanelCancelAction(panel
,(WMAction
*)testCancelButton
,panel
);
1628 SetTexturePanelTexture(panel
, "pinky",
1629 PLGetProplistWithDescription("(mdgradient, pink, red, blue, yellow)"));
1631 ShowTexturePanel(panel
);
1633 WMScreenMainLoop(scr
);