iup_theme.e 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. class IUP_THEME
  2. -- Creates a theme element to be applied to controls with features
  3. -- "set_theme" or "set_ntheme". The theme is a list of pair strings, the
  4. -- attribute (key) and the value to be applied to that attribute. The key of
  5. -- the attribute is the default IUP name of the attribute.
  6. --
  7. -- Only attributes that are registered in the element will receive its theme
  8. -- value.
  9. --
  10. -- Attributes that are registered as not being strings, read-only, write-only
  11. -- or callbacks will NOT be applied.
  12. --
  13. -- The theme can contain an specialized sub-theme for the element class. The
  14. -- element class name will be used with a "IUP" prefix to identify the
  15. -- sub-theme. For instance, if the element is a label, then an attribute called
  16. -- "IUPLABEL" can point to anohter theme name to be applied at the element
  17. -- additionally to the already applied attributes.
  18. --
  19. -- The global attribute DEFAULTTHEME can be applied to all elements during
  20. -- creation.
  21. inherit
  22. IUP_WIDGET
  23. create
  24. theme
  25. feature {ANY}
  26. theme (name: STRING)
  27. -- Creates a theme with the given name.
  28. local
  29. a_theme, p: POINTER
  30. do
  31. a_theme := int_theme
  32. set_widget(a_theme)
  33. p := int_set_widget_name(get_pointer(name.to_c), widget)
  34. --if p /= default_pointer then
  35. -- io.put_string("There was a previous widget with this name. %N")
  36. --end
  37. end
  38. set_value_for_key (value, key: STRING)
  39. -- Add a pair key-value at the theme. The key is the default IUP name
  40. -- of the attribute (like "SIZE", "MARGIN", "GAP", etc.). The value is
  41. -- a valid value for that attribute.
  42. do
  43. iup_open.set_attribute(Current, key, value)
  44. end
  45. feature {NONE}
  46. -- Internal
  47. int_theme: POINTER
  48. external
  49. "C inline use %"eiffel-iup.h%""
  50. alias
  51. "return IupUser();"
  52. end
  53. end
  54. -- The MIT License (MIT)
  55. -- Copyright (c) 2019 by German A. Arias
  56. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  57. -- of this software and associated documentation files (the "Software"), to deal
  58. -- in the Software without restriction, including without limitation the rights
  59. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  60. -- copies of the Software, and to permit persons to whom the Software is
  61. -- furnished to do so, subject to the following conditions:
  62. --
  63. -- The above copyright notice and this permission notice shall be included in
  64. -- all copies or substantial portions of the Software.
  65. --
  66. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  67. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  68. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  69. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  70. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  71. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  72. -- SOFTWARE.