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

Side by Side Diff: views/ime/input_method_win.h

Issue 6688049: New InputMethod api for Views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add InputMethodWin. Created 9 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
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 VIEWS_IME_INPUT_METHOD_WIN_H_
6 #define VIEWS_IME_INPUT_METHOD_WIN_H_
7 #pragma once
8
9 #include <windows.h>
10
11 #include <string>
12
13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h"
15 #include "ui/base/win/ime_input.h"
16 #include "views/focus/focus_manager.h"
17 #include "views/ime/input_method.h"
18 #include "views/ime/input_method_delegate.h"
19 #include "views/ime/text_input_client.h"
20 #include "views/view.h"
21 #include "views/widget/widget.h"
22
23 namespace views {
24
25 // An InputMethod implementation based on Windows IMM32 API.
26 class InputMethodWin : public InputMethod,
27 public FocusChangeListener {
28 public:
29 explicit InputMethodWin(internal::InputMethodDelegate* delegate);
30 virtual ~InputMethodWin();
31
32 // Overridden from InputMethod:
33 virtual void set_delegate(internal::InputMethodDelegate* delegate) OVERRIDE;
34 virtual void Init(Widget* widget) OVERRIDE;
35 virtual void DispatchKeyEvent(const KeyEvent& key) OVERRIDE;
36 virtual void OnTextInputTypeChanged(View* view) OVERRIDE;
37 virtual void OnCaretBoundsChanged(View* view) OVERRIDE;
38 virtual void CancelComposition(View* view) OVERRIDE;
39 virtual std::string GetInputLocale() OVERRIDE;
40 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE;
41 virtual bool IsActive() OVERRIDE;
42
43 // Overridden from FocusChangeListener:
44 virtual void FocusWillChange(View* focused_before, View* focused) OVERRIDE;
45
46 // Message handlers. The native widget is responsible for forwarding following
47 // messages to the input method.
48 void OnSetFocus();
49 void OnKillFocus();
50 void OnInputLangChange(DWORD character_set, HKL input_language_id);
51 LRESULT OnImeSetContext(
52 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled);
53 LRESULT OnImeStartComposition(
54 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled);
55 LRESULT OnImeComposition(
56 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled);
57 LRESULT OnImeEndComposition(
58 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled);
59 // For both WM_CHAR and WM_SYSCHAR
60 LRESULT OnChar(
61 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled);
62 // For both WM_DEADCHAR and WM_SYSDEADCHAR
63 LRESULT OnDeadChar(
64 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled);
65
66 private:
67 HWND hwnd() const { return widget_->GetNativeView(); }
68
69 // Asks the client to confirm current composition text.
70 void ConfirmComposition();
71
72 // Enables or disables the IME according to the current text input type.
73 void UpdateIMEState();
74
75 // Gets the focused text input client. Returns NULL if there is no focused
76 // View or the focused View doesn't support text input.
77 TextInputClient* GetTextInputClient() const;
78
79 // Gets the text input type of the focused text input client.
80 ui::TextInputType GetTextInputType() const;
81
82 // Checks if the given view is focused. Returns true only if the view and
83 // toplevel widget are both focused.
84 bool IsViewFocused(View* view) const;
85
86 // Convenience method to call delegate_->DispatchKeyEventPostIME().
87 void DispatchKeyEventPostIME(const KeyEvent& key) const;
88
89 // Convenience method to call text input client's OnInputMethodChanged().
90 void OnInputMethodChanged() const;
91
92 internal::InputMethodDelegate* delegate_;
93 Widget* widget_;
94 View* focused_view_;
95
96 // Indicates if the toplevel widget is focused or not.
97 bool widget_focused_;
98
99 // Indicates if the current input locale has an IME.
100 bool active_;
101
102 // Name of the current input locale.
103 std::string locale_;
104
105 // The current input text direction.
106 base::i18n::TextDirection direction_;
107
108 // The new text direction and layout alignment requested by the user by
109 // pressing ctrl-shift. It'll be sent to the text input client when the key
110 // is released.
111 base::i18n::TextDirection pending_requested_direction_;
112
113 // Windows IMM32 wrapper.
114 // (See "ui/base/win/ime_input.h" for its details.)
115 ui::ImeInput ime_input_;
116 };
117
118 } // namespace views
119
120 #endif // VIEWS_IME_INPUT_METHOD_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698