iup_widget_child.e 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. deferred class IUP_WIDGET_CHILD
  2. -- Commands to handle the attributes related with the child.
  3. inherit
  4. IUP_WIDGET_INTERNALS
  5. feature {ANY}
  6. -- Attributes to be used inside a container.
  7. set_cx (cx: INTEGER)
  8. -- X coordinate of the position to be used inside a IUP_CBOX container.
  9. require
  10. non_negative: cx >= 0
  11. do
  12. iup_open.set_attribute(Current, "CX", cx.out)
  13. end
  14. get_cx: INTEGER
  15. -- Return the x coordinate used inside a IUP_CBOX container.
  16. local
  17. cx: STRING
  18. do
  19. cx := iup_open.get_attribute(Current, "CX")
  20. Result := cx.to_integer
  21. end
  22. set_cy (cy: INTEGER)
  23. -- Y coordinate of the position to be used inside a IUP_CBOX container.
  24. require
  25. non_negative: cy >= 0
  26. do
  27. iup_open.set_attribute(Current, "CY", cy.out)
  28. end
  29. get_cy: INTEGER
  30. -- Return the y coordinate used inside a IUP_CBOX container.
  31. local
  32. cy: STRING
  33. do
  34. cy := iup_open.get_attribute(Current, "CY")
  35. Result := cy.to_integer
  36. end
  37. set_expand_weight (value: INTEGER)
  38. -- (non inheritable) (at children only): If a child defines the expand
  39. -- weight, then it is used to multiply the free space used for expansion.
  40. do
  41. iup_open.set_attribute(Current, "EXPANDWEIGHT", value.out)
  42. end
  43. get_expand_weight: INTEGER
  44. -- Return the value of expandweight.
  45. local
  46. str: STRING
  47. do
  48. str := iup_open.get_attribute(Current, "EXPANDWEIGHT")
  49. Result := str.to_integer
  50. end
  51. set_tab_title (value: STRING)
  52. -- (non inheritable) (at children only): Same as TABTITLEn in
  53. -- IUP_TABS but set in each child. Works only if set before the child is
  54. -- added to the tabs.
  55. do
  56. iup_open.set_attribute(Current, "TABTITLE", value)
  57. end
  58. get_tab_title: STRING
  59. -- Return the value of tabtitle.
  60. do
  61. Result := iup_open.get_attribute(Current, "TABTITLE")
  62. end
  63. set_tab_image (value: STRING)
  64. -- (non inheritable) (at children only): Same as TABIMAGEn in
  65. -- IUP_TABS but set in each child. Works only if set before the child is
  66. -- added to the tabs.
  67. do
  68. iup_open.set_attribute(Current, "TABIMAGE", value)
  69. end
  70. get_tab_image: STRING
  71. -- Return the value of tabimage.
  72. do
  73. Result := iup_open.get_attribute(Current, "TABIMAGE")
  74. end
  75. -- Commands to handle the hierarchy
  76. detach
  77. -- Detaches the interface element from its parent.
  78. do
  79. iup_open.iup_detach(Current)
  80. end
  81. get_parent: detachable IUP_CONTAINER
  82. -- Return the parent of the element or void if does not have a parent.
  83. do
  84. if attached {IUP_CONTAINER} iup_open.iup_get_parent(Current) as pr then
  85. Result := pr
  86. end
  87. end
  88. get_brother: detachable IUP_WIDGET
  89. -- Return the next element in the parent where this element is
  90. -- placed or void if there is none.
  91. do
  92. Result := iup_open.iup_get_brother(Current)
  93. end
  94. get_dialog: detachable IUP_DIALOG
  95. -- Returns the dialog that contains this interface element. Works
  96. -- also for children of a menu that is associated with a dialog.
  97. -- Returns: the dialog or void if not found.
  98. do
  99. if attached {IUP_DIALOG} iup_open.iup_get_dialog(Current) as dlg then
  100. Result := dlg
  101. end
  102. end
  103. set_normalizer_group (name: STRING)
  104. -- (non inheritable): name of a normalizer element to which to
  105. -- automatically add the control. If an element with that name does not
  106. -- exists then one is created.
  107. do
  108. iup_open.set_attribute(Current, "NORMALIZERGROUP", name)
  109. end
  110. -- For widgets at IUP_MULTI_BOX
  111. set_line_break (state: BOOLEAN)
  112. -- Force a line break after the child when ORIENTATION=HORIZONTAL.
  113. do
  114. if state then
  115. iup_open.set_attribute(Current, "LINEBREAK", "YES")
  116. else
  117. iup_open.set_attribute_null(Current, "LINEBREAK")
  118. end
  119. end
  120. set_column_break (state: BOOLEAN)
  121. -- Force a column break after the child when ORIENTATION=VERTICAL.
  122. do
  123. if state then
  124. iup_open.set_attribute(Current, "COLUMNBREAK", "YES")
  125. else
  126. iup_open.set_attribute_null(Current, "COLUMNBREAK")
  127. end
  128. end
  129. end
  130. -- The MIT License (MIT)
  131. -- Copyright (c) 2016, 2017, 2018, 2019 by German A. Arias
  132. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  133. -- of this software and associated documentation files (the "Software"), to deal
  134. -- in the Software without restriction, including without limitation the rights
  135. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  136. -- copies of the Software, and to permit persons to whom the Software is
  137. -- furnished to do so, subject to the following conditions:
  138. --
  139. -- The above copyright notice and this permission notice shall be included in
  140. -- all copies or substantial portions of the Software.
  141. --
  142. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  143. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  144. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  145. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  146. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  147. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  148. -- SOFTWARE.