| 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 "app/menus/simple_menu_model.h" | |
| 10 #include "base/string16.h" | 9 #include "base/string16.h" |
| 11 #include "base/task.h" | 10 #include "base/task.h" |
| 12 #include "gfx/font.h" | 11 #include "gfx/font.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 gfx { | 17 namespace gfx { |
| 18 class Canvas; | 18 class Canvas; |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 namespace views { | 21 namespace views { |
| 22 | 22 |
| 23 class KeyEvent; | 23 class KeyEvent; |
| 24 class Menu2; | 24 class Menu2; |
| 25 class TextfieldViewsModel; | 25 class TextfieldViewsModel; |
| 26 | 26 |
| 27 // A views/skia only implementation of NativeTextfieldWrapper. | 27 // A views/skia only implementation of NativeTextfieldWrapper. |
| 28 // No platform specific code is used. | 28 // No platform specific code is used. |
| 29 // Following features are not yet supported. | 29 // Following features are not yet supported. |
| 30 // * BIDI | 30 // * BIDI |
| 31 // * IME/i18n support. | 31 // * IME/i18n support. |
| 32 // * X selection (only if we want to support). | 32 // * X selection (only if we want to support). |
| 33 // * STYLE_MULTILINE, STYLE_LOWERCASE text. (These are not used in | 33 // * STYLE_MULTILINE, STYLE_LOWERCASE text. (These are not used in |
| 34 // chromeos, so we may not need them) | 34 // chromeos, so we may not need them) |
| 35 // * Double click to select word, and triple click to select all. | 35 // * Double click to select word, and triple click to select all. |
| 36 // * Undo/Redo | 36 // * Undo/Redo |
| 37 class NativeTextfieldViews : public views::View, | 37 class NativeTextfieldViews : public views::View, |
| 38 public views::ContextMenuController, | 38 public views::ContextMenuController, |
| 39 public NativeTextfieldWrapper, | 39 public NativeTextfieldWrapper, |
| 40 public menus::SimpleMenuModel::Delegate { | 40 public ui::SimpleMenuModel::Delegate { |
| 41 public: | 41 public: |
| 42 explicit NativeTextfieldViews(Textfield* parent); | 42 explicit NativeTextfieldViews(Textfield* parent); |
| 43 ~NativeTextfieldViews(); | 43 ~NativeTextfieldViews(); |
| 44 | 44 |
| 45 // views::View overrides: | 45 // views::View overrides: |
| 46 virtual bool OnMousePressed(const views::MouseEvent& e); | 46 virtual bool OnMousePressed(const views::MouseEvent& e); |
| 47 virtual bool OnMouseDragged(const views::MouseEvent& e); | 47 virtual bool OnMouseDragged(const views::MouseEvent& e); |
| 48 virtual void OnMouseReleased(const views::MouseEvent& e, bool canceled); | 48 virtual void OnMouseReleased(const views::MouseEvent& e, bool canceled); |
| 49 virtual bool OnKeyPressed(const views::KeyEvent& e); | 49 virtual bool OnKeyPressed(const views::KeyEvent& e); |
| 50 virtual bool OnKeyReleased(const views::KeyEvent& e); | 50 virtual bool OnKeyReleased(const views::KeyEvent& e); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 80 virtual bool SetFocus(); | 80 virtual bool SetFocus(); |
| 81 virtual View* GetView(); | 81 virtual View* GetView(); |
| 82 virtual gfx::NativeView GetTestingHandle() const; | 82 virtual gfx::NativeView GetTestingHandle() const; |
| 83 virtual bool IsIMEComposing() const; | 83 virtual bool IsIMEComposing() const; |
| 84 virtual bool HandleKeyPressed(const views::KeyEvent& e); | 84 virtual bool HandleKeyPressed(const views::KeyEvent& e); |
| 85 virtual bool HandleKeyReleased(const views::KeyEvent& e); | 85 virtual bool HandleKeyReleased(const views::KeyEvent& e); |
| 86 virtual void HandleWillGainFocus(); | 86 virtual void HandleWillGainFocus(); |
| 87 virtual void HandleDidGainFocus(); | 87 virtual void HandleDidGainFocus(); |
| 88 virtual void HandleWillLoseFocus(); | 88 virtual void HandleWillLoseFocus(); |
| 89 | 89 |
| 90 // menus::SimpleMenuModel::Delegate overrides | 90 // ui::SimpleMenuModel::Delegate overrides |
| 91 virtual bool IsCommandIdChecked(int command_id) const; | 91 virtual bool IsCommandIdChecked(int command_id) const; |
| 92 virtual bool IsCommandIdEnabled(int command_id) const; | 92 virtual bool IsCommandIdEnabled(int command_id) const; |
| 93 virtual bool GetAcceleratorForCommandId(int command_id, | 93 virtual bool GetAcceleratorForCommandId(int command_id, |
| 94 menus::Accelerator* accelerator); | 94 ui::Accelerator* accelerator); |
| 95 virtual void ExecuteCommand(int command_id); | 95 virtual void ExecuteCommand(int command_id); |
| 96 | 96 |
| 97 // class name of internal | 97 // class name of internal |
| 98 static const char kViewClassName[]; | 98 static const char kViewClassName[]; |
| 99 | 99 |
| 100 // Returns true when | 100 // Returns true when |
| 101 // 1) built with GYP_DEFIENS="touchui=1" | 101 // 1) built with GYP_DEFIENS="touchui=1" |
| 102 // 2) enabled by SetEnableTextfieldViews(true) | 102 // 2) enabled by SetEnableTextfieldViews(true) |
| 103 // 3) enabled by the command line flag "--enable-textfield-view". | 103 // 3) enabled by the command line flag "--enable-textfield-view". |
| 104 static bool IsTextfieldViewsEnabled(); | 104 static bool IsTextfieldViewsEnabled(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 // True if the textfield is in insert mode. | 184 // True if the textfield is in insert mode. |
| 185 bool insert_; | 185 bool insert_; |
| 186 | 186 |
| 187 // The drawing state of cursor. True to draw. | 187 // The drawing state of cursor. True to draw. |
| 188 bool is_cursor_visible_; | 188 bool is_cursor_visible_; |
| 189 | 189 |
| 190 // A runnable method factory for callback to update the cursor. | 190 // A runnable method factory for callback to update the cursor. |
| 191 ScopedRunnableMethodFactory<NativeTextfieldViews> cursor_timer_; | 191 ScopedRunnableMethodFactory<NativeTextfieldViews> cursor_timer_; |
| 192 | 192 |
| 193 // Context menu and its content list for the textfield. | 193 // Context menu and its content list for the textfield. |
| 194 scoped_ptr<menus::SimpleMenuModel> context_menu_contents_; | 194 scoped_ptr<ui::SimpleMenuModel> context_menu_contents_; |
| 195 scoped_ptr<Menu2> context_menu_menu_; | 195 scoped_ptr<Menu2> context_menu_menu_; |
| 196 | 196 |
| 197 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); | 197 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 } // namespace views | 200 } // namespace views |
| 201 | 201 |
| 202 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 202 #endif // VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
| OLD | NEW |