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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // complex scripts, and bi-directional text. Implementations provide mechanisms | 186 // complex scripts, and bi-directional text. Implementations provide mechanisms |
187 // for rendering and translation between logical and visual data. | 187 // for rendering and translation between logical and visual data. |
188 class GFX_EXPORT RenderText { | 188 class GFX_EXPORT RenderText { |
189 public: | 189 public: |
190 virtual ~RenderText(); | 190 virtual ~RenderText(); |
191 | 191 |
192 // Creates a platform-specific or cross-platform RenderText instance. | 192 // Creates a platform-specific or cross-platform RenderText instance. |
193 static RenderText* CreateInstance(); | 193 static RenderText* CreateInstance(); |
194 static RenderText* CreateInstanceForEditing(); | 194 static RenderText* CreateInstanceForEditing(); |
195 | 195 |
| 196 // Returns true if the current RenderText subclass supports multilines. |
| 197 static bool MultilineSupported(); |
| 198 |
196 // Creates another instance of the same concrete class. | 199 // Creates another instance of the same concrete class. |
197 virtual scoped_ptr<RenderText> CreateInstanceOfSameType() const = 0; | 200 virtual scoped_ptr<RenderText> CreateInstanceOfSameType() const = 0; |
198 | 201 |
199 const base::string16& text() const { return text_; } | 202 const base::string16& text() const { return text_; } |
200 void SetText(const base::string16& text); | 203 void SetText(const base::string16& text); |
201 | 204 |
202 HorizontalAlignment horizontal_alignment() const { | 205 HorizontalAlignment horizontal_alignment() const { |
203 return horizontal_alignment_; | 206 return horizontal_alignment_; |
204 } | 207 } |
205 void SetHorizontalAlignment(HorizontalAlignment alignment); | 208 void SetHorizontalAlignment(HorizontalAlignment alignment); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 // supplied index is already at the boundary of the string. | 414 // supplied index is already at the boundary of the string. |
412 size_t IndexOfAdjacentGrapheme(size_t index, | 415 size_t IndexOfAdjacentGrapheme(size_t index, |
413 LogicalCursorDirection direction); | 416 LogicalCursorDirection direction); |
414 | 417 |
415 // Return a SelectionModel with the cursor at the current selection's start. | 418 // Return a SelectionModel with the cursor at the current selection's start. |
416 // The returned value represents a cursor/caret position without a selection. | 419 // The returned value represents a cursor/caret position without a selection. |
417 SelectionModel GetSelectionModelForSelectionStart(); | 420 SelectionModel GetSelectionModelForSelectionStart(); |
418 | 421 |
419 // Sets shadows to drawn with text. | 422 // Sets shadows to drawn with text. |
420 void set_shadows(const ShadowValues& shadows) { shadows_ = shadows; } | 423 void set_shadows(const ShadowValues& shadows) { shadows_ = shadows; } |
421 const ShadowValues& shadows() { return shadows_; } | 424 const ShadowValues& shadows() const { return shadows_; } |
422 | 425 |
423 typedef std::pair<Font, Range> FontSpan; | 426 typedef std::pair<Font, Range> FontSpan; |
424 // For testing purposes, returns which fonts were chosen for which parts of | 427 // For testing purposes, returns which fonts were chosen for which parts of |
425 // the text by returning a vector of Font and Range pairs, where each range | 428 // the text by returning a vector of Font and Range pairs, where each range |
426 // specifies the character range for which the corresponding font has been | 429 // specifies the character range for which the corresponding font has been |
427 // chosen. | 430 // chosen. |
428 virtual std::vector<FontSpan> GetFontSpansForTesting() = 0; | 431 virtual std::vector<FontSpan> GetFontSpansForTesting() = 0; |
429 | 432 |
430 // Gets the horizontal bounds (relative to the left of the text, not the view) | 433 // Gets the horizontal bounds (relative to the left of the text, not the view) |
431 // of the glyph starting at |index|. If the glyph is RTL then the returned | 434 // of the glyph starting at |index|. If the glyph is RTL then the returned |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 // Lines computed by EnsureLayout. These should be invalidated with | 730 // Lines computed by EnsureLayout. These should be invalidated with |
728 // ResetLayout and on |display_rect_| changes. | 731 // ResetLayout and on |display_rect_| changes. |
729 std::vector<internal::Line> lines_; | 732 std::vector<internal::Line> lines_; |
730 | 733 |
731 DISALLOW_COPY_AND_ASSIGN(RenderText); | 734 DISALLOW_COPY_AND_ASSIGN(RenderText); |
732 }; | 735 }; |
733 | 736 |
734 } // namespace gfx | 737 } // namespace gfx |
735 | 738 |
736 #endif // UI_GFX_RENDER_TEXT_H_ | 739 #endif // UI_GFX_RENDER_TEXT_H_ |
OLD | NEW |