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_H_ | 5 #ifndef UI_GFX_RENDER_TEXT_H_ |
6 #define UI_GFX_RENDER_TEXT_H_ | 6 #define UI_GFX_RENDER_TEXT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 19 matching lines...) Expand all Loading... |
30 // before dogfooding textfield views. | 30 // before dogfooding textfield views. |
31 const SkColor kSelectedTextColor = SK_ColorWHITE; | 31 const SkColor kSelectedTextColor = SK_ColorWHITE; |
32 const SkColor kFocusedSelectionColor = SK_ColorCYAN; | 32 const SkColor kFocusedSelectionColor = SK_ColorCYAN; |
33 const SkColor kUnfocusedSelectionColor = SK_ColorLTGRAY; | 33 const SkColor kUnfocusedSelectionColor = SK_ColorLTGRAY; |
34 const SkColor kCursorColor = SK_ColorBLACK; | 34 const SkColor kCursorColor = SK_ColorBLACK; |
35 | 35 |
36 class Canvas; | 36 class Canvas; |
37 class RenderTextTest; | 37 class RenderTextTest; |
38 | 38 |
39 // A visual style applicable to a range of text. | 39 // A visual style applicable to a range of text. |
40 struct UI_API StyleRange { | 40 struct UI_EXPORT StyleRange { |
41 StyleRange(); | 41 StyleRange(); |
42 | 42 |
43 Font font; | 43 Font font; |
44 SkColor foreground; | 44 SkColor foreground; |
45 bool strike; | 45 bool strike; |
46 bool underline; | 46 bool underline; |
47 ui::Range range; | 47 ui::Range range; |
48 }; | 48 }; |
49 | 49 |
50 typedef std::vector<StyleRange> StyleRanges; | 50 typedef std::vector<StyleRange> StyleRanges; |
(...skipping 26 matching lines...) Expand all Loading... |
77 // Pointing to the right half of 'c' displays the cursor right of 'c' as | 77 // Pointing to the right half of 'c' displays the cursor right of 'c' as |
78 // "abc|FED". | 78 // "abc|FED". |
79 // Pointing to the right half of 'D' displays the cursor right of 'D' as | 79 // Pointing to the right half of 'D' displays the cursor right of 'D' as |
80 // "abcFED|". | 80 // "abcFED|". |
81 // So, besides the logical selection start point and end point, we need extra | 81 // So, besides the logical selection start point and end point, we need extra |
82 // information to specify to which character and on which edge of the character | 82 // information to specify to which character and on which edge of the character |
83 // the visual cursor is bound to. For example, the visual cursor is bound to | 83 // the visual cursor is bound to. For example, the visual cursor is bound to |
84 // the trailing side of the 2nd character 'c' when pointing to right half of | 84 // the trailing side of the 2nd character 'c' when pointing to right half of |
85 // 'c'. And it is bound to the leading edge of the 3rd character 'D' when | 85 // 'c'. And it is bound to the leading edge of the 3rd character 'D' when |
86 // pointing to right of 'D'. | 86 // pointing to right of 'D'. |
87 class UI_API SelectionModel { | 87 class UI_EXPORT SelectionModel { |
88 public: | 88 public: |
89 enum CaretPlacement { | 89 enum CaretPlacement { |
90 // PREVIOUS_GRAPHEME_TRAILING means cursor is visually attached to the | 90 // PREVIOUS_GRAPHEME_TRAILING means cursor is visually attached to the |
91 // trailing edge of previous grapheme. | 91 // trailing edge of previous grapheme. |
92 PREVIOUS_GRAPHEME_TRAILING, | 92 PREVIOUS_GRAPHEME_TRAILING, |
93 LEADING, | 93 LEADING, |
94 TRAILING, | 94 TRAILING, |
95 }; | 95 }; |
96 | 96 |
97 SelectionModel(); | 97 SelectionModel(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // The visual placement of the cursor, relative to its associated character. | 135 // The visual placement of the cursor, relative to its associated character. |
136 CaretPlacement caret_placement_; | 136 CaretPlacement caret_placement_; |
137 }; | 137 }; |
138 | 138 |
139 // TODO(msw): Implement RenderText[Win|Linux] for Uniscribe/Pango BiDi... | 139 // TODO(msw): Implement RenderText[Win|Linux] for Uniscribe/Pango BiDi... |
140 | 140 |
141 // RenderText represents an abstract model of styled text and its corresponding | 141 // RenderText represents an abstract model of styled text and its corresponding |
142 // visual layout. Support is built in for a cursor, a selection, simple styling, | 142 // visual layout. Support is built in for a cursor, a selection, simple styling, |
143 // complex scripts, and bi-directional text. Implementations provide mechanisms | 143 // complex scripts, and bi-directional text. Implementations provide mechanisms |
144 // for rendering and translation between logical and visual data. | 144 // for rendering and translation between logical and visual data. |
145 class UI_API RenderText { | 145 class UI_EXPORT RenderText { |
146 public: | 146 public: |
147 virtual ~RenderText(); | 147 virtual ~RenderText(); |
148 | 148 |
149 // Creates a platform-specific RenderText instance. | 149 // Creates a platform-specific RenderText instance. |
150 static RenderText* CreateRenderText(); | 150 static RenderText* CreateRenderText(); |
151 | 151 |
152 const string16& text() const { return text_; } | 152 const string16& text() const { return text_; } |
153 virtual void SetText(const string16& text); | 153 virtual void SetText(const string16& text); |
154 | 154 |
155 const SelectionModel& selection_model() const { return selection_model_; } | 155 const SelectionModel& selection_model() const { return selection_model_; } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 Rect display_rect_; | 321 Rect display_rect_; |
322 // The offset for the text to be drawn, relative to the display area. | 322 // The offset for the text to be drawn, relative to the display area. |
323 Point display_offset_; | 323 Point display_offset_; |
324 | 324 |
325 DISALLOW_COPY_AND_ASSIGN(RenderText); | 325 DISALLOW_COPY_AND_ASSIGN(RenderText); |
326 }; | 326 }; |
327 | 327 |
328 } // namespace gfx | 328 } // namespace gfx |
329 | 329 |
330 #endif // UI_GFX_RENDER_TEXT_H_ | 330 #endif // UI_GFX_RENDER_TEXT_H_ |
OLD | NEW |