class DrawableNode

Description

This class encapsulates all of the features of a node which can be drawn by the visual renderer. If, during the pre-render of the scene, a node wishes to register itself with the visual renderer so that it can be drawn, it must be derived from this class.

Proxy class hierarchy

DrawableNode : Traversable

Methods

The DrawableNode class defines the following functions, which are used by the visual renderer to draw the scene in an optimal manner (i.e. minimising the amount of drawing which is needed). Many of these functions are virtual functions to be overridden by the derived classes, although in some cases a default implementation is provided.

    virtual float GetDrawingOrder() const { return m_drawOrder; }
Returns the drawing order value for this node. The default implementation returns the appropriate data member.

    int GetCreateOrder() const { return m_createOrder; }
Returns a number which indicates when this object was created. The larger the number, the later the node was created. This can be used to determine which node appeared before another in the order given in the source file.

    virtual BOOL NeedsDrawing() const
Returns TRUE if this node needs to be drawn (because it has changed since it was last drawn).

    virtual BOOL IsTransparent() const { return m_isTransparent; }
Return TRUE if this node is transparent. ie. it does not completely fill its bounding rectangle, either because not every pixel is written and/or and alpha blending component is used. The default implementation returns TRUE if the previous and current bounding boxes are different. A derived class which implements this method, must include the result of this method from this class.

    virtual void Draw(BRect const* pClipBRect)
Draw the part of the node which is enclosed inside the given bounding rectangle, or draw the entire object if no bounding rectangle is given.

The bounding rectange uses the BIFS coordinate system, with the origin of the output display is in the middle of the window, with increasing X and Y to the right and up.

    virtual BOOL IsPointOver(int x, int y) { return GetBoundingRect()->IsPointIn(x, y); }
Return TRUE if the given point, in BIFS coordinates, is above the current shape. Return FALSE otherwise. The default implementation uses the bounding rectangle of the drawable.

    const BRect* GetBoundingRect() const { return &m_boundingRect; }
Returns the bounding rectangle which completely encloses this object. The bounding rectange uses the BIFS coordinate system, with the origin of the output display is in the middle of the window, with increasing X and Y to the right and up.

    const BRect* GetCombinedBoundingRect() const { return &m_combinedBoundingRect; }
Returns the bounding rectangle which completely encloses this object, at it current and previous locations. The bounding rectange uses the BIFS coordinate system, with the origin of the output display is in the middle of the window, with increasing X and Y to the right and up.

The DrawableNode class also defines a number of other functions which are only to be used by deriving classes, and are as such, declared as protected. These functions are as follows:

    BOOL InitPreRender(Effects const& effects)
The method will store a copy of all of the effects parameters locally in this node, and then register this node with the visual renderer so that it is drawn. If this node has been switched off, FALSE is returned, in which case the calling function must return immediately.

    void UpdateBoundingRect()
Call this function from the PreRender() method of a derived class, once the m_boundingRect data member has been set. This will combine the current bounding rectangle with the previous.

    BOOL IsSwitchedOn() const { return m_isSwitchedOn; }
Returns FALSE if this node is switched off, as the result of a Switch node, otherwise it returns TRUE.