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_LINUX_H_ | 5 #ifndef UI_GFX_RENDER_TEXT_LINUX_H_ |
6 #define UI_GFX_RENDER_TEXT_LINUX_H_ | 6 #define UI_GFX_RENDER_TEXT_LINUX_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <pango/pango.h> | 9 #include <pango/pango.h> |
10 | 10 |
msw
2011/11/28 20:01:17
I don't think you need this blank line, both are s
xji
2011/11/29 01:37:02
Done.
| |
11 #include <vector> | |
12 | |
11 #include "ui/gfx/render_text.h" | 13 #include "ui/gfx/render_text.h" |
12 | 14 |
13 namespace gfx { | 15 namespace gfx { |
14 | 16 |
15 // RenderTextLinux is the Linux implementation of RenderText using Pango. | 17 // RenderTextLinux is the Linux implementation of RenderText using Pango. |
16 class RenderTextLinux : public RenderText { | 18 class RenderTextLinux : public RenderText { |
17 public: | 19 public: |
18 RenderTextLinux(); | 20 RenderTextLinux(); |
19 virtual ~RenderTextLinux(); | 21 virtual ~RenderTextLinux(); |
20 | 22 |
21 // Overridden from RenderText: | 23 // Overridden from RenderText: |
22 virtual base::i18n::TextDirection GetTextDirection() OVERRIDE; | 24 virtual base::i18n::TextDirection GetTextDirection() OVERRIDE; |
23 virtual int GetStringWidth() OVERRIDE; | 25 virtual int GetStringWidth() OVERRIDE; |
24 virtual void Draw(Canvas* canvas) OVERRIDE; | 26 virtual void Draw(Canvas* canvas) OVERRIDE; |
25 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; | 27 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE; |
26 virtual Rect GetCursorBounds(const SelectionModel& position, | 28 virtual Rect GetCursorBounds(const SelectionModel& position, |
27 bool insert_mode) OVERRIDE; | 29 bool insert_mode) OVERRIDE; |
28 | 30 |
29 protected: | 31 protected: |
30 // Overridden from RenderText: | 32 // Overridden from RenderText: |
31 virtual SelectionModel GetLeftSelectionModel(const SelectionModel& current, | 33 virtual SelectionModel GetLeftSelectionModel(const SelectionModel& current, |
32 BreakType break_type) OVERRIDE; | 34 BreakType break_type) OVERRIDE; |
33 virtual SelectionModel GetRightSelectionModel(const SelectionModel& current, | 35 virtual SelectionModel GetRightSelectionModel(const SelectionModel& current, |
34 BreakType break_type) OVERRIDE; | 36 BreakType break_type) OVERRIDE; |
35 virtual SelectionModel LeftEndSelectionModel() OVERRIDE; | 37 virtual SelectionModel LeftEndSelectionModel() OVERRIDE; |
36 virtual SelectionModel RightEndSelectionModel() OVERRIDE; | 38 virtual SelectionModel RightEndSelectionModel() OVERRIDE; |
39 virtual std::vector<Rect> GetSubstringBounds(size_t from, size_t to) OVERRIDE; | |
40 virtual void SetSelectionModel( | |
41 const SelectionModel& selection_model) OVERRIDE; | |
37 virtual bool IsCursorablePosition(size_t position) OVERRIDE; | 42 virtual bool IsCursorablePosition(size_t position) OVERRIDE; |
38 virtual void UpdateLayout() OVERRIDE; | 43 virtual void UpdateLayout() OVERRIDE; |
44 virtual void DrawVisualText(Canvas* canvas) OVERRIDE; | |
39 | 45 |
40 private: | 46 private: |
41 virtual size_t IndexOfAdjacentGrapheme(size_t index, bool next) OVERRIDE; | 47 virtual size_t IndexOfAdjacentGrapheme(size_t index, bool next) OVERRIDE; |
42 | 48 |
43 // Returns the run that contains |position|. Return NULL if not found. | 49 // Returns the run that contains |position|. Return NULL if not found. |
44 GSList* GetRunContainingPosition(size_t position) const; | 50 GSList* GetRunContainingPosition(size_t position) const; |
45 | 51 |
46 // Given |utf8_index_of_current_grapheme|, returns the UTF8 or UTF16 index of | 52 // Given |utf8_index_of_current_grapheme|, returns the UTF8 or UTF16 index of |
47 // next grapheme in the text if |next| is true, otherwise, returns the index | 53 // next grapheme in the text if |next| is true, otherwise, returns the index |
48 // of previous grapheme. Returns 0 if there is no previous grapheme, and | 54 // of previous grapheme. Returns 0 if there is no previous grapheme, and |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 // The complexity is O(n) since it is a single-linked list. | 95 // The complexity is O(n) since it is a single-linked list. |
90 PangoLayoutRun* GetPreviousRun(PangoLayoutRun* run) const; | 96 PangoLayoutRun* GetPreviousRun(PangoLayoutRun* run) const; |
91 | 97 |
92 // Returns the last run in |current_line_|. | 98 // Returns the last run in |current_line_|. |
93 // The complexity is O(n) since it is a single-linked list. | 99 // The complexity is O(n) since it is a single-linked list. |
94 PangoLayoutRun* GetLastRun() const; | 100 PangoLayoutRun* GetLastRun() const; |
95 | 101 |
96 size_t Utf16IndexToUtf8Index(size_t index) const; | 102 size_t Utf16IndexToUtf8Index(size_t index) const; |
97 size_t Utf8IndexToUtf16Index(size_t index) const; | 103 size_t Utf8IndexToUtf16Index(size_t index) const; |
98 | 104 |
105 // Save the visual bounds containing the logical substring within |from| to | |
106 // |to| into |bounds|. | |
107 void GetSubstringBounds(size_t from, size_t to, std::vector<Rect>* bounds); | |
msw
2011/11/28 20:01:17
Our style guide discourages overloading function n
xji
2011/11/29 01:37:02
changed the name to CalculateSubstringBounds.
| |
108 | |
99 // Pango Layout. | 109 // Pango Layout. |
100 PangoLayout* layout_; | 110 PangoLayout* layout_; |
101 // A single line layout resulting from laying out via |layout_|. | 111 // A single line layout resulting from laying out via |layout_|. |
102 PangoLayoutLine* current_line_; | 112 PangoLayoutLine* current_line_; |
103 | 113 |
104 // Information about character attributes. | 114 // Information about character attributes. |
105 PangoLogAttr* log_attrs_; | 115 PangoLogAttr* log_attrs_; |
106 // Number of attributes in |log_attrs_|. | 116 // Number of attributes in |log_attrs_|. |
107 int num_log_attrs_; | 117 int num_log_attrs_; |
108 | 118 |
119 // Vector of the visual bounds containing the logical substring of selection. | |
120 std::vector<Rect> selection_visual_bounds_; | |
121 | |
109 // The text in the |layout_|. | 122 // The text in the |layout_|. |
110 const char* layout_text_; | 123 const char* layout_text_; |
111 // The text length. | 124 // The text length. |
112 size_t layout_text_len_; | 125 size_t layout_text_len_; |
113 | 126 |
114 DISALLOW_COPY_AND_ASSIGN(RenderTextLinux); | 127 DISALLOW_COPY_AND_ASSIGN(RenderTextLinux); |
115 }; | 128 }; |
116 | 129 |
117 } // namespace gfx | 130 } // namespace gfx |
118 | 131 |
119 #endif // UI_GFX_RENDER_TEXT_LINUX_H_ | 132 #endif // UI_GFX_RENDER_TEXT_LINUX_H_ |
OLD | NEW |