iup_widget_normalize_size.e 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. deferred class IUP_WIDGET_NORMALIZE_SIZE
  2. -- Commands to handle the attributes related with normalize size.
  3. inherit
  4. IUP_WIDGET_INTERNALS
  5. feature {ANY}
  6. set_normalize_size (value: STRING)
  7. -- (non inheritable): normalizes all children natural size to be the
  8. -- biggest natural size among them. All natural width will be set to the
  9. -- biggest width, and all natural height will be set to the biggest
  10. -- height according to is value. Can be NO, HORIZONTAL, VERTICAL or BOTH.
  11. -- Default: "NO". Same as using IUP_NORMALIZER.
  12. require
  13. is_valid_normalize_size(value)
  14. do
  15. iup_open.set_attribute(Current, "NORMALIZESIZE", value)
  16. end
  17. normalize_size_horizontal
  18. do
  19. iup_open.set_attribute(Current, "NORMALIZESIZE", "HORIZONTAL")
  20. end
  21. normalize_size_vertical
  22. do
  23. iup_open.set_attribute(Current, "NORMALIZESIZE", "VERTICAL")
  24. end
  25. normalize_size_both_directions
  26. do
  27. iup_open.set_attribute(Current, "NORMALIZESIZE", "BOTH")
  28. end
  29. remove_normalize_size
  30. do
  31. iup_open.set_attribute(Current, "NORMALIZESIZE", "NO")
  32. end
  33. get_normalize_size: STRING
  34. -- Return the value of normalize size.
  35. do
  36. Result := iup_open.get_attribute(Current, "NORMALIZESIZE")
  37. end
  38. -- Validation
  39. is_valid_normalize_size (value: STRING): BOOLEAN
  40. do
  41. if value.is_equal("BOTH") or
  42. value.is_equal("HORIZONTAL") or
  43. value.is_equal("VERTICAL") or
  44. value.is_equal("NO") then
  45. Result := True
  46. else
  47. Result := False
  48. end
  49. end
  50. end
  51. -- The MIT License (MIT)
  52. -- Copyright (c) 2019 by German A. Arias
  53. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  54. -- of this software and associated documentation files (the "Software"), to deal
  55. -- in the Software without restriction, including without limitation the rights
  56. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  57. -- copies of the Software, and to permit persons to whom the Software is
  58. -- furnished to do so, subject to the following conditions:
  59. --
  60. -- The above copyright notice and this permission notice shall be included in
  61. -- all copies or substantial portions of the Software.
  62. --
  63. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  64. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  65. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  66. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  67. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  68. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  69. -- SOFTWARE.