iup_widget_flat_text.e 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. deferred class IUP_WIDGET_FLAT_TEXT
  2. -- Command to handle the additional features to text in flat controls.
  3. inherit
  4. IUP_WIDGET_INTERNALS
  5. feature {ANY}
  6. set_alignment (horizontal, vertical: STRING)
  7. -- (non inheritable): horizontal and vertical alignment. Possible values:
  8. -- "ALEFT", "ACENTER" and "ARIGHT", combined to "ATOP", "ACENTER" and
  9. -- "ABOTTOM". Default: "ALEFT:ACENTER". In Motif, vertical alignment is
  10. -- restricted to "ACENTER".
  11. require
  12. is_valid_alignment(horizontal, vertical)
  13. local
  14. str: STRING
  15. do
  16. create str.make_from_string(horizontal)
  17. str.append_string(":")
  18. str.append_string(vertical)
  19. iup_open.set_attribute(Current, "ALIGNMENT", str)
  20. end
  21. set_text_alignment (value: STRING)
  22. -- (non inheritable): Horizontal text alignment for multiple lines. Can
  23. -- be: ALEFT, ARIGHT or ACENTER. Default: ALEFT.
  24. require
  25. is_valid_horizontal_alignment(value)
  26. do
  27. iup_open.set_attribute(Current, "TEXTALIGNMENT", value)
  28. end
  29. set_text_wrap (state: BOOLEAN)
  30. -- (non inheritable): For single line texts if the text is larger than
  31. -- its box the line will be automatically broken in multiple lines.
  32. -- Notice that this is done internally by the system, the element natural
  33. -- size will still use only a single line. For the remaining lines to be
  34. -- visible the element should use EXPAND=VERTICAL or set a
  35. -- SIZE/RASTERSIZE with enough height for the wrapped lines.
  36. do
  37. iup_open.set_attribute(Current, "TEXTWRAP", boolean_to_yesno(state))
  38. end
  39. set_text_ellipsis (state: BOOLEAN)
  40. -- (non inheritable): If the text is larger that its box, an ellipsis
  41. -- ("...") will be placed near the last visible part of the text and
  42. -- replace the invisible part. It will be ignored when TEXTWRAP=True.
  43. do
  44. iup_open.set_attribute(Current, "TEXTELLIPSIS", boolean_to_yesno(state))
  45. end
  46. set_text_orientation (value: REAL_64)
  47. -- (non inheritable): text angle in degrees and counterclockwise. The
  48. -- text size will adapt to include the rotated space.
  49. do
  50. iup_open.set_attribute(Current, "TEXTORIENTATION", value.out)
  51. end
  52. -- Validations
  53. is_valid_alignment (horizontal, vertical: STRING): BOOLEAN
  54. do
  55. if is_valid_vertical_alignment(vertical) and
  56. is_valid_horizontal_alignment(horizontal) then
  57. Result := True
  58. else
  59. Result := False
  60. end
  61. end
  62. is_valid_vertical_alignment (value: STRING): BOOLEAN
  63. do
  64. if value.is_equal("ATOP") or
  65. value.is_equal("ACENTER") or
  66. value.is_equal("ABOTTOM") then
  67. Result := True
  68. else
  69. Result := False
  70. end
  71. end
  72. is_valid_horizontal_alignment (value: STRING): BOOLEAN
  73. do
  74. if value.is_equal("ALEFT") or
  75. value.is_equal("ACENTER") or
  76. value.is_equal("ARIGHT") then
  77. Result := True
  78. else
  79. Result := False
  80. end
  81. end
  82. end
  83. -- The MIT License (MIT)
  84. -- Copyright (c) 2018, 2019 by German A. Arias
  85. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  86. -- of this software and associated documentation files (the "Software"), to deal
  87. -- in the Software without restriction, including without limitation the rights
  88. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  89. -- copies of the Software, and to permit persons to whom the Software is
  90. -- furnished to do so, subject to the following conditions:
  91. --
  92. -- The above copyright notice and this permission notice shall be included in
  93. -- all copies or substantial portions of the Software.
  94. --
  95. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  96. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  97. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  98. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  99. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  100. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  101. -- SOFTWARE.