iup_widget_size.e 2.5 KB

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