2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
11 #include <graphics/gfx.h>
12 #include <graphics/view.h>
13 #include <clib/alib_protos.h>
15 #include <proto/dos.h>
16 #include <proto/exec.h>
17 #include <proto/graphics.h>
18 #include <proto/utility.h>
19 #include <proto/intuition.h>
20 #include <proto/muimaster.h>
24 /* #define MYDEBUG 1 */
27 #include "imspec_intern.h"
29 #include "muimaster_intern.h"
31 #include "support_classes.h"
32 #include "imageadjust_private.h"
34 extern struct Library
*MUIMasterBase
;
36 STATIC STRPTR
StrDupPooled(APTR pool
, CONST_STRPTR str
)
39 if (!str
) return NULL
;
40 newstr
= AllocPooled(pool
,strlen(str
)+1);
41 if (newstr
) strcpy(newstr
,str
);
45 static void Bitmap_Function(struct Hook
*hook
, Object
*obj
, APTR msg
)
47 struct Imageadjust_DATA
*data
= *(struct Imageadjust_DATA
**)msg
;
51 get(data
->bitmap_string
, MUIA_String_Contents
, &name
);
52 if (name
&& strlen(name
) > 0)
54 snprintf(buf
, 255, "5:%s", name
);
55 set(data
->bitmap_image
, MUIA_Imagedisplay_Spec
, (IPTR
)buf
);
60 static void Gradient_Function(struct Hook
*hook
, Object
*obj
, APTR msg
)
62 struct Imageadjust_DATA
*data
= *(struct Imageadjust_DATA
**)msg
;
63 struct MUI_RGBcolor
*start_rgb
;
64 struct MUI_RGBcolor
*end_rgb
;
65 LONG angle
= XGET(data
->gradient_angle_slider
, MUIA_Numeric_Value
);
66 LONG is_tiled
= XGET(data
->gradient_type_cycle
, MUIA_Cycle_Active
);
68 start_rgb
= (struct MUI_RGBcolor
*)XGET(data
->gradient_start_poppen
,
69 MUIA_Pendisplay_RGBcolor
);
70 end_rgb
= (struct MUI_RGBcolor
*)XGET(data
->gradient_end_poppen
,
71 MUIA_Pendisplay_RGBcolor
);
73 snprintf(data
->gradient_imagespec
,sizeof(data
->gradient_imagespec
),
74 "%s:%d,%08x,%08x,%08x-%08x,%08x,%08x",
77 start_rgb
->red
,start_rgb
->green
,start_rgb
->blue
,
78 end_rgb
->red
,end_rgb
->green
,end_rgb
->blue
);
80 set(data
->gradient_imagedisplay
, MUIA_Imagedisplay_Spec
, data
->gradient_imagespec
);
83 static void GradientSwap_Function(struct Hook
*hook
, Object
*obj
, APTR msg
)
85 struct Imageadjust_DATA
*data
= *(struct Imageadjust_DATA
**)msg
;
86 struct MUI_RGBcolor
*start_rgb
;
87 struct MUI_RGBcolor
*end_rgb
;
88 struct MUI_RGBcolor tmp
;
90 start_rgb
= (struct MUI_RGBcolor
*)XGET(data
->gradient_start_poppen
,
91 MUIA_Pendisplay_RGBcolor
);
92 end_rgb
= (struct MUI_RGBcolor
*)XGET(data
->gradient_end_poppen
,
93 MUIA_Pendisplay_RGBcolor
);
96 set(data
->gradient_start_poppen
, MUIA_Pendisplay_RGBcolor
, (IPTR
)end_rgb
);
97 set(data
->gradient_end_poppen
, MUIA_Pendisplay_RGBcolor
, (IPTR
)&tmp
);
98 Gradient_Function(NULL
,obj
,&data
);
102 static VOID
Pattern_Select_Function(struct Hook
*hook
, Object
*obj
, void **msg
)
104 struct Imageadjust_DATA
*data
= (struct Imageadjust_DATA
*)hook
->h_Data
;
105 int new_selected
= (int)msg
[0];
107 if (data
->last_pattern_selected
!= -1)
108 set(data
->pattern_image
[data
->last_pattern_selected
],MUIA_Selected
,FALSE
);
109 data
->last_pattern_selected
= new_selected
;
113 static VOID
Vector_Select_Function(struct Hook
*hook
, Object
*obj
, void **msg
)
115 struct Imageadjust_DATA
*data
= (struct Imageadjust_DATA
*)hook
->h_Data
;
116 int new_selected
= (int)msg
[0];
118 if (data
->last_vector_selected
!= -1)
119 set(data
->vector_image
[data
->last_vector_selected
],MUIA_Selected
,FALSE
);
120 data
->last_vector_selected
= new_selected
;
124 struct ExternalListEntry
{
132 static void Imageadjust_External_Display(struct Hook
*h
, char **strings
,
133 struct ExternalListEntry
*entry
)
135 static char buf
[256];
141 snprintf(buf
, 256, "%s", FilePart(entry
->filename
));
144 if (len
> 4 && !strcmp(buf
+ len
- 4, ".mf0"))
146 else if (len
> 4 && !strcmp(buf
+ len
- 4, ".mb0"))
148 else if (len
> 4 && !strcmp(buf
+ len
- 4, ".mbr"))
150 else if (len
> 6 && !strcmp(buf
+ len
- 6, ".image"))
155 static struct ExternalListEntry
*
156 Imageadjust_External_Construct(struct Hook
*h
,
158 struct ExternalListEntry
*ele
)
160 struct ExternalListEntry
*entry
= NULL
;
165 if (NULL
!= ele
->filename
)
167 entry
= AllocPooled(pool
, sizeof(struct ExternalListEntry
));
171 entry
->filename
= StrDupPooled(pool
, entry
->filename
);
172 entry
->reldir
= StrDupPooled(pool
, entry
->reldir
);
179 static void Imageadjust_External_Destruct(struct Hook
*h
, APTR pool
,
180 struct ExternalListEntry
*entry
)
184 if (entry
->filename
!= NULL
)
185 FreePooled(pool
, entry
->filename
, entry
->namelen
+ 1);
186 if (entry
->reldir
!= NULL
)
187 FreePooled(pool
, entry
->reldir
, entry
->dirlen
+ 1);
188 FreePooled(pool
, entry
, sizeof(struct ExternalListEntry
));
193 /**************************************************************************
194 Adds a directory to the list
195 **************************************************************************/
196 static int AddDirectory(Object
*list
, STRPTR dir
, LONG parent
)
198 BPTR lock
= Lock(dir
,ACCESS_READ
);
199 struct ExAllControl
*eac
;
200 struct ExAllData
*ead
, *EAData
;
202 int dir_len
= strlen(dir
);
205 //bug("AddDirectory: locked %s\n", dir);
207 eac
= (struct ExAllControl
*)AllocDosObject(DOS_EXALLCONTROL
, NULL
);
214 EAData
= AllocVec(1024, 0);
217 FreeDosObject(DOS_EXALLCONTROL
, eac
);
222 eac
->eac_LastKey
= 0;
226 //DoMethod(_app(list), MUIM_Application_InputBuffered);
228 more
= ExAll(lock
, EAData
, 1024, ED_TYPE
, eac
);
229 if ((!more
) && (IoErr() != ERROR_NO_MORE_ENTRIES
)) break;
230 if (eac
->eac_Entries
== 0) continue;
235 size_t namelen
= strlen(ead
->ed_Name
);
236 int len
= dir_len
+ namelen
+ 10;
239 //DoMethod(_app(list), MUIM_Application_InputBuffered);
241 buf
= AllocVec(len
,0);
248 if (ead
->ed_Type
> 0)
251 if (ead
->ed_Type
== ST_SOFTLINK
)
253 /* TODO: Special handling */
255 } else is_directory
= 0;
258 AddPart(buf
, ead
->ed_Name
, len
);
260 if (!is_directory
&& namelen
> 4
261 && !strcmp(ead
->ed_Name
+ namelen
- 4, ".mf1"))
263 if (!is_directory
&& namelen
> 4
264 && !strcmp(ead
->ed_Name
+ namelen
- 4, ".mb1"))
269 struct ExternalListEntry ele
;
270 //bug("AddDirectory: adding image %s\n", buf);
273 ele
.reldir
= dir
+ strlen(IMSPEC_EXTERNAL_PREFIX
);
274 ele
.dirlen
= strlen(ele
.reldir
);
275 ele
.filename
= ead
->ed_Name
;
276 ele
.namelen
= strlen(ele
.filename
);
277 ele
.type
= ead
->ed_Type
;
281 num
= DoMethod(list
, MUIM_List_InsertSingle
,
283 MUIV_List_Insert_Bottom
);
286 #warning "FIXME: where does num's value come from here?"
287 if (num
!= -1 && is_directory
)
289 AddDirectory(list
, buf
, num
);
298 FreeDosObject(DOS_EXALLCONTROL
, eac
);
305 /**************************************************************************
307 **************************************************************************/
308 STATIC VOID
Imageadjust_SetImagespec(Object
*obj
, struct Imageadjust_DATA
*data
, char *spec
)
311 if (!spec
) spec
= "0:128";
321 pat
-= MUII_BACKGROUND
;
323 if (pat
>= 0 && pat
< 18)
325 set(data
->pattern_image
[pat
],MUIA_Selected
,TRUE
);
326 set(obj
,MUIA_Group_ActivePage
,0);
334 StrToLong(s
+2,&vect
);
336 if (vect
>= 0 && vect
< 24)
338 set(data
->vector_image
[vect
],MUIA_Selected
,TRUE
);
339 set(obj
,MUIA_Group_ActivePage
,1);
346 switch(data
->adjust_type
)
348 case MUIV_Imageadjust_Type_All
:
349 case MUIV_Imageadjust_Type_Image
:
350 nfset(obj
, MUIA_Group_ActivePage
, 2);
352 case MUIV_Imageadjust_Type_Background
:
353 nfset(obj
, MUIA_Group_ActivePage
, 1);
356 nfset(obj
, MUIA_Group_ActivePage
, 0);
359 D(bug("imageadjust: setting color to %s\n", s
));
360 set(data
->color_group
, MUIA_Penadjust_Spec
, (IPTR
)s
+2);
366 struct ExternalListEntry
*entry
;
370 set(obj
, MUIA_Group_ActivePage
, 3);
372 get(data
->external_list
, MUIA_List_Entries
, &entries
);
373 for (i
= 0; i
< entries
; i
++)
375 DoMethod(data
->external_list
, MUIM_List_GetEntry
, i
,
378 && entry
->reldir
!= NULL
379 && entry
->filename
!= NULL
)
381 STRPTR file
= FilePart(s
+2);
382 //bug("entry->reldir = %s, s + 2 = %s, len=%d\n",
383 //entry->reldir, s + 2, strlen(s + 2) - strlen(file) - 1);
384 if (!strncmp(entry
->reldir
, s
+ 2,
385 strlen(s
+ 2) - strlen(file
) - 1))
387 //bug("entry->filename = %s, file = %s\n",
388 //entry->filename, file);
389 if (!strcmp(entry
->filename
, file
))
391 set(data
->external_list
, MUIA_List_Active
, i
);
401 set(data
->bitmap_string
,MUIA_String_Contents
,(IPTR
)s
+2);
402 Bitmap_Function(NULL
, obj
, &data
);
403 if (data
->adjust_type
== MUIV_Imageadjust_Type_All
)
404 set(obj
,MUIA_Group_ActivePage
,4);
406 set(obj
,MUIA_Group_ActivePage
,2);
419 struct MUI_ImageSpec_intern spec
;
420 if (zune_gradient_string_to_intern(s
+2,&spec
))
422 struct MUI_RGBcolor col
;
423 col
.red
= spec
.u
.gradient
.start_rgb
[0]*0x01010101;
424 col
.green
= spec
.u
.gradient
.start_rgb
[1]*0x01010101;
425 col
.blue
= spec
.u
.gradient
.start_rgb
[2]*0x01010101;
427 nnset(data
->gradient_start_poppen
, MUIA_Pendisplay_RGBcolor
, &col
);
429 col
.red
= spec
.u
.gradient
.end_rgb
[0]*0x01010101;
430 col
.green
= spec
.u
.gradient
.end_rgb
[1]*0x01010101;
431 col
.blue
= spec
.u
.gradient
.end_rgb
[2]*0x01010101;
433 nnset(data
->gradient_end_poppen
, MUIA_Pendisplay_RGBcolor
, &col
);
435 nnset(data
->gradient_angle_slider
, MUIA_Numeric_Value
, spec
.u
.gradient
.angle
);
437 set(data
->gradient_type_cycle
, MUIA_Cycle_Active
, *s
== '7' ? 0 : 1);
440 Gradient_Function(NULL
,obj
,&data
);
441 if (data
->adjust_type
== MUIV_Imageadjust_Type_All
)
442 set(obj
,MUIA_Group_ActivePage
,5);
444 set(obj
,MUIA_Group_ActivePage
,3);
450 IPTR
Imageadjust__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
452 struct Imageadjust_DATA
*data
;
454 const struct TagItem
*tags
;
455 static const char * const labels_all
[] = {"Pattern", "Vector", "Color", "External", "Bitmap", "Gradient", NULL
};
456 static const char * const labels_image
[] = {"Pattern", "Vector", "Color", "External", NULL
};
457 static const char * const labels_bg
[] = {"Pattern", "Color", "Bitmap", "Gradient", NULL
};
458 static const char * const labels_color
[] = {"Color", NULL
};
459 static const char * const gradient_type_entries
[] = {"Scaled", "Tiled", NULL
};
461 Object
*pattern_group
= NULL
;
462 Object
*vector_group
= NULL
;
463 Object
*external_list
= NULL
;
464 Object
*bitmap_string
= NULL
;
465 Object
*bitmap_image
= NULL
;
466 Object
*bitmap_popasl
= NULL
;
467 Object
*gradient_imagedisplay
= NULL
;
468 Object
*gradient_start_poppen
= NULL
;
469 Object
*gradient_end_poppen
= NULL
;
470 Object
*gradient_angle_slider
= NULL
;
471 Object
*gradient_type_cycle
= NULL
;
472 Object
*gradient_horiz_button
= NULL
;
473 Object
*gradient_vert_button
= NULL
;
474 Object
*gradient_swap_button
= NULL
;
478 Object
*color_group
= NULL
;
479 Object
*external_group
= NULL
;
480 Object
*bitmap_group
= NULL
;
481 Object
*gradient_group
= NULL
;
483 adjust_type
= GetTagData(MUIA_Imageadjust_Type
, MUIV_Imageadjust_Type_All
,
486 color_group
= MUI_NewObject(MUIC_Penadjust
, TAG_DONE
);
488 if (adjust_type
== MUIV_Imageadjust_Type_All
||
489 adjust_type
== MUIV_Imageadjust_Type_Image
)
491 external_group
= (Object
*)ListviewObject
,
492 MUIA_Listview_List
, (IPTR
)(external_list
= (Object
*)ListObject
,
494 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
495 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
500 if (adjust_type
== MUIV_Imageadjust_Type_All
||
501 adjust_type
== MUIV_Imageadjust_Type_Background
)
503 bitmap_group
= (Object
*)VGroup
,
504 Child
, (IPTR
)(bitmap_image
= (Object
*)ImagedisplayObject
,
507 MUIA_Imagedisplay_FreeHoriz
, TRUE
,
508 MUIA_Imagedisplay_FreeVert
, TRUE
,
509 MUIA_Dropable
, FALSE
,
511 Child
, (IPTR
)(bitmap_popasl
= (Object
*)PopaslObject
,
512 MUIA_Popstring_String
, (IPTR
)(bitmap_string
= (Object
*)StringObject
,
516 MUIA_Popstring_Button
, (IPTR
)PopButton(MUII_PopFile
),
520 gradient_group
= (Object
*)ColGroup(2),
521 Child
, (IPTR
)FreeLabel("Type:"),
522 Child
, (IPTR
)(gradient_type_cycle
= MUI_MakeObject(MUIO_Cycle
,
523 (IPTR
)"Type:", (IPTR
)gradient_type_entries
)),
524 Child
, (IPTR
)FreeLabel("Angle:"),
527 MUIA_Group_SameWidth
, TRUE
,
528 Child
, (IPTR
)(gradient_horiz_button
= (Object
*)TextObject
,
530 MUIA_Background
, MUII_ButtonBack
,
531 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
532 MUIA_Text_PreParse
, (IPTR
)"\33c",
533 MUIA_Text_Contents
, (IPTR
)"Vertical",
535 Child
, (IPTR
)(gradient_vert_button
= (Object
*)TextObject
,
537 MUIA_Background
, MUII_ButtonBack
,
538 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
539 MUIA_Text_PreParse
, (IPTR
)"\33c",
540 MUIA_Text_Contents
, (IPTR
)"Horizontal",
543 Child
, (IPTR
)(gradient_angle_slider
= (Object
*)SliderObject
,
544 MUIA_Group_Horiz
, TRUE
,
546 MUIA_Numeric_Max
, 179,
549 Child
, (IPTR
)FreeLabel("Colors:"),
551 Child
, (IPTR
)(gradient_start_poppen
= (Object
*)PoppenObject
,
552 MUIA_Window_Title
, (IPTR
) "Start pen",
553 MUIA_Pendisplay_Spec
, (IPTR
) "rbbbbbbbb,bbbbbbbb,bbbbbbbb", End
),
554 Child
, (IPTR
)VCenter((gradient_swap_button
= (Object
*)TextObject
,
556 MUIA_Background
, MUII_ButtonBack
,
557 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
558 MUIA_Text_Contents
, (IPTR
)"<->",
561 Child
, (IPTR
)(gradient_end_poppen
= (Object
*)PoppenObject
,
562 MUIA_Window_Title
, (IPTR
) "End pen",
563 MUIA_Pendisplay_Spec
, (IPTR
)"r55555555,55555555,55555555", End
),
565 Child
, (IPTR
)FreeLabel("Preview:"),
566 Child
, (IPTR
)(gradient_imagedisplay
= (Object
*)ImagedisplayObject
,
569 MUIA_Imagedisplay_FreeHoriz
, TRUE
,
570 MUIA_Imagedisplay_FreeVert
, TRUE
,
571 MUIA_Dropable
, FALSE
,
578 case MUIV_Imageadjust_Type_All
:
579 obj
= (Object
*)DoSuperNewTags(cl
, obj
, NULL
,
580 MUIA_Register_Titles
, (IPTR
)labels_all
,
581 Child
, (IPTR
)HCenter((pattern_group
= (Object
*)ColGroup(6), End
)),
582 Child
, (IPTR
)HCenter((vector_group
= (Object
*)ColGroup(6), End
)),
583 Child
, (IPTR
)color_group
,
584 Child
, (IPTR
)external_group
,
585 Child
, (IPTR
)bitmap_group
,
586 Child
, (IPTR
)gradient_group
,
587 TAG_MORE
, (IPTR
)msg
->ops_AttrList
);
589 case MUIV_Imageadjust_Type_Background
:
590 obj
= (Object
*)DoSuperNewTags(cl
, obj
, NULL
,
591 MUIA_Register_Titles
, (IPTR
)labels_bg
,
592 Child
, (IPTR
)HCenter((pattern_group
= (Object
*)ColGroup(6), End
)),
593 Child
, (IPTR
)color_group
,
594 Child
, (IPTR
)bitmap_group
,
595 Child
, (IPTR
)gradient_group
,
596 TAG_MORE
, (IPTR
)msg
->ops_AttrList
);
598 case MUIV_Imageadjust_Type_Image
:
599 obj
= (Object
*)DoSuperNewTags(cl
, obj
, NULL
,
600 MUIA_Register_Titles
, (IPTR
)labels_image
,
601 Child
, (IPTR
)HCenter((pattern_group
= (Object
*)ColGroup(6), End
)),
602 Child
, (IPTR
)HCenter((vector_group
= (Object
*)ColGroup(6), End
)),
603 Child
, (IPTR
)color_group
,
604 Child
, (IPTR
)external_group
,
605 TAG_MORE
, (IPTR
)msg
->ops_AttrList
);
607 case MUIV_Imageadjust_Type_Pen
:
608 obj
= (Object
*)DoSuperNewTags(cl
, obj
, NULL
,
609 MUIA_Register_Titles
, (IPTR
)labels_color
,
610 Child
, (IPTR
)color_group
,
611 TAG_MORE
, (IPTR
)msg
->ops_AttrList
);
615 if (!obj
) return FALSE
;
617 data
= INST_DATA(cl
, obj
);
618 data
->adjust_type
= adjust_type
;
619 data
->color_group
= color_group
;
620 data
->originator
= (APTR
)GetTagData(MUIA_Imageadjust_Originator
, 0, msg
->ops_AttrList
);
622 if (adjust_type
!= MUIV_Imageadjust_Type_Pen
)
624 data
->last_pattern_selected
= -1;
625 data
->pattern_select_hook
.h_Data
= data
;
626 data
->pattern_select_hook
.h_Entry
= HookEntry
;
627 data
->pattern_select_hook
.h_SubEntry
= (HOOKFUNC
)Pattern_Select_Function
;
631 data
->pattern_image
[i
] = (Object
*)ImageObject
,
635 MUIA_Image_Spec
, i
+ MUII_BACKGROUND
,
636 MUIA_InputMode
, MUIV_InputMode_Immediate
,
637 MUIA_Image_FreeHoriz
, TRUE
,
638 MUIA_Image_FreeVert
, TRUE
,
643 if (data
->pattern_image
[i
])
645 DoMethod(pattern_group
,OM_ADDMEMBER
,(IPTR
)data
->pattern_image
[i
]);
646 DoMethod(data
->pattern_image
[i
],MUIM_Notify
,MUIA_Selected
,TRUE
,(IPTR
)obj
,3,MUIM_CallHook
,(IPTR
)&data
->pattern_select_hook
,i
);
650 if (adjust_type
!= MUIV_Imageadjust_Type_Background
)
652 data
->last_vector_selected
= -1;
653 data
->vector_select_hook
.h_Data
= data
;
654 data
->vector_select_hook
.h_Entry
= HookEntry
;
655 data
->vector_select_hook
.h_SubEntry
= (HOOKFUNC
)Vector_Select_Function
;
661 snprintf(spec
, sizeof(spec
), "1:%d", i
);
662 data
->vector_image
[i
] = (Object
*)ImageObject
,
666 MUIA_Image_Spec
, (IPTR
)spec
,
667 MUIA_InputMode
, MUIV_InputMode_Immediate
,
671 if (data
->vector_image
[i
])
673 DoMethod(vector_group
,OM_ADDMEMBER
,(IPTR
)data
->vector_image
[i
]);
674 DoMethod(data
->vector_image
[i
],MUIM_Notify
,MUIA_Selected
,TRUE
,(IPTR
)obj
,3,MUIM_CallHook
,(IPTR
)&data
->vector_select_hook
,i
);
677 } /* if (adjust_type != MUIV_Imageadjust_Type_Background) */
679 if (adjust_type
!= MUIV_Imageadjust_Type_Image
)
681 data
->bitmap_string
= bitmap_string
;
682 data
->bitmap_image
= bitmap_image
;
683 data
->bitmap_hook
.h_Entry
= HookEntry
;
684 data
->bitmap_hook
.h_SubEntry
= (HOOKFUNC
)Bitmap_Function
;
685 DoMethod(bitmap_popasl
, MUIM_Notify
, MUIA_Popasl_Active
, FALSE
,
686 (IPTR
)obj
, 3, MUIM_CallHook
, (IPTR
)&data
->bitmap_hook
, (IPTR
)data
);
687 DoMethod(bitmap_string
, MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
688 (IPTR
)obj
, 3, MUIM_CallHook
, (IPTR
)&data
->bitmap_hook
, (IPTR
)data
);
690 } /* if (adjust_type != MUIV_Imageadjust_Type_Pen) */
692 if (gradient_imagedisplay
)
694 data
->gradient_imagedisplay
= gradient_imagedisplay
;
695 data
->gradient_start_poppen
= gradient_start_poppen
;
696 data
->gradient_end_poppen
= gradient_end_poppen
;
697 data
->gradient_angle_slider
= gradient_angle_slider
;
698 data
->gradient_type_cycle
= gradient_type_cycle
;
699 data
->gradient_vert_button
= gradient_vert_button
;
700 data
->gradient_horiz_button
= gradient_horiz_button
;
701 data
->gradient_swap_button
= gradient_swap_button
;
703 DoMethod(gradient_vert_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
704 (IPTR
)gradient_angle_slider
, 3, MUIM_Set
, MUIA_Numeric_Value
, 90);
705 DoMethod(gradient_horiz_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
706 (IPTR
)gradient_angle_slider
, 3, MUIM_Set
, MUIA_Numeric_Value
, 0);
708 data
->gradient_swap_hook
.h_Entry
= HookEntry
;
709 data
->gradient_swap_hook
.h_SubEntry
= (HOOKFUNC
)GradientSwap_Function
;
710 DoMethod(gradient_swap_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
711 (IPTR
)obj
, 3, MUIM_CallHook
, (IPTR
)&data
->gradient_swap_hook
, (IPTR
)data
);
713 data
->gradient_hook
.h_Entry
= HookEntry
;
714 data
->gradient_hook
.h_SubEntry
= (HOOKFUNC
)Gradient_Function
;
715 DoMethod(gradient_start_poppen
, MUIM_Notify
, MUIA_Pendisplay_Spec
, MUIV_EveryTime
,
716 (IPTR
)obj
, 3, MUIM_CallHook
, (IPTR
)&data
->gradient_hook
, (IPTR
)data
);
717 DoMethod(gradient_end_poppen
, MUIM_Notify
, MUIA_Pendisplay_Spec
, MUIV_EveryTime
,
718 (IPTR
)obj
, 3, MUIM_CallHook
, (IPTR
)&data
->gradient_hook
, (IPTR
)data
);
719 DoMethod(gradient_angle_slider
, MUIM_Notify
, MUIA_Numeric_Value
, MUIV_EveryTime
,
720 (IPTR
)obj
, 3, MUIM_CallHook
, (IPTR
)&data
->gradient_hook
, (IPTR
)data
);
721 DoMethod(gradient_type_cycle
, MUIM_Notify
, MUIA_Cycle_Active
, MUIV_EveryTime
,
722 (IPTR
)obj
, 3, MUIM_CallHook
, (IPTR
)&data
->gradient_hook
, (IPTR
)data
);
724 /* Set the gradient image to correct values */
725 Gradient_Function(NULL
,obj
,&data
);
727 } /* if (gradient_imagedisplay) */
729 /* parse initial taglist */
730 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
734 case MUIA_Imageadjust_Spec
:
735 spec
= (char*)tag
->ti_Data
;
740 if (adjust_type
!= MUIV_Imageadjust_Type_Background
&&
741 adjust_type
!= MUIV_Imageadjust_Type_Pen
)
743 data
->external_list
= external_list
;
744 data
->external_display_hook
.h_Entry
= HookEntry
;
745 data
->external_display_hook
.h_SubEntry
= (HOOKFUNC
)Imageadjust_External_Display
;
746 set(data
->external_list
, MUIA_List_DisplayHook
, (IPTR
)&data
->external_display_hook
);
748 data
->external_construct_hook
.h_Entry
= HookEntry
;
749 data
->external_construct_hook
.h_SubEntry
= (HOOKFUNC
)Imageadjust_External_Construct
;
750 set(data
->external_list
, MUIA_List_ConstructHook
, (IPTR
)&data
->external_construct_hook
);
752 data
->external_destruct_hook
.h_Entry
= HookEntry
;
753 data
->external_destruct_hook
.h_SubEntry
= (HOOKFUNC
)Imageadjust_External_Destruct
;
754 set(data
->external_list
, MUIA_List_DestructHook
, (IPTR
)&data
->external_destruct_hook
);
756 /* Because we have many childs, we disable the forwarding of the notify method */
757 DoMethod(obj
, MUIM_Group_DoMethodNoForward
, MUIM_Notify
,
758 MUIA_Group_ActivePage
, 3, (IPTR
)obj
, 1,
759 MUIM_Imageadjust_ReadExternal
);
761 if (data
->originator
)
762 DoMethod(data
->external_list
, MUIM_Notify
,
763 MUIA_Listview_DoubleClick
, TRUE
,
764 MUIV_Notify_Application
, 5, MUIM_Application_PushMethod
,
765 (IPTR
)data
->originator
, 2, MUIM_Popimage_CloseWindow
, TRUE
);
767 Imageadjust_SetImagespec(obj
,data
,spec
);
771 IPTR
Imageadjust__OM_DISPOSE(struct IClass
*cl
, Object
*obj
, Msg msg
)
773 struct Imageadjust_DATA
*data
= INST_DATA(cl
, obj
);
775 if (data
->imagespec
) FreeVec(data
->imagespec
);
777 DoSuperMethodA(cl
,obj
,msg
);
781 IPTR
Imageadjust__OM_SET(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
783 const struct TagItem
*tags
;
785 struct Imageadjust_DATA
*data
= INST_DATA(cl
, obj
);
787 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
791 case MUIA_Imageadjust_Spec
:
792 Imageadjust_SetImagespec(obj
,data
,(char*)tag
->ti_Data
);
797 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
800 IPTR
Imageadjust__OM_GET(struct IClass
*cl
, Object
*obj
, struct opGet
*msg
)
802 struct Imageadjust_DATA
*data
= INST_DATA(cl
, obj
);
808 const static struct pages pages_per_type
[] =
810 { MUIV_Imageadjust_Type_Pen
, { 2, -1, -1, -1, -1, -1} },
811 { MUIV_Imageadjust_Type_Background
, { 0, 2, 4, 5, -1, -1} },
812 { MUIV_Imageadjust_Type_Image
, { 0, 1, 2, 3, -1, -1} },
813 { MUIV_Imageadjust_Type_All
, { 0, 1, 2, 3, 4, 5} },
816 switch (msg
->opg_AttrID
)
818 case MUIA_Imageadjust_Spec
:
825 FreeVec(data
->imagespec
);
826 data
->imagespec
= NULL
;
829 get(obj
, MUIA_Group_ActivePage
, &act
);
831 for (i
= 0; i
< 4; i
++)
833 if (pages_per_type
[i
].type
== data
->adjust_type
)
837 act
= pages_per_type
[i
].pos
[act
];
841 case 0: /* Pattern */
842 if ((data
->imagespec
= AllocVec(40,0)))
844 if (data
->last_pattern_selected
!= -1)
845 snprintf(data
->imagespec
, 40, "0:%d",
846 data
->last_pattern_selected
+128);
848 strcpy(data
->imagespec
,"0:128");
853 if ((data
->imagespec
= AllocVec(20,0)))
855 if (data
->last_vector_selected
!= -1)
856 snprintf(data
->imagespec
, 20, "1:%d",
857 data
->last_vector_selected
);
859 strcpy(data
->imagespec
,"0:128");
865 struct MUI_PenSpec
*penspec
;
867 get(data
->color_group
, MUIA_Penadjust_Spec
, &penspec
);
871 D(bug("imageadjust: penspec = %s\n", penspec
));
872 len
= strlen((STRPTR
)penspec
) + 3;
873 if ((data
->imagespec
= AllocVec(len
, 0)))
874 snprintf(data
->imagespec
, len
, "2:%s", penspec
->ps_buf
);
879 case 3: /* External */
881 struct ExternalListEntry
*entry
;
883 DoMethod(data
->external_list
, MUIM_List_GetEntry
,
884 MUIV_List_GetEntry_Active
, (IPTR
)&entry
);
885 if (entry
!= NULL
&& entry
->filename
!= NULL
&& entry
->reldir
!= NULL
)
888 len
= 2 + strlen(entry
->reldir
) + 1 + strlen(entry
->filename
) + 1;
889 if ((data
->imagespec
= AllocVec(len
, 0)))
891 snprintf(data
->imagespec
, len
, "3:%s/%s",
892 entry
->reldir
, entry
->filename
);
893 D(bug("Imageadjust_OM_GET: imspec=%s\n", data
->imagespec
));
902 get(data
->bitmap_string
,MUIA_String_Contents
,&str
);
906 len
= strlen(str
) + 10;
907 if ((data
->imagespec
= AllocVec(len
, 0)))
908 snprintf(data
->imagespec
, len
, "5:%s", str
);
913 case 5: /* Gradient */
914 data
->imagespec
= StrDup(data
->gradient_imagespec
);
917 if (data
->imagespec
) *msg
->opg_Storage
= (ULONG
)data
->imagespec
;
918 else *msg
->opg_Storage
= (ULONG
)"0:128";
923 return (DoSuperMethodA(cl
, obj
, (Msg
) msg
));
926 IPTR
Imageadjust__MUIM_Imageadjust_ReadExternal(struct IClass
*cl
, Object
*obj
, Msg msg
)
928 struct Imageadjust_DATA
*data
= INST_DATA(cl
, obj
);
930 DoMethod(data
->external_list
, MUIM_List_Clear
);
931 set(data
->external_list
, MUIA_List_Quiet
, TRUE
);
932 AddDirectory(data
->external_list
, IMSPEC_EXTERNAL_PREFIX
, -1);
933 set(data
->external_list
, MUIA_List_Quiet
, FALSE
);
938 IPTR
Imageadjust__MUIM_Imageadjust_ExternalSelected(struct IClass
*cl
, Object
*obj
, Msg msg
)
940 struct Imageadjust_DATA
*data
= INST_DATA(cl
, obj
);
942 if (data
->originator
)
943 DoMethod(_app(obj
), MUIM_Application_PushMethod
, data
->originator
, 2,
944 MUIM_Popimage_CloseWindow
, TRUE
);
949 #if ZUNE_BUILTIN_IMAGEADJUST
950 BOOPSI_DISPATCHER(IPTR
, Imageadjust_Dispatcher
, cl
, obj
, msg
)
952 switch (msg
->MethodID
)
955 return Imageadjust__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
958 return Imageadjust__OM_DISPOSE(cl
,obj
,(APTR
)msg
);
961 return Imageadjust__OM_SET(cl
, obj
, (struct opSet
*)msg
);
964 return Imageadjust__OM_GET(cl
,obj
,(APTR
)msg
);
966 case MUIM_Imageadjust_ReadExternal
:
967 return Imageadjust__MUIM_Imageadjust_ReadExternal(cl
,obj
,(APTR
)msg
);
969 //case MUIM_Imageadjust_ExternalSelected:
970 //return Imageadjust__MUIM_Imageadjust_ExternalSelected(cl,obj,(APTR)msg);
973 return DoSuperMethodA(cl
, obj
, msg
);
976 BOOPSI_DISPATCHER_END
978 const struct __MUIBuiltinClass _MUI_Imageadjust_desc
=
982 sizeof(struct Imageadjust_DATA
),
983 (void*)Imageadjust_Dispatcher
985 #endif /* ZUNE_BUILTIN_IMAGEADJUST */