iup_widget_bgcolor.e 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. deferred class IUP_WIDGET_BGCOLOR
  2. -- Commands to handle the attributes related with bgcolor.
  3. inherit
  4. IUP_WIDGET_INTERNALS
  5. insert
  6. IUP_INTERFACE
  7. feature {ANY}
  8. set_rgb_background_color (red: INTEGER; green: INTEGER; blue: INTEGER)
  9. -- Set the background color of the element using the RGB values.
  10. do
  11. iup_open.set_attribute(Current, "BGCOLOR", rgb_to_string(red, green, blue))
  12. end
  13. set_hexadecimal_background_color (color: STRING)
  14. -- Set the background color of the element usign an hexadecimal
  15. -- value (#RRGGBB).
  16. local
  17. tup: TUPLE[INTEGER, INTEGER, INTEGER]
  18. do
  19. tup := hexadecimal_to_rgb(color)
  20. set_rgb_background_color(tup.item_1, tup.item_2, tup.item_3)
  21. end
  22. get_rgb_background_color: TUPLE[INTEGER, INTEGER, INTEGER]
  23. -- Return the RGB values of the background color.
  24. do
  25. Result := iup_open.get_rgb(Current, "BGCOLOR")
  26. end
  27. get_hexadecimal_background_color: STRING
  28. -- Return the hexadecimal value of the background color.
  29. local
  30. color: TUPLE[INTEGER, INTEGER, INTEGER]
  31. do
  32. color := iup_open.get_rgb(Current, "BGCOLOR")
  33. Result := rgb_to_hexadecimal(color.item_1, color.item_2, color.item_3)
  34. end
  35. reset_background_color
  36. -- Reset the background color to the default value.
  37. do
  38. iup_open.reset_attribute(Current, "BGCOLOR")
  39. end
  40. end
  41. -- The MIT License (MIT)
  42. -- Copyright (c) 2016 by German A. Arias
  43. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  44. -- of this software and associated documentation files (the "Software"), to deal
  45. -- in the Software without restriction, including without limitation the rights
  46. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47. -- copies of the Software, and to permit persons to whom the Software is
  48. -- furnished to do so, subject to the following conditions:
  49. --
  50. -- The above copyright notice and this permission notice shall be included in
  51. -- all copies or substantial portions of the Software.
  52. --
  53. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  54. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  55. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  56. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  57. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  58. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  59. -- SOFTWARE.