Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_ImeWin32.cpp
| Show All 28 Lines | |||||
| # include "GHOST_C-api.h" | # include "GHOST_C-api.h" | ||||
| # include "GHOST_WindowWin32.h" | # include "GHOST_WindowWin32.h" | ||||
| # include "utfconv.h" | # include "utfconv.h" | ||||
| GHOST_ImeWin32::GHOST_ImeWin32() | GHOST_ImeWin32::GHOST_ImeWin32() | ||||
| : is_composing_(false), | : is_composing_(false), | ||||
| ime_status_(false), | ime_status_(false), | ||||
| input_language_id_(LANG_USER_DEFAULT), | input_language_id_(LANG_USER_DEFAULT), | ||||
| conversion_modes_(IME_CMODE_ALPHANUMERIC), | |||||
| sentence_mode_(IME_SMODE_NONE), | |||||
| system_caret_(false), | system_caret_(false), | ||||
| caret_rect_(-1, -1, 0, 0), | caret_rect_(-1, -1, 0, 0), | ||||
| is_first(true), | is_first(true), | ||||
| is_enable(true) | is_enable(true) | ||||
| { | { | ||||
| } | } | ||||
| GHOST_ImeWin32::~GHOST_ImeWin32() | GHOST_ImeWin32::~GHOST_ImeWin32() | ||||
| Show All 9 Lines | bool GHOST_ImeWin32::SetInputLanguage() | ||||
| * while composing a text. | * while composing a text. | ||||
| */ | */ | ||||
| HKL keyboard_layout = ::GetKeyboardLayout(0); | HKL keyboard_layout = ::GetKeyboardLayout(0); | ||||
| input_language_id_ = LOWORD(keyboard_layout); | input_language_id_ = LOWORD(keyboard_layout); | ||||
| ime_status_ = ::ImmIsIME(keyboard_layout); | ime_status_ = ::ImmIsIME(keyboard_layout); | ||||
| return ime_status_; | return ime_status_; | ||||
| } | } | ||||
| WORD GHOST_ImeWin32::GetInputLanguage() | |||||
| { | |||||
| return input_language_id_; | |||||
| } | |||||
| void GHOST_ImeWin32::UpdateConversionStatus(HWND window_handle) | |||||
| { | |||||
| HIMC imm_context = ::ImmGetContext(window_handle); | |||||
| if (imm_context) { | |||||
| if (::ImmGetOpenStatus(imm_context)) { | |||||
| ::ImmGetConversionStatus(imm_context, &conversion_modes_, &sentence_mode_); | |||||
| } | |||||
| else { | |||||
| conversion_modes_ = IME_CMODE_ALPHANUMERIC; | |||||
| sentence_mode_ = IME_SMODE_NONE; | |||||
| } | |||||
| ::ImmReleaseContext(window_handle, imm_context); | |||||
| } | |||||
| else { | |||||
| conversion_modes_ = IME_CMODE_ALPHANUMERIC; | |||||
| sentence_mode_ = IME_SMODE_NONE; | |||||
| } | |||||
| } | |||||
brecht: Use camel case like other method names. | |||||
Done Inline Actions
sntulix: > Use camel case like other method names.
| |||||
| bool GHOST_ImeWin32::IsEnglishMode() | |||||
| { | |||||
| return (conversion_modes_ & IME_CMODE_NOCONVERSION) || | |||||
| !(conversion_modes_ & (IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE)); | |||||
| } | |||||
| bool GHOST_ImeWin32::IsImeKeyEvent(char ascii) | |||||
| { | |||||
| if (!(IsEnglishMode())) { | |||||
| /* In Chinese, Japanese, Korena, all alpha keys are processed by IME. */ | |||||
| if ((ascii >= 'A' && ascii <= 'Z') || (ascii >= 'a' && ascii <= 'z')) { | |||||
| return true; | |||||
| } | |||||
| switch (PRIMARYLANGID(GetInputLanguage())) { | |||||
| /* In Japanese, all symbolic characters are also processed by IME. */ | |||||
| case LANG_JAPANESE: { | |||||
| if (ascii >= ' ' && ascii <= '~') { | |||||
| return true; | |||||
| } | |||||
| break; | |||||
| } | |||||
| /* In Chinese, some symbolic characters are also processed by IME. */ | |||||
| case LANG_CHINESE: { | |||||
| if (ascii && strchr("!\"$'(),.:;<>?[\\]^_`", ascii)) { | |||||
| return true; | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| void GHOST_ImeWin32::CreateImeWindow(HWND window_handle) | void GHOST_ImeWin32::CreateImeWindow(HWND window_handle) | ||||
| { | { | ||||
| /** | /** | ||||
| * When a user disables TSF (Text Service Framework) and CUAS (Cicero | * When a user disables TSF (Text Service Framework) and CUAS (Cicero | ||||
| * Unaware Application Support), Chinese IMEs somehow ignore function calls | * Unaware Application Support), Chinese IMEs somehow ignore function calls | ||||
| * to ::ImmSetCandidateWindow(), i.e. they do not move their candidate | * to ::ImmSetCandidateWindow(), i.e. they do not move their candidate | ||||
| * window to the position given as its parameters, and use the position | * window to the position given as its parameters, and use the position | ||||
| * of the current system caret instead, i.e. it uses ::GetCaretPos() to | * of the current system caret instead, i.e. it uses ::GetCaretPos() to | ||||
| ▲ Show 20 Lines • Show All 420 Lines • Show Last 20 Lines | |||||
Use camel case like other method names.