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 RDestroyImage(image
);
177 WMSetButtonImage(panel
->dirhB
, pixmap
);
178 WMReleasePixmap(pixmap
);
180 image
= RRenderMultiGradient(80, 30, colors
, RVerticalGradient
);
181 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
183 RDestroyImage(image
);
184 WMSetButtonImage(panel
->dirvB
, pixmap
);
185 WMReleasePixmap(pixmap
);
187 image
= RRenderMultiGradient(80, 30, colors
, RDiagonalGradient
);
188 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
190 RDestroyImage(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 RDestroyImage(gradient
);
242 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->win
),
245 WMSetLabelImage(panel
->imageL
, pixmap
);
246 WMReleasePixmap(pixmap
);
247 WMResizeWidget(panel
->imageL
, image
->width
, image
->height
);
248 RDestroyImage(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 RDestroyImage(image
);
275 WMSetButtonImage(panel
->dirhB
, pixmap
);
276 WMReleasePixmap(pixmap
);
278 image
= RRenderGradient(80, 30, &from
, &to
, RVerticalGradient
);
279 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
281 RDestroyImage(image
);
282 WMSetButtonImage(panel
->dirvB
, pixmap
);
283 WMReleasePixmap(pixmap
);
285 image
= RRenderGradient(80, 30, &from
, &to
, RDiagonalGradient
);
286 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
288 RDestroyImage(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
);
308 RHSVtoRGB(&tmp
, &from
);
309 tmp
.saturation
= 255;
310 RHSVtoRGB(&tmp
, &to
);
313 RHSVtoRGB(&tmp
, &from
);
315 RHSVtoRGB(&tmp
, &to
);
317 image
= RRenderGradient(130, 16, &from
, &to
, RHorizontalGradient
);
318 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
319 RDestroyImage(image
);
321 if (hsv
->value
< 128 || !saturation
) {
322 WMColor
*col
= WMWhiteColor(scr
);
324 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
325 (16 - WMFontHeight(font
))/2 - 1,
326 saturation
? "Saturation" : "Brightness", 10);
329 WMColor
*col
= WMBlackColor(scr
);
331 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
332 (16 - WMFontHeight(font
))/2 - 1,
333 saturation
? "Saturation" : "Brightness", 10);
336 WMSetSliderImage(sPtr
, pixmap
);
337 WMReleasePixmap(pixmap
);
342 updateHueSlider(WMSlider
*sPtr
, WMFont
*font
, RHSVColor
*hsv
)
347 WMScreen
*scr
= WMWidgetScreen(sPtr
);
352 for (i
= 0; i
<= 6; i
++) {
353 thsv
.hue
= (360*i
)/6;
354 colors
[i
] = wmalloc(sizeof(RColor
));
355 RHSVtoRGB(&thsv
, colors
[i
]);
359 image
= RRenderMultiGradient(130, 16, colors
, RGRD_HORIZONTAL
);
360 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
361 RDestroyImage(image
);
363 if (hsv
->value
< 128) {
364 WMColor
*col
= WMWhiteColor(scr
);
366 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
367 (16 - WMFontHeight(font
))/2 - 1, "Hue", 3);
370 WMColor
*col
= WMBlackColor(scr
);
372 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
373 (16 - WMFontHeight(font
))/2 - 1, "Hue", 3);
376 WMSetSliderImage(sPtr
, pixmap
);
377 WMReleasePixmap(pixmap
);
379 for (i
= 0; i
<= 6; i
++)
386 sliderChangeCallback(WMWidget
*w
, void *data
)
388 TexturePanel
*panel
= (TexturePanel
*)data
;
395 WMScreen
*scr
= WMWidgetScreen(w
);
397 hsv
.hue
= WMGetSliderValue(panel
->ghueS
);
398 hsv
.saturation
= WMGetSliderValue(panel
->gsatS
);
399 hsv
.value
= WMGetSliderValue(panel
->gvalS
);
401 row
= WMGetListSelectedItemRow(panel
->gcolL
);
405 item
= WMGetListItem(panel
->gcolL
, row
);
407 rgb
= (RColor
*)item
->clientData
;
409 RHSVtoRGB(&hsv
, rgb
);
411 sprintf(item
->text
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
414 if (w
== panel
->ghueS
) {
415 updateSVSlider(panel
->gsatS
, True
, panel
->listFont
, &hsv
);
416 updateSVSlider(panel
->gvalS
, False
, panel
->listFont
, &hsv
);
417 } else if (w
== panel
->gsatS
) {
418 updateHueSlider(panel
->ghueS
, panel
->listFont
, &hsv
);
419 updateSVSlider(panel
->gvalS
, False
, panel
->listFont
, &hsv
);
421 updateHueSlider(panel
->ghueS
, panel
->listFont
, &hsv
);
422 updateSVSlider(panel
->gsatS
, True
, panel
->listFont
, &hsv
);
425 rows
= WMGetListNumberOfRows(panel
->gcolL
);
429 colors
= wmalloc(sizeof(RColor
*)*(rows
+1));
431 for (i
= 0; i
< rows
; i
++) {
432 item
= WMGetListItem(panel
->gcolL
, i
);
434 colors
[i
] = (RColor
*)item
->clientData
;
438 if (panel
->gimage
!= None
) {
439 XFreePixmap(WMScreenDisplay(scr
), panel
->gimage
);
442 image
= RRenderMultiGradient(30, i
*WMGetListItemHeight(panel
->gcolL
),
443 colors
, RVerticalGradient
);
444 RConvertImage(WMScreenRContext(scr
), image
, &panel
->gimage
);
445 RDestroyImage(image
);
449 WMRedisplayWidget(panel
->gcolL
);
451 updateGradButtons(panel
);
456 paintGradListItem(WMList
*lPtr
, int index
, Drawable d
, char *text
, int state
,
459 TexturePanel
*panel
= (TexturePanel
*)WMGetHangedData(lPtr
);
460 WMScreen
*scr
= WMWidgetScreen(lPtr
);
461 int width
, height
, x
, y
;
463 WMColor
*white
= WMWhiteColor(scr
);
465 WMColor
*black
= WMBlackColor(scr
);
467 dpy
= WMScreenDisplay(scr
);
469 width
= rect
->size
.width
;
470 height
= rect
->size
.height
;
474 if (state
& WLDSSelected
)
475 XFillRectangle(dpy
, d
, WMColorGC(white
), x
, y
, width
, height
);
477 XClearArea(dpy
, d
, x
, y
, width
, height
, False
);
479 item
= WMGetListItem(lPtr
, index
);
482 XCopyArea(WMScreenDisplay(scr
), panel
->gimage
, d
, WMColorGC(white
),
483 0, height
*index
, 30, height
, x
+ 5, y
);
485 WMDrawString(scr
, d
, WMColorGC(black
), panel
->listFont
,
486 x
+ 40, y
+ 1, text
, strlen(text
));
488 WMReleaseColor(white
);
489 WMReleaseColor(black
);
495 gradAddCallback(WMWidget
*w
, void *data
)
497 TexturePanel
*panel
= (TexturePanel
*)data
;
502 row
= WMGetListSelectedItemRow(panel
->gcolL
) + 1;
503 item
= WMInsertListItem(panel
->gcolL
, row
, "00,00,00");
504 rgb
= wmalloc(sizeof(RColor
));
505 memset(rgb
, 0, sizeof(RColor
));
506 item
->clientData
= rgb
;
508 WMSelectListItem(panel
->gcolL
, row
);
510 updateGradButtons(panel
);
512 sliderChangeCallback(panel
->ghueS
, panel
);
514 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
520 gradClickCallback(WMWidget
*w
, void *data
)
522 TexturePanel
*panel
= (TexturePanel
*)data
;
527 row
= WMGetListSelectedItemRow(w
);
531 item
= WMGetListItem(panel
->gcolL
, row
);
532 RRGBtoHSV((RColor
*)item
->clientData
, &hsv
);
534 WMSetSliderValue(panel
->ghueS
, hsv
.hue
);
535 WMSetSliderValue(panel
->gsatS
, hsv
.saturation
);
536 WMSetSliderValue(panel
->gvalS
, hsv
.value
);
538 sliderChangeCallback(panel
->ghueS
, panel
);
539 sliderChangeCallback(panel
->gsatS
, panel
);
544 gradDeleteCallback(WMWidget
*w
, void *data
)
546 TexturePanel
*panel
= (TexturePanel
*)data
;
550 row
= WMGetListSelectedItemRow(panel
->gcolL
);
554 item
= WMGetListItem(panel
->gcolL
, row
);
555 wfree(item
->clientData
);
557 WMRemoveListItem(panel
->gcolL
, row
);
559 WMSelectListItem(panel
->gcolL
, row
- 1);
561 updateGradButtons(panel
);
563 gradClickCallback(panel
->gcolL
, panel
);
565 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
569 /*************** Simple Gradient ***************/
572 colorWellObserver(void *self
, WMNotification
*n
)
574 updateSGradButtons(self
);
581 opaqChangeCallback(WMWidget
*w
, void *data
)
583 TexturePanel
*panel
= (TexturePanel
*)data
;
585 updateTGradImage(panel
);
588 /****************** Image ******************/
591 updateImage(TexturePanel
*panel
, char *path
)
593 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
599 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
603 message
= wstrconcat(_("Could not load the selected file: "),
604 (char*)RMessageForError(RErrorCode
));
606 WMRunAlertPanel(scr
, panel
->win
, _("Error"), message
,
607 _("OK"), NULL
, NULL
);
610 WMSetButtonEnabled(panel
->okB
, False
);
616 WMSetButtonEnabled(panel
->okB
, True
);
619 RDestroyImage(panel
->image
);
620 panel
->image
= image
;
622 image
= panel
->image
;
625 if (WMGetPopUpButtonSelectedItem(panel
->typeP
) == TYPE_PIXMAP
) {
627 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
629 size
= WMGetPixmapSize(pixmap
);
630 WMSetLabelImage(panel
->imageL
, pixmap
);
631 WMResizeWidget(panel
->imageL
, size
.width
, size
.height
);
633 WMReleasePixmap(pixmap
);
636 updateTGradImage(panel
);
642 browseImageCallback(WMWidget
*w
, void *data
)
644 TexturePanel
*panel
= (TexturePanel
*)data
;
646 WMScreen
*scr
= WMWidgetScreen(w
);
647 static char *ipath
= NULL
;
649 opanel
= WMGetOpenPanel(scr
);
650 WMSetFilePanelCanChooseDirectories(opanel
, False
);
651 WMSetFilePanelCanChooseFiles(opanel
, True
);
654 ipath
= wstrdup(wgethomedir());
656 if (WMRunModalFilePanelForDirectory(opanel
, panel
->win
, ipath
,
657 _("Open Image"), NULL
)) {
658 char *path
, *fullpath
;
661 tmp
= WMGetFilePanelFileName(opanel
);
669 path
= wstrdup(fullpath
);
671 tmp2
= strrchr(fullpath
, '/');
675 tmp
= wfindfileinarray(panel
->pathList
, tmp2
);
678 if (strcmp(fullpath
, tmp
)==0) {
685 if (!RGetImageFileFormat(fullpath
)) {
686 WMRunAlertPanel(scr
, panel
->win
, _("Error"),
687 _("The selected file does not contain a supported image."),
688 _("OK"), NULL
, NULL
);
691 updateImage(panel
, fullpath
);
692 wfree(panel
->imageFile
);
693 panel
->imageFile
= path
;
695 WMSetTextFieldText(panel
->imageT
, path
);
703 buttonCallback(WMWidget
*w
, void *data
)
705 TexturePanel
*panel
= (TexturePanel
*)data
;
707 if (w
== panel
->okB
) {
708 (*panel
->okAction
)(panel
->okData
);
710 (*panel
->cancelAction
)(panel
->cancelData
);
717 changeTypeCallback(WMWidget
*w
, void *data
)
719 TexturePanel
*panel
= (TexturePanel
*)data
;
723 newType
= WMGetPopUpButtonSelectedItem(w
);
724 if (newType
== panel
->currentType
)
727 if (panel
->currentType
>= 0) {
728 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
729 if (panel
->sectionParts
[panel
->currentType
][i
] == NULL
)
731 WMUnmapWidget(panel
->sectionParts
[panel
->currentType
][i
]);
735 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
736 if (panel
->sectionParts
[newType
][i
] == NULL
)
738 WMMapWidget(panel
->sectionParts
[newType
][i
]);
740 panel
->currentType
= newType
;
744 updateSGradButtons(panel
);
745 WMSetButtonEnabled(panel
->okB
, True
);
748 updateGradButtons(panel
);
749 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
)>1);
753 updateImage(panel
, NULL
);
754 WMSetButtonEnabled(panel
->okB
, panel
->image
!=NULL
);
757 WMSetButtonEnabled(panel
->okB
, True
);
764 *--------------------------------------------------------------------------
766 *--------------------------------------------------------------------------
769 DestroyTexturePanel(TexturePanel
*panel
)
776 ShowTexturePanel(TexturePanel
*panel
)
778 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(panel
->win
));
779 Screen
*scr
= DefaultScreenOfDisplay(dpy
);
781 WMSetWindowInitialPosition(panel
->win
,
782 (WidthOfScreen(scr
)-WMWidgetWidth(panel
->win
))/2,
783 (HeightOfScreen(scr
)-WMWidgetHeight(panel
->win
))/2);
784 WMMapWidget(panel
->win
);
789 HideTexturePanel(TexturePanel
*panel
)
791 WMUnmapWidget(panel
->win
);
796 SetTexturePanelOkAction(TexturePanel
*panel
, WMCallback
*action
, void *clientData
)
798 panel
->okAction
= action
;
799 panel
->okData
= clientData
;
804 SetTexturePanelCancelAction(TexturePanel
*panel
, WMCallback
*action
, void *clientData
)
806 panel
->cancelAction
= action
;
807 panel
->cancelData
= clientData
;
812 SetTexturePanelTexture(TexturePanel
*panel
, char *name
, proplist_t texture
)
814 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
822 WMSetTextFieldText(panel
->nameT
, name
);
827 p
= PLGetArrayElement(texture
, 0);
831 type
= PLGetString(p
);
833 /*...............................................*/
834 if (strcasecmp(type
, "solid")==0) {
836 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SOLID
);
838 p
= PLGetArrayElement(texture
, 1);
842 str
= PLGetString(p
);
844 color
= WMCreateNamedColor(scr
, str
, False
);
846 WMSetColorWellColor(panel
->defcW
, color
);
848 WMReleaseColor(color
);
849 /*...............................................*/
850 } else if (strcasecmp(type
, "hgradient")==0
851 || strcasecmp(type
, "vgradient")==0
852 || strcasecmp(type
, "dgradient")==0) {
854 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SGRADIENT
);
856 p
= PLGetArrayElement(texture
, 1);
860 str
= PLGetString(p
);
862 color
= WMCreateNamedColor(scr
, str
, False
);
864 WMSetColorWellColor(panel
->tcol1W
, color
);
866 WMReleaseColor(color
);
868 p
= PLGetArrayElement(texture
, 2);
872 str
= PLGetString(p
);
874 color
= WMCreateNamedColor(scr
, str
, False
);
876 WMSetColorWellColor(panel
->tcol2W
, color
);
878 WMReleaseColor(color
);
881 /*...............................................*/
882 } else if (strcasecmp(type
, "thgradient")==0
883 || strcasecmp(type
, "tvgradient")==0
884 || strcasecmp(type
, "tdgradient")==0) {
887 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_TGRADIENT
);
891 WMSetTextFieldText(panel
->imageT
,
892 PLGetString(PLGetArrayElement(texture
, 1)));
893 if (panel
->imageFile
)
894 wfree(panel
->imageFile
);
895 panel
->imageFile
= wstrdup(PLGetString(PLGetArrayElement(texture
, 1)));
899 sscanf(PLGetString(PLGetArrayElement(texture
, 2)), "%i", &i
);
900 WMSetSliderValue(panel
->topaS
, i
);
902 p
= PLGetArrayElement(texture
, 3);
906 str
= PLGetString(p
);
908 color
= WMCreateNamedColor(scr
, str
, False
);
910 WMSetColorWellColor(panel
->tcol1W
, color
);
912 WMReleaseColor(color
);
914 p
= PLGetArrayElement(texture
, 4);
918 str
= PLGetString(p
);
920 color
= WMCreateNamedColor(scr
, str
, False
);
922 WMSetColorWellColor(panel
->tcol2W
, color
);
924 WMReleaseColor(color
);
926 WMSetTextFieldText(panel
->imageT
,
927 PLGetString(PLGetArrayElement(texture
, 1)));
929 if (panel
->imageFile
)
930 wfree(panel
->imageFile
);
931 if ((panel
->imageFile
= wfindfileinarray(panel
->pathList
,
932 PLGetString(PLGetArrayElement(texture
, 1)))) != NULL
) {
934 panel
->image
= RLoadImage(WMScreenRContext(scr
), panel
->imageFile
, 0);
935 updateTGradImage(panel
);
937 updateSGradButtons(panel
);
938 } else wwarning(_("could not load file '%s': %s"), panel
->imageFile
,
939 RMessageForError(RErrorCode
));
941 /*...............................................*/
942 } else if (strcasecmp(type
, "mhgradient")==0
943 || strcasecmp(type
, "mvgradient")==0
944 || strcasecmp(type
, "mdgradient")==0) {
947 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
948 item
= WMGetListItem(panel
->gcolL
, i
);
949 wfree(item
->clientData
);
951 WMClearList(panel
->gcolL
);
953 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_GRADIENT
);
955 p
= PLGetArrayElement(texture
, 1);
959 str
= PLGetString(p
);
961 color
= WMCreateNamedColor(scr
, str
, False
);
963 WMSetColorWellColor(panel
->defcW
, color
);
965 WMReleaseColor(color
);
967 for (i
= 2; i
< PLGetNumberOfElements(texture
); i
++) {
971 p
= PLGetArrayElement(texture
, i
);
975 str
= PLGetString(p
);
978 XParseColor(WMScreenDisplay(scr
), WMScreenRContext(scr
)->cmap
,
981 rgb
= wmalloc(sizeof(RColor
));
982 rgb
->red
= xcolor
.red
>> 8;
983 rgb
->green
= xcolor
.green
>> 8;
984 rgb
->blue
= xcolor
.blue
>> 8;
985 sprintf(buffer
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
987 item
= WMAddListItem(panel
->gcolL
, buffer
);
988 item
->clientData
= rgb
;
991 sliderChangeCallback(panel
->ghueS
, panel
);
994 /*...............................................*/
995 } else if (strcasecmp(type
, "cpixmap")==0
996 || strcasecmp(type
, "spixmap")==0
997 || strcasecmp(type
, "mpixmap")==0
998 || strcasecmp(type
, "tpixmap")==0) {
1000 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_PIXMAP
);
1002 switch (toupper(type
[0])) {
1004 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_CENTER
);
1007 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_SCALE
);
1010 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_MAXIMIZE
);
1014 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_TILE
);
1018 WMSetTextFieldText(panel
->imageT
,
1019 PLGetString(PLGetArrayElement(texture
, 1)));
1021 if (panel
->imageFile
)
1022 wfree(panel
->imageFile
);
1023 panel
->imageFile
= wfindfileinarray(panel
->pathList
,
1024 PLGetString(PLGetArrayElement(texture
, 1)));
1026 color
= WMCreateNamedColor(scr
,
1027 PLGetString(PLGetArrayElement(texture
, 2)), False
);
1028 WMSetColorWellColor(panel
->defcW
, color
);
1029 WMReleaseColor(color
);
1031 updateImage(panel
, panel
->imageFile
);
1034 changeTypeCallback(panel
->typeP
, panel
);
1037 updateGradButtons(panel
);
1039 switch (toupper(gradient
)) {
1041 WMPerformButtonClick(panel
->dirhB
);
1044 WMPerformButtonClick(panel
->dirvB
);
1048 WMPerformButtonClick(panel
->dirdB
);
1056 str
= PLGetDescription(texture
);
1057 wwarning(_("error creating texture %s"), str
);
1065 GetTexturePanelTextureName(TexturePanel
*panel
)
1067 return WMGetTextFieldText(panel
->nameT
);
1074 GetTexturePanelTexture(TexturePanel
*panel
)
1076 proplist_t prop
= NULL
;
1083 switch (WMGetPopUpButtonSelectedItem(panel
->typeP
)) {
1086 color
= WMGetColorWellColor(panel
->defcW
);
1087 str
= WMGetColorRGBDescription(color
);
1088 prop
= PLMakeArrayFromElements(PLMakeString("solid"),
1089 PLMakeString(str
), NULL
);
1095 color
= WMGetColorWellColor(panel
->defcW
);
1096 str
= WMGetColorRGBDescription(color
);
1098 switch (WMGetPopUpButtonSelectedItem(panel
->arrP
)) {
1100 prop
= PLMakeArrayFromElements(PLMakeString("spixmap"),
1101 PLMakeString(panel
->imageFile
),
1102 PLMakeString(str
), NULL
);
1104 case PTYPE_MAXIMIZE
:
1105 prop
= PLMakeArrayFromElements(PLMakeString("mpixmap"),
1106 PLMakeString(panel
->imageFile
),
1107 PLMakeString(str
), NULL
);
1110 prop
= PLMakeArrayFromElements(PLMakeString("cpixmap"),
1111 PLMakeString(panel
->imageFile
),
1112 PLMakeString(str
), NULL
);
1115 prop
= PLMakeArrayFromElements(PLMakeString("tpixmap"),
1116 PLMakeString(panel
->imageFile
),
1117 PLMakeString(str
), NULL
);
1123 case TYPE_TGRADIENT
:
1124 color
= WMGetColorWellColor(panel
->tcol1W
);
1125 str
= WMGetColorRGBDescription(color
);
1127 color
= WMGetColorWellColor(panel
->tcol2W
);
1128 str2
= WMGetColorRGBDescription(color
);
1130 sprintf(buff
, "%i", WMGetSliderValue(panel
->topaS
));
1132 if (WMGetButtonSelected(panel
->dirdB
)) {
1133 prop
= PLMakeArrayFromElements(PLMakeString("tdgradient"),
1134 PLMakeString(panel
->imageFile
),
1137 PLMakeString(str2
), NULL
);
1138 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1139 prop
= PLMakeArrayFromElements(PLMakeString("tvgradient"),
1140 PLMakeString(panel
->imageFile
),
1143 PLMakeString(str2
), NULL
);
1145 prop
= PLMakeArrayFromElements(PLMakeString("thgradient"),
1146 PLMakeString(panel
->imageFile
),
1149 PLMakeString(str2
), NULL
);
1156 case TYPE_SGRADIENT
:
1157 color
= WMGetColorWellColor(panel
->tcol1W
);
1158 str
= WMGetColorRGBDescription(color
);
1160 color
= WMGetColorWellColor(panel
->tcol2W
);
1161 str2
= WMGetColorRGBDescription(color
);
1163 if (WMGetButtonSelected(panel
->dirdB
)) {
1164 prop
= PLMakeArrayFromElements(PLMakeString("dgradient"),
1166 PLMakeString(str2
), NULL
);
1167 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1168 prop
= PLMakeArrayFromElements(PLMakeString("vgradient"),
1170 PLMakeString(str2
), NULL
);
1172 prop
= PLMakeArrayFromElements(PLMakeString("hgradient"),
1174 PLMakeString(str2
), NULL
);
1181 color
= WMGetColorWellColor(panel
->defcW
);
1182 str
= WMGetColorRGBDescription(color
);
1184 if (WMGetButtonSelected(panel
->dirdB
)) {
1185 prop
= PLMakeArrayFromElements(PLMakeString("mdgradient"),
1186 PLMakeString(str
), NULL
);
1187 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1188 prop
= PLMakeArrayFromElements(PLMakeString("mvgradient"),
1189 PLMakeString(str
), NULL
);
1191 prop
= PLMakeArrayFromElements(PLMakeString("mhgradient"),
1192 PLMakeString(str
), NULL
);
1196 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
1200 item
= WMGetListItem(panel
->gcolL
, i
);
1202 rgb
= (RColor
*)item
->clientData
;
1204 sprintf(buff
, "#%02x%02x%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
1206 PLAppendArrayElement(prop
, PLMakeString(buff
));
1218 SetTexturePanelPixmapPath(TexturePanel
*panel
, proplist_t array
)
1220 panel
->pathList
= array
;
1226 CreateTexturePanel(WMWindow
*keyWindow
)
1227 /*CreateTexturePanel(WMScreen *scr)*/
1229 TexturePanel
*panel
;
1230 WMScreen
*scr
= WMWidgetScreen(keyWindow
);
1232 panel
= wmalloc(sizeof(TexturePanel
));
1233 memset(panel
, 0, sizeof(TexturePanel
));
1235 panel
->listFont
= WMSystemFontOfSize(scr
, 12);
1238 panel
->win
= WMCreatePanelWithStyleForWindow(keyWindow
, "texturePanel",
1240 |WMClosableWindowMask
);
1242 panel->win = WMCreateWindowWithStyle(scr, "texturePanel",
1244 |WMClosableWindowMask);
1247 WMResizeWidget(panel
->win
, 325, 423);
1248 WMSetWindowTitle(panel
->win
, _("Texture Panel"));
1249 WMSetWindowCloseAction(panel
->win
, buttonCallback
, panel
);
1253 panel
->nameF
= WMCreateFrame(panel
->win
);
1254 WMResizeWidget(panel
->nameF
, 185, 50);
1255 WMMoveWidget(panel
->nameF
, 15, 10);
1256 WMSetFrameTitle(panel
->nameF
, _("Texture Name"));
1258 panel
->nameT
= WMCreateTextField(panel
->nameF
);
1259 WMResizeWidget(panel
->nameT
, 160, 20);
1260 WMMoveWidget(panel
->nameT
, 12, 18);
1262 WMMapSubwidgets(panel
->nameF
);
1265 panel
->typeP
= WMCreatePopUpButton(panel
->win
);
1266 WMResizeWidget(panel
->typeP
, 185, 20);
1267 WMMoveWidget(panel
->typeP
, 15, 65);
1268 WMAddPopUpButtonItem(panel
->typeP
, _("Solid Color"));
1269 WMAddPopUpButtonItem(panel
->typeP
, _("Gradient Texture"));
1270 WMAddPopUpButtonItem(panel
->typeP
, _("Simple Gradient Texture"));
1271 WMAddPopUpButtonItem(panel
->typeP
, _("Textured Gradient"));
1272 WMAddPopUpButtonItem(panel
->typeP
, _("Image Texture"));
1273 WMSetPopUpButtonSelectedItem(panel
->typeP
, 0);
1274 WMSetPopUpButtonAction(panel
->typeP
, changeTypeCallback
, panel
);
1277 panel
->defcF
= WMCreateFrame(panel
->win
);
1278 WMResizeWidget(panel
->defcF
, 100, 75);
1279 WMMoveWidget(panel
->defcF
, 210, 10);
1280 WMSetFrameTitle(panel
->defcF
, _("Default Color"));
1282 panel
->defcW
= WMCreateColorWell(panel
->defcF
);
1283 WMResizeWidget(panel
->defcW
, 60, 45);
1284 WMMoveWidget(panel
->defcW
, 20, 20);
1286 WMMapSubwidgets(panel
->defcF
);
1288 /****** Gradient ******/
1289 panel
->gcolF
= WMCreateFrame(panel
->win
);
1290 WMResizeWidget(panel
->gcolF
, 295, 205);
1291 WMMoveWidget(panel
->gcolF
, 15, 95);
1292 WMSetFrameTitle(panel
->gcolF
, _("Gradient Colors"));
1294 panel
->gcolL
= WMCreateList(panel
->gcolF
);
1295 WMResizeWidget(panel
->gcolL
, 130, 140);
1296 WMMoveWidget(panel
->gcolL
, 10, 25);
1297 WMHangData(panel
->gcolL
, panel
);
1298 WMSetListUserDrawProc(panel
->gcolL
, paintGradListItem
);
1299 WMSetListAction(panel
->gcolL
, gradClickCallback
, panel
);
1301 panel
->gcolaB
= WMCreateCommandButton(panel
->gcolF
);
1302 WMResizeWidget(panel
->gcolaB
, 64, 24);
1303 WMMoveWidget(panel
->gcolaB
, 10, 170);
1304 WMSetButtonText(panel
->gcolaB
, _("Add"));
1305 WMSetButtonAction(panel
->gcolaB
, gradAddCallback
, panel
);
1307 panel
->gcoldB
= WMCreateCommandButton(panel
->gcolF
);
1308 WMResizeWidget(panel
->gcoldB
, 64, 24);
1309 WMMoveWidget(panel
->gcoldB
, 75, 170);
1310 WMSetButtonText(panel
->gcoldB
, _("Delete"));
1311 WMSetButtonAction(panel
->gcoldB
, gradDeleteCallback
, panel
);
1314 panel
->gbriS
= WMCreateSlider(panel
->gcolF
);
1315 WMResizeWidget(panel
->gbriS
, 130, 16);
1316 WMMoveWidget(panel
->gbriS
, 150, 25);
1317 WMSetSliderKnobThickness(panel
->gbriS
, 8);
1318 WMSetSliderMaxValue(panel
->gbriS
, 100);
1319 WMSetSliderAction(panel
->gbriS
, sliderChangeCallback
, panel
);
1324 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1325 color
= WMDarkGrayColor(scr
);
1326 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
),
1327 WMColorGC(color
), 0, 0, 130, 16);
1328 WMReleaseColor(color
);
1329 color
= WMWhiteColor(color
);
1330 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(color
),
1332 (16 - WMFontHeight(panel
->listFont
))/2 - 1,
1334 WMSetSliderImage(panel
->gbriS
, pixmap
);
1335 WMReleasePixmap(pixmap
);
1338 panel
->gconS
= WMCreateSlider(panel
->gcolF
);
1339 WMResizeWidget(panel
->gconS
, 130, 16);
1340 WMMoveWidget(panel
->gconS
, 150, 50);
1341 WMSetSliderKnobThickness(panel
->gconS
, 8);
1342 WMSetSliderMaxValue(panel
->gconS
, 100);
1343 WMSetSliderAction(panel
->gconS
, sliderChangeCallback
, panel
);
1348 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1349 color
= WMDarkGrayColor(scr
);
1350 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
),
1351 WMColorGC(color
), 0, 0, 130, 16);
1352 WMReleaseColor(color
);
1353 color
= WMWhiteColor(scr
);
1354 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(color
),
1356 (16 - WMFontHeight(panel
->listFont
))/2 - 1,
1358 WMSetSliderImage(panel
->gconS
, pixmap
);
1359 WMReleasePixmap(pixmap
);
1362 panel
->ghueS
= WMCreateSlider(panel
->gcolF
);
1363 WMResizeWidget(panel
->ghueS
, 130, 16);
1364 WMMoveWidget(panel
->ghueS
, 150, 100);
1365 WMSetSliderKnobThickness(panel
->ghueS
, 8);
1366 WMSetSliderMaxValue(panel
->ghueS
, 359);
1367 WMSetSliderAction(panel
->ghueS
, sliderChangeCallback
, panel
);
1369 panel
->gsatS
= WMCreateSlider(panel
->gcolF
);
1370 WMResizeWidget(panel
->gsatS
, 130, 16);
1371 WMMoveWidget(panel
->gsatS
, 150, 125);
1372 WMSetSliderKnobThickness(panel
->gsatS
, 8);
1373 WMSetSliderMaxValue(panel
->gsatS
, 255);
1374 WMSetSliderAction(panel
->gsatS
, sliderChangeCallback
, panel
);
1376 panel
->gvalS
= WMCreateSlider(panel
->gcolF
);
1377 WMResizeWidget(panel
->gvalS
, 130, 16);
1378 WMMoveWidget(panel
->gvalS
, 150, 150);
1379 WMSetSliderKnobThickness(panel
->gvalS
, 8);
1380 WMSetSliderMaxValue(panel
->gvalS
, 255);
1381 WMSetSliderAction(panel
->gvalS
, sliderChangeCallback
, panel
);
1384 WMMapSubwidgets(panel
->gcolF
);
1387 panel
->dirF
= WMCreateFrame(panel
->win
);
1388 WMSetFrameTitle(panel
->dirF
, _("Direction"));
1389 WMResizeWidget(panel
->dirF
, 295, 75);
1390 WMMoveWidget(panel
->dirF
, 15, 305);
1392 panel
->dirvB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1393 WMSetButtonImagePosition(panel
->dirvB
, WIPImageOnly
);
1394 WMResizeWidget(panel
->dirvB
, 90, 40);
1395 WMMoveWidget(panel
->dirvB
, 10, 20);
1397 panel
->dirhB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1398 WMSetButtonImagePosition(panel
->dirhB
, WIPImageOnly
);
1399 WMResizeWidget(panel
->dirhB
, 90, 40);
1400 WMMoveWidget(panel
->dirhB
, 102, 20);
1402 panel
->dirdB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1403 WMSetButtonImagePosition(panel
->dirdB
, WIPImageOnly
);
1404 WMResizeWidget(panel
->dirdB
, 90, 40);
1405 WMMoveWidget(panel
->dirdB
, 194, 20);
1407 WMGroupButtons(panel
->dirvB
, panel
->dirhB
);
1408 WMGroupButtons(panel
->dirvB
, panel
->dirdB
);
1410 WMMapSubwidgets(panel
->dirF
);
1412 /****************** Textured Gradient ******************/
1413 panel
->tcolF
= WMCreateFrame(panel
->win
);
1414 WMResizeWidget(panel
->tcolF
, 100, 135);
1415 WMMoveWidget(panel
->tcolF
, 210, 10);
1416 WMSetFrameTitle(panel
->tcolF
, _("Gradient"));
1418 panel
->tcol1W
= WMCreateColorWell(panel
->tcolF
);
1419 WMResizeWidget(panel
->tcol1W
, 60, 45);
1420 WMMoveWidget(panel
->tcol1W
, 20, 25);
1421 WMAddNotificationObserver(colorWellObserver
, panel
,
1422 WMColorWellDidChangeNotification
, panel
->tcol1W
);
1424 panel
->tcol2W
= WMCreateColorWell(panel
->tcolF
);
1425 WMResizeWidget(panel
->tcol2W
, 60, 45);
1426 WMMoveWidget(panel
->tcol2W
, 20, 75);
1427 WMAddNotificationObserver(colorWellObserver
, panel
,
1428 WMColorWellDidChangeNotification
, panel
->tcol2W
);
1431 panel
->topaF
= WMCreateFrame(panel
->win
);
1432 WMResizeWidget(panel
->topaF
, 185, 50);
1433 WMMoveWidget(panel
->topaF
, 15, 95);
1434 WMSetFrameTitle(panel
->topaF
, _("Gradient Opacity"));
1436 panel
->topaS
= WMCreateSlider(panel
->topaF
);
1437 WMResizeWidget(panel
->topaS
, 155, 18);
1438 WMMoveWidget(panel
->topaS
, 15, 20);
1439 WMSetSliderMaxValue(panel
->topaS
, 255);
1440 WMSetSliderValue(panel
->topaS
, 200);
1441 WMSetSliderContinuous(panel
->topaS
, False
);
1442 WMSetSliderAction(panel
->topaS
, opaqChangeCallback
, panel
);
1444 WMMapSubwidgets(panel
->topaF
);
1451 pixmap
= WMCreatePixmap(scr
, 155, 18, WMScreenDepth(scr
), False
);
1452 p
= WMGetPixmapXID(pixmap
);
1454 color
= WMDarkGrayColor(scr
);
1455 XFillRectangle(WMScreenDisplay(scr
), p
, WMColorGC(color
),
1457 WMReleaseColor(color
);
1459 color
= WMWhiteColor(scr
);
1460 WMDrawString(scr
, p
, WMColorGC(color
), panel
->listFont
,
1462 WMDrawString(scr
, p
, WMColorGC(color
), panel
->listFont
,
1463 153 - WMWidthOfString(panel
->listFont
, "100%", 4), 1,
1465 WMReleaseColor(color
);
1467 WMSetSliderImage(panel
->topaS
, pixmap
);
1468 WMReleasePixmap(pixmap
);
1471 WMMapSubwidgets(panel
->tcolF
);
1473 /****************** Image ******************/
1474 panel
->imageF
= WMCreateFrame(panel
->win
);
1475 WMResizeWidget(panel
->imageF
, 295, 150);
1476 WMMoveWidget(panel
->imageF
, 15, 150);
1477 WMSetFrameTitle(panel
->imageF
, _("Image"));
1479 panel
->imageL
= WMCreateLabel(panel
->imageF
);
1480 WMSetLabelImagePosition(panel
->imageL
, WIPImageOnly
);
1482 panel
->imageT
= WMCreateTextField(panel
->imageF
);
1483 WMResizeWidget(panel
->imageT
, 90, 20);
1484 WMMoveWidget(panel
->imageT
, 190, 25);
1486 panel
->imageV
= WMCreateScrollView(panel
->imageF
);
1487 WMResizeWidget(panel
->imageV
, 165, 115);
1488 WMMoveWidget(panel
->imageV
, 15, 20);
1489 WMSetScrollViewRelief(panel
->imageV
, WRSunken
);
1490 WMSetScrollViewHasHorizontalScroller(panel
->imageV
, True
);
1491 WMSetScrollViewHasVerticalScroller(panel
->imageV
, True
);
1492 WMSetScrollViewContentView(panel
->imageV
, WMWidgetView(panel
->imageL
));
1494 panel
->browB
= WMCreateCommandButton(panel
->imageF
);
1495 WMResizeWidget(panel
->browB
, 90, 24);
1496 WMMoveWidget(panel
->browB
, 190, 50);
1497 WMSetButtonText(panel
->browB
, _("Browse..."));
1498 WMSetButtonAction(panel
->browB
, browseImageCallback
, panel
);
1500 /* panel->dispB = WMCreateCommandButton(panel->imageF);
1501 WMResizeWidget(panel->dispB, 90, 24);
1502 WMMoveWidget(panel->dispB, 190, 80);
1503 WMSetButtonText(panel->dispB, _("Show"));
1506 panel
->arrP
= WMCreatePopUpButton(panel
->imageF
);
1507 WMResizeWidget(panel
->arrP
, 90, 20);
1508 WMMoveWidget(panel
->arrP
, 190, 120);
1509 WMAddPopUpButtonItem(panel
->arrP
, _("Tile"));
1510 WMAddPopUpButtonItem(panel
->arrP
, _("Scale"));
1511 WMAddPopUpButtonItem(panel
->arrP
, _("Center"));
1512 WMAddPopUpButtonItem(panel
->arrP
, _("Maximize"));
1513 WMSetPopUpButtonSelectedItem(panel
->arrP
, 0);
1515 WMMapSubwidgets(panel
->imageF
);
1519 panel
->okB
= WMCreateCommandButton(panel
->win
);
1520 WMResizeWidget(panel
->okB
, 84, 24);
1521 WMMoveWidget(panel
->okB
, 225, 390);
1522 WMSetButtonText(panel
->okB
, _("OK"));
1523 WMSetButtonAction(panel
->okB
, buttonCallback
, panel
);
1525 panel
->cancelB
= WMCreateCommandButton(panel
->win
);
1526 WMResizeWidget(panel
->cancelB
, 84, 24);
1527 WMMoveWidget(panel
->cancelB
, 130, 390);
1528 WMSetButtonText(panel
->cancelB
, _("Cancel"));
1529 WMSetButtonAction(panel
->cancelB
, buttonCallback
, panel
);
1531 WMMapWidget(panel
->nameF
);
1532 WMMapWidget(panel
->typeP
);
1533 WMMapWidget(panel
->okB
);
1534 WMMapWidget(panel
->cancelB
);
1536 WMUnmapWidget(panel
->arrP
);
1538 WMRealizeWidget(panel
->win
);
1540 panel
->currentType
= -1;
1542 panel
->sectionParts
[TYPE_SOLID
][0] = panel
->defcF
;
1544 panel
->sectionParts
[TYPE_GRADIENT
][0] = panel
->defcF
;
1545 panel
->sectionParts
[TYPE_GRADIENT
][1] = panel
->gcolF
;
1546 panel
->sectionParts
[TYPE_GRADIENT
][2] = panel
->dirF
;
1548 panel
->sectionParts
[TYPE_SGRADIENT
][0] = panel
->tcolF
;
1549 panel
->sectionParts
[TYPE_SGRADIENT
][1] = panel
->dirF
;
1551 panel
->sectionParts
[TYPE_TGRADIENT
][0] = panel
->tcolF
;
1552 panel
->sectionParts
[TYPE_TGRADIENT
][1] = panel
->dirF
;
1553 panel
->sectionParts
[TYPE_TGRADIENT
][2] = panel
->imageF
;
1554 panel
->sectionParts
[TYPE_TGRADIENT
][3] = panel
->topaF
;
1555 panel
->sectionParts
[TYPE_TGRADIENT
][4] = panel
->arrP
;
1557 panel
->sectionParts
[TYPE_PIXMAP
][0] = panel
->defcF
;
1558 panel
->sectionParts
[TYPE_PIXMAP
][1] = panel
->imageF
;
1559 panel
->sectionParts
[TYPE_PIXMAP
][2] = panel
->arrP
;
1562 /* setup for first time */
1564 changeTypeCallback(panel
->typeP
, panel
);
1566 sliderChangeCallback(panel
->ghueS
, panel
);
1567 sliderChangeCallback(panel
->gsatS
, panel
);
1575 *--------------------------------------------------------------------------
1577 *--------------------------------------------------------------------------
1582 char *ProgName
= "test";
1585 testOKButton(WMWidget
*self
, void *data
)
1593 TexturePanel
*panel
= (TexturePanel
*)data
;
1594 /* test = GetTexturePanelTextureString(panel); */
1598 dpy
= WMScreenDisplay(WMWidgetScreen(panel
->okB
));
1599 win
= XCreateSimpleWindow(dpy
, DefaultRootWindow(dpy
), 10, 10, 250, 250,
1601 XMapRaised(dpy
, win
);
1604 /* image = RenderTexturePanelTexture(panel, 250, 250); */
1606 RConvertImage(WMScreenRContext(WMWidgetScreen(panel
->okB
)), image
, &pix
);
1608 XCopyArea(dpy
, pix
, win
, (WMScreenRContext(WMWidgetScreen(panel
->okB
)))->copy_gc
, 0, 0, image
->width
, image
->height
,
1615 void testCancelButton(WMWidget
*self
, void *data
){
1616 wwarning("Exiting test....");
1625 int main(int argc
, char **argv
)
1627 TexturePanel
*panel
;
1629 Display
*dpy
= XOpenDisplay("");
1634 WMInitializeApplication("Test", &argc
, argv
);
1637 wfatal("could not open display");
1641 scr
= WMCreateSimpleApplicationScreen(dpy
);
1643 panel
= CreateTexturePanel(scr
);
1645 SetTexturePanelOkAction(panel
,(WMAction
*)testOKButton
,panel
);
1646 SetTexturePanelCancelAction(panel
,(WMAction
*)testCancelButton
,panel
);
1648 SetTexturePanelTexture(panel
, "pinky",
1649 PLGetProplistWithDescription("(mdgradient, pink, red, blue, yellow)"));
1651 ShowTexturePanel(panel
);
1653 WMScreenMainLoop(scr
);