When you create your editor view, typically you add other views in the constructor, and
set the target handler to this
in AttachedToWindow.
This is necessary so that your IEObjectEditor derived class will get the messages that the attached views send.
You call TargetObjectChanged with the target IEEditableObject at the end of the constructor, which will
set up the views that you added in the constructor.
Each time you change the target object, you need to call ChangeTargetObject
to notify the object roster about the changes. That is all you need to do.
TargetObjectChanged() | Must be implemented to update the editor if the target object changes. |
UpdateObject() | Must be implemented to update the object based on the editor view. |
IEObjectEditor(BRect frame, const char* name, IEEditableObject *target)Initializes the BView with frame and name, which are passed unchanged to the BView constructor.
virtual ~IEObjectEditor(void);Calls the EditorClosed method of the target IEEditableObject.
void ChangeTargetObject(IEEditableObject *new_target=NULL);
You must call ChangeTargetObject after you changed the target object. You can pass NULL as new_target if the address of the target object was not changed. Otherwise if you reallocated the target object, you need to send the new address in new_target so that other editors of the same object are also updated.
void EditObject(IEEditableObject *an_object); void RemoveObject(IEEditableObject *an_object);
EditObject opens an editor window for an_object. The parent window of the editor window will be the window which this object editor is attached to. This means when the user closes an object editor window, its child windows will also be closed. RemoveObject closes all editor windows of an_object and deletes an_object.
void EditView(BView *a_bview); void SelectView(BView *a_bview); void RemoveView(BView *a_bview);
You can use these methods to edit, select or remove a view from a view editor window.
void MakeCollapsed(int32 collapsemode);
You can influence whether your editor view opens collapsed, expanded or the default.
For example the BView editor will be collapsed if the view has a name, expanded otherwise.
collapsemode can be one of these constants:
Name | Description |
---|---|
IE_COLLAPSE_NO_CHANGE |
The editor view does not change the default collapse mode. This is the default. |
IE_COLLAPSE |
The editor view will collapsed when open. |
IE_EXPAND |
The editor view will expanded when open. |
virtual void TargetObjectChanged(IEEditableObject *new_target);
You have to implement this hook function in order to update the object editor.
There is a public target
data which you have to load new_target
into. It is advised to update the views only if their content is changed to minimize
flickering.
virtual void UpdateObject();
You have to implement this hook function in order to update the object from the editor view. In other words you need to convert the views state into the object, just like when the user applies his changes.