iup_widget_font.e 3.9 KB

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