iup_widget_maxmin_size.e 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. deferred class IUP_WIDGET_MAXMIN_SIZE
  2. -- Commands to handle the attributes related with max/min size.
  3. inherit
  4. IUP_WIDGET_INTERNALS
  5. feature {ANY}
  6. set_maxsize (width: INTEGER; height: INTEGER)
  7. -- Specifies the element maximum size in pixels during the layout
  8. -- process.
  9. require
  10. non_negative: width >= 0
  11. height >= 0
  12. is_valid_maxsize(width, height)
  13. local
  14. size: STRING
  15. do
  16. size := width.out
  17. size.append_string("x")
  18. size.append_string(height.out)
  19. iup_open.set_attribute(Current, "MAXSIZE", size)
  20. end
  21. get_maxsize: TUPLE[INTEGER, INTEGER]
  22. -- Return the maximum size of the element.
  23. local
  24. size: STRING
  25. do
  26. size := iup_open.get_attribute(Current, "MAXSIZE")
  27. Result := components_of_size(size)
  28. end
  29. set_minsize (width: INTEGER; height: INTEGER)
  30. -- Specifies the element minimum size in pixels during the layout process.
  31. require
  32. non_negative: width >= 0
  33. height >= 0
  34. is_valid_minsize(width, height)
  35. local
  36. size: STRING
  37. do
  38. size := width.out
  39. size.append_string("x")
  40. size.append_string(height.out)
  41. iup_open.set_attribute(Current, "MINSIZE", size)
  42. end
  43. get_minsize: TUPLE[INTEGER, INTEGER]
  44. -- Return the minimum size of the element.
  45. local
  46. size: STRING
  47. do
  48. size := iup_open.get_attribute(Current, "MINSIZE")
  49. Result := components_of_size(size)
  50. end
  51. is_valid_maxsize (w, h: INTEGER): BOOLEAN
  52. local
  53. mins: TUPLE[INTEGER, INTEGER]
  54. w1, h1: INTEGER
  55. do
  56. mins := get_minsize
  57. w1 := mins.integer_32_item(1)
  58. h1 := mins.integer_32_item(2)
  59. if w1 <= w and then
  60. h1 <= h then
  61. Result := True
  62. else
  63. Result := False
  64. end
  65. end
  66. is_valid_minsize (w, h: INTEGER): BOOLEAN
  67. local
  68. maxs: TUPLE[INTEGER, INTEGER]
  69. w1, h1: INTEGER
  70. do
  71. maxs := get_maxsize
  72. w1 := maxs.integer_32_item(1)
  73. h1 := maxs.integer_32_item(2)
  74. if w1 >= w and then
  75. h1 >= h then
  76. Result := True
  77. else
  78. Result := False
  79. end
  80. end
  81. end
  82. -- The MIT License (MIT)
  83. -- Copyright (c) 2016, 2019 by German A. Arias
  84. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  85. -- of this software and associated documentation files (the "Software"), to deal
  86. -- in the Software without restriction, including without limitation the rights
  87. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  88. -- copies of the Software, and to permit persons to whom the Software is
  89. -- furnished to do so, subject to the following conditions:
  90. --
  91. -- The above copyright notice and this permission notice shall be included in
  92. -- all copies or substantial portions of the Software.
  93. --
  94. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  95. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  96. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  97. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  98. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  99. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  100. -- SOFTWARE.