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

lightweight general purpose container. More...

#include <uelem.hpp>

Inheritance diagram for ubit::UElem:
ubit::UNode ubit::UObject ubit::UBox ubit::UDefaultBlockElement ubit::UDefaultInlineElement ubit::UFinder::Options ubit::UMessagePort ubit::UTrow ubit::UWinList ZLeaf ZLess ZMore

Classes

struct  Modes
 

Public Types

enum  { REMOVE_FROM_PARENTS = -1 }
 
- Public Types inherited from ubit::UNode
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

 UElem (UArgs node_arglist=UArgs::none)
 creates a new UElem; The argument can either be a single object pointer or reference, or a list of object pointers or references separated by + operators, example: More...
 
virtual ~UElem ()
 destructor, note that children are recursively destroyed except if pointed elsewhere ( More...
 
virtual void destructs ()
 unlinks the object from its parents and destroys its children.
 
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.
 
const UStylegetStyle (UUpdateContext *) const
 virtual function that returns the style of this object. More...
 
virtual int getNodeType () const
 returns the XML node type.
 
virtual const UStrgetNodeName () const
 return the XML node name (which is the class name).
 
virtual int getDisplayType () const
 
virtual void initNode (UDoc *context)
 initialises the XML context of this node.
 
UElemsetAttr (UNode &attribute)
 adds or replaces this attribute in the ATTRIBUTE list. More...
 
UElemaddAttr (const UArgs &attributes)
 adds one or several attributes (deriving from UAttr) to the ATTRIBUTE list. More...
 
UElemremoveAttr (UNode &attribute, bool auto_delete=true)
 removes/deletes an attribute (and its descendants) from the ATTRIBUTE list. More...
 
UElemremoveAllAttrs (bool auto_delete=true)
 removes/deletes all attributes (and their descendants) in the ATTRIBUTE list. More...
 
bool getAttrValue (UStr &value, const UStr &attr_name) const
 retrieves the value of the attribute which class name is 'attr_name'. More...
 
UAttrgetAttr (const UStr &attr_name) const
 returns the attribute node which class name is 'attr_name'. More...
 
template<class ATTR >
ATTR * getAttr () const
 retrieves the attribute node that derives from the "ATTR" C++ class. More...
 
template<class ATTR >
ATTR & obtainAttr ()
 retrieves or creates the element's attribute that derives from the "ATTR" C++ class. More...
 
virtual bool isParentOf (const UNode &possible_child) const
 returns true if this object a direct or indirect parent of 'child'.
 
UElemadd (const UArgs &children)
 adds one or several objects to the end of the CHILD list of this element. More...
 
UElemadd (const UArgs &children, int position)
 adds one or several objects in the CHILD list before this position. More...
 
UElemadd (const UArgs &children, UChildIter iterator)
 adds one or several objects in the CHILD list before this iterator. More...
 
virtual UElemaddImpl (const UArgs &nodes, UChildIter pos, UChildren &in_list)
 
virtual bool addImpl1 (const UChild &node, UChildIter pos, UChildren &in_list)
 
UElemremove (UNode &child, bool auto_delete=true)
 removes/deletes a child (and its descendants) from the CHILD list. More...
 
UElemremove (int pos, bool auto_delete=true)
 removes/deletes a child (and its descendants) at this position in the CHILD list. More...
 
UElemremove (UChildIter pos, bool auto_delete=true)
 removes/deletes a child (and its descendants) at this position in the CHILD list. More...
 
UElemremoveAll (bool auto_delete=true)
 removes/deletes all children (and their descendants) in the CHILD list. More...
 
virtual UElemremoveImpl (UChildIter begin, int N, bool autodel, UChildren &in_list)
 
virtual bool removeImpl1 (UChildIter pos, int auto_delete, UChildren &in_list)
 
UChildrengetChildren () const
 
int getChildCount () const
 
UChildIter child (int pos) const
 
UNodegetChild (int pos) const
 returns an iterator pointing to the child at this position. More...
 
UChildIter cbegin () const
 returns the child at this position. More...
 
UChildIter cend () const
 returns a forward iterator pointing to the end of the child list ( More...
 
UChildReverseIter crbegin () const
 returns a reverse iterator pointing to the beginning of the child list ( More...
 
UChildReverseIter crend () const
 returns a reverse iterator pionting to the end of the child list ( More...
 
virtual UStr retrieveText (bool recursive=true) const
 collates and returns the text that is enclosed in this object. More...
 
virtual void retrieveText (UStr &string, bool recursive=true) const
 collates and returns the text that is enclosed in this object. More...
 
virtual bool isShown () const
 returns true if this object is shown. More...
 
bool isShowable () const
 returns true if this object can be shown. More...
 
void setShowable (bool s) const
 synonym for show(bool).
 
virtual void show (bool=true)
 shows/hides this object. More...
 
void repaint ()
 indicates that this object will be repainted (when the main loop becomes idle).
 
void update ()
 indicates that this object will be layed out and repainted (when the main loop becomes idle).
 
virtual void update (const UUpdate &update_options, UDisp *=null)
 indicates that the layout and/or the paint of this object will be updated. More...
 
void doUpdate ()
 
virtual void doUpdate (const UUpdate &, UDisp *=null)
 updates the layout and/or the paint of this object right now. More...
 
UElemignoreEvents (bool state=true)
 if arg is true, this element and (its children) ignore events. More...
 
UElemcatchEvents (const UChild &condition_callback_expr)
 catches certain events before they reach the object's children. More...
 
UElemobserveChildrenEvents (const UChild &condition_callback_expr)
 observe events that occur in children. More...
 
bool isIgnoringEvents () const
 returns true if events are ignored by this object;
 
bool hasCallback (long callback_id) const
 true if thie object has such a callback.
 
virtual bool fire (UEvent &) const
 fires callback functions that match this event.
 
UElemenable (bool state=true)
 shortcut for setEnabled(bool state = true).
 
virtual UElemsetEnabled (bool state=true, bool call_callbacks=true)
 specifies whether this object is enabled. More...
 
bool isEnabled () const
 returns true if this object is currently enabled; More...
 
virtual UElemsetSelected (bool state=true, bool call_callbacks=true)
 specifies whether this object is selected. More...
 
bool isSelected () const
 
bool isSelectable () const
 
UElemsetSelectable (bool state=true)
 
bool isArmed () const
 
bool isArmable () const
 specifies whether this object can be armed. More...
 
UElemsetArmable (bool state=true)
 
UElemsetAutoRepeat (bool state=true)
 
bool isAutoRepeat () const
 
bool isCrossable () const
 
UElemsetCrossable (bool state=true)
 
UElemsetBrowsable (bool=true)
 
bool isBrowsable () const
 
bool isDragged () const
 
bool isDraggable () const
 
UElemsetDraggable (bool=true)
 
bool isDroppable () const
 
UElemsetDroppable (bool=true)
 
bool isTextEditable () const
 
bool isFloating () const
 
bool isVertical () const
 
bool isWidthResizable () const
 
bool isHeightResizable () const
 
virtual bool isSubWin () const
 
void disableMenuClosing (bool s=true)
 this object and its children wont close menus when clicked if argument is true.
 
bool isMenuClosingDisabled () const
 true if this object and its children do not close menus when clicked.
 
bool isBrowsingGroup ()
 
virtual UChildrenchildren () const
 
virtual UChildrenattributes () const
 
UChildIter abegin () const
 
UChildIter aend () const
 
UObject::State getInterState () const
 
void setInterState (UObject::State)
 
virtual const UStrgetTextSeparator () const
 returns the text separator used by retrieveText() for separating enclosed children
 
virtual void deleteViewsInside (const std::vector< UView *> &parent_views)
 
virtual void initView (UView *parent_view)
 
virtual void initChildViews (UElem *)
 
virtual void highlight (bool state)
 
virtual int retrieveRelatedViews (std::vector< UView *> &collating_vector) const
 
UElem_setArmableAndSelectable (bool state)
 
virtual void keyPressBehavior (UKeyEvent &)
 
virtual void keyReleaseBehavior (UKeyEvent &)
 
virtual void enterBehavior (UInputEvent &, bool is_browing)
 
virtual void leaveBehavior (UInputEvent &, bool is_browing)
 
virtual void armBehavior (UInputEvent &, bool is_browing)
 
virtual void disarmBehavior (UInputEvent &, bool is_browing)
 
virtual void actionBehavior (UInputEvent &)
 
- Public Member Functions inherited from ubit::UNode
virtual UStr getNodeValue () const
 return the XML node value.
 
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...
 
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 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.
 

Static Public Member Functions

static UStylecreateStyle ()
 static function that returns the style of this class. More...
 
static void closeWin (UInputEvent &, int status)
 closes the first window (UDialog, UMenu...) that contains this element. More...
 
- 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 ()
 

Protected Member Functions

virtual int _getTextLength (bool recursive) const
 
virtual char * _getTextData (char *ptr, bool recursive) const
 
- Protected Member Functions inherited from ubit::UNode
 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...
 

Protected Attributes

Modes emodes
 
long callback_mask
 
UChildren _children
 
- Protected Attributes inherited from ubit::UNode
UParents _parents
 
UChildren _attributes
 
- Protected Attributes inherited from ubit::UObject
PtrCount ptr_count
 
Modes omodes
 
State ostate
 

Friends

class UNode
 
class UEdit
 
class UChildEventFlag
 
class UPos
 
class USize
 
class UOrient
 
class UCursor
 
class UTip
 
class UStr
 
class UWin
 
class UOn
 
class UEventFlow
 
class UViewStyle
 
class UUpdateContext
 
class UWinUpdateContext
 

Additional Inherited Members

- 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

lightweight general purpose container.

This class is a very lightweight and general container. In contrast with UBox (and its subclasses) UElem objects do not control UViews and do not manage screen rendering directly (they are just genuine containers)

IMPORTANT NOTE ON RECURSIVE DESTRUCTION AND SMART POINTERS: When a UElem is destroyed, its direct and indirect children are ALSO destroyed EXCEPT if they have other parents OR if they are pointed by a uptr<> Smart Pointer.

See also
class UNode for details.

Notes:

Constructor & Destructor Documentation

§ UElem()

ubit::UElem::UElem ( UArgs  node_arglist = UArgs::none)

creates a new UElem; The argument can either be a single object pointer or reference, or a list of object pointers or references separated by + operators, example:

  UButton* b = new UButton(UPix::disquette + "Save" + ucall(obj, saveFunc));
See also
also the UElem() shortcut, that returns: *new UElem(arglist)

§ ~UElem()

UElem::~UElem ( )
virtual

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

See also
class UNode).

Member Function Documentation

§ add() [1/3]

UElem& ubit::UElem::add ( const UArgs children)

adds one or several objects to the end of the CHILD list of this element.

The argument can either be a single object pointer or reference, or a list of object pointers or references separated by + operators:

  UButton* b = new UButton();    // creates a UButton (that derives from UElem)
  b->add(UPix::disquette);       // adds a pixmap image to the button
  b->add("Save");                // adds a string that serves as a label
  b->add(ucall(obj, saveFunc));  // adds a callback function (
See also
UCall) is equivalent to:
  UButton* b = new UButton();
  b->add(UPix::disquette + "Save" + ucall(obj, saveFunc));
and also to:
  UButton* b = new UButton(UPix::disquette + "Save" + ucall(obj, saveFunc));
Objects added to the CHILD list should derive from UElem (typically, widgets deriving from UBox, UWin), UData (viewable objects such as UStr, UIma) or UCall (callback objects). Certain attributes such as UColor, UFont, UHalign, UValign can also be added to the child list.
Character strings (e.g. "abcd") are implicitely converted to UStr objects, so 
that add("abcd") is equivalent to: add( ustr("abcd") ).
For syntactical reasons, an argument list cannot solely contain pointers or strings
separated by + operators: one argument must then be dereferenced or appropriately
converted (exple: add(ustr("abcd") + "xyz") is correct, add("abcd" + "xyz") is not)
The addAttr() method works as add() excepts that it adds arguments to the 
ATTRBITUTE list. Arguments should then derive from UAttr (attributes) or 
UCall (callback aobjects).
Subclasses that require a specific behavior should not redefine this function
but addImpl(), that is called internally by all add functions
See also
also: add(const UArgs&, int pos), add(const UArgs&, UChildIter pos), addAttr(const UArgs&)

§ add() [2/3]

UElem& ubit::UElem::add ( const UArgs children,
int  position 
)

adds one or several objects in the CHILD list before this position.

See also
add(const UArgs& objects) for details: both functions work in the same way except that this function makes it possible to specify the position instead of adding to the end of the child list. 0 refers to the position before the first argument in the child list, special value -1 refers to the position after the last child.

§ add() [3/3]

UElem& ubit::UElem::add ( const UArgs children,
UChildIter  iterator 
)

adds one or several objects in the CHILD list before this iterator.

See also
add(const UArgs& objects) for details: both functions work in the same way except that this function makes it possible to specify the position (through an iterator,
UChildIter) instead of adding to the end of the child list.

§ addAttr()

UElem & UElem::addAttr ( const UArgs attributes)

adds one or several attributes (deriving from UAttr) to the ATTRIBUTE list.

See also
add(const UArgs&) for details (both functions work in the same way).

§ addImpl1()

bool UElem::addImpl1 ( const UChild node,
UChildIter  pos,
UChildren in_list 
)
virtual

!!!!!! verifier pas deja dans la liste !!!

§ catchEvents()

UElem & UElem::catchEvents ( const UChild condition_callback_expr)

catches certain events before they reach the object's children.

Events are not delivered to their normal targets, instead, they are catched by this element if it contains the target. The specified callback is then fired with this element as a "source" (

See also
UEvent::getSource()). If this callback calls the event's propagate() method, this event will then be sent to the normal target. This makes it possible to filter events and decide which of them can reach targets. Also, some some useful functions can be triggered before events reach their final targets and the events can be modified by settings UFlags or by modifiying the event coordinates.

3 categories of events can be currently catched:

  • UOn::mpress, UOn::mrelease & UOn::mdrag mouse events. As, these events are closely related, catching one of them will also catch the other 2 kinds.
  • UOn::mmove mouse events.
  • UOn::wheel events.

'condition_callback_expr' is a construct such as:

   UOn::mpress / ucall(obj, &Obj::foo)   // (obj type is Obj*)  

The callback method (eg. 'foo') will be fired BEFORE this condition (eg. 'UOn::mpress') occurs in a direct and indirect child of this element.

To learn more about conditions

See also
classes UOn and UCond. To learn more about callback objects
class UCall.

§ cbegin()

UChildIter ubit::UElem::cbegin ( ) const
inline

returns the child at this position.

returns the last child if 'pos' = -1 / returns null if 'pos' is out of bounds

See also
also: UChildren find() functionsreturns a forward iterator pointing to the beginning of the CHILD list. UChildIter is a child iterator. It is compatible with standard STL algorithms. This example prints the children class names:
         UElem* obj = ...;
         for (UChildIter i = obj->cbegin(); i != obj->cend(); ++i)
             cout << (*i)->getClassName() << endl;
      
also: children(), cend(), crbegin(), crend(), abegin(), aend(), pbegin(), pend().

§ cend()

UChildIter ubit::UElem::cend ( ) const
inline

returns a forward iterator pointing to the end of the child list (

See also
cbegin()).

§ closeWin()

void UElem::closeWin ( UInputEvent e,
int  status 
)
static

closes the first window (UDialog, UMenu...) that contains this element.

See also
: UWin::close() and ucloseWin().

§ crbegin()

UChildReverseIter ubit::UElem::crbegin ( ) const
inline

returns a reverse iterator pointing to the beginning of the child list (

See also
cbegin()).

§ createStyle()

UStyle * UElem::createStyle ( )
static

static function that returns the style of this class.

this function MUST be redefined by subclasses if they use another UStyle.

§ crend()

UChildReverseIter ubit::UElem::crend ( ) const
inline

returns a reverse iterator pionting to the end of the child list (

See also
cbegin()).

§ doUpdate()

virtual void ubit::UElem::doUpdate ( const UUpdate ,
UDisp = null 
)
virtual

updates the layout and/or the paint of this object right now.

this function is called when the main loop becomes idle for repainting the object. Usually, a client program should NOT call doUpdate() directly. Instead, it should call update() or update(const UUpdate&, UDisp*) that delay layout and repaint actions until the main loop becomes idle. This improves performance and makes double buffering possible.

Reimplemented in ubit::UWin, and ubit::UBox.

§ getAttr() [1/2]

UAttr* ubit::UElem::getAttr ( const UStr attr_name) const

returns the attribute node which class name is 'attr_name'.

null is returned if there is no such attribute in the element's ATTRIBUTE list. example: UColor* col = (UColor*) element.getAttr("UColor");

§ getAttr() [2/2]

template<class ATTR >
ATTR* ubit::UElem::getAttr ( ) const
inline

retrieves the attribute node that derives from the "ATTR" C++ class.

null is returned if there is no such attribute in the element's ATTRIBUTE list. example: UColor* col = element.getAttr<UColor>();

§ getAttrValue()

bool UElem::getAttrValue ( UStr value,
const UStr attr_name 
) const

retrieves the value of the attribute which class name is 'attr_name'.

false is returned if there is no such attribute in the element's ATTRIBUTE list. true is returned otherwise and the attribute value is stored in the 'value' argument.

§ getChild()

UNode * UElem::getChild ( int  pos) const

returns an iterator pointing to the child at this position.

returns the last child if 'pos' = -1 / returns cend() if 'pos' is out of bounds

See also
also: UChildren find() functions

§ getStyle()

const UStyle & UElem::getStyle ( UUpdateContext ctx) const

virtual function that returns the style of this object.

this function calls createStyle() the first time it is called, then it always return the same UStyle object. In contrast with createStyle(), which that must be redefined for each subclass, there is no need to redefine getStyle().

§ ignoreEvents()

UElem & UElem::ignoreEvents ( bool  state = true)

if arg is true, this element and (its children) ignore events.

events are then received by the parent(s) of this element

§ isArmable()

bool ubit::UElem::isArmable ( ) const
inline

specifies whether this object can be armed.

an armable widget behaves as a button (but its appearance depends on its UStyle). A widget can be made armable by calling its setArmable() methode

§ isEnabled()

bool UElem::isEnabled ( ) const

returns true if this object is currently enabled;

See also
setEnabled().

§ isShowable()

bool ubit::UElem::isShowable ( ) const
inline

returns true if this object can be shown.

isShowable() == true means that this object will be shown if its parents can also be shown. Note: this function has the same meaning as isVisible() in Java. : isShown(), UElem::show()

§ isShown()

bool UElem::isShown ( ) const
virtual

returns true if this object is shown.

isShown() returns true if this object is "showable" (see isShowable()) and all its parents are also "showable". Note that "shown" objects are not always visible on the screen as they may be hidden or clipped by other objects such as scroll panes.

See also
: isShowable(), UElem::show()

Reimplemented in ubit::UWin.

§ observeChildrenEvents()

UElem & UElem::observeChildrenEvents ( const UChild condition_callback_expr)

observe events that occur in children.

'condition_callback_expr' is a construct such as:

   UOn::action / ucall(obj, &Obj::foo)   // (obj type is Obj*)  

The callback method (eg. 'foo') will be fired AFTER this condition (eg. 'UOn::action') occurs in a direct and indirect child of this element.

To learn more about conditions

See also
classes UOn and UCond. To learn more about callback objects
class UCall.

§ obtainAttr()

template<class ATTR >
ATTR& ubit::UElem::obtainAttr ( )
inline

retrieves or creates the element's attribute that derives from the "ATTR" C++ class.

if there is no such attribute in the element's ATTRIBUTE list, it is created and added to the ATTRIBUTE list. example: UColor& col = element.getAttr<UColor>();

§ remove() [1/3]

UElem& ubit::UElem::remove ( UNode child,
bool  auto_delete = true 
)

removes/deletes a child (and its descendants) from the CHILD list.

This function removes the first occurence of 'child' from the child list. Moreover, 'child' and its children are DESTROYED if 'auto_delete' is true, they were created by 'new' and they are not referenced elsewhere by a widget or a UPtr smart pointer (

See also
UNode).

The same child can appear SEVERAL times in the child list, in which case it is never deleted (the first occurence is just removed from the list)

Subclasses that require a specific behavior should not redefine this function but removeImpl(), that is called internally by all remove functions

§ remove() [2/3]

UElem& ubit::UElem::remove ( int  pos,
bool  auto_delete = true 
)

removes/deletes a child (and its descendants) at this position in the CHILD list.

'pos' must be a valid position (positions start from 0, -1 indicates the last child)

See also
: remove(UNode&, bool) for important details on removal vs. deletion.

§ remove() [3/3]

UElem& ubit::UElem::remove ( UChildIter  pos,
bool  auto_delete = true 
)

removes/deletes a child (and its descendants) at this position in the CHILD list.

'pos' must be an iterator pointing to the child that must be removed or deleted.

See also
: remove(UNode&, bool).

§ removeAll()

UElem & UElem::removeAll ( bool  auto_delete = true)

removes/deletes all children (and their descendants) in the CHILD list.

See also
: remove(UNode&, bool).

§ removeAllAttrs()

UElem & UElem::removeAllAttrs ( bool  auto_delete = true)
virtual

removes/deletes all attributes (and their descendants) in the ATTRIBUTE list.

See also
: remove(UNode&, bool) for details (both functions work in the same way). NOTE that the removed attributes are destroyed if they were created by 'new' and are not referenced elsewhere by a widget or a UPtr smart pointer (
UNode)

Reimplemented from ubit::UNode.

§ removeAttr()

UElem & UElem::removeAttr ( UNode attribute,
bool  auto_delete = true 
)

removes/deletes an attribute (and its descendants) from the ATTRIBUTE list.

See also
: remove(UNode&, bool) for details (both functions work in the same way). NOTE that the removed attribute object is destroyed if it was created by 'new' and is not referenced elsewhere by a widget or a UPtr smart pointer (
UNode)

§ retrieveText() [1/2]

virtual UStr ubit::UElem::retrieveText ( bool  recursive = true) const
virtual

collates and returns the text that is enclosed in this object.

'recursive' means that the text included in descendants is also collated.

§ retrieveText() [2/2]

virtual void ubit::UElem::retrieveText ( UStr string,
bool  recursive = true 
) const
virtual

collates and returns the text that is enclosed in this object.

'recursive' means that the text included in descendants is also collated.

§ setAttr()

UElem & UElem::setAttr ( UNode attribute)

adds or replaces this attribute in the ATTRIBUTE list.

NOTE that the previous attribute object is destroyed if it was created by 'new' and is not referenced elsewhere by a widget or a UPtr smart pointer (

See also
UNode)

§ setEnabled()

UElem & UElem::setEnabled ( bool  state = true,
bool  call_callbacks = true 
)
virtual

specifies whether this object is enabled.

§ setSelected()

UElem & UElem::setSelected ( bool  state = true,
bool  call_callbacks = true 
)
virtual

specifies whether this object is selected.

fires related callbacks if 'call_callbacks' is true

Reimplemented in ubit::UCheckbox.

§ show()

void UElem::show ( bool  state = true)
virtual

shows/hides this object.

See also
also: isShown(), isShowable(), update()

Reimplemented in ubit::UAlertbox, ubit::UWin, ubit::UFrame, ubit::UPiemenu, ubit::UMenu, and ubit::UDialog.

§ update()

virtual void ubit::UElem::update ( const UUpdate update_options,
UDisp = null 
)
virtual

indicates that the layout and/or the paint of this object will be updated.

this will be done when the main loop becomes idle.

  • the first argument specify what must be updated and misc options (see UUpdate)
  • the second argument is only taken into account by redefinitions of this function
    See also
    also: repaint(), update(), show().

Reimplemented in ubit::UWin, and ubit::UBox.


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