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 VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_VIEWS_MODEL_H_ | 5 #ifndef VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_VIEWS_MODEL_H_ |
6 #define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_VIEWS_MODEL_H_ | 6 #define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_VIEWS_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <vector> | 10 #include <vector> |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Cursor related methods. | 127 // Cursor related methods. |
128 | 128 |
129 // Returns the current cursor position. | 129 // Returns the current cursor position. |
130 size_t GetCursorPosition() const; | 130 size_t GetCursorPosition() const; |
131 | 131 |
132 // Moves the cursor, see RenderText for additional details. | 132 // Moves the cursor, see RenderText for additional details. |
133 // The current composition text will be confirmed. | 133 // The current composition text will be confirmed. |
134 void MoveCursorLeft(gfx::BreakType break_type, bool select); | 134 void MoveCursorLeft(gfx::BreakType break_type, bool select); |
135 void MoveCursorRight(gfx::BreakType break_type, bool select); | 135 void MoveCursorRight(gfx::BreakType break_type, bool select); |
136 | 136 |
137 // Moves the cursor to the specified |position|. | 137 // Moves the selection to the specified selection in |selection|. |
138 // If |select| is true, it updates the selection accordingly. | 138 // If there is composition text, it will be confirmed, which will update the |
139 // The current composition text will be confirmed. | 139 // selection range, and it overrides the selection_start to which the |
140 bool MoveCursorTo(size_t position, bool select); | 140 // selection will move to. |
| 141 bool MoveCursorTo(const gfx::SelectionModel& selection); |
141 | 142 |
142 // Helper function to call MoveCursorTo on the TextfieldViewsModel. | 143 // Helper function to call MoveCursorTo on the TextfieldViewsModel. |
143 bool MoveCursorTo(const gfx::Point& point, bool select); | 144 bool MoveCursorTo(const gfx::Point& point, bool select); |
144 | 145 |
145 // Returns the bounds of selected text. | 146 // Returns the bounds of selected text. |
146 std::vector<gfx::Rect> GetSelectionBounds() const; | 147 std::vector<gfx::Rect> GetSelectionBounds() const; |
147 | 148 |
148 // Selection related method | 149 // Selection related method |
149 | 150 |
150 // Returns the selected text. | 151 // Returns the selected text. |
151 string16 GetSelectedText() const; | 152 string16 GetSelectedText() const; |
152 | 153 |
153 void GetSelectedRange(ui::Range* range) const; | 154 void GetSelectedRange(ui::Range* range) const; |
154 | 155 |
155 // The current composition text will be confirmed. The | 156 // The current composition text will be confirmed. The |
156 // selection starts with the range's start position, | 157 // selection starts with the range's start position, |
157 // and ends with the range's end position, therefore | 158 // and ends with the range's end position, therefore |
158 // the cursor position becomes the end position. | 159 // the cursor position becomes the end position. |
159 void SelectRange(const ui::Range& range); | 160 void SelectRange(const ui::Range& range); |
160 | 161 |
| 162 // The current composition text will be confirmed. |
| 163 // render_text_'s selection model is set to |sel|. |
| 164 void SelectSelectionModel(const gfx::SelectionModel& sel); |
| 165 |
161 // Selects all text. | 166 // Selects all text. |
162 // The current composition text will be confirmed. | 167 // The current composition text will be confirmed. |
163 void SelectAll(); | 168 void SelectAll(); |
164 | 169 |
165 // Selects the word at which the cursor is currently positioned. | 170 // Selects the word at which the cursor is currently positioned. |
166 // The current composition text will be confirmed. | 171 // The current composition text will be confirmed. |
167 void SelectWord(); | 172 void SelectWord(); |
168 | 173 |
169 // Clears selection. | 174 // Clears selection. |
170 // The current composition text will be confirmed. | 175 // The current composition text will be confirmed. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // 2) new edit is added. (redo history is cleared) | 325 // 2) new edit is added. (redo history is cleared) |
321 // 3) redone all undone edits. | 326 // 3) redone all undone edits. |
322 EditHistory::iterator current_edit_; | 327 EditHistory::iterator current_edit_; |
323 | 328 |
324 DISALLOW_COPY_AND_ASSIGN(TextfieldViewsModel); | 329 DISALLOW_COPY_AND_ASSIGN(TextfieldViewsModel); |
325 }; | 330 }; |
326 | 331 |
327 } // namespace views | 332 } // namespace views |
328 | 333 |
329 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_VIEWS_MODEL_H_ | 334 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_VIEWS_MODEL_H_ |
OLD | NEW |