iup_user.e 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. class IUP_USER
  2. -- Creates a user element in IUP, which is not associated to any interface
  3. -- element. It is used to map an external element to a IUP element. Its use is
  4. -- usually for additional elements, but you can use it to create an Ihandle*
  5. -- to store private attributes.
  6. --
  7. -- It is also a void container. Its children can be dynamically added using
  8. -- append or insert.
  9. inherit
  10. IUP_WIDGET
  11. rename
  12. refresh as clear_attributes
  13. redefine
  14. clear_attributes
  15. end
  16. create {ANY}
  17. user
  18. feature {ANY}
  19. user
  20. local
  21. a_user: POINTER
  22. do
  23. a_user := int_user
  24. set_widget(a_user)
  25. end
  26. --- Operations
  27. clear_attributes
  28. -- (write-only, non inheritable): it will clear all attributes stored
  29. -- internally and remove all references.
  30. do
  31. iup_open.set_attribute(Current, "CLEARATTRIBUTES", "Yes")
  32. end
  33. -- Commands to handle heirarchy
  34. append (new_child: IUP_WIDGET): detachable IUP_WIDGET
  35. -- Inserts an interface element at the end of the container, after
  36. -- the last element of the container.
  37. -- Returns: the actual parent if the interface element was
  38. -- successfully inserted. Otherwise returns Void.
  39. do
  40. Result := iup_open.iup_append(Current, new_child)
  41. end
  42. insert (ref_child: IUP_WIDGET; new_child: IUP_WIDGET): detachable IUP_WIDGET
  43. -- Inserts an interface element before another child of the
  44. -- container.
  45. -- Returns: the actual parent if the interface element was
  46. -- successfully inserted. Otherwise returns NULL
  47. do
  48. Result := iup_open.iup_insert(Current, ref_child, new_child)
  49. end
  50. get_child (pos: INTEGER): detachable IUP_WIDGET
  51. -- Returns the a child of the control given its position.
  52. -- Returns: the child or Void if there is none.
  53. do
  54. Result := iup_open.iup_get_child(Current, pos)
  55. end
  56. get_child_pos (child: IUP_WIDGET): INTEGER
  57. -- Returns the position of a child of the given control.
  58. -- Returns: the position of the desire child starting at 0, or -1
  59. -- if child not found.
  60. do
  61. Result := iup_open.iup_get_child_pos(Current, child)
  62. end
  63. get_child_count: INTEGER
  64. -- Returns the number of children of the given control.
  65. do
  66. Result := iup_open.iup_get_child_count(Current)
  67. end
  68. get_next_child (child: IUP_WIDGET): detachable IUP_WIDGET
  69. -- Returns the a child of the given control given its brother.
  70. -- Returns: the child or Void.
  71. do
  72. Result := iup_open.iup_get_next_child(Current, child)
  73. end
  74. detach
  75. -- Detaches the interface element from its parent.
  76. do
  77. iup_open.iup_detach(Current)
  78. end
  79. get_parent: detachable IUP_WIDGET
  80. -- Return the parent of the element or void if does not have a parent.
  81. do
  82. Result := iup_open.iup_get_parent(Current)
  83. end
  84. get_brother: detachable IUP_WIDGET
  85. -- Return the next element in the parent where this element is
  86. -- placed or void if there is none.
  87. do
  88. Result := iup_open.iup_get_brother(Current)
  89. end
  90. feature {NONE}
  91. -- Internal
  92. int_user: POINTER
  93. external
  94. "C inline use %"eiffel-iup.h%""
  95. alias
  96. "return IupUser();"
  97. end
  98. end
  99. -- The MIT License (MIT)
  100. -- Copyright (c) 2016, 2019 by German A. Arias
  101. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  102. -- of this software and associated documentation files (the "Software"), to deal
  103. -- in the Software without restriction, including without limitation the rights
  104. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  105. -- copies of the Software, and to permit persons to whom the Software is
  106. -- furnished to do so, subject to the following conditions:
  107. --
  108. -- The above copyright notice and this permission notice shall be included in
  109. -- all copies or substantial portions of the Software.
  110. --
  111. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  112. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  113. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  114. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  115. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  116. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  117. -- SOFTWARE.