iup_user.e 4.1 KB

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