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>
27 #include "muimaster_intern.h"
29 #include "support_classes.h"
31 #include "penadjust_private.h"
33 extern struct Library
*MUIMasterBase
;
35 static void UpdateState(Object
*obj
, struct Penadjust_DATA
*data
)
37 zune_pen_spec_to_intern(&data
->penspec
, &data
->intpenspec
);
39 switch (data
->intpenspec
.p_type
)
42 set(data
->listobj
, MUIA_List_Active
, data
->intpenspec
.p_mui
);
43 set(obj
, MUIA_Group_ActivePage
, 0);
47 set(data
->sliderobj
, MUIA_Numeric_Value
, data
->intpenspec
.p_cmap
);
48 set(obj
, MUIA_Group_ActivePage
, 1);
52 set(data
->coloradjobj
, MUIA_Coloradjust_RGB
,
53 (IPTR
) & data
->intpenspec
.p_rgb
);
54 set(obj
, MUIA_Group_ActivePage
, 2);
62 static void UpdatePenspec(Object
*obj
, struct Penadjust_DATA
*data
)
67 get(obj
, MUIA_Group_ActivePage
, &val
);
72 data
->intpenspec
.p_type
= PST_MUI
;
75 get(data
->listobj
, MUIA_List_Active
, &val
);
76 data
->intpenspec
.p_mui
= (LONG
) val
;
80 data
->intpenspec
.p_type
= PST_CMAP
;
83 get(data
->sliderobj
, MUIA_Numeric_Value
, &val
);
84 data
->intpenspec
.p_cmap
= (LONG
) val
;
88 data
->intpenspec
.p_type
= PST_RGB
;
91 get(data
->coloradjobj
, MUIA_Coloradjust_Red
, &val
);
92 data
->intpenspec
.p_rgb
.red
= (ULONG
) val
;
94 get(data
->coloradjobj
, MUIA_Coloradjust_Green
, &val
);
95 data
->intpenspec
.p_rgb
.green
= (ULONG
) val
;
97 get(data
->coloradjobj
, MUIA_Coloradjust_Blue
, &val
);
98 data
->intpenspec
.p_rgb
.blue
= (ULONG
) val
;
101 zune_pen_intern_to_spec(&data
->intpenspec
, &data
->penspec
);
103 D(bug(" ## penspec now %s\n", &data
->penspec
));
106 static IPTR
MuipenDisplayFunc(struct Hook
*hook
, char **array
, char *entry
)
111 line
= (SIPTR
) array
[-1];
112 if (line
< 0 || line
> 7)
114 snprintf(buf
, sizeof(buf
), "\033I[2:m%d]", (int)line
);
123 IPTR
Penadjust__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
125 static const char *const register_labels
[] =
126 { "MUI", "Colormap", "RGB", NULL
};
127 static const char *const lv_labels
[] =
128 { "Shine", "Halfshine", "Background", "Halfshadow", "Shadow",
129 "Text", "Fill", "Mark", NULL
};
130 static const struct Hook muipen_display_hook
=
131 { {NULL
, NULL
}, HookEntry
, MuipenDisplayFunc
, NULL
};
133 struct Penadjust_DATA
*data
;
134 struct TagItem
*tags
;
136 Object
*listobj
, *sliderobj
, *coloradjobj
;
138 obj
= (Object
*) DoSuperNewTags
142 MUIA_Register_Titles
, (IPTR
) register_labels
,
143 Child
, (IPTR
) ListviewObject
,
144 MUIA_Listview_List
, (IPTR
) (listobj
= (Object
*)ListObject
,
146 MUIA_List_SourceArray
, (IPTR
) lv_labels
,
147 MUIA_List_Format
, (IPTR
) ",,",
148 MUIA_List_DisplayHook
, (IPTR
) &muipen_display_hook
,
151 Child
, (IPTR
) (sliderobj
= (Object
*)SliderObject
,
152 MUIA_Slider_Horiz
, TRUE
,
153 MUIA_Numeric_Min
, -128,
154 MUIA_Numeric_Max
, 127,
156 Child
, (IPTR
) (coloradjobj
= (Object
*)ColoradjustObject
, End
),
158 TAG_MORE
, (IPTR
) msg
->ops_AttrList
164 data
= INST_DATA(cl
, obj
);
166 data
->listobj
= listobj
;
167 data
->sliderobj
= sliderobj
;
168 data
->coloradjobj
= coloradjobj
;
170 strcpy(data
->penspec
.ps_buf
, "m5");
172 /* parse initial taglist */
173 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
177 case MUIA_Penadjust_Spec
:
178 data
->penspec
= *(struct MUI_PenSpec
*)tag
->ti_Data
;
183 UpdateState(obj
, data
);
188 IPTR
Penadjust__OM_SET(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
190 struct TagItem
*tags
;
192 struct Penadjust_DATA
*data
= INST_DATA(cl
, obj
);
195 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
199 case MUIA_Penadjust_Spec
:
200 data
->penspec
= *(struct MUI_PenSpec
*)tag
->ti_Data
;
207 UpdateState(obj
, data
);
209 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
212 IPTR
Penadjust__OM_GET(struct IClass
*cl
, Object
*obj
, struct opGet
*msg
)
214 struct Penadjust_DATA
*data
= INST_DATA(cl
, obj
);
215 IPTR
*store
= msg
->opg_Storage
;
217 switch (msg
->opg_AttrID
)
219 case MUIA_Penadjust_Spec
:
220 UpdatePenspec(obj
, data
);
221 *store
= (IPTR
) & data
->penspec
;
225 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
232 #if ZUNE_BUILTIN_PENADJUST
233 BOOPSI_DISPATCHER(IPTR
, Penadjust_Dispatcher
, cl
, obj
, msg
)
235 switch (msg
->MethodID
)
238 return Penadjust__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
240 return Penadjust__OM_SET(cl
, obj
, (struct opSet
*)msg
);
242 return Penadjust__OM_GET(cl
, obj
, (APTR
) msg
);
244 return DoSuperMethodA(cl
, obj
, msg
);
247 BOOPSI_DISPATCHER_END
249 const struct __MUIBuiltinClass _MUI_Penadjust_desc
=
253 sizeof(struct Penadjust_DATA
),
254 (void *) Penadjust_Dispatcher
256 #endif /* ZUNE_BUILTIN_PENADJUST */