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 const struct TagItem
*tags
;
46 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
47 if (!obj
) return FALSE
;
49 data
= INST_DATA(cl
, obj
);
51 /* parse initial taglist */
52 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
56 case MUIA_Colorfield_Red
:
57 data
->rgb
[0] = (ULONG
)tag
->ti_Data
;
60 case MUIA_Colorfield_Green
:
61 data
->rgb
[1] = (ULONG
)tag
->ti_Data
;
64 case MUIA_Colorfield_Blue
:
65 data
->rgb
[2] = (ULONG
)tag
->ti_Data
;
68 case MUIA_Colorfield_RGB
:
69 rgb
= (ULONG
*)tag
->ti_Data
;
70 data
->rgb
[0] = *rgb
++;
71 data
->rgb
[1] = *rgb
++;
72 data
->rgb
[2] = *rgb
++;
75 case MUIA_Colorfield_Pen
:
76 data
->pen
= (UBYTE
)tag
->ti_Data
;
77 data
->pen
= FLAG_FIXED_PEN
;
86 IPTR
Colorfield__OM_SET(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
88 struct Colorfield_DATA
*data
;
89 const struct TagItem
*tags
;
95 data
= INST_DATA(cl
, obj
);
97 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
101 case MUIA_Colorfield_Red
:
102 data
->rgb
[0] = (ULONG
)tag
->ti_Data
;
106 case MUIA_Colorfield_Green
:
107 data
->rgb
[1] = (ULONG
)tag
->ti_Data
;
111 case MUIA_Colorfield_Blue
:
112 data
->rgb
[2] = (ULONG
)tag
->ti_Data
;
116 case MUIA_Colorfield_RGB
:
117 rgb
= (ULONG
*)tag
->ti_Data
;
118 data
->rgb
[0] = *rgb
++;
119 data
->rgb
[1] = *rgb
++;
120 data
->rgb
[2] = *rgb
++;
124 case MUIA_Colorfield_Pen
:
125 if (data
->flags
& FLAG_PEN_ALLOCATED
)
127 ReleasePen(_screen(obj
)->ViewPort
.ColorMap
, data
->pen
);
128 data
->flags
&= ~(FLAG_PEN_ALLOCATED
| FLAG_NO_PEN
);
130 data
->pen
= (UBYTE
)data
->pen
;
131 data
->flags
|= FLAG_FIXED_PEN
;
137 retval
= DoSuperMethodA(cl
, obj
, (Msg
)msg
);
139 if (newcol
&& (_flags(obj
) & MADF_SETUP
) && !(data
->flags
& FLAG_NO_PEN
))
141 SetRGB32(&_screen(obj
)->ViewPort
, data
->pen
, data
->rgb
[0], data
->rgb
[1], data
->rgb
[2]);
143 if (GetBitMapAttr(_rp(obj
)->BitMap
, BMA_DEPTH
) > 8)
145 MUI_Redraw(obj
, MADF_DRAWUPDATE
);
152 IPTR
Colorfield__OM_GET(struct IClass
*cl
, Object
* obj
, struct opGet
*msg
)
154 struct Colorfield_DATA
*data
= INST_DATA(cl
, obj
);
155 IPTR
*store
= msg
->opg_Storage
;
157 switch (msg
->opg_AttrID
)
159 case MUIA_Colorfield_Red
:
160 *store
= data
->rgb
[0];
163 case MUIA_Colorfield_Green
:
164 *store
= data
->rgb
[1];
167 case MUIA_Colorfield_Blue
:
168 *store
= data
->rgb
[2];
171 case MUIA_Colorfield_RGB
:
172 *(ULONG
**)store
= data
->rgb
;
175 case MUIA_Colorfield_Pen
:
180 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
186 IPTR
Colorfield__MUIM_Setup(struct IClass
*cl
, Object
*obj
, struct MUIP_Setup
*msg
)
188 struct Colorfield_DATA
*data
= INST_DATA(cl
,obj
);
190 if (!(DoSuperMethodA(cl
, obj
, (Msg
)msg
))) return 0;
192 if (data
->flags
& FLAG_FIXED_PEN
)
194 SetRGB32(&_screen(obj
)->ViewPort
,
204 pen
= ObtainPen(_screen(obj
)->ViewPort
.ColorMap
,
213 data
->flags
|= FLAG_NO_PEN
;
218 data
->pen
= (UBYTE
)pen
;
219 data
->flags
|= FLAG_PEN_ALLOCATED
;
226 IPTR
Colorfield__MUIM_Cleanup(struct IClass
*cl
, Object
*obj
, struct MUIP_Cleanup
*msg
)
228 struct Colorfield_DATA
*data
= INST_DATA(cl
,obj
);
230 if (data
->flags
& FLAG_PEN_ALLOCATED
)
232 ReleasePen(_screen(obj
)->ViewPort
.ColorMap
, data
->pen
);
233 data
->flags
&= ~FLAG_PEN_ALLOCATED
;
236 data
->flags
&= ~FLAG_NO_PEN
;
238 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
241 IPTR
Colorfield__MUIM_AskMinMax(struct IClass
*cl
, Object
*obj
, struct MUIP_AskMinMax
*msg
)
243 DoSuperMethodA(cl
,obj
,(Msg
)msg
);
245 msg
->MinMaxInfo
->MinWidth
+= 1;
246 msg
->MinMaxInfo
->MinHeight
+= 1;
247 msg
->MinMaxInfo
->DefWidth
+= 16;
248 msg
->MinMaxInfo
->DefHeight
+= 16;
249 msg
->MinMaxInfo
->MaxWidth
= MUI_MAXMAX
;
250 msg
->MinMaxInfo
->MaxHeight
= MUI_MAXMAX
;
255 IPTR
Colorfield__MUIM_Draw(struct IClass
*cl
, Object
*obj
, struct MUIP_Draw
*msg
)
257 struct Colorfield_DATA
*data
= INST_DATA(cl
,obj
);
259 DoSuperMethodA(cl
,obj
,(Msg
)msg
);
261 if (!(msg
->flags
& (MADF_DRAWOBJECT
| MADF_DRAWUPDATE
)))
264 if (data
->flags
& FLAG_NO_PEN
)
266 static UWORD pat
[] = {0x1111,0x2222,0x4444,0x8888};
268 SetAfPt(_rp(obj
), pat
, 2);
269 SetABPenDrMd(_rp(obj
), _pens(obj
)[MPEN_SHADOW
], _pens(obj
)[MPEN_BACKGROUND
],JAM2
);
274 SetABPenDrMd(_rp(obj
), data
->pen
, 0,JAM1
);
277 RectFill(_rp(obj
), _mleft(obj
), _mtop(obj
), _mright(obj
), _mbottom(obj
));
279 SetAfPt(_rp(obj
), NULL
, 0);
284 #if ZUNE_BUILTIN_COLORFIELD
285 BOOPSI_DISPATCHER(IPTR
, Colorfield_Dispatcher
, cl
, obj
, msg
)
287 switch (msg
->MethodID
)
289 case OM_NEW
: return Colorfield__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
290 case OM_SET
: return Colorfield__OM_SET(cl
, obj
, (struct opSet
*)msg
);
291 case OM_GET
: return Colorfield__OM_GET(cl
, obj
, (struct opGet
*)msg
);
292 case MUIM_Setup
: return Colorfield__MUIM_Setup(cl
, obj
, (struct MUIP_Setup
*)msg
);
293 case MUIM_Cleanup
: return Colorfield__MUIM_Cleanup(cl
, obj
, (struct MUIP_Cleanup
*)msg
);
294 case MUIM_AskMinMax
: return Colorfield__MUIM_AskMinMax(cl
, obj
, (struct MUIP_AskMinMax
*)msg
);
295 case MUIM_Draw
: return Colorfield__MUIM_Draw(cl
, obj
, (struct MUIP_Draw
*)msg
);
296 default: return DoSuperMethodA(cl
, obj
, msg
);
299 BOOPSI_DISPATCHER_END
301 const struct __MUIBuiltinClass _MUI_Colorfield_desc
=
305 sizeof(struct Colorfield_DATA
),
306 (void*)Colorfield_Dispatcher
308 #endif /* ZUNE_BUILTIN_COLORFIELD */