2 Copyright © 2002-2015, 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 /****** Colorfield.mui/MUIA_Colorfield_Pen ***********************************
42 * MUIA_Colorfield_Pen -- (V4) [ISG], ULONG
45 * The used pen. If not set explicitly, a new one is obtained
48 * This attribute was incorrectly documented as gettable-only in the MUI
51 ******************************************************************************
55 /****** Colorfield.mui/MUIA_Colorfield_Red ***********************************
58 * MUIA_Colorfield_Red -- (V4) [ISG], ULONG
61 * The red component of the color field as an unsigned 32-bit value
65 * MUIA_Colorfield_RGB, MUIA_Colorfield_Green, MUIA_Colorfield_Blue
67 ******************************************************************************
71 /****** Colorfield.mui/MUIA_Colorfield_Green *********************************
74 * MUIA_Colorfield_Green -- (V4) [ISG], ULONG
77 * The green component of the color field as an unsigned 32-bit value
81 * MUIA_Colorfield_RGB, MUIA_Colorfield_Red, MUIA_Colorfield_Blue
83 ******************************************************************************
87 /****** Colorfield.mui/MUIA_Colorfield_Blue **********************************
90 * MUIA_Colorfield_Blue -- (V4) [ISG], ULONG
93 * The blue component of the color field as an unsigned 32-bit value
97 * MUIA_Colorfield_RGB, MUIA_Colorfield_Red, MUIA_Colorfield_Green
99 ******************************************************************************
103 /****** Colorfield.mui/MUIA_Colorfield_RGB ***********************************
106 * MUIA_Colorfield_RGB -- (V4) [ISG], ULONG *
109 * The red, green and blue components of the color field as an array of
110 * unsigned 32-bit values (0 to 0xFFFFFFFF).
113 * MUIA_Colorfield_Red, MUIA_Colorfield_Green, MUIA_Colorfield_Blue
115 ******************************************************************************
119 IPTR
Colorfield__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
121 struct Colorfield_DATA
*data
;
122 struct TagItem
*tags
;
126 obj
= (Object
*) DoSuperMethodA(cl
, obj
, (Msg
) msg
);
130 data
= INST_DATA(cl
, obj
);
132 /* parse initial taglist */
133 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
137 case MUIA_Colorfield_Red
:
138 data
->rgb
[0] = (ULONG
) tag
->ti_Data
;
141 case MUIA_Colorfield_Green
:
142 data
->rgb
[1] = (ULONG
) tag
->ti_Data
;
145 case MUIA_Colorfield_Blue
:
146 data
->rgb
[2] = (ULONG
) tag
->ti_Data
;
149 case MUIA_Colorfield_RGB
:
150 rgb
= (ULONG
*) tag
->ti_Data
;
151 data
->rgb
[0] = *rgb
++;
152 data
->rgb
[1] = *rgb
++;
153 data
->rgb
[2] = *rgb
++;
156 case MUIA_Colorfield_Pen
:
157 data
->pen
= (UBYTE
) tag
->ti_Data
;
158 data
->flags
|= FLAG_FIXED_PEN
;
167 IPTR
Colorfield__OM_SET(struct IClass
*cl
, Object
*obj
,
170 struct Colorfield_DATA
*data
;
172 struct TagItem
*tags
;
177 struct TagItem extra_tags
[] = {{TAG_IGNORE
, 0}, {TAG_IGNORE
, 0},
178 {TAG_IGNORE
, 0}, {TAG_IGNORE
, 0},
179 {TAG_MORE
, (IPTR
)msg
->ops_AttrList
}};
181 data
= INST_DATA(cl
, obj
);
183 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
187 case MUIA_Colorfield_Red
:
188 data
->rgb
[0] = (ULONG
) tag
->ti_Data
;
190 extra_tags
[3].ti_Tag
= MUIA_Colorfield_RGB
;
193 case MUIA_Colorfield_Green
:
194 data
->rgb
[1] = (ULONG
) tag
->ti_Data
;
196 extra_tags
[3].ti_Tag
= MUIA_Colorfield_RGB
;
199 case MUIA_Colorfield_Blue
:
200 data
->rgb
[2] = (ULONG
) tag
->ti_Data
;
202 extra_tags
[3].ti_Tag
= MUIA_Colorfield_RGB
;
205 case MUIA_Colorfield_RGB
:
206 rgb
= (ULONG
*) tag
->ti_Data
;
207 data
->rgb
[0] = *rgb
++;
208 data
->rgb
[1] = *rgb
++;
209 data
->rgb
[2] = *rgb
++;
211 extra_tags
[0].ti_Tag
= MUIA_Colorfield_Red
;
212 extra_tags
[1].ti_Tag
= MUIA_Colorfield_Green
;
213 extra_tags
[2].ti_Tag
= MUIA_Colorfield_Blue
;
216 case MUIA_Colorfield_Pen
:
217 if (data
->flags
& FLAG_PEN_ALLOCATED
)
219 ReleasePen(_screen(obj
)->ViewPort
.ColorMap
, data
->pen
);
220 data
->flags
&= ~(FLAG_PEN_ALLOCATED
| FLAG_NO_PEN
);
222 data
->pen
= (UBYTE
) tag
->ti_Data
;
223 data
->flags
|= FLAG_FIXED_PEN
;
230 /* Prepare notification values for inter-dependent attributes */
231 extra_tags
[0].ti_Data
= data
->rgb
[0];
232 extra_tags
[1].ti_Data
= data
->rgb
[1];
233 extra_tags
[2].ti_Data
= data
->rgb
[2];
234 extra_tags
[3].ti_Data
= (IPTR
) data
->rgb
;
235 supMsg
.MethodID
= msg
->MethodID
;
236 supMsg
.ops_AttrList
= extra_tags
;
237 supMsg
.ops_GInfo
= msg
->ops_GInfo
;
239 retval
= DoSuperMethodA(cl
, obj
, (Msg
) &supMsg
);
241 if (newcol
&& (_flags(obj
) & MADF_SETUP
)
242 && !(data
->flags
& FLAG_NO_PEN
))
244 SetRGB32(&_screen(obj
)->ViewPort
, data
->pen
, data
->rgb
[0],
245 data
->rgb
[1], data
->rgb
[2]);
247 if (GetBitMapAttr(_rp(obj
)->BitMap
, BMA_DEPTH
) > 8)
249 MUI_Redraw(obj
, MADF_DRAWUPDATE
);
256 IPTR
Colorfield__OM_GET(struct IClass
*cl
, Object
*obj
,
259 struct Colorfield_DATA
*data
= INST_DATA(cl
, obj
);
260 IPTR
*store
= msg
->opg_Storage
;
262 switch (msg
->opg_AttrID
)
264 case MUIA_Colorfield_Red
:
265 *store
= data
->rgb
[0];
268 case MUIA_Colorfield_Green
:
269 *store
= data
->rgb
[1];
272 case MUIA_Colorfield_Blue
:
273 *store
= data
->rgb
[2];
276 case MUIA_Colorfield_RGB
:
277 *(ULONG
**) store
= data
->rgb
;
280 case MUIA_Colorfield_Pen
:
285 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
291 IPTR
Colorfield__MUIM_Setup(struct IClass
*cl
, Object
*obj
,
292 struct MUIP_Setup
*msg
)
294 struct Colorfield_DATA
*data
= INST_DATA(cl
, obj
);
296 if (!(DoSuperMethodA(cl
, obj
, (Msg
) msg
)))
299 if (data
->flags
& FLAG_FIXED_PEN
)
301 SetRGB32(&_screen(obj
)->ViewPort
,
302 data
->pen
, data
->rgb
[0], data
->rgb
[1], data
->rgb
[2]);
308 pen
= ObtainPen(_screen(obj
)->ViewPort
.ColorMap
,
310 data
->rgb
[0], data
->rgb
[1], data
->rgb
[2], PENF_EXCLUSIVE
);
314 data
->flags
|= FLAG_NO_PEN
;
319 data
->pen
= (UBYTE
) pen
;
320 data
->flags
|= FLAG_PEN_ALLOCATED
;
327 IPTR
Colorfield__MUIM_Cleanup(struct IClass
*cl
, Object
*obj
,
328 struct MUIP_Cleanup
*msg
)
330 struct Colorfield_DATA
*data
= INST_DATA(cl
, obj
);
332 if (data
->flags
& FLAG_PEN_ALLOCATED
)
334 ReleasePen(_screen(obj
)->ViewPort
.ColorMap
, data
->pen
);
335 data
->flags
&= ~FLAG_PEN_ALLOCATED
;
338 data
->flags
&= ~FLAG_NO_PEN
;
340 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
343 IPTR
Colorfield__MUIM_AskMinMax(struct IClass
*cl
, Object
*obj
,
344 struct MUIP_AskMinMax
*msg
)
346 DoSuperMethodA(cl
, obj
, (Msg
) msg
);
348 msg
->MinMaxInfo
->MinWidth
+= 1;
349 msg
->MinMaxInfo
->MinHeight
+= 1;
350 msg
->MinMaxInfo
->DefWidth
+= 16;
351 msg
->MinMaxInfo
->DefHeight
+= 16;
352 msg
->MinMaxInfo
->MaxWidth
= MUI_MAXMAX
;
353 msg
->MinMaxInfo
->MaxHeight
= MUI_MAXMAX
;
358 IPTR
Colorfield__MUIM_Draw(struct IClass
*cl
, Object
*obj
,
359 struct MUIP_Draw
*msg
)
361 struct Colorfield_DATA
*data
= INST_DATA(cl
, obj
);
363 DoSuperMethodA(cl
, obj
, (Msg
) msg
);
365 if (!(msg
->flags
& (MADF_DRAWOBJECT
| MADF_DRAWUPDATE
)))
368 if (data
->flags
& FLAG_NO_PEN
)
370 static UWORD pat
[] = { 0x1111, 0x2222, 0x4444, 0x8888 };
372 SetAfPt(_rp(obj
), pat
, 2);
373 SetABPenDrMd(_rp(obj
), _pens(obj
)[MPEN_SHADOW
],
374 _pens(obj
)[MPEN_BACKGROUND
], JAM2
);
379 SetABPenDrMd(_rp(obj
), data
->pen
, 0, JAM1
);
382 RectFill(_rp(obj
), _mleft(obj
), _mtop(obj
), _mright(obj
),
385 SetAfPt(_rp(obj
), NULL
, 0);
390 #if ZUNE_BUILTIN_COLORFIELD
391 BOOPSI_DISPATCHER(IPTR
, Colorfield_Dispatcher
, cl
, obj
, msg
)
393 switch (msg
->MethodID
)
396 return Colorfield__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
398 return Colorfield__OM_SET(cl
, obj
, (struct opSet
*)msg
);
400 return Colorfield__OM_GET(cl
, obj
, (struct opGet
*)msg
);
402 return Colorfield__MUIM_Setup(cl
, obj
, (struct MUIP_Setup
*)msg
);
404 return Colorfield__MUIM_Cleanup(cl
, obj
,
405 (struct MUIP_Cleanup
*)msg
);
407 return Colorfield__MUIM_AskMinMax(cl
, obj
,
408 (struct MUIP_AskMinMax
*)msg
);
410 return Colorfield__MUIM_Draw(cl
, obj
, (struct MUIP_Draw
*)msg
);
412 return DoSuperMethodA(cl
, obj
, msg
);
415 BOOPSI_DISPATCHER_END
417 const struct __MUIBuiltinClass _MUI_Colorfield_desc
=
421 sizeof(struct Colorfield_DATA
),
422 (void *) Colorfield_Dispatcher
424 #endif /* ZUNE_BUILTIN_COLORFIELD */