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
, (IPTR
) &data
->intpenspec
.p_rgb
);
53 set(obj
, MUIA_Group_ActivePage
, 2);
61 static void UpdatePenspec(Object
*obj
, struct Penadjust_DATA
*data
)
65 get(obj
, MUIA_Group_ActivePage
, &val
);
70 data
->intpenspec
.p_type
= PST_MUI
;
72 get(data
->listobj
, MUIA_List_Active
, &val
);
73 data
->intpenspec
.p_mui
= (LONG
)val
;
77 data
->intpenspec
.p_type
= PST_CMAP
;
79 get(data
->sliderobj
, MUIA_Numeric_Value
, &val
);
80 data
->intpenspec
.p_cmap
= (LONG
)val
;
84 data
->intpenspec
.p_type
= PST_RGB
;
86 get(data
->coloradjobj
, MUIA_Coloradjust_Red
, &val
);
87 data
->intpenspec
.p_rgb
.red
= (ULONG
)val
;
88 get(data
->coloradjobj
, MUIA_Coloradjust_Green
, &val
);
89 data
->intpenspec
.p_rgb
.green
= (ULONG
)val
;
90 get(data
->coloradjobj
, MUIA_Coloradjust_Blue
, &val
);
91 data
->intpenspec
.p_rgb
.blue
= (ULONG
)val
;
94 zune_pen_intern_to_spec(&data
->intpenspec
, &data
->penspec
);
96 D(bug(" ## penspec now %s\n", &data
->penspec
));
99 static IPTR
MuipenDisplayFunc(struct Hook
*hook
, char **array
, char *entry
)
104 line
= (LONG
)array
[-1];
105 if (line
< 0 || line
> 7)
107 snprintf(buf
, sizeof(buf
), "\33I[2:m%ld]", line
);
116 IPTR
Penadjust__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
118 static const char * const register_labels
[] = {"MUI", "Colormap", "RGB", NULL
};
119 static const char * const lv_labels
[] = {"Shine", "Halfshine", "Background", "Halfshadow", "Shadow", "Text", "Fill", "Mark", NULL
};
120 static const struct Hook muipen_display_hook
= { {NULL
, NULL
}, HookEntry
, MuipenDisplayFunc
, NULL
};
122 struct Penadjust_DATA
*data
;
123 struct TagItem
*tag
, *tags
;
124 Object
*listobj
, *sliderobj
, *coloradjobj
;
126 obj
= (Object
*) DoSuperNewTags
130 MUIA_Register_Titles
, (IPTR
) register_labels
,
131 Child
, (IPTR
) ListviewObject
,
132 MUIA_Listview_List
, (IPTR
) (listobj
= ListObject
,
134 MUIA_List_SourceArray
, (IPTR
) lv_labels
,
135 MUIA_List_Format
, (IPTR
) ",,",
136 MUIA_List_DisplayHook
, (IPTR
) &muipen_display_hook
,
139 Child
, (IPTR
) (sliderobj
= SliderObject
,
140 MUIA_Slider_Horiz
, TRUE
,
141 MUIA_Numeric_Min
, -128,
142 MUIA_Numeric_Max
, 127,
144 Child
, (IPTR
) (coloradjobj
= ColoradjustObject
, End
),
146 TAG_MORE
, (IPTR
) msg
->ops_AttrList
149 if (!obj
) return FALSE
;
151 data
= INST_DATA(cl
, obj
);
153 data
->listobj
= listobj
;
154 data
->sliderobj
= sliderobj
;
155 data
->coloradjobj
= coloradjobj
;
157 strcpy(data
->penspec
.ps_buf
, "m5");
159 /* parse initial taglist */
160 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
164 case MUIA_Penadjust_Spec
:
165 data
->penspec
= *(struct MUI_PenSpec
*)tag
->ti_Data
;
170 UpdateState(obj
, data
);
175 IPTR
Penadjust__OM_SET(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
177 struct TagItem
*tags
,*tag
;
178 struct Penadjust_DATA
*data
= INST_DATA(cl
, obj
);
181 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
185 case MUIA_Penadjust_Spec
:
186 data
->penspec
= *(struct MUI_PenSpec
*)tag
->ti_Data
;
192 if (update
) UpdateState(obj
, data
);
194 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
197 IPTR
Penadjust__OM_GET(struct IClass
*cl
, Object
*obj
, struct opGet
*msg
)
199 struct Penadjust_DATA
*data
= INST_DATA(cl
, obj
);
200 IPTR
*store
= msg
->opg_Storage
;
202 switch(msg
->opg_AttrID
)
204 case MUIA_Penadjust_Spec
:
205 UpdatePenspec(obj
, data
);
206 *store
= (IPTR
)&data
->penspec
;
210 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
217 #if ZUNE_BUILTIN_PENADJUST
218 BOOPSI_DISPATCHER(IPTR
, Penadjust_Dispatcher
, cl
, obj
, msg
)
220 switch (msg
->MethodID
)
222 case OM_NEW
: return Penadjust__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
223 case OM_SET
: return Penadjust__OM_SET(cl
, obj
, (struct opSet
*)msg
);
224 case OM_GET
: return Penadjust__OM_GET(cl
,obj
,(APTR
)msg
);
225 default: return DoSuperMethodA(cl
, obj
, msg
);
228 BOOPSI_DISPATCHER_END
230 const struct __MUIBuiltinClass _MUI_Penadjust_desc
=
234 sizeof(struct Penadjust_DATA
),
235 (void*)Penadjust_Dispatcher
237 #endif /* ZUNE_BUILTIN_PENADJUST */