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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 const string16& text() const { return text_; } | 153 const string16& text() const { return text_; } |
154 virtual void SetText(const string16& text); | 154 virtual void SetText(const string16& text); |
155 | 155 |
156 const SelectionModel& selection_model() const { return selection_model_; } | 156 const SelectionModel& selection_model() const { return selection_model_; } |
157 void SetSelectionModel(const SelectionModel& sel); | 157 void SetSelectionModel(const SelectionModel& sel); |
158 | 158 |
159 bool cursor_visible() const { return cursor_visible_; } | 159 bool cursor_visible() const { return cursor_visible_; } |
160 void set_cursor_visible(bool visible) { cursor_visible_ = visible; } | 160 void set_cursor_visible(bool visible) { cursor_visible_ = visible; } |
161 | 161 |
162 bool insert_mode() const { return insert_mode_; } | 162 bool insert_mode() const { return insert_mode_; } |
163 void toggle_insert_mode() { insert_mode_ = !insert_mode_; } | 163 void ToggleInsertMode(); |
164 | 164 |
165 bool focused() const { return focused_; } | 165 bool focused() const { return focused_; } |
166 void set_focused(bool focused) { focused_ = focused; } | 166 void set_focused(bool focused) { focused_ = focused; } |
167 | 167 |
168 const StyleRange& default_style() const { return default_style_; } | 168 const StyleRange& default_style() const { return default_style_; } |
169 void set_default_style(StyleRange style) { default_style_ = style; } | 169 void set_default_style(StyleRange style) { default_style_ = style; } |
170 | 170 |
171 const Rect& display_rect() const { return display_rect_; } | 171 const Rect& display_rect() const { return display_rect_; } |
172 virtual void SetDisplayRect(const Rect& r); | 172 virtual void SetDisplayRect(const Rect& r); |
173 | 173 |
174 // This cursor position corresponds to SelectionModel::selection_end. In | 174 // This cursor position corresponds to SelectionModel::selection_end. In |
175 // addition to representing the selection end, it's also where logical text | 175 // addition to representing the selection end, it's also where logical text |
176 // edits take place, and doesn't necessarily correspond to | 176 // edits take place, and doesn't necessarily correspond to |
177 // SelectionModel::caret_pos. | 177 // SelectionModel::caret_pos. |
178 size_t GetCursorPosition() const; | 178 size_t GetCursorPosition() const; |
179 void SetCursorPosition(const size_t position); | 179 void SetCursorPosition(size_t position); |
180 | 180 |
181 void SetCaretPlacement(SelectionModel::CaretPlacement placement) { | 181 void SetCaretPlacement(SelectionModel::CaretPlacement placement) { |
182 selection_model_.set_caret_placement(placement); | 182 selection_model_.set_caret_placement(placement); |
183 } | 183 } |
184 | 184 |
185 // Moves the cursor left or right. Cursor movement is visual, meaning that | 185 // Moves the cursor left or right. Cursor movement is visual, meaning that |
186 // left and right are relative to screen, not the directionality of the text. | 186 // left and right are relative to screen, not the directionality of the text. |
187 // If |select| is false, the selection range is emptied at the new position. | 187 // If |select| is false, the selection start is moved to the same position. |
188 void MoveCursorLeft(BreakType break_type, bool select); | 188 void MoveCursorLeft(BreakType break_type, bool select); |
189 void MoveCursorRight(BreakType break_type, bool select); | 189 void MoveCursorRight(BreakType break_type, bool select); |
190 | 190 |
191 // Set the cursor to |position|. | |
192 // If |select| is false, the selection start is moved to the same position. | |
193 void MoveCursorTo(size_t position, bool select); | |
xji
2011/08/18 22:47:54
seems that this is not used as public (and we prob
msw
2011/08/19 10:55:30
Done.
| |
194 | |
191 // Set the selection_model_ to the value of |selection|. | 195 // Set the selection_model_ to the value of |selection|. |
192 // Returns true if the cursor position or selection range changed. | 196 // Returns true if the cursor position or selection range changed. |
193 bool MoveCursorTo(const SelectionModel& selection); | 197 bool MoveCursorTo(const SelectionModel& selection); |
194 | 198 |
195 // Move the cursor to the position associated with the clicked point. | 199 // Move the cursor to the position associated with the clicked point. |
196 // If |select| is false, the selection range is emptied at the new position. | 200 // If |select| is false, the selection start is moved to the same position. |
201 // Returns true if the cursor position or selection range changed. | |
197 bool MoveCursorTo(const Point& point, bool select); | 202 bool MoveCursorTo(const Point& point, bool select); |
198 | 203 |
199 size_t GetSelectionStart() const { | 204 size_t GetSelectionStart() const { |
200 return selection_model_.selection_start(); | 205 return selection_model_.selection_start(); |
201 } | 206 } |
202 size_t MinOfSelection() const { | 207 size_t MinOfSelection() const { |
203 return std::min(GetSelectionStart(), GetCursorPosition()); | 208 return std::min(GetSelectionStart(), GetCursorPosition()); |
204 } | 209 } |
205 size_t MaxOfSelection() const { | 210 size_t MaxOfSelection() const { |
206 return std::max(GetSelectionStart(), GetCursorPosition()); | 211 return std::max(GetSelectionStart(), GetCursorPosition()); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 // SetCursorPosition, SetSelectionModel, Font related style change, and other | 337 // SetCursorPosition, SetSelectionModel, Font related style change, and other |
333 // operations that adjust the visible text bounds. | 338 // operations that adjust the visible text bounds. |
334 bool cached_bounds_and_offset_valid_; | 339 bool cached_bounds_and_offset_valid_; |
335 | 340 |
336 DISALLOW_COPY_AND_ASSIGN(RenderText); | 341 DISALLOW_COPY_AND_ASSIGN(RenderText); |
337 }; | 342 }; |
338 | 343 |
339 } // namespace gfx | 344 } // namespace gfx |
340 | 345 |
341 #endif // UI_GFX_RENDER_TEXT_H_ | 346 #endif // UI_GFX_RENDER_TEXT_H_ |
OLD | NEW |