-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathIme.cpp
More file actions
93 lines (72 loc) · 1.62 KB
/
Copy pathIme.cpp
File metadata and controls
93 lines (72 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright © 2014 CCP ehf.
#include "StdAfx.h"
#include "Ime.h"
#include "KeyboardLayoutMac.h"
#if __APPLE__
Ime::Ime( IRoot* lockobj )
{
}
Ime::~Ime()
{
}
std::wstring Ime::GetKeyboardLayout()
{
return GetKeyboardLayoutMac();
}
#elif _WIN32
Ime::Ime( IRoot* lockobj )
{
ImeWrapper::InitializeImm();
}
Ime::~Ime()
{
ImeWrapper::UninitializeImm();
}
void Ime::SetHWND( uintptr_t handle )
{
auto window = reinterpret_cast<HWND>( handle );
if( window != m_window )
{
if( m_window )
{
ImeWrapper::ImmReleaseContext( m_window, m_imc );
}
m_window = window;
m_imc = ImeWrapper::ImmGetContext( m_window );
}
}
void Ime::AssociateContext( bool show )
{
ImeWrapper::ImmAssociateContext( m_window, show ? m_imc : nullptr );
}
long Ime::GetCursorPos()
{
return ImeWrapper::ImmGetCompositionStringW( m_imc, GCS_CURSORPOS, nullptr, 0 );
}
std::wstring Ime::GetCompositionString( DWORD mask )
{
wchar_t str[256] = {};
long size = ImeWrapper::ImmGetCompositionStringW( m_imc, mask, str, sizeof( str ) );
return std::wstring( std::begin( str ), std::begin( str ) + size / 2 );
}
size_t Ime::GetKeyboardLayout()
{
return reinterpret_cast<size_t>( ::GetKeyboardLayout( GetCurrentThreadId() ) );
}
bool Ime::NotifyIME( DWORD dwAction, DWORD dwIndex, DWORD dwValue )
{
return ImeWrapper::ImmNotifyIME( m_imc, dwAction, dwIndex, dwValue );
}
bool Ime::SimulateHotKey( DWORD hotkeyID )
{
return ImeWrapper::ImmSimulateHotKey( m_window, hotkeyID );
}
bool Ime::GetOpenStatus()
{
return ImeWrapper::ImmGetOpenStatus( m_imc );
}
bool Ime::SetOpenStatus( bool show )
{
return ImeWrapper::ImmSetOpenStatus( m_imc, show );
}
#endif