1 /* TexturePanel.c- texture editting panel
3 * WPrefs - WindowMaker Preferences Program
5 * Copyright (c) 1998-2003 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 along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include <WINGs/WINGs.h>
35 #include "TexturePanel.h"
37 #define MAX_SECTION_PARTS 5
39 typedef struct _TexturePanel
{
71 /* direction (common) */
77 /*-- Simple Gradient --*/
79 /*-- Textured Gradient --*/
105 WMCallback
*okAction
;
108 WMCallback
*cancelAction
;
112 WMWidget
*sectionParts
[5][MAX_SECTION_PARTS
];
116 WMPropList
*pathList
;
121 #define TYPE_GRADIENT 1
122 #define TYPE_SGRADIENT 2
123 #define TYPE_TGRADIENT 3
124 #define TYPE_PIXMAP 4
127 #define PTYPE_SCALE 1
128 #define PTYPE_CENTER 2
129 #define PTYPE_MAXIMIZE 3
132 *--------------------------------------------------------------------------
134 *--------------------------------------------------------------------------
139 static void updateGradButtons(TexturePanel
* panel
)
146 colorn
= WMGetListNumberOfRows(panel
->gcolL
);
153 colors
= wmalloc(sizeof(RColor
*) * (colorn
+ 1));
155 for (i
= 0; i
< colorn
; i
++) {
156 item
= WMGetListItem(panel
->gcolL
, i
);
157 colors
[i
] = (RColor
*) item
->clientData
;
161 image
= RRenderMultiGradient(80, 30, colors
, RHorizontalGradient
);
162 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
), image
, 128);
163 RReleaseImage(image
);
164 WMSetButtonImage(panel
->dirhB
, pixmap
);
165 WMReleasePixmap(pixmap
);
167 image
= RRenderMultiGradient(80, 30, colors
, RVerticalGradient
);
168 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
), image
, 128);
169 RReleaseImage(image
);
170 WMSetButtonImage(panel
->dirvB
, pixmap
);
171 WMReleasePixmap(pixmap
);
173 image
= RRenderMultiGradient(80, 30, colors
, RDiagonalGradient
);
174 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
), image
, 128);
175 RReleaseImage(image
);
176 WMSetButtonImage(panel
->dirdB
, pixmap
);
177 WMReleasePixmap(pixmap
);
183 static void updateTGradImage(TexturePanel
* panel
)
185 RImage
*image
, *gradient
;
194 color
= WMGetColorWellColor(panel
->tcol1W
);
195 from
.red
= WMRedComponentOfColor(color
) >> 8;
196 from
.green
= WMGreenComponentOfColor(color
) >> 8;
197 from
.blue
= WMBlueComponentOfColor(color
) >> 8;
199 color
= WMGetColorWellColor(panel
->tcol2W
);
200 to
.red
= WMRedComponentOfColor(color
) >> 8;
201 to
.green
= WMGreenComponentOfColor(color
) >> 8;
202 to
.blue
= WMBlueComponentOfColor(color
) >> 8;
204 if (panel
->image
->width
< 141 || panel
->image
->height
< 91) {
205 image
= RMakeTiledImage(panel
->image
, 141, 91);
207 image
= RCloneImage(panel
->image
);
210 if (WMGetButtonSelected(panel
->dirhB
)) {
211 gradient
= RRenderGradient(image
->width
, image
->height
, &from
, &to
, RHorizontalGradient
);
212 } else if (WMGetButtonSelected(panel
->dirvB
)) {
213 gradient
= RRenderGradient(image
->width
, image
->height
, &from
, &to
, RVerticalGradient
);
215 gradient
= RRenderGradient(image
->width
, image
->height
, &from
, &to
, RDiagonalGradient
);
218 RCombineImagesWithOpaqueness(image
, gradient
, WMGetSliderValue(panel
->topaS
));
219 RReleaseImage(gradient
);
220 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->win
), image
, 128);
222 WMSetLabelImage(panel
->imageL
, pixmap
);
223 WMReleasePixmap(pixmap
);
224 WMResizeWidget(panel
->imageL
, image
->width
, image
->height
);
225 RReleaseImage(image
);
228 static void updateSGradButtons(TexturePanel
* panel
)
236 color
= WMGetColorWellColor(panel
->tcol1W
);
237 from
.red
= WMRedComponentOfColor(color
) >> 8;
238 from
.green
= WMGreenComponentOfColor(color
) >> 8;
239 from
.blue
= WMBlueComponentOfColor(color
) >> 8;
241 color
= WMGetColorWellColor(panel
->tcol2W
);
242 to
.red
= WMRedComponentOfColor(color
) >> 8;
243 to
.green
= WMGreenComponentOfColor(color
) >> 8;
244 to
.blue
= WMBlueComponentOfColor(color
) >> 8;
246 image
= RRenderGradient(80, 30, &from
, &to
, RHorizontalGradient
);
247 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
), image
, 128);
248 RReleaseImage(image
);
249 WMSetButtonImage(panel
->dirhB
, pixmap
);
250 WMReleasePixmap(pixmap
);
252 image
= RRenderGradient(80, 30, &from
, &to
, RVerticalGradient
);
253 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
), image
, 128);
254 RReleaseImage(image
);
255 WMSetButtonImage(panel
->dirvB
, pixmap
);
256 WMReleasePixmap(pixmap
);
258 image
= RRenderGradient(80, 30, &from
, &to
, RDiagonalGradient
);
259 pixmap
= WMCreatePixmapFromRImage(WMWidgetScreen(panel
->gcolL
), image
, 128);
260 RReleaseImage(image
);
261 WMSetButtonImage(panel
->dirdB
, pixmap
);
262 WMReleasePixmap(pixmap
);
265 /*********** Gradient ************/
267 static void updateSVSlider(WMSlider
* sPtr
, Bool saturation
, WMFont
* font
, RHSVColor
* hsv
)
271 WMScreen
*scr
= WMWidgetScreen(sPtr
);
279 RHSVtoRGB(&tmp
, &from
);
280 tmp
.saturation
= 255;
281 RHSVtoRGB(&tmp
, &to
);
284 RHSVtoRGB(&tmp
, &from
);
286 RHSVtoRGB(&tmp
, &to
);
288 image
= RRenderGradient(130, 16, &from
, &to
, RHorizontalGradient
);
289 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
290 RReleaseImage(image
);
293 buffer
= wstrdup(_("Saturation"));
295 buffer
= wstrdup(_("Brightness"));
297 if (hsv
->value
< 128 || !saturation
) {
298 WMColor
*col
= WMWhiteColor(scr
);
300 WMDrawString(scr
, WMGetPixmapXID(pixmap
), col
, font
, 2,
301 (16 - WMFontHeight(font
)) / 2 - 1, buffer
, strlen(buffer
));
304 WMColor
*col
= WMBlackColor(scr
);
306 WMDrawString(scr
, WMGetPixmapXID(pixmap
), col
, font
, 2,
307 (16 - WMFontHeight(font
)) / 2 - 1, buffer
, strlen(buffer
));
311 WMSetSliderImage(sPtr
, pixmap
);
312 WMReleasePixmap(pixmap
);
315 static void updateHueSlider(WMSlider
* sPtr
, WMFont
* font
, RHSVColor
* hsv
)
320 WMScreen
*scr
= WMWidgetScreen(sPtr
);
325 for (i
= 0; i
<= 6; i
++) {
326 thsv
.hue
= (360 * i
) / 6;
327 colors
[i
] = wmalloc(sizeof(RColor
));
328 RHSVtoRGB(&thsv
, colors
[i
]);
332 image
= RRenderMultiGradient(130, 16, colors
, RGRD_HORIZONTAL
);
333 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
334 RReleaseImage(image
);
336 if (hsv
->value
< 128) {
337 WMColor
*col
= WMWhiteColor(scr
);
339 WMDrawString(scr
, WMGetPixmapXID(pixmap
), col
, font
, 2,
340 (16 - WMFontHeight(font
)) / 2 - 1, _("Hue"), strlen(_("Hue")));
343 WMColor
*col
= WMBlackColor(scr
);
345 WMDrawString(scr
, WMGetPixmapXID(pixmap
), col
, font
, 2,
346 (16 - WMFontHeight(font
)) / 2 - 1, _("Hue"), strlen(_("Hue")));
349 WMSetSliderImage(sPtr
, pixmap
);
350 WMReleasePixmap(pixmap
);
352 for (i
= 0; i
<= 6; i
++)
356 static void sliderChangeCallback(WMWidget
* w
, void *data
)
358 TexturePanel
*panel
= (TexturePanel
*) data
;
365 WMScreen
*scr
= WMWidgetScreen(w
);
367 hsv
.hue
= WMGetSliderValue(panel
->ghueS
);
368 hsv
.saturation
= WMGetSliderValue(panel
->gsatS
);
369 hsv
.value
= WMGetSliderValue(panel
->gvalS
);
371 row
= WMGetListSelectedItemRow(panel
->gcolL
);
375 item
= WMGetListItem(panel
->gcolL
, row
);
377 rgb
= (RColor
*) item
->clientData
;
379 RHSVtoRGB(&hsv
, rgb
);
381 sprintf(item
->text
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
384 if (w
== panel
->ghueS
) {
385 updateSVSlider(panel
->gsatS
, True
, panel
->listFont
, &hsv
);
386 updateSVSlider(panel
->gvalS
, False
, panel
->listFont
, &hsv
);
387 } else if (w
== panel
->gsatS
) {
388 updateHueSlider(panel
->ghueS
, panel
->listFont
, &hsv
);
389 updateSVSlider(panel
->gvalS
, False
, panel
->listFont
, &hsv
);
391 updateHueSlider(panel
->ghueS
, panel
->listFont
, &hsv
);
392 updateSVSlider(panel
->gsatS
, True
, panel
->listFont
, &hsv
);
395 rows
= WMGetListNumberOfRows(panel
->gcolL
);
399 colors
= wmalloc(sizeof(RColor
*) * (rows
+ 1));
401 for (i
= 0; i
< rows
; i
++) {
402 item
= WMGetListItem(panel
->gcolL
, i
);
404 colors
[i
] = (RColor
*) item
->clientData
;
408 if (panel
->gimage
!= None
) {
409 XFreePixmap(WMScreenDisplay(scr
), panel
->gimage
);
412 image
= RRenderMultiGradient(30, i
* WMGetListItemHeight(panel
->gcolL
), colors
, RVerticalGradient
);
413 RConvertImage(WMScreenRContext(scr
), image
, &panel
->gimage
);
414 RReleaseImage(image
);
418 WMRedisplayWidget(panel
->gcolL
);
420 updateGradButtons(panel
);
423 static void paintGradListItem(WMList
* lPtr
, int index
, Drawable d
, char *text
, int state
, WMRect
* rect
)
425 TexturePanel
*panel
= (TexturePanel
*) WMGetHangedData(lPtr
);
426 WMScreen
*scr
= WMWidgetScreen(lPtr
);
427 WMColor
*white
= WMWhiteColor(scr
);
428 WMColor
*black
= WMBlackColor(scr
);
429 WMColor
*gray
= WMGrayColor(scr
);
430 int width
, height
, x
, y
;
433 dpy
= WMScreenDisplay(scr
);
435 width
= rect
->size
.width
;
436 height
= rect
->size
.height
;
440 if (state
& WLDSSelected
)
441 XFillRectangle(dpy
, d
, WMColorGC(white
), x
, y
, width
, height
);
443 XFillRectangle(dpy
, d
, WMColorGC(gray
), x
, y
, width
, height
);
446 XCopyArea(WMScreenDisplay(scr
), panel
->gimage
, d
, WMColorGC(white
),
447 0, height
* index
, 30, height
, x
+ 5, y
);
449 WMDrawString(scr
, d
, black
, panel
->listFont
, x
+ 40, y
+ 1, text
, strlen(text
));
451 WMReleaseColor(white
);
452 WMReleaseColor(black
);
453 WMReleaseColor(gray
);
456 static void gradAddCallback(WMWidget
* w
, void *data
)
458 TexturePanel
*panel
= (TexturePanel
*) data
;
463 row
= WMGetListSelectedItemRow(panel
->gcolL
) + 1;
464 item
= WMInsertListItem(panel
->gcolL
, row
, "00,00,00");
465 rgb
= wmalloc(sizeof(RColor
));
466 item
->clientData
= rgb
;
468 WMSelectListItem(panel
->gcolL
, row
);
470 updateGradButtons(panel
);
472 sliderChangeCallback(panel
->ghueS
, panel
);
474 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
477 static void gradClickCallback(WMWidget
* w
, void *data
)
479 TexturePanel
*panel
= (TexturePanel
*) data
;
484 row
= WMGetListSelectedItemRow(w
);
488 item
= WMGetListItem(panel
->gcolL
, row
);
489 RRGBtoHSV((RColor
*) item
->clientData
, &hsv
);
491 WMSetSliderValue(panel
->ghueS
, hsv
.hue
);
492 WMSetSliderValue(panel
->gsatS
, hsv
.saturation
);
493 WMSetSliderValue(panel
->gvalS
, hsv
.value
);
495 sliderChangeCallback(panel
->ghueS
, panel
);
496 sliderChangeCallback(panel
->gsatS
, panel
);
499 static void gradDeleteCallback(WMWidget
* w
, void *data
)
501 TexturePanel
*panel
= (TexturePanel
*) data
;
505 row
= WMGetListSelectedItemRow(panel
->gcolL
);
509 item
= WMGetListItem(panel
->gcolL
, row
);
510 wfree(item
->clientData
);
512 WMRemoveListItem(panel
->gcolL
, row
);
514 WMSelectListItem(panel
->gcolL
, row
- 1);
516 updateGradButtons(panel
);
518 gradClickCallback(panel
->gcolL
, panel
);
520 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
523 /*************** Simple Gradient ***************/
525 static void colorWellObserver(void *self
, WMNotification
* n
)
527 updateSGradButtons(self
);
530 static void opaqChangeCallback(WMWidget
* w
, void *data
)
532 TexturePanel
*panel
= (TexturePanel
*) data
;
534 updateTGradImage(panel
);
537 /****************** Image ******************/
539 static void updateImage(TexturePanel
* panel
, char *path
)
541 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
547 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
551 message
= wstrconcat(_("Could not load the selected file: "),
552 (char *)RMessageForError(RErrorCode
));
554 WMRunAlertPanel(scr
, panel
->win
, _("Error"), message
, _("OK"), NULL
, NULL
);
557 WMSetButtonEnabled(panel
->okB
, False
);
563 WMSetButtonEnabled(panel
->okB
, True
);
566 RReleaseImage(panel
->image
);
567 panel
->image
= image
;
569 image
= panel
->image
;
572 if (WMGetPopUpButtonSelectedItem(panel
->typeP
) == TYPE_PIXMAP
) {
574 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
576 size
= WMGetPixmapSize(pixmap
);
577 WMSetLabelImage(panel
->imageL
, pixmap
);
578 WMResizeWidget(panel
->imageL
, size
.width
, size
.height
);
580 WMReleasePixmap(pixmap
);
583 updateTGradImage(panel
);
587 static void browseImageCallback(WMWidget
* w
, void *data
)
589 TexturePanel
*panel
= (TexturePanel
*) data
;
591 WMScreen
*scr
= WMWidgetScreen(w
);
592 static char *ipath
= NULL
;
594 opanel
= WMGetOpenPanel(scr
);
595 WMSetFilePanelCanChooseDirectories(opanel
, False
);
596 WMSetFilePanelCanChooseFiles(opanel
, True
);
599 ipath
= wstrdup(wgethomedir());
601 if (WMRunModalFilePanelForDirectory(opanel
, panel
->win
, ipath
, _("Open Image"), NULL
)) {
602 char *path
, *fullpath
;
605 tmp
= WMGetFilePanelFileName(opanel
);
613 path
= wstrdup(fullpath
);
615 tmp2
= strrchr(fullpath
, '/');
619 tmp
= wfindfileinarray(panel
->pathList
, tmp2
);
622 if (strcmp(fullpath
, tmp
) == 0) {
629 if (!RGetImageFileFormat(fullpath
)) {
630 WMRunAlertPanel(scr
, panel
->win
, _("Error"),
631 _("The selected file does not contain a supported image."),
632 _("OK"), NULL
, NULL
);
635 updateImage(panel
, fullpath
);
636 wfree(panel
->imageFile
);
637 panel
->imageFile
= path
;
639 WMSetTextFieldText(panel
->imageT
, path
);
644 static void buttonCallback(WMWidget
* w
, void *data
)
646 TexturePanel
*panel
= (TexturePanel
*) data
;
648 if (w
== panel
->okB
) {
649 (*panel
->okAction
) (panel
->okData
);
651 (*panel
->cancelAction
) (panel
->cancelData
);
655 static void changeTypeCallback(WMWidget
* w
, void *data
)
657 TexturePanel
*panel
= (TexturePanel
*) data
;
661 newType
= WMGetPopUpButtonSelectedItem(w
);
662 if (newType
== panel
->currentType
)
665 if (panel
->currentType
>= 0) {
666 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
667 if (panel
->sectionParts
[panel
->currentType
][i
] == NULL
)
669 WMUnmapWidget(panel
->sectionParts
[panel
->currentType
][i
]);
673 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
674 if (panel
->sectionParts
[newType
][i
] == NULL
)
676 WMMapWidget(panel
->sectionParts
[newType
][i
]);
678 panel
->currentType
= newType
;
682 updateSGradButtons(panel
);
683 WMSetButtonEnabled(panel
->okB
, True
);
686 updateGradButtons(panel
);
687 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
691 updateImage(panel
, NULL
);
692 WMSetButtonEnabled(panel
->okB
, panel
->image
!= NULL
);
695 WMSetButtonEnabled(panel
->okB
, True
);
701 *--------------------------------------------------------------------------
703 *--------------------------------------------------------------------------
705 void DestroyTexturePanel(TexturePanel
* panel
)
710 void ShowTexturePanel(TexturePanel
* panel
)
712 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(panel
->win
));
713 Screen
*scr
= DefaultScreenOfDisplay(dpy
);
715 WMSetWindowInitialPosition(panel
->win
,
716 (WidthOfScreen(scr
) - WMWidgetWidth(panel
->win
)) / 2,
717 (HeightOfScreen(scr
) - WMWidgetHeight(panel
->win
)) / 2);
718 WMMapWidget(panel
->win
);
721 void HideTexturePanel(TexturePanel
* panel
)
723 WMUnmapWidget(panel
->win
);
726 void SetTexturePanelOkAction(TexturePanel
* panel
, WMCallback
* action
, void *clientData
)
728 panel
->okAction
= action
;
729 panel
->okData
= clientData
;
732 void SetTexturePanelCancelAction(TexturePanel
* panel
, WMCallback
* action
, void *clientData
)
734 panel
->cancelAction
= action
;
735 panel
->cancelData
= clientData
;
738 void SetTexturePanelTexture(TexturePanel
* panel
, char *name
, WMPropList
* texture
)
740 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
748 WMSetTextFieldText(panel
->nameT
, name
);
753 p
= WMGetFromPLArray(texture
, 0);
757 type
= WMGetFromPLString(p
);
759 /*............................................... */
760 if (strcasecmp(type
, "solid") == 0) {
762 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SOLID
);
764 p
= WMGetFromPLArray(texture
, 1);
768 str
= WMGetFromPLString(p
);
770 color
= WMCreateNamedColor(scr
, str
, False
);
772 WMSetColorWellColor(panel
->defcW
, color
);
774 WMReleaseColor(color
);
775 /*............................................... */
776 } else if (strcasecmp(type
, "hgradient") == 0
777 || strcasecmp(type
, "vgradient") == 0 || strcasecmp(type
, "dgradient") == 0) {
779 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SGRADIENT
);
781 p
= WMGetFromPLArray(texture
, 1);
785 str
= WMGetFromPLString(p
);
787 color
= WMCreateNamedColor(scr
, str
, False
);
789 WMSetColorWellColor(panel
->tcol1W
, color
);
791 WMReleaseColor(color
);
793 p
= WMGetFromPLArray(texture
, 2);
797 str
= WMGetFromPLString(p
);
799 color
= WMCreateNamedColor(scr
, str
, False
);
801 WMSetColorWellColor(panel
->tcol2W
, color
);
803 WMReleaseColor(color
);
806 /*............................................... */
807 } else if (strcasecmp(type
, "thgradient") == 0
808 || strcasecmp(type
, "tvgradient") == 0 || strcasecmp(type
, "tdgradient") == 0) {
811 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_TGRADIENT
);
815 WMSetTextFieldText(panel
->imageT
, WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
816 if (panel
->imageFile
)
817 wfree(panel
->imageFile
);
818 panel
->imageFile
= wstrdup(WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
821 sscanf(WMGetFromPLString(WMGetFromPLArray(texture
, 2)), "%i", &i
);
822 WMSetSliderValue(panel
->topaS
, i
);
824 p
= WMGetFromPLArray(texture
, 3);
828 str
= WMGetFromPLString(p
);
830 color
= WMCreateNamedColor(scr
, str
, False
);
832 WMSetColorWellColor(panel
->tcol1W
, color
);
834 WMReleaseColor(color
);
836 p
= WMGetFromPLArray(texture
, 4);
840 str
= WMGetFromPLString(p
);
842 color
= WMCreateNamedColor(scr
, str
, False
);
844 WMSetColorWellColor(panel
->tcol2W
, color
);
846 WMReleaseColor(color
);
848 WMSetTextFieldText(panel
->imageT
, WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
850 if (panel
->imageFile
)
851 wfree(panel
->imageFile
);
852 if ((panel
->imageFile
= wfindfileinarray(panel
->pathList
,
853 WMGetFromPLString(WMGetFromPLArray(texture
, 1)))) !=
856 panel
->image
= RLoadImage(WMScreenRContext(scr
), panel
->imageFile
, 0);
857 updateTGradImage(panel
);
859 updateSGradButtons(panel
);
861 wwarning(_("could not load file '%s': %s"), panel
->imageFile
,
862 RMessageForError(RErrorCode
));
864 /*............................................... */
865 } else if (strcasecmp(type
, "mhgradient") == 0
866 || strcasecmp(type
, "mvgradient") == 0 || strcasecmp(type
, "mdgradient") == 0) {
869 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
870 item
= WMGetListItem(panel
->gcolL
, i
);
871 wfree(item
->clientData
);
873 WMClearList(panel
->gcolL
);
875 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_GRADIENT
);
877 p
= WMGetFromPLArray(texture
, 1);
881 str
= WMGetFromPLString(p
);
883 color
= WMCreateNamedColor(scr
, str
, False
);
885 WMSetColorWellColor(panel
->defcW
, color
);
887 WMReleaseColor(color
);
889 for (i
= 2; i
< WMGetPropListItemCount(texture
); i
++) {
893 p
= WMGetFromPLArray(texture
, i
);
897 str
= WMGetFromPLString(p
);
900 XParseColor(WMScreenDisplay(scr
), WMScreenRContext(scr
)->cmap
, str
, &xcolor
);
902 rgb
= wmalloc(sizeof(RColor
));
903 rgb
->red
= xcolor
.red
>> 8;
904 rgb
->green
= xcolor
.green
>> 8;
905 rgb
->blue
= xcolor
.blue
>> 8;
906 sprintf(buffer
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
908 item
= WMAddListItem(panel
->gcolL
, buffer
);
909 item
->clientData
= rgb
;
912 sliderChangeCallback(panel
->ghueS
, panel
);
915 /*............................................... */
916 } else if (strcasecmp(type
, "cpixmap") == 0
917 || strcasecmp(type
, "spixmap") == 0
918 || strcasecmp(type
, "mpixmap") == 0 || strcasecmp(type
, "tpixmap") == 0) {
920 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_PIXMAP
);
922 switch (toupper(type
[0])) {
924 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_CENTER
);
927 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_SCALE
);
930 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_MAXIMIZE
);
934 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_TILE
);
938 WMSetTextFieldText(panel
->imageT
, WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
940 if (panel
->imageFile
)
941 wfree(panel
->imageFile
);
942 panel
->imageFile
= wfindfileinarray(panel
->pathList
,
943 WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
945 color
= WMCreateNamedColor(scr
, WMGetFromPLString(WMGetFromPLArray(texture
, 2)), False
);
946 WMSetColorWellColor(panel
->defcW
, color
);
947 WMReleaseColor(color
);
949 updateImage(panel
, panel
->imageFile
);
952 changeTypeCallback(panel
->typeP
, panel
);
955 updateGradButtons(panel
);
957 switch (toupper(gradient
)) {
959 WMPerformButtonClick(panel
->dirhB
);
962 WMPerformButtonClick(panel
->dirvB
);
966 WMPerformButtonClick(panel
->dirdB
);
974 str
= WMGetPropListDescription(texture
, False
);
975 wwarning(_("error creating texture %s"), str
);
980 char *GetTexturePanelTextureName(TexturePanel
* panel
)
982 return WMGetTextFieldText(panel
->nameT
);
986 WMPropList
*GetTexturePanelTexture(TexturePanel
* panel
)
988 WMPropList
*prop
= NULL
;
994 switch (WMGetPopUpButtonSelectedItem(panel
->typeP
)) {
997 color
= WMGetColorWellColor(panel
->defcW
);
998 str
= WMGetColorRGBDescription(color
);
999 prop
= WMCreatePLArray(WMCreatePLString("solid"), WMCreatePLString(str
), NULL
);
1005 color
= WMGetColorWellColor(panel
->defcW
);
1006 str
= WMGetColorRGBDescription(color
);
1008 switch (WMGetPopUpButtonSelectedItem(panel
->arrP
)) {
1010 prop
= WMCreatePLArray(WMCreatePLString("spixmap"),
1011 WMCreatePLString(panel
->imageFile
), WMCreatePLString(str
), NULL
);
1013 case PTYPE_MAXIMIZE
:
1014 prop
= WMCreatePLArray(WMCreatePLString("mpixmap"),
1015 WMCreatePLString(panel
->imageFile
), WMCreatePLString(str
), NULL
);
1018 prop
= WMCreatePLArray(WMCreatePLString("cpixmap"),
1019 WMCreatePLString(panel
->imageFile
), WMCreatePLString(str
), NULL
);
1022 prop
= WMCreatePLArray(WMCreatePLString("tpixmap"),
1023 WMCreatePLString(panel
->imageFile
), WMCreatePLString(str
), NULL
);
1029 case TYPE_TGRADIENT
:
1030 color
= WMGetColorWellColor(panel
->tcol1W
);
1031 str
= WMGetColorRGBDescription(color
);
1033 color
= WMGetColorWellColor(panel
->tcol2W
);
1034 str2
= WMGetColorRGBDescription(color
);
1036 sprintf(buff
, "%i", WMGetSliderValue(panel
->topaS
));
1038 if (WMGetButtonSelected(panel
->dirdB
)) {
1039 prop
= WMCreatePLArray(WMCreatePLString("tdgradient"),
1040 WMCreatePLString(panel
->imageFile
),
1041 WMCreatePLString(buff
),
1042 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1043 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1044 prop
= WMCreatePLArray(WMCreatePLString("tvgradient"),
1045 WMCreatePLString(panel
->imageFile
),
1046 WMCreatePLString(buff
),
1047 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1049 prop
= WMCreatePLArray(WMCreatePLString("thgradient"),
1050 WMCreatePLString(panel
->imageFile
),
1051 WMCreatePLString(buff
),
1052 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1058 case TYPE_SGRADIENT
:
1059 color
= WMGetColorWellColor(panel
->tcol1W
);
1060 str
= WMGetColorRGBDescription(color
);
1062 color
= WMGetColorWellColor(panel
->tcol2W
);
1063 str2
= WMGetColorRGBDescription(color
);
1065 if (WMGetButtonSelected(panel
->dirdB
)) {
1066 prop
= WMCreatePLArray(WMCreatePLString("dgradient"),
1067 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1068 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1069 prop
= WMCreatePLArray(WMCreatePLString("vgradient"),
1070 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1072 prop
= WMCreatePLArray(WMCreatePLString("hgradient"),
1073 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1080 color
= WMGetColorWellColor(panel
->defcW
);
1081 str
= WMGetColorRGBDescription(color
);
1083 if (WMGetButtonSelected(panel
->dirdB
)) {
1084 prop
= WMCreatePLArray(WMCreatePLString("mdgradient"), WMCreatePLString(str
), NULL
);
1085 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1086 prop
= WMCreatePLArray(WMCreatePLString("mvgradient"), WMCreatePLString(str
), NULL
);
1088 prop
= WMCreatePLArray(WMCreatePLString("mhgradient"), WMCreatePLString(str
), NULL
);
1092 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
1096 item
= WMGetListItem(panel
->gcolL
, i
);
1098 rgb
= (RColor
*) item
->clientData
;
1100 sprintf(buff
, "#%02x%02x%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
1102 WMAddToPLArray(prop
, WMCreatePLString(buff
));
1110 void SetTexturePanelPixmapPath(TexturePanel
* panel
, WMPropList
* array
)
1112 panel
->pathList
= array
;
1115 TexturePanel
*CreateTexturePanel(WMWindow
* keyWindow
)
1116 /*CreateTexturePanel(WMScreen *scr)*/
1118 TexturePanel
*panel
;
1119 WMScreen
*scr
= WMWidgetScreen(keyWindow
);
1121 panel
= wmalloc(sizeof(TexturePanel
));
1123 panel
->listFont
= WMSystemFontOfSize(scr
, 12);
1125 panel
->win
= WMCreatePanelWithStyleForWindow(keyWindow
, "texturePanel",
1126 WMTitledWindowMask
| WMClosableWindowMask
);
1128 panel->win = WMCreateWindowWithStyle(scr, "texturePanel",
1130 |WMClosableWindowMask);
1133 WMResizeWidget(panel
->win
, 325, 423);
1134 WMSetWindowTitle(panel
->win
, _("Texture Panel"));
1135 WMSetWindowCloseAction(panel
->win
, buttonCallback
, panel
);
1138 panel
->nameF
= WMCreateFrame(panel
->win
);
1139 WMResizeWidget(panel
->nameF
, 185, 50);
1140 WMMoveWidget(panel
->nameF
, 15, 10);
1141 WMSetFrameTitle(panel
->nameF
, _("Texture Name"));
1143 panel
->nameT
= WMCreateTextField(panel
->nameF
);
1144 WMResizeWidget(panel
->nameT
, 160, 20);
1145 WMMoveWidget(panel
->nameT
, 12, 18);
1147 WMMapSubwidgets(panel
->nameF
);
1150 panel
->typeP
= WMCreatePopUpButton(panel
->win
);
1151 WMResizeWidget(panel
->typeP
, 185, 20);
1152 WMMoveWidget(panel
->typeP
, 15, 65);
1153 WMAddPopUpButtonItem(panel
->typeP
, _("Solid Color"));
1154 WMAddPopUpButtonItem(panel
->typeP
, _("Gradient Texture"));
1155 WMAddPopUpButtonItem(panel
->typeP
, _("Simple Gradient Texture"));
1156 WMAddPopUpButtonItem(panel
->typeP
, _("Textured Gradient"));
1157 WMAddPopUpButtonItem(panel
->typeP
, _("Image Texture"));
1158 WMSetPopUpButtonSelectedItem(panel
->typeP
, 0);
1159 WMSetPopUpButtonAction(panel
->typeP
, changeTypeCallback
, panel
);
1162 panel
->defcF
= WMCreateFrame(panel
->win
);
1163 WMResizeWidget(panel
->defcF
, 100, 75);
1164 WMMoveWidget(panel
->defcF
, 210, 10);
1165 WMSetFrameTitle(panel
->defcF
, _("Default Color"));
1167 panel
->defcW
= WMCreateColorWell(panel
->defcF
);
1168 WMResizeWidget(panel
->defcW
, 60, 45);
1169 WMMoveWidget(panel
->defcW
, 20, 20);
1171 WMMapSubwidgets(panel
->defcF
);
1173 /****** Gradient ******/
1174 panel
->gcolF
= WMCreateFrame(panel
->win
);
1175 WMResizeWidget(panel
->gcolF
, 295, 205);
1176 WMMoveWidget(panel
->gcolF
, 15, 95);
1177 WMSetFrameTitle(panel
->gcolF
, _("Gradient Colors"));
1179 panel
->gcolL
= WMCreateList(panel
->gcolF
);
1180 WMResizeWidget(panel
->gcolL
, 130, 140);
1181 WMMoveWidget(panel
->gcolL
, 10, 25);
1182 WMHangData(panel
->gcolL
, panel
);
1183 WMSetListUserDrawProc(panel
->gcolL
, paintGradListItem
);
1184 WMSetListAction(panel
->gcolL
, gradClickCallback
, panel
);
1186 panel
->gcolaB
= WMCreateCommandButton(panel
->gcolF
);
1187 WMResizeWidget(panel
->gcolaB
, 64, 24);
1188 WMMoveWidget(panel
->gcolaB
, 10, 170);
1189 WMSetButtonText(panel
->gcolaB
, _("Add"));
1190 WMSetButtonAction(panel
->gcolaB
, gradAddCallback
, panel
);
1192 panel
->gcoldB
= WMCreateCommandButton(panel
->gcolF
);
1193 WMResizeWidget(panel
->gcoldB
, 64, 24);
1194 WMMoveWidget(panel
->gcoldB
, 75, 170);
1195 WMSetButtonText(panel
->gcoldB
, _("Delete"));
1196 WMSetButtonAction(panel
->gcoldB
, gradDeleteCallback
, panel
);
1199 panel
->gbriS
= WMCreateSlider(panel
->gcolF
);
1200 WMResizeWidget(panel
->gbriS
, 130, 16);
1201 WMMoveWidget(panel
->gbriS
, 150, 25);
1202 WMSetSliderKnobThickness(panel
->gbriS
, 8);
1203 WMSetSliderMaxValue(panel
->gbriS
, 100);
1204 WMSetSliderAction(panel
->gbriS
, sliderChangeCallback
, panel
);
1209 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1210 color
= WMDarkGrayColor(scr
);
1211 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
), WMColorGC(color
), 0, 0, 130, 16);
1212 WMReleaseColor(color
);
1213 color
= WMWhiteColor(color
);
1214 WMDrawString(scr
, WMGetPixmapXID(pixmap
), color
,
1215 panel
->listFont
, 2, (16 - WMFontHeight(panel
->listFont
)) / 2 - 1, "Brightness", 10);
1216 WMSetSliderImage(panel
->gbriS
, pixmap
);
1217 WMReleasePixmap(pixmap
);
1220 panel
->gconS
= WMCreateSlider(panel
->gcolF
);
1221 WMResizeWidget(panel
->gconS
, 130, 16);
1222 WMMoveWidget(panel
->gconS
, 150, 50);
1223 WMSetSliderKnobThickness(panel
->gconS
, 8);
1224 WMSetSliderMaxValue(panel
->gconS
, 100);
1225 WMSetSliderAction(panel
->gconS
, sliderChangeCallback
, panel
);
1230 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1231 color
= WMDarkGrayColor(scr
);
1232 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
), WMColorGC(color
), 0, 0, 130, 16);
1233 WMReleaseColor(color
);
1234 color
= WMWhiteColor(scr
);
1235 WMDrawString(scr
, WMGetPixmapXID(pixmap
), color
,
1236 panel
->listFont
, 2, (16 - WMFontHeight(panel
->listFont
)) / 2 - 1, "Contrast", 8);
1237 WMSetSliderImage(panel
->gconS
, pixmap
);
1238 WMReleasePixmap(pixmap
);
1241 panel
->ghueS
= WMCreateSlider(panel
->gcolF
);
1242 WMResizeWidget(panel
->ghueS
, 130, 16);
1243 WMMoveWidget(panel
->ghueS
, 150, 100);
1244 WMSetSliderKnobThickness(panel
->ghueS
, 8);
1245 WMSetSliderMaxValue(panel
->ghueS
, 359);
1246 WMSetSliderAction(panel
->ghueS
, sliderChangeCallback
, panel
);
1248 panel
->gsatS
= WMCreateSlider(panel
->gcolF
);
1249 WMResizeWidget(panel
->gsatS
, 130, 16);
1250 WMMoveWidget(panel
->gsatS
, 150, 125);
1251 WMSetSliderKnobThickness(panel
->gsatS
, 8);
1252 WMSetSliderMaxValue(panel
->gsatS
, 255);
1253 WMSetSliderAction(panel
->gsatS
, sliderChangeCallback
, panel
);
1255 panel
->gvalS
= WMCreateSlider(panel
->gcolF
);
1256 WMResizeWidget(panel
->gvalS
, 130, 16);
1257 WMMoveWidget(panel
->gvalS
, 150, 150);
1258 WMSetSliderKnobThickness(panel
->gvalS
, 8);
1259 WMSetSliderMaxValue(panel
->gvalS
, 255);
1260 WMSetSliderAction(panel
->gvalS
, sliderChangeCallback
, panel
);
1262 WMMapSubwidgets(panel
->gcolF
);
1265 panel
->dirF
= WMCreateFrame(panel
->win
);
1266 WMSetFrameTitle(panel
->dirF
, _("Direction"));
1267 WMResizeWidget(panel
->dirF
, 295, 75);
1268 WMMoveWidget(panel
->dirF
, 15, 305);
1270 panel
->dirvB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1271 WMSetButtonImagePosition(panel
->dirvB
, WIPImageOnly
);
1272 WMResizeWidget(panel
->dirvB
, 90, 40);
1273 WMMoveWidget(panel
->dirvB
, 10, 20);
1275 panel
->dirhB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1276 WMSetButtonImagePosition(panel
->dirhB
, WIPImageOnly
);
1277 WMResizeWidget(panel
->dirhB
, 90, 40);
1278 WMMoveWidget(panel
->dirhB
, 102, 20);
1280 panel
->dirdB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1281 WMSetButtonImagePosition(panel
->dirdB
, WIPImageOnly
);
1282 WMResizeWidget(panel
->dirdB
, 90, 40);
1283 WMMoveWidget(panel
->dirdB
, 194, 20);
1285 WMGroupButtons(panel
->dirvB
, panel
->dirhB
);
1286 WMGroupButtons(panel
->dirvB
, panel
->dirdB
);
1288 WMMapSubwidgets(panel
->dirF
);
1290 /****************** Textured Gradient ******************/
1291 panel
->tcolF
= WMCreateFrame(panel
->win
);
1292 WMResizeWidget(panel
->tcolF
, 100, 135);
1293 WMMoveWidget(panel
->tcolF
, 210, 10);
1294 WMSetFrameTitle(panel
->tcolF
, _("Gradient"));
1296 panel
->tcol1W
= WMCreateColorWell(panel
->tcolF
);
1297 WMResizeWidget(panel
->tcol1W
, 60, 45);
1298 WMMoveWidget(panel
->tcol1W
, 20, 25);
1299 WMAddNotificationObserver(colorWellObserver
, panel
, WMColorWellDidChangeNotification
, panel
->tcol1W
);
1301 panel
->tcol2W
= WMCreateColorWell(panel
->tcolF
);
1302 WMResizeWidget(panel
->tcol2W
, 60, 45);
1303 WMMoveWidget(panel
->tcol2W
, 20, 75);
1304 WMAddNotificationObserver(colorWellObserver
, panel
, WMColorWellDidChangeNotification
, panel
->tcol2W
);
1307 panel
->topaF
= WMCreateFrame(panel
->win
);
1308 WMResizeWidget(panel
->topaF
, 185, 50);
1309 WMMoveWidget(panel
->topaF
, 15, 95);
1310 WMSetFrameTitle(panel
->topaF
, _("Gradient Opacity"));
1312 panel
->topaS
= WMCreateSlider(panel
->topaF
);
1313 WMResizeWidget(panel
->topaS
, 155, 18);
1314 WMMoveWidget(panel
->topaS
, 15, 20);
1315 WMSetSliderMaxValue(panel
->topaS
, 255);
1316 WMSetSliderValue(panel
->topaS
, 200);
1317 WMSetSliderContinuous(panel
->topaS
, False
);
1318 WMSetSliderAction(panel
->topaS
, opaqChangeCallback
, panel
);
1320 WMMapSubwidgets(panel
->topaF
);
1327 pixmap
= WMCreatePixmap(scr
, 155, 18, WMScreenDepth(scr
), False
);
1328 p
= WMGetPixmapXID(pixmap
);
1330 color
= WMDarkGrayColor(scr
);
1331 XFillRectangle(WMScreenDisplay(scr
), p
, WMColorGC(color
), 0, 0, 155, 18);
1332 WMReleaseColor(color
);
1334 color
= WMWhiteColor(scr
);
1335 WMDrawString(scr
, p
, color
, panel
->listFont
, 2, 1, "0%", 2);
1336 WMDrawString(scr
, p
, color
, panel
->listFont
,
1337 153 - WMWidthOfString(panel
->listFont
, "100%", 4), 1, "100%", 4);
1338 WMReleaseColor(color
);
1340 WMSetSliderImage(panel
->topaS
, pixmap
);
1341 WMReleasePixmap(pixmap
);
1344 WMMapSubwidgets(panel
->tcolF
);
1346 /****************** Image ******************/
1347 panel
->imageF
= WMCreateFrame(panel
->win
);
1348 WMResizeWidget(panel
->imageF
, 295, 150);
1349 WMMoveWidget(panel
->imageF
, 15, 150);
1350 WMSetFrameTitle(panel
->imageF
, _("Image"));
1352 panel
->imageL
= WMCreateLabel(panel
->imageF
);
1353 WMSetLabelImagePosition(panel
->imageL
, WIPImageOnly
);
1355 panel
->imageT
= WMCreateTextField(panel
->imageF
);
1356 WMResizeWidget(panel
->imageT
, 90, 20);
1357 WMMoveWidget(panel
->imageT
, 190, 25);
1359 panel
->imageV
= WMCreateScrollView(panel
->imageF
);
1360 WMResizeWidget(panel
->imageV
, 165, 115);
1361 WMMoveWidget(panel
->imageV
, 15, 20);
1362 WMSetScrollViewRelief(panel
->imageV
, WRSunken
);
1363 WMSetScrollViewHasHorizontalScroller(panel
->imageV
, True
);
1364 WMSetScrollViewHasVerticalScroller(panel
->imageV
, True
);
1365 WMSetScrollViewContentView(panel
->imageV
, WMWidgetView(panel
->imageL
));
1367 panel
->browB
= WMCreateCommandButton(panel
->imageF
);
1368 WMResizeWidget(panel
->browB
, 90, 24);
1369 WMMoveWidget(panel
->browB
, 190, 50);
1370 WMSetButtonText(panel
->browB
, _("Browse..."));
1371 WMSetButtonAction(panel
->browB
, browseImageCallback
, panel
);
1373 /* panel->dispB = WMCreateCommandButton(panel->imageF);
1374 WMResizeWidget(panel->dispB, 90, 24);
1375 WMMoveWidget(panel->dispB, 190, 80);
1376 WMSetButtonText(panel->dispB, _("Show"));
1379 panel
->arrP
= WMCreatePopUpButton(panel
->imageF
);
1380 WMResizeWidget(panel
->arrP
, 90, 20);
1381 WMMoveWidget(panel
->arrP
, 190, 120);
1382 WMAddPopUpButtonItem(panel
->arrP
, _("Tile"));
1383 WMAddPopUpButtonItem(panel
->arrP
, _("Scale"));
1384 WMAddPopUpButtonItem(panel
->arrP
, _("Center"));
1385 WMAddPopUpButtonItem(panel
->arrP
, _("Maximize"));
1386 WMSetPopUpButtonSelectedItem(panel
->arrP
, 0);
1388 WMMapSubwidgets(panel
->imageF
);
1392 panel
->okB
= WMCreateCommandButton(panel
->win
);
1393 WMResizeWidget(panel
->okB
, 84, 24);
1394 WMMoveWidget(panel
->okB
, 225, 390);
1395 WMSetButtonText(panel
->okB
, _("OK"));
1396 WMSetButtonAction(panel
->okB
, buttonCallback
, panel
);
1398 panel
->cancelB
= WMCreateCommandButton(panel
->win
);
1399 WMResizeWidget(panel
->cancelB
, 84, 24);
1400 WMMoveWidget(panel
->cancelB
, 130, 390);
1401 WMSetButtonText(panel
->cancelB
, _("Cancel"));
1402 WMSetButtonAction(panel
->cancelB
, buttonCallback
, panel
);
1404 WMMapWidget(panel
->nameF
);
1405 WMMapWidget(panel
->typeP
);
1406 WMMapWidget(panel
->okB
);
1407 WMMapWidget(panel
->cancelB
);
1409 WMUnmapWidget(panel
->arrP
);
1411 WMRealizeWidget(panel
->win
);
1413 panel
->currentType
= -1;
1415 panel
->sectionParts
[TYPE_SOLID
][0] = panel
->defcF
;
1417 panel
->sectionParts
[TYPE_GRADIENT
][0] = panel
->defcF
;
1418 panel
->sectionParts
[TYPE_GRADIENT
][1] = panel
->gcolF
;
1419 panel
->sectionParts
[TYPE_GRADIENT
][2] = panel
->dirF
;
1421 panel
->sectionParts
[TYPE_SGRADIENT
][0] = panel
->tcolF
;
1422 panel
->sectionParts
[TYPE_SGRADIENT
][1] = panel
->dirF
;
1424 panel
->sectionParts
[TYPE_TGRADIENT
][0] = panel
->tcolF
;
1425 panel
->sectionParts
[TYPE_TGRADIENT
][1] = panel
->dirF
;
1426 panel
->sectionParts
[TYPE_TGRADIENT
][2] = panel
->imageF
;
1427 panel
->sectionParts
[TYPE_TGRADIENT
][3] = panel
->topaF
;
1428 panel
->sectionParts
[TYPE_TGRADIENT
][4] = panel
->arrP
;
1430 panel
->sectionParts
[TYPE_PIXMAP
][0] = panel
->defcF
;
1431 panel
->sectionParts
[TYPE_PIXMAP
][1] = panel
->imageF
;
1432 panel
->sectionParts
[TYPE_PIXMAP
][2] = panel
->arrP
;
1434 /* setup for first time */
1436 changeTypeCallback(panel
->typeP
, panel
);
1438 sliderChangeCallback(panel
->ghueS
, panel
);
1439 sliderChangeCallback(panel
->gsatS
, panel
);
1445 *--------------------------------------------------------------------------
1447 *--------------------------------------------------------------------------
1452 char *ProgName
= "test";
1454 void testOKButton(WMWidget
* self
, void *data
)
1462 TexturePanel
*panel
= (TexturePanel
*) data
;
1463 /* test = GetTexturePanelTextureString(panel); */
1467 dpy
= WMScreenDisplay(WMWidgetScreen(panel
->okB
));
1468 win
= XCreateSimpleWindow(dpy
, DefaultRootWindow(dpy
), 10, 10, 250, 250, 0, 0, 0);
1469 XMapRaised(dpy
, win
);
1472 /* image = RenderTexturePanelTexture(panel, 250, 250); */
1474 RConvertImage(WMScreenRContext(WMWidgetScreen(panel
->okB
)), image
, &pix
);
1476 XCopyArea(dpy
, pix
, win
, (WMScreenRContext(WMWidgetScreen(panel
->okB
)))->copy_gc
, 0, 0, image
->width
,
1477 image
->height
, 0, 0);
1483 void testCancelButton(WMWidget
* self
, void *data
)
1485 wwarning("Exiting test....");
1494 int main(int argc
, char **argv
)
1496 TexturePanel
*panel
;
1498 Display
*dpy
= XOpenDisplay("");
1503 WMInitializeApplication("Test", &argc
, argv
);
1506 wfatal("could not open display");
1510 scr
= WMCreateSimpleApplicationScreen(dpy
);
1512 panel
= CreateTexturePanel(scr
);
1514 SetTexturePanelOkAction(panel
, (WMAction
*) testOKButton
, panel
);
1515 SetTexturePanelCancelAction(panel
, (WMAction
*) testCancelButton
, panel
);
1517 SetTexturePanelTexture(panel
, "pinky",
1518 WMCreatePropListFromDescription("(mdgradient, pink, red, blue, yellow)"));
1520 ShowTexturePanel(panel
);
1522 WMScreenMainLoop(scr
);