| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_WIN_H_ | 5 #ifndef UI_GFX_RENDER_TEXT_WIN_H_ |
| 6 #define UI_GFX_RENDER_TEXT_WIN_H_ | 6 #define UI_GFX_RENDER_TEXT_WIN_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <usp10.h> | 9 #include <usp10.h> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } // namespace internal | 53 } // namespace internal |
| 54 | 54 |
| 55 // RenderTextWin is the Windows implementation of RenderText using Uniscribe. | 55 // RenderTextWin is the Windows implementation of RenderText using Uniscribe. |
| 56 class RenderTextWin : public RenderText { | 56 class RenderTextWin : public RenderText { |
| 57 public: | 57 public: |
| 58 RenderTextWin(); | 58 RenderTextWin(); |
| 59 virtual ~RenderTextWin(); | 59 virtual ~RenderTextWin(); |
| 60 | 60 |
| 61 // Overridden from RenderText: | 61 // Overridden from RenderText: |
| 62 virtual int GetStringWidth() OVERRIDE; | 62 virtual int GetStringWidth() OVERRIDE; |
| 63 virtual void Draw(Canvas* canvas) OVERRIDE; | |
| 64 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; | 63 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; |
| 65 virtual Rect GetCursorBounds(const SelectionModel& selection, | 64 virtual Rect GetCursorBounds(const SelectionModel& selection, |
| 66 bool insert_mode) OVERRIDE; | 65 bool insert_mode) OVERRIDE; |
| 67 | 66 |
| 68 protected: | 67 protected: |
| 69 // Overridden from RenderText: | 68 // Overridden from RenderText: |
| 70 virtual SelectionModel GetLeftSelectionModel(const SelectionModel& current, | 69 virtual SelectionModel GetLeftSelectionModel(const SelectionModel& current, |
| 71 BreakType break_type) OVERRIDE; | 70 BreakType break_type) OVERRIDE; |
| 72 virtual SelectionModel GetRightSelectionModel(const SelectionModel& current, | 71 virtual SelectionModel GetRightSelectionModel(const SelectionModel& current, |
| 73 BreakType break_type) OVERRIDE; | 72 BreakType break_type) OVERRIDE; |
| 74 virtual SelectionModel LeftEndSelectionModel() OVERRIDE; | 73 virtual SelectionModel LeftEndSelectionModel() OVERRIDE; |
| 75 virtual SelectionModel RightEndSelectionModel() OVERRIDE; | 74 virtual SelectionModel RightEndSelectionModel() OVERRIDE; |
| 76 virtual std::vector<Rect> GetSubstringBounds(size_t from, size_t to) OVERRIDE; | 75 virtual void GetSubstringBounds(size_t from, |
| 76 size_t to, |
| 77 std::vector<Rect>* bounds) OVERRIDE; |
| 77 virtual bool IsCursorablePosition(size_t position) OVERRIDE; | 78 virtual bool IsCursorablePosition(size_t position) OVERRIDE; |
| 78 virtual void UpdateLayout() OVERRIDE; | 79 virtual void UpdateLayout() OVERRIDE; |
| 80 virtual void DrawVisualText(Canvas* canvas) OVERRIDE; |
| 79 | 81 |
| 80 private: | 82 private: |
| 81 virtual size_t IndexOfAdjacentGrapheme(size_t index, bool next) OVERRIDE; | 83 virtual size_t IndexOfAdjacentGrapheme(size_t index, bool next) OVERRIDE; |
| 82 | 84 |
| 83 void ItemizeLogicalText(); | 85 void ItemizeLogicalText(); |
| 84 void LayoutVisualText(); | 86 void LayoutVisualText(); |
| 85 | 87 |
| 86 // Return the run index that contains the argument; or the length of the | 88 // Return the run index that contains the argument; or the length of the |
| 87 // |runs_| vector if argument exceeds the text length or width. | 89 // |runs_| vector if argument exceeds the text length or width. |
| 88 size_t GetRunContainingPosition(size_t position) const; | 90 size_t GetRunContainingPosition(size_t position) const; |
| 89 size_t GetRunContainingPoint(const Point& point) const; | 91 size_t GetRunContainingPoint(const Point& point) const; |
| 90 | 92 |
| 91 // Given a |run|, returns the SelectionModel that contains the logical first | 93 // Given a |run|, returns the SelectionModel that contains the logical first |
| 92 // or last caret position inside (not at a boundary of) the run. | 94 // or last caret position inside (not at a boundary of) the run. |
| 93 // The returned value represents a cursor/caret position without a selection. | 95 // The returned value represents a cursor/caret position without a selection. |
| 94 SelectionModel FirstSelectionModelInsideRun(internal::TextRun* run); | 96 SelectionModel FirstSelectionModelInsideRun(internal::TextRun* run); |
| 95 SelectionModel LastSelectionModelInsideRun(internal::TextRun* run); | 97 SelectionModel LastSelectionModelInsideRun(internal::TextRun* run); |
| 96 | 98 |
| 97 // Get the selection model visually left/right of |selection| by one grapheme. | 99 // Get the selection model visually left/right of |selection| by one grapheme. |
| 98 // The returned value represents a cursor/caret position without a selection. | 100 // The returned value represents a cursor/caret position without a selection. |
| 99 SelectionModel LeftSelectionModel(const SelectionModel& selection); | 101 SelectionModel LeftSelectionModel(const SelectionModel& selection); |
| 100 SelectionModel RightSelectionModel(const SelectionModel& selection); | 102 SelectionModel RightSelectionModel(const SelectionModel& selection); |
| 101 | 103 |
| 102 // Draw the text, cursor, and selection. | |
| 103 void DrawSelection(Canvas* canvas); | |
| 104 void DrawVisualText(Canvas* canvas); | |
| 105 void DrawCursor(Canvas* canvas); | |
| 106 | |
| 107 // National Language Support native digit and digit substitution settings. | 104 // National Language Support native digit and digit substitution settings. |
| 108 SCRIPT_DIGITSUBSTITUTE digit_substitute_; | 105 SCRIPT_DIGITSUBSTITUTE digit_substitute_; |
| 109 | 106 |
| 110 SCRIPT_CONTROL script_control_; | 107 SCRIPT_CONTROL script_control_; |
| 111 SCRIPT_STATE script_state_; | 108 SCRIPT_STATE script_state_; |
| 112 | 109 |
| 113 std::vector<internal::TextRun*> runs_; | 110 std::vector<internal::TextRun*> runs_; |
| 114 int string_width_; | 111 int string_width_; |
| 115 | 112 |
| 116 scoped_array<int> visual_to_logical_; | 113 scoped_array<int> visual_to_logical_; |
| 117 scoped_array<int> logical_to_visual_; | 114 scoped_array<int> logical_to_visual_; |
| 118 | 115 |
| 119 DISALLOW_COPY_AND_ASSIGN(RenderTextWin); | 116 DISALLOW_COPY_AND_ASSIGN(RenderTextWin); |
| 120 }; | 117 }; |
| 121 | 118 |
| 122 } // namespace gfx | 119 } // namespace gfx |
| 123 | 120 |
| 124 #endif // UI_GFX_RENDER_TEXT_WIN_H_ | 121 #endif // UI_GFX_RENDER_TEXT_WIN_H_ |
| OLD | NEW |