class_label.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. | void | :ref:`set_align<class_Label_set_align>` **(** :ref:`int<class_int>` align **)** |
  15. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`int<class_int>` | :ref:`get_align<class_Label_get_align>` **(** **)** const |
  17. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`set_valign<class_Label_set_valign>` **(** :ref:`int<class_int>` valign **)** |
  19. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`int<class_int>` | :ref:`get_valign<class_Label_get_valign>` **(** **)** const |
  21. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`set_text<class_Label_set_text>` **(** :ref:`String<class_string>` text **)** |
  23. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`String<class_string>` | :ref:`get_text<class_Label_get_text>` **(** **)** const |
  25. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`set_autowrap<class_Label_set_autowrap>` **(** :ref:`bool<class_bool>` enable **)** |
  27. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`bool<class_bool>` | :ref:`has_autowrap<class_Label_has_autowrap>` **(** **)** const |
  29. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`set_clip_text<class_Label_set_clip_text>` **(** :ref:`bool<class_bool>` enable **)** |
  31. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`is_clipping_text<class_Label_is_clipping_text>` **(** **)** const |
  33. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_uppercase<class_Label_set_uppercase>` **(** :ref:`bool<class_bool>` enable **)** |
  35. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`is_uppercase<class_Label_is_uppercase>` **(** **)** const |
  37. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`get_line_height<class_Label_get_line_height>` **(** **)** const |
  39. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`int<class_int>` | :ref:`get_line_count<class_Label_get_line_count>` **(** **)** const |
  41. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_total_character_count<class_Label_get_total_character_count>` **(** **)** const |
  43. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_visible_characters<class_Label_set_visible_characters>` **(** :ref:`int<class_int>` amount **)** |
  45. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`get_visible_characters<class_Label_get_visible_characters>` **(** **)** const |
  47. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_percent_visible<class_Label_set_percent_visible>` **(** :ref:`float<class_float>` percent_visible **)** |
  49. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`float<class_float>` | :ref:`get_percent_visible<class_Label_get_percent_visible>` **(** **)** const |
  51. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_lines_skipped<class_Label_set_lines_skipped>` **(** :ref:`int<class_int>` lines_skipped **)** |
  53. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`int<class_int>` | :ref:`get_lines_skipped<class_Label_get_lines_skipped>` **(** **)** const |
  55. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_max_lines_visible<class_Label_set_max_lines_visible>` **(** :ref:`int<class_int>` lines_visible **)** |
  57. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`int<class_int>` | :ref:`get_max_lines_visible<class_Label_get_max_lines_visible>` **(** **)** const |
  59. +------------------------------+---------------------------------------------------------------------------------------------------------------------+
  60. Numeric Constants
  61. -----------------
  62. - **ALIGN_LEFT** = **0** --- Align rows to the left (default).
  63. - **ALIGN_CENTER** = **1** --- Align rows centered.
  64. - **ALIGN_RIGHT** = **2** --- Align rows to the right (default).
  65. - **ALIGN_FILL** = **3** --- Expand row whitespaces to fit the width.
  66. - **VALIGN_TOP** = **0** --- Align the whole text to the top.
  67. - **VALIGN_CENTER** = **1** --- Align the whole text to the center.
  68. - **VALIGN_BOTTOM** = **2** --- Align the whole text to the bottom.
  69. - **VALIGN_FILL** = **3** --- Align the whole text by spreading the rows.
  70. Description
  71. -----------
  72. 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.
  73. Member Function Description
  74. ---------------------------
  75. .. _class_Label_set_align:
  76. - void **set_align** **(** :ref:`int<class_int>` align **)**
  77. Sets the alignment mode to any of the ALIGN\_\* enumeration values.
  78. .. _class_Label_get_align:
  79. - :ref:`int<class_int>` **get_align** **(** **)** const
  80. Return the alignment mode (any of the ALIGN\_\* enumeration values).
  81. .. _class_Label_set_valign:
  82. - void **set_valign** **(** :ref:`int<class_int>` valign **)**
  83. Sets the vertical alignment mode to any of the VALIGN\_\* enumeration values.
  84. .. _class_Label_get_valign:
  85. - :ref:`int<class_int>` **get_valign** **(** **)** const
  86. Return the vertical alignment mode (any of the VALIGN\_\* enumeration values).
  87. .. _class_Label_set_text:
  88. - void **set_text** **(** :ref:`String<class_string>` text **)**
  89. Set the label text. Text can contain newlines.
  90. .. _class_Label_get_text:
  91. - :ref:`String<class_string>` **get_text** **(** **)** const
  92. Return the label text. Text can contain newlines.
  93. .. _class_Label_set_autowrap:
  94. - void **set_autowrap** **(** :ref:`bool<class_bool>` enable **)**
  95. 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.
  96. .. _class_Label_has_autowrap:
  97. - :ref:`bool<class_bool>` **has_autowrap** **(** **)** const
  98. Return the state of the *autowrap* mode (see :ref:`set_autowrap<class_Label_set_autowrap>`).
  99. .. _class_Label_set_clip_text:
  100. - void **set_clip_text** **(** :ref:`bool<class_bool>` enable **)**
  101. Cuts off the rest of the text if it is too wide.
  102. .. _class_Label_is_clipping_text:
  103. - :ref:`bool<class_bool>` **is_clipping_text** **(** **)** const
  104. Return true if text would be cut off if it is too wide.
  105. .. _class_Label_set_uppercase:
  106. - void **set_uppercase** **(** :ref:`bool<class_bool>` enable **)**
  107. Display text in all capitals.
  108. .. _class_Label_is_uppercase:
  109. - :ref:`bool<class_bool>` **is_uppercase** **(** **)** const
  110. Return true if text is displayed in all capitals.
  111. .. _class_Label_get_line_height:
  112. - :ref:`int<class_int>` **get_line_height** **(** **)** const
  113. Return the height of a line.
  114. .. _class_Label_get_line_count:
  115. - :ref:`int<class_int>` **get_line_count** **(** **)** const
  116. Return the amount of lines.
  117. .. _class_Label_get_total_character_count:
  118. - :ref:`int<class_int>` **get_total_character_count** **(** **)** const
  119. Return the total length of the text.
  120. .. _class_Label_set_visible_characters:
  121. - void **set_visible_characters** **(** :ref:`int<class_int>` amount **)**
  122. Restricts the number of characters to display. Set to -1 to disable.
  123. .. _class_Label_get_visible_characters:
  124. - :ref:`int<class_int>` **get_visible_characters** **(** **)** const
  125. Return the restricted number of characters to display. Returns -1 if unrestricted.
  126. .. _class_Label_set_percent_visible:
  127. - void **set_percent_visible** **(** :ref:`float<class_float>` percent_visible **)**
  128. Restricts the number of characters to display (as a percentage of the total text).
  129. .. _class_Label_get_percent_visible:
  130. - :ref:`float<class_float>` **get_percent_visible** **(** **)** const
  131. Return the restricted number of characters to display (as a percentage of the total text).
  132. .. _class_Label_set_lines_skipped:
  133. - void **set_lines_skipped** **(** :ref:`int<class_int>` lines_skipped **)**
  134. Sets the number of lines to skip before displaying. Useful for scrolling text.
  135. .. _class_Label_get_lines_skipped:
  136. - :ref:`int<class_int>` **get_lines_skipped** **(** **)** const
  137. Return the the number of lines to skipped before displaying.
  138. .. _class_Label_set_max_lines_visible:
  139. - void **set_max_lines_visible** **(** :ref:`int<class_int>` lines_visible **)**
  140. Restricts the number of lines to display. Set to -1 to disable.
  141. .. _class_Label_get_max_lines_visible:
  142. - :ref:`int<class_int>` **get_max_lines_visible** **(** **)** const
  143. Return the restricted number of lines to display. Returns -1 if unrestricted.