OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_RENDER_TEXT_H_ | 5 #ifndef UI_GFX_RENDER_TEXT_H_ |
6 #define UI_GFX_RENDER_TEXT_H_ | 6 #define UI_GFX_RENDER_TEXT_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <cstring> | 9 #include <cstring> |
10 #include <string> | 10 #include <string> |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 207 |
208 const base::string16& text() const { return text_; } | 208 const base::string16& text() const { return text_; } |
209 void SetText(const base::string16& text); | 209 void SetText(const base::string16& text); |
210 void AppendText(const base::string16& text); | 210 void AppendText(const base::string16& text); |
211 | 211 |
212 HorizontalAlignment horizontal_alignment() const { | 212 HorizontalAlignment horizontal_alignment() const { |
213 return horizontal_alignment_; | 213 return horizontal_alignment_; |
214 } | 214 } |
215 void SetHorizontalAlignment(HorizontalAlignment alignment); | 215 void SetHorizontalAlignment(HorizontalAlignment alignment); |
216 | 216 |
| 217 VerticalAlignment vertical_alignment() const { return vertical_alignment_; } |
| 218 void SetVerticalAlignment(VerticalAlignment alignment); |
| 219 |
217 const FontList& font_list() const { return font_list_; } | 220 const FontList& font_list() const { return font_list_; } |
218 void SetFontList(const FontList& font_list); | 221 void SetFontList(const FontList& font_list); |
219 | 222 |
220 bool cursor_enabled() const { return cursor_enabled_; } | 223 bool cursor_enabled() const { return cursor_enabled_; } |
221 void SetCursorEnabled(bool cursor_enabled); | 224 void SetCursorEnabled(bool cursor_enabled); |
222 | 225 |
223 bool cursor_visible() const { return cursor_visible_; } | 226 bool cursor_visible() const { return cursor_visible_; } |
224 void set_cursor_visible(bool visible) { cursor_visible_ = visible; } | 227 void set_cursor_visible(bool visible) { cursor_visible_ = visible; } |
225 | 228 |
226 bool insert_mode() const { return insert_mode_; } | 229 bool insert_mode() const { return insert_mode_; } |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, NewlineWithoutMultilineFlag); | 639 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, NewlineWithoutMultilineFlag); |
637 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GlyphBounds); | 640 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GlyphBounds); |
638 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_GlyphBounds); | 641 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_GlyphBounds); |
639 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, | 642 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, |
640 MoveCursorLeftRight_MeiryoUILigatures); | 643 MoveCursorLeftRight_MeiryoUILigatures); |
641 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Win_LogicalClusters); | 644 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Win_LogicalClusters); |
642 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SameFontForParentheses); | 645 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SameFontForParentheses); |
643 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, BreakRunsByUnicodeBlocks); | 646 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, BreakRunsByUnicodeBlocks); |
644 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PangoAttributes); | 647 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PangoAttributes); |
645 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StringFitsOwnWidth); | 648 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StringFitsOwnWidth); |
| 649 FRIEND_TEST_ALL_PREFIXES(RenderTextTest, VerticalAlignement); |
646 | 650 |
647 // Set the cursor to |position|, with the caret trailing the previous | 651 // Set the cursor to |position|, with the caret trailing the previous |
648 // grapheme, or if there is no previous grapheme, leading the cursor position. | 652 // grapheme, or if there is no previous grapheme, leading the cursor position. |
649 // If |select| is false, the selection start is moved to the same position. | 653 // If |select| is false, the selection start is moved to the same position. |
650 // If the |position| is not a cursorable position (not on grapheme boundary), | 654 // If the |position| is not a cursorable position (not on grapheme boundary), |
651 // it is a NO-OP. | 655 // it is a NO-OP. |
652 void MoveCursorTo(size_t position, bool select); | 656 void MoveCursorTo(size_t position, bool select); |
653 | 657 |
654 // Updates |layout_text_| and |display_text_| as needed (or marks them dirty). | 658 // Updates |layout_text_| and |display_text_| as needed (or marks them dirty). |
655 void OnTextAttributeChanged(); | 659 void OnTextAttributeChanged(); |
(...skipping 16 matching lines...) Expand all Loading... |
672 // Draw the selection. | 676 // Draw the selection. |
673 void DrawSelection(Canvas* canvas); | 677 void DrawSelection(Canvas* canvas); |
674 | 678 |
675 // Logical UTF-16 string data to be drawn. | 679 // Logical UTF-16 string data to be drawn. |
676 base::string16 text_; | 680 base::string16 text_; |
677 | 681 |
678 // Horizontal alignment of the text with respect to |display_rect_|. The | 682 // Horizontal alignment of the text with respect to |display_rect_|. The |
679 // default is to align left if the application UI is LTR and right if RTL. | 683 // default is to align left if the application UI is LTR and right if RTL. |
680 HorizontalAlignment horizontal_alignment_; | 684 HorizontalAlignment horizontal_alignment_; |
681 | 685 |
| 686 // Vertical alignment of the text with respect to |display_rect_|. The |
| 687 // default is to vertically align middle. |
| 688 VerticalAlignment vertical_alignment_; |
| 689 |
682 // The text directionality mode, defaults to DIRECTIONALITY_FROM_TEXT. | 690 // The text directionality mode, defaults to DIRECTIONALITY_FROM_TEXT. |
683 DirectionalityMode directionality_mode_; | 691 DirectionalityMode directionality_mode_; |
684 | 692 |
685 // The cached text direction, potentially computed from the text or UI locale. | 693 // The cached text direction, potentially computed from the text or UI locale. |
686 // Use GetTextDirection(), do not use this potentially invalid value directly! | 694 // Use GetTextDirection(), do not use this potentially invalid value directly! |
687 base::i18n::TextDirection text_direction_; | 695 base::i18n::TextDirection text_direction_; |
688 | 696 |
689 // A list of fonts used to render |text_|. | 697 // A list of fonts used to render |text_|. |
690 FontList font_list_; | 698 FontList font_list_; |
691 | 699 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 // Lines computed by EnsureLayout. These should be invalidated upon | 807 // Lines computed by EnsureLayout. These should be invalidated upon |
800 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. | 808 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. |
801 std::vector<internal::Line> lines_; | 809 std::vector<internal::Line> lines_; |
802 | 810 |
803 DISALLOW_COPY_AND_ASSIGN(RenderText); | 811 DISALLOW_COPY_AND_ASSIGN(RenderText); |
804 }; | 812 }; |
805 | 813 |
806 } // namespace gfx | 814 } // namespace gfx |
807 | 815 |
808 #endif // UI_GFX_RENDER_TEXT_H_ | 816 #endif // UI_GFX_RENDER_TEXT_H_ |
OLD | NEW |