IGUIListBox.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef IRR_I_GUI_LIST_BOX_H_INCLUDED
  5. #define IRR_I_GUI_LIST_BOX_H_INCLUDED
  6. #include "IGUIElement.h"
  7. #include "SColor.h"
  8. namespace irr
  9. {
  10. namespace gui
  11. {
  12. class IGUISpriteBank;
  13. class IGUIScrollBar;
  14. //! Enumeration for listbox colors
  15. enum EGUI_LISTBOX_COLOR
  16. {
  17. //! Color of text
  18. EGUI_LBC_TEXT=0,
  19. //! Color of selected text
  20. EGUI_LBC_TEXT_HIGHLIGHT,
  21. //! Color of icon
  22. EGUI_LBC_ICON,
  23. //! Color of selected icon
  24. EGUI_LBC_ICON_HIGHLIGHT,
  25. //! Color of background.
  26. //! Note that this one is drawn over the listbox background and when not used there is no other default
  27. EGUI_LBC_BACKGROUND,
  28. //! Color of selected background
  29. EGUI_LBC_BACKGROUND_HIGHLIGHT,
  30. //! Not used, just counts the number of available colors
  31. EGUI_LBC_COUNT
  32. };
  33. //! Default list box GUI element.
  34. /** \par This element can create the following events of type EGUI_EVENT_TYPE:
  35. \li EGET_LISTBOX_CHANGED
  36. \li EGET_LISTBOX_SELECTED_AGAIN
  37. */
  38. class IGUIListBox : public IGUIElement
  39. {
  40. public:
  41. //! constructor
  42. IGUIListBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
  43. : IGUIElement(EGUIET_LIST_BOX, environment, parent, id, rectangle) {}
  44. //! returns amount of list items
  45. virtual u32 getItemCount() const = 0;
  46. //! returns string of a list item. the may id be a value from 0 to itemCount-1
  47. virtual const wchar_t* getListItem(u32 id) const = 0;
  48. //! adds an list item with an icon
  49. /** \param text Text of list entry
  50. \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon
  51. \return The id of the new created item */
  52. virtual u32 addItem(const wchar_t* text, s32 icon=-1) = 0;
  53. //! Insert the item at the given index
  54. /** \return The index on success or -1 on failure. */
  55. virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon=-1) = 0;
  56. //! set the item at the given index
  57. virtual void setItem(u32 index, const wchar_t* text, s32 icon=-1) = 0;
  58. //! Removes an item from the list
  59. virtual void removeItem(u32 index) = 0;
  60. //! get the the id of the item at the given absolute coordinates
  61. /** \return The id of the list item or -1 when no item is at those coordinates*/
  62. virtual s32 getItemAt(s32 xpos, s32 ypos) const = 0;
  63. //! Returns the icon of an item
  64. virtual s32 getIcon(u32 index) const = 0;
  65. //! Sets the sprite bank which should be used to draw list icons.
  66. /** This font is set to the sprite bank of the built-in-font by
  67. default. A sprite can be displayed in front of every list item.
  68. An icon is an index within the icon sprite bank. Several
  69. default icons are available in the skin through getIcon. */
  70. virtual void setSpriteBank(IGUISpriteBank* bank) = 0;
  71. //! clears the list, deletes all items in the listbox
  72. virtual void clear() = 0;
  73. //! returns id of selected item. returns -1 if no item is selected.
  74. virtual s32 getSelected() const = 0;
  75. //! sets the selected item. Set this to -1 if no item should be selected
  76. virtual void setSelected(s32 index) = 0;
  77. //! sets the selected item. Set this to 0 if no item should be selected
  78. virtual void setSelected(const wchar_t *item) = 0;
  79. //! set whether the listbox should scroll to newly selected items
  80. virtual void setAutoScrollEnabled(bool scroll) = 0;
  81. //! returns true if automatic scrolling is enabled, false if not.
  82. virtual bool isAutoScrollEnabled() const = 0;
  83. //! set all item colors at given index to color
  84. virtual void setItemOverrideColor(u32 index, video::SColor color) = 0;
  85. //! set all item colors of specified type at given index to color
  86. virtual void setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, video::SColor color) = 0;
  87. //! clear all item colors at index
  88. virtual void clearItemOverrideColor(u32 index) = 0;
  89. //! clear item color at index for given colortype
  90. virtual void clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) = 0;
  91. //! has the item at index its color overwritten?
  92. virtual bool hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const = 0;
  93. //! return the overwrite color at given item index.
  94. virtual video::SColor getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const = 0;
  95. //! return the default color which is used for the given colorType
  96. virtual video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const = 0;
  97. //! Swap the items at the given indices
  98. virtual void swapItems(u32 index1, u32 index2) = 0;
  99. //! set global itemHeight
  100. virtual void setItemHeight( s32 height ) = 0;
  101. //! Sets whether to draw the background
  102. virtual void setDrawBackground(bool draw) = 0;
  103. //! Access the vertical scrollbar
  104. virtual IGUIScrollBar* getVerticalScrollBar() const = 0;
  105. };
  106. } // end namespace gui
  107. } // end namespace irr
  108. #endif