Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / views / controls / prefix_selector.h
blob255046f60dff9aed12021c2286c9de0395e59f82
1 // Copyright 2013 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_PREFIX_SELECTOR_H_
6 #define UI_VIEWS_CONTROLS_PREFIX_SELECTOR_H_
8 #include "base/strings/string16.h"
9 #include "base/time/time.h"
10 #include "ui/base/ime/text_input_client.h"
11 #include "ui/views/views_export.h"
13 namespace views {
15 class PrefixDelegate;
17 // PrefixSelector is used to change the selection in a view as the user
18 // types characters.
19 class VIEWS_EXPORT PrefixSelector : public ui::TextInputClient {
20 public:
21 explicit PrefixSelector(PrefixDelegate* delegate);
22 virtual ~PrefixSelector();
24 // Invoked from the view when it loses focus.
25 void OnViewBlur();
27 // ui::TextInputClient:
28 virtual void SetCompositionText(
29 const ui::CompositionText& composition) OVERRIDE;
30 virtual void ConfirmCompositionText() OVERRIDE;
31 virtual void ClearCompositionText() OVERRIDE;
32 virtual void InsertText(const base::string16& text) OVERRIDE;
33 virtual void InsertChar(base::char16 ch, int flags) OVERRIDE;
34 virtual gfx::NativeWindow GetAttachedWindow() const OVERRIDE;
35 virtual ui::TextInputType GetTextInputType() const OVERRIDE;
36 virtual ui::TextInputMode GetTextInputMode() const OVERRIDE;
37 virtual bool CanComposeInline() const OVERRIDE;
38 virtual gfx::Rect GetCaretBounds() const OVERRIDE;
39 virtual bool GetCompositionCharacterBounds(uint32 index,
40 gfx::Rect* rect) const OVERRIDE;
41 virtual bool HasCompositionText() const OVERRIDE;
42 virtual bool GetTextRange(gfx::Range* range) const OVERRIDE;
43 virtual bool GetCompositionTextRange(gfx::Range* range) const OVERRIDE;
44 virtual bool GetSelectionRange(gfx::Range* range) const OVERRIDE;
45 virtual bool SetSelectionRange(const gfx::Range& range) OVERRIDE;
46 virtual bool DeleteRange(const gfx::Range& range) OVERRIDE;
47 virtual bool GetTextFromRange(const gfx::Range& range,
48 base::string16* text) const OVERRIDE;
49 virtual void OnInputMethodChanged() OVERRIDE;
50 virtual bool ChangeTextDirectionAndLayoutAlignment(
51 base::i18n::TextDirection direction) OVERRIDE;
52 virtual void ExtendSelectionAndDelete(size_t before, size_t after) OVERRIDE;
53 virtual void EnsureCaretInRect(const gfx::Rect& rect) OVERRIDE;
54 virtual void OnCandidateWindowShown() OVERRIDE;
55 virtual void OnCandidateWindowUpdated() OVERRIDE;
56 virtual void OnCandidateWindowHidden() OVERRIDE;
58 virtual bool IsEditingCommandEnabled(int command_id) OVERRIDE;
59 virtual void ExecuteEditingCommand(int command_id) OVERRIDE;
61 private:
62 // Invoked when text is typed. Tries to change the selection appropriately.
63 void OnTextInput(const base::string16& text);
65 // Returns true if the text of the node at |row| starts with |lower_text|.
66 bool TextAtRowMatchesText(int row, const base::string16& lower_text);
68 // Clears |current_text_| and resets |time_of_last_key_|.
69 void ClearText();
71 PrefixDelegate* prefix_delegate_;
73 // Time OnTextInput() was last invoked.
74 base::TimeTicks time_of_last_key_;
76 base::string16 current_text_;
78 DISALLOW_COPY_AND_ASSIGN(PrefixSelector);
81 } // namespace views
83 #endif // UI_VIEWS_CONTROLS_PREFIX_SELECTOR_H_