Crazy Eddie's GUI System  0.8.4
CEGUI::ItemListBase Class Reference

Base class for item list widgets. More...

+ Inheritance diagram for CEGUI::ItemListBase:
+ Collaboration diagram for CEGUI::ItemListBase:

List of all members.

Public Types

enum  SortMode { Ascending, Descending, UserSort }
 Sort modes for ItemListBase.
typedef bool(* SortCallback )(const ItemEntry *a, const ItemEntry *b)

Public Member Functions

size_t getItemCount (void) const
 Return number of items attached to the list.
ItemEntrygetItemFromIndex (size_t index) const
 Return the item at index position index.
size_t getItemIndex (const ItemEntry *item) const
 Return the index of ItemEntry item.
ItemEntryfindItemWithText (const String &text, const ItemEntry *start_item)
 Search the list for an item with the specified text.
bool isItemInList (const ItemEntry *item) const
 Return whether the specified ItemEntry is in the List.
bool isAutoResizeEnabled () const
 Return whether this window is automatically resized to fit its content.
bool isSortEnabled (void) const
 Returns 'true' if the list is sorted.
SortMode getSortMode (void) const
 Get sort mode.
SortCallback getSortCallback (void) const
 Get user sorting callback.
virtual void initialiseComponents (void)
 Initialise the Window based object ready for use.
void resetList (void)
 Remove all items from the list.
void addItem (ItemEntry *item)
 Add the given ItemEntry to the list.
void insertItem (ItemEntry *item, const ItemEntry *position)
 Insert an item into the list before a specified item already in the list.
void removeItem (ItemEntry *item)
 Removes the given item from the list. If the item is has the 'DestroyedByParent' property set to 'true', the item will be deleted.
void handleUpdatedItemData (bool resort=false)
 Causes the list to update it's internal state after changes have been made to one or more attached ItemEntry objects.
void setAutoResizeEnabled (bool setting)
 Set whether or not this ItemListBase widget should automatically resize to fit its content.
virtual void sizeToContent (void)
 Resize the ItemListBase to exactly fit the content that is attached to it. Return a Rect object describing, in un-clipped pixels, the window relative area that is to be used for rendering items.
virtual void endInitialisation (void)
 Triggers a ListContentsChanged event. These are not fired during initialisation for optimization purposes.
void performChildWindowLayout (bool nonclient_sized_hint=false, bool client_sized_hint=false)
Rectf getItemRenderArea (void) const
 Return a Rect object describing, in un-clipped pixels, the window relative area that is to be used for rendering list items.
WindowgetContentPane (void) const
 Returns a pointer to the window that all items are directed too.
virtual void notifyItemClicked (ItemEntry *)
 Notify this ItemListBase that the given item was just clicked. Internal function - NOT to be used from client code.
virtual void notifyItemSelectState (ItemEntry *, bool)
 Notify this ItemListBase that the given item just changed selection state. Internal function - NOT to be used from client code.
void setSortEnabled (bool setting)
 Set whether the list should be sorted (by text).
void setSortMode (SortMode mode)
 Set mode to be used when sorting the list.
void setSortCallback (SortCallback cb)
 Set a user callback as sorting function.
void sortList (bool relayout=true)
 Sort the list.
 ItemListBase (const String &type, const String &name)
 Constructor for ItemListBase base class.
virtual ~ItemListBase (void)
 Destructor for ItemListBase base class.

Static Public Attributes

static const String EventNamespace
 Namespace for global events.
static const String EventListContentsChanged
static const String EventSortEnabledChanged
static const String EventSortModeChanged

Protected Types

typedef std::vector< ItemEntry
*CEGUI_VECTOR_ALLOC(ItemEntry *) 
ItemEntryList )

Protected Member Functions

virtual void sizeToContent_impl (void)
 Resize the ItemListBase to exactly fit the content that is attached to it. Return a Rect object describing, in un-clipped pixels, the window relative area that is to be used for rendering items.
virtual Sizef getContentSize () const =0
 Returns the Size in unclipped pixels of the content attached to this ItemListBase that is attached to it.
virtual void layoutItemWidgets ()=0
 Return a Rect object describing, in un-clipped pixels, the window relative area that is to be used for rendering list items.
bool resetList_impl (void)
 Remove all items from the list.
virtual bool validateWindowRenderer (const WindowRenderer *renderer) const
 Function used in checking if a WindowRenderer is valid for this window.
SortCallback getRealSortCallback (void) const
 Returns the SortCallback that's really going to be used for the sorting operation.
virtual void onListContentsChanged (WindowEventArgs &e)
 Handler called internally when the list contents are changed.
virtual void onSortEnabledChanged (WindowEventArgs &e)
 Handler called internally when sorting gets enabled.
virtual void onSortModeChanged (WindowEventArgs &e)
 Handler called internally when the sorting mode is changed.
