Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: ui/views/ime/input_method_gtk.h

Issue 9728002: Removing deprecated GTK-Views code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/focus/accelerator_handler_gtk_unittest.cc ('k') | ui/views/ime/input_method_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_VIEWS_IME_INPUT_METHOD_GTK_H_
6 #define UI_VIEWS_IME_INPUT_METHOD_GTK_H_
7 #pragma once
8
9 #include <gtk/gtk.h>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "ui/base/gtk/gtk_signal.h"
14 #include "ui/base/ime/composition_text.h"
15 #include "ui/base/ime/text_input_client.h"
16 #include "ui/views/ime/input_method_base.h"
17 #include "ui/views/view.h"
18
19 namespace views {
20
21 // An InputMethod implementation based on GtkIMContext. Most code are copied
22 // from chrome/browser/renderer_host/gtk_im_context_wrapper.*
23 // It's intended for testing purpose.
24 class InputMethodGtk : public InputMethodBase {
25 public:
26 explicit InputMethodGtk(internal::InputMethodDelegate* delegate);
27 virtual ~InputMethodGtk();
28
29 // Overridden from InputMethod:
30 virtual void Init(Widget* widget) OVERRIDE;
31 virtual void OnFocus() OVERRIDE;
32 virtual void OnBlur() OVERRIDE;
33 virtual void DispatchKeyEvent(const KeyEvent& key) OVERRIDE;
34 virtual void OnTextInputTypeChanged(View* view) OVERRIDE;
35 virtual void OnCaretBoundsChanged(View* view) OVERRIDE;
36 virtual void CancelComposition(View* view) OVERRIDE;
37 virtual std::string GetInputLocale() OVERRIDE;
38 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE;
39 virtual bool IsActive() OVERRIDE;
40
41 private:
42 // Overridden from InputMethodBase:
43 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE;
44 virtual void OnDidChangeFocus(View* focused_before, View* focused) OVERRIDE;
45
46 // Asks the client to confirm current composition text.
47 void ConfirmCompositionText();
48
49 // Resets |context_| and |context_simple_|.
50 void ResetContext();
51
52 // Checks the availability of focused text input client and update focus state
53 // of |context_| and |context_simple_| accordingly.
54 void UpdateContextFocusState();
55
56 // Processes a key event that was already filtered by the input method.
57 // A VKEY_PROCESSKEY may be dispatched to the focused View.
58 void ProcessFilteredKeyPressEvent(const KeyEvent& key);
59
60 // Processes a key event that was not filtered by the input method.
61 void ProcessUnfilteredKeyPressEvent(const KeyEvent& key);
62
63 // Sends input method result caused by the given key event to the focused text
64 // input client.
65 void ProcessInputMethodResult(const KeyEvent& key, bool filtered);
66
67 // Checks if the pending input method result needs inserting into the focused
68 // text input client as a single character.
69 bool NeedInsertChar() const;
70
71 // Checks if there is pending input method result.
72 bool HasInputMethodResult() const;
73
74 // Fabricates a key event with VKEY_PROCESSKEY key code and dispatches it to
75 // the focused View.
76 void SendFakeProcessKeyEvent(bool pressed) const;
77
78 // Synthesize a GdkEventKey based on given key event. The returned GdkEventKey
79 // must be freed with gdk_event_free().
80 GdkEvent* SynthesizeGdkEventKey(const KeyEvent& key) const;
81
82 // Event handlers:
83 CHROMEG_CALLBACK_1(InputMethodGtk, void, OnCommit, GtkIMContext*, gchar*);
84 CHROMEG_CALLBACK_0(InputMethodGtk, void, OnPreeditStart, GtkIMContext*);
85 CHROMEG_CALLBACK_0(InputMethodGtk, void, OnPreeditChanged, GtkIMContext*);
86 CHROMEG_CALLBACK_0(InputMethodGtk, void, OnPreeditEnd, GtkIMContext*);
87
88 CHROMEGTK_CALLBACK_0(InputMethodGtk, void, OnWidgetRealize);
89 CHROMEGTK_CALLBACK_0(InputMethodGtk, void, OnWidgetUnrealize);
90
91 GtkIMContext* context_;
92 GtkIMContext* context_simple_;
93
94 ui::CompositionText composition_;
95
96 string16 result_text_;
97
98 // Signal ids for corresponding gtk signals.
99 gulong widget_realize_id_;
100 gulong widget_unrealize_id_;
101
102 // Indicates if |context_| and |context_simple_| are focused or not.
103 bool context_focused_;
104
105 // Indicates if we are handling a key event.
106 bool handling_key_event_;
107
108 // Indicates if there is an ongoing composition text.
109 bool composing_text_;
110
111 // Indicates if the composition text is changed or deleted.
112 bool composition_changed_;
113
114 // If it's true then all input method result received before the next key
115 // event will be discarded.
116 bool suppress_next_result_;
117
118 DISALLOW_COPY_AND_ASSIGN(InputMethodGtk);
119 };
120
121 } // namespace views
122
123 #endif // UI_VIEWS_IME_INPUT_METHOD_GTK_H_
OLDNEW
« no previous file with comments | « ui/views/focus/accelerator_handler_gtk_unittest.cc ('k') | ui/views/ime/input_method_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698