I have implemented the OM_NEW method as follows:
Code: Select all
uint32 om_new(Class *cl, Object *o, Msg msg)
{
struct ClassBase *libBase = (struct ClassBase *)cl->cl_UserData;
struct localObjectData *lod = NULL;
uint32 retVal = 0L;
if ( (retVal = IIntuition->IDoSuperMethodA(cl, o, msg)) )
{
// Obtain pointer to our object's local instance data.
if ( (lod = (struct localObjectData *)INST_DATA(cl, retVal)) )
{
// Create space.gadget.
if ( !(lod->space = IIntuition->NewObject(SpaceClass, NULL,
SPACE_MinWidth, 200,
SPACE_MinHeight, 100,
SPACE_RenderHook, renderHook, // pointer to my hook that renders the text
TAG_DONE)) )
{
IIntuition->ICoerceMethod(cl, (Object *) retVal, OM_DISPOSE);
retVal = 0;
}
}
}
return retVal;
}
Code: Select all
uint32 om_dispose(Class *cl, Object *o, Msg msg)
{
struct ClassBase *libBase = (struct ClassBase *)cl->cl_UserData;
struct localObjectData *lod = (struct localObjectData *)INST_DATA(cl, o);
// Dispose of the space gadget.
if ( lod->space ) IIntuition->DisposeObject(lod->space);
// Let superclass dispose of the textbox object.
IIntuition->IDoSuperMethodA(cl, o, msg);
return 0;
}