ubit
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ubit::UNode Class Reference

Base class of objects that can be added to the UBIT scene graph (SEE DETAILS!). More...

#include <unode.hpp>

Inheritance diagram for ubit::UNode:
ubit::UObject ubit::UAttr ubit::UCall ubit::UCDATASection ubit::UComment ubit::UData ubit::UElem ubit::UNumber ubit::UProcessingInstruction ubit::USource ubit::UTimer ubit::UXmlDocType

Public Types

enum  NodeType {
  ELEMENT_NODE = 1, ATTRIBUTE_NODE = 2, TEXT_NODE = 3, CDATA_SECTION_NODE = 4,
  ENTITY_REFERENCE_NODE = 5, ENTITY_NODE = 6, PROCESSING_INSTRUCTION_NODE = 7, COMMENT_NODE = 8,
  DOCUMENT_NODE = 9, DOCUMENT_TYPE_NODE = 10, DOCUMENT_FRAGMENT_NODE = 11, NOTATION_NODE = 12
}
 redefines Class() and getClass() methods ( More...
 
enum  DisplayType {
  WINLIST =-1, UNDISPLAYBLE =0, ATTRIBUTE, DATA,
  INLINE, BLOCK, BORDER, HARDWIN,
  SOFTWIN
}
 Ubit display types.
 
- Public Types inherited from ubit::UObject
typedef unsigned char State
 
typedef short PtrCount
 

Public Member Functions

virtual int getNodeType () const
 returns the XML node type.
 
virtual const UStrgetNodeName () const
 return the XML node name.
 
virtual UStr getNodeValue () const
 return the XML node value.
 
virtual int getDisplayType () const
 
virtual int isDisplayable () const
 
virtual UNodetoNode ()
 dynamic cast: returns this object if it derives from UNode and null otherwise.
 
virtual const UNodetoNode () const
 dynamic cast: returns this object if it derives from UNode and null otherwise.
 
virtual bool isChildOf (const UElem &parent, bool indirect=true) const
 returns true if this object a child of 'parent'. More...
 
UParentIter pbegin () const
 returns an iterator to the beginning of the list of direct parents. More...
 
UParentIter pend () const
 returns an iterator to the end of the parent list ( More...
 
virtual UParentsparents () const
 returns the list of direct parents ( More...
 
virtual UElemgetParent (int pos=0) const
 returns the Nth direct parent. More...
 
virtual bool hasSceneGraphParent () const
 
template<class CC >
CC * findParent () const
 < this object has at least one parent in the scene graph. More...
 
virtual int getBoxParents (std::vector< UBox *> &parvect) const
 retrieves direct and indirect parents that are boxes.
 
virtual UBoxgetParent (const UView *) const
 returns the direct or indirect parent that contains this view. More...
 
virtual UViewgetParentView (const UView *) const
 returns the direct or indirect parent's view that contains this view. More...
 
virtual UBoxgetParent (const UInputEvent &) const
 
virtual UViewgetParentView (const UInputEvent &) const
 
virtual void removeFromParents (bool update_parents=true)
 [impl] removes this object from all direct parents. More...
 
virtual bool fire (UEvent &) const
 fires callback functions that match this event.
 
virtual UNoderemoveAllAttrs (bool autodel=true)
 removes all attributes (if any, redefined by subclasses).
 
virtual void update ()
 updates object graphics.
 
bool isAutoUpdate () const
 return current update policy: see setAutoUpdate().
 
UNodesetAutoUpdate (bool state=true)
 changes the update policy of this object when its is modified. More...
 
void fireParents (const UCond &c, UNode *n) const
 
void updateAutoParents (const UUpdate &m)
 
virtual void addChangeCall (UCall &)
 
virtual UElemgetSubGroup () const
 
void _addAttr (const UChild &attribute)
 [impl] to be removed @.
 
UChildIter _abegin () const
 [impl] to be removed @.
 
UChildIter _aend () const
 [impl] to be removed @.
 
- Public Member Functions inherited from ubit::UObject
 UObject (const UObject &)
 
UObjectoperator= (const UObject &)
 
virtual const UClassgetClass () const
 instance method that returns the metaclass of this object. More...
 
const UStrgetClassName () const
 returns getClass().getName().
 
virtual void error (const char *function_name, const char *format,...) const
 prints out an error message. More...
 
virtual void warning (const char *function_name, const char *format,...) const
 prints out a warning message: More...
 
bool isDeletable () const
 checks if this object can be destroyed by 'delete'. More...
 
bool isConst () const
 checks whether the content of this object can be modified ( More...
 
UObjectsetConst ()
 specifies that the content of this object cannot be modified. More...
 
bool isAutoUpdate () const
 return current update policy: More...
 
UObjectsetAutoUpdate (bool state=true)
 changes the update policy of this object when its is modified. More...
 
bool isIgnoringChangeCallbacks () const
 return true if change callbacks are fired.
 
UObjectignoreChangeCallbacks (bool state)
 change callbacks are not fired if argument is true.
 
virtual UAttrtoAttr ()
 dynamic cast: returns this object if it derives from UAttr and null otherwise.
 
virtual const UAttrtoAttr () const
 dynamic cast: returns this object if it derives from UAttr and null otherwise.
 
virtual UElemtoElem ()
 dynamic cast: returns this object if it derives from UElem and null otherwise.
 
virtual const UElemtoElem () const
 dynamic cast: returns this object if it derives from UElem and null otherwise.
 
virtual UDatatoData ()
 dynamic cast: returns this object if it derives from UData and null otherwise.
 
virtual const UDatatoData () const
 dynamic cast: returns this object if it derives from UData and null otherwise.
 
virtual UStrtoStr ()
 dynamic cast: returns this object if it derives from UStr and null otherwise.
 
virtual const UStrtoStr () const
 dynamic cast: returns this object if it derives from UStr and null otherwise.
 
virtual UCalltoCall ()
 dynamic cast: returns this object if it derives from UCall and null otherwise.
 
virtual const UCalltoCall () const
 dynamic cast: returns this object if it derives from UCall and null otherwise.
 
virtual UBoxtoBox ()
 dynamic cast: returns this object if it derives from UBox and null otherwise.
 
virtual const UBoxtoBox () const
 dynamic cast: returns this object if it derives from UBox and null otherwise.
 
virtual UWintoWin ()
 dynamic cast: returns this object if it derives from UWin and null otherwise.
 
virtual const UWintoWin () const
 dynamic cast: returns this object if it derives from UWin and null otherwise.
 
virtual UMenutoMenu ()
 dynamic cast: returns this object if it derives from UMenu and null otherwise.
 
virtual const UMenutoMenu () const
 dynamic cast: returns this object if it derives from UMenu and null otherwise.
 
State getState () const
 returns the current object state.
 
void setState (State s)
 changes the object state.
 
PtrCount getPtrCount () const
 [impl] returns the number of uptr<> smart pointers that are pointing to this object.
 
bool checkConst () const
 [impl] produces an error if this object is logically constant ( More...
 
bool isDestructed () const
 [impl] this object has been destructed (but memory has not been freed yet).
 
bool isDestructing () const
 [impl] this object is being destructed (one of its destructors has been called).
 
void * operator new (size_t)
 < [impl] returns true if there is at least one scene graph parent (redefined by UNode). More...
 
void operator delete (void *)
 delete operator is forbidden on instances that derive from UObject.
 
void addPtr () const
 [Impl] a uptr is added to this object.
 
void removePtr () const
 [Impl] a uptr is removed from this object.
 

Protected Member Functions

 UNode ()
 constructor, can anly be called by subclasses because UNode is abstract.
 
virtual ~UNode ()
 destructor, note that children are recursively destroyed except if pointed elsewhere ( More...
 
virtual void addingTo (UChild &, UElem &parent)
 called when this object is added to a parent.
 
virtual void removingFrom (UChild &, UElem &parent)
 called when this object is removed from a parent (SEE DETAILS IF YOU REDEFINE THIS METHOD). More...
 
virtual void destructs ()
 unlinks the object from its parents and destroys its children.
 

Protected Attributes

UParents _parents
 
UChildren _attributes
 
- Protected Attributes inherited from ubit::UObject
PtrCount ptr_count
 
Modes omodes
 
State ostate
 

Friends

class UChild
 
class UArgs
 
class UParents
 
class UElem
 
UChild operator/ (const UCond &, UNode &)
 conditional expression for callback functions and conditionnal objects. More...
 
UChild operator/ (const UCond &, UNode *)
 see operator/(const UCond&, UNode&).
 

Additional Inherited Members

- Static Public Member Functions inherited from ubit::UObject
static const char * getVersion ()
 returns the version of the Ubit package.
 
static const UClassClass ()
 class method that returns the metaclass of this class. More...
 
static UStylecreateStyle ()
 
- Static Public Attributes inherited from ubit::UObject
static UConst UCONST
 UCONST can be given as an argument to some constructors to make the object constant. More...
 

Detailed Description

Base class of objects that can be added to the UBIT scene graph (SEE DETAILS!).

A Ubit scene graph can be seen as a XML document:

UNode derives from UObject, the base class for (almost) all Ubit objects. See the UNode documentation for important info about:

Member Enumeration Documentation

§ NodeType

redefines Class() and getClass() methods (

See also
UNode). XML object types.

Constructor & Destructor Documentation

§ ~UNode()

virtual ubit::UNode::~UNode ( )
inlineprotectedvirtual

destructor, note that children are recursively destroyed except if pointed elsewhere (

See also
class UNode).

Member Function Documentation

§ findParent()

template<class CC >
CC* ubit::UNode::findParent ( ) const
inline

< this object has at least one parent in the scene graph.

objects can have non scene graph parents in some cases. Such parents are not taken into account for deciding whether objects can be automatically destructed. returns first the direct or indirect parent with that class.

§ getParent() [1/2]

virtual UElem* ubit::UNode::getParent ( int  pos = 0) const
virtual

returns the Nth direct parent.

returns the first parent if 'pos' = 0 and the last parent if 'pos' = -1. returns null and issues an error message if 'pos' is out of range. Notes:

  • objects can have several parents
  • getParents() is more efficient for accessing multiple parents.

§ getParent() [2/2]

virtual UBox* ubit::UNode::getParent ( const UView ) const
virtual

returns the direct or indirect parent that contains this view.

intermediate UElem parents are ignored (ie. traversed) by this function.

§ getParentView()

virtual UView* ubit::UNode::getParentView ( const UView ) const
virtual

returns the direct or indirect parent's view that contains this view.

intermediate UElem parents are ignored (ie. traversed) by this function.

§ isChildOf()

bool UNode::isChildOf ( const UElem parent,
bool  indirect = true 
) const
virtual

returns true if this object a child of 'parent'.

'indirect' specifies if indirect childhood is taken into account.

§ parents()

virtual UParents& ubit::UNode::parents ( ) const
inlinevirtual

returns the list of direct parents (

See also
pbegin()).

§ pbegin()

UParentIter ubit::UNode::pbegin ( ) const
inline

returns an iterator to the beginning of the list of direct parents.

UParentIter is a parent iterator. It is compatible with standard STL algorithms. This example prints the class name of the direct parents of an object :

        UNode* obj = ...;
        for (UParentIter p = obj->pbegin(); p != obj->pend(); ++p)
            cout << (*p)->getClassName() << endl;
     
See also
also: parents(), abegin(), aend().

§ pend()

UParentIter ubit::UNode::pend ( ) const
inline

returns an iterator to the end of the parent list (

See also
pbegin()).

§ removeFromParents()

void UNode::removeFromParents ( bool  update_parents = true)
virtual

[impl] removes this object from all direct parents.

notes:

  • objects can have several parents!
  • this function is potentially dangerous: UElem::remove() methods should be prefered when possible.

§ removingFrom()

virtual void ubit::UNode::removingFrom ( UChild ,
UElem parent 
)
inlineprotectedvirtual

called when this object is removed from a parent (SEE DETAILS IF YOU REDEFINE THIS METHOD).

!BEWARE: subclasses that redefine removingFrom() MUST HAVE A DESTRUCTOR that calls destructs().
DETAILS: this is because of a C++ subtletly: as polymorphism is deactivated in destructors, a redefined removingFrom() method won't be called except if destructs() - that calls removingFrom() - is called in the destructor of the class that redefines removingFrom()).

Reimplemented in ubit::UStr, ubit::UOrient, ubit::USizeControl, ubit::UTip, ubit::URadioSelect, ubit::UPosControl, ubit::UEdit, ubit::UChoice, ubit::UMenu, ubit::UDialog, ubit::UCursor, and ubit::UViewStyle.

§ setAutoUpdate()

UNode & UNode::setAutoUpdate ( bool  state = true)

changes the update policy of this object when its is modified.

  • if 'state' is true, the object if automatically updated when modified (either by adding/removing children for UElem and subclasses, or by setting new values for UData, UStr, UAttr ...)
  • if 'state' is false, the update() function must be called explicitely to update the graphics. This can be useful in certain cases to avoid intermediate updates in order to to speed up rendition

Friends And Related Function Documentation

§ operator/

UChild operator/ ( const UCond ,
UNode  
)
friend

conditional expression for callback functions and conditionnal objects.

example:

   struct Demo {
      void saveFile();
      void showMsg(const char*);
      ....
   };
   Demo* d = new Demo;
   // NB: ubutton(...) returns *new UButton(...)
   UBox& b = ubutton(" Save..." + UOn::action / ucall(d, &Demo::saveFile));
   ....
   b.addAttr(UOn::enter / ucall(d, "Saves the file", &Demo::showMsg)
See also
: addAttr(), UCall, UOn, UFlag for more details.

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