From 156463da4f1a0d788af1083f6e8bd3b53935f031 Mon Sep 17 00:00:00 2001 From: cutealien Date: Thu, 5 May 2022 15:19:35 +0000 Subject: [PATCH] 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 --- include/IGUIListBox.h | 19 ++++++++----------- source/Irrlicht/CGUIListBox.cpp | 7 ------- source/Irrlicht/CGUIListBox.h | 19 ++++++++----------- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/include/IGUIListBox.h b/include/IGUIListBox.h index a74b449..466f286 100644 --- a/include/IGUIListBox.h +++ b/include/IGUIListBox.h @@ -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; diff --git a/source/Irrlicht/CGUIListBox.cpp b/source/Irrlicht/CGUIListBox.cpp index 65434fa..7ec1869 100644 --- a/source/Irrlicht/CGUIListBox.cpp +++ b/source/Irrlicht/CGUIListBox.cpp @@ -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) { diff --git a/source/Irrlicht/CGUIListBox.h b/source/Irrlicht/CGUIListBox.h index 0afe81d..10a9e5f 100644 --- a/source/Irrlicht/CGUIListBox.h +++ b/source/Irrlicht/CGUIListBox.h @@ -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;