- Main Page
- Classes
- Files
- Directories
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# KrImNode Class Reference

The base class of everything that can be in an ImageTree. More...

`#include <imnode.h>`

Inheritance diagram for KrImNode:

List of all members.

## Public Member Functions
int | ZDepth ()
| Every node has a Z-Depth within the node that contains it.
void | SetZDepth (int z)
| Set the z-depth of this node relative to its siblings.
int | X (int window=0)
| Return the x postion of this node, relative to its parent.
int | Y (int window=0)
| Return the y position of this node, relative to its parent.
GlFixed | XScale (int window=0)
| Return the x scale of this node, untransformed by parent.
GlFixed | YScale (int window=0)
| Return the x scale of this node, untransformed by parent.
const KrMatrix2 & | Transform (int window=0)
| Query the entire transformation matrix.
void | SetPos (int x, int y, int window=KR_ALL_WINDOWS)
| Set the x and y positon of the ImNode, relative to the node's parent.
void | SetScale (GlFixed xScale, GlFixed yScale, int window=KR_ALL_WINDOWS)
| Set the scale of this ImNode, which changes all the children as well.
void | SetTransform (KrMatrix2 &xForm, int window=KR_ALL_WINDOWS)
| Set the transformation matrix of this ImNode: combines the SetPos and SetScale functionality.
void | SetQuality (int quality, int window=KR_ALL_WINDOWS)
| Set the drawing quality for scaling.
void | DeltaPos (int deltaX, int deltaY, int window=KR_ALL_WINDOWS)
| Offsets the node position.
const KrColorTransform & | CTransform (int window=0)
| Get the color transformation of the node.
virtual void | SetColor (const KrColorTransform &color, int window=KR_ALL_WINDOWS)
| Set the color of a node.
virtual KrImage * | ToImage ()
| Return a pointer if this is an image.
virtual KrSprite * | ToSprite ()
| Return a pointer if this is a sprite.
virtual KrTile * | ToTile ()
| Return a pointer if this is a tile.
virtual KrCanvas * | ToCanvas ()
| Return a pointer if this is a canvas.
virtual KrTextBox * | ToTextBox ()
| Return a pointer if this is a text box.
virtual KrBox * | ToBox ()
| Return a pointer if this is a box.
virtual KrWidget * | ToWidget ()
| Return a pointer if this is a widget.
virtual KrImNode * | ToExtended (const std::string &type)
| A generic cast.
const std::string & | NodeName ()
| Any ImNode can have a name or id.
int | NodeId ()
| Any ImNode can have a name or id.
void | SetNodeName (const std::string &name)
| Set the name of this node.
void | SetNodeId (int id)
| Set the id of this node.
GlInsideNodeIt< KrImNode * > | ChildTreeIterator ()
| Fetch an iterator to walk the children with.
virtual bool | HitTest (int x, int y, int flags, std::vector< KrImage * > *results, int window)
| Hit test this object. Returns true if there was a hit, and 'this' will be added to results.
bool | IsVisible (int window=0)
| Return the visibility of this node, taking into account the state of all its parents.
bool | IsThisVisible (int window=0)
| Return the visibility of this node, NOT taking into account the state of all its parents.
virtual void | SetVisible (bool visible, int window=KR_ALL_WINDOWS)
| If visible is set to false, this node and all its children will not show up on the stage.
void | ScreenToObject (int x, int y, grinliz::Vector2< GlFixed > *object, int window=0)
| Transform screen (pixel) coordinates to local object coordinates.
void | SetUserData (void *data)
| A hook to set user defined data.
void * | GetUserData ()
| Fetches the user defined data.
virtual KrImNode * | Clone ()
| Return a copy if this object, not in a Tree().
KrImNode * | Parent ()
| The parent of this KrImNode.
KrEngine * | Engine ()
| The engine this KrImNode is in.
## Protected Member Functions
void | Resort (KrImNode *resortMe)
| Resort can be called if a node's depth has changed and it needs to move elsewhere in the list.
## Friends
class | KrImageTree

## Detailed Description

The base class of everything that can be in an ImageTree.

