text_constants.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_GFX_TEXT_CONSTANTS_H_
  5. #define UI_GFX_TEXT_CONSTANTS_H_
  6. namespace gfx {
  7. // TODO(msw): Distinguish between logical character stops and glyph stops?
  8. // TODO(msw): Merge with base::i18n::BreakIterator::BreakType.
  9. enum BreakType {
  10. CHARACTER_BREAK = 0, // Stop cursor movement on neighboring characters.
  11. WORD_BREAK, // Stop cursor movement on nearest word boundaries.
  12. LINE_BREAK, // Stop cursor movement on line ends as shown on screen.
  13. FIELD_BREAK, // Stop cursor movement on text ends.
  14. };
  15. // Specifies the selection behavior for a move/move-and-select command. For
  16. // example consider the state "ab|cd|e", i.e. cd is selected. Assume the
  17. // selection direction is from left to right. If we move to the beginning of the
  18. // line (LINE_BREAK, CURSOR_LEFT), the resultant state is:
  19. // "|ab|cde" for SELECTION_RETAIN, selection direction from right to left.
  20. // "|abcd|e" for SELECTION_EXTEND, selection direction from right to left.
  21. // "ab|cde" for SELECTION_CARET.
  22. // "|abcde" for SELECTION_NONE.
  23. enum SelectionBehavior {
  24. // Default behavior for a move-and-select command. The selection start point
  25. // remains the same. For example, this is the behavior of textfields on Mac
  26. // for the command moveUpAndModifySelection (Shift + Up).
  27. SELECTION_RETAIN,
  28. // Use for move-and-select commands that want the existing selection to be
  29. // extended in the opposite direction, when the selection direction is
  30. // reversed. For example, this is the behavior for textfields on Mac for the
  31. // command moveToLeftEndOfLineAndModifySelection (Command + Shift + Left).
  32. SELECTION_EXTEND,
  33. // Use for move-and-select commands that want the existing selection to reduce
  34. // to a caret, when the selection direction is reversed. For example, this is
  35. // the behavior for textfields on Mac for the command
  36. // moveWordLeftAndModifySelection (Alt + Shift + Left).
  37. SELECTION_CARET,
  38. // No selection. To be used for move commands that don't want to cause a
  39. // selection, and that want to collapse any pre-existing selection.
  40. SELECTION_NONE,
  41. };
  42. // Specifies the word wrapping behavior when a word would exceed the available
  43. // display width. All words that are too wide will be put on a new line, and
  44. // then:
  45. enum WordWrapBehavior {
  46. IGNORE_LONG_WORDS, // Overflowing word text is left on that line.
  47. TRUNCATE_LONG_WORDS, // Overflowing word text is truncated.
  48. ELIDE_LONG_WORDS, // Overflowing word text is elided at the ellipsis.
  49. WRAP_LONG_WORDS, // Overflowing word text is wrapped over multiple lines.
  50. };
  51. // Horizontal text alignment modes.
  52. enum HorizontalAlignment {
  53. ALIGN_LEFT = 0, // Align the text's left edge with that of its display area.
  54. ALIGN_CENTER, // Align the text's center with that of its display area.
  55. ALIGN_RIGHT, // Align the text's right edge with that of its display area.
  56. ALIGN_TO_HEAD, // Align the text to its first strong character's direction.
  57. };
  58. // Vertical text alignment modes for multiline text.
  59. enum VerticalAlignment {
  60. ALIGN_TOP = 0, // Align the text's top edge with that of its display area.
  61. ALIGN_MIDDLE, // Align the text's center with that of its display area.
  62. ALIGN_BOTTOM, // Align the text's bottom edge with that of its display area.
  63. };
  64. // The directionality modes used to determine the base text direction.
  65. enum DirectionalityMode {
  66. DIRECTIONALITY_FROM_TEXT = 0, // Use the first strong character's direction.
  67. DIRECTIONALITY_FROM_UI, // Use the UI locale's text reading direction.
  68. DIRECTIONALITY_FORCE_LTR, // Use LTR regardless of content or UI locale.
  69. DIRECTIONALITY_FORCE_RTL, // Use RTL regardless of content or UI locale.
  70. // Note: Unless the experimental feature LeftToRightUrls is enabled,
  71. // DIRECTIONALITY_AS_URL is the same as DIRECTIONALITY_FORCE_LTR.
  72. DIRECTIONALITY_AS_URL, // FORCE_LTR with additional rules for URLs.
  73. };
  74. // Text styles and adornments.
  75. // TODO(msw): Merge with gfx::Font::FontStyle.
  76. enum TextStyle {
  77. TEXT_STYLE_ITALIC = 0,
  78. TEXT_STYLE_STRIKE,
  79. TEXT_STYLE_UNDERLINE,
  80. TEXT_STYLE_HEAVY_UNDERLINE,
  81. TEXT_STYLE_COUNT,
  82. };
  83. // Text baseline offset types.
  84. // Figure of font metrics:
  85. // +--------+--------+------------------------+-------------+
  86. // | | | internal leading | SUPERSCRIPT |
  87. // | | +------------+-----------| |
  88. // | | ascent | | SUPERIOR |-------------+
  89. // | height | | cap height |-----------|
  90. // | | | | INFERIOR |-------------+
  91. // | |--------+------------+-----------| |
  92. // | | descent | SUBSCRIPT |
  93. // +--------+---------------------------------+-------------+
  94. enum BaselineStyle {
  95. NORMAL_BASELINE = 0,
  96. SUPERSCRIPT, // e.g. a mathematical exponent would be superscript.
  97. SUPERIOR, // e.g. 8th, the "th" would be superior script.
  98. INFERIOR, // e.g. 1/2, the "2" would be inferior ("1" is superior).
  99. SUBSCRIPT, // e.g. H2O, the "2" would be subscript.
  100. };
  101. // Elision behaviors of text that exceeds constrained dimensions.
  102. enum ElideBehavior {
  103. NO_ELIDE = 0, // Do not modify the text, it may overflow its available bounds.
  104. TRUNCATE, // Do not elide or fade, just truncate at the end of the string.
  105. ELIDE_HEAD, // Add an ellipsis at the start of the string.
  106. ELIDE_MIDDLE, // Add an ellipsis in the middle of the string.
  107. ELIDE_TAIL, // Add an ellipsis at the end of the string.
  108. ELIDE_EMAIL, // Add ellipses to username and domain substrings.
  109. FADE_TAIL, // Fade the string's end opposite of its horizontal alignment.
  110. };
  111. } // namespace gfx
  112. #endif // UI_GFX_TEXT_CONSTANTS_H_