IGUIComboBox.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #pragma once
  5. #include "IGUIElement.h"
  6. namespace irr
  7. {
  8. namespace gui
  9. {
  10. //! Combobox widget
  11. /** \par This element can create the following events of type EGUI_EVENT_TYPE:
  12. \li EGET_COMBO_BOX_CHANGED
  13. */
  14. class IGUIComboBox : public IGUIElement
  15. {
  16. public:
  17. //! constructor
  18. IGUIComboBox(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect<s32> rectangle) :
  19. IGUIElement(EGUIET_COMBO_BOX, environment, parent, id, rectangle) {}
  20. //! Returns amount of items in box
  21. virtual u32 getItemCount() const = 0;
  22. //! Returns string of an item. the idx may be a value from 0 to itemCount-1
  23. virtual const wchar_t *getItem(u32 idx) const = 0;
  24. //! Returns item data of an item. the idx may be a value from 0 to itemCount-1
  25. virtual u32 getItemData(u32 idx) const = 0;
  26. //! Returns index based on item data
  27. virtual s32 getIndexForItemData(u32 data) const = 0;
  28. //! Adds an item and returns the index of it
  29. virtual u32 addItem(const wchar_t *text, u32 data = 0) = 0;
  30. //! Removes an item from the combo box.
  31. /** Warning. This will change the index of all following items */
  32. virtual void removeItem(u32 idx) = 0;
  33. //! Deletes all items in the combo box
  34. virtual void clear() = 0;
  35. //! Returns id of selected item. returns -1 if no item is selected.
  36. virtual s32 getSelected() const = 0;
  37. //! Sets the selected item. Set this to -1 if no item should be selected
  38. virtual void setSelected(s32 idx) = 0;
  39. //! Sets the selected item and emits a change event.
  40. /** Set this to -1 if no item should be selected */
  41. virtual void setAndSendSelected(s32 idx) = 0;
  42. //! Sets text justification of the text area
  43. /** \param horizontal: EGUIA_UPPERLEFT for left justified (default),
  44. EGUIA_LOWERRIGHT for right justified, or EGUIA_CENTER for centered text.
  45. \param vertical: EGUIA_UPPERLEFT to align with top edge,
  46. EGUIA_LOWERRIGHT for bottom edge, or EGUIA_CENTER for centered text (default). */
  47. virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) = 0;
  48. //! Set the maximal number of rows for the selection listbox
  49. virtual void setMaxSelectionRows(u32 max) = 0;
  50. //! Get the maximal number of rows for the selection listbox
  51. virtual u32 getMaxSelectionRows() const = 0;
  52. };
  53. } // end namespace gui
  54. } // end namespace irr