| 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 #include "ui/views/ime/input_method_win.h" | 5 #include "ui/views/ime/input_method_win.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "ui/base/events/event.h" | 10 #include "ui/base/events/event.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace views { | 22 namespace views { |
| 23 | 23 |
| 24 InputMethodWin::InputMethodWin(internal::InputMethodDelegate* delegate, | 24 InputMethodWin::InputMethodWin(internal::InputMethodDelegate* delegate, |
| 25 HWND hwnd, | 25 HWND hwnd, |
| 26 ui::InputMethod* host) | 26 ui::InputMethod* host) |
| 27 : hwnd_(hwnd), | 27 : hwnd_(hwnd), |
| 28 active_(false), | 28 active_(false), |
| 29 direction_(base::i18n::UNKNOWN_DIRECTION), | 29 direction_(base::i18n::UNKNOWN_DIRECTION), |
| 30 pending_requested_direction_(base::i18n::UNKNOWN_DIRECTION), | 30 pending_requested_direction_(base::i18n::UNKNOWN_DIRECTION), |
| 31 host_(host) { | 31 host_(host) { |
| 32 set_delegate(delegate); | 32 SetDelegate(delegate); |
| 33 } | 33 } |
| 34 | 34 |
| 35 InputMethodWin::~InputMethodWin() { | 35 InputMethodWin::~InputMethodWin() { |
| 36 if (widget()) | 36 if (widget()) |
| 37 ime_input_.DisableIME(hwnd_); | 37 ime_input_.DisableIME(hwnd_); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void InputMethodWin::Init(Widget* widget) { | 40 void InputMethodWin::Init(Widget* widget) { |
| 41 InputMethodBase::Init(widget); |
| 42 |
| 41 // Gets the initial input locale and text direction information. | 43 // Gets the initial input locale and text direction information. |
| 42 OnInputLangChange(0, 0); | 44 OnInputLangChange(0, 0); |
| 43 | |
| 44 InputMethodBase::Init(widget); | |
| 45 } | 45 } |
| 46 | 46 |
| 47 void InputMethodWin::OnFocus() { | 47 void InputMethodWin::OnFocus() { |
| 48 DCHECK(!widget_focused()); | |
| 49 InputMethodBase::OnFocus(); | |
| 50 UpdateIMEState(); | 48 UpdateIMEState(); |
| 51 } | 49 } |
| 52 | 50 |
| 53 void InputMethodWin::OnBlur() { | 51 void InputMethodWin::OnBlur() { |
| 54 DCHECK(widget_focused()); | |
| 55 ConfirmCompositionText(); | 52 ConfirmCompositionText(); |
| 56 InputMethodBase::OnBlur(); | |
| 57 } | 53 } |
| 58 | 54 |
| 59 void InputMethodWin::DispatchKeyEvent(const ui::KeyEvent& key) { | 55 void InputMethodWin::DispatchKeyEvent(const ui::KeyEvent& key) { |
| 60 // Handles ctrl-shift key to change text direction and layout alignment. | 56 // Handles ctrl-shift key to change text direction and layout alignment. |
| 61 if (ui::ImeInput::IsRTLKeyboardLayoutInstalled() && !IsTextInputTypeNone()) { | 57 if (ui::ImeInput::IsRTLKeyboardLayoutInstalled() && !IsTextInputTypeNone()) { |
| 62 ui::KeyboardCode code = key.key_code(); | 58 ui::KeyboardCode code = key.key_code(); |
| 63 if (key.type() == ui::ET_KEY_PRESSED) { | 59 if (key.type() == ui::ET_KEY_PRESSED) { |
| 64 if (code == ui::VKEY_SHIFT) { | 60 if (code == ui::VKEY_SHIFT) { |
| 65 base::i18n::TextDirection dir; | 61 base::i18n::TextDirection dir; |
| 66 if (ui::ImeInput::IsCtrlShiftPressed(&dir)) | 62 if (ui::ImeInput::IsCtrlShiftPressed(&dir)) |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 case ui::TEXT_INPUT_TYPE_PASSWORD: | 433 case ui::TEXT_INPUT_TYPE_PASSWORD: |
| 438 ime_input_.DisableIME(hwnd_); | 434 ime_input_.DisableIME(hwnd_); |
| 439 break; | 435 break; |
| 440 default: | 436 default: |
| 441 ime_input_.EnableIME(hwnd_); | 437 ime_input_.EnableIME(hwnd_); |
| 442 break; | 438 break; |
| 443 } | 439 } |
| 444 } | 440 } |
| 445 | 441 |
| 446 } // namespace views | 442 } // namespace views |
| OLD | NEW |