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"
41 #define MAX_SECTION_PARTS 5
43 typedef struct _TexturePanel
{
75 /* direction (common) */
81 /*-- Simple Gradient --*/
84 /*-- Textured Gradient --*/
111 WMCallback
*okAction
;
114 WMCallback
*cancelAction
;
118 WMWidget
*sectionParts
[5][MAX_SECTION_PARTS
];
130 #define TYPE_GRADIENT 1
131 #define TYPE_SGRADIENT 2
132 #define TYPE_TGRADIENT 3
133 #define TYPE_PIXMAP 4
137 #define PTYPE_SCALE 1
138 #define PTYPE_CENTER 2
139 #define PTYPE_MAXIMIZE 3
144 *--------------------------------------------------------------------------
146 *--------------------------------------------------------------------------
152 updateGradButtons(TexturePanel
*panel
)
159 colorn
= WMGetListNumberOfRows(panel
->gcolL
);
166 colors
= wmalloc(sizeof(RColor
*)*(colorn
+1));
168 for (i
= 0; i
< colorn
; i
++) {
169 item
= WMGetListItem(panel
->gcolL
, i
);
170 colors
[i
] = (RColor
*)item
->clientData
;
174 image
= RRenderMultiGradient(80, 30, colors
, RHorizontalGradient
);
175 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
177 RDestroyImage(image
);
178 WMSetButtonImage(panel
->dirhB
, pixmap
);
179 WMReleasePixmap(pixmap
);
181 image
= RRenderMultiGradient(80, 30, colors
, RVerticalGradient
);
182 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
184 RDestroyImage(image
);
185 WMSetButtonImage(panel
->dirvB
, pixmap
);
186 WMReleasePixmap(pixmap
);
188 image
= RRenderMultiGradient(80, 30, colors
, RDiagonalGradient
);
189 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
),
191 RDestroyImage(image
);
192 WMSetButtonImage(panel
->dirdB
, pixmap
);
193 WMReleasePixmap(pixmap
);
202 updateTGradImage(TexturePanel
*panel
)
204 RImage
*image
, *gradient
;
213 color
= WMGetColorWellColor(panel
->tcol1W
);
214 from
.red
= WMRedComponentOfColor(color
)>>8;
215 from
.green
= WMGreenComponentOfColor(color
)>>8;
216 from
.blue
= WMBlueComponentOfColor(color
)>>8;
218 color
= WMGetColorWellColor(panel
->tcol2W
);
219 to
.red
= WMRedComponentOfColor(color
)>>8;
220 to
.green
= WMGreenComponentOfColor(color
)>>8;
221 to
.blue
= WMBlueComponentOfColor(color
)>>8;
223 if (panel
->image
->width
< 141 || panel
->image
->height
< 91) {
224 image
= RMakeTiledImage(panel
->image
, 141, 91);
226 image
= RCloneImage(panel
->image
);
229 if (WMGetButtonSelected(panel
->dirhB
)) {
230 gradient
= RRenderGradient(image
->width
, image
->height
, &from
, &to
,
231 RHorizontalGradient
);
232 } else if (WMGetButtonSelected(panel
->dirvB
)) {
233 gradient
= RRenderGradient(image
->width
, image
->height
, &from
, &to
,
236 gradient
= RRenderGradient(image
->width
, image
->height
, &from
, &to
,
240 RCombineImagesWithOpaqueness(image
, gradient
,
241 WMGetSliderValue(panel
->topaS
));
242 RDestroyImage(gradient
);
243 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->win
),
246 WMSetLabelImage(panel
->imageL
, pixmap
);
247 WMReleasePixmap(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
;
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
);
515 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
521 gradClickCallback(WMWidget
*w
, void *data
)
523 TexturePanel
*panel
= (TexturePanel
*)data
;
528 row
= WMGetListSelectedItemRow(w
);
532 item
= WMGetListItem(panel
->gcolL
, row
);
533 RRGBtoHSV((RColor
*)item
->clientData
, &hsv
);
535 WMSetSliderValue(panel
->ghueS
, hsv
.hue
);
536 WMSetSliderValue(panel
->gsatS
, hsv
.saturation
);
537 WMSetSliderValue(panel
->gvalS
, hsv
.value
);
539 sliderChangeCallback(panel
->ghueS
, panel
);
540 sliderChangeCallback(panel
->gsatS
, panel
);
545 gradDeleteCallback(WMWidget
*w
, void *data
)
547 TexturePanel
*panel
= (TexturePanel
*)data
;
551 row
= WMGetListSelectedItemRow(panel
->gcolL
);
555 item
= WMGetListItem(panel
->gcolL
, row
);
556 wfree(item
->clientData
);
558 WMRemoveListItem(panel
->gcolL
, row
);
560 WMSelectListItem(panel
->gcolL
, row
- 1);
562 updateGradButtons(panel
);
564 gradClickCallback(panel
->gcolL
, panel
);
566 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
570 /*************** Simple Gradient ***************/
573 colorWellObserver(void *self
, WMNotification
*n
)
575 updateSGradButtons(self
);
582 opaqChangeCallback(WMWidget
*w
, void *data
)
584 TexturePanel
*panel
= (TexturePanel
*)data
;
586 updateTGradImage(panel
);
589 /****************** Image ******************/
592 updateImage(TexturePanel
*panel
, char *path
)
594 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
600 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
604 message
= wstrconcat(_("Could not load the selected file: "),
605 (char*)RMessageForError(RErrorCode
));
607 WMRunAlertPanel(scr
, panel
->win
, _("Error"), message
,
608 _("OK"), NULL
, NULL
);
611 WMSetButtonEnabled(panel
->okB
, False
);
617 WMSetButtonEnabled(panel
->okB
, True
);
620 RDestroyImage(panel
->image
);
621 panel
->image
= image
;
623 image
= panel
->image
;
626 if (WMGetPopUpButtonSelectedItem(panel
->typeP
) == TYPE_PIXMAP
) {
628 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
630 size
= WMGetPixmapSize(pixmap
);
631 WMSetLabelImage(panel
->imageL
, pixmap
);
632 WMResizeWidget(panel
->imageL
, size
.width
, size
.height
);
634 WMReleasePixmap(pixmap
);
637 updateTGradImage(panel
);
643 browseImageCallback(WMWidget
*w
, void *data
)
645 TexturePanel
*panel
= (TexturePanel
*)data
;
647 WMScreen
*scr
= WMWidgetScreen(w
);
648 static char *ipath
= NULL
;
650 opanel
= WMGetOpenPanel(scr
);
651 WMSetFilePanelCanChooseDirectories(opanel
, False
);
652 WMSetFilePanelCanChooseFiles(opanel
, True
);
655 ipath
= wstrdup(wgethomedir());
657 if (WMRunModalFilePanelForDirectory(opanel
, panel
->win
, ipath
,
658 "Open Image", NULL
)) {
659 char *path
, *fullpath
;
662 tmp
= WMGetFilePanelFileName(opanel
);
670 path
= wstrdup(fullpath
);
672 tmp2
= strrchr(fullpath
, '/');
676 tmp
= wfindfileinarray(panel
->pathList
, tmp2
);
679 if (strcmp(fullpath
, tmp
)==0) {
686 if (!RGetImageFileFormat(fullpath
)) {
687 WMRunAlertPanel(scr
, panel
->win
, _("Error"),
688 _("The selected file does not contain a supported image."),
689 _("OK"), NULL
, NULL
);
692 updateImage(panel
, fullpath
);
693 wfree(panel
->imageFile
);
694 panel
->imageFile
= path
;
696 WMSetTextFieldText(panel
->imageT
, path
);
704 buttonCallback(WMWidget
*w
, void *data
)
706 TexturePanel
*panel
= (TexturePanel
*)data
;
708 if (w
== panel
->okB
) {
709 (*panel
->okAction
)(panel
->okData
);
711 (*panel
->cancelAction
)(panel
->cancelData
);
718 changeTypeCallback(WMWidget
*w
, void *data
)
720 TexturePanel
*panel
= (TexturePanel
*)data
;
724 newType
= WMGetPopUpButtonSelectedItem(w
);
725 if (newType
== panel
->currentType
)
728 if (panel
->currentType
>= 0) {
729 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
730 if (panel
->sectionParts
[panel
->currentType
][i
] == NULL
)
732 WMUnmapWidget(panel
->sectionParts
[panel
->currentType
][i
]);
736 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
737 if (panel
->sectionParts
[newType
][i
] == NULL
)
739 WMMapWidget(panel
->sectionParts
[newType
][i
]);
741 panel
->currentType
= newType
;
745 updateSGradButtons(panel
);
746 WMSetButtonEnabled(panel
->okB
, True
);
749 updateGradButtons(panel
);
750 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
)>1);
754 updateImage(panel
, NULL
);
755 WMSetButtonEnabled(panel
->okB
, panel
->image
!=NULL
);
758 WMSetButtonEnabled(panel
->okB
, True
);
765 *--------------------------------------------------------------------------
767 *--------------------------------------------------------------------------
770 DestroyTexturePanel(TexturePanel
*panel
)
777 ShowTexturePanel(TexturePanel
*panel
)
779 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(panel
->win
));
780 Screen
*scr
= DefaultScreenOfDisplay(dpy
);
782 WMSetWindowInitialPosition(panel
->win
,
783 (WidthOfScreen(scr
)-WMWidgetWidth(panel
->win
))/2,
784 (HeightOfScreen(scr
)-WMWidgetHeight(panel
->win
))/2);
785 WMMapWidget(panel
->win
);
790 HideTexturePanel(TexturePanel
*panel
)
792 WMUnmapWidget(panel
->win
);
797 SetTexturePanelOkAction(TexturePanel
*panel
, WMCallback
*action
, void *clientData
)
799 panel
->okAction
= action
;
800 panel
->okData
= clientData
;
805 SetTexturePanelCancelAction(TexturePanel
*panel
, WMCallback
*action
, void *clientData
)
807 panel
->cancelAction
= action
;
808 panel
->cancelData
= clientData
;
813 SetTexturePanelTexture(TexturePanel
*panel
, char *name
, proplist_t texture
)
815 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
823 WMSetTextFieldText(panel
->nameT
, name
);
828 p
= PLGetArrayElement(texture
, 0);
832 type
= PLGetString(p
);
834 /*...............................................*/
835 if (strcasecmp(type
, "solid")==0) {
837 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SOLID
);
839 p
= PLGetArrayElement(texture
, 1);
843 str
= PLGetString(p
);
845 color
= WMCreateNamedColor(scr
, str
, False
);
847 WMSetColorWellColor(panel
->defcW
, color
);
849 WMReleaseColor(color
);
850 /*...............................................*/
851 } else if (strcasecmp(type
, "hgradient")==0
852 || strcasecmp(type
, "vgradient")==0
853 || strcasecmp(type
, "dgradient")==0) {
855 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SGRADIENT
);
857 p
= PLGetArrayElement(texture
, 1);
861 str
= PLGetString(p
);
863 color
= WMCreateNamedColor(scr
, str
, False
);
865 WMSetColorWellColor(panel
->tcol1W
, color
);
867 WMReleaseColor(color
);
869 p
= PLGetArrayElement(texture
, 2);
873 str
= PLGetString(p
);
875 color
= WMCreateNamedColor(scr
, str
, False
);
877 WMSetColorWellColor(panel
->tcol2W
, color
);
879 WMReleaseColor(color
);
882 /*...............................................*/
883 } else if (strcasecmp(type
, "thgradient")==0
884 || strcasecmp(type
, "tvgradient")==0
885 || strcasecmp(type
, "tdgradient")==0) {
888 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_TGRADIENT
);
892 WMSetTextFieldText(panel
->imageT
,
893 PLGetString(PLGetArrayElement(texture
, 1)));
894 if (panel
->imageFile
)
895 wfree(panel
->imageFile
);
896 panel
->imageFile
= wstrdup(PLGetString(PLGetArrayElement(texture
, 1)));
900 sscanf(PLGetString(PLGetArrayElement(texture
, 2)), "%i", &i
);
901 WMSetSliderValue(panel
->topaS
, i
);
903 p
= PLGetArrayElement(texture
, 3);
907 str
= PLGetString(p
);
909 color
= WMCreateNamedColor(scr
, str
, False
);
911 WMSetColorWellColor(panel
->tcol1W
, color
);
913 WMReleaseColor(color
);
915 p
= PLGetArrayElement(texture
, 4);
919 str
= PLGetString(p
);
921 color
= WMCreateNamedColor(scr
, str
, False
);
923 WMSetColorWellColor(panel
->tcol2W
, color
);
925 WMReleaseColor(color
);
927 WMSetTextFieldText(panel
->imageT
,
928 PLGetString(PLGetArrayElement(texture
, 1)));
930 if (panel
->imageFile
)
931 wfree(panel
->imageFile
);
932 if ((panel
->imageFile
= wfindfileinarray(panel
->pathList
,
933 PLGetString(PLGetArrayElement(texture
, 1)))) != NULL
) {
935 panel
->image
= RLoadImage(WMScreenRContext(scr
), panel
->imageFile
, 0);
936 updateTGradImage(panel
);
938 updateSGradButtons(panel
);
939 } else wwarning("could not load file '%s': %s", panel
->imageFile
,
940 RMessageForError(RErrorCode
));
942 /*...............................................*/
943 } else if (strcasecmp(type
, "mhgradient")==0
944 || strcasecmp(type
, "mvgradient")==0
945 || strcasecmp(type
, "mdgradient")==0) {
948 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
949 item
= WMGetListItem(panel
->gcolL
, i
);
950 wfree(item
->clientData
);
952 WMClearList(panel
->gcolL
);
954 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_GRADIENT
);
956 p
= PLGetArrayElement(texture
, 1);
960 str
= PLGetString(p
);
962 color
= WMCreateNamedColor(scr
, str
, False
);
964 WMSetColorWellColor(panel
->defcW
, color
);
966 WMReleaseColor(color
);
968 for (i
= 2; i
< PLGetNumberOfElements(texture
); i
++) {
972 p
= PLGetArrayElement(texture
, i
);
976 str
= PLGetString(p
);
979 XParseColor(WMScreenDisplay(scr
), WMScreenRContext(scr
)->cmap
,
982 rgb
= wmalloc(sizeof(RColor
));
983 rgb
->red
= xcolor
.red
>> 8;
984 rgb
->green
= xcolor
.green
>> 8;
985 rgb
->blue
= xcolor
.blue
>> 8;
986 sprintf(buffer
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
988 item
= WMAddListItem(panel
->gcolL
, buffer
);
989 item
->clientData
= rgb
;
992 sliderChangeCallback(panel
->ghueS
, panel
);
995 /*...............................................*/
996 } else if (strcasecmp(type
, "cpixmap")==0
997 || strcasecmp(type
, "spixmap")==0
998 || strcasecmp(type
, "mpixmap")==0
999 || strcasecmp(type
, "tpixmap")==0) {
1001 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_PIXMAP
);
1003 switch (toupper(type
[0])) {
1005 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_CENTER
);
1008 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_SCALE
);
1011 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_MAXIMIZE
);
1015 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_TILE
);
1019 WMSetTextFieldText(panel
->imageT
,
1020 PLGetString(PLGetArrayElement(texture
, 1)));
1022 if (panel
->imageFile
)
1023 wfree(panel
->imageFile
);
1024 panel
->imageFile
= wfindfileinarray(panel
->pathList
,
1025 PLGetString(PLGetArrayElement(texture
, 1)));
1027 color
= WMCreateNamedColor(scr
,
1028 PLGetString(PLGetArrayElement(texture
, 2)), False
);
1029 WMSetColorWellColor(panel
->defcW
, color
);
1030 WMReleaseColor(color
);
1032 updateImage(panel
, panel
->imageFile
);
1035 changeTypeCallback(panel
->typeP
, panel
);
1038 updateGradButtons(panel
);
1040 switch (toupper(gradient
)) {
1042 WMPerformButtonClick(panel
->dirhB
);
1045 WMPerformButtonClick(panel
->dirvB
);
1049 WMPerformButtonClick(panel
->dirdB
);
1057 str
= PLGetDescription(texture
);
1058 wwarning("error creating texture %s", str
);
1066 GetTexturePanelTextureName(TexturePanel
*panel
)
1068 return WMGetTextFieldText(panel
->nameT
);
1075 GetTexturePanelTexture(TexturePanel
*panel
)
1077 proplist_t prop
= NULL
;
1084 switch (WMGetPopUpButtonSelectedItem(panel
->typeP
)) {
1087 color
= WMGetColorWellColor(panel
->defcW
);
1088 str
= WMGetColorRGBDescription(color
);
1089 prop
= PLMakeArrayFromElements(PLMakeString("solid"),
1090 PLMakeString(str
), NULL
);
1096 color
= WMGetColorWellColor(panel
->defcW
);
1097 str
= WMGetColorRGBDescription(color
);
1099 switch (WMGetPopUpButtonSelectedItem(panel
->arrP
)) {
1101 prop
= PLMakeArrayFromElements(PLMakeString("spixmap"),
1102 PLMakeString(panel
->imageFile
),
1103 PLMakeString(str
), NULL
);
1105 case PTYPE_MAXIMIZE
:
1106 prop
= PLMakeArrayFromElements(PLMakeString("mpixmap"),
1107 PLMakeString(panel
->imageFile
),
1108 PLMakeString(str
), NULL
);
1111 prop
= PLMakeArrayFromElements(PLMakeString("cpixmap"),
1112 PLMakeString(panel
->imageFile
),
1113 PLMakeString(str
), NULL
);
1116 prop
= PLMakeArrayFromElements(PLMakeString("tpixmap"),
1117 PLMakeString(panel
->imageFile
),
1118 PLMakeString(str
), NULL
);
1124 case TYPE_TGRADIENT
:
1125 color
= WMGetColorWellColor(panel
->tcol1W
);
1126 str
= WMGetColorRGBDescription(color
);
1128 color
= WMGetColorWellColor(panel
->tcol2W
);
1129 str2
= WMGetColorRGBDescription(color
);
1131 sprintf(buff
, "%i", WMGetSliderValue(panel
->topaS
));
1133 if (WMGetButtonSelected(panel
->dirdB
)) {
1134 prop
= PLMakeArrayFromElements(PLMakeString("tdgradient"),
1135 PLMakeString(panel
->imageFile
),
1138 PLMakeString(str2
), NULL
);
1139 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1140 prop
= PLMakeArrayFromElements(PLMakeString("tvgradient"),
1141 PLMakeString(panel
->imageFile
),
1144 PLMakeString(str2
), NULL
);
1146 prop
= PLMakeArrayFromElements(PLMakeString("thgradient"),
1147 PLMakeString(panel
->imageFile
),
1150 PLMakeString(str2
), NULL
);
1157 case TYPE_SGRADIENT
:
1158 color
= WMGetColorWellColor(panel
->tcol1W
);
1159 str
= WMGetColorRGBDescription(color
);
1161 color
= WMGetColorWellColor(panel
->tcol2W
);
1162 str2
= WMGetColorRGBDescription(color
);
1164 if (WMGetButtonSelected(panel
->dirdB
)) {
1165 prop
= PLMakeArrayFromElements(PLMakeString("dgradient"),
1167 PLMakeString(str2
), NULL
);
1168 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1169 prop
= PLMakeArrayFromElements(PLMakeString("vgradient"),
1171 PLMakeString(str2
), NULL
);
1173 prop
= PLMakeArrayFromElements(PLMakeString("hgradient"),
1175 PLMakeString(str2
), NULL
);
1182 color
= WMGetColorWellColor(panel
->defcW
);
1183 str
= WMGetColorRGBDescription(color
);
1185 if (WMGetButtonSelected(panel
->dirdB
)) {
1186 prop
= PLMakeArrayFromElements(PLMakeString("mdgradient"),
1187 PLMakeString(str
), NULL
);
1188 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1189 prop
= PLMakeArrayFromElements(PLMakeString("mvgradient"),
1190 PLMakeString(str
), NULL
);
1192 prop
= PLMakeArrayFromElements(PLMakeString("mhgradient"),
1193 PLMakeString(str
), NULL
);
1197 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
1201 item
= WMGetListItem(panel
->gcolL
, i
);
1203 rgb
= (RColor
*)item
->clientData
;
1205 sprintf(buff
, "#%02x%02x%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
1207 PLAppendArrayElement(prop
, PLMakeString(buff
));
1219 SetTexturePanelPixmapPath(TexturePanel
*panel
, proplist_t array
)
1221 panel
->pathList
= array
;
1227 CreateTexturePanel(WMWindow
*keyWindow
)
1228 /*CreateTexturePanel(WMScreen *scr)*/
1230 TexturePanel
*panel
;
1231 WMScreen
*scr
= WMWidgetScreen(keyWindow
);
1233 panel
= wmalloc(sizeof(TexturePanel
));
1234 memset(panel
, 0, sizeof(TexturePanel
));
1236 panel
->listFont
= WMSystemFontOfSize(scr
, 12);
1239 panel
->win
= WMCreatePanelWithStyleForWindow(keyWindow
, "texturePanel",
1241 |WMClosableWindowMask
);
1243 panel->win = WMCreateWindowWithStyle(scr, "texturePanel",
1245 |WMClosableWindowMask);
1248 WMResizeWidget(panel
->win
, 325, 423);
1249 WMSetWindowTitle(panel
->win
, _("Texture Panel"));
1250 WMSetWindowCloseAction(panel
->win
, buttonCallback
, panel
);
1254 panel
->nameF
= WMCreateFrame(panel
->win
);
1255 WMResizeWidget(panel
->nameF
, 185, 50);
1256 WMMoveWidget(panel
->nameF
, 15, 10);
1257 WMSetFrameTitle(panel
->nameF
, _("Texture Name"));
1259 panel
->nameT
= WMCreateTextField(panel
->nameF
);
1260 WMResizeWidget(panel
->nameT
, 160, 20);
1261 WMMoveWidget(panel
->nameT
, 12, 18);
1263 WMMapSubwidgets(panel
->nameF
);
1266 panel
->typeP
= WMCreatePopUpButton(panel
->win
);
1267 WMResizeWidget(panel
->typeP
, 185, 20);
1268 WMMoveWidget(panel
->typeP
, 15, 65);
1269 WMAddPopUpButtonItem(panel
->typeP
, _("Solid Color"));
1270 WMAddPopUpButtonItem(panel
->typeP
, _("Gradient Texture"));
1271 WMAddPopUpButtonItem(panel
->typeP
, _("Simple Gradient Texture"));
1272 WMAddPopUpButtonItem(panel
->typeP
, _("Textured Gradient"));
1273 WMAddPopUpButtonItem(panel
->typeP
, _("Image Texture"));
1274 WMSetPopUpButtonSelectedItem(panel
->typeP
, 0);
1275 WMSetPopUpButtonAction(panel
->typeP
, changeTypeCallback
, panel
);
1278 panel
->defcF
= WMCreateFrame(panel
->win
);
1279 WMResizeWidget(panel
->defcF
, 100, 75);
1280 WMMoveWidget(panel
->defcF
, 210, 10);
1281 WMSetFrameTitle(panel
->defcF
, _("Default Color"));
1283 panel
->defcW
= WMCreateColorWell(panel
->defcF
);
1284 WMResizeWidget(panel
->defcW
, 60, 45);
1285 WMMoveWidget(panel
->defcW
, 20, 20);
1287 WMMapSubwidgets(panel
->defcF
);
1289 /****** Gradient ******/
1290 panel
->gcolF
= WMCreateFrame(panel
->win
);
1291 WMResizeWidget(panel
->gcolF
, 295, 205);
1292 WMMoveWidget(panel
->gcolF
, 15, 95);
1293 WMSetFrameTitle(panel
->gcolF
, _("Gradient Colors"));
1295 panel
->gcolL
= WMCreateList(panel
->gcolF
);
1296 WMResizeWidget(panel
->gcolL
, 130, 140);
1297 WMMoveWidget(panel
->gcolL
, 10, 25);
1298 WMHangData(panel
->gcolL
, panel
);
1299 WMSetListUserDrawProc(panel
->gcolL
, paintGradListItem
);
1300 WMSetListAction(panel
->gcolL
, gradClickCallback
, panel
);
1302 panel
->gcolaB
= WMCreateCommandButton(panel
->gcolF
);
1303 WMResizeWidget(panel
->gcolaB
, 64, 24);
1304 WMMoveWidget(panel
->gcolaB
, 10, 170);
1305 WMSetButtonText(panel
->gcolaB
, _("Add"));
1306 WMSetButtonAction(panel
->gcolaB
, gradAddCallback
, panel
);
1308 panel
->gcoldB
= WMCreateCommandButton(panel
->gcolF
);
1309 WMResizeWidget(panel
->gcoldB
, 64, 24);
1310 WMMoveWidget(panel
->gcoldB
, 75, 170);
1311 WMSetButtonText(panel
->gcoldB
, _("Delete"));
1312 WMSetButtonAction(panel
->gcoldB
, gradDeleteCallback
, panel
);
1315 panel
->gbriS
= WMCreateSlider(panel
->gcolF
);
1316 WMResizeWidget(panel
->gbriS
, 130, 16);
1317 WMMoveWidget(panel
->gbriS
, 150, 25);
1318 WMSetSliderKnobThickness(panel
->gbriS
, 8);
1319 WMSetSliderMaxValue(panel
->gbriS
, 100);
1320 WMSetSliderAction(panel
->gbriS
, sliderChangeCallback
, panel
);
1325 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1326 color
= WMDarkGrayColor(scr
);
1327 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
),
1328 WMColorGC(color
), 0, 0, 130, 16);
1329 WMReleaseColor(color
);
1330 color
= WMWhiteColor(color
);
1331 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(color
),
1333 (16 - WMFontHeight(panel
->listFont
))/2 - 1,
1335 WMSetSliderImage(panel
->gbriS
, pixmap
);
1336 WMReleasePixmap(pixmap
);
1339 panel
->gconS
= WMCreateSlider(panel
->gcolF
);
1340 WMResizeWidget(panel
->gconS
, 130, 16);
1341 WMMoveWidget(panel
->gconS
, 150, 50);
1342 WMSetSliderKnobThickness(panel
->gconS
, 8);
1343 WMSetSliderMaxValue(panel
->gconS
, 100);
1344 WMSetSliderAction(panel
->gconS
, sliderChangeCallback
, panel
);
1349 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1350 color
= WMDarkGrayColor(scr
);
1351 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
),
1352 WMColorGC(color
), 0, 0, 130, 16);
1353 WMReleaseColor(color
);
1354 color
= WMWhiteColor(scr
);
1355 WMDrawString(scr
, WMGetPixmapXID(pixmap
), WMColorGC(color
),
1357 (16 - WMFontHeight(panel
->listFont
))/2 - 1,
1359 WMSetSliderImage(panel
->gconS
, pixmap
);
1360 WMReleasePixmap(pixmap
);
1363 panel
->ghueS
= WMCreateSlider(panel
->gcolF
);
1364 WMResizeWidget(panel
->ghueS
, 130, 16);
1365 WMMoveWidget(panel
->ghueS
, 150, 100);
1366 WMSetSliderKnobThickness(panel
->ghueS
, 8);
1367 WMSetSliderMaxValue(panel
->ghueS
, 359);
1368 WMSetSliderAction(panel
->ghueS
, sliderChangeCallback
, panel
);
1370 panel
->gsatS
= WMCreateSlider(panel
->gcolF
);
1371 WMResizeWidget(panel
->gsatS
, 130, 16);
1372 WMMoveWidget(panel
->gsatS
, 150, 125);
1373 WMSetSliderKnobThickness(panel
->gsatS
, 8);
1374 WMSetSliderMaxValue(panel
->gsatS
, 255);
1375 WMSetSliderAction(panel
->gsatS
, sliderChangeCallback
, panel
);
1377 panel
->gvalS
= WMCreateSlider(panel
->gcolF
);
1378 WMResizeWidget(panel
->gvalS
, 130, 16);
1379 WMMoveWidget(panel
->gvalS
, 150, 150);
1380 WMSetSliderKnobThickness(panel
->gvalS
, 8);
1381 WMSetSliderMaxValue(panel
->gvalS
, 255);
1382 WMSetSliderAction(panel
->gvalS
, sliderChangeCallback
, panel
);
1385 WMMapSubwidgets(panel
->gcolF
);
1388 panel
->dirF
= WMCreateFrame(panel
->win
);
1389 WMSetFrameTitle(panel
->dirF
, _("Direction"));
1390 WMResizeWidget(panel
->dirF
, 295, 75);
1391 WMMoveWidget(panel
->dirF
, 15, 305);
1393 panel
->dirvB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1394 WMSetButtonImagePosition(panel
->dirvB
, WIPImageOnly
);
1395 WMResizeWidget(panel
->dirvB
, 90, 40);
1396 WMMoveWidget(panel
->dirvB
, 10, 20);
1398 panel
->dirhB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1399 WMSetButtonImagePosition(panel
->dirhB
, WIPImageOnly
);
1400 WMResizeWidget(panel
->dirhB
, 90, 40);
1401 WMMoveWidget(panel
->dirhB
, 102, 20);
1403 panel
->dirdB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1404 WMSetButtonImagePosition(panel
->dirdB
, WIPImageOnly
);
1405 WMResizeWidget(panel
->dirdB
, 90, 40);
1406 WMMoveWidget(panel
->dirdB
, 194, 20);
1408 WMGroupButtons(panel
->dirvB
, panel
->dirhB
);
1409 WMGroupButtons(panel
->dirvB
, panel
->dirdB
);
1411 WMMapSubwidgets(panel
->dirF
);
1413 /****************** Textured Gradient ******************/
1414 panel
->tcolF
= WMCreateFrame(panel
->win
);
1415 WMResizeWidget(panel
->tcolF
, 100, 135);
1416 WMMoveWidget(panel
->tcolF
, 210, 10);
1417 WMSetFrameTitle(panel
->tcolF
, _("Gradient"));
1419 panel
->tcol1W
= WMCreateColorWell(panel
->tcolF
);
1420 WMResizeWidget(panel
->tcol1W
, 60, 45);
1421 WMMoveWidget(panel
->tcol1W
, 20, 25);
1422 WMAddNotificationObserver(colorWellObserver
, panel
,
1423 WMColorWellDidChangeNotification
, panel
->tcol1W
);
1425 panel
->tcol2W
= WMCreateColorWell(panel
->tcolF
);
1426 WMResizeWidget(panel
->tcol2W
, 60, 45);
1427 WMMoveWidget(panel
->tcol2W
, 20, 75);
1428 WMAddNotificationObserver(colorWellObserver
, panel
,
1429 WMColorWellDidChangeNotification
, panel
->tcol2W
);
1432 panel
->topaF
= WMCreateFrame(panel
->win
);
1433 WMResizeWidget(panel
->topaF
, 185, 50);
1434 WMMoveWidget(panel
->topaF
, 15, 95);
1435 WMSetFrameTitle(panel
->topaF
, _("Gradient Opacity"));
1437 panel
->topaS
= WMCreateSlider(panel
->topaF
);
1438 WMResizeWidget(panel
->topaS
, 155, 18);
1439 WMMoveWidget(panel
->topaS
, 15, 20);
1440 WMSetSliderMaxValue(panel
->topaS
, 255);
1441 WMSetSliderValue(panel
->topaS
, 200);
1442 WMSetSliderContinuous(panel
->topaS
, False
);
1443 WMSetSliderAction(panel
->topaS
, opaqChangeCallback
, panel
);
1445 WMMapSubwidgets(panel
->topaF
);
1452 pixmap
= WMCreatePixmap(scr
, 155, 18, WMScreenDepth(scr
), False
);
1453 p
= WMGetPixmapXID(pixmap
);
1455 color
= WMDarkGrayColor(scr
);
1456 XFillRectangle(WMScreenDisplay(scr
), p
, WMColorGC(color
),
1458 WMReleaseColor(color
);
1460 color
= WMWhiteColor(scr
);
1461 WMDrawString(scr
, p
, WMColorGC(color
), panel
->listFont
,
1463 WMDrawString(scr
, p
, WMColorGC(color
), panel
->listFont
,
1464 153 - WMWidthOfString(panel
->listFont
, "100%", 4), 1,
1466 WMReleaseColor(color
);
1468 WMSetSliderImage(panel
->topaS
, pixmap
);
1469 WMReleasePixmap(pixmap
);
1472 WMMapSubwidgets(panel
->tcolF
);
1474 /****************** Image ******************/
1475 panel
->imageF
= WMCreateFrame(panel
->win
);
1476 WMResizeWidget(panel
->imageF
, 295, 150);
1477 WMMoveWidget(panel
->imageF
, 15, 150);
1478 WMSetFrameTitle(panel
->imageF
, _("Image"));
1480 panel
->imageL
= WMCreateLabel(panel
->imageF
);
1481 WMSetLabelImagePosition(panel
->imageL
, WIPImageOnly
);
1483 panel
->imageT
= WMCreateTextField(panel
->imageF
);
1484 WMResizeWidget(panel
->imageT
, 90, 20);
1485 WMMoveWidget(panel
->imageT
, 190, 25);
1487 panel
->imageV
= WMCreateScrollView(panel
->imageF
);
1488 WMResizeWidget(panel
->imageV
, 165, 115);
1489 WMMoveWidget(panel
->imageV
, 15, 20);
1490 WMSetScrollViewRelief(panel
->imageV
, WRSunken
);
1491 WMSetScrollViewHasHorizontalScroller(panel
->imageV
, True
);
1492 WMSetScrollViewHasVerticalScroller(panel
->imageV
, True
);
1493 WMSetScrollViewContentView(panel
->imageV
, WMWidgetView(panel
->imageL
));
1495 panel
->browB
= WMCreateCommandButton(panel
->imageF
);
1496 WMResizeWidget(panel
->browB
, 90, 24);
1497 WMMoveWidget(panel
->browB
, 190, 50);
1498 WMSetButtonText(panel
->browB
, _("Browse..."));
1499 WMSetButtonAction(panel
->browB
, browseImageCallback
, panel
);
1501 /* panel->dispB = WMCreateCommandButton(panel->imageF);
1502 WMResizeWidget(panel->dispB, 90, 24);
1503 WMMoveWidget(panel->dispB, 190, 80);
1504 WMSetButtonText(panel->dispB, _("Show"));
1507 panel
->arrP
= WMCreatePopUpButton(panel
->imageF
);
1508 WMResizeWidget(panel
->arrP
, 90, 20);
1509 WMMoveWidget(panel
->arrP
, 190, 120);
1510 WMAddPopUpButtonItem(panel
->arrP
, _("Tile"));
1511 WMAddPopUpButtonItem(panel
->arrP
, _("Scale"));
1512 WMAddPopUpButtonItem(panel
->arrP
, _("Center"));
1513 WMAddPopUpButtonItem(panel
->arrP
, _("Maximize"));
1514 WMSetPopUpButtonSelectedItem(panel
->arrP
, 0);
1516 WMMapSubwidgets(panel
->imageF
);
1520 panel
->okB
= WMCreateCommandButton(panel
->win
);
1521 WMResizeWidget(panel
->okB
, 84, 24);
1522 WMMoveWidget(panel
->okB
, 225, 390);
1523 WMSetButtonText(panel
->okB
, _("OK"));
1524 WMSetButtonAction(panel
->okB
, buttonCallback
, panel
);
1526 panel
->cancelB
= WMCreateCommandButton(panel
->win
);
1527 WMResizeWidget(panel
->cancelB
, 84, 24);
1528 WMMoveWidget(panel
->cancelB
, 130, 390);
1529 WMSetButtonText(panel
->cancelB
, _("Cancel"));
1530 WMSetButtonAction(panel
->cancelB
, buttonCallback
, panel
);
1532 WMMapWidget(panel
->nameF
);
1533 WMMapWidget(panel
->typeP
);
1534 WMMapWidget(panel
->okB
);
1535 WMMapWidget(panel
->cancelB
);
1537 WMUnmapWidget(panel
->arrP
);
1539 WMRealizeWidget(panel
->win
);
1541 panel
->currentType
= -1;
1543 panel
->sectionParts
[TYPE_SOLID
][0] = panel
->defcF
;
1545 panel
->sectionParts
[TYPE_GRADIENT
][0] = panel
->defcF
;
1546 panel
->sectionParts
[TYPE_GRADIENT
][1] = panel
->gcolF
;
1547 panel
->sectionParts
[TYPE_GRADIENT
][2] = panel
->dirF
;
1549 panel
->sectionParts
[TYPE_SGRADIENT
][0] = panel
->tcolF
;
1550 panel
->sectionParts
[TYPE_SGRADIENT
][1] = panel
->dirF
;
1552 panel
->sectionParts
[TYPE_TGRADIENT
][0] = panel
->tcolF
;
1553 panel
->sectionParts
[TYPE_TGRADIENT
][1] = panel
->dirF
;
1554 panel
->sectionParts
[TYPE_TGRADIENT
][2] = panel
->imageF
;
1555 panel
->sectionParts
[TYPE_TGRADIENT
][3] = panel
->topaF
;
1556 panel
->sectionParts
[TYPE_TGRADIENT
][4] = panel
->arrP
;
1558 panel
->sectionParts
[TYPE_PIXMAP
][0] = panel
->defcF
;
1559 panel
->sectionParts
[TYPE_PIXMAP
][1] = panel
->imageF
;
1560 panel
->sectionParts
[TYPE_PIXMAP
][2] = panel
->arrP
;
1563 /* setup for first time */
1565 changeTypeCallback(panel
->typeP
, panel
);
1567 sliderChangeCallback(panel
->ghueS
, panel
);
1568 sliderChangeCallback(panel
->gsatS
, panel
);
1576 *--------------------------------------------------------------------------
1578 *--------------------------------------------------------------------------
1583 char *ProgName
= "test";
1586 testOKButton(WMWidget
*self
, void *data
)
1594 TexturePanel
*panel
= (TexturePanel
*)data
;
1595 /* test = GetTexturePanelTextureString(panel); */
1599 dpy
= WMScreenDisplay(WMWidgetScreen(panel
->okB
));
1600 win
= XCreateSimpleWindow(dpy
, DefaultRootWindow(dpy
), 10, 10, 250, 250,
1602 XMapRaised(dpy
, win
);
1605 /* image = RenderTexturePanelTexture(panel, 250, 250); */
1607 RConvertImage(WMScreenRContext(WMWidgetScreen(panel
->okB
)), image
, &pix
);
1609 XCopyArea(dpy
, pix
, win
, (WMScreenRContext(WMWidgetScreen(panel
->okB
)))->copy_gc
, 0, 0, image
->width
, image
->height
,
1616 void testCancelButton(WMWidget
*self
, void *data
){
1617 wwarning("Exiting test....");
1626 int main(int argc
, char **argv
)
1628 TexturePanel
*panel
;
1630 Display
*dpy
= XOpenDisplay("");
1635 WMInitializeApplication("Test", &argc
, argv
);
1638 wfatal("could not open display");
1642 scr
= WMCreateSimpleApplicationScreen(dpy
);
1644 panel
= CreateTexturePanel(scr
);
1646 SetTexturePanelOkAction(panel
,(WMAction
*)testOKButton
,panel
);
1647 SetTexturePanelCancelAction(panel
,(WMAction
*)testCancelButton
,panel
);
1649 SetTexturePanelTexture(panel
, "pinky",
1650 PLGetProplistWithDescription("(mdgradient, pink, red, blue, yellow)"));
1652 ShowTexturePanel(panel
);
1654 WMScreenMainLoop(scr
);