virtual void onParentSized (ElementEventArgs &e)
 Handler called when this window's parent window has been resized. If this window is the root / GUI Sheet window, this call will be made when the display size changes.
virtual bool handle_PaneChildRemoved (const EventArgs &e)
 Handler to manage items being removed from the content pane. If there is one!

Protected Attributes

ItemEntryList d_listItems
 list of items in the list.
bool d_autoResize
 Pointer to the content pane (for items), 0 if we're not using one.
Windowd_pane
 True if this ItemListBase is sorted. False if not.
bool d_sortEnabled
 The current sorting mode applied if sorting is enabled.
SortMode d_sortMode
 The user sort callback or 0 if none.
SortCallback d_sortCallback
 True if the list needs to be resorted.
bool d_resort

Detailed Description

Base class for item list widgets.


Member Function Documentation

Add the given ItemEntry to the list.

Parameters:
itemPointer to the ItemEntry to be added to the list. Note that it is the passed object that is added to the list, a copy is not made. If this parameter is NULL, nothing happens.
Returns:
Nothing.
ItemEntry* CEGUI::ItemListBase::findItemWithText ( const String text,
const ItemEntry start_item 
)

Search the list for an item with the specified text.

Parameters:
textString object containing the text to be searched for.
start_itemItemEntry where the search is to begin, the search will not include item. If item is NULL, the search will begin from the first item in the list.
Returns:
Pointer to the first ItemEntry in the list after item that has text matching text. If no item matches the criteria NULL is returned.
Exceptions:
InvalidRequestExceptionthrown if item is not attached to this list box.
Window* CEGUI::ItemListBase::getContentPane ( void  ) const [inline]

Returns a pointer to the window that all items are directed too.

Returns:
A pointer to the content pane window, or 'this' if children are added directly to this window.
virtual Sizef CEGUI::ItemListBase::getContentSize ( ) const [protected, pure virtual]

Returns the Size in unclipped pixels of the content attached to this ItemListBase that is attached to it.

Returns:
Size object describing in unclipped pixels the size of the content ItemEntries attached to this menu.

Implemented in CEGUI::ItemListbox, CEGUI::PopupMenu, and CEGUI::Menubar.

size_t CEGUI::ItemListBase::getItemCount ( void  ) const [inline]

Return number of items attached to the list.

Returns:
the number of items currently attached to this list.

Return the item at index position index.

Parameters:
indexZero based index of the item to be returned.
Returns:
Pointer to the ItemEntry at index position index in the list.
Exceptions:
InvalidRequestExceptionthrown if index is out of range.
size_t CEGUI::ItemListBase::getItemIndex ( const ItemEntry item) const

Return the index of ItemEntry item.

Parameters:
itemPointer to a ItemEntry whos zero based index is to be returned.
Returns:
Zero based index indicating the position of ItemEntry item in the list.
Exceptions:
InvalidRequestExceptionthrown if item is not attached to this list.

Return a Rect object describing, in un-clipped pixels, the window relative area that is to be used for rendering list items.

Returns:
Rect object describing the window relative area of the that is to be used for rendering the items.
virtual bool CEGUI::ItemListBase::handle_PaneChildRemoved ( const EventArgs e) [protected, virtual]

Handler to manage items being removed from the content pane. If there is one!

Note:
If you override this, you should call this base class version to ensure correct behaviour is maintained.

Reimplemented in CEGUI::ItemListbox.

void CEGUI::ItemListBase::handleUpdatedItemData ( bool  resort = false)

Causes the list to update it's internal state after changes have been made to one or more attached ItemEntry objects.

It should not be necessary to call this from client code, as the ItemEntries themselves call it if their parent is an ItemListBase.

Parameters:
resort'true' to redo the list sorting as well. 'false' to only do layout and perhaps auto resize. (defaults to 'false')
Returns:
Nothing.
virtual void CEGUI::ItemListBase::initialiseComponents ( void  ) [virtual]

Initialise the Window based object ready for use.

Note:
This must be called for every window created. Normally this is handled automatically by the WindowFactory for each Window type.
Returns:
Nothing

Reimplemented from CEGUI::Window.

Reimplemented in CEGUI::ScrolledItemListBase.

void CEGUI::ItemListBase::insertItem ( ItemEntry item,
const ItemEntry position 
)

Insert an item into the list before a specified item already in the list.

Note that if the list is sorted, the item may not end up in the requested position.

Parameters:
itemPointer to the ItemEntry to be inserted. Note that it is the passed object that is added to the list, a copy is not made. If this parameter is NULL, nothing happens.
positionPointer to a ItemEntry that item is to be inserted before. If this parameter is NULL, the item is inserted at the start of the list.
Returns:
Nothing.

Return whether this window is automatically resized to fit its content.

Returns:
true if automatic resizing is enabled, false if it is disabled.
bool CEGUI::ItemListBase::isItemInList ( const ItemEntry item) const

Return whether the specified ItemEntry is in the List.

