Add ICU message format support
[chromium-blink-merge.git] / ui / views / controls / textfield / textfield_controller.h
blob4a01d384f4bcd4be48e2a14769bd5132a2495f94
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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_
6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_
8 #include <set>
10 #include "base/strings/string16.h"
11 #include "ui/base/dragdrop/os_exchange_data.h"
12 #include "ui/views/views_export.h"
14 namespace ui {
15 class KeyEvent;
16 class MouseEvent;
17 class SimpleMenuModel;
18 } // namespace ui
20 namespace views {
22 class Textfield;
24 // This defines the callback interface for other code to be notified of changes
25 // in the state of a text field.
26 class VIEWS_EXPORT TextfieldController {
27 public:
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
30 // Textfield::SetText() or Textfield::AppendText().
31 virtual void ContentsChanged(Textfield* sender,
32 const base::string16& new_contents) {}
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
36 // further. If it returns false the processing continues.
37 virtual bool HandleKeyEvent(Textfield* sender,
38 const ui::KeyEvent& key_event);
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
42 // further. Currently, only mouse down events are sent here.
43 virtual bool HandleMouseEvent(Textfield* sender,
44 const ui::MouseEvent& mouse_event);
46 // Called before performing a user action that may change the textfield.
47 // It's currently only supported by Views implementation.
48 virtual void OnBeforeUserAction(Textfield* sender) {}
50 // Called after performing a user action that may change the textfield.
51 // It's currently only supported by Views implementation.
52 virtual void OnAfterUserAction(Textfield* sender) {}
54 // Called after performing a Cut or Copy operation.
55 virtual void OnAfterCutOrCopy(ui::ClipboardType clipboard_type) {}
57 // Called after performing a Paste operation.
58 virtual void OnAfterPaste() {}
60 // Called after the textfield has written drag data to give the controller a
61 // chance to modify the drag data.
62 virtual void OnWriteDragData(ui::OSExchangeData* data) {}
64 // Called after the textfield has set default drag operations to give the
65 // controller a chance to update them.
66 virtual void OnGetDragOperationsForTextfield(int* drag_operations) {}
68 // Enables the controller to append to the accepted drop formats.
69 virtual void AppendDropFormats(
70 int* formats,
71 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) {}
73 // Called when a drop of dragged data happens on the textfield. This method is
74 // called before regular handling of the drop. If this returns a drag
75 // operation other than |ui::DragDropTypes::DRAG_NONE|, regular handling is
76 // skipped.
77 virtual int OnDrop(const ui::OSExchangeData& data);
79 // Gives the controller a chance to modify the context menu contents.
80 virtual void UpdateContextMenu(ui::SimpleMenuModel* menu_contents) {}
82 protected:
83 virtual ~TextfieldController() {}
86 } // namespace views
88 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_