#include <ugroup.hpp>
Inheritance diagram for ubit::UGroup:
Public Types | |
REMOVE_FROM_PARENTS = -1 | |
enum | { REMOVE_FROM_PARENTS = -1 } |
Public Member Functions | |
const UStyle & | getStyle (UContext *) const |
virtual function that returns the UStyle of this object. | |
UGroup (const UArgs &=UArgs::none) | |
creates a new UGroup; see also the ugroup() shortcut. | |
virtual | ~UGroup () |
recursive destructor. | |
virtual UGroup * | groupCast () |
dynamic cast. | |
virtual unsigned short | getNodeType () const |
returns the XML node type. | |
virtual const UStr * | getNodeName () const |
return the XML node name. | |
virtual const UStr * | getNodeValue () const |
return the XML node value. | |
virtual void | initNode (UDoc *context) |
initialises the XML context of this node. | |
virtual bool | isParentOf (const UBrick &possible_child) const |
returns true if this object a direct or indirect parent of 'child'. | |
virtual UGroup & | addlist (const UArgs &child_list) |
adds a list of arguments to the end the child list. | |
virtual UChildIter | add (const UChild &) |
adds an object (deriving from UBrick) to the end of the child list. | |
virtual UChildIter | add (const UChild &, int position) |
virtual UChildIter | add (const UChild &, UChildIter position) |
virtual UChildIter | remove (UBrick &, bool auto_delete=true) |
removes/deletes an object (and its descendants) from the child list. | |
virtual UChildIter | removeNC (UBrick &, bool auto_delete=true) |
removes/deletes an object (and its descendants) from the child list. | |
virtual UChildIter | remove (int position, bool auto_delete=true) |
removes/deletes an object (and its descendants) at this position in the child list. | |
virtual UChildIter | remove (UChildIter position, bool auto_delete=true) |
removes/deletes an object (and its descendants) at this position in the child list. | |
virtual void | removeAll (bool auto_delete=true) |
removes/delete all children and their descendants. | |
UChildIter | cbegin () const |
returns a forward iterator pointing to the beginning of the child list. | |
UChildIter | cend () const |
returns a forward iterator pointing to the end of the child list ( | |
UChildReverseIter | crbegin () const |
returns a reverse iterator pointing to the beginning of the child list ( | |
UChildReverseIter | crend () const |
returns a reverse iterator pionting to the end of the child list ( | |
virtual UChildren & | children () const |
return the child list. | |
UChildIter | child (int position) const |
returns an iterator pointing to the child at this position; returns cend() if position is out of bounds ( | |
UBrick * | getChild (int position) const |
returns the child at this position; returns null if position is out of bounds ( | |
virtual UStr | retrieveText (bool recursive=true) const |
virtual void | retrieveText (UStr &to, bool recursive=true) const |
collates and returns the text that is enclosed in this object. | |
virtual void | addAttr (const UChild &attribute) |
adds an attribute (that should derive from UAttribute) to the end of the attribute list. | |
virtual void | removeAttr (UBrick &attribute, bool auto_delete=true) |
removes an object from the attribute list (may DELETE 'x' AND its descendants if 'auto_delete' is true). | |
virtual void | removeAttrNC (UBrick &attr, bool auto_delete=true) |
virtual void | removeAllAttrs (bool auto_del=true) |
removes *or* DELETES all attributes AND their descendants. | |
UChildIter | abegin () const |
returns an iterator to the beginning the attribute list. | |
UChildIter | aend () const |
returns an iterator to the end of the attribute list ( | |
virtual UChildren & | attributes () const |
returns the attribute list ( | |
virtual const UStr * | getAttr (const UStr &name, bool ignore_case=true) const |
returns the value of this attribute (null if not found). | |
virtual const UProp * | getAttrNode (const UStr &name, bool ignore_case=true) const |
returns the node of this attribute (null if not found). | |
virtual UProp * | getAttrNode (const UStr &name, bool ignore_case=true) |
returns the node of this attribute (null if not found). | |
virtual UProp * | setAttrNode (UProp *) |
changes an attribute. | |
virtual void | repaint () |
specifies that this object must be repainted. | |
virtual void | update () |
specifies that the layout and the paint of this object must be updated. | |
virtual void | update (const UUpdate &) |
specifies that the layout and/or the paint of this object must be updated. | |
UGroup & | autoUpdate (bool state) |
specify auto update policy: | |
virtual void | show (bool=true) |
show/hide this object. | |
void | hide () |
shortcut for show(false). | |
virtual void | close (int status=0) |
hides and "closes" this object By default, close() is equivalent to hide() but it is redefined by certain subclasses to perform appropriate actions. | |
virtual void | closeWin (int status=0) |
closes the first window (UDialog, UMenu. | |
virtual const UStr * | getTextSeparator () const |
returns the text separator used by retrieveText() for separating enclosed children | |
virtual UChildIter | addImpl (UChildren &, const UChild &, UChildIter, bool update, bool *should_update) |
implementation of all add methods; must be overriden if a subclass need to redefine add() methods. | |
virtual UChildIter | removeImpl (UChildren &, UChildIter, int rem_mode, bool update, bool *should_update) |
implementation of all remove methods; must be overriden if a subclass need to redefine remove() methods. | |
virtual bool | fire (UEvent &, const UOn &) const |
fires callback functions that matches this UOn condition. | |
virtual int | getRelatedViews (std::vector< UView * > &) const |
[impl] returns the views that are related to this object. | |
Static Public Member Functions | |
static UStyle * | createStyle () |
< important: all subclasses MUST contain this declaration. static function that returns the UStyle of this class (see details!). | |
static void | closeWinCB (UEvent &, int status) |
Friends | |
UGroup & | ugroup (const UArgs &a=UArgs::none) |
creator shortcut: returns *new UGroup(). |
This class is a very lightweight and general container. In contrast with UBox (and its subclasses) UGroup 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 "group" is destroyed, its direct and indirect children are ALSO destroyed EXCEPT if they have other parents OR if they are pointed by a uptr<> (Ubit Smart Pointer). See class UBrick for details.
Notes:
ubit::UGroup::~UGroup | ( | ) | [virtual] |
recursive destructor.
children are automatically destroyed if not pointed elsewhere in the instance graph or by a uptr<>. see class UBrick for details.
UChildIter ubit::UGroup::abegin | ( | ) | const |
returns an iterator to the beginning the attribute list.
UChildIter is a child iterator. It is compatible with standard STL algorithms. This example prints the class name of the attributes of an object :
UBrick* obj = ...; for (UChildIter c = obj->abegin(); c != obj->aend(); ++c) cout << (*c)->getClassName() << endl;
Reimplemented from ubit::UBrick.
UChildIter ubit::UGroup::add | ( | const UChild & | ) | [virtual] |
adds an object (deriving from UBrick) to the end of the child list.
Returns an iterator that points to the inserted object. Note that the same object can be added several times to the same parent.
void ubit::UGroup::addAttr | ( | const UChild & | attribute | ) | [virtual] |
adds an attribute (that should derive from UAttribute) to the end of the attribute list.
the argument can also be a conditionnal expression such as: UOn::selected / UColor::red or UOn::action / ucall(obj, &MyObj::callback)
Reimplemented from ubit::UBrick.
adds a list of arguments to the end the child list.
Exemple:
UGroup* g = new UGroup(); g->addlist( UColor::red + UFont::bold + "abcd" );
Reimplemented in ubit::UBox, and ubit::UWin.
UChildIter ubit::UGroup::aend | ( | ) | const |
returns an iterator to the end of the attribute list (
Reimplemented from ubit::UBrick.
virtual UChildren& ubit::UGroup::attributes | ( | ) | const [virtual] |
UGroup& ubit::UGroup::autoUpdate | ( | bool | state | ) |
UChildIter ubit::UGroup::cbegin | ( | ) | const |
returns 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:
UGroup* obj = ...; for (UChildIter i = obj->cbegin(); i != obj->cend(); ++i) cout << (*i)->getClassName() << endl;
UChildIter ubit::UGroup::cend | ( | ) | const |
UChildIter ubit::UGroup::child | ( | int | position | ) | const |
virtual UChildren& ubit::UGroup::children | ( | ) | const [virtual] |
void ubit::UGroup::close | ( | int | status = 0 |
) | [virtual] |
hides and "closes" this object By default, close() is equivalent to hide() but it is redefined by certain subclasses to perform appropriate actions.
If the object is a window (UWin subclass) this function is called when the "Close" button of the window decoration is clicked (see UWin::close())
Reimplemented in ubit::UWin, and ubit::UFrame.
void ubit::UGroup::closeWin | ( | int | status = 0 |
) | [virtual] |
closes the first window (UDialog, UMenu.
..) that contains this object. See UWin::close() for details on the 'status' arg.
UChildReverseIter ubit::UGroup::crbegin | ( | ) | const |
UStyle * ubit::UGroup::createStyle | ( | ) | [static] |
< important: all subclasses MUST contain this declaration. static function that returns the UStyle of this class (see details!).
this macro defines the UClass that corresponds to this class and:
Reimplemented in ubit::UBox, ubit::UVbox, ubit::UHbox, ubit::UFlowbox, ubit::UCardbox, ubit::UAlertbox, ubit::UBar, ubit::UStatusbar, ubit::USepar, ubit::ULabel, ubit::UItem, ubit::UButton, ubit::UTabbutton, ubit::UFlatbutton, ubit::ULinkbutton, ubit::URadiobutton, ubit::UCheckbox, ubit::USpinbox, ubit::UCtlmenu, ubit::UIconbox, ubit::UListbox, ubit::UCombobox, ubit::UMenubar, ubit::UMenu, ubit::UPopmenu, ubit::UPiemenu, ubit::UScrollbar, ubit::UScrollpane, ubit::USlider, ubit::UTable, ubit::UTrow, ubit::UTcell, ubit::UTextbox, ubit::UTextfield, ubit::UTextarea, ubit::UWin, ubit::UDialog, and ubit::UFrame.
UChildReverseIter ubit::UGroup::crend | ( | ) | const |
UBrick * ubit::UGroup::getChild | ( | int | position | ) | const |
returns the child at this position; returns null if position is out of bounds (
virtual function that returns the UStyle of this object.
this function calls createStyle() the first time it is called.
UChildIter ubit::UGroup::remove | ( | UChildIter | position, | |
bool | auto_delete = true | |||
) | [virtual] |
removes/deletes an object (and its descendants) at this position in the child list.
UChildIter ubit::UGroup::remove | ( | int | position, | |
bool | auto_delete = true | |||
) | [virtual] |
removes/deletes an object (and its descendants) at this position in the child list.
the position is an integer (0 is the position of the first child).
UChildIter ubit::UGroup::remove | ( | UBrick & | , | |
bool | auto_delete = true | |||
) | [virtual] |
removes/deletes an object (and its descendants) from the child list.
void ubit::UGroup::removeAll | ( | bool | auto_delete = true |
) | [virtual] |
removes/delete all children and their descendants.
See remove(UBrick&, bool) for details
void ubit::UGroup::removeAllAttrs | ( | bool | auto_del = true |
) | [virtual] |
removes *or* DELETES all attributes AND their descendants.
works in the same way as removeAll()
Reimplemented from ubit::UBrick.
void ubit::UGroup::removeAttr | ( | UBrick & | attribute, | |
bool | auto_delete = true | |||
) | [virtual] |
removes an object from the attribute list (may DELETE 'x' AND its descendants if 'auto_delete' is true).
the functions work in the same way as remove(UBrick&, bool)
UChildIter ubit::UGroup::removeNC | ( | UBrick & | , | |
bool | auto_delete = true | |||
) | [virtual] |
removes/deletes an object (and its descendants) from the child list.
Same as remove(UBrick&, bool) except that no error message is issued if the object does not belong toe the child list
virtual void ubit::UGroup::repaint | ( | ) | [virtual] |
specifies that this object must be repainted.
note that actual painting is generally delayed (
Reimplemented in ubit::UBox, and ubit::UWin.
void ubit::UGroup::retrieveText | ( | UStr & | to, | |
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.
void ubit::UGroup::show | ( | bool | = true |
) | [virtual] |
show/hide this object.
objects are shown by default (except UWin subclasses).
Reimplemented in ubit::UAlertbox, ubit::UMenu, ubit::UPiemenu, ubit::UWin, ubit::UDialog, and ubit::UFrame.
void ubit::UGroup::update | ( | const UUpdate & | ) | [virtual] |
specifies that the layout and/or the paint of this object must be updated.
the specific actions that will take place depend on the UUpdate argument. Note that these actions are generally delayed:
Implements ubit::UControl.
Reimplemented in ubit::UBox, and ubit::UWin.
virtual void ubit::UGroup::update | ( | ) | [virtual] |
specifies that the layout and the paint of this object must be updated.
note that these actions are generally delayed (
Reimplemented from ubit::UControl.
Reimplemented in ubit::UBox, and ubit::UWin.