iup_widget_size.e 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. deferred class IUP_WIDGET_SIZE
  2. -- Commands to handle the attributes related with size.
  3. inherit
  4. IUP_WIDGET_INTERNALS
  5. feature {ANY}
  6. set_size (width: INTEGER; height: INTEGER)
  7. -- Specifies the element User size in units proportional to the size
  8. -- of a character. The size units observes the following
  9. -- heuristics:
  10. --
  11. -- * Width in 1/4's of the average width of a character for the
  12. -- current FONT of each control.
  13. -- * Height in 1/8's of the average height of a character for the
  14. -- current FONT of each control.
  15. --
  16. -- So, a SIZE="4x8" means 1 character width and 1 character height.
  17. -- Notice that this is the average character size, the space occupied by
  18. -- a specific string is always different than its number of character
  19. -- times its average character size, except when using a monospaced
  20. -- font like Courier.
  21. --
  22. -- You can also set only one of the parameters by setting the other value
  23. -- to 0.
  24. require
  25. non_negative: width >= 0
  26. height >= 0
  27. local
  28. size: STRING
  29. do
  30. size := width.out
  31. size.append_string("x")
  32. size.append_string(height.out)
  33. iup_open.set_attribute(Current, "SIZE", size)
  34. end
  35. get_size: TUPLE[INTEGER, INTEGER]
  36. -- Returns the Current size, in units proportional to the size of
  37. -- a character.
  38. local
  39. size: STRING
  40. do
  41. size := iup_open.get_attribute(Current, "SIZE")
  42. Result := components_of_size(size)
  43. end
  44. end
  45. -- The MIT License (MIT)
  46. -- Copyright (c) 2016, 2019 by German A. Arias
  47. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  48. -- of this software and associated documentation files (the "Software"), to deal
  49. -- in the Software without restriction, including without limitation the rights
  50. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  51. -- copies of the Software, and to permit persons to whom the Software is
  52. -- furnished to do so, subject to the following conditions:
  53. --
  54. -- The above copyright notice and this permission notice shall be included in
  55. -- all copies or substantial portions of the Software.
  56. --
  57. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  59. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  60. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  61. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  62. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  63. -- SOFTWARE.