Returns:
true if ItemEntry item is in the list, false if ItemEntry item is not in the list.
virtual void CEGUI::ItemListBase::layoutItemWidgets ( ) [protected, pure virtual]

Return a Rect object describing, in un-clipped pixels, the window relative area that is to be used for rendering list items.

Returns:
Rect object describing the window relative area of the that is to be used for rendering the items.

Setup size and position for the item widgets attached to this ItemListBase

Returns:
Nothing.

Implemented in CEGUI::ItemListbox, CEGUI::PopupMenu, and CEGUI::Menubar.

virtual void CEGUI::ItemListBase::onParentSized ( ElementEventArgs e) [protected, virtual]

Handler called when this window's parent window has been resized. If this window is the root / GUI Sheet window, this call will be made when the display size changes.

Parameters:
eWindowEventArgs object whose 'window' pointer field is set the the window that caused the event; this is typically either this window's parent window, or NULL to indicate the screen size has changed.

Reimplemented from CEGUI::Window.

void CEGUI::ItemListBase::performChildWindowLayout ( bool  nonclient_sized_hint = false,
bool  client_sized_hint = false 
) [virtual]

Layout child window content.

Laying out of child content includes:

  • ensuring content specified in any assigned WidgetLook has its area rectangles sychronised.
  • assigned WindowRenderer given the opportunity to update child content areas as needed.
  • All content is then potentially updated via the onParentSized notification as required by changes in non-client and client area rectangles.

The system may call this at various times (like when a window is resized for example), and it may be invoked directly where required.

Parameters:
nonclient_sized_hintHint that the non-client area rectangle has changed size.
client_sized_hintHint that the client area rectangle has changed size.
Note:
The hint parameters are essentially a way to force onParentSized notifications for a given type (client / nonclient) of child window. Setting a hint to false does not mean a notification will not happen, instead it means that the function is to do its best to determine whether a given notification is required to be sent.

Reimplemented from CEGUI::Window.

Removes the given item from the list. If the item is has the 'DestroyedByParent' property set to 'true', the item will be deleted.

Parameters:
itemPointer to the ItemEntry that is to be removed. If item is not attached to this list then nothing will happen.
Returns:
Nothing.

Remove all items from the list.

Note that this will cause items, which does not have the 'DestroyedByParent' property set to 'false', to be deleted.

bool CEGUI::ItemListBase::resetList_impl ( void  ) [protected]

Remove all items from the list.

Note:
Note that this will cause items with the 'DestroyedByParent' property set to 'true', to be deleted.
Returns:
  • true if the list contents were changed.
  • false if the list contents were not changed (list already empty).

Set whether or not this ItemListBase widget should automatically resize to fit its content.

Parameters:
settingBoolean value that if true enables automatic resizing, if false disables automatic resizing.
Returns:
Nothing.
void CEGUI::ItemListBase::setSortCallback ( SortCallback  cb)

Set a user callback as sorting function.

Parameters:
modeSortCallback

Set mode to be used when sorting the list.

Parameters:
modeSortMode enum.
virtual void CEGUI::ItemListBase::sizeToContent ( void  ) [inline, virtual]

Resize the ItemListBase to exactly fit the content that is attached to it. Return a Rect object describing, in un-clipped pixels, the window relative area that is to be used for rendering items.

Returns:
Nothing
virtual void CEGUI::ItemListBase::sizeToContent_impl ( void  ) [protected, virtual]

Resize the ItemListBase to exactly fit the content that is attached to it. Return a Rect object describing, in un-clipped pixels, the window relative area that is to be used for rendering items.

Returns:
Nothing
void CEGUI::ItemListBase::sortList ( bool  relayout = true)

Sort the list.

Parameters:
relayoutTrue if the item layout should be redone after the sorting. False to only sort the internal list. Nothing more.

This parameter defaults to true and should generally not be used in client code.

virtual bool CEGUI::ItemListBase::validateWindowRenderer ( const WindowRenderer renderer) const [protected, virtual]

Function used in checking if a WindowRenderer is valid for this window.

Parameters:
rendererWindow renderer that will be checked (it can be null!)
Returns:
Returns true if the given WindowRenderer class name is valid for this window. False if not.

Reimplemented from CEGUI::Window.


Member Data Documentation

ItemEntryList CEGUI::ItemListBase::d_listItems [protected]

list of items in the list.

True if this ItemListBase widget should automatically resize to fit its content. False if not.

Event fired when the contents of the list is changed. Handlers are passed a const WindowEventArgs reference with WindowEventArgs::window set to the ItemListBase whose contents has changed.

Event fired when the sort enabled state of the list is changed. Handlers are passed a const WindowEventArgs reference with WindowEventArgs::window set to the ItemListBase whose sort enabled mode has been changed.

Event fired when the sort mode of the list is changed. Handlers are passed a const WindowEventArgs reference with WindowEventArgs::window set to the ItemListBase whose sorting mode has been changed.

 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends