iup_sbox.e 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. class IUP_SBOX
  2. -- Creates a void container that allows its child to be resized. Allows
  3. -- expanding and contracting the child size in one direction.
  4. --
  5. -- It does not have a native representation but it contains also a IupCanvas to
  6. -- implement the bar handler.
  7. inherit
  8. IUP_CONTAINER
  9. IUP_WIDGET_EXPAND
  10. IUP_WIDGET_WID
  11. IUP_WIDGET_FONT
  12. IUP_WIDGET_SIZE
  13. IUP_WIDGET_RASTERSIZE
  14. IUP_WIDGET_USERSIZE
  15. IUP_WIDGET_CLIENTSIZE
  16. IUP_WIDGET_CLIENTOFFSET
  17. IUP_WIDGET_POSITION
  18. IUP_WIDGET_MAXMIN_SIZE
  19. IUP_WIDGET_CHILD
  20. IUP_WIDGET_NAME
  21. IUP_WIDGET_CUSTOM_ATTRIBUTES
  22. create {ANY}
  23. sbox_empty,
  24. sbox
  25. feature {ANY}
  26. sbox_empty
  27. -- Create an empty sbox.
  28. local
  29. p, a_sbox: POINTER
  30. do
  31. a_sbox := int_sbox (p)
  32. set_widget(a_sbox)
  33. end
  34. sbox (child: IUP_WIDGET)
  35. -- Create a new sbox containing the widget.
  36. local
  37. a_sbox: POINTER
  38. do
  39. a_sbox := int_sbox (child.widget)
  40. set_widget(a_sbox)
  41. end
  42. -- Attributes
  43. set_bar_size (value: INTEGER)
  44. -- (non inheritable): controls the size of the bar handler. Default: 5.
  45. require
  46. value > 0
  47. do
  48. iup_open.set_attribute(Current, "BARSIZE", value.out)
  49. end
  50. set_rgb_color (red, green, blue: INTEGER)
  51. -- Changes the color of the bar handler. The value should be given in "R G
  52. -- B" color style. Default: "192 192 192".
  53. do
  54. iup_open.set_attribute(Current, "COLOR", rgb_to_string(red, green, blue))
  55. end
  56. get_rgb_color: TUPLE[INTEGER, INTEGER, INTEGER]
  57. -- Return the RGB values of the bar color.
  58. do
  59. Result := iup_open.get_rgb(Current, "COLOR")
  60. end
  61. set_direction (value: STRING)
  62. -- (creation only): Indicates the direction of the resize and the position
  63. -- of the bar handler. Possible values are "NORTH", "SOUTH" (vertical
  64. -- direction), "EAST" or "WEST" (horizontal direction). Default: "EAST".
  65. require
  66. is_valid_direction(value)
  67. do
  68. iup_open.set_attribute(Current, "DIRECTION", value)
  69. end
  70. get_direction: STRING
  71. -- Return the value of direction.
  72. do
  73. Result := iup_open.get_attribute(Current, "DIRECTION")
  74. end
  75. set_layout_drag (state: BOOLEAN)
  76. -- (non inheritable): When the bar is moved automatically update the
  77. -- children layout. Default: True. If set to false then the layout will
  78. -- be updated only when the mouse drag is released.
  79. do
  80. iup_open.set_attribute(Current, "LAYOUTDRAG", boolean_to_yesno(state))
  81. end
  82. set_show_grip (value: STRING)
  83. -- (non inheritable): Shows the bar grip affordance, possible
  84. -- values: YES, NO, LINES. Default: NO. When set to NO, COLOR is used to
  85. -- fill the grip area. If set to "LINES" then instead of the traditional
  86. -- grip appearance, it will be two parallel lines.
  87. require
  88. is_valid_showgrip(value)
  89. do
  90. iup_open.set_attribute(Current, "SHOWGRIP", value)
  91. end
  92. -- Validations
  93. is_valid_direction (value: STRING): BOOLEAN
  94. do
  95. if value.is_equal("NORTH") or
  96. value.is_equal("SOUTH") or
  97. value.is_equal("EAST") or
  98. value.is_equal("WEST") then
  99. Result := True
  100. else
  101. Result := False
  102. end
  103. end
  104. is_valid_showgrip (value: STRING): BOOLEAN
  105. do
  106. if is_yes_no(value) or
  107. value.is_equal("LINES") then
  108. Result := True
  109. else
  110. Result := False
  111. end
  112. end
  113. feature {NONE}
  114. -- Internal
  115. int_sbox (child: POINTER): POINTER
  116. external
  117. "C inline use %"eiffel-iup.h%""
  118. alias
  119. "return IupSbox ($child);"
  120. end
  121. end
  122. -- The MIT License (MIT)
  123. -- Copyright (c) 2016, 2017, 2019 by German A. Arias
  124. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  125. -- of this software and associated documentation files (the "Software"), to deal
  126. -- in the Software without restriction, including without limitation the rights
  127. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  128. -- copies of the Software, and to permit persons to whom the Software is
  129. -- furnished to do so, subject to the following conditions:
  130. --
  131. -- The above copyright notice and this permission notice shall be included in
  132. -- all copies or substantial portions of the Software.
  133. --
  134. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  135. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  136. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  137. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  138. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  139. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  140. -- SOFTWARE.