An application which uses the ObjectHandlerLib must initialize the global ie_object_roster
variable which is available in all add-ons too. You can access the object handler through ie_object_roster
, although this is rarely needed.
The object editor add-ons are stored in a list where the items point to an AddOnInfo
structure:
struct AddOnInfo { char *filename; char *fullpath; image_id imageid; entry_ref ref; bool loaded; IEEditableObject *(*unflatten)(const void *buffer, ssize_t buffersize); IEEditableObject *default_object; char *classname; int32 typecode; };
The structure members speak for themselves. unflatten
is the exported
UnflattenObject
method of the IEEditableObject derived class.
IEObjectRoster(entry_ref *add_ons_directory=NULL);Initializes data members and calls Initialize to load the add-ons. If add_ons_directory is NULL, it tries to load the add-on from a directory called 'AddOns' in the application directory.
virtual ~IEObjectRoster(void);Unloads the add-ons and frees all previously reserved data.
AddOnInfo *AddOnAt(int32 index);
Returns the nth add-on from the add-on list. Same as (AddOnInfo*)AddOnList()->ItemAt(index)
BList *AddOnList(void);
Returns the list where the add-ons are stored. Each item in the list is a pointer to an AddOnInfo structure.
void CloseObject(IEEditableObject *object);
Closes all editor windows which the object is edited in and deletes the object. Same as delete object;
AddOnInfo *FindClass(char *byname); AddOnInfo *FindClass(BArchivable *archivable);
Returns the AddOnInfo pointer of a given data type, or NULL if not found.
void Initialize(entry_ref *add_ons_directory=NULL);
Initialize is called by the constructor to load the add-ons. If add_ons_directory is NULL, it tries to load the add-on from a directory called 'AddOns' in the application directory.
void InsertAddOn(AddOnInfo *ai);
InsertAddOn inserts an add-on in the add-on list. Use this for example if you have
an object editor in your application, not as a separate add-on. Of course you have to fill
the AddOnInfo structure for the add-on. You have to set the loaded
data to false
so that the "add-on" will not be unloaded.
bool Lock(); void Unlock();
Lock the object roster if you access the add-on list
or the editor_list
. The editor_list
is a list of existing IEEditableObjects but is not documented because you never need to access it.
IEObjectEditorWindow *OpenObject(IEEditableObject *object, char *title=NULL, BWindow *parent=NULL);
OpenObject opens an editor window, and returns the window pointer, or NULL if the object has no editor. You can specify the window title, and a parent window. The editor window will be closed if its parent window is closed.