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 memset(rgb
, 0, sizeof(RColor
));
467 item
->clientData
= rgb
;
469 WMSelectListItem(panel
->gcolL
, row
);
471 updateGradButtons(panel
);
473 sliderChangeCallback(panel
->ghueS
, panel
);
475 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
478 static void gradClickCallback(WMWidget
* w
, void *data
)
480 TexturePanel
*panel
= (TexturePanel
*) data
;
485 row
= WMGetListSelectedItemRow(w
);
489 item
= WMGetListItem(panel
->gcolL
, row
);
490 RRGBtoHSV((RColor
*) item
->clientData
, &hsv
);
492 WMSetSliderValue(panel
->ghueS
, hsv
.hue
);
493 WMSetSliderValue(panel
->gsatS
, hsv
.saturation
);
494 WMSetSliderValue(panel
->gvalS
, hsv
.value
);
496 sliderChangeCallback(panel
->ghueS
, panel
);
497 sliderChangeCallback(panel
->gsatS
, panel
);
500 static void gradDeleteCallback(WMWidget
* w
, void *data
)
502 TexturePanel
*panel
= (TexturePanel
*) data
;
506 row
= WMGetListSelectedItemRow(panel
->gcolL
);
510 item
= WMGetListItem(panel
->gcolL
, row
);
511 wfree(item
->clientData
);
513 WMRemoveListItem(panel
->gcolL
, row
);
515 WMSelectListItem(panel
->gcolL
, row
- 1);
517 updateGradButtons(panel
);
519 gradClickCallback(panel
->gcolL
, panel
);
521 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
524 /*************** Simple Gradient ***************/
526 static void colorWellObserver(void *self
, WMNotification
* n
)
528 updateSGradButtons(self
);
531 static void opaqChangeCallback(WMWidget
* w
, void *data
)
533 TexturePanel
*panel
= (TexturePanel
*) data
;
535 updateTGradImage(panel
);
538 /****************** Image ******************/
540 static void updateImage(TexturePanel
* panel
, char *path
)
542 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
548 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
552 message
= wstrconcat(_("Could not load the selected file: "),
553 (char *)RMessageForError(RErrorCode
));
555 WMRunAlertPanel(scr
, panel
->win
, _("Error"), message
, _("OK"), NULL
, NULL
);
558 WMSetButtonEnabled(panel
->okB
, False
);
564 WMSetButtonEnabled(panel
->okB
, True
);
567 RReleaseImage(panel
->image
);
568 panel
->image
= image
;
570 image
= panel
->image
;
573 if (WMGetPopUpButtonSelectedItem(panel
->typeP
) == TYPE_PIXMAP
) {
575 pixmap
= WMCreatePixmapFromRImage(scr
, image
, 128);
577 size
= WMGetPixmapSize(pixmap
);
578 WMSetLabelImage(panel
->imageL
, pixmap
);
579 WMResizeWidget(panel
->imageL
, size
.width
, size
.height
);
581 WMReleasePixmap(pixmap
);
584 updateTGradImage(panel
);
588 static void browseImageCallback(WMWidget
* w
, void *data
)
590 TexturePanel
*panel
= (TexturePanel
*) data
;
592 WMScreen
*scr
= WMWidgetScreen(w
);
593 static char *ipath
= NULL
;
595 opanel
= WMGetOpenPanel(scr
);
596 WMSetFilePanelCanChooseDirectories(opanel
, False
);
597 WMSetFilePanelCanChooseFiles(opanel
, True
);
600 ipath
= wstrdup(wgethomedir());
602 if (WMRunModalFilePanelForDirectory(opanel
, panel
->win
, ipath
, _("Open Image"), NULL
)) {
603 char *path
, *fullpath
;
606 tmp
= WMGetFilePanelFileName(opanel
);
614 path
= wstrdup(fullpath
);
616 tmp2
= strrchr(fullpath
, '/');
620 tmp
= wfindfileinarray(panel
->pathList
, tmp2
);
623 if (strcmp(fullpath
, tmp
) == 0) {
630 if (!RGetImageFileFormat(fullpath
)) {
631 WMRunAlertPanel(scr
, panel
->win
, _("Error"),
632 _("The selected file does not contain a supported image."),
633 _("OK"), NULL
, NULL
);
636 updateImage(panel
, fullpath
);
637 wfree(panel
->imageFile
);
638 panel
->imageFile
= path
;
640 WMSetTextFieldText(panel
->imageT
, path
);
645 static void buttonCallback(WMWidget
* w
, void *data
)
647 TexturePanel
*panel
= (TexturePanel
*) data
;
649 if (w
== panel
->okB
) {
650 (*panel
->okAction
) (panel
->okData
);
652 (*panel
->cancelAction
) (panel
->cancelData
);
656 static void changeTypeCallback(WMWidget
* w
, void *data
)
658 TexturePanel
*panel
= (TexturePanel
*) data
;
662 newType
= WMGetPopUpButtonSelectedItem(w
);
663 if (newType
== panel
->currentType
)
666 if (panel
->currentType
>= 0) {
667 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
668 if (panel
->sectionParts
[panel
->currentType
][i
] == NULL
)
670 WMUnmapWidget(panel
->sectionParts
[panel
->currentType
][i
]);
674 for (i
= 0; i
< MAX_SECTION_PARTS
; i
++) {
675 if (panel
->sectionParts
[newType
][i
] == NULL
)
677 WMMapWidget(panel
->sectionParts
[newType
][i
]);
679 panel
->currentType
= newType
;
683 updateSGradButtons(panel
);
684 WMSetButtonEnabled(panel
->okB
, True
);
687 updateGradButtons(panel
);
688 WMSetButtonEnabled(panel
->okB
, WMGetListNumberOfRows(panel
->gcolL
) > 1);
692 updateImage(panel
, NULL
);
693 WMSetButtonEnabled(panel
->okB
, panel
->image
!= NULL
);
696 WMSetButtonEnabled(panel
->okB
, True
);
702 *--------------------------------------------------------------------------
704 *--------------------------------------------------------------------------
706 void DestroyTexturePanel(TexturePanel
* panel
)
711 void ShowTexturePanel(TexturePanel
* panel
)
713 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(panel
->win
));
714 Screen
*scr
= DefaultScreenOfDisplay(dpy
);
716 WMSetWindowInitialPosition(panel
->win
,
717 (WidthOfScreen(scr
) - WMWidgetWidth(panel
->win
)) / 2,
718 (HeightOfScreen(scr
) - WMWidgetHeight(panel
->win
)) / 2);
719 WMMapWidget(panel
->win
);
722 void HideTexturePanel(TexturePanel
* panel
)
724 WMUnmapWidget(panel
->win
);
727 void SetTexturePanelOkAction(TexturePanel
* panel
, WMCallback
* action
, void *clientData
)
729 panel
->okAction
= action
;
730 panel
->okData
= clientData
;
733 void SetTexturePanelCancelAction(TexturePanel
* panel
, WMCallback
* action
, void *clientData
)
735 panel
->cancelAction
= action
;
736 panel
->cancelData
= clientData
;
739 void SetTexturePanelTexture(TexturePanel
* panel
, char *name
, WMPropList
* texture
)
741 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
749 WMSetTextFieldText(panel
->nameT
, name
);
754 p
= WMGetFromPLArray(texture
, 0);
758 type
= WMGetFromPLString(p
);
760 /*............................................... */
761 if (strcasecmp(type
, "solid") == 0) {
763 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SOLID
);
765 p
= WMGetFromPLArray(texture
, 1);
769 str
= WMGetFromPLString(p
);
771 color
= WMCreateNamedColor(scr
, str
, False
);
773 WMSetColorWellColor(panel
->defcW
, color
);
775 WMReleaseColor(color
);
776 /*............................................... */
777 } else if (strcasecmp(type
, "hgradient") == 0
778 || strcasecmp(type
, "vgradient") == 0 || strcasecmp(type
, "dgradient") == 0) {
780 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_SGRADIENT
);
782 p
= WMGetFromPLArray(texture
, 1);
786 str
= WMGetFromPLString(p
);
788 color
= WMCreateNamedColor(scr
, str
, False
);
790 WMSetColorWellColor(panel
->tcol1W
, color
);
792 WMReleaseColor(color
);
794 p
= WMGetFromPLArray(texture
, 2);
798 str
= WMGetFromPLString(p
);
800 color
= WMCreateNamedColor(scr
, str
, False
);
802 WMSetColorWellColor(panel
->tcol2W
, color
);
804 WMReleaseColor(color
);
807 /*............................................... */
808 } else if (strcasecmp(type
, "thgradient") == 0
809 || strcasecmp(type
, "tvgradient") == 0 || strcasecmp(type
, "tdgradient") == 0) {
812 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_TGRADIENT
);
816 WMSetTextFieldText(panel
->imageT
, WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
817 if (panel
->imageFile
)
818 wfree(panel
->imageFile
);
819 panel
->imageFile
= wstrdup(WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
822 sscanf(WMGetFromPLString(WMGetFromPLArray(texture
, 2)), "%i", &i
);
823 WMSetSliderValue(panel
->topaS
, i
);
825 p
= WMGetFromPLArray(texture
, 3);
829 str
= WMGetFromPLString(p
);
831 color
= WMCreateNamedColor(scr
, str
, False
);
833 WMSetColorWellColor(panel
->tcol1W
, color
);
835 WMReleaseColor(color
);
837 p
= WMGetFromPLArray(texture
, 4);
841 str
= WMGetFromPLString(p
);
843 color
= WMCreateNamedColor(scr
, str
, False
);
845 WMSetColorWellColor(panel
->tcol2W
, color
);
847 WMReleaseColor(color
);
849 WMSetTextFieldText(panel
->imageT
, WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
851 if (panel
->imageFile
)
852 wfree(panel
->imageFile
);
853 if ((panel
->imageFile
= wfindfileinarray(panel
->pathList
,
854 WMGetFromPLString(WMGetFromPLArray(texture
, 1)))) !=
857 panel
->image
= RLoadImage(WMScreenRContext(scr
), panel
->imageFile
, 0);
858 updateTGradImage(panel
);
860 updateSGradButtons(panel
);
862 wwarning(_("could not load file '%s': %s"), panel
->imageFile
,
863 RMessageForError(RErrorCode
));
865 /*............................................... */
866 } else if (strcasecmp(type
, "mhgradient") == 0
867 || strcasecmp(type
, "mvgradient") == 0 || strcasecmp(type
, "mdgradient") == 0) {
870 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
871 item
= WMGetListItem(panel
->gcolL
, i
);
872 wfree(item
->clientData
);
874 WMClearList(panel
->gcolL
);
876 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_GRADIENT
);
878 p
= WMGetFromPLArray(texture
, 1);
882 str
= WMGetFromPLString(p
);
884 color
= WMCreateNamedColor(scr
, str
, False
);
886 WMSetColorWellColor(panel
->defcW
, color
);
888 WMReleaseColor(color
);
890 for (i
= 2; i
< WMGetPropListItemCount(texture
); i
++) {
894 p
= WMGetFromPLArray(texture
, i
);
898 str
= WMGetFromPLString(p
);
901 XParseColor(WMScreenDisplay(scr
), WMScreenRContext(scr
)->cmap
, str
, &xcolor
);
903 rgb
= wmalloc(sizeof(RColor
));
904 rgb
->red
= xcolor
.red
>> 8;
905 rgb
->green
= xcolor
.green
>> 8;
906 rgb
->blue
= xcolor
.blue
>> 8;
907 sprintf(buffer
, "%02x,%02x,%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
909 item
= WMAddListItem(panel
->gcolL
, buffer
);
910 item
->clientData
= rgb
;
913 sliderChangeCallback(panel
->ghueS
, panel
);
916 /*............................................... */
917 } else if (strcasecmp(type
, "cpixmap") == 0
918 || strcasecmp(type
, "spixmap") == 0
919 || strcasecmp(type
, "mpixmap") == 0 || strcasecmp(type
, "tpixmap") == 0) {
921 WMSetPopUpButtonSelectedItem(panel
->typeP
, TYPE_PIXMAP
);
923 switch (toupper(type
[0])) {
925 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_CENTER
);
928 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_SCALE
);
931 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_MAXIMIZE
);
935 WMSetPopUpButtonSelectedItem(panel
->arrP
, PTYPE_TILE
);
939 WMSetTextFieldText(panel
->imageT
, WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
941 if (panel
->imageFile
)
942 wfree(panel
->imageFile
);
943 panel
->imageFile
= wfindfileinarray(panel
->pathList
,
944 WMGetFromPLString(WMGetFromPLArray(texture
, 1)));
946 color
= WMCreateNamedColor(scr
, WMGetFromPLString(WMGetFromPLArray(texture
, 2)), False
);
947 WMSetColorWellColor(panel
->defcW
, color
);
948 WMReleaseColor(color
);
950 updateImage(panel
, panel
->imageFile
);
953 changeTypeCallback(panel
->typeP
, panel
);
956 updateGradButtons(panel
);
958 switch (toupper(gradient
)) {
960 WMPerformButtonClick(panel
->dirhB
);
963 WMPerformButtonClick(panel
->dirvB
);
967 WMPerformButtonClick(panel
->dirdB
);
975 str
= WMGetPropListDescription(texture
, False
);
976 wwarning(_("error creating texture %s"), str
);
981 char *GetTexturePanelTextureName(TexturePanel
* panel
)
983 return WMGetTextFieldText(panel
->nameT
);
987 WMPropList
*GetTexturePanelTexture(TexturePanel
* panel
)
989 WMPropList
*prop
= NULL
;
995 switch (WMGetPopUpButtonSelectedItem(panel
->typeP
)) {
998 color
= WMGetColorWellColor(panel
->defcW
);
999 str
= WMGetColorRGBDescription(color
);
1000 prop
= WMCreatePLArray(WMCreatePLString("solid"), WMCreatePLString(str
), NULL
);
1006 color
= WMGetColorWellColor(panel
->defcW
);
1007 str
= WMGetColorRGBDescription(color
);
1009 switch (WMGetPopUpButtonSelectedItem(panel
->arrP
)) {
1011 prop
= WMCreatePLArray(WMCreatePLString("spixmap"),
1012 WMCreatePLString(panel
->imageFile
), WMCreatePLString(str
), NULL
);
1014 case PTYPE_MAXIMIZE
:
1015 prop
= WMCreatePLArray(WMCreatePLString("mpixmap"),
1016 WMCreatePLString(panel
->imageFile
), WMCreatePLString(str
), NULL
);
1019 prop
= WMCreatePLArray(WMCreatePLString("cpixmap"),
1020 WMCreatePLString(panel
->imageFile
), WMCreatePLString(str
), NULL
);
1023 prop
= WMCreatePLArray(WMCreatePLString("tpixmap"),
1024 WMCreatePLString(panel
->imageFile
), WMCreatePLString(str
), NULL
);
1030 case TYPE_TGRADIENT
:
1031 color
= WMGetColorWellColor(panel
->tcol1W
);
1032 str
= WMGetColorRGBDescription(color
);
1034 color
= WMGetColorWellColor(panel
->tcol2W
);
1035 str2
= WMGetColorRGBDescription(color
);
1037 sprintf(buff
, "%i", WMGetSliderValue(panel
->topaS
));
1039 if (WMGetButtonSelected(panel
->dirdB
)) {
1040 prop
= WMCreatePLArray(WMCreatePLString("tdgradient"),
1041 WMCreatePLString(panel
->imageFile
),
1042 WMCreatePLString(buff
),
1043 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1044 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1045 prop
= WMCreatePLArray(WMCreatePLString("tvgradient"),
1046 WMCreatePLString(panel
->imageFile
),
1047 WMCreatePLString(buff
),
1048 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1050 prop
= WMCreatePLArray(WMCreatePLString("thgradient"),
1051 WMCreatePLString(panel
->imageFile
),
1052 WMCreatePLString(buff
),
1053 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1059 case TYPE_SGRADIENT
:
1060 color
= WMGetColorWellColor(panel
->tcol1W
);
1061 str
= WMGetColorRGBDescription(color
);
1063 color
= WMGetColorWellColor(panel
->tcol2W
);
1064 str2
= WMGetColorRGBDescription(color
);
1066 if (WMGetButtonSelected(panel
->dirdB
)) {
1067 prop
= WMCreatePLArray(WMCreatePLString("dgradient"),
1068 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1069 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1070 prop
= WMCreatePLArray(WMCreatePLString("vgradient"),
1071 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1073 prop
= WMCreatePLArray(WMCreatePLString("hgradient"),
1074 WMCreatePLString(str
), WMCreatePLString(str2
), NULL
);
1081 color
= WMGetColorWellColor(panel
->defcW
);
1082 str
= WMGetColorRGBDescription(color
);
1084 if (WMGetButtonSelected(panel
->dirdB
)) {
1085 prop
= WMCreatePLArray(WMCreatePLString("mdgradient"), WMCreatePLString(str
), NULL
);
1086 } else if (WMGetButtonSelected(panel
->dirvB
)) {
1087 prop
= WMCreatePLArray(WMCreatePLString("mvgradient"), WMCreatePLString(str
), NULL
);
1089 prop
= WMCreatePLArray(WMCreatePLString("mhgradient"), WMCreatePLString(str
), NULL
);
1093 for (i
= 0; i
< WMGetListNumberOfRows(panel
->gcolL
); i
++) {
1097 item
= WMGetListItem(panel
->gcolL
, i
);
1099 rgb
= (RColor
*) item
->clientData
;
1101 sprintf(buff
, "#%02x%02x%02x", rgb
->red
, rgb
->green
, rgb
->blue
);
1103 WMAddToPLArray(prop
, WMCreatePLString(buff
));
1111 void SetTexturePanelPixmapPath(TexturePanel
* panel
, WMPropList
* array
)
1113 panel
->pathList
= array
;
1116 TexturePanel
*CreateTexturePanel(WMWindow
* keyWindow
)
1117 /*CreateTexturePanel(WMScreen *scr)*/
1119 TexturePanel
*panel
;
1120 WMScreen
*scr
= WMWidgetScreen(keyWindow
);
1122 panel
= wmalloc(sizeof(TexturePanel
));
1123 memset(panel
, 0, sizeof(TexturePanel
));
1125 panel
->listFont
= WMSystemFontOfSize(scr
, 12);
1127 panel
->win
= WMCreatePanelWithStyleForWindow(keyWindow
, "texturePanel",
1128 WMTitledWindowMask
| WMClosableWindowMask
);
1130 panel->win = WMCreateWindowWithStyle(scr, "texturePanel",
1132 |WMClosableWindowMask);
1135 WMResizeWidget(panel
->win
, 325, 423);
1136 WMSetWindowTitle(panel
->win
, _("Texture Panel"));
1137 WMSetWindowCloseAction(panel
->win
, buttonCallback
, panel
);
1140 panel
->nameF
= WMCreateFrame(panel
->win
);
1141 WMResizeWidget(panel
->nameF
, 185, 50);
1142 WMMoveWidget(panel
->nameF
, 15, 10);
1143 WMSetFrameTitle(panel
->nameF
, _("Texture Name"));
1145 panel
->nameT
= WMCreateTextField(panel
->nameF
);
1146 WMResizeWidget(panel
->nameT
, 160, 20);
1147 WMMoveWidget(panel
->nameT
, 12, 18);
1149 WMMapSubwidgets(panel
->nameF
);
1152 panel
->typeP
= WMCreatePopUpButton(panel
->win
);
1153 WMResizeWidget(panel
->typeP
, 185, 20);
1154 WMMoveWidget(panel
->typeP
, 15, 65);
1155 WMAddPopUpButtonItem(panel
->typeP
, _("Solid Color"));
1156 WMAddPopUpButtonItem(panel
->typeP
, _("Gradient Texture"));
1157 WMAddPopUpButtonItem(panel
->typeP
, _("Simple Gradient Texture"));
1158 WMAddPopUpButtonItem(panel
->typeP
, _("Textured Gradient"));
1159 WMAddPopUpButtonItem(panel
->typeP
, _("Image Texture"));
1160 WMSetPopUpButtonSelectedItem(panel
->typeP
, 0);
1161 WMSetPopUpButtonAction(panel
->typeP
, changeTypeCallback
, panel
);
1164 panel
->defcF
= WMCreateFrame(panel
->win
);
1165 WMResizeWidget(panel
->defcF
, 100, 75);
1166 WMMoveWidget(panel
->defcF
, 210, 10);
1167 WMSetFrameTitle(panel
->defcF
, _("Default Color"));
1169 panel
->defcW
= WMCreateColorWell(panel
->defcF
);
1170 WMResizeWidget(panel
->defcW
, 60, 45);
1171 WMMoveWidget(panel
->defcW
, 20, 20);
1173 WMMapSubwidgets(panel
->defcF
);
1175 /****** Gradient ******/
1176 panel
->gcolF
= WMCreateFrame(panel
->win
);
1177 WMResizeWidget(panel
->gcolF
, 295, 205);
1178 WMMoveWidget(panel
->gcolF
, 15, 95);
1179 WMSetFrameTitle(panel
->gcolF
, _("Gradient Colors"));
1181 panel
->gcolL
= WMCreateList(panel
->gcolF
);
1182 WMResizeWidget(panel
->gcolL
, 130, 140);
1183 WMMoveWidget(panel
->gcolL
, 10, 25);
1184 WMHangData(panel
->gcolL
, panel
);
1185 WMSetListUserDrawProc(panel
->gcolL
, paintGradListItem
);
1186 WMSetListAction(panel
->gcolL
, gradClickCallback
, panel
);
1188 panel
->gcolaB
= WMCreateCommandButton(panel
->gcolF
);
1189 WMResizeWidget(panel
->gcolaB
, 64, 24);
1190 WMMoveWidget(panel
->gcolaB
, 10, 170);
1191 WMSetButtonText(panel
->gcolaB
, _("Add"));
1192 WMSetButtonAction(panel
->gcolaB
, gradAddCallback
, panel
);
1194 panel
->gcoldB
= WMCreateCommandButton(panel
->gcolF
);
1195 WMResizeWidget(panel
->gcoldB
, 64, 24);
1196 WMMoveWidget(panel
->gcoldB
, 75, 170);
1197 WMSetButtonText(panel
->gcoldB
, _("Delete"));
1198 WMSetButtonAction(panel
->gcoldB
, gradDeleteCallback
, panel
);
1201 panel
->gbriS
= WMCreateSlider(panel
->gcolF
);
1202 WMResizeWidget(panel
->gbriS
, 130, 16);
1203 WMMoveWidget(panel
->gbriS
, 150, 25);
1204 WMSetSliderKnobThickness(panel
->gbriS
, 8);
1205 WMSetSliderMaxValue(panel
->gbriS
, 100);
1206 WMSetSliderAction(panel
->gbriS
, sliderChangeCallback
, panel
);
1211 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1212 color
= WMDarkGrayColor(scr
);
1213 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
), WMColorGC(color
), 0, 0, 130, 16);
1214 WMReleaseColor(color
);
1215 color
= WMWhiteColor(color
);
1216 WMDrawString(scr
, WMGetPixmapXID(pixmap
), color
,
1217 panel
->listFont
, 2, (16 - WMFontHeight(panel
->listFont
)) / 2 - 1, "Brightness", 10);
1218 WMSetSliderImage(panel
->gbriS
, pixmap
);
1219 WMReleasePixmap(pixmap
);
1222 panel
->gconS
= WMCreateSlider(panel
->gcolF
);
1223 WMResizeWidget(panel
->gconS
, 130, 16);
1224 WMMoveWidget(panel
->gconS
, 150, 50);
1225 WMSetSliderKnobThickness(panel
->gconS
, 8);
1226 WMSetSliderMaxValue(panel
->gconS
, 100);
1227 WMSetSliderAction(panel
->gconS
, sliderChangeCallback
, panel
);
1232 pixmap
= WMCreatePixmap(scr
, 130, 16, WMScreenDepth(scr
), False
);
1233 color
= WMDarkGrayColor(scr
);
1234 XFillRectangle(WMScreenDisplay(scr
), WMGetPixmapXID(pixmap
), WMColorGC(color
), 0, 0, 130, 16);
1235 WMReleaseColor(color
);
1236 color
= WMWhiteColor(scr
);
1237 WMDrawString(scr
, WMGetPixmapXID(pixmap
), color
,
1238 panel
->listFont
, 2, (16 - WMFontHeight(panel
->listFont
)) / 2 - 1, "Contrast", 8);
1239 WMSetSliderImage(panel
->gconS
, pixmap
);
1240 WMReleasePixmap(pixmap
);
1243 panel
->ghueS
= WMCreateSlider(panel
->gcolF
);
1244 WMResizeWidget(panel
->ghueS
, 130, 16);
1245 WMMoveWidget(panel
->ghueS
, 150, 100);
1246 WMSetSliderKnobThickness(panel
->ghueS
, 8);
1247 WMSetSliderMaxValue(panel
->ghueS
, 359);
1248 WMSetSliderAction(panel
->ghueS
, sliderChangeCallback
, panel
);
1250 panel
->gsatS
= WMCreateSlider(panel
->gcolF
);
1251 WMResizeWidget(panel
->gsatS
, 130, 16);
1252 WMMoveWidget(panel
->gsatS
, 150, 125);
1253 WMSetSliderKnobThickness(panel
->gsatS
, 8);
1254 WMSetSliderMaxValue(panel
->gsatS
, 255);
1255 WMSetSliderAction(panel
->gsatS
, sliderChangeCallback
, panel
);
1257 panel
->gvalS
= WMCreateSlider(panel
->gcolF
);
1258 WMResizeWidget(panel
->gvalS
, 130, 16);
1259 WMMoveWidget(panel
->gvalS
, 150, 150);
1260 WMSetSliderKnobThickness(panel
->gvalS
, 8);
1261 WMSetSliderMaxValue(panel
->gvalS
, 255);
1262 WMSetSliderAction(panel
->gvalS
, sliderChangeCallback
, panel
);
1264 WMMapSubwidgets(panel
->gcolF
);
1267 panel
->dirF
= WMCreateFrame(panel
->win
);
1268 WMSetFrameTitle(panel
->dirF
, _("Direction"));
1269 WMResizeWidget(panel
->dirF
, 295, 75);
1270 WMMoveWidget(panel
->dirF
, 15, 305);
1272 panel
->dirvB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1273 WMSetButtonImagePosition(panel
->dirvB
, WIPImageOnly
);
1274 WMResizeWidget(panel
->dirvB
, 90, 40);
1275 WMMoveWidget(panel
->dirvB
, 10, 20);
1277 panel
->dirhB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1278 WMSetButtonImagePosition(panel
->dirhB
, WIPImageOnly
);
1279 WMResizeWidget(panel
->dirhB
, 90, 40);
1280 WMMoveWidget(panel
->dirhB
, 102, 20);
1282 panel
->dirdB
= WMCreateButton(panel
->dirF
, WBTOnOff
);
1283 WMSetButtonImagePosition(panel
->dirdB
, WIPImageOnly
);
1284 WMResizeWidget(panel
->dirdB
, 90, 40);
1285 WMMoveWidget(panel
->dirdB
, 194, 20);
1287 WMGroupButtons(panel
->dirvB
, panel
->dirhB
);
1288 WMGroupButtons(panel
->dirvB
, panel
->dirdB
);
1290 WMMapSubwidgets(panel
->dirF
);
1292 /****************** Textured Gradient ******************/
1293 panel
->tcolF
= WMCreateFrame(panel
->win
);
1294 WMResizeWidget(panel
->tcolF
, 100, 135);
1295 WMMoveWidget(panel
->tcolF
, 210, 10);
1296 WMSetFrameTitle(panel
->tcolF
, _("Gradient"));
1298 panel
->tcol1W
= WMCreateColorWell(panel
->tcolF
);
1299 WMResizeWidget(panel
->tcol1W
, 60, 45);
1300 WMMoveWidget(panel
->tcol1W
, 20, 25);
1301 WMAddNotificationObserver(colorWellObserver
, panel
, WMColorWellDidChangeNotification
, panel
->tcol1W
);
1303 panel
->tcol2W
= WMCreateColorWell(panel
->tcolF
);
1304 WMResizeWidget(panel
->tcol2W
, 60, 45);
1305 WMMoveWidget(panel
->tcol2W
, 20, 75);
1306 WMAddNotificationObserver(colorWellObserver
, panel
, WMColorWellDidChangeNotification
, panel
->tcol2W
);
1309 panel
->topaF
= WMCreateFrame(panel
->win
);
1310 WMResizeWidget(panel
->topaF
, 185, 50);
1311 WMMoveWidget(panel
->topaF
, 15, 95);
1312 WMSetFrameTitle(panel
->topaF
, _("Gradient Opacity"));
1314 panel
->topaS
= WMCreateSlider(panel
->topaF
);
1315 WMResizeWidget(panel
->topaS
, 155, 18);
1316 WMMoveWidget(panel
->topaS
, 15, 20);
1317 WMSetSliderMaxValue(panel
->topaS
, 255);
1318 WMSetSliderValue(panel
->topaS
, 200);
1319 WMSetSliderContinuous(panel
->topaS
, False
);
1320 WMSetSliderAction(panel
->topaS
, opaqChangeCallback
, panel
);
1322 WMMapSubwidgets(panel
->topaF
);
1329 pixmap
= WMCreatePixmap(scr
, 155, 18, WMScreenDepth(scr
), False
);
1330 p
= WMGetPixmapXID(pixmap
);
1332 color
= WMDarkGrayColor(scr
);
1333 XFillRectangle(WMScreenDisplay(scr
), p
, WMColorGC(color
), 0, 0, 155, 18);
1334 WMReleaseColor(color
);
1336 color
= WMWhiteColor(scr
);
1337 WMDrawString(scr
, p
, color
, panel
->listFont
, 2, 1, "0%", 2);
1338 WMDrawString(scr
, p
, color
, panel
->listFont
,
1339 153 - WMWidthOfString(panel
->listFont
, "100%", 4), 1, "100%", 4);
1340 WMReleaseColor(color
);
1342 WMSetSliderImage(panel
->topaS
, pixmap
);
1343 WMReleasePixmap(pixmap
);
1346 WMMapSubwidgets(panel
->tcolF
);
1348 /****************** Image ******************/
1349 panel
->imageF
= WMCreateFrame(panel
->win
);
1350 WMResizeWidget(panel
->imageF
, 295, 150);
1351 WMMoveWidget(panel
->imageF
, 15, 150);
1352 WMSetFrameTitle(panel
->imageF
, _("Image"));
1354 panel
->imageL
= WMCreateLabel(panel
->imageF
);
1355 WMSetLabelImagePosition(panel
->imageL
, WIPImageOnly
);
1357 panel
->imageT
= WMCreateTextField(panel
->imageF
);
1358 WMResizeWidget(panel
->imageT
, 90, 20);
1359 WMMoveWidget(panel
->imageT
, 190, 25);
1361 panel
->imageV
= WMCreateScrollView(panel
->imageF
);
1362 WMResizeWidget(panel
->imageV
, 165, 115);
1363 WMMoveWidget(panel
->imageV
, 15, 20);
1364 WMSetScrollViewRelief(panel
->imageV
, WRSunken
);
1365 WMSetScrollViewHasHorizontalScroller(panel
->imageV
, True
);
1366 WMSetScrollViewHasVerticalScroller(panel
->imageV
, True
);
1367 WMSetScrollViewContentView(panel
->imageV
, WMWidgetView(panel
->imageL
));
1369 panel
->browB
= WMCreateCommandButton(panel
->imageF
);
1370 WMResizeWidget(panel
->browB
, 90, 24);
1371 WMMoveWidget(panel
->browB
, 190, 50);
1372 WMSetButtonText(panel
->browB
, _("Browse..."));
1373 WMSetButtonAction(panel
->browB
, browseImageCallback
, panel
);
1375 /* panel->dispB = WMCreateCommandButton(panel->imageF);
1376 WMResizeWidget(panel->dispB, 90, 24);
1377 WMMoveWidget(panel->dispB, 190, 80);
1378 WMSetButtonText(panel->dispB, _("Show"));
1381 panel
->arrP
= WMCreatePopUpButton(panel
->imageF
);
1382 WMResizeWidget(panel
->arrP
, 90, 20);
1383 WMMoveWidget(panel
->arrP
, 190, 120);
1384 WMAddPopUpButtonItem(panel
->arrP
, _("Tile"));
1385 WMAddPopUpButtonItem(panel
->arrP
, _("Scale"));
1386 WMAddPopUpButtonItem(panel
->arrP
, _("Center"));
1387 WMAddPopUpButtonItem(panel
->arrP
, _("Maximize"));
1388 WMSetPopUpButtonSelectedItem(panel
->arrP
, 0);
1390 WMMapSubwidgets(panel
->imageF
);
1394 panel
->okB
= WMCreateCommandButton(panel
->win
);
1395 WMResizeWidget(panel
->okB
, 84, 24);
1396 WMMoveWidget(panel
->okB
, 225, 390);
1397 WMSetButtonText(panel
->okB
, _("OK"));
1398 WMSetButtonAction(panel
->okB
, buttonCallback
, panel
);
1400 panel
->cancelB
= WMCreateCommandButton(panel
->win
);
1401 WMResizeWidget(panel
->cancelB
, 84, 24);
1402 WMMoveWidget(panel
->cancelB
, 130, 390);
1403 WMSetButtonText(panel
->cancelB
, _("Cancel"));
1404 WMSetButtonAction(panel
->cancelB
, buttonCallback
, panel
);
1406 WMMapWidget(panel
->nameF
);
1407 WMMapWidget(panel
->typeP
);
1408 WMMapWidget(panel
->okB
);
1409 WMMapWidget(panel
->cancelB
);
1411 WMUnmapWidget(panel
->arrP
);
1413 WMRealizeWidget(panel
->win
);
1415 panel
->currentType
= -1;
1417 panel
->sectionParts
[TYPE_SOLID
][0] = panel
->defcF
;
1419 panel
->sectionParts
[TYPE_GRADIENT
][0] = panel
->defcF
;
1420 panel
->sectionParts
[TYPE_GRADIENT
][1] = panel
->gcolF
;
1421 panel
->sectionParts
[TYPE_GRADIENT
][2] = panel
->dirF
;
1423 panel
->sectionParts
[TYPE_SGRADIENT
][0] = panel
->tcolF
;
1424 panel
->sectionParts
[TYPE_SGRADIENT
][1] = panel
->dirF
;
1426 panel
->sectionParts
[TYPE_TGRADIENT
][0] = panel
->tcolF
;
1427 panel
->sectionParts
[TYPE_TGRADIENT
][1] = panel
->dirF
;
1428 panel
->sectionParts
[TYPE_TGRADIENT
][2] = panel
->imageF
;
1429 panel
->sectionParts
[TYPE_TGRADIENT
][3] = panel
->topaF
;
1430 panel
->sectionParts
[TYPE_TGRADIENT
][4] = panel
->arrP
;
1432 panel
->sectionParts
[TYPE_PIXMAP
][0] = panel
->defcF
;
1433 panel
->sectionParts
[TYPE_PIXMAP
][1] = panel
->imageF
;
1434 panel
->sectionParts
[TYPE_PIXMAP
][2] = panel
->arrP
;
1436 /* setup for first time */
1438 changeTypeCallback(panel
->typeP
, panel
);
1440 sliderChangeCallback(panel
->ghueS
, panel
);
1441 sliderChangeCallback(panel
->gsatS
, panel
);
1447 *--------------------------------------------------------------------------
1449 *--------------------------------------------------------------------------
1454 char *ProgName
= "test";
1456 void testOKButton(WMWidget
* self
, void *data
)
1464 TexturePanel
*panel
= (TexturePanel
*) data
;
1465 /* test = GetTexturePanelTextureString(panel); */
1469 dpy
= WMScreenDisplay(WMWidgetScreen(panel
->okB
));
1470 win
= XCreateSimpleWindow(dpy
, DefaultRootWindow(dpy
), 10, 10, 250, 250, 0, 0, 0);
1471 XMapRaised(dpy
, win
);
1474 /* image = RenderTexturePanelTexture(panel, 250, 250); */
1476 RConvertImage(WMScreenRContext(WMWidgetScreen(panel
->okB
)), image
, &pix
);
1478 XCopyArea(dpy
, pix
, win
, (WMScreenRContext(WMWidgetScreen(panel
->okB
)))->copy_gc
, 0, 0, image
->width
,
1479 image
->height
, 0, 0);
1485 void testCancelButton(WMWidget
* self
, void *data
)
1487 wwarning("Exiting test....");
1496 int main(int argc
, char **argv
)
1498 TexturePanel
*panel
;
1500 Display
*dpy
= XOpenDisplay("");
1505 WMInitializeApplication("Test", &argc
, argv
);
1508 wfatal("could not open display");
1512 scr
= WMCreateSimpleApplicationScreen(dpy
);
1514 panel
= CreateTexturePanel(scr
);
1516 SetTexturePanelOkAction(panel
, (WMAction
*) testOKButton
, panel
);
1517 SetTexturePanelCancelAction(panel
, (WMAction
*) testCancelButton
, panel
);
1519 SetTexturePanelTexture(panel
, "pinky",
1520 WMCreatePropListFromDescription("(mdgradient, pink, red, blue, yellow)"));
1522 ShowTexturePanel(panel
);
1524 WMScreenMainLoop(scr
);