annotate EXCLUDE/GLIMM/src/IMM.cpp @ 4745:0aaa54fbd2bc

Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
author dewyatt
date Tue, 06 Jul 2010 02:06:17 -0400
parents bb189d44af16
children
rev   line source
4741
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
1 #include "IMM.hpp"
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
2 #include <stdexcept>
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
3
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
4 IMM::IMM() : my_COM_Initialized(false),
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
5 my_Thread_Manager(0),
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
6 my_Window(0),
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
7 my_Context(0),
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
8 my_HKL(0),
4745
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
9 my_Vertical_Candidates(false),
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
10 my_Enabled(false)
4741
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
11 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
12
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
13 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
14
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
15 IMM::~IMM()
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
16 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
17 Finalize();
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
18 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
19
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
20 void IMM::Initialize(HWND Window)
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
21 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
22 Finalize();
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
23
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
24 my_Window = Window;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
25
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
26 if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
27 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
28 my_COM_Initialized = true;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
29 if (SUCCEEDED(CoCreateInstance(CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, IID_ITfThreadMgr, reinterpret_cast<LPVOID *>(&my_Thread_Manager))))
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
30 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
31 ITfDocumentMgr *Document_Manager = 0;
4745
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
32 if (SUCCEEDED(my_Thread_Manager->AssociateFocus(Window, NULL, &Document_Manager)))
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
33 {
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
34 if (Document_Manager)
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
35 Document_Manager->Release();
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
36 }
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
37 else
4741
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
38 printf("Warning: ITfThreadMgr->AssociateFocus failed\n");
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
39 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
40 else
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
41 printf("Warning: Failed to create ITfThreadMgr instance\n");
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
42 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
43 else
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
44 printf("Warning: Failed to initialize COM\n");
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
45
4745
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
46 ImmDisableTextFrameService((DWORD)-1);
4741
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
47
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
48 my_Context = ImmGetContext(my_Window);
4745
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
49 ImmReleaseContext(my_Window, my_Context);
4741
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
50 if (!my_Context)
4745
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
51 throw std::runtime_error("No context (No IME installed?)");
4741
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
52
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
53 Update_Input_Locale();
4745
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
54 Cancel_Composition();
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
55 Disable();
4741
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
56 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
57
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
58 void IMM::Finalize()
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
59 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
60 if (my_Thread_Manager)
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
61 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
62 my_Thread_Manager->Release();
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
63 my_Thread_Manager = 0;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
64 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
65 if (my_COM_Initialized)
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
66 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
67 CoUninitialize();
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
68 my_COM_Initialized = false;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
69 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
70 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
71
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
72 #define GET_LANG(hkl) LOWORD((hkl))
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
73 #define GET_PRIMLANG(hkl) ((WORD)PRIMARYLANGID(GET_LANG((hkl))))
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
74 #define GET_SUBLANG(hkl) SUBLANGID(GET_LANG((hkl)))
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
75
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
76 void IMM::Update_Input_Locale()
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
77 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
78 static HKL Previous_HKL = 0;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
79 my_HKL = GetKeyboardLayout(0);
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
80 if (Previous_HKL == my_HKL)
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
81 return;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
82
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
83 Previous_HKL = my_HKL;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
84 my_Vertical_Candidates = false;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
85 switch (GET_PRIMLANG(my_HKL))
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
86 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
87 case LANG_CHINESE:
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
88 my_Vertical_Candidates = true;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
89 switch (GET_SUBLANG(my_HKL))
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
90 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
91 case SUBLANG_CHINESE_SIMPLIFIED:
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
92 my_Vertical_Candidates = false;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
93 break;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
94 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
95 break;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
96 case LANG_JAPANESE:
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
97 my_Vertical_Candidates = true;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
98 break;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
99 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
100 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
101
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
102 LRESULT IMM::Handle_Message(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam, bool &Ate)
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
103 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
104 Ate = false;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
105 switch (Message)
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
106 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
107 case WM_INPUTLANGCHANGE:
4745
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
108 Input_Language_Changed();
4741
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
109 break;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
110 case WM_IME_SETCONTEXT:
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
111 lParam = 0;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
112 break;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
113 case WM_IME_STARTCOMPOSITION:
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
114 Ate = true;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
115 break;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
116 case WM_IME_COMPOSITION:
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
117 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
118 Ate = true;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
119 HIMC Context = ImmGetContext(Window);
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
120 if (!Context)
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
121 break;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
122
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
123 if (lParam & GCS_RESULTSTR)
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
124 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
125 LONG Length = ImmGetCompositionStringW(Context, GCS_RESULTSTR, 0, 0);
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
126 std::wstring Composition(Length / sizeof(wchar_t), 0);
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
127 Length = ImmGetCompositionStringW(Context, GCS_RESULTSTR, &Composition[0], Composition.size() * sizeof(Composition[0]));
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
128 printf("GCS_RESULTSTR: ");
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
129 for (LONG i = 0; i < Length / sizeof(wchar_t); ++i)
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
130 printf("U+%04X ", Composition[i]);
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
131
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
132 printf("\n");
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
133 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
134 if (lParam & GCS_COMPSTR)
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
135 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
136 LONG Length = ImmGetCompositionStringW(Context, GCS_COMPSTR, 0, 0);
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
137 std::wstring Composition(Length / sizeof(wchar_t), 0);
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
138 Length = ImmGetCompositionStringW(Context, GCS_COMPSTR, &Composition[0], Composition.size() * sizeof(Composition[0]));
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
139 printf("GCS_COMPSTR: ");
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
140 for (LONG i = 0; i < Length / sizeof(wchar_t); ++i)
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
141 printf("U+%04X ", Composition[i]);
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
142
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
143 printf("\n");
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
144 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
145 ImmReleaseContext(Window, Context);
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
146 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
147 break;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
148 case WM_IME_ENDCOMPOSITION:
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
149 break;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
150 case WM_IME_NOTIFY:
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
151 switch (wParam)
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
152 {
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
153 case IMN_SETCONVERSIONMODE:
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
154
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
155 break;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
156 case IMN_SETOPENSTATUS:
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
157 Update_Input_Locale();
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
158 break;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
159 case IMN_OPENCANDIDATE:
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
160 case IMN_CHANGECANDIDATE:
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
161 Ate = true;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
162 break;
4745
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
163 case IMN_CLOSECANDIDATE:
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
164 Ate = true;
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
165 break;
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
166 default:
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
167 Ate = true;
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
168 break;
4741
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
169 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
170 break;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
171 }
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
172 return 0;
bb189d44af16 Added GLIMM (using IMM instead of TSF)
dewyatt
parents:
diff changeset
173 }
4745
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
174
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
175 void IMM::Enable()
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
176 {
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
177 ImmAssociateContext(my_Window, my_Context);
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
178 Update_Input_Locale();
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
179 my_Enabled = true;
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
180 printf("* Enabled\n");
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
181 }
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
182
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
183 void IMM::Disable()
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
184 {
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
185 ImmAssociateContext(my_Window, 0);
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
186 my_Enabled = false;
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
187 printf("* Disabled\n");
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
188 }
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
189
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
190 bool IMM::Is_Enabled()
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
191 {
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
192 return my_Enabled;
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
193 }
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
194
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
195 void IMM::Toggle()
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
196 {
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
197 if (my_Enabled)
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
198 Disable();
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
199 else
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
200 Enable();
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
201 }
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
202
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
203 void IMM::Focus_Gained()
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
204 {
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
205 if (my_Enabled)
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
206 Enable();
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
207 }
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
208
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
209 void IMM::Focus_Lost()
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
210 {
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
211 bool Enabled = my_Enabled;
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
212 Cancel_Composition();
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
213 Disable();
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
214 my_Enabled = Enabled;
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
215 }
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
216
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
217 void IMM::Cancel_Composition()
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
218 {
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
219 HIMC hIMC = ImmGetContext(my_Window);
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
220 if (!hIMC)
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
221 return;
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
222
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
223 ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
224 ImmNotifyIME(hIMC, NI_CLOSECANDIDATE, 0, 0);
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
225 ImmReleaseContext(my_Window, hIMC);
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
226 }
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
227
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
228 void IMM::Input_Language_Changed()
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
229 {
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
230 Update_Input_Locale();
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
231 HWND hwndImeDef = ImmGetDefaultIMEWnd(my_Window);
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
232 if (hwndImeDef)
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
233 {
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
234 SendMessageA(hwndImeDef, WM_IME_CONTROL, IMC_OPENSTATUSWINDOW, 0);
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
235 SendMessageA(hwndImeDef, WM_IME_CONTROL, IMC_CLOSESTATUSWINDOW, 0);
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
236 }
0aaa54fbd2bc Many changes, preparing to pull/merge main repo to get SDL_GetKeyboardFocus.
dewyatt
parents: 4741
diff changeset
237 }