OpenGUI::WidgetCollection Class Reference

#include <OpenGUI_WidgetCollection.h>

List of all members.


Detailed Description

Ordered collection of Widget objects.

Maintains an ordered list of Widget pointers. Also provides the option to take ownership of heap allocated memory, and delete the given widget pointer on destruction.


Public Types

typedef collection_iterator<
WidgetCollectionItemPtrList::iterator > 
iterator
 WidgetCollection iterator.
typedef collection_iterator<
WidgetCollectionItemPtrList::reverse_iterator > 
reverse_iterator
 WidgetCollection reverse_iterator.

Public Member Functions

 WidgetCollection ()
 public constructor
 ~WidgetCollection ()
 public destructor
void add_front (Widget *widget, bool takeOwnership=false)
 Adds given widget pointer to the front of the collection.
void add_back (Widget *widget, bool takeOwnership=false)
 Adds given widget pointer to the back of the collection.
void remove (Widget *widget)
 Remove the given widget pointer from the collection.
void moveToFront (Widget *widget)
 Move the given widget pointer to the front of the collection.
void moveToBack (Widget *widget)
 Move the given widget to the back of the collection.
WidgetgetWidget (const std::string &widgetName) const
 returns a pointer to the requested widget or 0 if not found
Widgetoperator[] (const std::string &widgetName)
 returns a reference to the requested widget or throws an exception if not found
bool hasWidget (Widget *widget)
 returns true if the given widget pointer is in the collection
void attachListener (WidgetCollectionListener *listener)
 Attaches a WidgetCollectionListener to this WidgetCollection.
void detachListener (WidgetCollectionListener *listener)
 Removes a previously attached WidgetCollectionListener from this WidgetCollection.
void setParent (Object *object)
 Sets the hierarchical parent of this collection.
ObjectgetParent ()
 Gets the hierarchical parent of this collection.
void appendWidgetPtrList (WidgetPtrList &l) const
 Appends the contents of this collection to the end of the given WidgetPtrList, preserving the collection's order.
iterator begin ()
 returns an iterator for the collection starting at the beginning
iterator end ()
 returns an iterator for the collection starting off the end
reverse_iterator rbegin ()
 returns an iterator for the collection starting at the end
reverse_iterator rend ()
 returns an iterator for the collection starting off the beginning

Classes

class  collection_iterator
 Template class providing iterator encapsulation. More...


Member Typedef Documentation

typedef collection_iterator<WidgetCollectionItemPtrList::iterator> OpenGUI::WidgetCollection::iterator

WidgetCollection iterator.

typedef collection_iterator<WidgetCollectionItemPtrList::reverse_iterator> OpenGUI::WidgetCollection::reverse_iterator

WidgetCollection reverse_iterator.


Constructor & Destructor Documentation

OpenGUI::WidgetCollection::WidgetCollection (  ) 

public constructor

OpenGUI::WidgetCollection::~WidgetCollection (  ) 

public destructor


Member Function Documentation

void OpenGUI::WidgetCollection::add_back ( Widget widget,
bool  takeOwnership = false 
)

Adds given widget pointer to the back of the collection.

void OpenGUI::WidgetCollection::add_front ( Widget widget,
bool  takeOwnership = false 
)

Adds given widget pointer to the front of the collection.

void OpenGUI::WidgetCollection::appendWidgetPtrList ( WidgetPtrList l  )  const

Appends the contents of this collection to the end of the given WidgetPtrList, preserving the collection's order.

void OpenGUI::WidgetCollection::attachListener ( WidgetCollectionListener listener  ) 

Attaches a WidgetCollectionListener to this WidgetCollection.

WidgetCollection::iterator OpenGUI::WidgetCollection::begin (  ) 

returns an iterator for the collection starting at the beginning

void OpenGUI::WidgetCollection::detachListener ( WidgetCollectionListener listener  ) 

Removes a previously attached WidgetCollectionListener from this WidgetCollection.

WidgetCollection::iterator OpenGUI::WidgetCollection::end (  ) 

returns an iterator for the collection starting off the end

Object * OpenGUI::WidgetCollection::getParent (  ) 

Gets the hierarchical parent of this collection.

Widget * OpenGUI::WidgetCollection::getWidget ( const std::string &  widgetName  )  const

returns a pointer to the requested widget or 0 if not found

bool OpenGUI::WidgetCollection::hasWidget ( Widget widget  ) 

returns true if the given widget pointer is in the collection

void OpenGUI::WidgetCollection::moveToBack ( Widget widget  ) 

Move the given widget to the back of the collection.

void OpenGUI::WidgetCollection::moveToFront ( Widget widget  ) 

Move the given widget pointer to the front of the collection.

Widget & OpenGUI::WidgetCollection::operator[] ( const std::string &  widgetName  ) 

returns a reference to the requested widget or throws an exception if not found

WidgetCollection::reverse_iterator OpenGUI::WidgetCollection::rbegin (  ) 

returns an iterator for the collection starting at the end

void OpenGUI::WidgetCollection::remove ( Widget widget  ) 

Remove the given widget pointer from the collection.

If the collection was told to take ownership of the requested widget, this operation removes that ownership. The collection will no longer delete the removed widget on destruction.

Exceptions:
Exception if the widget is not part of this collection

WidgetCollection::reverse_iterator OpenGUI::WidgetCollection::rend (  ) 

returns an iterator for the collection starting off the beginning

void OpenGUI::WidgetCollection::setParent ( Object object  ) 

Sets the hierarchical parent of this collection.

Warning:
Do not take this operation lightly. Stealing ownership of WidgetCollections can lead to very unpredictable results. The general rule of thumb is, if you didn't create it, then you shouldn't be claiming ownership of it.
Deprecated:
May move this functionality into the constructor to ultimately eliminate the potential for misuse.


The documentation for this class was generated from the following files:
Copyright © 2006 OpenGUI | OpenGUI.SF.net
Generated: Fri Jan 5 23:05:27 2007