2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
6 /* Dtpic.mui. Source based on the one from MUIUndoc */
8 #define MUIMASTER_YES_INLINE_STDARG
13 #include <graphics/gfx.h>
14 #include <graphics/view.h>
15 #include <clib/alib_protos.h>
17 #include <datatypes/datatypesclass.h>
18 #include <datatypes/pictureclass.h>
20 #include <proto/exec.h>
21 #include <proto/graphics.h>
22 #include <proto/utility.h>
23 #include <proto/intuition.h>
24 #include <proto/muimaster.h>
25 #include <proto/datatypes.h>
29 /* #define MYDEBUG 1 */
33 #include "muimaster_intern.h"
35 #include "support_classes.h"
36 #include "dtpic_private.h"
38 extern struct Library
*MUIMasterBase
;
44 #define DataTypesBase data->datatypesbase
46 static void killdto(struct Dtpic_DATA
*data
)
53 DisposeDTObject(data
->dto
);
57 if (data
->datatypesbase
)
59 CloseLibrary(data
->datatypesbase
);
64 IPTR
Dtpic__OM_NEW(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
66 struct Dtpic_DATA
*data
;
68 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
71 data
= INST_DATA(cl
, obj
);
73 data
->name
= (STRPTR
)GetTagData(MUIA_Dtpic_Name
, 0, msg
->ops_AttrList
);
75 set(obj
, MUIA_FillArea
, FALSE
);
81 IPTR
Dtpic__MUIM_Setup(struct IClass
*cl
, Object
*obj
, struct MUIP_Setup
*msg
)
83 struct Dtpic_DATA
*data
= INST_DATA(cl
, obj
);
85 if (!DoSuperMethodA(cl
, obj
, (Msg
)msg
)) return FALSE
;
89 if ((data
->datatypesbase
= OpenLibrary("datatypes.library", 39)))
91 /* Prevent DOS Requesters from showing up */
93 struct Process
*me
= (struct Process
*)FindTask(0);
94 APTR oldwinptr
= me
->pr_WindowPtr
;
96 me
->pr_WindowPtr
= (APTR
)-1;
98 data
->dto
= NewDTObject(data
->name
, DTA_GroupID
, GID_PICTURE
,
99 OBP_Precision
, PRECISION_IMAGE
,
100 PDTA_Screen
, _screen(obj
),
101 PDTA_FreeSourceBitMap
, TRUE
,
102 PDTA_DestMode
, PMODE_V43
,
103 PDTA_UseFriendBitMap
, TRUE
,
105 me
->pr_WindowPtr
= oldwinptr
;
109 struct FrameInfo fri
= {0};
111 DoMethod(data
->dto
, DTM_FRAMEBOX
, 0, &fri
, &fri
, sizeof(struct FrameInfo
), 0);
113 if (fri
.fri_Dimensions
.Depth
> 0)
115 if (DoMethod(data
->dto
, DTM_PROCLAYOUT
, 0, 1))
117 get(data
->dto
, PDTA_BitMapHeader
, &data
->bmhd
);
121 GetDTAttrs(data
->dto
, PDTA_DestBitMap
, &data
->bm
, TAG_DONE
);
125 GetDTAttrs(data
->dto
, PDTA_BitMap
, &data
->bm
, TAG_DONE
);
128 if (data
->bm
) return TRUE
;
130 } /* if (data->bmhd) */
132 } /* if (DoMethod(data->dto, DTM_PROCLAYOUT, 0, 1)) */
134 } /* if (fri.fri_Dimensions.Depth > 0) */
136 } /* if (data->dto) */
138 } /* if ((data->datatypesbase = OpenLibrary("datatypes.library", 39))) */
140 } /* if (data->name) */
147 IPTR
Dtpic__MUIM_Cleanup(struct IClass
*cl
, Object
*obj
, struct MUIP_Cleanup
*msg
)
149 struct Dtpic_DATA
*data
= INST_DATA(cl
, obj
);
153 return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
156 IPTR
Dtpic__MUIM_AskMinMax(struct IClass
*cl
, Object
*obj
, struct MUIP_AskMinMax
*msg
)
158 struct Dtpic_DATA
*data
= INST_DATA(cl
, obj
);
161 retval
= DoSuperMethodA(cl
, obj
, (Msg
) msg
);
165 msg
->MinMaxInfo
->MinWidth
+= data
->bmhd
->bmh_Width
;
166 msg
->MinMaxInfo
->MinHeight
+= data
->bmhd
->bmh_Height
;
167 msg
->MinMaxInfo
->DefWidth
+= data
->bmhd
->bmh_Width
;
168 msg
->MinMaxInfo
->DefHeight
+= data
->bmhd
->bmh_Height
;
169 msg
->MinMaxInfo
->MaxWidth
+= data
->bmhd
->bmh_Width
;
170 msg
->MinMaxInfo
->MaxHeight
+= data
->bmhd
->bmh_Height
;
176 IPTR
Dtpic__MUIM_Draw(struct IClass
*cl
, Object
*obj
, struct MUIP_Draw
*msg
)
178 struct Dtpic_DATA
*data
= INST_DATA(cl
, obj
);
180 DoSuperMethodA(cl
, obj
, (Msg
)msg
);
182 if ((msg
->flags
& MADF_DRAWOBJECT
) && data
->bm
)
184 BltBitMapRastPort(data
->bm
, 0, 0, _rp(obj
), _mleft(obj
), _mtop(obj
), _mwidth(obj
), _mheight(obj
), 192);
190 #if ZUNE_BUILTIN_DTPIC
191 BOOPSI_DISPATCHER(IPTR
, Dtpic_Dispatcher
, cl
, obj
, msg
)
193 switch (msg
->MethodID
)
195 case OM_NEW
: return Dtpic__OM_NEW(cl
, obj
, (struct opSet
*)msg
);
196 case MUIM_Setup
: return Dtpic__MUIM_Setup(cl
, obj
, (struct MUIP_Setup
*)msg
);
197 case MUIM_Cleanup
: return Dtpic__MUIM_Cleanup(cl
, obj
, (struct MUIP_Clean
*)msg
);
198 case MUIM_AskMinMax
: return Dtpic__MUIM_AskMinMax(cl
, obj
, (struct MUIP_AskMinMax
*)msg
);
199 case MUIM_Draw
: return Dtpic__MUIM_Draw(cl
, obj
, (struct MUIP_Draw
*)msg
);
200 default: return DoSuperMethodA(cl
, obj
, msg
);
203 BOOPSI_DISPATCHER_END
205 const struct __MUIBuiltinClass _MUI_Dtpic_desc
=
209 sizeof(struct Dtpic_DATA
),
210 (void*)Dtpic_Dispatcher
212 #endif /* ZUNE_BUILTIN_DTPIC */