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
);
431 int width
, height
, x
, y
;
434 dpy
= WMScreenDisplay(scr
);
436 width
= rect
->size
.width
;
437 height
= rect
->size
.height
;
441 if (state
& WLDSSelected
)
442 XFillRectangle(dpy
, d
, WMColorGC(white
), x
, y
, width
, height
);
444 XFillRectangle(dpy
, d
, WMColorGC(gray
), x
, y
, width
, height
);
446 item
= WMGetListItem(lPtr
, index
);
449 XCopyArea(WMScreenDisplay(scr
), panel
->gimage
, d
, WMColorGC(white
),
450 0, height
* index
, 30, height
, x
+ 5, y
);
452 WMDrawString(scr
, d
, black
, panel
->listFont
, x
+ 40, y
+ 1, text
, strlen(text
));
454 WMReleaseColor(white
);
455 WMReleaseColor(black
);
456 WMReleaseColor(gray
);
459 static void gradAddCallback(WMWidget
* w
, void *data
)
461 TexturePanel
*panel
= (TexturePanel
*) data
;
466 row
= WMGetListSelectedItemRow(panel
->gcolL
) + 1;
467 item
= WMInsertListItem(panel
->gcolL
, row
, "00,00,00");
468 rgb
= wmalloc(sizeof(RColor
));
469 memset(rgb
, 0, sizeof(RColor
));
470 item
->clientData
= rgb
;
472 WMSelectListItem(panel
->gcolL
, row
);
474 updateGradButtons(panel
);
476 sliderChangeCallback(panel
->ghueS
, panel
);
478 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
481 static void gradClickCallback(WMWidget
* w
, void *data
)
483 TexturePanel
*panel
= (TexturePanel
*) data
;
488 row
= WMGetListSelectedItemRow(w
);
492 item
= WMGetListItem(panel
->gcolL
, row
);
493 RRGBtoHSV((RColor
*) item
->clientData
, &hsv
);
495 WMSetSliderValue(panel
->ghueS
, hsv
.hue
);
496 WMSetSliderValue(panel
->gsatS
, hsv
.saturation
);
497 WMSetSliderValue(panel
->gvalS
, hsv
.value
);
499 sliderChangeCallback(panel
->ghueS
, panel
);
500 sliderChangeCallback(panel
->gsatS
, panel
);
503 static void gradDeleteCallback(WMWidget
* w
, void *data
)
505 TexturePanel
*panel
= (TexturePanel
*) data
;
509 row
= WMGetListSelectedItemRow(panel
->gcolL
);
513 item
= WMGetListItem(panel
->gcolL
, row
);
514 wfree(item
->clientData
);
516 WMRemoveListItem(panel
->gcolL
, row
);
518 WMSelectListItem(panel
->gcolL
, row
- 1);
520 updateGradButtons(panel
);
522 gradClickCallback(panel
->gcolL
, panel
);
524 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
527 /*************** Simple Gradient ***************/
529 static void colorWellObserver(void *self
, WMNotification
* n
)
531 updateSGradButtons(self
);
534 static void opaqChangeCallback(WMWidget
* w
, void *data
)
536 TexturePanel
*panel
= (TexturePanel
*) data
;
538 updateTGradImage(panel
);
541 /****************** Image ******************/
543 static void updateImage(TexturePanel
* panel
, char *path
)
545 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
551 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
555 message
= wstrconcat(_("Could not load the selected file: "),
556 (char *)RMessageForError(RErrorCode
));
558 WMRunAlertPanel(scr
, panel
->win
, _("Error"), message
, _("OK"), NULL
, NULL
);
561 WMSetButtonEnabled(panel
->okB
, False
);
567 WMSetButtonEnabled(panel
->okB
, True
);
570 RReleaseImage(panel
->image
);
571 panel
->image
= image
;
573 image
= panel
->image
;
576 if (WMGetPopUpButtonSelectedItem(panel
->typeP
) == TYPE_PIXMAP
) {
578 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
580 size
= WMGetPixmapSize(pixmap
);
581 WMSetLabelImage(panel
->imageL
, pixmap
);
582 WMResizeWidget(panel
->imageL
, size
.width
, size
.height
);
584 WMReleasePixmap(pixmap
);
587 updateTGradImage(panel
);
591 static void browseImageCallback(WMWidget
* w
, void *data
)
593 TexturePanel
*panel
= (TexturePanel
*) data
;
595 WMScreen
*scr
= WMWidgetScreen(w
);
596 static char *ipath
= NULL
;
598 opanel
= WMGetOpenPanel(scr
);
599 WMSetFilePanelCanChooseDirectories(opanel
, False
);
600 WMSetFilePanelCanChooseFiles(opanel
, True
);
603 ipath
= wstrdup(wgethomedir());
605 if (WMRunModalFilePanelForDirectory(opanel
, panel
->win
, ipath
, _("Open Image"), NULL
)) {
606 char *path
, *fullpath
;
609 tmp
= WMGetFilePanelFileName(opanel
);
617 path
= wstrdup(fullpath
);
619 tmp2
= strrchr(fullpath
, '/');
623 tmp
= wfindfileinarray(panel
->pathList
, tmp2
);
626 if (strcmp(fullpath
, tmp
) == 0) {
633 if (!RGetImageFileFormat(fullpath
)) {
634 WMRunAlertPanel(scr
, panel
->win
, _("Error"),
635 _("The selected file does not contain a supported image."),
636 _("OK"), NULL
, NULL
);
639 updateImage(panel
, fullpath
);
640 wfree(panel
->imageFile
);
641 panel
->imageFile
= path
;
643 WMSetTextFieldText(panel
->imageT
, path
);
648 static void buttonCallback(WMWidget
* w
, void *data
)
650 TexturePanel
*panel
= (TexturePanel
*) data
;
652 if (w
== panel
->okB
) {
653 (*panel
->okAction
) (panel
->okData
);
655 (*panel
->cancelAction
) (panel
->cancelData
);
659 static void changeTypeCallback(WMWidget
* w
, void *data
)
661 TexturePanel
*panel
= (TexturePanel
*) data
;
665 newType
= WMGetPopUpButtonSelectedItem(w
);
666 if (newType
== panel
->currentType
)
669 if (panel
->currentType
>= 0) {
670 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
671 if (panel
->sectionParts
[panel
->currentType
][i
] == NULL
)
673 WMUnmapWidget(panel
->sectionParts
[panel
->currentType
][i
]);
677 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
678 if (panel
->sectionParts
[newType
][i
] == NULL
)
680 WMMapWidget(panel
->sectionParts
[newType
][i
]);
682 panel
->currentType
= newType
;
686 updateSGradButtons(panel
);
687 WMSetButtonEnabled(panel
->okB
, True
);
690 updateGradButtons(panel
);
691 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
695 updateImage(panel
, NULL
);
696 WMSetButtonEnabled(panel
->okB
, panel
->image
!= NULL
);
699 WMSetButtonEnabled(panel
->okB
, True
);
705 *--------------------------------------------------------------------------
707 *--------------------------------------------------------------------------
709 void DestroyTexturePanel(TexturePanel
* panel
)
714 void ShowTexturePanel(TexturePanel
* panel
)
716 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(panel
->win
));
717 Screen
*scr
= DefaultScreenOfDisplay(dpy
);
719 WMSetWindowInitialPosition(panel
->win
,
720 (WidthOfScreen(scr
) - WMWidgetWidth(panel
->win
)) / 2,
721 (HeightOfScreen(scr
) - WMWidgetHeight(panel
->win
)) / 2);
722 WMMapWidget(panel
->win
);
725 void HideTexturePanel(TexturePanel
* panel
)
727 WMUnmapWidget(panel
->win
);
730 void SetTexturePanelOkAction(TexturePanel
* panel
, WMCallback
* action
, void *clientData
)
732 panel
->okAction
= action
;
733 panel
->okData
= clientData
;
736 void SetTexturePanelCancelAction(TexturePanel
* panel
, WMCallback
* action
, void *clientData
)
738 panel
->cancelAction
= action
;
739 panel
->cancelData
= clientData
;
742 void SetTexturePanelTexture(TexturePanel
* panel
, char *name
, WMPropList
* texture
)
744 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
752 WMSetTextFieldText(panel
->nameT
, name
);
757 p
= WMGetFromPLArray(texture
, 0);
761 type
= WMGetFromPLString(p
);
763 /*............................................... */
764 if (strcasecmp(type
, "solid") == 0) {
766 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SOLID
);
768 p
= WMGetFromPLArray(texture
, 1);
772 str
= WMGetFromPLString(p
);
774 color
= WMCreateNamedColor(scr
, str
, False
);
776 WMSetColorWellColor(panel
->defcW
, color
);
778 WMReleaseColor(color
);
779 /*............................................... */
780 } else if (strcasecmp(type
, "hgradient") == 0
781 || strcasecmp(type
, "vgradient") == 0 || strcasecmp(type
, "dgradient") == 0) {
783 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SGRADIENT
);
785 p
= WMGetFromPLArray(texture
, 1);
789 str
= WMGetFromPLString(p
);
791 color
= WMCreateNamedColor(scr
, str
, False
);
793 WMSetColorWellColor(panel
->tcol1W
, color
);
795 WMReleaseColor(color
);
797 p
= WMGetFromPLArray(texture
, 2);
801 str
= WMGetFromPLString(p
);
803 color
= WMCreateNamedColor(scr
, str
, False
);
805 WMSetColorWellColor(panel
->tcol2W
, color
);
807 WMReleaseColor(color
);
810 /*............................................... */
811 } else if (strcasecmp(type
, "thgradient") == 0
812 || strcasecmp(type
, "tvgradient") == 0 || strcasecmp(type
, "tdgradient") == 0) {
815 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_TGRADIENT
);
819 WMSetTextFieldText(panel
->imageT
, WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
820 if (panel
->imageFile
)
821 wfree(panel
->imageFile
);
822 panel
->imageFile
= wstrdup(WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
825 sscanf(WMGetFromPLString(WMGetFromPLArray(texture
, 2)), "%i", &i
);
826 WMSetSliderValue(panel
->topaS
, i
);
828 p
= WMGetFromPLArray(texture
, 3);
832 str
= WMGetFromPLString(p
);
834 color
= WMCreateNamedColor(scr
, str
, False
);
836 WMSetColorWellColor(panel
->tcol1W
, color
);
838 WMReleaseColor(color
);
840 p
= WMGetFromPLArray(texture
, 4);
844 str
= WMGetFromPLString(p
);
846 color
= WMCreateNamedColor(scr
, str
, False
);
848 WMSetColorWellColor(panel
->tcol2W
, color
);
850 WMReleaseColor(color
);
852 WMSetTextFieldText(panel
->imageT
, WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
854 if (panel
->imageFile
)
855 wfree(panel
->imageFile
);
856 if ((panel
->imageFile
= wfindfileinarray(panel
->pathList
,
857 WMGetFromPLString(WMGetFromPLArray(texture
, 1)))) !=
860 panel
->image
= RLoadImage(WMScreenRContext(scr
), panel
->imageFile
, 0);
861 updateTGradImage(panel
);
863 updateSGradButtons(panel
);
865 wwarning(_("could not load file '%s': %s"), panel
->imageFile
,
866 RMessageForError(RErrorCode
));
868 /*............................................... */
869 } else if (strcasecmp(type
, "mhgradient") == 0
870 || strcasecmp(type
, "mvgradient") == 0 || strcasecmp(type
, "mdgradient") == 0) {
873 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
874 item
= WMGetListItem(panel
->gcolL
, i
);
875 wfree(item
->clientData
);
877 WMClearList(panel
->gcolL
);
879 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_GRADIENT
);
881 p
= WMGetFromPLArray(texture
, 1);
885 str
= WMGetFromPLString(p
);
887 color
= WMCreateNamedColor(scr
, str
, False
);
889 WMSetColorWellColor(panel
->defcW
, color
);
891 WMReleaseColor(color
);
893 for (i
= 2; i
< WMGetPropListItemCount(texture
); i
++) {
897 p
= WMGetFromPLArray(texture
, i
);
901 str
= WMGetFromPLString(p
);
904 XParseColor(WMScreenDisplay(scr
), WMScreenRContext(scr
)->cmap
, str
, &xcolor
);
906 rgb
= wmalloc(sizeof(RColor
));
907 rgb
->red
= xcolor
.red
>> 8;
908 rgb
->green
= xcolor
.green
>> 8;
909 rgb
->blue
= xcolor
.blue
>> 8;
910 sprintf(buffer
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
912 item
= WMAddListItem(panel
->gcolL
, buffer
);
913 item
->clientData
= rgb
;
916 sliderChangeCallback(panel
->ghueS
, panel
);
919 /*............................................... */
920 } else if (strcasecmp(type
, "cpixmap") == 0
921 || strcasecmp(type
, "spixmap") == 0
922 || strcasecmp(type
, "mpixmap") == 0 || strcasecmp(type
, "tpixmap") == 0) {
924 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_PIXMAP
);
926 switch (toupper(type
[0])) {
928 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_CENTER
);
931 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_SCALE
);
934 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_MAXIMIZE
);
938 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_TILE
);
942 WMSetTextFieldText(panel
->imageT
, WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
944 if (panel
->imageFile
)
945 wfree(panel
->imageFile
);
946 panel
->imageFile
= wfindfileinarray(panel
->pathList
,
947 WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
949 color
= WMCreateNamedColor(scr
, WMGetFromPLString(WMGetFromPLArray(texture
, 2)), False
);
950 WMSetColorWellColor(panel
->defcW
, color
);
951 WMReleaseColor(color
);
953 updateImage(panel
, panel
->imageFile
);
956 changeTypeCallback(panel
->typeP
, panel
);
959 updateGradButtons(panel
);
961 switch (toupper(gradient
)) {
963 WMPerformButtonClick(panel
->dirhB
);
966 WMPerformButtonClick(panel
->dirvB
);
970 WMPerformButtonClick(panel
->dirdB
);
978 str
= WMGetPropListDescription(texture
, False
);
979 wwarning(_("error creating texture %s"), str
);
984 char *GetTexturePanelTextureName(TexturePanel
* panel
)
986 return WMGetTextFieldText(panel
->nameT
);
990 WMPropList
*GetTexturePanelTexture(TexturePanel
* panel
)
992 WMPropList
*prop
= NULL
;
998 switch (WMGetPopUpButtonSelectedItem(panel
->typeP
)) {
1001 color
= WMGetColorWellColor(panel
->defcW
);
1002 str
= WMGetColorRGBDescription(color
);
1003 prop
= WMCreatePLArray(WMCreatePLString("solid"), WMCreatePLString(str
), NULL
);
1009 color
= WMGetColorWellColor(panel
->defcW
);
1010 str
= WMGetColorRGBDescription(color
);
1012 switch (WMGetPopUpButtonSelectedItem(panel
->arrP
)) {
1014 prop
= WMCreatePLArray(WMCreatePLString("spixmap"),
1015 WMCreatePLString(panel
->imageFile
), WMCreatePLString(str
), NULL
);
1017 case PTYPE_MAXIMIZE
:
1018 prop
= WMCreatePLArray(WMCreatePLString("mpixmap"),
1019 WMCreatePLString(panel
->imageFile
), WMCreatePLString(str
), NULL
);
1022 prop
= WMCreatePLArray(WMCreatePLString("cpixmap"),
1023 WMCreatePLString(panel
->imageFile
), WMCreatePLString(str
), NULL
);
1026 prop
= WMCreatePLArray(WMCreatePLString("tpixmap"),
1027 WMCreatePLString(panel
->imageFile
), WMCreatePLString(str
), NULL
);
1033 case TYPE_TGRADIENT
:
1034 color
= WMGetColorWellColor(panel
->tcol1W
);
1035 str
= WMGetColorRGBDescription(color
);
1037 color
= WMGetColorWellColor(panel
->tcol2W
);
1038 str2
= WMGetColorRGBDescription(color
);
1040 sprintf(buff
, "%i", WMGetSliderValue(panel
->topaS
));
1042 if (WMGetButtonSelected(panel
->dirdB
)) {
1043 prop
= WMCreatePLArray(WMCreatePLString("tdgradient"),
1044 WMCreatePLString(panel
->imageFile
),
1045 WMCreatePLString(buff
),
1046 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1047 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1048 prop
= WMCreatePLArray(WMCreatePLString("tvgradient"),
1049 WMCreatePLString(panel
->imageFile
),
1050 WMCreatePLString(buff
),
1051 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1053 prop
= WMCreatePLArray(WMCreatePLString("thgradient"),
1054 WMCreatePLString(panel
->imageFile
),
1055 WMCreatePLString(buff
),
1056 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1062 case TYPE_SGRADIENT
:
1063 color
= WMGetColorWellColor(panel
->tcol1W
);
1064 str
= WMGetColorRGBDescription(color
);
1066 color
= WMGetColorWellColor(panel
->tcol2W
);
1067 str2
= WMGetColorRGBDescription(color
);
1069 if (WMGetButtonSelected(panel
->dirdB
)) {
1070 prop
= WMCreatePLArray(WMCreatePLString("dgradient"),
1071 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1072 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1073 prop
= WMCreatePLArray(WMCreatePLString("vgradient"),
1074 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1076 prop
= WMCreatePLArray(WMCreatePLString("hgradient"),
1077 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1084 color
= WMGetColorWellColor(panel
->defcW
);
1085 str
= WMGetColorRGBDescription(color
);
1087 if (WMGetButtonSelected(panel
->dirdB
)) {
1088 prop
= WMCreatePLArray(WMCreatePLString("mdgradient"), WMCreatePLString(str
), NULL
);
1089 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1090 prop
= WMCreatePLArray(WMCreatePLString("mvgradient"), WMCreatePLString(str
), NULL
);
1092 prop
= WMCreatePLArray(WMCreatePLString("mhgradient"), WMCreatePLString(str
), NULL
);
1096 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
1100 item
= WMGetListItem(panel
->gcolL
, i
);
1102 rgb
= (RColor
*) item
->clientData
;
1104 sprintf(buff
, "#%02x%02x%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
1106 WMAddToPLArray(prop
, WMCreatePLString(buff
));
1114 void SetTexturePanelPixmapPath(TexturePanel
* panel
, WMPropList
* array
)
1116 panel
->pathList
= array
;
1119 TexturePanel
*CreateTexturePanel(WMWindow
* keyWindow
)
1120 /*CreateTexturePanel(WMScreen *scr)*/
1122 TexturePanel
*panel
;
1123 WMScreen
*scr
= WMWidgetScreen(keyWindow
);
1125 panel
= wmalloc(sizeof(TexturePanel
));
1126 memset(panel
, 0, sizeof(TexturePanel
));
1128 panel
->listFont
= WMSystemFontOfSize(scr
, 12);
1130 panel
->win
= WMCreatePanelWithStyleForWindow(keyWindow
, "texturePanel",
1131 WMTitledWindowMask
| WMClosableWindowMask
);
1133 panel->win = WMCreateWindowWithStyle(scr, "texturePanel",
1135 |WMClosableWindowMask);
1138 WMResizeWidget(panel
->win
, 325, 423);
1139 WMSetWindowTitle(panel
->win
, _("Texture Panel"));
1140 WMSetWindowCloseAction(panel
->win
, buttonCallback
, panel
);
1143 panel
->nameF
= WMCreateFrame(panel
->win
);
1144 WMResizeWidget(panel
->nameF
, 185, 50);
1145 WMMoveWidget(panel
->nameF
, 15, 10);
1146 WMSetFrameTitle(panel
->nameF
, _("Texture Name"));
1148 panel
->nameT
= WMCreateTextField(panel
->nameF
);
1149 WMResizeWidget(panel
->nameT
, 160, 20);
1150 WMMoveWidget(panel
->nameT
, 12, 18);
1152 WMMapSubwidgets(panel
->nameF
);
1155 panel
->typeP
= WMCreatePopUpButton(panel
->win
);
1156 WMResizeWidget(panel
->typeP
, 185, 20);
1157 WMMoveWidget(panel
->typeP
, 15, 65);
1158 WMAddPopUpButtonItem(panel
->typeP
, _("Solid Color"));
1159 WMAddPopUpButtonItem(panel
->typeP
, _("Gradient Texture"));
1160 WMAddPopUpButtonItem(panel
->typeP
, _("Simple Gradient Texture"));
1161 WMAddPopUpButtonItem(panel
->typeP
, _("Textured Gradient"));
1162 WMAddPopUpButtonItem(panel
->typeP
, _("Image Texture"));
1163 WMSetPopUpButtonSelectedItem(panel
->typeP
, 0);
1164 WMSetPopUpButtonAction(panel
->typeP
, changeTypeCallback
, panel
);
1167 panel
->defcF
= WMCreateFrame(panel
->win
);
1168 WMResizeWidget(panel
->defcF
, 100, 75);
1169 WMMoveWidget(panel
->defcF
, 210, 10);
1170 WMSetFrameTitle(panel
->defcF
, _("Default Color"));
1172 panel
->defcW
= WMCreateColorWell(panel
->defcF
);
1173 WMResizeWidget(panel
->defcW
, 60, 45);
1174 WMMoveWidget(panel
->defcW
, 20, 20);
1176 WMMapSubwidgets(panel
->defcF
);
1178 /****** Gradient ******/
1179 panel
->gcolF
= WMCreateFrame(panel
->win
);
1180 WMResizeWidget(panel
->gcolF
, 295, 205);
1181 WMMoveWidget(panel
->gcolF
, 15, 95);
1182 WMSetFrameTitle(panel
->gcolF
, _("Gradient Colors"));
1184 panel
->gcolL
= WMCreateList(panel
->gcolF
);
1185 WMResizeWidget(panel
->gcolL
, 130, 140);
1186 WMMoveWidget(panel
->gcolL
, 10, 25);
1187 WMHangData(panel
->gcolL
, panel
);
1188 WMSetListUserDrawProc(panel
->gcolL
, paintGradListItem
);
1189 WMSetListAction(panel
->gcolL
, gradClickCallback
, panel
);
1191 panel
->gcolaB
= WMCreateCommandButton(panel
->gcolF
);
1192 WMResizeWidget(panel
->gcolaB
, 64, 24);
1193 WMMoveWidget(panel
->gcolaB
, 10, 170);
1194 WMSetButtonText(panel
->gcolaB
, _("Add"));
1195 WMSetButtonAction(panel
->gcolaB
, gradAddCallback
, panel
);
1197 panel
->gcoldB
= WMCreateCommandButton(panel
->gcolF
);
1198 WMResizeWidget(panel
->gcoldB
, 64, 24);
1199 WMMoveWidget(panel
->gcoldB
, 75, 170);
1200 WMSetButtonText(panel
->gcoldB
, _("Delete"));
1201 WMSetButtonAction(panel
->gcoldB
, gradDeleteCallback
, panel
);
1204 panel
->gbriS
= WMCreateSlider(panel
->gcolF
);
1205 WMResizeWidget(panel
->gbriS
, 130, 16);
1206 WMMoveWidget(panel
->gbriS
, 150, 25);
1207 WMSetSliderKnobThickness(panel
->gbriS
, 8);
1208 WMSetSliderMaxValue(panel
->gbriS
, 100);
1209 WMSetSliderAction(panel
->gbriS
, sliderChangeCallback
, panel
);
1214 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1215 color
= WMDarkGrayColor(scr
);
1216 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
), WMColorGC(color
), 0, 0, 130, 16);
1217 WMReleaseColor(color
);
1218 color
= WMWhiteColor(color
);
1219 WMDrawString(scr
, WMGetPixmapXID(pixmap
), color
,
1220 panel
->listFont
, 2, (16 - WMFontHeight(panel
->listFont
)) / 2 - 1, "Brightness", 10);
1221 WMSetSliderImage(panel
->gbriS
, pixmap
);
1222 WMReleasePixmap(pixmap
);
1225 panel
->gconS
= WMCreateSlider(panel
->gcolF
);
1226 WMResizeWidget(panel
->gconS
, 130, 16);
1227 WMMoveWidget(panel
->gconS
, 150, 50);
1228 WMSetSliderKnobThickness(panel
->gconS
, 8);
1229 WMSetSliderMaxValue(panel
->gconS
, 100);
1230 WMSetSliderAction(panel
->gconS
, sliderChangeCallback
, panel
);
1235 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1236 color
= WMDarkGrayColor(scr
);
1237 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
), WMColorGC(color
), 0, 0, 130, 16);
1238 WMReleaseColor(color
);
1239 color
= WMWhiteColor(scr
);
1240 WMDrawString(scr
, WMGetPixmapXID(pixmap
), color
,
1241 panel
->listFont
, 2, (16 - WMFontHeight(panel
->listFont
)) / 2 - 1, "Contrast", 8);
1242 WMSetSliderImage(panel
->gconS
, pixmap
);
1243 WMReleasePixmap(pixmap
);
1246 panel
->ghueS
= WMCreateSlider(panel
->gcolF
);
1247 WMResizeWidget(panel
->ghueS
, 130, 16);
1248 WMMoveWidget(panel
->ghueS
, 150, 100);
1249 WMSetSliderKnobThickness(panel
->ghueS
, 8);
1250 WMSetSliderMaxValue(panel
->ghueS
, 359);
1251 WMSetSliderAction(panel
->ghueS
, sliderChangeCallback
, panel
);
1253 panel
->gsatS
= WMCreateSlider(panel
->gcolF
);
1254 WMResizeWidget(panel
->gsatS
, 130, 16);
1255 WMMoveWidget(panel
->gsatS
, 150, 125);
1256 WMSetSliderKnobThickness(panel
->gsatS
, 8);
1257 WMSetSliderMaxValue(panel
->gsatS
, 255);
1258 WMSetSliderAction(panel
->gsatS
, sliderChangeCallback
, panel
);
1260 panel
->gvalS
= WMCreateSlider(panel
->gcolF
);
1261 WMResizeWidget(panel
->gvalS
, 130, 16);
1262 WMMoveWidget(panel
->gvalS
, 150, 150);
1263 WMSetSliderKnobThickness(panel
->gvalS
, 8);
1264 WMSetSliderMaxValue(panel
->gvalS
, 255);
1265 WMSetSliderAction(panel
->gvalS
, sliderChangeCallback
, panel
);
1267 WMMapSubwidgets(panel
->gcolF
);
1270 panel
->dirF
= WMCreateFrame(panel
->win
);
1271 WMSetFrameTitle(panel
->dirF
, _("Direction"));
1272 WMResizeWidget(panel
->dirF
, 295, 75);
1273 WMMoveWidget(panel
->dirF
, 15, 305);
1275 panel
->dirvB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1276 WMSetButtonImagePosition(panel
->dirvB
, WIPImageOnly
);
1277 WMResizeWidget(panel
->dirvB
, 90, 40);
1278 WMMoveWidget(panel
->dirvB
, 10, 20);
1280 panel
->dirhB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1281 WMSetButtonImagePosition(panel
->dirhB
, WIPImageOnly
);
1282 WMResizeWidget(panel
->dirhB
, 90, 40);
1283 WMMoveWidget(panel
->dirhB
, 102, 20);
1285 panel
->dirdB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1286 WMSetButtonImagePosition(panel
->dirdB
, WIPImageOnly
);
1287 WMResizeWidget(panel
->dirdB
, 90, 40);
1288 WMMoveWidget(panel
->dirdB
, 194, 20);
1290 WMGroupButtons(panel
->dirvB
, panel
->dirhB
);
1291 WMGroupButtons(panel
->dirvB
, panel
->dirdB
);
1293 WMMapSubwidgets(panel
->dirF
);
1295 /****************** Textured Gradient ******************/
1296 panel
->tcolF
= WMCreateFrame(panel
->win
);
1297 WMResizeWidget(panel
->tcolF
, 100, 135);
1298 WMMoveWidget(panel
->tcolF
, 210, 10);
1299 WMSetFrameTitle(panel
->tcolF
, _("Gradient"));
1301 panel
->tcol1W
= WMCreateColorWell(panel
->tcolF
);
1302 WMResizeWidget(panel
->tcol1W
, 60, 45);
1303 WMMoveWidget(panel
->tcol1W
, 20, 25);
1304 WMAddNotificationObserver(colorWellObserver
, panel
, WMColorWellDidChangeNotification
, panel
->tcol1W
);
1306 panel
->tcol2W
= WMCreateColorWell(panel
->tcolF
);
1307 WMResizeWidget(panel
->tcol2W
, 60, 45);
1308 WMMoveWidget(panel
->tcol2W
, 20, 75);
1309 WMAddNotificationObserver(colorWellObserver
, panel
, WMColorWellDidChangeNotification
, panel
->tcol2W
);
1312 panel
->topaF
= WMCreateFrame(panel
->win
);
1313 WMResizeWidget(panel
->topaF
, 185, 50);
1314 WMMoveWidget(panel
->topaF
, 15, 95);
1315 WMSetFrameTitle(panel
->topaF
, _("Gradient Opacity"));
1317 panel
->topaS
= WMCreateSlider(panel
->topaF
);
1318 WMResizeWidget(panel
->topaS
, 155, 18);
1319 WMMoveWidget(panel
->topaS
, 15, 20);
1320 WMSetSliderMaxValue(panel
->topaS
, 255);
1321 WMSetSliderValue(panel
->topaS
, 200);
1322 WMSetSliderContinuous(panel
->topaS
, False
);
1323 WMSetSliderAction(panel
->topaS
, opaqChangeCallback
, panel
);
1325 WMMapSubwidgets(panel
->topaF
);
1332 pixmap
= WMCreatePixmap(scr
, 155, 18, WMScreenDepth(scr
), False
);
1333 p
= WMGetPixmapXID(pixmap
);
1335 color
= WMDarkGrayColor(scr
);
1336 XFillRectangle(WMScreenDisplay(scr
), p
, WMColorGC(color
), 0, 0, 155, 18);
1337 WMReleaseColor(color
);
1339 color
= WMWhiteColor(scr
);
1340 WMDrawString(scr
, p
, color
, panel
->listFont
, 2, 1, "0%", 2);
1341 WMDrawString(scr
, p
, color
, panel
->listFont
,
1342 153 - WMWidthOfString(panel
->listFont
, "100%", 4), 1, "100%", 4);
1343 WMReleaseColor(color
);
1345 WMSetSliderImage(panel
->topaS
, pixmap
);
1346 WMReleasePixmap(pixmap
);
1349 WMMapSubwidgets(panel
->tcolF
);
1351 /****************** Image ******************/
1352 panel
->imageF
= WMCreateFrame(panel
->win
);
1353 WMResizeWidget(panel
->imageF
, 295, 150);
1354 WMMoveWidget(panel
->imageF
, 15, 150);
1355 WMSetFrameTitle(panel
->imageF
, _("Image"));
1357 panel
->imageL
= WMCreateLabel(panel
->imageF
);
1358 WMSetLabelImagePosition(panel
->imageL
, WIPImageOnly
);
1360 panel
->imageT
= WMCreateTextField(panel
->imageF
);
1361 WMResizeWidget(panel
->imageT
, 90, 20);
1362 WMMoveWidget(panel
->imageT
, 190, 25);
1364 panel
->imageV
= WMCreateScrollView(panel
->imageF
);
1365 WMResizeWidget(panel
->imageV
, 165, 115);
1366 WMMoveWidget(panel
->imageV
, 15, 20);
1367 WMSetScrollViewRelief(panel
->imageV
, WRSunken
);
1368 WMSetScrollViewHasHorizontalScroller(panel
->imageV
, True
);
1369 WMSetScrollViewHasVerticalScroller(panel
->imageV
, True
);
1370 WMSetScrollViewContentView(panel
->imageV
, WMWidgetView(panel
->imageL
));
1372 panel
->browB
= WMCreateCommandButton(panel
->imageF
);
1373 WMResizeWidget(panel
->browB
, 90, 24);
1374 WMMoveWidget(panel
->browB
, 190, 50);
1375 WMSetButtonText(panel
->browB
, _("Browse..."));
1376 WMSetButtonAction(panel
->browB
, browseImageCallback
, panel
);
1378 /* panel->dispB = WMCreateCommandButton(panel->imageF);
1379 WMResizeWidget(panel->dispB, 90, 24);
1380 WMMoveWidget(panel->dispB, 190, 80);
1381 WMSetButtonText(panel->dispB, _("Show"));
1384 panel
->arrP
= WMCreatePopUpButton(panel
->imageF
);
1385 WMResizeWidget(panel
->arrP
, 90, 20);
1386 WMMoveWidget(panel
->arrP
, 190, 120);
1387 WMAddPopUpButtonItem(panel
->arrP
, _("Tile"));
1388 WMAddPopUpButtonItem(panel
->arrP
, _("Scale"));
1389 WMAddPopUpButtonItem(panel
->arrP
, _("Center"));
1390 WMAddPopUpButtonItem(panel
->arrP
, _("Maximize"));
1391 WMSetPopUpButtonSelectedItem(panel
->arrP
, 0);
1393 WMMapSubwidgets(panel
->imageF
);
1397 panel
->okB
= WMCreateCommandButton(panel
->win
);
1398 WMResizeWidget(panel
->okB
, 84, 24);
1399 WMMoveWidget(panel
->okB
, 225, 390);
1400 WMSetButtonText(panel
->okB
, _("OK"));
1401 WMSetButtonAction(panel
->okB
, buttonCallback
, panel
);
1403 panel
->cancelB
= WMCreateCommandButton(panel
->win
);
1404 WMResizeWidget(panel
->cancelB
, 84, 24);
1405 WMMoveWidget(panel
->cancelB
, 130, 390);
1406 WMSetButtonText(panel
->cancelB
, _("Cancel"));
1407 WMSetButtonAction(panel
->cancelB
, buttonCallback
, panel
);
1409 WMMapWidget(panel
->nameF
);
1410 WMMapWidget(panel
->typeP
);
1411 WMMapWidget(panel
->okB
);
1412 WMMapWidget(panel
->cancelB
);
1414 WMUnmapWidget(panel
->arrP
);
1416 WMRealizeWidget(panel
->win
);
1418 panel
->currentType
= -1;
1420 panel
->sectionParts
[TYPE_SOLID
][0] = panel
->defcF
;
1422 panel
->sectionParts
[TYPE_GRADIENT
][0] = panel
->defcF
;
1423 panel
->sectionParts
[TYPE_GRADIENT
][1] = panel
->gcolF
;
1424 panel
->sectionParts
[TYPE_GRADIENT
][2] = panel
->dirF
;
1426 panel
->sectionParts
[TYPE_SGRADIENT
][0] = panel
->tcolF
;
1427 panel
->sectionParts
[TYPE_SGRADIENT
][1] = panel
->dirF
;
1429 panel
->sectionParts
[TYPE_TGRADIENT
][0] = panel
->tcolF
;
1430 panel
->sectionParts
[TYPE_TGRADIENT
][1] = panel
->dirF
;
1431 panel
->sectionParts
[TYPE_TGRADIENT
][2] = panel
->imageF
;
1432 panel
->sectionParts
[TYPE_TGRADIENT
][3] = panel
->topaF
;
1433 panel
->sectionParts
[TYPE_TGRADIENT
][4] = panel
->arrP
;
1435 panel
->sectionParts
[TYPE_PIXMAP
][0] = panel
->defcF
;
1436 panel
->sectionParts
[TYPE_PIXMAP
][1] = panel
->imageF
;
1437 panel
->sectionParts
[TYPE_PIXMAP
][2] = panel
->arrP
;
1439 /* setup for first time */
1441 changeTypeCallback(panel
->typeP
, panel
);
1443 sliderChangeCallback(panel
->ghueS
, panel
);
1444 sliderChangeCallback(panel
->gsatS
, panel
);
1450 *--------------------------------------------------------------------------
1452 *--------------------------------------------------------------------------
1457 char *ProgName
= "test";
1459 void testOKButton(WMWidget
* self
, void *data
)
1467 TexturePanel
*panel
= (TexturePanel
*) data
;
1468 /* test = GetTexturePanelTextureString(panel); */
1472 dpy
= WMScreenDisplay(WMWidgetScreen(panel
->okB
));
1473 win
= XCreateSimpleWindow(dpy
, DefaultRootWindow(dpy
), 10, 10, 250, 250, 0, 0, 0);
1474 XMapRaised(dpy
, win
);
1477 /* image = RenderTexturePanelTexture(panel, 250, 250); */
1479 RConvertImage(WMScreenRContext(WMWidgetScreen(panel
->okB
)), image
, &pix
);
1481 XCopyArea(dpy
, pix
, win
, (WMScreenRContext(WMWidgetScreen(panel
->okB
)))->copy_gc
, 0, 0, image
->width
,
1482 image
->height
, 0, 0);
1488 void testCancelButton(WMWidget
* self
, void *data
)
1490 wwarning("Exiting test....");
1499 int main(int argc
, char **argv
)
1501 TexturePanel
*panel
;
1503 Display
*dpy
= XOpenDisplay("");
1508 WMInitializeApplication("Test", &argc
, argv
);
1511 wfatal("could not open display");
1515 scr
= WMCreateSimpleApplicationScreen(dpy
);
1517 panel
= CreateTexturePanel(scr
);
1519 SetTexturePanelOkAction(panel
, (WMAction
*) testOKButton
, panel
);
1520 SetTexturePanelCancelAction(panel
, (WMAction
*) testCancelButton
, panel
);
1522 SetTexturePanelTexture(panel
, "pinky",
1523 WMCreatePropListFromDescription("(mdgradient, pink, red, blue, yellow)"));
1525 ShowTexturePanel(panel
);
1527 WMScreenMainLoop(scr
);