| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
| 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "ui/base/events.h" | 10 #include "ui/base/events.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 class Time; | 23 class Time; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace gfx { | 26 namespace gfx { |
| 27 class Canvas; | 27 class Canvas; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace views { | 30 namespace views { |
| 31 | 31 |
| 32 class FocusableBorder; | 32 class FocusableBorder; |
| 33 class KeyEvent; | |
| 34 class MenuModelAdapter; | 33 class MenuModelAdapter; |
| 35 class MenuRunner; | 34 class MenuRunner; |
| 36 | 35 |
| 37 // A views/skia only implementation of NativeTextfieldWrapper. | 36 // A views/skia only implementation of NativeTextfieldWrapper. |
| 38 // No platform specific code is used. | 37 // No platform specific code is used. |
| 39 // Following features are not yet supported. | 38 // Following features are not yet supported. |
| 40 // * BIDI/Complex script. | 39 // * BIDI/Complex script. |
| 41 // * Support surrogate pair, or maybe we should just use UTF32 internally. | 40 // * Support surrogate pair, or maybe we should just use UTF32 internally. |
| 42 // * X selection (only if we want to support). | 41 // * X selection (only if we want to support). |
| 43 // Once completed, this will replace Textfield, NativeTextfieldWin and | 42 // Once completed, this will replace Textfield, NativeTextfieldWin and |
| 44 // NativeTextfieldGtk. | 43 // NativeTextfieldGtk. |
| 45 class VIEWS_EXPORT NativeTextfieldViews : public TouchSelectionClientView, | 44 class VIEWS_EXPORT NativeTextfieldViews : public TouchSelectionClientView, |
| 46 public ContextMenuController, | 45 public ContextMenuController, |
| 47 public DragController, | 46 public DragController, |
| 48 public NativeTextfieldWrapper, | 47 public NativeTextfieldWrapper, |
| 49 public ui::TextInputClient, | 48 public ui::TextInputClient, |
| 50 public TextfieldViewsModel::Delegate { | 49 public TextfieldViewsModel::Delegate { |
| 51 public: | 50 public: |
| 52 explicit NativeTextfieldViews(Textfield* parent); | 51 explicit NativeTextfieldViews(Textfield* parent); |
| 53 virtual ~NativeTextfieldViews(); | 52 virtual ~NativeTextfieldViews(); |
| 54 | 53 |
| 55 // View overrides: | 54 // View overrides: |
| 56 virtual gfx::NativeCursor GetCursor(const MouseEvent& event) OVERRIDE; | 55 virtual gfx::NativeCursor GetCursor(const MouseEvent& event) OVERRIDE; |
| 57 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; | 56 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; |
| 58 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; | 57 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; |
| 59 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; | 58 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; |
| 60 virtual ui::GestureStatus OnGestureEvent(const GestureEvent& event) OVERRIDE; | 59 virtual ui::GestureStatus OnGestureEvent(const GestureEvent& event) OVERRIDE; |
| 61 virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE; | 60 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
| 62 virtual bool GetDropFormats( | 61 virtual bool GetDropFormats( |
| 63 int* formats, | 62 int* formats, |
| 64 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; | 63 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; |
| 65 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; | 64 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; |
| 66 virtual int OnDragUpdated(const DropTargetEvent& event) OVERRIDE; | 65 virtual int OnDragUpdated(const DropTargetEvent& event) OVERRIDE; |
| 67 virtual int OnPerformDrop(const DropTargetEvent& event) OVERRIDE; | 66 virtual int OnPerformDrop(const DropTargetEvent& event) OVERRIDE; |
| 68 virtual void OnDragDone() OVERRIDE; | 67 virtual void OnDragDone() OVERRIDE; |
| 69 virtual bool OnKeyReleased(const KeyEvent& event) OVERRIDE; | 68 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; |
| 70 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 69 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 71 virtual void OnFocus() OVERRIDE; | 70 virtual void OnFocus() OVERRIDE; |
| 72 virtual void OnBlur() OVERRIDE; | 71 virtual void OnBlur() OVERRIDE; |
| 73 | 72 |
| 74 // TouchSelectionClientView overrides: | 73 // TouchSelectionClientView overrides: |
| 75 virtual void SelectRect(const gfx::Point& start, | 74 virtual void SelectRect(const gfx::Point& start, |
| 76 const gfx::Point& end) OVERRIDE; | 75 const gfx::Point& end) OVERRIDE; |
| 77 | 76 |
| 78 // ContextMenuController overrides: | 77 // ContextMenuController overrides: |
| 79 virtual void ShowContextMenuForView(View* source, | 78 virtual void ShowContextMenuForView(View* source, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 109 virtual void UpdateVerticalMargins() OVERRIDE; | 108 virtual void UpdateVerticalMargins() OVERRIDE; |
| 110 virtual bool SetFocus() OVERRIDE; | 109 virtual bool SetFocus() OVERRIDE; |
| 111 virtual View* GetView() OVERRIDE; | 110 virtual View* GetView() OVERRIDE; |
| 112 virtual gfx::NativeView GetTestingHandle() const OVERRIDE; | 111 virtual gfx::NativeView GetTestingHandle() const OVERRIDE; |
| 113 virtual bool IsIMEComposing() const OVERRIDE; | 112 virtual bool IsIMEComposing() const OVERRIDE; |
| 114 virtual void GetSelectedRange(ui::Range* range) const OVERRIDE; | 113 virtual void GetSelectedRange(ui::Range* range) const OVERRIDE; |
| 115 virtual void SelectRange(const ui::Range& range) OVERRIDE; | 114 virtual void SelectRange(const ui::Range& range) OVERRIDE; |
| 116 virtual void GetSelectionModel(gfx::SelectionModel* sel) const OVERRIDE; | 115 virtual void GetSelectionModel(gfx::SelectionModel* sel) const OVERRIDE; |
| 117 virtual void SelectSelectionModel(const gfx::SelectionModel& sel) OVERRIDE; | 116 virtual void SelectSelectionModel(const gfx::SelectionModel& sel) OVERRIDE; |
| 118 virtual size_t GetCursorPosition() const OVERRIDE; | 117 virtual size_t GetCursorPosition() const OVERRIDE; |
| 119 virtual bool HandleKeyPressed(const KeyEvent& e) OVERRIDE; | 118 virtual bool HandleKeyPressed(const ui::KeyEvent& e) OVERRIDE; |
| 120 virtual bool HandleKeyReleased(const KeyEvent& e) OVERRIDE; | 119 virtual bool HandleKeyReleased(const ui::KeyEvent& e) OVERRIDE; |
| 121 virtual void HandleFocus() OVERRIDE; | 120 virtual void HandleFocus() OVERRIDE; |
| 122 virtual void HandleBlur() OVERRIDE; | 121 virtual void HandleBlur() OVERRIDE; |
| 123 virtual ui::TextInputClient* GetTextInputClient() OVERRIDE; | 122 virtual ui::TextInputClient* GetTextInputClient() OVERRIDE; |
| 124 virtual void ApplyStyleRange(const gfx::StyleRange& style) OVERRIDE; | 123 virtual void ApplyStyleRange(const gfx::StyleRange& style) OVERRIDE; |
| 125 virtual void ApplyDefaultStyle() OVERRIDE; | 124 virtual void ApplyDefaultStyle() OVERRIDE; |
| 126 virtual void ClearEditHistory() OVERRIDE; | 125 virtual void ClearEditHistory() OVERRIDE; |
| 127 virtual int GetFontHeight() OVERRIDE; | 126 virtual int GetFontHeight() OVERRIDE; |
| 128 | 127 |
| 129 // ui::SimpleMenuModel::Delegate overrides | 128 // ui::SimpleMenuModel::Delegate overrides |
| 130 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 129 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 185 |
| 187 // Repaint the cursor. | 186 // Repaint the cursor. |
| 188 void RepaintCursor(); | 187 void RepaintCursor(); |
| 189 | 188 |
| 190 // Update the cursor_bounds and text_offset. | 189 // Update the cursor_bounds and text_offset. |
| 191 void UpdateCursorBoundsAndTextOffset(size_t cursor_pos, bool insert_mode); | 190 void UpdateCursorBoundsAndTextOffset(size_t cursor_pos, bool insert_mode); |
| 192 | 191 |
| 193 void PaintTextAndCursor(gfx::Canvas* canvas); | 192 void PaintTextAndCursor(gfx::Canvas* canvas); |
| 194 | 193 |
| 195 // Handle the keyevent. | 194 // Handle the keyevent. |
| 196 bool HandleKeyEvent(const KeyEvent& key_event); | 195 bool HandleKeyEvent(const ui::KeyEvent& key_event); |
| 197 | 196 |
| 198 // Helper function to call MoveCursorTo on the TextfieldViewsModel. | 197 // Helper function to call MoveCursorTo on the TextfieldViewsModel. |
| 199 bool MoveCursorTo(const gfx::Point& point, bool select); | 198 bool MoveCursorTo(const gfx::Point& point, bool select); |
| 200 | 199 |
| 201 // Utility function to inform the parent textfield (and its controller if any) | 200 // Utility function to inform the parent textfield (and its controller if any) |
| 202 // that the text in the textfield has changed. | 201 // that the text in the textfield has changed. |
| 203 void PropagateTextChange(); | 202 void PropagateTextChange(); |
| 204 | 203 |
| 205 // Does necessary updates when the text and/or the position of the cursor | 204 // Does necessary updates when the text and/or the position of the cursor |
| 206 // changed. | 205 // changed. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 scoped_ptr<views::MenuRunner> context_menu_runner_; | 281 scoped_ptr<views::MenuRunner> context_menu_runner_; |
| 283 | 282 |
| 284 scoped_ptr<TouchSelectionController> touch_selection_controller_; | 283 scoped_ptr<TouchSelectionController> touch_selection_controller_; |
| 285 | 284 |
| 286 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); | 285 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViews); |
| 287 }; | 286 }; |
| 288 | 287 |
| 289 } // namespace views | 288 } // namespace views |
| 290 | 289 |
| 291 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ | 290 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_VIEWS_H_ |
| OLD | NEW |