iup_theme.e 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. insert
  24. IUP_INTERFACE
  25. create
  26. theme
  27. feature {ANY}
  28. theme (name: STRING)
  29. -- Creates a theme with the given name.
  30. local
  31. a_theme, p: POINTER
  32. do
  33. a_theme := int_theme
  34. set_widget(a_theme)
  35. p := int_set_widget_name(name.to_external, widget)
  36. --if p /= Void then
  37. -- io.put_string("There was a previous widget with this name. %N")
  38. --end
  39. end
  40. set_value_for_key (value, key: STRING)
  41. -- Add a pair key-value at the theme. The key is the default IUP name
  42. -- of the attribute (like "SIZE", "MARGIN", "GAP", etc.). The value is
  43. -- a valid value for that attribute.
  44. do
  45. iup_open.set_attribute(Current, key, value)
  46. end
  47. feature {}
  48. -- Internal
  49. int_theme: POINTER
  50. external "plug_in"
  51. alias "{
  52. location: "${sys}/plugins"
  53. module_name: "iup"
  54. feature_name: "IupUser()"
  55. }"
  56. end
  57. int_set_widget_name(name, wgt: POINTER): POINTER
  58. external "plug_in"
  59. alias "{
  60. location: "${sys}/plugins"
  61. module_name: "iup"
  62. feature_name: "IupSetHandle"
  63. }"
  64. end
  65. end
  66. -- The MIT License (MIT)
  67. -- Copyright (c) 2019 by German A. Arias
  68. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  69. -- of this software and associated documentation files (the "Software"), to deal
  70. -- in the Software without restriction, including without limitation the rights
  71. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  72. -- copies of the Software, and to permit persons to whom the Software is
  73. -- furnished to do so, subject to the following conditions:
  74. --
  75. -- The above copyright notice and this permission notice shall be included in
  76. -- all copies or substantial portions of the Software.
  77. --
  78. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  79. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  80. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  81. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  82. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  83. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  84. -- SOFTWARE.