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 WMReleasePixmap(pixmap
);
249 WMResizeWidget(panel
->imageL
, image
->width
, image
->height
);
250 RDestroyImage(image
);
255 updateSGradButtons(TexturePanel
*panel
)
263 color
= WMGetColorWellColor(panel
->tcol1W
);
264 from
.red
= WMRedComponentOfColor(color
)>>8;
265 from
.green
= WMGreenComponentOfColor(color
)>>8;
266 from
.blue
= WMBlueComponentOfColor(color
)>>8;
268 color
= WMGetColorWellColor(panel
->tcol2W
);
269 to
.red
= WMRedComponentOfColor(color
)>>8;
270 to
.green
= WMGreenComponentOfColor(color
)>>8;
271 to
.blue
= WMBlueComponentOfColor(color
)>>8;
273 image
= RRenderGradient(80, 30, &from
, &to
, RHorizontalGradient
);
274 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
276 RDestroyImage(image
);
277 WMSetButtonImage(panel
->dirhB
, pixmap
);
278 WMReleasePixmap(pixmap
);
280 image
= RRenderGradient(80, 30, &from
, &to
, RVerticalGradient
);
281 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
283 RDestroyImage(image
);
284 WMSetButtonImage(panel
->dirvB
, pixmap
);
285 WMReleasePixmap(pixmap
);
287 image
= RRenderGradient(80, 30, &from
, &to
, RDiagonalGradient
);
288 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
290 RDestroyImage(image
);
291 WMSetButtonImage(panel
->dirdB
, pixmap
);
292 WMReleasePixmap(pixmap
);
296 /*********** Gradient ************/
299 updateSVSlider(WMSlider
*sPtr
, Bool saturation
, WMFont
*font
, RHSVColor
*hsv
)
303 WMScreen
*scr
= WMWidgetScreen(sPtr
);
310 RHSVtoRGB(&tmp
, &from
);
311 tmp
.saturation
= 255;
312 RHSVtoRGB(&tmp
, &to
);
315 RHSVtoRGB(&tmp
, &from
);
317 RHSVtoRGB(&tmp
, &to
);
319 image
= RRenderGradient(130, 16, &from
, &to
, RHorizontalGradient
);
320 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
321 RDestroyImage(image
);
323 if (hsv
->value
< 128 || !saturation
) {
324 WMColor
*col
= WMWhiteColor(scr
);
326 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
327 (16 - WMFontHeight(font
))/2 - 1,
328 saturation
? "Saturation" : "Brightness", 10);
331 WMColor
*col
= WMBlackColor(scr
);
333 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
334 (16 - WMFontHeight(font
))/2 - 1,
335 saturation
? "Saturation" : "Brightness", 10);
338 WMSetSliderImage(sPtr
, pixmap
);
339 WMReleasePixmap(pixmap
);
344 updateHueSlider(WMSlider
*sPtr
, WMFont
*font
, RHSVColor
*hsv
)
349 WMScreen
*scr
= WMWidgetScreen(sPtr
);
354 for (i
= 0; i
<= 6; i
++) {
355 thsv
.hue
= (360*i
)/6;
356 colors
[i
] = wmalloc(sizeof(RColor
));
357 RHSVtoRGB(&thsv
, colors
[i
]);
361 image
= RRenderMultiGradient(130, 16, colors
, RGRD_HORIZONTAL
);
362 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
363 RDestroyImage(image
);
365 if (hsv
->value
< 128) {
366 WMColor
*col
= WMWhiteColor(scr
);
368 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
369 (16 - WMFontHeight(font
))/2 - 1, "Hue", 3);
372 WMColor
*col
= WMBlackColor(scr
);
374 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(col
), font
, 2,
375 (16 - WMFontHeight(font
))/2 - 1, "Hue", 3);
378 WMSetSliderImage(sPtr
, pixmap
);
379 WMReleasePixmap(pixmap
);
381 for (i
= 0; i
<= 6; i
++)
388 sliderChangeCallback(WMWidget
*w
, void *data
)
390 TexturePanel
*panel
= (TexturePanel
*)data
;
397 WMScreen
*scr
= WMWidgetScreen(w
);
399 hsv
.hue
= WMGetSliderValue(panel
->ghueS
);
400 hsv
.saturation
= WMGetSliderValue(panel
->gsatS
);
401 hsv
.value
= WMGetSliderValue(panel
->gvalS
);
403 row
= WMGetListSelectedItemRow(panel
->gcolL
);
407 item
= WMGetListItem(panel
->gcolL
, row
);
409 rgb
= (RColor
*)item
->clientData
;
411 RHSVtoRGB(&hsv
, rgb
);
413 sprintf(item
->text
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
416 if (w
== panel
->ghueS
) {
417 updateSVSlider(panel
->gsatS
, True
, panel
->listFont
, &hsv
);
418 updateSVSlider(panel
->gvalS
, False
, panel
->listFont
, &hsv
);
419 } else if (w
== panel
->gsatS
) {
420 updateHueSlider(panel
->ghueS
, panel
->listFont
, &hsv
);
421 updateSVSlider(panel
->gvalS
, False
, panel
->listFont
, &hsv
);
423 updateHueSlider(panel
->ghueS
, panel
->listFont
, &hsv
);
424 updateSVSlider(panel
->gsatS
, True
, panel
->listFont
, &hsv
);
427 rows
= WMGetListNumberOfRows(panel
->gcolL
);
431 colors
= wmalloc(sizeof(RColor
*)*(rows
+1));
433 for (i
= 0; i
< rows
; i
++) {
434 item
= WMGetListItem(panel
->gcolL
, i
);
436 colors
[i
] = (RColor
*)item
->clientData
;
440 if (panel
->gimage
!= None
) {
441 XFreePixmap(WMScreenDisplay(scr
), panel
->gimage
);
444 image
= RRenderMultiGradient(30, i
*WMGetListItemHeight(panel
->gcolL
),
445 colors
, RVerticalGradient
);
446 RConvertImage(WMScreenRContext(scr
), image
, &panel
->gimage
);
447 RDestroyImage(image
);
451 WMRedisplayWidget(panel
->gcolL
);
453 updateGradButtons(panel
);
458 paintGradListItem(WMList
*lPtr
, int index
, Drawable d
, char *text
, int state
,
461 TexturePanel
*panel
= (TexturePanel
*)WMGetHangedData(lPtr
);
462 WMScreen
*scr
= WMWidgetScreen(lPtr
);
463 int width
, height
, x
, y
;
465 WMColor
*white
= WMWhiteColor(scr
);
467 WMColor
*black
= WMBlackColor(scr
);
469 dpy
= WMScreenDisplay(scr
);
471 width
= rect
->size
.width
;
472 height
= rect
->size
.height
;
476 if (state
& WLDSSelected
)
477 XFillRectangle(dpy
, d
, WMColorGC(white
), x
, y
, width
, height
);
479 XClearArea(dpy
, d
, x
, y
, width
, height
, False
);
481 item
= WMGetListItem(lPtr
, index
);
484 XCopyArea(WMScreenDisplay(scr
), panel
->gimage
, d
, WMColorGC(white
),
485 0, height
*index
, 30, height
, x
+ 5, y
);
487 WMDrawString(scr
, d
, WMColorGC(black
), panel
->listFont
,
488 x
+ 40, y
+ 1, text
, strlen(text
));
490 WMReleaseColor(white
);
491 WMReleaseColor(black
);
497 gradAddCallback(WMWidget
*w
, void *data
)
499 TexturePanel
*panel
= (TexturePanel
*)data
;
504 row
= WMGetListSelectedItemRow(panel
->gcolL
) + 1;
505 item
= WMInsertListItem(panel
->gcolL
, row
, "00,00,00");
506 rgb
= wmalloc(sizeof(RColor
));
507 memset(rgb
, 0, sizeof(RColor
));
508 item
->clientData
= rgb
;
510 WMSelectListItem(panel
->gcolL
, row
);
512 updateGradButtons(panel
);
514 sliderChangeCallback(panel
->ghueS
, panel
);
516 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
522 gradClickCallback(WMWidget
*w
, void *data
)
524 TexturePanel
*panel
= (TexturePanel
*)data
;
529 row
= WMGetListSelectedItemRow(w
);
533 item
= WMGetListItem(panel
->gcolL
, row
);
534 RRGBtoHSV((RColor
*)item
->clientData
, &hsv
);
536 WMSetSliderValue(panel
->ghueS
, hsv
.hue
);
537 WMSetSliderValue(panel
->gsatS
, hsv
.saturation
);
538 WMSetSliderValue(panel
->gvalS
, hsv
.value
);
540 sliderChangeCallback(panel
->ghueS
, panel
);
541 sliderChangeCallback(panel
->gsatS
, panel
);
546 gradDeleteCallback(WMWidget
*w
, void *data
)
548 TexturePanel
*panel
= (TexturePanel
*)data
;
552 row
= WMGetListSelectedItemRow(panel
->gcolL
);
556 item
= WMGetListItem(panel
->gcolL
, row
);
557 free(item
->clientData
);
559 WMRemoveListItem(panel
->gcolL
, row
);
561 WMSelectListItem(panel
->gcolL
, row
- 1);
563 updateGradButtons(panel
);
565 gradClickCallback(panel
->gcolL
, panel
);
567 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
571 /*************** Simple Gradient ***************/
574 colorWellObserver(void *self
, WMNotification
*n
)
576 updateSGradButtons(self
);
583 opaqChangeCallback(WMWidget
*w
, void *data
)
585 TexturePanel
*panel
= (TexturePanel
*)data
;
587 updateTGradImage(panel
);
590 /****************** Image ******************/
593 updateImage(TexturePanel
*panel
, char *path
)
595 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
601 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
605 message
= wstrappend(_("Could not load the selected file: "),
606 (char*)RMessageForError(RErrorCode
));
608 WMRunAlertPanel(scr
, panel
->win
, _("Error"), message
,
609 _("OK"), NULL
, NULL
);
612 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 free(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 free(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 free(panel
->imageFile
);
931 panel
->imageFile
= wfindfileinarray(panel
->pathList
,
932 PLGetString(PLGetArrayElement(texture
, 1)));
934 panel
->image
= RLoadImage(WMScreenRContext(scr
), panel
->imageFile
, 0);
935 updateTGradImage(panel
);
937 updateSGradButtons(panel
);
939 /*...............................................*/
940 } else if (strcasecmp(type
, "mhgradient")==0
941 || strcasecmp(type
, "mvgradient")==0
942 || strcasecmp(type
, "mdgradient")==0) {
945 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
946 item
= WMGetListItem(panel
->gcolL
, i
);
947 free(item
->clientData
);
949 WMClearList(panel
->gcolL
);
951 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_GRADIENT
);
953 p
= PLGetArrayElement(texture
, 1);
957 str
= PLGetString(p
);
959 color
= WMCreateNamedColor(scr
, str
, False
);
961 WMSetColorWellColor(panel
->defcW
, color
);
963 WMReleaseColor(color
);
965 for (i
= 2; i
< PLGetNumberOfElements(texture
); i
++) {
969 p
= PLGetArrayElement(texture
, i
);
973 str
= PLGetString(p
);
976 XParseColor(WMScreenDisplay(scr
), WMScreenRContext(scr
)->cmap
,
979 rgb
= wmalloc(sizeof(RColor
));
980 rgb
->red
= xcolor
.red
>> 8;
981 rgb
->green
= xcolor
.green
>> 8;
982 rgb
->blue
= xcolor
.blue
>> 8;
983 sprintf(buffer
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
985 item
= WMAddListItem(panel
->gcolL
, buffer
);
986 item
->clientData
= rgb
;
989 sliderChangeCallback(panel
->ghueS
, panel
);
992 /*...............................................*/
993 } else if (strcasecmp(type
, "cpixmap")==0
994 || strcasecmp(type
, "spixmap")==0
995 || strcasecmp(type
, "mpixmap")==0
996 || strcasecmp(type
, "tpixmap")==0) {
998 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_PIXMAP
);
1000 switch (toupper(type
[0])) {
1002 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_CENTER
);
1005 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_SCALE
);
1008 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_MAXIMIZE
);
1012 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_TILE
);
1016 WMSetTextFieldText(panel
->imageT
,
1017 PLGetString(PLGetArrayElement(texture
, 1)));
1019 if (panel
->imageFile
)
1020 free(panel
->imageFile
);
1021 panel
->imageFile
= wfindfileinarray(panel
->pathList
,
1022 PLGetString(PLGetArrayElement(texture
, 1)));
1024 color
= WMCreateNamedColor(scr
,
1025 PLGetString(PLGetArrayElement(texture
, 2)), False
);
1026 WMSetColorWellColor(panel
->defcW
, color
);
1027 WMReleaseColor(color
);
1029 updateImage(panel
, panel
->imageFile
);
1032 changeTypeCallback(panel
->typeP
, panel
);
1035 updateGradButtons(panel
);
1037 switch (toupper(gradient
)) {
1039 WMPerformButtonClick(panel
->dirhB
);
1042 WMPerformButtonClick(panel
->dirvB
);
1046 WMPerformButtonClick(panel
->dirdB
);
1054 str
= PLGetDescription(texture
);
1055 wwarning("error creating texture %s", str
);
1063 GetTexturePanelTextureName(TexturePanel
*panel
)
1065 return WMGetTextFieldText(panel
->nameT
);
1072 GetTexturePanelTexture(TexturePanel
*panel
)
1074 proplist_t prop
= NULL
;
1081 switch (WMGetPopUpButtonSelectedItem(panel
->typeP
)) {
1084 color
= WMGetColorWellColor(panel
->defcW
);
1085 str
= WMGetColorRGBDescription(color
);
1086 prop
= PLMakeArrayFromElements(PLMakeString("solid"),
1087 PLMakeString(str
), NULL
);
1093 color
= WMGetColorWellColor(panel
->defcW
);
1094 str
= WMGetColorRGBDescription(color
);
1096 switch (WMGetPopUpButtonSelectedItem(panel
->arrP
)) {
1098 prop
= PLMakeArrayFromElements(PLMakeString("spixmap"),
1099 PLMakeString(panel
->imageFile
),
1100 PLMakeString(str
), NULL
);
1102 case PTYPE_MAXIMIZE
:
1103 prop
= PLMakeArrayFromElements(PLMakeString("mpixmap"),
1104 PLMakeString(panel
->imageFile
),
1105 PLMakeString(str
), NULL
);
1108 prop
= PLMakeArrayFromElements(PLMakeString("cpixmap"),
1109 PLMakeString(panel
->imageFile
),
1110 PLMakeString(str
), NULL
);
1113 prop
= PLMakeArrayFromElements(PLMakeString("tpixmap"),
1114 PLMakeString(panel
->imageFile
),
1115 PLMakeString(str
), NULL
);
1121 case TYPE_TGRADIENT
:
1122 color
= WMGetColorWellColor(panel
->tcol1W
);
1123 str
= WMGetColorRGBDescription(color
);
1125 color
= WMGetColorWellColor(panel
->tcol2W
);
1126 str2
= WMGetColorRGBDescription(color
);
1128 sprintf(buff
, "%i", WMGetSliderValue(panel
->topaS
));
1130 if (WMGetButtonSelected(panel
->dirdB
)) {
1131 prop
= PLMakeArrayFromElements(PLMakeString("tdgradient"),
1132 PLMakeString(panel
->imageFile
),
1135 PLMakeString(str2
), NULL
);
1136 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1137 prop
= PLMakeArrayFromElements(PLMakeString("tvgradient"),
1138 PLMakeString(panel
->imageFile
),
1141 PLMakeString(str2
), NULL
);
1143 prop
= PLMakeArrayFromElements(PLMakeString("thgradient"),
1144 PLMakeString(panel
->imageFile
),
1147 PLMakeString(str2
), NULL
);
1154 case TYPE_SGRADIENT
:
1155 color
= WMGetColorWellColor(panel
->tcol1W
);
1156 str
= WMGetColorRGBDescription(color
);
1158 color
= WMGetColorWellColor(panel
->tcol2W
);
1159 str2
= WMGetColorRGBDescription(color
);
1161 if (WMGetButtonSelected(panel
->dirdB
)) {
1162 prop
= PLMakeArrayFromElements(PLMakeString("dgradient"),
1164 PLMakeString(str2
), NULL
);
1165 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1166 prop
= PLMakeArrayFromElements(PLMakeString("vgradient"),
1168 PLMakeString(str2
), NULL
);
1170 prop
= PLMakeArrayFromElements(PLMakeString("hgradient"),
1172 PLMakeString(str2
), NULL
);
1179 color
= WMGetColorWellColor(panel
->defcW
);
1180 str
= WMGetColorRGBDescription(color
);
1182 if (WMGetButtonSelected(panel
->dirdB
)) {
1183 prop
= PLMakeArrayFromElements(PLMakeString("mdgradient"),
1184 PLMakeString(str
), NULL
);
1185 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1186 prop
= PLMakeArrayFromElements(PLMakeString("mvgradient"),
1187 PLMakeString(str
), NULL
);
1189 prop
= PLMakeArrayFromElements(PLMakeString("mhgradient"),
1190 PLMakeString(str
), NULL
);
1194 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
1198 item
= WMGetListItem(panel
->gcolL
, i
);
1200 rgb
= (RColor
*)item
->clientData
;
1202 sprintf(buff
, "#%02x%02x%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
1204 PLAppendArrayElement(prop
, PLMakeString(buff
));
1216 SetTexturePanelPixmapPath(TexturePanel
*panel
, proplist_t array
)
1218 panel
->pathList
= array
;
1224 CreateTexturePanel(WMWindow
*keyWindow
)
1225 /*CreateTexturePanel(WMScreen *scr)*/
1227 TexturePanel
*panel
;
1228 WMScreen
*scr
= WMWidgetScreen(keyWindow
);
1230 panel
= wmalloc(sizeof(TexturePanel
));
1231 memset(panel
, 0, sizeof(TexturePanel
));
1233 panel
->listFont
= WMSystemFontOfSize(scr
, 12);
1236 panel
->win
= WMCreatePanelWithStyleForWindow(keyWindow
, "texturePanel",
1238 |WMClosableWindowMask
);
1240 panel->win = WMCreateWindowWithStyle(scr, "texturePanel",
1242 |WMClosableWindowMask);
1245 WMResizeWidget(panel
->win
, 325, 423);
1246 WMSetWindowTitle(panel
->win
, _("Texture Panel"));
1247 WMSetWindowCloseAction(panel
->win
, buttonCallback
, panel
);
1251 panel
->nameF
= WMCreateFrame(panel
->win
);
1252 WMResizeWidget(panel
->nameF
, 185, 50);
1253 WMMoveWidget(panel
->nameF
, 15, 10);
1254 WMSetFrameTitle(panel
->nameF
, _("Texture Name"));
1256 panel
->nameT
= WMCreateTextField(panel
->nameF
);
1257 WMResizeWidget(panel
->nameT
, 160, 20);
1258 WMMoveWidget(panel
->nameT
, 12, 18);
1260 WMMapSubwidgets(panel
->nameF
);
1263 panel
->typeP
= WMCreatePopUpButton(panel
->win
);
1264 WMResizeWidget(panel
->typeP
, 185, 20);
1265 WMMoveWidget(panel
->typeP
, 15, 65);
1266 WMAddPopUpButtonItem(panel
->typeP
, _("Solid Color"));
1267 WMAddPopUpButtonItem(panel
->typeP
, _("Gradient Texture"));
1268 WMAddPopUpButtonItem(panel
->typeP
, _("Simple Gradient Texture"));
1269 WMAddPopUpButtonItem(panel
->typeP
, _("Textured Gradient"));
1270 WMAddPopUpButtonItem(panel
->typeP
, _("Image Texture"));
1271 WMSetPopUpButtonSelectedItem(panel
->typeP
, 0);
1272 WMSetPopUpButtonAction(panel
->typeP
, changeTypeCallback
, panel
);
1275 panel
->defcF
= WMCreateFrame(panel
->win
);
1276 WMResizeWidget(panel
->defcF
, 100, 75);
1277 WMMoveWidget(panel
->defcF
, 210, 10);
1278 WMSetFrameTitle(panel
->defcF
, _("Default Color"));
1280 panel
->defcW
= WMCreateColorWell(panel
->defcF
);
1281 WMResizeWidget(panel
->defcW
, 60, 45);
1282 WMMoveWidget(panel
->defcW
, 20, 20);
1284 WMMapSubwidgets(panel
->defcF
);
1286 /****** Gradient ******/
1287 panel
->gcolF
= WMCreateFrame(panel
->win
);
1288 WMResizeWidget(panel
->gcolF
, 295, 205);
1289 WMMoveWidget(panel
->gcolF
, 15, 95);
1290 WMSetFrameTitle(panel
->gcolF
, _("Gradient Colors"));
1292 panel
->gcolL
= WMCreateList(panel
->gcolF
);
1293 WMResizeWidget(panel
->gcolL
, 130, 140);
1294 WMMoveWidget(panel
->gcolL
, 10, 25);
1295 WMHangData(panel
->gcolL
, panel
);
1296 WMSetListUserDrawProc(panel
->gcolL
, paintGradListItem
);
1297 WMSetListAction(panel
->gcolL
, gradClickCallback
, panel
);
1299 panel
->gcolaB
= WMCreateCommandButton(panel
->gcolF
);
1300 WMResizeWidget(panel
->gcolaB
, 64, 24);
1301 WMMoveWidget(panel
->gcolaB
, 10, 170);
1302 WMSetButtonText(panel
->gcolaB
, _("Add"));
1303 WMSetButtonAction(panel
->gcolaB
, gradAddCallback
, panel
);
1305 panel
->gcoldB
= WMCreateCommandButton(panel
->gcolF
);
1306 WMResizeWidget(panel
->gcoldB
, 64, 24);
1307 WMMoveWidget(panel
->gcoldB
, 75, 170);
1308 WMSetButtonText(panel
->gcoldB
, _("Delete"));
1309 WMSetButtonAction(panel
->gcoldB
, gradDeleteCallback
, panel
);
1312 panel
->gbriS
= WMCreateSlider(panel
->gcolF
);
1313 WMResizeWidget(panel
->gbriS
, 130, 16);
1314 WMMoveWidget(panel
->gbriS
, 150, 25);
1315 WMSetSliderKnobThickness(panel
->gbriS
, 8);
1316 WMSetSliderMaxValue(panel
->gbriS
, 100);
1317 WMSetSliderAction(panel
->gbriS
, sliderChangeCallback
, panel
);
1322 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1323 color
= WMDarkGrayColor(scr
);
1324 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
),
1325 WMColorGC(color
), 0, 0, 130, 16);
1326 WMReleaseColor(color
);
1327 color
= WMWhiteColor(color
);
1328 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(color
),
1330 (16 - WMFontHeight(panel
->listFont
))/2 - 1,
1332 WMSetSliderImage(panel
->gbriS
, pixmap
);
1333 WMReleasePixmap(pixmap
);
1336 panel
->gconS
= WMCreateSlider(panel
->gcolF
);
1337 WMResizeWidget(panel
->gconS
, 130, 16);
1338 WMMoveWidget(panel
->gconS
, 150, 50);
1339 WMSetSliderKnobThickness(panel
->gconS
, 8);
1340 WMSetSliderMaxValue(panel
->gconS
, 100);
1341 WMSetSliderAction(panel
->gconS
, sliderChangeCallback
, panel
);
1346 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1347 color
= WMDarkGrayColor(scr
);
1348 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
),
1349 WMColorGC(color
), 0, 0, 130, 16);
1350 WMReleaseColor(color
);
1351 color
= WMWhiteColor(scr
);
1352 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(color
),
1354 (16 - WMFontHeight(panel
->listFont
))/2 - 1,
1356 WMSetSliderImage(panel
->gconS
, pixmap
);
1357 WMReleasePixmap(pixmap
);
1360 panel
->ghueS
= WMCreateSlider(panel
->gcolF
);
1361 WMResizeWidget(panel
->ghueS
, 130, 16);
1362 WMMoveWidget(panel
->ghueS
, 150, 100);
1363 WMSetSliderKnobThickness(panel
->ghueS
, 8);
1364 WMSetSliderMaxValue(panel
->ghueS
, 359);
1365 WMSetSliderAction(panel
->ghueS
, sliderChangeCallback
, panel
);
1367 panel
->gsatS
= WMCreateSlider(panel
->gcolF
);
1368 WMResizeWidget(panel
->gsatS
, 130, 16);
1369 WMMoveWidget(panel
->gsatS
, 150, 125);
1370 WMSetSliderKnobThickness(panel
->gsatS
, 8);
1371 WMSetSliderMaxValue(panel
->gsatS
, 255);
1372 WMSetSliderAction(panel
->gsatS
, sliderChangeCallback
, panel
);
1374 panel
->gvalS
= WMCreateSlider(panel
->gcolF
);
1375 WMResizeWidget(panel
->gvalS
, 130, 16);
1376 WMMoveWidget(panel
->gvalS
, 150, 150);
1377 WMSetSliderKnobThickness(panel
->gvalS
, 8);
1378 WMSetSliderMaxValue(panel
->gvalS
, 255);
1379 WMSetSliderAction(panel
->gvalS
, sliderChangeCallback
, panel
);
1382 WMMapSubwidgets(panel
->gcolF
);
1385 panel
->dirF
= WMCreateFrame(panel
->win
);
1386 WMSetFrameTitle(panel
->dirF
, _("Direction"));
1387 WMResizeWidget(panel
->dirF
, 295, 75);
1388 WMMoveWidget(panel
->dirF
, 15, 305);
1390 panel
->dirvB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1391 WMSetButtonImagePosition(panel
->dirvB
, WIPImageOnly
);
1392 WMResizeWidget(panel
->dirvB
, 90, 40);
1393 WMMoveWidget(panel
->dirvB
, 10, 20);
1395 panel
->dirhB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1396 WMSetButtonImagePosition(panel
->dirhB
, WIPImageOnly
);
1397 WMResizeWidget(panel
->dirhB
, 90, 40);
1398 WMMoveWidget(panel
->dirhB
, 102, 20);
1400 panel
->dirdB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1401 WMSetButtonImagePosition(panel
->dirdB
, WIPImageOnly
);
1402 WMResizeWidget(panel
->dirdB
, 90, 40);
1403 WMMoveWidget(panel
->dirdB
, 194, 20);
1405 WMGroupButtons(panel
->dirvB
, panel
->dirhB
);
1406 WMGroupButtons(panel
->dirvB
, panel
->dirdB
);
1408 WMMapSubwidgets(panel
->dirF
);
1410 /****************** Textured Gradient ******************/
1411 panel
->tcolF
= WMCreateFrame(panel
->win
);
1412 WMResizeWidget(panel
->tcolF
, 100, 135);
1413 WMMoveWidget(panel
->tcolF
, 210, 10);
1414 WMSetFrameTitle(panel
->tcolF
, _("Gradient"));
1416 panel
->tcol1W
= WMCreateColorWell(panel
->tcolF
);
1417 WMResizeWidget(panel
->tcol1W
, 60, 45);
1418 WMMoveWidget(panel
->tcol1W
, 20, 25);
1419 WMAddNotificationObserver(colorWellObserver
, panel
,
1420 WMColorWellDidChangeNotification
, panel
->tcol1W
);
1422 panel
->tcol2W
= WMCreateColorWell(panel
->tcolF
);
1423 WMResizeWidget(panel
->tcol2W
, 60, 45);
1424 WMMoveWidget(panel
->tcol2W
, 20, 75);
1425 WMAddNotificationObserver(colorWellObserver
, panel
,
1426 WMColorWellDidChangeNotification
, panel
->tcol2W
);
1429 panel
->topaF
= WMCreateFrame(panel
->win
);
1430 WMResizeWidget(panel
->topaF
, 185, 50);
1431 WMMoveWidget(panel
->topaF
, 15, 95);
1432 WMSetFrameTitle(panel
->topaF
, _("Gradient Opacity"));
1434 panel
->topaS
= WMCreateSlider(panel
->topaF
);
1435 WMResizeWidget(panel
->topaS
, 155, 18);
1436 WMMoveWidget(panel
->topaS
, 15, 20);
1437 WMSetSliderMaxValue(panel
->topaS
, 255);
1438 WMSetSliderValue(panel
->topaS
, 200);
1439 WMSetSliderContinuous(panel
->topaS
, False
);
1440 WMSetSliderAction(panel
->topaS
, opaqChangeCallback
, panel
);
1442 WMMapSubwidgets(panel
->topaF
);
1449 pixmap
= WMCreatePixmap(scr
, 155, 18, WMScreenDepth(scr
), False
);
1450 p
= WMGetPixmapXID(pixmap
);
1452 color
= WMDarkGrayColor(scr
);
1453 XFillRectangle(WMScreenDisplay(scr
), p
, WMColorGC(color
),
1455 WMReleaseColor(color
);
1457 color
= WMWhiteColor(scr
);
1458 WMDrawString(scr
, p
, WMColorGC(color
), panel
->listFont
,
1460 WMDrawString(scr
, p
, WMColorGC(color
), panel
->listFont
,
1461 153 - WMWidthOfString(panel
->listFont
, "100%", 4), 1,
1463 WMReleaseColor(color
);
1465 WMSetSliderImage(panel
->topaS
, pixmap
);
1466 WMReleasePixmap(pixmap
);
1469 WMMapSubwidgets(panel
->tcolF
);
1471 /****************** Image ******************/
1472 panel
->imageF
= WMCreateFrame(panel
->win
);
1473 WMResizeWidget(panel
->imageF
, 295, 150);
1474 WMMoveWidget(panel
->imageF
, 15, 150);
1475 WMSetFrameTitle(panel
->imageF
, _("Image"));
1477 panel
->imageL
= WMCreateLabel(panel
->imageF
);
1478 WMSetLabelImagePosition(panel
->imageL
, WIPImageOnly
);
1480 panel
->imageT
= WMCreateTextField(panel
->imageF
);
1481 WMResizeWidget(panel
->imageT
, 90, 20);
1482 WMMoveWidget(panel
->imageT
, 190, 25);
1484 panel
->imageV
= WMCreateScrollView(panel
->imageF
);
1485 WMResizeWidget(panel
->imageV
, 165, 115);
1486 WMMoveWidget(panel
->imageV
, 15, 20);
1487 WMSetScrollViewRelief(panel
->imageV
, WRSunken
);
1488 WMSetScrollViewHasHorizontalScroller(panel
->imageV
, True
);
1489 WMSetScrollViewHasVerticalScroller(panel
->imageV
, True
);
1490 WMSetScrollViewContentView(panel
->imageV
, WMWidgetView(panel
->imageL
));
1492 panel
->browB
= WMCreateCommandButton(panel
->imageF
);
1493 WMResizeWidget(panel
->browB
, 90, 24);
1494 WMMoveWidget(panel
->browB
, 190, 50);
1495 WMSetButtonText(panel
->browB
, _("Browse..."));
1496 WMSetButtonAction(panel
->browB
, browseImageCallback
, panel
);
1498 /* panel->dispB = WMCreateCommandButton(panel->imageF);
1499 WMResizeWidget(panel->dispB, 90, 24);
1500 WMMoveWidget(panel->dispB, 190, 80);
1501 WMSetButtonText(panel->dispB, _("Show"));
1504 panel
->arrP
= WMCreatePopUpButton(panel
->imageF
);
1505 WMResizeWidget(panel
->arrP
, 90, 20);
1506 WMMoveWidget(panel
->arrP
, 190, 120);
1507 WMAddPopUpButtonItem(panel
->arrP
, _("Tile"));
1508 WMAddPopUpButtonItem(panel
->arrP
, _("Scale"));
1509 WMAddPopUpButtonItem(panel
->arrP
, _("Center"));
1510 WMAddPopUpButtonItem(panel
->arrP
, _("Maximize"));
1511 WMSetPopUpButtonSelectedItem(panel
->arrP
, 0);
1513 WMMapSubwidgets(panel
->imageF
);
1517 panel
->okB
= WMCreateCommandButton(panel
->win
);
1518 WMResizeWidget(panel
->okB
, 84, 24);
1519 WMMoveWidget(panel
->okB
, 225, 390);
1520 WMSetButtonText(panel
->okB
, _("OK"));
1521 WMSetButtonAction(panel
->okB
, buttonCallback
, panel
);
1523 panel
->cancelB
= WMCreateCommandButton(panel
->win
);
1524 WMResizeWidget(panel
->cancelB
, 84, 24);
1525 WMMoveWidget(panel
->cancelB
, 130, 390);
1526 WMSetButtonText(panel
->cancelB
, _("Cancel"));
1527 WMSetButtonAction(panel
->cancelB
, buttonCallback
, panel
);
1529 WMMapWidget(panel
->nameF
);
1530 WMMapWidget(panel
->typeP
);
1531 WMMapWidget(panel
->okB
);
1532 WMMapWidget(panel
->cancelB
);
1534 WMUnmapWidget(panel
->arrP
);
1536 WMRealizeWidget(panel
->win
);
1538 panel
->currentType
= -1;
1540 panel
->sectionParts
[TYPE_SOLID
][0] = panel
->defcF
;
1542 panel
->sectionParts
[TYPE_GRADIENT
][0] = panel
->defcF
;
1543 panel
->sectionParts
[TYPE_GRADIENT
][1] = panel
->gcolF
;
1544 panel
->sectionParts
[TYPE_GRADIENT
][2] = panel
->dirF
;
1546 panel
->sectionParts
[TYPE_SGRADIENT
][0] = panel
->tcolF
;
1547 panel
->sectionParts
[TYPE_SGRADIENT
][1] = panel
->dirF
;
1549 panel
->sectionParts
[TYPE_TGRADIENT
][0] = panel
->tcolF
;
1550 panel
->sectionParts
[TYPE_TGRADIENT
][1] = panel
->dirF
;
1551 panel
->sectionParts
[TYPE_TGRADIENT
][2] = panel
->imageF
;
1552 panel
->sectionParts
[TYPE_TGRADIENT
][3] = panel
->topaF
;
1553 panel
->sectionParts
[TYPE_TGRADIENT
][4] = panel
->arrP
;
1555 panel
->sectionParts
[TYPE_PIXMAP
][0] = panel
->defcF
;
1556 panel
->sectionParts
[TYPE_PIXMAP
][1] = panel
->imageF
;
1557 panel
->sectionParts
[TYPE_PIXMAP
][2] = panel
->arrP
;
1560 /* setup for first time */
1562 changeTypeCallback(panel
->typeP
, panel
);
1564 sliderChangeCallback(panel
->ghueS
, panel
);
1565 sliderChangeCallback(panel
->gsatS
, panel
);
1573 *--------------------------------------------------------------------------
1575 *--------------------------------------------------------------------------
1580 char *ProgName
= "test";
1583 testOKButton(WMWidget
*self
, void *data
)
1591 TexturePanel
*panel
= (TexturePanel
*)data
;
1592 /* test = GetTexturePanelTextureString(panel); */
1596 dpy
= WMScreenDisplay(WMWidgetScreen(panel
->okB
));
1597 win
= XCreateSimpleWindow(dpy
, DefaultRootWindow(dpy
), 10, 10, 250, 250,
1599 XMapRaised(dpy
, win
);
1602 /* image = RenderTexturePanelTexture(panel, 250, 250); */
1604 RConvertImage(WMScreenRContext(WMWidgetScreen(panel
->okB
)), image
, &pix
);
1606 XCopyArea(dpy
, pix
, win
, (WMScreenRContext(WMWidgetScreen(panel
->okB
)))->copy_gc
, 0, 0, image
->width
, image
->height
,
1613 void testCancelButton(WMWidget
*self
, void *data
){
1614 wwarning("Exiting test....");
1623 int main(int argc
, char **argv
)
1625 TexturePanel
*panel
;
1627 Display
*dpy
= XOpenDisplay("");
1632 WMInitializeApplication("Test", &argc
, argv
);
1635 wfatal("could not open display");
1639 scr
= WMCreateSimpleApplicationScreen(dpy
);
1641 panel
= CreateTexturePanel(scr
);
1643 SetTexturePanelOkAction(panel
,(WMAction
*)testOKButton
,panel
);
1644 SetTexturePanelCancelAction(panel
,(WMAction
*)testCancelButton
,panel
);
1646 SetTexturePanelTexture(panel
, "pinky",
1647 PLGetProplistWithDescription("(mdgradient, pink, red, blue, yellow)"));
1649 ShowTexturePanel(panel
);
1651 WMScreenMainLoop(scr
);