Mercurial > sdl-ios-xcode
annotate EXCLUDE/GLTSF/src/TSF.cpp @ 4734:0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
Removed a lot of TSF code because part of it was wrong and part was too complicated.
Added Clear method to clear the window.
IME input should work in both windowed mode and fullscreen mode with these changes.
I have tested on Windows XP SP3 and Windows 7 Ultimate in VirtualBox.
When you type a character (with an IME or not), the console will show the code point as U+XXXX.
You use Left Alt+Shift (or whatever you have it set to) to switch input languages as usual.
Hit ESC to exit (or close the window in windowed mode).
The program will pause before exiting so you can review the console output (press a key to exit).
author | dewyatt |
---|---|
date | Wed, 09 Jun 2010 00:03:54 -0400 |
parents | e1307be6cb9e |
children | f51a9f01b508 |
rev | line source |
---|---|
4731 | 1 #include "TSF.hpp" |
4732 | 2 #include <stdexcept> |
3 | |
4734
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
4 bool TSF::COM_Initialized = false; |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
5 CComPtr<ITfThreadMgr> TSF::Thread_Manager; |
4732 | 6 |
7 void TSF::Initialize() | |
8 { | |
4734
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
9 if (!COM_Initialized) |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
10 { |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
11 HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
12 if (S_OK != hr && S_FALSE != hr) |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
13 throw std::runtime_error("Failed to initialize COM"); |
4732 | 14 |
4734
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
15 COM_Initialized = true; |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
16 } |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
17 if (!Thread_Manager) |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
18 { |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
19 if (FAILED(CoCreateInstance(CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, IID_ITfThreadMgr, reinterpret_cast<void **>(&Thread_Manager)))) |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
20 throw std::runtime_error("Failed to create ITfThreadMgr instance"); |
4732 | 21 |
4734
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
22 TfClientId ClientId; |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
23 if (FAILED(Thread_Manager->Activate(&ClientId))) |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
24 throw std::runtime_error("ITfThreadMgr::Activate failed"); |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
25 } |
4732 | 26 } |
27 | |
28 void TSF::Finalize() | |
29 { | |
4734
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
30 if (Thread_Manager) |
4732 | 31 { |
4734
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
32 Thread_Manager->Deactivate(); |
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
33 Thread_Manager = NULL; |
4732 | 34 } |
4734
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
35 if (COM_Initialized) |
4732 | 36 { |
37 CoUninitialize(); | |
4734
0c7c67d4e6ee
Added On_Char method to Window_Listener for WM_CHAR messages.
dewyatt
parents:
4732
diff
changeset
|
38 COM_Initialized = false; |
4732 | 39 } |
40 } |