iup_vbox.e 3.6 KB

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