IEObjectEditor


Derives from: BView
Header: IEObjectEditor.h
Library: ObjectHandlerLib.so



Overview

IEObjectEditor is the actual object editor view which derives from BView. You need to derive your own editor from this class to be able to edit an object. Its functionality (with method names in parenthesis):

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.


Hook Functions

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.


Constructor and Destructor


IEObjectEditor()

   IEObjectEditor(BRect frame, const char* name, IEEditableObject *target)
Initializes the BView with frame and name, which are passed unchanged to the BView constructor.



~IEObjectEditor()

    virtual ~IEObjectEditor(void);
Calls the EditorClosed method of the target IEEditableObject.


Member Functions


ChangeTargetObject()

      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.


EditObject()
RemoveObject()

      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.


EditView()
SelectView()
RemoveView()

      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.


MakeCollapsed()

      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.


TargetObjectChanged()

     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.


UpdateObject()

     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.