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