The class in not abstract -- it can be very useful to have a KrImNode that is used as a container for other objects.

Children always draw on top of their parents.

## Member Function Documentation

virtual KrImNode* KrImNode::Clone | ( |  | ) | `[virtual]`

Return a copy if this object, not in a Tree().

It is return untransformed. In the case of a sprite, the action and frame will be set to the current value.

Reimplemented in KrBox, KrCanvas, KrSprite, KrTextBox, and KrTile.

int KrImNode::NodeId | ( |  | ) | `[inline]`

Any ImNode can have a name or id.

They are completely managed by the user -- they are not used by the engine in any way. They should be unique to the tree, and can be used as a way to keep track of nodes.

An empty name or an id<0 indicate no name and no id, respectively.

const std::string& KrImNode::NodeName | ( |  | ) | `[inline]`

Any ImNode can have a name or id.

They are completely managed by the user -- they are not used by the engine in any way. They should be unique to the tree, and can be used as a way to keep track of nodes.

An empty name or an id<0 indicate no name and no id, respectively.

void KrImNode::ScreenToObject | ( | int | x,
|  | int | y,
|  | grinliz::Vector2< GlFixed > * | object,
|  | int | window = `0` |
| ) |  |  |

Transform screen (pixel) coordinates to local object coordinates.

The composite Xform is used for this and must be initialized -- practically, the object must be in a Tree to call this method.

virtual void KrImNode::SetColor | ( | const KrColorTransform & | color,
|  | int | window = `KR_ALL_WINDOWS` |
| ) |  |  | `[virtual]`

Set the color of a node.

This color transforms all the node's children as well.

void KrImNode::SetNodeId | ( | int | id | ) |

Set the id of this node.

It must be > 0. This is completely user defined. Like the name, this should be unique. In DEBUG mode, an assertion will fire if an id is re-used.

You can later find a node by the id you set by calling KrImageTree::FindNodeById().

void KrImNode::SetNodeName | ( | const std::string & | name | ) |

Set the name of this node.

This is completely user defined. The name of a node should be unique. In DEBUG mode, an assertion will fire if the same name is used twice.

void KrImNode::SetPos | ( | int | x,
|  | int | y,
|  | int | window = `KR_ALL_WINDOWS` |
| ) |  |  |

Set the x and y positon of the ImNode, relative to the node's parent.

Even non-drawing nodes have position since changing the position moves the node's children.

Setting the positon of the root node scrolls the screen.

void KrImNode::SetQuality | ( | int | quality,
|  | int | window = `KR_ALL_WINDOWS` |
| ) |  |  |

Set the drawing quality for scaling.

Quality is inherited from the parent the same way other properties are, if the quality is set to KrQualityNone, else the set quality is used. Cached scaling is always at maximum quality.

virtual void KrImNode::SetVisible | ( | bool | visible,
|  | int | window = `KR_ALL_WINDOWS` |
| ) |  |  | `[virtual]`

If visible is set to false, this node and all its children will not show up on the stage.

Returns true if the visiblity was changed by this call.

virtual KrImNode* KrImNode::ToExtended | ( | const std::string & | type | ) | `[inline, virtual]`

A generic cast.

The Kyra library is not as extensible as it could be; this implements a "cheap RTTI" if you add your own sub-classes. Arbitrary casting to any type in the string. For example,

    			MyClassType* myType = (MyClassType*) node->ToExtended( "MyClassType" );

Somewhat inelegant, but a very useful hook. The build in classes will not respond to this. (That is, ToExtended( "Sprite" ) does not work.)

Reimplemented in KrConsole.

int KrImNode::ZDepth | ( |  | ) | `[inline]`

Every node has a Z-Depth within the node that contains it.

The lowest z-depth is the farthest from the viewer. Any integer value is acceptable.

Nodes at the same z-depth are sorted by the order they were added to the tree. The last one added is the closest to the viewer. (It is not a good idea to mix z-depth changing and "order sorting." Go with one or the other.

Changing the z-depth of the root is meaningless. (It has no siblings.)

The documentation for this class was generated from the following file:

- imnode.h