| 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_TEXTFIELD_CONTROLLER_H_ | 5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ |
| 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ | 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class Textfield; | 22 class Textfield; |
| 23 | 23 |
| 24 // This defines the callback interface for other code to be notified of changes | 24 // This defines the callback interface for other code to be notified of changes |
| 25 // in the state of a text field. | 25 // in the state of a text field. |
| 26 class VIEWS_EXPORT TextfieldController { | 26 class VIEWS_EXPORT TextfieldController { |
| 27 public: | 27 public: |
| 28 // This method is called whenever the text in the field is changed by the | 28 // This method is called whenever the text in the field is changed by the |
| 29 // user. It won't be called if the text is changed by calling | 29 // user. It won't be called if the text is changed by calling |
| 30 // Textfield::SetText() or Textfield::AppendText(). | 30 // Textfield::SetText() or Textfield::AppendText(). |
| 31 virtual void ContentsChanged(Textfield* sender, | 31 virtual void ContentsChanged(Textfield* sender, |
| 32 const string16& new_contents) {} | 32 const base::string16& new_contents) {} |
| 33 | 33 |
| 34 // This method is called to get notified about keystrokes in the edit. | 34 // This method is called to get notified about keystrokes in the edit. |
| 35 // Returns true if the message was handled and should not be processed | 35 // Returns true if the message was handled and should not be processed |
| 36 // further. If it returns false the processing continues. | 36 // further. If it returns false the processing continues. |
| 37 virtual bool HandleKeyEvent(Textfield* sender, | 37 virtual bool HandleKeyEvent(Textfield* sender, |
| 38 const ui::KeyEvent& key_event); | 38 const ui::KeyEvent& key_event); |
| 39 | 39 |
| 40 // This method is called to get notified about mouse events in the edit. | 40 // This method is called to get notified about mouse events in the edit. |
| 41 // Returns true if the message was handled and should not be processed | 41 // Returns true if the message was handled and should not be processed |
| 42 // further. Currently, only mouse down events are sent here. | 42 // further. Currently, only mouse down events are sent here. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 virtual void UpdateContextMenu(ui::SimpleMenuModel* menu_contents) {} | 80 virtual void UpdateContextMenu(ui::SimpleMenuModel* menu_contents) {} |
| 81 | 81 |
| 82 // Returns true if the |command_id| should be enabled in the context menu. | 82 // Returns true if the |command_id| should be enabled in the context menu. |
| 83 virtual bool IsCommandIdEnabled(int command_id) const; | 83 virtual bool IsCommandIdEnabled(int command_id) const; |
| 84 | 84 |
| 85 // Returns true if the item label for the |command_id| is dynamic in the | 85 // Returns true if the item label for the |command_id| is dynamic in the |
| 86 // context menu. | 86 // context menu. |
| 87 virtual bool IsItemForCommandIdDynamic(int command_id) const; | 87 virtual bool IsItemForCommandIdDynamic(int command_id) const; |
| 88 | 88 |
| 89 // Returns the label string for the |coomand_id|. | 89 // Returns the label string for the |coomand_id|. |
| 90 virtual string16 GetLabelForCommandId(int command_id) const; | 90 virtual base::string16 GetLabelForCommandId(int command_id) const; |
| 91 | 91 |
| 92 // Returns whether the controller handles the specified command. This is used | 92 // Returns whether the controller handles the specified command. This is used |
| 93 // to handle a command the textfield would normally handle. For example, to | 93 // to handle a command the textfield would normally handle. For example, to |
| 94 // have the controller handle |IDS_APP_PASTE| override and return true if | 94 // have the controller handle |IDS_APP_PASTE| override and return true if |
| 95 // |command_id| == |IDS_APP_PASTE|. | 95 // |command_id| == |IDS_APP_PASTE|. |
| 96 // This is only invoked if the command is enabled. | 96 // This is only invoked if the command is enabled. |
| 97 virtual bool HandlesCommand(int command_id) const; | 97 virtual bool HandlesCommand(int command_id) const; |
| 98 | 98 |
| 99 // Execute context menu command specified by |command_id|. | 99 // Execute context menu command specified by |command_id|. |
| 100 virtual void ExecuteCommand(int command_id, int event_flag) {} | 100 virtual void ExecuteCommand(int command_id, int event_flag) {} |
| 101 | 101 |
| 102 protected: | 102 protected: |
| 103 virtual ~TextfieldController() {} | 103 virtual ~TextfieldController() {} |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 } // namespace views | 106 } // namespace views |
| 107 | 107 |
| 108 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ | 108 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ |
| OLD | NEW |