iup_lineal_box.e 7.3 KB

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