iup_hbox.e 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. class IUP_HBOX
  2. -- Container for composing elements horizontally
  3. inherit
  4. IUP_LINEAL_BOX
  5. redefine
  6. set_alignment,
  7. set_expand_children,
  8. set_size,
  9. set_raster_size
  10. end
  11. create {ANY}
  12. hbox_empty,
  13. hbox
  14. feature {ANY}
  15. hbox_empty
  16. -- Create an empty hbox
  17. local
  18. p, a_hbox: POINTER
  19. do
  20. a_hbox := int_hbox_empty (p)
  21. set_widget(a_hbox)
  22. end
  23. hbox (col: ARRAY[IUP_WIDGET])
  24. -- Create a new hbox containing the list of widgets
  25. local
  26. i: INTEGER; arg: ARRAY[POINTER]; s: IUP_WIDGET; a_hbox: POINTER
  27. do
  28. i := col.count
  29. create arg.make_filled(default_pointer, 1, i + 1)
  30. i := 0
  31. across
  32. col as ic
  33. loop
  34. i := i + 1
  35. s := ic.item
  36. arg.put(s.widget, i)
  37. end
  38. a_hbox := int_hbox (get_pointer(arg.to_c))
  39. set_widget(a_hbox)
  40. end
  41. -- Attributes
  42. set_alignment (value: STRING)
  43. -- (non inheritable): Vertically aligns the elements. Possible values:
  44. -- "ATOP", "ACENTER", "ABOTTOM". Default: "ATOP".
  45. do
  46. Precursor (value)
  47. end
  48. set_expand_children (state: BOOLEAN)
  49. -- (non inheritable): forces all children to expand vertically and to
  50. -- fully occupy its space available inside the box. Default: "NO". This
  51. -- has the same effect as setting EXPAND=VERTICAL on each child.
  52. do
  53. Precursor (state)
  54. end
  55. set_size (width: INTEGER; height: INTEGER)
  56. -- (non inheritable): Defines the width of the box. Height will be
  57. -- ignored. When consulted behaves as the standard SIZE attribute.
  58. do
  59. Precursor (width, height)
  60. end
  61. set_raster_size (width: INTEGER; height: INTEGER)
  62. -- (non inheritable): Defines the width of the box. Height will be
  63. -- ignored. When consulted behaves as the standard RASTERSIZE attribute.
  64. do
  65. Precursor (width, height)
  66. end
  67. -- Validations
  68. is_valid_alignment (value: STRING): BOOLEAN
  69. do
  70. if value.is_equal("ATOP") or
  71. value.is_equal("ACENTER") or
  72. value.is_equal("ABOTTOM") then
  73. Result := True
  74. else
  75. Result := False
  76. end
  77. end
  78. feature {NONE}
  79. -- Internals
  80. int_hbox_empty (arguments: POINTER): POINTER
  81. external
  82. "C inline use %"eiffel-iup.h%""
  83. alias
  84. "return IupHbox ($arguments);"
  85. end
  86. int_hbox (arguments: POINTER): POINTER
  87. external
  88. "C inline use %"eiffel-iup.h%""
  89. alias
  90. "return IupHboxv ($arguments);"
  91. end
  92. end -- class IUP_HBOX
  93. -- The MIT License (MIT)
  94. -- Copyright (c) 2016, 2019, 2020 by German A. Arias
  95. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  96. -- of this software and associated documentation files (the "Software"), to deal
  97. -- in the Software without restriction, including without limitation the rights
  98. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  99. -- copies of the Software, and to permit persons to whom the Software is
  100. -- furnished to do so, subject to the following conditions:
  101. --
  102. -- The above copyright notice and this permission notice shall be included in
  103. -- all copies or substantial portions of the Software.
  104. --
  105. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  106. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  107. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  108. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  109. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  110. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  111. -- SOFTWARE.