iup_drop.e 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. class IUP_DROP
  2. -- Class used to display a dropdown list or a popup menu at IUP_MATRIX. How
  3. -- this will be displayed depend on the IUP_MATRIX callback that will be used
  4. -- to append its items. See IUP_MATRIX documentation.
  5. inherit
  6. IUP_WIDGET
  7. create {IUP}
  8. drop_widget
  9. feature {IUP}
  10. drop_widget (p: POINTER)
  11. do
  12. set_widget(p)
  13. end
  14. feature {ANY}
  15. --- Operations
  16. set_value (id: INTEGER)
  17. -- Set the list current value, id starts at 1.
  18. -- The default is always "1".
  19. require
  20. id >= 0
  21. do
  22. iup_open.set_int(Current, "VALUE", id)
  23. end
  24. get_previous_value: STRING
  25. -- The previously value in the cell where the drop is displayed.
  26. do
  27. Result := iup_open.get_attribute(Current, "PREVIOUSVALUE")
  28. end
  29. append_items (items: ARRAY[STRING])
  30. -- Append items at dropdown list or menu in the same order.
  31. local
  32. i: INTEGER
  33. do
  34. i := 1
  35. across
  36. items as ic
  37. loop
  38. iup_open.set_attribute(Current, i.out, ic.item)
  39. i := i + 1
  40. end
  41. iup_open.set_attribute_null(Current, i.out)
  42. end
  43. set_image_at (image_name: STRING; id_item: INTEGER)
  44. -- Image to be set at the correspondent menu item.
  45. -- id starts at 1. Only works when the drop is displayed like
  46. -- a popup menu. Ignored if id is out of bounds.
  47. require
  48. valid_id: id_item > 0
  49. do
  50. iup_open.set_attribute_id(Current, "IMAGE", id_item, image_name)
  51. end
  52. end
  53. -- The MIT License (MIT)
  54. -- Copyright (c) 2017, 2019 by German A. Arias
  55. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  56. -- of this software and associated documentation files (the "Software"), to deal
  57. -- in the Software without restriction, including without limitation the rights
  58. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  59. -- copies of the Software, and to permit persons to whom the Software is
  60. -- furnished to do so, subject to the following conditions:
  61. --
  62. -- The above copyright notice and this permission notice shall be included in
  63. -- all copies or substantial portions of the Software.
  64. --
  65. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  66. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  67. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  68. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  69. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  70. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  71. -- SOFTWARE.