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"
25 #include "textengine.h"
27 #include "support_classes.h"
28 #include "pendisplay_private.h"
30 /* #define MYDEBUG 1 */
33 extern struct Library
*MUIMasterBase
;
36 IPTR
Pendisplay__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
38 struct Pendisplay_DATA
*data
;
42 obj
= (Object
*) DoSuperMethodA(cl
, obj
, (Msg
) msg
);
46 data
= INST_DATA(cl
, obj
);
48 /* Format identifiers need to be long enforced because of RawDoFmt()
50 snprintf(data
->penspec
.buf
, sizeof(data
->penspec
.buf
), "%lc%d",
51 (int)PST_MUI
, (int)MPEN_TEXT
);
54 /* parse initial taglist */
55 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
59 case MUIA_Pendisplay_Reference
:
60 data
->refobj
= (Object
*) tag
->ti_Data
;
61 DoMethod(data
->refobj
, MUIM_Notify
, MUIA_Pendisplay_Spec
,
62 MUIV_EveryTime
, (IPTR
) obj
, 3, MUIM_Set
,
63 MUIA_Pendisplay_Spec
, MUIV_TriggerValue
);
66 case MUIA_Pendisplay_RGBcolor
:
68 struct MUI_RGBcolor
*rgb
=
69 (struct MUI_RGBcolor
*)tag
->ti_Data
;
70 snprintf(data
->penspec
.buf
, sizeof(data
->penspec
.buf
),
71 "%lc%08x,%08x,%08x", (int)PST_RGB
,
72 (unsigned int)rgb
->red
, (unsigned int)rgb
->green
,
73 (unsigned int)rgb
->blue
);
77 case MUIA_Pendisplay_Spec
:
78 data
->penspec
= *(struct MUI_PenSpec
*)tag
->ti_Data
;
87 IPTR
Pendisplay__OM_DISPOSE(struct IClass
*cl
, Object
*obj
, Msg msg
)
89 struct Pendisplay_DATA
*data
;
91 data
= INST_DATA(cl
, obj
);
94 /* kill notify here? But refobj might already have been killed :-\ */
97 return DoSuperMethodA(cl
, obj
, msg
);
100 IPTR
Pendisplay__OM_SET(struct IClass
*cl
, Object
*obj
,
103 struct Pendisplay_DATA
*data
;
104 struct TagItem
*tags
;
109 struct TagItem extra_tags
[] = {{TAG_IGNORE
, 0}, {TAG_IGNORE
, 0},
110 {TAG_IGNORE
, 0}, {TAG_MORE
, (IPTR
)msg
->ops_AttrList
}};
112 data
= INST_DATA(cl
, obj
);
114 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
));)
118 case MUIA_Pendisplay_Reference
:
121 DoMethod(data
->refobj
, MUIM_KillNotifyObj
,
122 MUIA_Pendisplay_Spec
, (IPTR
) obj
);
125 data
->refobj
= (Object
*) tag
->ti_Data
;
129 DoMethod(data
->refobj
, MUIM_Notify
, MUIA_Pendisplay_Spec
,
130 MUIV_EveryTime
, (IPTR
) obj
, 3, MUIM_Set
,
131 MUIA_Pendisplay_Spec
, MUIV_TriggerValue
);
134 extra_tags
[0].ti_Tag
= MUIA_Pendisplay_Pen
;
135 extra_tags
[1].ti_Tag
= MUIA_Pendisplay_RGBcolor
;
136 extra_tags
[2].ti_Tag
= MUIA_Pendisplay_Spec
;
139 case MUIA_Pendisplay_RGBcolor
:
141 struct MUI_RGBcolor
*rgb
=
142 (struct MUI_RGBcolor
*)tag
->ti_Data
;
144 snprintf(data
->penspec
.buf
, sizeof(data
->penspec
.buf
),
145 "%lc%08x,%08x,%08x", (int)PST_RGB
,
146 (unsigned int)rgb
->red
, (unsigned int)rgb
->green
,
147 (unsigned int)rgb
->blue
);
150 extra_tags
[0].ti_Tag
= MUIA_Pendisplay_Pen
;
151 extra_tags
[2].ti_Tag
= MUIA_Pendisplay_Spec
;
154 case MUIA_Pendisplay_Spec
:
157 data
->penspec
= *(struct MUI_PenSpec
*)tag
->ti_Data
;
160 extra_tags
[0].ti_Tag
= MUIA_Pendisplay_Pen
;
161 extra_tags
[1].ti_Tag
= MUIA_Pendisplay_RGBcolor
;
168 if (newcol
&& (_flags(obj
) & MADF_SETUP
))
172 MUI_ReleasePen(muiRenderInfo(obj
), data
->pen
);
179 MUI_ObtainPen(muiRenderInfo(obj
), &data
->penspec
, 0);
182 MUI_Redraw(obj
, MADF_DRAWUPDATE
);
185 GetRGB32(muiRenderInfo(obj
)->mri_Colormap
, data
->pen
& 0xffff, 1,
186 (ULONG
*)&data
->rgb
);
188 extra_tags
[1].ti_Tag
= TAG_IGNORE
;
190 /* Prepare notification values for attributes affected by pen change */
191 extra_tags
[0].ti_Data
= data
->pen
& 0xffff;
192 extra_tags
[1].ti_Data
= (IPTR
) &data
->rgb
;
193 extra_tags
[2].ti_Data
= (IPTR
) &data
->penspec
;
195 supMsg
.MethodID
= msg
->MethodID
;
196 supMsg
.ops_AttrList
= extra_tags
;
197 supMsg
.ops_GInfo
= msg
->ops_GInfo
;
201 retval
= DoSuperMethodA(cl
, obj
, (Msg
) msg
);
206 IPTR
Pendisplay__OM_GET(struct IClass
*cl
, Object
*obj
,
209 struct Pendisplay_DATA
*data
= INST_DATA(cl
, obj
);
210 IPTR
*store
= msg
->opg_Storage
;
212 /* Redirect queries to the object we reference, if any */
213 if (data
->refobj
!= NULL
&& msg
->opg_AttrID
!= MUIA_Pendisplay_Reference
)
214 return DoMethodA(data
->refobj
, (Msg
) msg
);
216 switch (msg
->opg_AttrID
)
218 case MUIA_Pendisplay_Pen
:
219 *store
= (IPTR
) data
->pen
& 0xffff;
222 case MUIA_Pendisplay_Reference
:
223 *store
= (IPTR
) data
->refobj
;
226 case MUIA_Pendisplay_RGBcolor
:
228 struct MUI_PenSpec_intern intpenspec
;
229 zune_pen_spec_to_intern(&data
->penspec
, &intpenspec
);
231 switch (intpenspec
.p_type
)
236 GetRGB32(muiRenderInfo(obj
)->mri_Colormap
,
237 data
->pen
& 0xffff, 1, (ULONG
*)&data
->rgb
);
240 data
->rgb
= intpenspec
.p_rgb
;
244 if (data
->pen
!= -1 || intpenspec
.p_type
== PST_RGB
)
245 *store
= (IPTR
) &data
->rgb
;
251 case MUIA_Pendisplay_Spec
:
252 *store
= (IPTR
) &data
->penspec
;
256 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
262 IPTR
Pendisplay__MUIM_Setup(struct IClass
*cl
, Object
*obj
,
263 struct MUIP_Setup
*msg
)
265 struct Pendisplay_DATA
*data
= INST_DATA(cl
, obj
);
267 if (!(DoSuperMethodA(cl
, obj
, (Msg
) msg
)))
272 data
->pen
= MUI_ObtainPen(muiRenderInfo(obj
), &data
->penspec
, 0);
278 IPTR
Pendisplay__MUIM_Cleanup(struct IClass
*cl
, Object
*obj
,
279 struct MUIP_Cleanup
*msg
)
281 struct Pendisplay_DATA
*data
= INST_DATA(cl
, obj
);
285 MUI_ReleasePen(muiRenderInfo(obj
), data
->pen
);
289 return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
292 IPTR
Pendisplay__MUIM_AskMinMax(struct IClass
*cl
, Object
*obj
,
293 struct MUIP_AskMinMax
*msg
)
295 DoSuperMethodA(cl
, obj
, (Msg
) msg
);
297 msg
->MinMaxInfo
->MinWidth
+= 3;
298 msg
->MinMaxInfo
->MinHeight
+= 3;
299 msg
->MinMaxInfo
->DefWidth
+= 16;
300 msg
->MinMaxInfo
->DefHeight
+= 16;
301 msg
->MinMaxInfo
->MaxWidth
= MUI_MAXMAX
;
302 msg
->MinMaxInfo
->MaxHeight
= MUI_MAXMAX
;
307 IPTR
Pendisplay__MUIM_Draw(struct IClass
*cl
, Object
*obj
,
308 struct MUIP_Draw
*msg
)
310 struct Pendisplay_DATA
*data
= INST_DATA(cl
, obj
);
313 DoSuperMethodA(cl
, obj
, (Msg
) msg
);
315 if (!(msg
->flags
& (MADF_DRAWOBJECT
| MADF_DRAWUPDATE
)))
322 get(data
->refobj
, MUIA_Pendisplay_Pen
, &val
);
332 static UWORD pat
[] = { 0x1111, 0x2222, 0x4444, 0x8888 };
334 SetAfPt(_rp(obj
), pat
, 2);
335 SetABPenDrMd(_rp(obj
), _pens(obj
)[MPEN_SHADOW
],
336 _pens(obj
)[MPEN_BACKGROUND
], JAM2
);
341 SetABPenDrMd(_rp(obj
), MUIPEN(color
), 0, JAM1
);
344 RectFill(_rp(obj
), _mleft(obj
), _mtop(obj
), _mright(obj
),
347 SetAfPt(_rp(obj
), NULL
, 0);
352 IPTR
Pendisplay__MUIM_Pendisplay_SetColormap(struct IClass
*cl
,
353 Object
*obj
, struct MUIP_Pendisplay_SetColormap
*msg
)
355 struct MUI_PenSpec penspec
;
357 snprintf(penspec
.buf
, sizeof(penspec
.buf
), "%lc%d", (int)PST_CMAP
,
359 set(obj
, MUIA_Pendisplay_Spec
, (IPTR
) &penspec
);
364 IPTR
Pendisplay__MUIM_Pendisplay_SetRGB(struct IClass
*cl
, Object
*obj
,
365 struct MUIP_Pendisplay_SetRGB
*msg
)
367 struct MUI_PenSpec penspec
;
369 snprintf(penspec
.buf
, sizeof(penspec
.buf
), "%lc%08x,%08x,%08x",
370 (int)PST_RGB
, (unsigned int)msg
->r
, (unsigned int)msg
->g
,
371 (unsigned int)msg
->b
);
372 set(obj
, MUIA_Pendisplay_Spec
, (IPTR
) &penspec
);
377 IPTR
Pendisplay__MUIM_Pendisplay_SetMUIPen(struct IClass
*cl
, Object
*obj
,
378 struct MUIP_Pendisplay_SetMUIPen
*msg
)
380 struct MUI_PenSpec penspec
;
382 snprintf(penspec
.buf
, sizeof(penspec
.buf
), "%lc%d", (int)PST_MUI
,
384 set(obj
, MUIA_Pendisplay_Spec
, (IPTR
) &penspec
);
389 IPTR
Pendisplay__MUIM_DragQuery(struct IClass
*cl
, Object
*obj
,
390 struct MUIP_DragQuery
*msg
)
395 return MUIV_DragQuery_Refuse
;
397 if (get(msg
->obj
, MUIA_Pendisplay_Spec
, &spec
))
398 return MUIV_DragQuery_Accept
;
400 if (get(msg
->obj
, MUIA_Imagedisplay_Spec
, &spec
))
402 if ((NULL
!= spec
) && (strlen(spec
) > 2) && (spec
[0] == '2')
404 return MUIV_DragQuery_Accept
;
407 return MUIV_DragQuery_Refuse
;
410 IPTR
Pendisplay__MUIM_DragDrop(struct IClass
*cl
, Object
*obj
,
411 struct MUIP_DragDrop
*msg
)
415 if (get(msg
->obj
, MUIA_Pendisplay_Spec
, &spec
))
416 set(obj
, MUIA_Pendisplay_Spec
, spec
);
417 else if (get(msg
->obj
, MUIA_Imagedisplay_Spec
, &spec
))
418 set(obj
, MUIA_Pendisplay_Spec
, spec
+ 2);
422 #if ZUNE_BUILTIN_PENDISPLAY
423 BOOPSI_DISPATCHER(IPTR
, Pendisplay_Dispatcher
, cl
, obj
, msg
)
425 switch (msg
->MethodID
)
428 return Pendisplay__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
430 return Pendisplay__OM_DISPOSE(cl
, obj
, msg
);
432 return Pendisplay__OM_SET(cl
, obj
, (struct opSet
*)msg
);
434 return Pendisplay__OM_GET(cl
, obj
, (struct opGet
*)msg
);
436 return Pendisplay__MUIM_Setup(cl
, obj
, (struct MUIP_Setup
*)msg
);
438 return Pendisplay__MUIM_Cleanup(cl
, obj
,
439 (struct MUIP_Cleanup
*)msg
);
441 return Pendisplay__MUIM_AskMinMax(cl
, obj
,
442 (struct MUIP_AskMinMax
*)msg
);
444 return Pendisplay__MUIM_Draw(cl
, obj
, (struct MUIP_Draw
*)msg
);
445 case MUIM_Pendisplay_SetColormap
:
446 return Pendisplay__MUIM_Pendisplay_SetColormap(cl
, obj
,
447 (struct MUIP_Pendisplay_SetColormap
*)msg
);
448 case MUIM_Pendisplay_SetMUIPen
:
449 return Pendisplay__MUIM_Pendisplay_SetMUIPen(cl
, obj
,
450 (struct MUIP_Pendisplay_SetMUIPen
*)msg
);
451 case MUIM_Pendisplay_SetRGB
:
452 return Pendisplay__MUIM_Pendisplay_SetRGB(cl
, obj
,
453 (struct MUIP_Pendisplay_SetRGB
*)msg
);
455 return Pendisplay__MUIM_DragQuery(cl
, obj
,
456 (struct MUIP_DragQuery
*)msg
);
458 return Pendisplay__MUIM_DragDrop(cl
, obj
,
459 (struct MUIP_DragDrop
*)msg
);
461 return DoSuperMethodA(cl
, obj
, msg
);
464 BOOPSI_DISPATCHER_END
466 const struct __MUIBuiltinClass _MUI_Pendisplay_desc
=
470 sizeof(struct Pendisplay_DATA
),
471 (void *) Pendisplay_Dispatcher
473 #endif /* ZUNE_BUILTIN_PENDISPLAY */