2 Copyright © 2002-2015, 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 <workbench/startup.h>
14 #include <workbench/workbench.h>
16 #include <proto/dos.h>
17 #include <proto/exec.h>
18 #include <proto/graphics.h>
19 #include <proto/utility.h>
20 #include <proto/intuition.h>
21 #include <proto/muimaster.h>
22 #include <clib/alib_protos.h>
26 /* #define MYDEBUG 1 */
29 #include "imspec_intern.h"
31 #include "muimaster_intern.h"
33 #include "support_classes.h"
34 #include "imageadjust_private.h"
36 extern struct Library
*MUIMasterBase
;
38 STATIC STRPTR
StrDupPooled(APTR pool
, CONST_STRPTR str
)
43 newstr
= AllocPooled(pool
, strlen(str
) + 1);
49 static void Bitmap_Function(struct Hook
*hook
, Object
*obj
, APTR msg
)
51 struct Imageadjust_DATA
*data
= *(struct Imageadjust_DATA
**)msg
;
55 get(data
->bitmap_string
, MUIA_String_Contents
, &name
);
56 if (name
&& strlen(name
) > 0)
58 snprintf(buf
, 255, "5:%s", name
);
59 set(data
->bitmap_image
, MUIA_Imagedisplay_Spec
, (IPTR
) buf
);
64 static void AppMessage_Function(struct Hook
*hook
, Object
*obj
, void **msg
)
66 struct Imageadjust_DATA
*data
= *(struct Imageadjust_DATA
**)msg
;
67 struct AppMessage
*appmsg
= msg
[1];
71 wbarg
= &appmsg
->am_ArgList
[0];
72 buf
[0] = '5', buf
[1] = ':';
73 if (NameFromLock(wbarg
->wa_Lock
, buf
+ 2, 253))
75 if (AddPart(buf
+ 2, wbarg
->wa_Name
, 253))
77 set(data
->bitmap_image
, MUIA_Imagedisplay_Spec
, (IPTR
)buf
);
78 set(data
->bitmap_string
, MUIA_String_Contents
, (IPTR
)buf
+ 2);
84 static void Gradient_Function(struct Hook
*hook
, Object
*obj
, APTR msg
)
86 struct Imageadjust_DATA
*data
= *(struct Imageadjust_DATA
**)msg
;
87 struct MUI_RGBcolor
*start_rgb
;
88 struct MUI_RGBcolor
*end_rgb
;
89 LONG angle
= XGET(data
->gradient_angle_slider
, MUIA_Numeric_Value
);
90 LONG is_tiled
= XGET(data
->gradient_type_cycle
, MUIA_Cycle_Active
);
92 start_rgb
= (struct MUI_RGBcolor
*)XGET(data
->gradient_start_poppen
,
93 MUIA_Pendisplay_RGBcolor
);
94 end_rgb
= (struct MUI_RGBcolor
*)XGET(data
->gradient_end_poppen
,
95 MUIA_Pendisplay_RGBcolor
);
97 snprintf(data
->gradient_imagespec
, sizeof(data
->gradient_imagespec
),
98 "%s:%d,%08x,%08x,%08x-%08x,%08x,%08x",
101 (unsigned int)start_rgb
->red
,
102 (unsigned int)start_rgb
->green
,
103 (unsigned int)start_rgb
->blue
,
104 (unsigned int)end_rgb
->red
,
105 (unsigned int)end_rgb
->green
, (unsigned int)end_rgb
->blue
);
107 set(data
->gradient_imagedisplay
, MUIA_Imagedisplay_Spec
,
108 data
->gradient_imagespec
);
111 static void GradientSwap_Function(struct Hook
*hook
, Object
*obj
, APTR msg
)
113 struct Imageadjust_DATA
*data
= *(struct Imageadjust_DATA
**)msg
;
114 struct MUI_RGBcolor
*start_rgb
;
115 struct MUI_RGBcolor
*end_rgb
;
116 struct MUI_RGBcolor tmp
;
118 start_rgb
= (struct MUI_RGBcolor
*)XGET(data
->gradient_start_poppen
,
119 MUIA_Pendisplay_RGBcolor
);
120 end_rgb
= (struct MUI_RGBcolor
*)XGET(data
->gradient_end_poppen
,
121 MUIA_Pendisplay_RGBcolor
);
124 set(data
->gradient_start_poppen
, MUIA_Pendisplay_RGBcolor
,
126 set(data
->gradient_end_poppen
, MUIA_Pendisplay_RGBcolor
, (IPTR
) & tmp
);
127 Gradient_Function(NULL
, obj
, &data
);
131 static VOID
Pattern_Select_Function(struct Hook
*hook
, Object
*obj
,
134 struct Imageadjust_DATA
*data
= (struct Imageadjust_DATA
*)hook
->h_Data
;
135 SIPTR new_selected
= (SIPTR
) msg
[0];
137 if (data
->last_pattern_selected
!= -1)
138 set(data
->pattern_image
[data
->last_pattern_selected
], MUIA_Selected
,
140 data
->last_pattern_selected
= new_selected
;
144 static VOID
Vector_Select_Function(struct Hook
*hook
, Object
*obj
,
147 struct Imageadjust_DATA
*data
= (struct Imageadjust_DATA
*)hook
->h_Data
;
148 SIPTR new_selected
= (SIPTR
) msg
[0];
150 if (data
->last_vector_selected
!= -1)
151 set(data
->vector_image
[data
->last_vector_selected
], MUIA_Selected
,
153 data
->last_vector_selected
= new_selected
;
157 struct ExternalListEntry
166 static void Imageadjust_External_Display(struct Hook
*h
, char **strings
,
167 struct ExternalListEntry
*entry
)
169 static char buf
[256];
175 snprintf(buf
, 256, "%s", FilePart(entry
->filename
));
178 if (len
> 4 && !strcmp(buf
+ len
- 4, ".mf0"))
180 else if (len
> 4 && !strcmp(buf
+ len
- 4, ".mb0"))
182 else if (len
> 4 && !strcmp(buf
+ len
- 4, ".mbr"))
184 else if (len
> 6 && !strcmp(buf
+ len
- 6, ".image"))
189 static struct ExternalListEntry
*Imageadjust_External_Construct(struct Hook
190 *h
, APTR pool
, struct ExternalListEntry
*ele
)
192 struct ExternalListEntry
*entry
= NULL
;
197 if (NULL
!= ele
->filename
)
199 entry
= AllocPooled(pool
, sizeof(struct ExternalListEntry
));
203 entry
->filename
= StrDupPooled(pool
, entry
->filename
);
204 entry
->reldir
= StrDupPooled(pool
, entry
->reldir
);
211 static void Imageadjust_External_Destruct(struct Hook
*h
, APTR pool
,
212 struct ExternalListEntry
*entry
)
216 if (entry
->filename
!= NULL
)
217 FreePooled(pool
, entry
->filename
, entry
->namelen
+ 1);
218 if (entry
->reldir
!= NULL
)
219 FreePooled(pool
, entry
->reldir
, entry
->dirlen
+ 1);
220 FreePooled(pool
, entry
, sizeof(struct ExternalListEntry
));
225 /**************************************************************************
226 Adds a directory to the list
227 **************************************************************************/
228 static int AddDirectory(Object
*list
, STRPTR dir
, LONG parent
)
230 BPTR lock
= Lock(dir
, ACCESS_READ
);
231 struct ExAllControl
*eac
;
232 struct ExAllData
*ead
, *EAData
;
234 int dir_len
= strlen(dir
);
238 //bug("AddDirectory: locked %s\n", dir);
240 eac
= (struct ExAllControl
*)AllocDosObject(DOS_EXALLCONTROL
, NULL
);
247 EAData
= AllocVec(1024, 0);
250 FreeDosObject(DOS_EXALLCONTROL
, eac
);
255 eac
->eac_LastKey
= 0;
259 //DoMethod(_app(list), MUIM_Application_InputBuffered);
261 more
= ExAll(lock
, EAData
, 1024, ED_TYPE
, eac
);
262 if ((!more
) && (IoErr() != ERROR_NO_MORE_ENTRIES
))
264 if (eac
->eac_Entries
== 0)
270 size_t namelen
= strlen(ead
->ed_Name
);
271 int len
= dir_len
+ namelen
+ 10;
274 //DoMethod(_app(list), MUIM_Application_InputBuffered);
276 buf
= AllocVec(len
, 0);
283 if (ead
->ed_Type
> 0)
286 if (ead
->ed_Type
== ST_SOFTLINK
)
288 /* TODO: Special handling */
295 AddPart(buf
, ead
->ed_Name
, len
);
297 if (!is_directory
&& namelen
> 4
298 && !strcmp(ead
->ed_Name
+ namelen
- 4, ".mf1"))
300 if (!is_directory
&& namelen
> 4
301 && !strcmp(ead
->ed_Name
+ namelen
- 4, ".mb1"))
306 struct ExternalListEntry ele
;
307 //bug("AddDirectory: adding image %s\n", buf);
310 ele
.reldir
= dir
+ strlen(IMSPEC_EXTERNAL_PREFIX
);
311 ele
.dirlen
= strlen(ele
.reldir
);
312 ele
.filename
= ead
->ed_Name
;
313 ele
.namelen
= strlen(ele
.filename
);
314 ele
.type
= ead
->ed_Type
;
318 num
= DoMethod(list
, MUIM_List_InsertSingle
,
319 (IPTR
) & ele
, MUIV_List_Insert_Bottom
);
322 // FIXME: where does num's value come from here?
323 if (num
!= -1 && is_directory
)
325 AddDirectory(list
, buf
, num
);
336 FreeDosObject(DOS_EXALLCONTROL
, eac
);
343 /**************************************************************************
345 **************************************************************************/
346 STATIC VOID
Imageadjust_SetImagespec(Object
*obj
,
347 struct Imageadjust_DATA
*data
, char *spec
)
360 StrToLong(s
+ 2, &pat
);
361 pat
-= MUII_BACKGROUND
;
363 if (pat
>= 0 && pat
< 18)
365 set(data
->pattern_image
[pat
], MUIA_Selected
, TRUE
);
366 set(obj
, MUIA_Group_ActivePage
, 0);
374 StrToLong(s
+ 2, &vect
);
376 if (vect
>= 0 && vect
< 24)
378 set(data
->vector_image
[vect
], MUIA_Selected
, TRUE
);
379 set(obj
, MUIA_Group_ActivePage
, 1);
386 switch (data
->adjust_type
)
388 case MUIV_Imageadjust_Type_All
:
389 case MUIV_Imageadjust_Type_Image
:
390 nfset(obj
, MUIA_Group_ActivePage
, 2);
392 case MUIV_Imageadjust_Type_Background
:
393 nfset(obj
, MUIA_Group_ActivePage
, 1);
396 nfset(obj
, MUIA_Group_ActivePage
, 0);
399 D(bug("imageadjust: setting color to %s\n", s
));
400 set(data
->color_group
, MUIA_Penadjust_Spec
, (IPTR
) s
+ 2);
406 struct ExternalListEntry
*entry
;
410 set(obj
, MUIA_Group_ActivePage
, 3);
412 get(data
->external_list
, MUIA_List_Entries
, &entries
);
413 for (i
= 0; i
< entries
; i
++)
415 DoMethod(data
->external_list
, MUIM_List_GetEntry
, i
,
418 && entry
->reldir
!= NULL
&& entry
->filename
!= NULL
)
420 STRPTR file
= FilePart(s
+ 2);
421 //bug("entry->reldir = %s, s + 2 = %s, len=%d\n",
422 //entry->reldir, s + 2, strlen(s + 2) - strlen(file) - 1);
423 if (!strncmp(entry
->reldir
, s
+ 2,
424 strlen(s
+ 2) - strlen(file
) - 1))
426 //bug("entry->filename = %s, file = %s\n",
427 //entry->filename, file);
428 if (!strcmp(entry
->filename
, file
))
430 set(data
->external_list
, MUIA_List_Active
, i
);
440 set(data
->bitmap_string
, MUIA_String_Contents
, (IPTR
) s
+ 2);
441 Bitmap_Function(NULL
, obj
, &data
);
442 if (data
->adjust_type
== MUIV_Imageadjust_Type_All
)
443 set(obj
, MUIA_Group_ActivePage
, 4);
445 set(obj
, MUIA_Group_ActivePage
, 2);
451 StrToLong(s
+ 2, &img
);
458 struct MUI_ImageSpec_intern spec
;
459 if (zune_gradient_string_to_intern(s
+ 2, &spec
))
461 struct MUI_RGBcolor col
;
462 col
.red
= spec
.u
.gradient
.start_rgb
[0] * 0x01010101;
463 col
.green
= spec
.u
.gradient
.start_rgb
[1] * 0x01010101;
464 col
.blue
= spec
.u
.gradient
.start_rgb
[2] * 0x01010101;
466 nnset(data
->gradient_start_poppen
, MUIA_Pendisplay_RGBcolor
,
469 col
.red
= spec
.u
.gradient
.end_rgb
[0] * 0x01010101;
470 col
.green
= spec
.u
.gradient
.end_rgb
[1] * 0x01010101;
471 col
.blue
= spec
.u
.gradient
.end_rgb
[2] * 0x01010101;
473 nnset(data
->gradient_end_poppen
, MUIA_Pendisplay_RGBcolor
,
476 nnset(data
->gradient_angle_slider
, MUIA_Numeric_Value
,
477 spec
.u
.gradient
.angle
);
479 set(data
->gradient_type_cycle
, MUIA_Cycle_Active
,
483 Gradient_Function(NULL
, obj
, &data
);
484 if (data
->adjust_type
== MUIV_Imageadjust_Type_All
)
485 set(obj
, MUIA_Group_ActivePage
, 5);
487 set(obj
, MUIA_Group_ActivePage
, 3);
493 IPTR
Imageadjust__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
495 struct Imageadjust_DATA
*data
;
497 struct TagItem
*tags
;
498 static const char *const labels_all
[] =
499 { "Pattern", "Vector", "Color", "External", "Bitmap", "Gradient",
501 static const char *const labels_image
[] =
502 { "Pattern", "Vector", "Color", "External", NULL
};
503 static const char *const labels_bg
[] =
504 { "Pattern", "Color", "Bitmap", "Gradient", NULL
};
505 static const char *const labels_color
[] = { "Color", NULL
};
506 static const char *const gradient_type_entries
[] =
507 { "Scaled", "Tiled", NULL
};
509 Object
*pattern_group
= NULL
;
510 Object
*vector_group
= NULL
;
511 Object
*external_list
= NULL
;
512 Object
*bitmap_string
= NULL
;
513 Object
*bitmap_image
= NULL
;
514 Object
*bitmap_popasl
= NULL
;
515 Object
*gradient_imagedisplay
= NULL
;
516 Object
*gradient_start_poppen
= NULL
;
517 Object
*gradient_end_poppen
= NULL
;
518 Object
*gradient_angle_slider
= NULL
;
519 Object
*gradient_type_cycle
= NULL
;
520 Object
*gradient_horiz_button
= NULL
;
521 Object
*gradient_vert_button
= NULL
;
522 Object
*gradient_swap_button
= NULL
;
526 Object
*color_group
= NULL
;
527 Object
*external_group
= NULL
;
528 Object
*bitmap_group
= NULL
;
529 Object
*gradient_group
= NULL
;
532 GetTagData(MUIA_Imageadjust_Type
, MUIV_Imageadjust_Type_All
,
535 color_group
= MUI_NewObject(MUIC_Penadjust
, TAG_DONE
);
537 if (adjust_type
== MUIV_Imageadjust_Type_All
||
538 adjust_type
== MUIV_Imageadjust_Type_Image
)
540 external_group
= (Object
*) ListviewObject
,
541 MUIA_Listview_List
, (IPTR
) (external_list
=
542 (Object
*) ListObject
, InputListFrame
,
543 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
544 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
549 if (adjust_type
== MUIV_Imageadjust_Type_All
||
550 adjust_type
== MUIV_Imageadjust_Type_Background
)
552 bitmap_group
= (Object
*) VGroup
,
553 Child
, (IPTR
) (bitmap_image
= (Object
*) ImagedisplayObject
,
556 MUIA_Imagedisplay_FreeHoriz
, TRUE
,
557 MUIA_Imagedisplay_FreeVert
, TRUE
,
558 MUIA_Dropable
, FALSE
,
560 Child
, (IPTR
) (bitmap_popasl
= (Object
*) PopaslObject
,
561 MUIA_Popstring_String
, (IPTR
) (bitmap_string
=
562 (Object
*) StringObject
, StringFrame
, MUIA_CycleChain
, 1,
564 MUIA_Popstring_Button
, (IPTR
) PopButton(MUII_PopFile
),
568 gradient_group
= (Object
*) ColGroup(2),
569 Child
, (IPTR
) FreeLabel("Type:"),
570 Child
, (IPTR
) (gradient_type_cycle
= MUI_MakeObject(MUIO_Cycle
,
571 (IPTR
) "Type:", (IPTR
) gradient_type_entries
)),
572 Child
, (IPTR
) FreeLabel("Angle:"),
573 Child
, (IPTR
) VGroup
,
574 Child
, (IPTR
) HGroup
,
575 MUIA_Group_SameWidth
, TRUE
,
577 (IPTR
) (gradient_horiz_button
= (Object
*) TextObject
,
579 MUIA_Background
, MUII_ButtonBack
,
580 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
581 MUIA_Text_PreParse
, (IPTR
) "\33c",
582 MUIA_Text_Contents
, (IPTR
) "Vertical",
585 (IPTR
) (gradient_vert_button
= (Object
*) TextObject
,
587 MUIA_Background
, MUII_ButtonBack
,
588 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
589 MUIA_Text_PreParse
, (IPTR
) "\33c",
590 MUIA_Text_Contents
, (IPTR
) "Horizontal",
593 Child
, (IPTR
) (gradient_angle_slider
= (Object
*) SliderObject
,
594 MUIA_Group_Horiz
, TRUE
,
596 MUIA_Numeric_Max
, 179,
599 Child
, (IPTR
) FreeLabel("Colors:"),
600 Child
, (IPTR
) HGroup
,
601 Child
, (IPTR
) (gradient_start_poppen
= (Object
*) PoppenObject
,
602 MUIA_Window_Title
, (IPTR
) "Start pen",
603 MUIA_Pendisplay_Spec
, (IPTR
) "rbbbbbbbb,bbbbbbbb,bbbbbbbb",
605 Child
, (IPTR
) VCenter((gradient_swap_button
=
606 (Object
*) TextObject
, ButtonFrame
,
607 MUIA_Background
, MUII_ButtonBack
,
608 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
609 MUIA_Text_Contents
, (IPTR
) "<->",
612 Child
, (IPTR
) (gradient_end_poppen
=
613 (Object
*) PoppenObject
,
614 MUIA_Window_Title
, (IPTR
) "End pen",
615 MUIA_Pendisplay_Spec
, (IPTR
) "r55555555,55555555,55555555",
618 Child
, (IPTR
) FreeLabel("Preview:"),
619 Child
, (IPTR
) (gradient_imagedisplay
=
620 (Object
*) ImagedisplayObject
, TextFrame
,
622 MUIA_Imagedisplay_FreeHoriz
, TRUE
,
623 MUIA_Imagedisplay_FreeVert
, TRUE
,
624 MUIA_Dropable
, FALSE
,
631 case MUIV_Imageadjust_Type_All
:
632 obj
= (Object
*) DoSuperNewTags(cl
, obj
, NULL
,
633 MUIA_Register_Titles
, (IPTR
) labels_all
,
634 Child
, (IPTR
) HCenter((pattern_group
=
635 (Object
*) ColGroup(6), End
)),
636 Child
, (IPTR
) HCenter((vector_group
=
637 (Object
*) ColGroup(6), End
)),
638 Child
, (IPTR
) color_group
,
639 Child
, (IPTR
) external_group
,
640 Child
, (IPTR
) bitmap_group
,
641 Child
, (IPTR
) gradient_group
,
642 TAG_MORE
, (IPTR
) msg
->ops_AttrList
);
644 case MUIV_Imageadjust_Type_Background
:
645 obj
= (Object
*) DoSuperNewTags(cl
, obj
, NULL
,
646 MUIA_Register_Titles
, (IPTR
) labels_bg
,
647 Child
, (IPTR
) HCenter((pattern_group
=
648 (Object
*) ColGroup(6), End
)),
649 Child
, (IPTR
) color_group
,
650 Child
, (IPTR
) bitmap_group
,
651 Child
, (IPTR
) gradient_group
,
652 TAG_MORE
, (IPTR
) msg
->ops_AttrList
);
654 case MUIV_Imageadjust_Type_Image
:
655 obj
= (Object
*) DoSuperNewTags(cl
, obj
, NULL
,
656 MUIA_Register_Titles
, (IPTR
) labels_image
,
657 Child
, (IPTR
) HCenter((pattern_group
=
658 (Object
*) ColGroup(6), End
)),
659 Child
, (IPTR
) HCenter((vector_group
=
660 (Object
*) ColGroup(6), End
)),
661 Child
, (IPTR
) color_group
,
662 Child
, (IPTR
) external_group
,
663 TAG_MORE
, (IPTR
) msg
->ops_AttrList
);
665 case MUIV_Imageadjust_Type_Pen
:
666 obj
= (Object
*) DoSuperNewTags(cl
, obj
, NULL
,
667 MUIA_Register_Titles
, (IPTR
) labels_color
,
668 Child
, (IPTR
) color_group
,
669 TAG_MORE
, (IPTR
) msg
->ops_AttrList
);
676 data
= INST_DATA(cl
, obj
);
677 data
->adjust_type
= adjust_type
;
678 data
->color_group
= color_group
;
680 (APTR
) GetTagData(MUIA_Imageadjust_Originator
, 0,
683 if (bitmap_group
!= NULL
)
685 data
->appmessage_hook
.h_Data
= data
;
686 data
->appmessage_hook
.h_Entry
= HookEntry
;
687 data
->appmessage_hook
.h_SubEntry
= (HOOKFUNC
)AppMessage_Function
;
688 if (bitmap_image
!= NULL
)
689 DoMethod(bitmap_image
, MUIM_Notify
,
690 MUIA_AppMessage
, MUIV_EveryTime
,
691 (IPTR
)obj
, 4, MUIM_CallHook
, &data
->appmessage_hook
, data
,
693 if (bitmap_string
!= NULL
)
694 DoMethod(bitmap_string
, MUIM_Notify
,
695 MUIA_AppMessage
, MUIV_EveryTime
,
696 (IPTR
)obj
, 4, MUIM_CallHook
, &data
->appmessage_hook
, data
,
700 if (adjust_type
!= MUIV_Imageadjust_Type_Pen
)
702 data
->last_pattern_selected
= -1;
703 data
->pattern_select_hook
.h_Data
= data
;
704 data
->pattern_select_hook
.h_Entry
= HookEntry
;
705 data
->pattern_select_hook
.h_SubEntry
=
706 (HOOKFUNC
) Pattern_Select_Function
;
708 for (i
= 0; i
< 18; i
++)
710 data
->pattern_image
[i
] = (Object
*) ImageObject
,
714 MUIA_Image_Spec
, i
+ MUII_BACKGROUND
,
715 MUIA_InputMode
, MUIV_InputMode_Immediate
,
716 MUIA_Image_FreeHoriz
, TRUE
,
717 MUIA_Image_FreeVert
, TRUE
,
718 MUIA_FixWidth
, 16, MUIA_FixHeight
, 16, End
;
720 if (data
->pattern_image
[i
])
722 DoMethod(pattern_group
, OM_ADDMEMBER
,
723 (IPTR
) data
->pattern_image
[i
]);
724 DoMethod(data
->pattern_image
[i
], MUIM_Notify
, MUIA_Selected
,
725 TRUE
, (IPTR
) obj
, 3, MUIM_CallHook
,
726 (IPTR
) &data
->pattern_select_hook
, i
);
730 if (adjust_type
!= MUIV_Imageadjust_Type_Background
)
732 data
->last_vector_selected
= -1;
733 data
->vector_select_hook
.h_Data
= data
;
734 data
->vector_select_hook
.h_Entry
= HookEntry
;
735 data
->vector_select_hook
.h_SubEntry
=
736 (HOOKFUNC
) Vector_Select_Function
;
738 for (i
= 0; i
< 24; i
++)
742 snprintf(spec
, sizeof(spec
), "1:%d", (int)i
);
743 data
->vector_image
[i
] = (Object
*) ImageObject
,
747 MUIA_Image_Spec
, (IPTR
) spec
,
748 MUIA_InputMode
, MUIV_InputMode_Immediate
,
751 if (data
->vector_image
[i
])
753 DoMethod(vector_group
, OM_ADDMEMBER
,
754 (IPTR
) data
->vector_image
[i
]);
755 DoMethod(data
->vector_image
[i
], MUIM_Notify
,
756 MUIA_Selected
, TRUE
, (IPTR
) obj
, 3, MUIM_CallHook
,
757 (IPTR
) & data
->vector_select_hook
, i
);
762 if (adjust_type
!= MUIV_Imageadjust_Type_Image
)
764 data
->bitmap_string
= bitmap_string
;
765 data
->bitmap_image
= bitmap_image
;
766 data
->bitmap_hook
.h_Entry
= HookEntry
;
767 data
->bitmap_hook
.h_SubEntry
= (HOOKFUNC
) Bitmap_Function
;
768 DoMethod(bitmap_popasl
, MUIM_Notify
, MUIA_Popasl_Active
, FALSE
,
769 (IPTR
) obj
, 3, MUIM_CallHook
, (IPTR
) & data
->bitmap_hook
,
771 DoMethod(bitmap_string
, MUIM_Notify
, MUIA_String_Acknowledge
,
772 MUIV_EveryTime
, (IPTR
) obj
, 3, MUIM_CallHook
,
773 (IPTR
) & data
->bitmap_hook
, (IPTR
) data
);
777 if (gradient_imagedisplay
)
779 data
->gradient_imagedisplay
= gradient_imagedisplay
;
780 data
->gradient_start_poppen
= gradient_start_poppen
;
781 data
->gradient_end_poppen
= gradient_end_poppen
;
782 data
->gradient_angle_slider
= gradient_angle_slider
;
783 data
->gradient_type_cycle
= gradient_type_cycle
;
784 data
->gradient_vert_button
= gradient_vert_button
;
785 data
->gradient_horiz_button
= gradient_horiz_button
;
786 data
->gradient_swap_button
= gradient_swap_button
;
788 DoMethod(gradient_vert_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
789 (IPTR
) gradient_angle_slider
, 3, MUIM_Set
, MUIA_Numeric_Value
,
791 DoMethod(gradient_horiz_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
792 (IPTR
) gradient_angle_slider
, 3, MUIM_Set
, MUIA_Numeric_Value
,
795 data
->gradient_swap_hook
.h_Entry
= HookEntry
;
796 data
->gradient_swap_hook
.h_SubEntry
=
797 (HOOKFUNC
) GradientSwap_Function
;
798 DoMethod(gradient_swap_button
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
799 (IPTR
) obj
, 3, MUIM_CallHook
, (IPTR
) & data
->gradient_swap_hook
,
802 data
->gradient_hook
.h_Entry
= HookEntry
;
803 data
->gradient_hook
.h_SubEntry
= (HOOKFUNC
) Gradient_Function
;
804 DoMethod(gradient_start_poppen
, MUIM_Notify
, MUIA_Pendisplay_Spec
,
805 MUIV_EveryTime
, (IPTR
) obj
, 3, MUIM_CallHook
,
806 (IPTR
) & data
->gradient_hook
, (IPTR
) data
);
807 DoMethod(gradient_end_poppen
, MUIM_Notify
, MUIA_Pendisplay_Spec
,
808 MUIV_EveryTime
, (IPTR
) obj
, 3, MUIM_CallHook
,
809 (IPTR
) & data
->gradient_hook
, (IPTR
) data
);
810 DoMethod(gradient_angle_slider
, MUIM_Notify
, MUIA_Numeric_Value
,
811 MUIV_EveryTime
, (IPTR
) obj
, 3, MUIM_CallHook
,
812 (IPTR
) & data
->gradient_hook
, (IPTR
) data
);
813 DoMethod(gradient_type_cycle
, MUIM_Notify
, MUIA_Cycle_Active
,
814 MUIV_EveryTime
, (IPTR
) obj
, 3, MUIM_CallHook
,
815 (IPTR
) & data
->gradient_hook
, (IPTR
) data
);
817 /* Set the gradient image to correct values */
818 Gradient_Function(NULL
, obj
, &data
);
821 /* parse initial taglist */
822 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
826 case MUIA_Imageadjust_Spec
:
827 spec
= (char *)tag
->ti_Data
;
832 if (adjust_type
!= MUIV_Imageadjust_Type_Background
&&
833 adjust_type
!= MUIV_Imageadjust_Type_Pen
)
835 data
->external_list
= external_list
;
836 data
->external_display_hook
.h_Entry
= HookEntry
;
837 data
->external_display_hook
.h_SubEntry
=
838 (HOOKFUNC
) Imageadjust_External_Display
;
839 set(data
->external_list
, MUIA_List_DisplayHook
,
840 (IPTR
) & data
->external_display_hook
);
842 data
->external_construct_hook
.h_Entry
= HookEntry
;
843 data
->external_construct_hook
.h_SubEntry
=
844 (HOOKFUNC
) Imageadjust_External_Construct
;
845 set(data
->external_list
, MUIA_List_ConstructHook
,
846 (IPTR
) & data
->external_construct_hook
);
848 data
->external_destruct_hook
.h_Entry
= HookEntry
;
849 data
->external_destruct_hook
.h_SubEntry
=
850 (HOOKFUNC
) Imageadjust_External_Destruct
;
851 set(data
->external_list
, MUIA_List_DestructHook
,
852 (IPTR
) & data
->external_destruct_hook
);
854 /* Because we have many children, we disable the forwarding of the
856 DoMethod(obj
, MUIM_Group_DoMethodNoForward
, MUIM_Notify
,
857 MUIA_Group_ActivePage
, 3, (IPTR
) obj
, 1,
858 MUIM_Imageadjust_ReadExternal
);
860 if (data
->originator
)
861 DoMethod(data
->external_list
, MUIM_Notify
,
862 MUIA_Listview_DoubleClick
, TRUE
,
863 MUIV_Notify_Application
, 5, MUIM_Application_PushMethod
,
864 (IPTR
) data
->originator
, 2, MUIM_Popimage_CloseWindow
,
867 Imageadjust_SetImagespec(obj
, data
, spec
);
871 IPTR
Imageadjust__OM_DISPOSE(struct IClass
*cl
, Object
*obj
, Msg msg
)
873 struct Imageadjust_DATA
*data
= INST_DATA(cl
, obj
);
876 FreeVec(data
->imagespec
);
878 DoSuperMethodA(cl
, obj
, msg
);
882 IPTR
Imageadjust__OM_SET(struct IClass
*cl
, Object
*obj
,
885 struct TagItem
*tags
;
887 struct Imageadjust_DATA
*data
= INST_DATA(cl
, obj
);
889 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
893 case MUIA_Imageadjust_Spec
:
894 Imageadjust_SetImagespec(obj
, data
, (char *)tag
->ti_Data
);
899 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
902 IPTR
Imageadjust__OM_GET(struct IClass
*cl
, Object
*obj
,
905 struct Imageadjust_DATA
*data
= INST_DATA(cl
, obj
);
912 const static struct pages pages_per_type
[] =
914 {MUIV_Imageadjust_Type_Pen
, {2, -1, -1, -1, -1, -1}},
915 {MUIV_Imageadjust_Type_Background
, {0, 2, 4, 5, -1, -1}},
916 {MUIV_Imageadjust_Type_Image
, {0, 1, 2, 3, -1, -1}},
917 {MUIV_Imageadjust_Type_All
, {0, 1, 2, 3, 4, 5}},
920 switch (msg
->opg_AttrID
)
922 case MUIA_Imageadjust_Spec
:
929 FreeVec(data
->imagespec
);
930 data
->imagespec
= NULL
;
933 get(obj
, MUIA_Group_ActivePage
, &act
);
935 for (i
= 0; i
< 4; i
++)
937 if (pages_per_type
[i
].type
== data
->adjust_type
)
941 act
= pages_per_type
[i
].pos
[act
];
945 case 0: /* Pattern */
946 if ((data
->imagespec
= AllocVec(40, 0)))
948 if (data
->last_pattern_selected
!= -1)
949 snprintf(data
->imagespec
, 40, "0:%d",
950 (int)data
->last_pattern_selected
+ 128);
952 strcpy(data
->imagespec
, "0:128");
957 if ((data
->imagespec
= AllocVec(20, 0)))
959 if (data
->last_vector_selected
!= -1)
960 snprintf(data
->imagespec
, 20, "1:%d",
961 (int)data
->last_vector_selected
);
963 strcpy(data
->imagespec
, "0:128");
969 struct MUI_PenSpec
*penspec
= NULL
;
971 get(data
->color_group
, MUIA_Penadjust_Spec
, &penspec
);
975 D(bug("imageadjust: penspec = %s\n", penspec
));
976 len
= strlen((STRPTR
) penspec
) + 3;
977 if ((data
->imagespec
= AllocVec(len
, 0)))
978 snprintf(data
->imagespec
, len
, "2:%s",
984 case 3: /* External */
986 struct ExternalListEntry
*entry
;
988 DoMethod(data
->external_list
, MUIM_List_GetEntry
,
989 MUIV_List_GetEntry_Active
, (IPTR
) & entry
);
990 if (entry
!= NULL
&& entry
->filename
!= NULL
991 && entry
->reldir
!= NULL
)
995 2 + strlen(entry
->reldir
) + 1 +
996 strlen(entry
->filename
) + 1;
997 if ((data
->imagespec
= AllocVec(len
, 0)))
999 snprintf(data
->imagespec
, len
, "3:%s/%s",
1000 entry
->reldir
, entry
->filename
);
1001 D(bug("Imageadjust_OM_GET: imspec=%s\n",
1008 case 4: /* Bitmap */
1011 get(data
->bitmap_string
, MUIA_String_Contents
, &str
);
1015 len
= strlen(str
) + 10;
1016 if ((data
->imagespec
= AllocVec(len
, 0)))
1017 snprintf(data
->imagespec
, len
, "5:%s", str
);
1022 case 5: /* Gradient */
1023 data
->imagespec
= StrDup(data
->gradient_imagespec
);
1026 if (data
->imagespec
)
1027 *msg
->opg_Storage
= (IPTR
) data
->imagespec
;
1029 *msg
->opg_Storage
= (IPTR
) "0:128";
1034 return (DoSuperMethodA(cl
, obj
, (Msg
) msg
));
1037 IPTR
Imageadjust__MUIM_Imageadjust_ReadExternal(struct IClass
*cl
,
1038 Object
*obj
, Msg msg
)
1040 struct Imageadjust_DATA
*data
= INST_DATA(cl
, obj
);
1042 DoMethod(data
->external_list
, MUIM_List_Clear
);
1043 set(data
->external_list
, MUIA_List_Quiet
, TRUE
);
1044 AddDirectory(data
->external_list
, IMSPEC_EXTERNAL_PREFIX
, -1);
1045 set(data
->external_list
, MUIA_List_Quiet
, FALSE
);
1050 IPTR
Imageadjust__MUIM_Imageadjust_ExternalSelected(struct IClass
*cl
,
1051 Object
*obj
, Msg msg
)
1053 struct Imageadjust_DATA
*data
= INST_DATA(cl
, obj
);
1055 if (data
->originator
)
1056 DoMethod(_app(obj
), MUIM_Application_PushMethod
, data
->originator
,
1057 2, MUIM_Popimage_CloseWindow
, TRUE
);
1062 #if ZUNE_BUILTIN_IMAGEADJUST
1063 BOOPSI_DISPATCHER(IPTR
, Imageadjust_Dispatcher
, cl
, obj
, msg
)
1065 switch (msg
->MethodID
)
1068 return Imageadjust__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
1071 return Imageadjust__OM_DISPOSE(cl
, obj
, (APTR
) msg
);
1074 return Imageadjust__OM_SET(cl
, obj
, (struct opSet
*)msg
);
1077 return Imageadjust__OM_GET(cl
, obj
, (APTR
) msg
);
1079 case MUIM_Imageadjust_ReadExternal
:
1080 return Imageadjust__MUIM_Imageadjust_ReadExternal(cl
, obj
,
1083 //case MUIM_Imageadjust_ExternalSelected:
1084 // return Imageadjust__MUIM_Imageadjust_ExternalSelected(cl, obj,
1088 return DoSuperMethodA(cl
, obj
, msg
);
1091 BOOPSI_DISPATCHER_END
1093 const struct __MUIBuiltinClass _MUI_Imageadjust_desc
=
1097 sizeof(struct Imageadjust_DATA
),
1098 (void *)Imageadjust_Dispatcher
1100 #endif /* ZUNE_BUILTIN_IMAGEADJUST */