iup_lineal_box.e 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. deferred class IUP_LINEAL_BOX
  2. -- Abstract class for linear containers.
  3. inherit
  4. IUP_CONTAINER
  5. IUP_WIDGET_EXPAND
  6. IUP_WIDGET_SIZE
  7. IUP_WIDGET_RASTERSIZE
  8. IUP_WIDGET_USERSIZE
  9. IUP_WIDGET_WID
  10. IUP_WIDGET_FONT
  11. IUP_WIDGET_CLIENTSIZE
  12. IUP_WIDGET_CLIENTOFFSET
  13. IUP_WIDGET_POSITION
  14. IUP_WIDGET_MAXMIN_SIZE
  15. IUP_WIDGET_CHILD
  16. IUP_WIDGET_NAME
  17. IUP_WIDGET_CUSTOM_ATTRIBUTES
  18. IUP_WIDGET_NORMALIZE_SIZE
  19. feature {ANY}
  20. -- Attributes
  21. set_alignment (value: STRING)
  22. require
  23. is_valid: is_valid_alignment(value)
  24. do
  25. iup_open.set_attribute(Current, "ALIGNMENT", value)
  26. end
  27. get_alignment: STRING
  28. -- Return the value of the alignment.
  29. do
  30. Result := iup_open.get_attribute(Current, "ALIGNMENT")
  31. end
  32. set_gap (space: INTEGER)
  33. -- Defines a vertical space in pixels between the children. Default: "0".
  34. require
  35. space >= 0
  36. do
  37. iup_open.set_attribute(Current, "GAP", space.out)
  38. end
  39. get_gap: INTEGER
  40. -- Return the vertical space between the children.
  41. local
  42. value: STRING
  43. do
  44. value := iup_open.get_attribute(Current, "GAP")
  45. Result := value.to_integer
  46. end
  47. set_cgap (space: INTEGER)
  48. -- Defines a vertical space between the children in the same units of
  49. -- the SIZE attribute for the height. Default: "0".
  50. require
  51. space >= 0
  52. do
  53. iup_open.set_attribute(Current, "CGAP", space.out)
  54. end
  55. get_cgap: INTEGER
  56. -- Return the value of the attribute cgap.
  57. local
  58. value: STRING
  59. do
  60. value := iup_open.get_attribute(Current, "CGAP")
  61. Result := value.to_integer
  62. end
  63. set_ngap (space: INTEGER)
  64. -- Same as *GAP* but non inheritable.
  65. require
  66. space >= 0
  67. do
  68. iup_open.set_attribute(Current, "NGAP", space.out)
  69. end
  70. get_ngap: INTEGER
  71. -- Return the value of *NGAP* attribute.
  72. local
  73. value: STRING
  74. do
  75. value := iup_open.get_attribute(Current, "NGAP")
  76. Result := value.to_integer
  77. end
  78. set_ncgap (space: INTEGER)
  79. -- Same as *CGAP* but non inheritable.
  80. require
  81. space >= 0
  82. do
  83. iup_open.set_attribute(Current, "NCGAP", space.out)
  84. end
  85. get_ncgap: INTEGER
  86. -- Return the value of *NCGAP* attribute.
  87. local
  88. value: STRING
  89. do
  90. value := iup_open.get_attribute(Current, "NCGAP")
  91. Result := value.to_integer
  92. end
  93. set_homogeneous (state: BOOLEAN)
  94. -- (non inheritable): forces all children to get equal vertical space.
  95. -- The space height will be based on the highest child. Default: "NO".
  96. --Notice that this does not changes the children size, only the available
  97. --space for each one of them to expand.
  98. do
  99. iup_open.set_attribute(Current, "HOMOGENEOUS", boolean_to_yesno(state))
  100. end
  101. is_homogeneous: BOOLEAN
  102. -- Return the state of homogeneous.
  103. local
  104. str: STRING
  105. do
  106. str := iup_open.get_attribute(Current, "HOMOGENEOUS")
  107. Result := yesno_to_boolean(str)
  108. end
  109. set_margin (horizontal, vertical: INTEGER)
  110. -- Defines a margin in pixels. Default: "0x0" (no margin).
  111. require
  112. horizontal >= 0
  113. vertical >= 0
  114. local
  115. margin: STRING
  116. do
  117. margin := horizontal.out
  118. margin.append_string("x")
  119. margin.append_string(vertical.out)
  120. iup_open.set_attribute(Current, "MARGIN", margin)
  121. end
  122. get_margin: TUPLE[INTEGER, INTEGER]
  123. -- Return the value of the margins.
  124. local
  125. margin: STRING
  126. do
  127. margin := iup_open.get_attribute(Current, "MARGIN")
  128. Result := components_of_size(margin)
  129. end
  130. set_cmargin (horizontal, vertical: INTEGER)
  131. -- Defines a margin in the same units of the SIZE attribute.
  132. -- Default: "0x0" (no margin).
  133. require
  134. horizontal >= 0
  135. vertical >= 0
  136. local
  137. margin: STRING
  138. do
  139. margin := horizontal.out
  140. margin.append_string("x")
  141. margin.append_string(vertical.out)
  142. iup_open.set_attribute(Current, "CMARGIN", margin)
  143. end
  144. get_cmargin: TUPLE[INTEGER, INTEGER]
  145. -- Return the value of the CMARGIN.
  146. local
  147. margin: STRING
  148. do
  149. margin := iup_open.get_attribute(Current, "CMARGIN")
  150. Result := components_of_size(margin)
  151. end
  152. set_nmargin (horizontal, vertical: INTEGER)
  153. -- (non inheritable): Same as MARGIN but are non inheritable.
  154. require
  155. horizontal >= 0
  156. vertical >= 0
  157. local
  158. margin: STRING
  159. do
  160. margin := horizontal.out
  161. margin.append_string("x")
  162. margin.append_string(vertical.out)
  163. iup_open.set_attribute(Current, "NMARGIN", margin)
  164. end
  165. get_nmargin: TUPLE[INTEGER, INTEGER]
  166. -- Return the value of the nmargin.
  167. local
  168. margin: STRING
  169. do
  170. margin := iup_open.get_attribute(Current, "NMARGIN")
  171. Result := components_of_size(margin)
  172. end
  173. set_ncmargin (horizontal, vertical: INTEGER)
  174. -- (non inheritable): Same as CMARGIN but are non inheritable.
  175. require
  176. horizontal >= 0
  177. vertical >= 0
  178. local
  179. margin: STRING
  180. do
  181. margin := horizontal.out
  182. margin.append_string("x")
  183. margin.append_string(vertical.out)
  184. iup_open.set_attribute(Current, "NCMARGIN", margin)
  185. end
  186. get_ncmargin: TUPLE[INTEGER, INTEGER]
  187. -- Return the value of NCMARGIN.
  188. local
  189. margin: STRING
  190. do
  191. margin := iup_open.get_attribute(Current, "NCMARGIN")
  192. Result := components_of_size(margin)
  193. end
  194. set_expand_children (state: BOOLEAN)
  195. do
  196. iup_open.set_attribute(Current, "EXPANDCHILDREN", boolean_to_yesno(state))
  197. end
  198. is_expand_children: BOOLEAN
  199. local
  200. str: STRING
  201. do
  202. str := iup_open.get_attribute(Current, "EXPANDCHILDREN")
  203. Result := yesno_to_boolean(str)
  204. end
  205. -- Validations
  206. is_valid_alignment (value: STRING): BOOLEAN
  207. deferred
  208. end
  209. end
  210. -- The MIT License (MIT)
  211. -- Copyright (c) 2016, 2017, 2019 by German A. Arias
  212. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  213. -- of this software and associated documentation files (the "Software"), to deal
  214. -- in the Software without restriction, including without limitation the rights
  215. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  216. -- copies of the Software, and to permit persons to whom the Software is
  217. -- furnished to do so, subject to the following conditions:
  218. --
  219. -- The above copyright notice and this permission notice shall be included in
  220. -- all copies or substantial portions of the Software.
  221. --
  222. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  223. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  224. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  225. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  226. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  227. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  228. -- SOFTWARE.