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"
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
;
39 const struct TagItem
*tags
;
42 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
43 if (!obj
) return FALSE
;
45 data
= INST_DATA(cl
, obj
);
46 /* Format identifies need to be long enforced because of RawDoFmt() limits */
47 snprintf(data
->penspec
.ps_buf
, sizeof(data
->penspec
.ps_buf
), "%lc%ld", (LONG
)PST_MUI
, (LONG
)MPEN_TEXT
);
50 /* parse initial taglist */
51 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
55 case MUIA_Pendisplay_Reference
:
56 data
->refobj
= (Object
*)tag
->ti_Data
;
57 DoMethod(data
->refobj
, MUIM_Notify
, MUIA_Pendisplay_Spec
, MUIV_EveryTime
,
58 (IPTR
)obj
, 3, MUIM_Set
, MUIA_Pendisplay_Spec
, MUIV_TriggerValue
);
61 case MUIA_Pendisplay_RGBcolor
:
63 struct MUI_RGBcolor
*rgb
= (struct MUI_RGBcolor
*)tag
->ti_Data
;
64 snprintf(data
->penspec
.ps_buf
, sizeof(data
->penspec
.ps_buf
),
65 "%lc%08lx,%08lx,%08lx", (LONG
)PST_RGB
, rgb
->red
, rgb
->green
, rgb
->blue
);
69 case MUIA_Pendisplay_Spec
:
70 data
->penspec
= *(struct MUI_PenSpec
*)tag
->ti_Data
;
79 IPTR
Pendisplay__OM_DISPOSE(struct IClass
*cl
, Object
*obj
, Msg msg
)
81 struct Pendisplay_DATA
*data
;
83 data
= INST_DATA(cl
, obj
);
86 /* hmm ... kill notify here? But refobj might already have been killed :-\ */
89 return DoSuperMethodA(cl
, obj
, msg
);
92 IPTR
Pendisplay__OM_SET(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
94 struct Pendisplay_DATA
*data
;
95 const struct TagItem
*tags
;
100 data
= INST_DATA(cl
, obj
);
102 for (tags
= msg
->ops_AttrList
; (tag
= NextTagItem(&tags
)); )
106 case MUIA_Pendisplay_Reference
:
109 DoMethod(data
->refobj
, MUIM_KillNotifyObj
, MUIA_Pendisplay_Spec
, (IPTR
)obj
);
112 data
->refobj
= (Object
*)tag
->ti_Data
;
116 DoMethod(data
->refobj
, MUIM_Notify
, MUIA_Pendisplay_Spec
, MUIV_EveryTime
,
117 (IPTR
)obj
, 3, MUIM_Set
, MUIA_Pendisplay_Spec
, MUIV_TriggerValue
);
122 case MUIA_Pendisplay_RGBcolor
:
124 struct MUI_RGBcolor
*rgb
= (struct MUI_RGBcolor
*)tag
->ti_Data
;
126 snprintf(data
->penspec
.ps_buf
, sizeof(data
->penspec
.ps_buf
),
127 "%lc%08lx,%08lx,%08lx", (LONG
)PST_RGB
, rgb
->red
, rgb
->green
, rgb
->blue
);
132 case MUIA_Pendisplay_Spec
:
135 data
->penspec
= *(struct MUI_PenSpec
*)tag
->ti_Data
;
144 retval
= DoSuperMethodA(cl
, obj
, (Msg
)msg
);
146 if (newcol
&& (_flags(obj
) & MADF_SETUP
))
150 MUI_ReleasePen(muiRenderInfo(obj
), data
->pen
);
156 data
->pen
= MUI_ObtainPen(muiRenderInfo(obj
), &data
->penspec
, 0);
159 MUI_Redraw(obj
, MADF_DRAWUPDATE
);
165 IPTR
Pendisplay__OM_GET(struct IClass
*cl
, Object
* obj
, struct opGet
*msg
)
167 struct Pendisplay_DATA
*data
= INST_DATA(cl
, obj
);
168 IPTR
*store
= msg
->opg_Storage
;
170 switch (msg
->opg_AttrID
)
172 case MUIA_Pendisplay_Pen
:
173 *store
= (IPTR
)data
->pen
;
176 case MUIA_Pendisplay_Reference
:
177 *store
= (IPTR
)data
->refobj
;
180 case MUIA_Pendisplay_RGBcolor
:
182 #warning FIXME: MUIA_Pendisplay_RGBColor (only works for RGB pen specs)
183 struct MUI_PenSpec_intern intpenspec
;
184 zune_pen_spec_to_intern(&data
->penspec
, &intpenspec
);
186 switch(intpenspec
.p_type
)
193 data
->rgb
= intpenspec
.p_rgb
;
197 *store
= (IPTR
)&data
->rgb
;
201 case MUIA_Pendisplay_Spec
:
202 *store
= (IPTR
)&data
->penspec
;
206 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
212 IPTR
Pendisplay__MUIM_Setup(struct IClass
*cl
, Object
*obj
, struct MUIP_Setup
*msg
)
214 struct Pendisplay_DATA
*data
= INST_DATA(cl
,obj
);
216 if (!(DoSuperMethodA(cl
, obj
, (Msg
)msg
))) return 0;
220 data
->pen
= MUI_ObtainPen(muiRenderInfo(obj
), &data
->penspec
, 0);
226 IPTR
Pendisplay__MUIM_Cleanup(struct IClass
*cl
, Object
*obj
, struct MUIP_Cleanup
*msg
)
228 struct Pendisplay_DATA
*data
= INST_DATA(cl
,obj
);
232 MUI_ReleasePen(muiRenderInfo(obj
), data
->pen
);
236 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
239 IPTR
Pendisplay__MUIM_AskMinMax(struct IClass
*cl
, Object
*obj
, struct MUIP_AskMinMax
*msg
)
241 DoSuperMethodA(cl
,obj
,(Msg
)msg
);
243 msg
->MinMaxInfo
->MinWidth
+= 3;
244 msg
->MinMaxInfo
->MinHeight
+= 3;
245 msg
->MinMaxInfo
->DefWidth
+= 16;
246 msg
->MinMaxInfo
->DefHeight
+= 16;
247 msg
->MinMaxInfo
->MaxWidth
= MUI_MAXMAX
;
248 msg
->MinMaxInfo
->MaxHeight
= MUI_MAXMAX
;
253 IPTR
Pendisplay__MUIM_Draw(struct IClass
*cl
, Object
*obj
, struct MUIP_Draw
*msg
)
255 struct Pendisplay_DATA
*data
= INST_DATA(cl
,obj
);
258 DoSuperMethodA(cl
,obj
,(Msg
)msg
);
260 if (!(msg
->flags
& (MADF_DRAWOBJECT
| MADF_DRAWUPDATE
)))
267 get(data
->refobj
, MUIA_Pendisplay_Pen
, &val
);
277 static UWORD pat
[] = {0x1111,0x2222,0x4444,0x8888};
279 SetAfPt(_rp(obj
), pat
, 2);
280 SetABPenDrMd(_rp(obj
), _pens(obj
)[MPEN_SHADOW
], _pens(obj
)[MPEN_BACKGROUND
],JAM2
);
285 SetABPenDrMd(_rp(obj
), MUIPEN(color
), 0,JAM1
);
288 RectFill(_rp(obj
), _mleft(obj
), _mtop(obj
), _mright(obj
), _mbottom(obj
));
290 SetAfPt(_rp(obj
), NULL
, 0);
295 IPTR
Pendisplay__MUIM_Pendisplay_SetColormap(struct IClass
*cl
, Object
*obj
, struct MUIP_Pendisplay_SetColormap
*msg
)
297 struct MUI_PenSpec penspec
;
299 snprintf(penspec
.ps_buf
, sizeof(penspec
.ps_buf
), "%lc%ld", (LONG
)PST_CMAP
, msg
->colormap
);
300 set(obj
, MUIA_Pendisplay_Spec
, (IPTR
)&penspec
);
305 IPTR
Pendisplay__MUIM_Pendisplay_SetRGB(struct IClass
*cl
, Object
*obj
, struct MUIP_Pendisplay_SetRGB
*msg
)
307 struct MUI_PenSpec penspec
;
309 snprintf(penspec
.ps_buf
, sizeof(penspec
.ps_buf
), "%lc%08lx,%08lx,%08lx", (LONG
)PST_RGB
, msg
->r
, msg
->g
, msg
->b
);
310 set(obj
, MUIA_Pendisplay_Spec
, (IPTR
)&penspec
);
315 IPTR
Pendisplay__MUIM_Pendisplay_SetMUIPen(struct IClass
*cl
, Object
*obj
, struct MUIP_Pendisplay_SetMUIPen
*msg
)
317 struct MUI_PenSpec penspec
;
319 snprintf(penspec
.ps_buf
, sizeof(penspec
.ps_buf
), "%lc%ld", (LONG
)PST_MUI
, msg
->muipen
);
320 set(obj
, MUIA_Pendisplay_Spec
, (IPTR
)&penspec
);
325 IPTR
Pendisplay__MUIM_DragQuery(struct IClass
*cl
, Object
*obj
, struct MUIP_DragQuery
*msg
)
330 return MUIV_DragQuery_Refuse
;
332 if (get(msg
->obj
, MUIA_Pendisplay_Spec
, &spec
))
333 return MUIV_DragQuery_Accept
;
335 if (get(msg
->obj
, MUIA_Imagedisplay_Spec
, &spec
))
337 if ((NULL
!= spec
) && (strlen(spec
) > 2) && (spec
[0] == '2') && (spec
[1] == ':'))
338 return MUIV_DragQuery_Accept
;
341 return MUIV_DragQuery_Refuse
;
344 IPTR
Pendisplay__MUIM_DragDrop(struct IClass
*cl
, Object
*obj
, struct MUIP_DragDrop
*msg
)
348 if (get(msg
->obj
, MUIA_Pendisplay_Spec
, &spec
))
349 set(obj
, MUIA_Pendisplay_Spec
, spec
);
350 else if (get(msg
->obj
, MUIA_Imagedisplay_Spec
, &spec
))
351 set(obj
, MUIA_Pendisplay_Spec
, spec
+2);
355 #if ZUNE_BUILTIN_PENDISPLAY
356 BOOPSI_DISPATCHER(IPTR
, Pendisplay_Dispatcher
, cl
, obj
, msg
)
358 switch (msg
->MethodID
)
360 case OM_NEW
: return Pendisplay__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
361 case OM_DISPOSE
: return Pendisplay__OM_DISPOSE(cl
, obj
, msg
);
362 case OM_SET
: return Pendisplay__OM_SET(cl
, obj
, (struct opSet
*)msg
);
363 case OM_GET
: return Pendisplay__OM_GET(cl
, obj
, (struct opGet
*)msg
);
364 case MUIM_Setup
: return Pendisplay__MUIM_Setup(cl
, obj
, (struct MUIP_Setup
*)msg
);
365 case MUIM_Cleanup
: return Pendisplay__MUIM_Cleanup(cl
, obj
, (struct MUIP_Cleanup
*)msg
);
366 case MUIM_AskMinMax
: return Pendisplay__MUIM_AskMinMax(cl
, obj
, (struct MUIP_AskMinMax
*)msg
);
367 case MUIM_Draw
: return Pendisplay__MUIM_Draw(cl
, obj
, (struct MUIP_Draw
*)msg
);
368 case MUIM_Pendisplay_SetColormap
: return Pendisplay__MUIM_Pendisplay_SetColormap(cl
, obj
, (struct MUIP_Pendisplay_SetColormap
*)msg
);
369 case MUIM_Pendisplay_SetMUIPen
: return Pendisplay__MUIM_Pendisplay_SetMUIPen(cl
, obj
, (struct MUIP_Pendisplay_SetMUIPen
*)msg
);
370 case MUIM_Pendisplay_SetRGB
: return Pendisplay__MUIM_Pendisplay_SetRGB(cl
, obj
, (struct MUIP_Pendisplay_SetRGB
*)msg
);
371 case MUIM_DragQuery
: return Pendisplay__MUIM_DragQuery(cl
, obj
, (struct MUIP_DragQuery
*)msg
);
372 case MUIM_DragDrop
: return Pendisplay__MUIM_DragDrop(cl
, obj
, (struct MUIP_DragDrop
*)msg
);
373 default: return DoSuperMethodA(cl
, obj
, msg
);
376 BOOPSI_DISPATCHER_END
378 const struct __MUIBuiltinClass _MUI_Pendisplay_desc
=
382 sizeof(struct Pendisplay_DATA
),
383 (void*)Pendisplay_Dispatcher
385 #endif /* ZUNE_BUILTIN_PENDISPLAY */