iup_vbox.e 3.4 KB

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