added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / libs / muimaster / classes / dtpic.c
blob1c6e22b94b540c11c87ad12ee31a675757bd8cfc
1 /*
2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /* Dtpic.mui. Source based on the one from MUIUndoc */
8 #define MUIMASTER_YES_INLINE_STDARG
10 #include <stdio.h>
11 #include <stdlib.h>
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>
27 #include <string.h>
29 /* #define MYDEBUG 1 */
30 #include "debug.h"
32 #include "mui.h"
33 #include "muimaster_intern.h"
34 #include "support.h"
35 #include "support_classes.h"
36 #include "dtpic_private.h"
38 extern struct Library *MUIMasterBase;
40 #ifdef DataTypesBase
41 #undef DataTypesBase
42 #endif
44 #define DataTypesBase data->datatypesbase
46 static void killdto(struct Dtpic_DATA *data)
48 data->bm = NULL;
49 data->bmhd = NULL;
51 if (data->dto)
53 DisposeDTObject(data->dto);
54 data->dto = NULL;
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);
69 if (obj)
71 data = INST_DATA(cl, obj);
73 data->name = (STRPTR)GetTagData(MUIA_Dtpic_Name, 0, msg->ops_AttrList);
75 set(obj, MUIA_FillArea, FALSE);
78 return (IPTR)obj;
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;
87 if (data->name)
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,
104 TAG_DONE);
105 me->pr_WindowPtr = oldwinptr;
107 if (data->dto)
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);
119 if (data->bmhd)
121 GetDTAttrs(data->dto, PDTA_DestBitMap, &data->bm, TAG_DONE);
123 if (!data->bm)
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) */
142 killdto(data);
144 return TRUE;
147 IPTR Dtpic__MUIM_Cleanup(struct IClass *cl, Object *obj, struct MUIP_Cleanup *msg)
149 struct Dtpic_DATA *data = INST_DATA(cl, obj);
151 killdto(data);
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);
159 IPTR retval;
161 retval = DoSuperMethodA(cl, obj, (Msg) msg);
163 if (data->bm)
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;
173 return retval;
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);
187 return 0;
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 =
207 MUIC_Dtpic,
208 MUIC_Area,
209 sizeof(struct Dtpic_DATA),
210 (void*)Dtpic_Dispatcher
212 #endif /* ZUNE_BUILTIN_DTPIC */