Simplify/unify IGUIListBox interface.

Only needs one addItem function when using default parameters for icon.
Add default parameters for setIcon, insertIcon so they can be used easier with pure text.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6384 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2022-05-05 15:19:35 +00:00
parent 7b6115bcf1
commit 156463da4f
3 changed files with 16 additions and 29 deletions

View File

@ -49,14 +49,18 @@ namespace gui
//! returns string of a list item. the may id be a value from 0 to itemCount-1
virtual const wchar_t* getListItem(u32 id) const = 0;
//! adds an list item, returns id of item
virtual u32 addItem(const wchar_t* text) = 0;
//! adds an list item with an icon
/** \param text Text of list entry
\param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon
\return The id of the new created item */
virtual u32 addItem(const wchar_t* text, s32 icon) = 0;
virtual u32 addItem(const wchar_t* text, s32 icon=-1) = 0;
//! Insert the item at the given index
/** \return The index on success or -1 on failure. */
virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon=-1) = 0;
//! set the item at the given index
virtual void setItem(u32 index, const wchar_t* text, s32 icon=-1) = 0;
//! Removes an item from the list
virtual void removeItem(u32 index) = 0;
@ -114,13 +118,6 @@ namespace gui
//! return the default color which is used for the given colorType
virtual video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const = 0;
//! set the item at the given index
virtual void setItem(u32 index, const wchar_t* text, s32 icon) = 0;
//! Insert the item at the given index
/** \return The index on success or -1 on failure. */
virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon) = 0;
//! Swap the items at the given indices
virtual void swapItems(u32 index1, u32 index2) = 0;

View File

@ -97,13 +97,6 @@ s32 CGUIListBox::getIcon(u32 id) const
}
//! adds a list item, returns id of item
u32 CGUIListBox::addItem(const wchar_t* text)
{
return addItem(text, -1);
}
//! adds a list item, returns id of item
void CGUIListBox::removeItem(u32 id)
{

View File

@ -36,9 +36,6 @@ namespace gui
//! returns string of a list item. the id may be a value from 0 to itemCount-1
virtual const wchar_t* getListItem(u32 id) const IRR_OVERRIDE;
//! adds an list item, returns id of item
virtual u32 addItem(const wchar_t* text) IRR_OVERRIDE;
//! clears the list
virtual void clear() IRR_OVERRIDE;
@ -62,7 +59,14 @@ namespace gui
//! \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon
//! \return
//! returns the id of the new created item
virtual u32 addItem(const wchar_t* text, s32 icon) IRR_OVERRIDE;
virtual u32 addItem(const wchar_t* text, s32 icon=-1) IRR_OVERRIDE;
//! Insert the item at the given index
//! Return the index on success or -1 on failure.
virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon=-1) IRR_OVERRIDE;
//! set the item at the given index
virtual void setItem(u32 index, const wchar_t* text, s32 icon=-1) IRR_OVERRIDE;
//! Returns the icon of an item
virtual s32 getIcon(u32 id) const IRR_OVERRIDE;
@ -115,13 +119,6 @@ namespace gui
//! return the default color which is used for the given colorType
virtual video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const IRR_OVERRIDE;
//! set the item at the given index
virtual void setItem(u32 index, const wchar_t* text, s32 icon) IRR_OVERRIDE;
//! Insert the item at the given index
//! Return the index on success or -1 on failure.
virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon) IRR_OVERRIDE;
//! Swap the items at the given indices
virtual void swapItems(u32 index1, u32 index2) IRR_OVERRIDE;