How to deal input with EditBox or MultiLineEditBox that indi
Posted: Thu Oct 06, 2005 06:32
I try to let EditBox or MultiEditBox support to indicate Unicode character. But I don't handle MS-IME Messages
like WM_IME_COMPOSITION,WM_IME_ENDCOMPOSITION etc.
If someone interests it , you can do it like directx9.0c IME-EditBox, it's very cool.
Currently It's working to to indicate Unicode character,but Some Source code and data files have to be modified.
For Chinese character example.
1. Copy Tradition Chinese Font(I use 細明體(mingliu.ttc)) for ./datafiles/fonts/
2.Construct mingliu.font in ./datafiles/fonts/
and define its GlyphRange;
because I use Tradition Chinese Sub CodePoint (19968~40868 )
its' content:
<?xml version="1.0" ?>
<Font Name="mingliu" Filename="../datafiles/fonts/mingliu.ttc" Type="Dynamic" Size="12" NativeHorzRes="800" NativeVertRes="600" AutoScaled="true">
<GlyphRange StartCodepoint="19968" EndCodepoint="40868" />
</Font>
3. Add mingliu.font Setting into ./datafiles/fonts/schemes/TaharezLook.scheme
<?xml version="1.0" ?>
<GUIScheme Name="TaharezLook">
<Imageset Name="TaharezLook" Filename="../datafiles/imagesets/TaharezLook.imageset" />
<Font Name="mingliu" Filename="../datafiles/fonts/mingliu.font" />
<WindowSet Filename="CEGUITaharezLook" />
</GUIScheme>
4.Modified Sample_Demo7.cpp::initialiseSample()
System::getSingleton().setDefaultFont((CEGUI::utf8*)"mingliu" );
CEGUI::Font* font = CEGUI::FontManager::getSingleton().getFont((CEGUI::utf8*)"mingliu" );
font->setAutoScalingEnabled(true);
font->setNativeResolution(Size(800, 600));
font->defineFontGlyphs(font->getAvailableGlyphs());
5.Modified Win32AppHelper.cpp
(a)add this include and inline funciotn
#include <ctype.h>
inline int __cdecl isLeadByte(int _C)
{return ((unsigned char)(_C) & 0x80); }
(b)Modified wndProc()::case WM_CHAR to deal with Multi-Bye into Unicode then injectChar() is working well;
case WM_CHAR: {
static char MultiByte[2]={0};
static bool isHaveMultiByte = false;
if (isHaveMultiByte) {
isHaveMultiByte = false;
MultiByte[1] = (unsigned char) wParam;
int iLengthUnicode = 0;
wchar_t szUnicode;
MultiByteToWideChar(CP_ACP, 0, (char*)MultiByte, 2, &szUnicode, 1);
CEGUI::System::getSingleton().injectChar((CEGUI::utf32)szUnicode);
break;
}
else
{
if(isLeadByte(wParam))
{
isHaveMultiByte = true;
MultiByte[0] = (unsigned char)wParam;
}else
{
CEGUI::System::getSingleton().injectChar((CEGUI::utf32)wParam);
break;
}
}
}
[size=large]Screen Shot:[/size]
[img align=left]http://webhd.yam.com/jingjie//cegui1.JPG[/img]
like WM_IME_COMPOSITION,WM_IME_ENDCOMPOSITION etc.
If someone interests it , you can do it like directx9.0c IME-EditBox, it's very cool.
Currently It's working to to indicate Unicode character,but Some Source code and data files have to be modified.
For Chinese character example.
1. Copy Tradition Chinese Font(I use 細明體(mingliu.ttc)) for ./datafiles/fonts/
2.Construct mingliu.font in ./datafiles/fonts/
and define its GlyphRange;
because I use Tradition Chinese Sub CodePoint (19968~40868 )
its' content:
<?xml version="1.0" ?>
<Font Name="mingliu" Filename="../datafiles/fonts/mingliu.ttc" Type="Dynamic" Size="12" NativeHorzRes="800" NativeVertRes="600" AutoScaled="true">
<GlyphRange StartCodepoint="19968" EndCodepoint="40868" />
</Font>
3. Add mingliu.font Setting into ./datafiles/fonts/schemes/TaharezLook.scheme
<?xml version="1.0" ?>
<GUIScheme Name="TaharezLook">
<Imageset Name="TaharezLook" Filename="../datafiles/imagesets/TaharezLook.imageset" />
<Font Name="mingliu" Filename="../datafiles/fonts/mingliu.font" />
<WindowSet Filename="CEGUITaharezLook" />
</GUIScheme>
4.Modified Sample_Demo7.cpp::initialiseSample()
System::getSingleton().setDefaultFont((CEGUI::utf8*)"mingliu" );
CEGUI::Font* font = CEGUI::FontManager::getSingleton().getFont((CEGUI::utf8*)"mingliu" );
font->setAutoScalingEnabled(true);
font->setNativeResolution(Size(800, 600));
font->defineFontGlyphs(font->getAvailableGlyphs());
5.Modified Win32AppHelper.cpp
(a)add this include and inline funciotn
#include <ctype.h>
inline int __cdecl isLeadByte(int _C)
{return ((unsigned char)(_C) & 0x80); }
(b)Modified wndProc()::case WM_CHAR to deal with Multi-Bye into Unicode then injectChar() is working well;
case WM_CHAR: {
static char MultiByte[2]={0};
static bool isHaveMultiByte = false;
if (isHaveMultiByte) {
isHaveMultiByte = false;
MultiByte[1] = (unsigned char) wParam;
int iLengthUnicode = 0;
wchar_t szUnicode;
MultiByteToWideChar(CP_ACP, 0, (char*)MultiByte, 2, &szUnicode, 1);
CEGUI::System::getSingleton().injectChar((CEGUI::utf32)szUnicode);
break;
}
else
{
if(isLeadByte(wParam))
{
isHaveMultiByte = true;
MultiByte[0] = (unsigned char)wParam;
}else
{
CEGUI::System::getSingleton().injectChar((CEGUI::utf32)wParam);
break;
}
}
}
[size=large]Screen Shot:[/size]
[img align=left]http://webhd.yam.com/jingjie//cegui1.JPG[/img]