2
0

class_label.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Label:
  4. Label
  5. =====
  6. **Inherits:** :ref:`Control<class_control>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Control that displays formatted text.
  11. Member Functions
  12. ----------------
  13. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  14. | :ref:`int<class_int>` | :ref:`get_align<class_Label_get_align>` **(** **)** const |
  15. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`int<class_int>` | :ref:`get_line_count<class_Label_get_line_count>` **(** **)** const |
  17. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`int<class_int>` | :ref:`get_line_height<class_Label_get_line_height>` **(** **)** const |
  19. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`int<class_int>` | :ref:`get_lines_skipped<class_Label_get_lines_skipped>` **(** **)** const |
  21. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`int<class_int>` | :ref:`get_max_lines_visible<class_Label_get_max_lines_visible>` **(** **)** const |
  23. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`float<class_float>` | :ref:`get_percent_visible<class_Label_get_percent_visible>` **(** **)** const |
  25. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`String<class_string>` | :ref:`get_text<class_Label_get_text>` **(** **)** const |
  27. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`int<class_int>` | :ref:`get_total_character_count<class_Label_get_total_character_count>` **(** **)** const |
  29. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`int<class_int>` | :ref:`get_valign<class_Label_get_valign>` **(** **)** const |
  31. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`int<class_int>` | :ref:`get_visible_characters<class_Label_get_visible_characters>` **(** **)** const |
  33. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`get_visible_line_count<class_Label_get_visible_line_count>` **(** **)** const |
  35. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`has_autowrap<class_Label_has_autowrap>` **(** **)** const |
  37. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`bool<class_bool>` | :ref:`is_clipping_text<class_Label_is_clipping_text>` **(** **)** const |
  39. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`bool<class_bool>` | :ref:`is_uppercase<class_Label_is_uppercase>` **(** **)** const |
  41. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`set_align<class_Label_set_align>` **(** :ref:`int<class_int>` align **)** |
  43. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_autowrap<class_Label_set_autowrap>` **(** :ref:`bool<class_bool>` enable **)** |
  45. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_clip_text<class_Label_set_clip_text>` **(** :ref:`bool<class_bool>` enable **)** |
  47. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_lines_skipped<class_Label_set_lines_skipped>` **(** :ref:`int<class_int>` lines_skipped **)** |
  49. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_max_lines_visible<class_Label_set_max_lines_visible>` **(** :ref:`int<class_int>` lines_visible **)** |
  51. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_percent_visible<class_Label_set_percent_visible>` **(** :ref:`float<class_float>` percent_visible **)** |
  53. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_text<class_Label_set_text>` **(** :ref:`String<class_string>` text **)** |
  55. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_uppercase<class_Label_set_uppercase>` **(** :ref:`bool<class_bool>` enable **)** |
  57. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`set_valign<class_Label_set_valign>` **(** :ref:`int<class_int>` valign **)** |
  59. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`set_visible_characters<class_Label_set_visible_characters>` **(** :ref:`int<class_int>` amount **)** |
  61. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  62. Numeric Constants
  63. -----------------
  64. - **ALIGN_LEFT** = **0** --- Align rows to the left (default).
  65. - **ALIGN_CENTER** = **1** --- Align rows centered.
  66. - **ALIGN_RIGHT** = **2** --- Align rows to the right (default).
  67. - **ALIGN_FILL** = **3** --- Expand row whitespaces to fit the width.
  68. - **VALIGN_TOP** = **0** --- Align the whole text to the top.
  69. - **VALIGN_CENTER** = **1** --- Align the whole text to the center.
  70. - **VALIGN_BOTTOM** = **2** --- Align the whole text to the bottom.
  71. - **VALIGN_FILL** = **3** --- Align the whole text by spreading the rows.
  72. Description
  73. -----------
  74. Label is a control that displays formatted text, optionally autowrapping it to the :ref:`Control<class_control>` area. It inherits from range to be able to scroll wrapped text vertically.
  75. Member Function Description
  76. ---------------------------
  77. .. _class_Label_get_align:
  78. - :ref:`int<class_int>` **get_align** **(** **)** const
  79. Return the alignment mode (any of the ALIGN\_\* enumeration values).
  80. .. _class_Label_get_line_count:
  81. - :ref:`int<class_int>` **get_line_count** **(** **)** const
  82. Return the amount of lines.
  83. .. _class_Label_get_line_height:
  84. - :ref:`int<class_int>` **get_line_height** **(** **)** const
  85. Return the height of a line.
  86. .. _class_Label_get_lines_skipped:
  87. - :ref:`int<class_int>` **get_lines_skipped** **(** **)** const
  88. Return the the number of lines to skipped before displaying.
  89. .. _class_Label_get_max_lines_visible:
  90. - :ref:`int<class_int>` **get_max_lines_visible** **(** **)** const
  91. Return the restricted number of lines to display. Returns -1 if unrestricted.
  92. .. _class_Label_get_percent_visible:
  93. - :ref:`float<class_float>` **get_percent_visible** **(** **)** const
  94. Return the restricted number of characters to display (as a percentage of the total text).
  95. .. _class_Label_get_text:
  96. - :ref:`String<class_string>` **get_text** **(** **)** const
  97. Return the label text. Text can contain newlines.
  98. .. _class_Label_get_total_character_count:
  99. - :ref:`int<class_int>` **get_total_character_count** **(** **)** const
  100. Return the total length of the text.
  101. .. _class_Label_get_valign:
  102. - :ref:`int<class_int>` **get_valign** **(** **)** const
  103. Return the vertical alignment mode (any of the VALIGN\_\* enumeration values).
  104. .. _class_Label_get_visible_characters:
  105. - :ref:`int<class_int>` **get_visible_characters** **(** **)** const
  106. Return the restricted number of characters to display. Returns -1 if unrestricted.
  107. .. _class_Label_get_visible_line_count:
  108. - :ref:`int<class_int>` **get_visible_line_count** **(** **)** const
  109. .. _class_Label_has_autowrap:
  110. - :ref:`bool<class_bool>` **has_autowrap** **(** **)** const
  111. Return the state of the *autowrap* mode (see :ref:`set_autowrap<class_Label_set_autowrap>`).
  112. .. _class_Label_is_clipping_text:
  113. - :ref:`bool<class_bool>` **is_clipping_text** **(** **)** const
  114. Return true if text would be cut off if it is too wide.
  115. .. _class_Label_is_uppercase:
  116. - :ref:`bool<class_bool>` **is_uppercase** **(** **)** const
  117. Return true if text is displayed in all capitals.
  118. .. _class_Label_set_align:
  119. - void **set_align** **(** :ref:`int<class_int>` align **)**
  120. Sets the alignment mode to any of the ALIGN\_\* enumeration values.
  121. .. _class_Label_set_autowrap:
  122. - void **set_autowrap** **(** :ref:`bool<class_bool>` enable **)**
  123. Set *autowrap* mode. When enabled, autowrap will fit text to the control width, breaking sentences when they exceed the available horizontal space. When disabled, the label minimum width becomes the width of the longest row, and the minimum height large enough to fit all rows.
  124. .. _class_Label_set_clip_text:
  125. - void **set_clip_text** **(** :ref:`bool<class_bool>` enable **)**
  126. Cuts off the rest of the text if it is too wide.
  127. .. _class_Label_set_lines_skipped:
  128. - void **set_lines_skipped** **(** :ref:`int<class_int>` lines_skipped **)**
  129. Sets the number of lines to skip before displaying. Useful for scrolling text.
  130. .. _class_Label_set_max_lines_visible:
  131. - void **set_max_lines_visible** **(** :ref:`int<class_int>` lines_visible **)**
  132. Restricts the number of lines to display. Set to -1 to disable.
  133. .. _class_Label_set_percent_visible:
  134. - void **set_percent_visible** **(** :ref:`float<class_float>` percent_visible **)**
  135. Restricts the number of characters to display (as a percentage of the total text).
  136. .. _class_Label_set_text:
  137. - void **set_text** **(** :ref:`String<class_string>` text **)**
  138. Set the label text. Text can contain newlines.
  139. .. _class_Label_set_uppercase:
  140. - void **set_uppercase** **(** :ref:`bool<class_bool>` enable **)**
  141. Display text in all capitals.
  142. .. _class_Label_set_valign:
  143. - void **set_valign** **(** :ref:`int<class_int>` valign **)**
  144. Sets the vertical alignment mode to any of the VALIGN\_\* enumeration values.
  145. .. _class_Label_set_visible_characters:
  146. - void **set_visible_characters** **(** :ref:`int<class_int>` amount **)**
  147. Restricts the number of characters to display. Set to -1 to disable.