iup_widget_fgcolor.e 2.4 KB

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