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_NATIVE_TEXTFIELD_VIEWS_H_ | 5 #ifndef VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
6 #define VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 6 #define VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/task.h" | 10 #include "base/task.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 174 |
175 // Returns the Textfield's text color. | 175 // Returns the Textfield's text color. |
176 SkColor GetTextColor() const; | 176 SkColor GetTextColor() const; |
177 | 177 |
178 // A callback function to periodically update the cursor state. | 178 // A callback function to periodically update the cursor state. |
179 void UpdateCursor(); | 179 void UpdateCursor(); |
180 | 180 |
181 // Repaint the cursor. | 181 // Repaint the cursor. |
182 void RepaintCursor(); | 182 void RepaintCursor(); |
183 | 183 |
| 184 // Returns the bounds of character at the current cursor. |
| 185 gfx::Rect GetCursorBounds(size_t cursor_pos) const; |
| 186 |
184 // Update the cursor_bounds and text_offset. | 187 // Update the cursor_bounds and text_offset. |
185 void UpdateCursorBoundsAndTextOffset(); | 188 void UpdateCursorBoundsAndTextOffset(); |
186 | 189 |
187 void PaintTextAndCursor(gfx::Canvas* canvas); | 190 void PaintTextAndCursor(gfx::Canvas* canvas); |
188 | 191 |
189 // Handle the keyevent. | 192 // Handle the keyevent. |
190 bool HandleKeyEvent(const KeyEvent& key_event); | 193 bool HandleKeyEvent(const KeyEvent& key_event); |
191 | 194 |
192 // Find a cusor position for given |point| in this views coordinates. | 195 // Find a cusor position for given |point| in this views coordinates. |
193 size_t FindCursorPosition(const gfx::Point& point) const; | 196 size_t FindCursorPosition(const gfx::Point& point) const; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 237 |
235 // The text model. | 238 // The text model. |
236 scoped_ptr<TextfieldViewsModel> model_; | 239 scoped_ptr<TextfieldViewsModel> model_; |
237 | 240 |
238 // The reference to the border class. The object is owned by View::border_. | 241 // The reference to the border class. The object is owned by View::border_. |
239 FocusableBorder* text_border_; | 242 FocusableBorder* text_border_; |
240 | 243 |
241 // The x offset for the text to be drawn, without insets; | 244 // The x offset for the text to be drawn, without insets; |
242 int text_offset_; | 245 int text_offset_; |
243 | 246 |
244 // Cursor's bounds in the textfield's coordinates. | |
245 gfx::Rect cursor_bounds_; | |
246 | |
247 // True if the textfield is in insert mode. | 247 // True if the textfield is in insert mode. |
248 bool insert_; | 248 bool insert_; |
249 | 249 |
250 // The drawing state of cursor. True to draw. | 250 // The local bounds and visibility of the textfield's primary text cursor. |
| 251 gfx::Rect cursor_bounds_; |
251 bool is_cursor_visible_; | 252 bool is_cursor_visible_; |
252 | 253 |
| 254 // The local bounds and visibility of the textfield's drop text cursor. |
| 255 // The drop cursor is a visual cue for where dragged text will be dropped. |
| 256 gfx::Rect drop_cursor_bounds_; |
| 257 bool is_drop_cursor_visible_; |
| 258 |
253 // True if InputMethod::CancelComposition() should not be called. | 259 // True if InputMethod::CancelComposition() should not be called. |
254 bool skip_input_method_cancel_composition_; | 260 bool skip_input_method_cancel_composition_; |
255 | 261 |
256 // Is the user potentially dragging and dropping from this view? | 262 // Is the user potentially dragging and dropping from this view? |
257 bool initiating_drag_; | 263 bool initiating_drag_; |
258 | 264 |
259 // A runnable method factory for callback to update the cursor. | 265 // A runnable method factory for callback to update the cursor. |
260 ScopedRunnableMethodFactory<NativeTextfieldViews> cursor_timer_; | 266 ScopedRunnableMethodFactory<NativeTextfieldViews> cursor_timer_; |
261 | 267 |
262 // State variables used to track double and triple clicks. | 268 // State variables used to track double and triple clicks. |
263 size_t aggregated_clicks_; | 269 size_t aggregated_clicks_; |
264 base::Time last_click_time_; | 270 base::Time last_click_time_; |
265 gfx::Point last_click_location_; | 271 gfx::Point last_click_location_; |
266 | 272 |
267 // Context menu and its content list for the textfield. | 273 // Context menu and its content list for the textfield. |
268 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_; | 274 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_; |
269 scoped_ptr<Menu2> context_menu_menu_; | 275 scoped_ptr<Menu2> context_menu_menu_; |
270 | 276 |
271 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); | 277 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); |
272 }; | 278 }; |
273 | 279 |
274 } // namespace views | 280 } // namespace views |
275 | 281 |
276 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 282 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
OLD | NEW |