| 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" |
| 11 #include "gfx/font.h" | 11 #include "gfx/font.h" |
| 12 #include "ui/base/models/simple_menu_model.h" | 12 #include "ui/base/models/simple_menu_model.h" |
| 13 #include "views/border.h" | 13 #include "views/border.h" |
| 14 #include "views/controls/textfield/native_textfield_wrapper.h" | 14 #include "views/controls/textfield/native_textfield_wrapper.h" |
| 15 #include "views/view.h" | 15 #include "views/view.h" |
| 16 | 16 |
| 17 namespace base { |
| 18 class Time; |
| 19 } |
| 20 |
| 17 namespace gfx { | 21 namespace gfx { |
| 18 class Canvas; | 22 class Canvas; |
| 19 } // namespace | 23 } // namespace |
| 20 | 24 |
| 21 namespace views { | 25 namespace views { |
| 22 | 26 |
| 23 class KeyEvent; | 27 class KeyEvent; |
| 24 class Menu2; | 28 class Menu2; |
| 25 class TextfieldViewsModel; | 29 class TextfieldViewsModel; |
| 26 | 30 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // Handle the keyevent. | 156 // Handle the keyevent. |
| 153 bool HandleKeyEvent(const KeyEvent& key_event); | 157 bool HandleKeyEvent(const KeyEvent& key_event); |
| 154 | 158 |
| 155 // Utility function. Gets the character corresponding to a keyevent. | 159 // Utility function. Gets the character corresponding to a keyevent. |
| 156 // Returns 0 if the character is not printable. | 160 // Returns 0 if the character is not printable. |
| 157 char16 GetPrintableChar(const KeyEvent& key_event); | 161 char16 GetPrintableChar(const KeyEvent& key_event); |
| 158 | 162 |
| 159 // Find a cusor position for given |point| in this views coordinates. | 163 // Find a cusor position for given |point| in this views coordinates. |
| 160 size_t FindCursorPosition(const gfx::Point& point) const; | 164 size_t FindCursorPosition(const gfx::Point& point) const; |
| 161 | 165 |
| 166 // Double or tripple click handler. Returns true if a double/triple click is |
| 167 // detected and handled. |
| 168 bool DetectAndHandleDoubleAndTripleClick(const views::MouseEvent& e); |
| 169 |
| 162 // Utility function to inform the parent textfield (and its controller if any) | 170 // Utility function to inform the parent textfield (and its controller if any) |
| 163 // that the text in the textfield has changed. | 171 // that the text in the textfield has changed. |
| 164 void PropagateTextChange(); | 172 void PropagateTextChange(); |
| 165 | 173 |
| 166 // Utility function to create the context menu if one does not already exist. | 174 // Utility function to create the context menu if one does not already exist. |
| 167 void InitContextMenuIfRequired(); | 175 void InitContextMenuIfRequired(); |
| 168 | 176 |
| 169 // The parent textfield, the owner of this object. | 177 // The parent textfield, the owner of this object. |
| 170 Textfield* textfield_; | 178 Textfield* textfield_; |
| 171 | 179 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 183 | 191 |
| 184 // True if the textfield is in insert mode. | 192 // True if the textfield is in insert mode. |
| 185 bool insert_; | 193 bool insert_; |
| 186 | 194 |
| 187 // The drawing state of cursor. True to draw. | 195 // The drawing state of cursor. True to draw. |
| 188 bool is_cursor_visible_; | 196 bool is_cursor_visible_; |
| 189 | 197 |
| 190 // A runnable method factory for callback to update the cursor. | 198 // A runnable method factory for callback to update the cursor. |
| 191 ScopedRunnableMethodFactory<NativeTextfieldViews> cursor_timer_; | 199 ScopedRunnableMethodFactory<NativeTextfieldViews> cursor_timer_; |
| 192 | 200 |
| 201 // Time of last mouse press. Used for tracking double/triple click. |
| 202 base::Time last_mouse_press_time_; |
| 203 |
| 204 // True if a double click has occured and we are waiting for a triple click. |
| 205 bool tracking_triple_click_; |
| 206 |
| 193 // Context menu and its content list for the textfield. | 207 // Context menu and its content list for the textfield. |
| 194 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_; | 208 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_; |
| 195 scoped_ptr<Menu2> context_menu_menu_; | 209 scoped_ptr<Menu2> context_menu_menu_; |
| 196 | 210 |
| 197 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); | 211 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); |
| 198 }; | 212 }; |
| 199 | 213 |
| 200 } // namespace views | 214 } // namespace views |
| 201 | 215 |
| 202 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 216 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
| OLD | NEW |