A simple way to support IME

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
zhaojs
Posts: 4
Joined: Sun Jun 15, 2008 2:48 am

A simple way to support IME

Post by zhaojs »

A simple way to support IME, modify CIrrDeviceWin32.cpp, in WinProc function, add the following code:
case WM_IME_CHAR:
dev = getDeviceFromHWnd (hWnd);
If (dev) (
Event.EventType = irr:: EET_KEY_INPUT_EVENT;
Event.KeyInput.PressedDown = true;
Event.KeyInput.Key = irr:: KEY_OEM_CLEAR;
Event.KeyInput.Shift = 0;
Event.KeyInput.Control = 0;
char bits [2] = { (char) ((wParam & 0xff00)>> 8), (char) (wParam & 0xff) };
if (bits [0] == 0) event.KeyInput.Char = (irr:: u16) wParam;
else MultiByteToWideChar (CP_OEMCP, MB_PRECOMPOSED, bits, 2, & event.KeyInput.Char, 1);
dev-> postEventFromUser (event);
)
break;

Full-screen mode, can not show IME panel, but we can do a fake full-screen, style = WS_POPUP, full screen size, not title bar...

Welcome to test vector font support, upgrade 0.3 version:
(support FreeType and Windows APIs, #define _IRR_USE_FREETYPE_)
IGUIFontVector* vfont = (IGUIFontVector*)env->getFont("c:/Windows/fonts/msyh.ttf"");
env->addEditBox(L"请输入文字", rect<s32>(300,400,550,430))->setOverrideFont(vfont);

Change font size:
IGUIFontVector* font=(IGUIFontVector*)TextBox1->getOverrideFont();
font=font->getNewSizeFont(newWidth,newHeight);
if (font){ TextBox1->setOverrideFont(font); }

Download URL:
http://cwowaddon.googlegroups.com/web/I ... eZD07aX2iN
Last edited by zhaojs on Wed Jun 25, 2008 4:02 pm, edited 3 times in total.
zhaojs
Posts: 4
Joined: Sun Jun 15, 2008 2:48 am

Post by zhaojs »

Change font size:
IGUIFontVector* font=(IGUIFontVector*)TextBox1->getOverrideFont();
font=font->getNewSizeFont(newWidth,newHeight);
if (font){ TextBox1->setOverrideFont(font); }
lester
Posts: 86
Joined: Mon Jan 29, 2007 3:33 pm

Post by lester »

is it windows only?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

What would lead you to believe that it might not be?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
zhaojs
Posts: 4
Joined: Sun Jun 15, 2008 2:48 am

Post by zhaojs »

lester wrote:is it windows only?
I only tested on Windows, don't use Windows API, should be easy to Linux.
zhaojs
Posts: 4
Joined: Sun Jun 15, 2008 2:48 am

Post by zhaojs »

rogerborg wrote:What would lead you to believe that it might not be?
Are you saying that "if (font){ TextBox1->setOverrideFont(font); }"?

This is just want faster. Sometimes don't need to create a new size of the font, you can use the already existing.
tinhtoitrangtay
Posts: 70
Joined: Tue Oct 28, 2008 12:59 pm

Post by tinhtoitrangtay »

zhaojs wrote:Change font size:
IGUIFontVector* font=(IGUIFontVector*)TextBox1->getOverrideFont();
font=font->getNewSizeFont(newWidth,newHeight);
if (font){ TextBox1->setOverrideFont(font); }
Change Font Size don't work. I will crash when i use it. font=font->getNewSizeFont(32,32); It is crash
Post Reply