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> | |
10 | |
11 #include "base/memory/scoped_ptr.h" | |
9 #include "ui/gfx/render_text.h" | 12 #include "ui/gfx/render_text.h" |
10 | 13 |
11 namespace gfx { | 14 namespace gfx { |
12 | 15 |
16 struct TextRun { | |
oshima
2011/08/19 18:29:10
should this be in namespace internal?
msw
2011/08/19 20:34:03
Done.
| |
17 TextRun(); | |
18 | |
19 ui::Range range; | |
20 Font font; | |
21 // TODO(msw): Disambiguate color, strike, etc. from TextRuns. | |
22 // Otherwise, this breaks the glyph shaping process. | |
23 // See the example at: http://www.catch22.net/tuts/neatpad/12. | |
24 SkColor foreground; | |
25 bool strike; | |
26 | |
27 int width; | |
28 // The cumulative widths of preceding runs. | |
29 int preceding_run_widths; | |
30 | |
31 SCRIPT_ANALYSIS script_analysis; | |
32 | |
33 scoped_array<WORD> glyphs; | |
34 scoped_array<WORD> logical_clusters; | |
35 scoped_array<SCRIPT_VISATTR> visible_attributes; | |
36 int glyph_count; | |
37 | |
38 scoped_array<int> advance_widths; | |
39 scoped_array<GOFFSET> offsets; | |
40 ABC abc_widths; | |
41 | |
42 scoped_array<SCRIPT_LOGATTR> logical_attributes; | |
43 | |
44 private: | |
45 DISALLOW_COPY_AND_ASSIGN(TextRun); | |
46 }; | |
47 | |
13 // RenderTextWin is the Windows implementation of RenderText using Uniscribe. | 48 // RenderTextWin is the Windows implementation of RenderText using Uniscribe. |
14 class RenderTextWin : public RenderText { | 49 class RenderTextWin : public RenderText { |
15 public: | 50 public: |
16 RenderTextWin(); | 51 RenderTextWin(); |
17 virtual ~RenderTextWin(); | 52 virtual ~RenderTextWin(); |
18 | 53 |
54 virtual void SetText(const string16& text) OVERRIDE; | |
55 virtual void ApplyStyleRange(StyleRange style_range) OVERRIDE; | |
56 virtual int GetStringWidth() OVERRIDE; | |
57 virtual void Draw(Canvas* canvas) OVERRIDE; | |
58 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; | |
59 virtual std::vector<Rect> GetSubstringBounds(size_t from, size_t to) OVERRIDE; | |
60 virtual Rect GetCursorBounds(const SelectionModel& selection, | |
61 bool insert_mode) OVERRIDE; | |
62 | |
63 protected: | |
64 virtual SelectionModel GetLeftSelectionModel(const SelectionModel& current, | |
65 BreakType break_type) OVERRIDE; | |
66 virtual SelectionModel GetRightSelectionModel(const SelectionModel& current, | |
67 BreakType break_type) OVERRIDE; | |
68 | |
69 // TODO(msw): Implement this with complex script support. | |
70 // virtual size_t GetIndexOfPreviousGrapheme(size_t position) OVERRIDE; | |
71 | |
19 private: | 72 private: |
73 void ItemizeLogicalText(); | |
74 void LayoutVisualText(HDC hdc); | |
75 | |
76 // Return the run index that contains the argument; or the length of the | |
77 // |runs_| vector if argument exceeds the text length or width. | |
78 size_t GetRunContainingPosition(size_t position) const; | |
79 size_t GetRunContainingPoint(const Point& point) const; | |
80 | |
81 // Get the neighboring selection model, which may not be at a valid stop. | |
82 SelectionModel LeftSelectionModel(const SelectionModel& selection) const; | |
83 SelectionModel RightSelectionModel(const SelectionModel& selection) const; | |
84 | |
85 // Get the SelectionModels corresponding to the left and right text ends. | |
86 SelectionModel LeftEndSelectionModel() const; | |
87 SelectionModel RightEndSelectionModel() const; | |
88 | |
89 // Draw the text, cursor, and selection. | |
90 void DrawSelection(Canvas* canvas); | |
91 void DrawVisualText(Canvas* canvas); | |
92 void DrawCursor(Canvas* canvas); | |
93 | |
94 // Convert points from the text space to the view space and back. | |
95 // Handles the display area, display offset, and the application LTR/RTL mode. | |
96 Point RenderTextWin::ToTextPoint(const Point& point); | |
97 Point RenderTextWin::ToViewPoint(const Point& point); | |
98 | |
99 bool text_is_dirty_; | |
100 bool style_is_dirty_; | |
101 | |
102 // National Language Support native digit and digit substitution settings. | |
103 SCRIPT_DIGITSUBSTITUTE digit_substitute_; | |
104 | |
105 SCRIPT_CONTROL script_control_; | |
106 SCRIPT_STATE script_state_; | |
107 | |
108 SCRIPT_CACHE script_cache_; | |
109 | |
110 std::vector<TextRun*> runs_; | |
111 int string_width_; | |
112 | |
113 scoped_array<int> visual_to_logical_; | |
114 scoped_array<int> logical_to_visual_; | |
115 | |
20 DISALLOW_COPY_AND_ASSIGN(RenderTextWin); | 116 DISALLOW_COPY_AND_ASSIGN(RenderTextWin); |
21 }; | 117 }; |
22 | 118 |
23 } // namespace gfx; | 119 } // namespace gfx; |
24 | 120 |
25 #endif // UI_GFX_RENDER_TEXT_WIN_H_ | 121 #endif // UI_GFX_RENDER_TEXT_WIN_H_ |
OLD | NEW |