| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // Note that this returns the raw size of the string, which does not include | 268 // Note that this returns the raw size of the string, which does not include |
| 269 // the margin area of text shadows. | 269 // the margin area of text shadows. |
| 270 virtual Size GetStringSize() = 0; | 270 virtual Size GetStringSize() = 0; |
| 271 | 271 |
| 272 // Returns the common baseline of the text. The returned value is the vertical | 272 // Returns the common baseline of the text. The returned value is the vertical |
| 273 // offset from the top of |display_rect| to the text baseline, in pixels. | 273 // offset from the top of |display_rect| to the text baseline, in pixels. |
| 274 virtual int GetBaseline() = 0; | 274 virtual int GetBaseline() = 0; |
| 275 | 275 |
| 276 void Draw(Canvas* canvas); | 276 void Draw(Canvas* canvas); |
| 277 | 277 |
| 278 // Draws a cursor at |position|. |
| 279 void DrawCursor(Canvas* canvas, const SelectionModel& position); |
| 280 |
| 278 // Draw the selected text without a cursor or selection highlight. | 281 // Draw the selected text without a cursor or selection highlight. |
| 279 void DrawSelectedText(Canvas* canvas); | 282 void DrawSelectedText(Canvas* canvas); |
| 280 | 283 |
| 281 // Gets the SelectionModel from a visual point in local coordinates. | 284 // Gets the SelectionModel from a visual point in local coordinates. |
| 282 virtual SelectionModel FindCursorPosition(const Point& point) = 0; | 285 virtual SelectionModel FindCursorPosition(const Point& point) = 0; |
| 283 | 286 |
| 284 // Get the visual bounds of a cursor at |selection|. These bounds typically | 287 // Get the visual bounds of a cursor at |selection|. These bounds typically |
| 285 // represent a vertical line, but if |insert_mode| is true they contain the | 288 // represent a vertical line, but if |insert_mode| is true they contain the |
| 286 // bounds of the associated glyph. These bounds are in local coordinates, but | 289 // bounds of the associated glyph. These bounds are in local coordinates, but |
| 287 // may be outside the visible region if the text is longer than the textfield. | 290 // may be outside the visible region if the text is longer than the textfield. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 // it is a NO-OP. | 445 // it is a NO-OP. |
| 443 void MoveCursorTo(size_t position, bool select); | 446 void MoveCursorTo(size_t position, bool select); |
| 444 | 447 |
| 445 // Updates |obscured_text_| if the text is obscured. | 448 // Updates |obscured_text_| if the text is obscured. |
| 446 void UpdateObscuredText(); | 449 void UpdateObscuredText(); |
| 447 | 450 |
| 448 // Update the cached bounds and display offset to ensure that the current | 451 // Update the cached bounds and display offset to ensure that the current |
| 449 // cursor is within the visible display area. | 452 // cursor is within the visible display area. |
| 450 void UpdateCachedBoundsAndOffset(); | 453 void UpdateCachedBoundsAndOffset(); |
| 451 | 454 |
| 452 // Draw the selection and cursor. | 455 // Draw the selection. |
| 453 void DrawSelection(Canvas* canvas); | 456 void DrawSelection(Canvas* canvas); |
| 454 void DrawCursor(Canvas* canvas); | |
| 455 | 457 |
| 456 // Logical UTF-16 string data to be drawn. | 458 // Logical UTF-16 string data to be drawn. |
| 457 string16 text_; | 459 string16 text_; |
| 458 | 460 |
| 459 // Horizontal alignment of the text with respect to |display_rect_|. | 461 // Horizontal alignment of the text with respect to |display_rect_|. |
| 460 HorizontalAlignment horizontal_alignment_; | 462 HorizontalAlignment horizontal_alignment_; |
| 461 | 463 |
| 462 // The text directionality mode, defaults to DIRECTIONALITY_FROM_TEXT. | 464 // The text directionality mode, defaults to DIRECTIONALITY_FROM_TEXT. |
| 463 DirectionalityMode directionality_mode_; | 465 DirectionalityMode directionality_mode_; |
| 464 | 466 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 545 |
| 544 // Text shadows to be drawn. | 546 // Text shadows to be drawn. |
| 545 ShadowValues text_shadows_; | 547 ShadowValues text_shadows_; |
| 546 | 548 |
| 547 DISALLOW_COPY_AND_ASSIGN(RenderText); | 549 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 548 }; | 550 }; |
| 549 | 551 |
| 550 } // namespace gfx | 552 } // namespace gfx |
| 551 | 553 |
| 552 #endif // UI_GFX_RENDER_TEXT_H_ | 554 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |