2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
10 #include <graphics/gfx.h>
11 #include <graphics/view.h>
12 #include <graphics/gfxmacros.h>
13 #include <clib/alib_protos.h>
14 #include <proto/exec.h>
15 #include <proto/graphics.h>
16 #include <proto/utility.h>
17 #include <proto/intuition.h>
18 #include <proto/muimaster.h>
23 #include "muimaster_intern.h"
24 #include "textengine.h"
26 #include "support_classes.h"
27 #include "colorfield_private.h"
29 /* #define MYDEBUG 1 */
32 extern struct Library
*MUIMasterBase
;
34 #define FLAG_FIXED_PEN 1
35 #define FLAG_PEN_ALLOCATED 2
39 IPTR
Colorfield__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
41 struct Colorfield_DATA
*data
;
42 struct TagItem
*tag
, *tags
;
45 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
46 if (!obj
) return FALSE
;
48 data
= INST_DATA(cl
, obj
);
50 /* parse initial taglist */
51 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
55 case MUIA_Colorfield_Red
:
56 data
->rgb
[0] = (ULONG
)tag
->ti_Data
;
59 case MUIA_Colorfield_Green
:
60 data
->rgb
[1] = (ULONG
)tag
->ti_Data
;
63 case MUIA_Colorfield_Blue
:
64 data
->rgb
[2] = (ULONG
)tag
->ti_Data
;
67 case MUIA_Colorfield_RGB
:
68 rgb
= (ULONG
*)tag
->ti_Data
;
69 data
->rgb
[0] = *rgb
++;
70 data
->rgb
[1] = *rgb
++;
71 data
->rgb
[2] = *rgb
++;
74 case MUIA_Colorfield_Pen
:
75 data
->pen
= (UBYTE
)tag
->ti_Data
;
76 data
->pen
= FLAG_FIXED_PEN
;
85 IPTR
Colorfield__OM_SET(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
87 struct Colorfield_DATA
*data
;
88 struct TagItem
*tag
, *tags
;
93 data
= INST_DATA(cl
, obj
);
95 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
99 case MUIA_Colorfield_Red
:
100 data
->rgb
[0] = (ULONG
)tag
->ti_Data
;
104 case MUIA_Colorfield_Green
:
105 data
->rgb
[1] = (ULONG
)tag
->ti_Data
;
109 case MUIA_Colorfield_Blue
:
110 data
->rgb
[2] = (ULONG
)tag
->ti_Data
;
114 case MUIA_Colorfield_RGB
:
115 rgb
= (ULONG
*)tag
->ti_Data
;
116 data
->rgb
[0] = *rgb
++;
117 data
->rgb
[1] = *rgb
++;
118 data
->rgb
[2] = *rgb
++;
122 case MUIA_Colorfield_Pen
:
123 if (data
->flags
& FLAG_PEN_ALLOCATED
)
125 ReleasePen(_screen(obj
)->ViewPort
.ColorMap
, data
->pen
);
126 data
->flags
&= ~(FLAG_PEN_ALLOCATED
| FLAG_NO_PEN
);
128 data
->pen
= (UBYTE
)data
->pen
;
129 data
->flags
|= FLAG_FIXED_PEN
;
135 retval
= DoSuperMethodA(cl
, obj
, (Msg
)msg
);
137 if (newcol
&& (_flags(obj
) & MADF_SETUP
) && !(data
->flags
& FLAG_NO_PEN
))
139 SetRGB32(&_screen(obj
)->ViewPort
, data
->pen
, data
->rgb
[0], data
->rgb
[1], data
->rgb
[2]);
141 if (GetBitMapAttr(_rp(obj
)->BitMap
, BMA_DEPTH
) > 8)
143 MUI_Redraw(obj
, MADF_DRAWUPDATE
);
150 IPTR
Colorfield__OM_GET(struct IClass
*cl
, Object
* obj
, struct opGet
*msg
)
152 struct Colorfield_DATA
*data
= INST_DATA(cl
, obj
);
153 IPTR
*store
= msg
->opg_Storage
;
155 switch (msg
->opg_AttrID
)
157 case MUIA_Colorfield_Red
:
158 *store
= data
->rgb
[0];
161 case MUIA_Colorfield_Green
:
162 *store
= data
->rgb
[1];
165 case MUIA_Colorfield_Blue
:
166 *store
= data
->rgb
[2];
169 case MUIA_Colorfield_RGB
:
170 *(ULONG
**)store
= data
->rgb
;
173 case MUIA_Colorfield_Pen
:
178 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
184 IPTR
Colorfield__MUIM_Setup(struct IClass
*cl
, Object
*obj
, struct MUIP_Setup
*msg
)
186 struct Colorfield_DATA
*data
= INST_DATA(cl
,obj
);
188 if (!(DoSuperMethodA(cl
, obj
, (Msg
)msg
))) return 0;
190 if (data
->flags
& FLAG_FIXED_PEN
)
192 SetRGB32(&_screen(obj
)->ViewPort
,
202 pen
= ObtainPen(_screen(obj
)->ViewPort
.ColorMap
,
211 data
->flags
|= FLAG_NO_PEN
;
216 data
->pen
= (UBYTE
)pen
;
217 data
->flags
|= FLAG_PEN_ALLOCATED
;
224 IPTR
Colorfield__MUIM_Cleanup(struct IClass
*cl
, Object
*obj
, struct MUIP_Cleanup
*msg
)
226 struct Colorfield_DATA
*data
= INST_DATA(cl
,obj
);
228 if (data
->flags
& FLAG_PEN_ALLOCATED
)
230 ReleasePen(_screen(obj
)->ViewPort
.ColorMap
, data
->pen
);
231 data
->flags
&= ~FLAG_PEN_ALLOCATED
;
234 data
->flags
&= ~FLAG_NO_PEN
;
236 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
239 IPTR
Colorfield__MUIM_AskMinMax(struct IClass
*cl
, Object
*obj
, struct MUIP_AskMinMax
*msg
)
241 DoSuperMethodA(cl
,obj
,(Msg
)msg
);
243 msg
->MinMaxInfo
->MinWidth
+= 1;
244 msg
->MinMaxInfo
->MinHeight
+= 1;
245 msg
->MinMaxInfo
->DefWidth
+= 16;
246 msg
->MinMaxInfo
->DefHeight
+= 16;
247 msg
->MinMaxInfo
->MaxWidth
= MUI_MAXMAX
;
248 msg
->MinMaxInfo
->MaxHeight
= MUI_MAXMAX
;
253 IPTR
Colorfield__MUIM_Draw(struct IClass
*cl
, Object
*obj
, struct MUIP_Draw
*msg
)
255 struct Colorfield_DATA
*data
= INST_DATA(cl
,obj
);
257 DoSuperMethodA(cl
,obj
,(Msg
)msg
);
259 if (!(msg
->flags
& (MADF_DRAWOBJECT
| MADF_DRAWUPDATE
)))
262 if (data
->flags
& FLAG_NO_PEN
)
264 static UWORD pat
[] = {0x1111,0x2222,0x4444,0x8888};
266 SetAfPt(_rp(obj
), pat
, 2);
267 SetABPenDrMd(_rp(obj
), _pens(obj
)[MPEN_SHADOW
], _pens(obj
)[MPEN_BACKGROUND
],JAM2
);
272 SetABPenDrMd(_rp(obj
), data
->pen
, 0,JAM1
);
275 RectFill(_rp(obj
), _mleft(obj
), _mtop(obj
), _mright(obj
), _mbottom(obj
));
277 SetAfPt(_rp(obj
), NULL
, 0);
282 #if ZUNE_BUILTIN_COLORFIELD
283 BOOPSI_DISPATCHER(IPTR
, Colorfield_Dispatcher
, cl
, obj
, msg
)
285 switch (msg
->MethodID
)
287 case OM_NEW
: return Colorfield__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
288 case OM_SET
: return Colorfield__OM_SET(cl
, obj
, (struct opSet
*)msg
);
289 case OM_GET
: return Colorfield__OM_GET(cl
, obj
, (struct opGet
*)msg
);
290 case MUIM_Setup
: return Colorfield__MUIM_Setup(cl
, obj
, (struct MUIP_Setup
*)msg
);
291 case MUIM_Cleanup
: return Colorfield__MUIM_Cleanup(cl
, obj
, (struct MUIP_Cleanup
*)msg
);
292 case MUIM_AskMinMax
: return Colorfield__MUIM_AskMinMax(cl
, obj
, (struct MUIP_AskMinMax
*)msg
);
293 case MUIM_Draw
: return Colorfield__MUIM_Draw(cl
, obj
, (struct MUIP_Draw
*)msg
);
294 default: return DoSuperMethodA(cl
, obj
, msg
);
297 BOOPSI_DISPATCHER_END
299 const struct __MUIBuiltinClass _MUI_Colorfield_desc
=
303 sizeof(struct Colorfield_DATA
),
304 (void*)Colorfield_Dispatcher
306 #endif /* ZUNE_BUILTIN_COLORFIELD */