iup_widget_font.e 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. deferred class IUP_WIDGET_FONT
  2. -- Commands to handle the attributes related with fonts.
  3. inherit
  4. IUP_WIDGET_INTERNALS
  5. feature {ANY}
  6. set_font (font: STRING)
  7. -- Set the font used in the element. A string description
  8. -- containing typeface, style and size.
  9. -- Font face is the font face name, and can be any name. Although
  10. -- only names recognized by the system will be actually used. The
  11. -- names Helvetica, Courier and Times are always accepted in all
  12. -- systems.
  13. -- The supported font style is a combination of: Bold, Italic,
  14. -- Underline and Strikeout.
  15. -- Font size is in points (1/72 inch) or in pixels (using
  16. -- negative values).
  17. -- Unsupported values are simply ignored.
  18. -- Examples:
  19. -- "Times, Bold 18"
  20. -- "Arial, 24" (no style specified)
  21. -- "Courier New, Italic Underline -30" (size in pixels)
  22. do
  23. iup_open.set_attribute(Current, "FONT", font)
  24. end
  25. get_font: STRING
  26. -- Return the string with the description of the used font.
  27. do
  28. Result := iup_open.get_attribute(Current, "FONT")
  29. end
  30. reset_font
  31. -- Reset the font to the default value.
  32. do
  33. iup_open.reset_attribute(Current, "FONT")
  34. end
  35. set_font_face (fontface: STRING)
  36. -- Replaces the face name of the current FONT attribute.
  37. do
  38. iup_open.set_attribute(Current, "FONTFACE", fontface)
  39. end
  40. get_font_face: STRING
  41. -- Return the face name of the current FONT attribute.
  42. do
  43. Result := iup_open.get_attribute(Current, "FONTFACE")
  44. end
  45. reset_font_face
  46. -- Reset the fontface to the default value.
  47. do
  48. iup_open.reset_attribute(Current, "FONTFACE")
  49. end
  50. set_font_style (fontstyle: STRING)
  51. -- Replaces the style of the current FONT attribute.
  52. do
  53. iup_open.set_attribute(Current, "FONTSTYLE", fontstyle)
  54. end
  55. get_font_style: STRING
  56. -- Return the style of the current FONT attribute.
  57. do
  58. Result := iup_open.get_attribute(Current, "FONTSTYLE")
  59. end
  60. reset_font_style
  61. -- Reset the fontstyle to the default value.
  62. do
  63. iup_open.reset_attribute(Current, "FONTSTYLE")
  64. end
  65. set_font_size (fontsize: INTEGER)
  66. -- Replaces the size of the current FONT attribute.
  67. do
  68. iup_open.set_attribute(Current, "FONTSIZE", fontsize.out)
  69. end
  70. get_font_size: INTEGER
  71. -- Return the style of the current FONT attribute.
  72. local
  73. size: STRING
  74. do
  75. size := iup_open.get_attribute(Current, "FONTSIZE")
  76. Result := size.to_integer
  77. end
  78. reset_font_size
  79. -- Reset the fontsize to the default value.
  80. do
  81. iup_open.reset_attribute(Current, "FONTSIZE")
  82. end
  83. get_char_size: INTEGER
  84. -- Returns the average character size of the current FONT
  85. -- attribute. This is the factor used by the SIZE attribute to
  86. -- convert its units to pixels.
  87. local
  88. size: STRING
  89. do
  90. size := iup_open.get_attribute(Current, "CHARSIZE")
  91. Result := size.to_integer
  92. end
  93. end
  94. -- The MIT License (MIT)
  95. -- Copyright (c) 2016, 2019 by German A. Arias
  96. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  97. -- of this software and associated documentation files (the "Software"), to deal
  98. -- in the Software without restriction, including without limitation the rights
  99. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  100. -- copies of the Software, and to permit persons to whom the Software is
  101. -- furnished to do so, subject to the following conditions:
  102. --
  103. -- The above copyright notice and this permission notice shall be included in
  104. -- all copies or substantial portions of the Software.
  105. --
  106. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  107. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  108. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  109. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  110. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  111. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  112. -- SOFTWARE.