Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Libraries and TheIDE: i18n, Unicode and Internationalization » Japanese IME test code
Re: Japanese IME test code [message #15812 is a reply to message #15811] Thu, 08 May 2008 10:04 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
According to these:
http://www.mozilla.org/projects/intl/input-method-spec.html

On-the-spot means:
The composed text is rendered inside the text window by the application, by maintaining a special editing area "between" the text before the insertion point and the text after the insertion point. The composed text looks like text part of the document, however, different stylistic attributes are applied to the text into indicate that it is part of the input method composition string. Different parts of the input method composing string will have different styles applied to them, which indicates that they are in different stages of editing. Once the composition text is finalized by the user, it merges into the original document and is indistinguishable from the surrounding text. The on-the-spot style is also know as inline input on some platforms.

Re: Japanese IME test code [message #15827 is a reply to message #15812] Fri, 09 May 2008 02:16 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
Hi Mirek,
Sorry about virtual functions. Maybe we can remove some.
Please also consider the X11 implementations

Here my codes for X11:
at CtrlCore.cpp
#ifdef PLATFORM_X11
	static int ImePreEditStartCB(XIC xic, XPointer clientData, XPointer callData);
	static void ImePreEditDoneCB(XIC xic, XPointer clientData, XPointer callData);
	static void ImePreEditDrawCB(XIC xic, XPointer clientData, XIMPreeditDrawCallbackStruct *callData);
	static void ImePreEditCaretCB(XIC xic, XPointer clientData, XIMPreeditCaretCallbackStruct *callData);
	#endif


at Ctrl.cpp
#ifdef PLATFORM_X11
int Ctrl::ImePreEditStartCB(XIC xic, XPointer clientData, XPointer callData)
{
	Ctrl *ctrl = (Ctrl*)clientData;
	
	Ptr<Ctrl> pfocusCtrl = ctrl->GetFocusCtrl();
	if(!pfocusCtrl)
		return -1;
	
	pfocusCtrl->ImePreEditStart();
	return -1;
}

void Ctrl::ImePreEditDoneCB(XIC xic, XPointer clientData, XPointer callData)
{
	Ctrl *ctrl = (Ctrl*)clientData;
	
	Ptr<Ctrl> pfocusCtrl = ctrl->GetFocusCtrl();
	if(!pfocusCtrl)
		return;
	pfocusCtrl->ImePreEditEnd();
}

void Ctrl::ImePreEditDrawCB(XIC xic, XPointer clientData, XIMPreeditDrawCallbackStruct *callData)
{
	Ctrl *ctrl = (Ctrl*)clientData;
	Ptr<Ctrl> pfocusCtrl = ctrl->GetFocusCtrl();
		
	if(callData)
	{
		int caretPos = callData->caret;
		int changeFirst = callData->chg_first;
		int changeLength = callData->chg_length;
		
		if(callData->text)
		{
			int length = callData->text->length;

			if(!callData->text->encoding_is_wchar)
			{
				String newString = callData->text->string.multi_byte;
				WString newWString = ToUnicode(newString, newString.GetLength(), CHARSET_UTF8);
				
				pfocusCtrl->ImePreEditSetText(newWString);				
			}
		}
	}
}

void Ctrl::ImePreEditCaretCB(XIC xic, XPointer clientData, XIMPreeditCaretCallbackStruct *callData)
{
	Ctrl *ctrl = (Ctrl*)clientData;
	Ptr<Ctrl> pfocusCtrl = ctrl->GetFocusCtrl();
	
	if(!pfocusCtrl)
		return;
	
	pfocusCtrl->imePreEditCursor = callData->position;
	pfocusCtrl->ImePreEditSyncCaret();
	pfocusCtrl->SyncCaret(); 
}
#endif


At X11Wnd.cpp
/*cw.xic = xim ? XCreateIC(xim,
	                         XNInputStyle, XIMPreeditNothing|XIMStatusNothing,
	                         XNClientWindow, w,
	                         XNFocusWindow, w,
	                         NULL)
	             : NULL;*/
//Added for CJK 
	//Using on the spot way
	XIMCallback     PreEditStartCallback;
	XIMCallback     PreEditDoneCallback;
	XIMCallback     PreEditDrawCallback;
	XIMCallback     PreEditCaretCallback;
	
	PreEditStartCallback.client_data = (XPointer)this;
	PreEditStartCallback.callback = (XIMProc)ImePreEditStartCB;
	
	PreEditDoneCallback.client_data = (XPointer)this;
	PreEditDoneCallback.callback = (XIMProc)ImePreEditDoneCB;
	
	PreEditDrawCallback.client_data = (XPointer)this;
	PreEditDrawCallback.callback = (XIMProc)ImePreEditDrawCB;
	
	PreEditCaretCallback.client_data = (XPointer)this;
	PreEditCaretCallback.callback = (XIMProc)ImePreEditCaretCB;
	
	XVaNestedList preEditAttribute;
	XPoint imePosition;
	XFontSet fs;
	XIMStyle overSpot=XIMPreeditPosition | XIMStatusNothing;
	XIMStyle onSpot=XIMPreeditCallbacks | XIMStatusNothing;
	XIMStyle uppStyle = onSpot;
	char                    **missing_list;
    int                     missing_count;
    char                    *def_string;
	fs = XCreateFontSet(Xdisplay, "-*-*-*-R-Normal--14-130-75-75-*-*", &missing_list,
                               &missing_count, &def_string);
                               
	imePosition.x=imePosition.y=0;
	preEditAttribute = XVaCreateNestedList(NULL,
                                XNSpotLocation, &imePosition,
                                XNFontSet, fs,
                                XNPreeditStartCallback, &PreEditStartCallback,
                        		XNPreeditDoneCallback, &PreEditDoneCallback,
		                        XNPreeditDrawCallback, &PreEditDrawCallback,
		                        XNPreeditCaretCallback, &PreEditCaretCallback,
                                NULL);
                                            
	cw.xic = xim ? XCreateIC(xim,
	                         XNInputStyle, uppStyle,
	                         XNClientWindow, w,
	                         XNFocusWindow, w,
	                         XNPreeditAttributes, preEditAttribute,
	                         NULL)
	             : NULL;
	XFree(preEditAttribute);
	//End of Added for CJK
Re: Japanese IME test code [message #15887 is a reply to message #15827] Wed, 14 May 2008 09:13 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, please.

Quote:


BTW, for now I would like to add the mode from previous posts, where we were ok with just

virtual Font GetIMEFont();
virtual Point GetIMEPoint();

The only thing I am missing there is change so that GetIMEPoint returns view-relative Point, not top window relative.



Can we do just that before expanding to other areas? Smile

I mean, can you fix GetIMEPoint from a couple of posts before, so that I can use that code finally in uppsrc for Win32 (at least, for now...).

Mirek
Re: Japanese IME test code [message #15903 is a reply to message #15887] Thu, 15 May 2008 11:57 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
I tried the GetCaret.

But, still confused with view-relative point, please tell me a little about this.

Does the GetCaret's coordinate already in view-relative point?

index.php?t=getfile&id=1205&private=0

Re: Japanese IME test code [message #15908 is a reply to message #15903] Thu, 15 May 2008 14:43 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Hi!

I tried to give your code a spin, but I can't seem to compile it because I'm missing types like CANDIDATEFORM and constants like CFS_CANDIDATEPOS (and a lot more). Are you using some extra includes?

Anyway if I can get this to compile it looks promising. Some adjustments of positioning still needed if I understand correctly. I never written code with the IME API, but that is a pop-up window so there must be a way to get it reduced in size so that the portion which underlines "ari" doesn't overlap the main window in such an ugly manner.
Re: Japanese IME test code [message #15921 is a reply to message #15908] Fri, 16 May 2008 07:20 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
cbpporter wrote on Thu, 15 May 2008 21:43

Hi!

I tried to give your code a spin, but I can't seem to compile it because I'm missing types like CANDIDATEFORM and constants like CFS_CANDIDATEPOS (and a lot more). Are you using some extra includes?

Anyway if I can get this to compile it looks promising. Some adjustments of positioning still needed if I understand correctly. I never written code with the IME API, but that is a pop-up window so there must be a way to get it reduced in size so that the portion which underlines "ari" doesn't overlap the main window in such an ugly manner.


Just add #include "imm.h" to Win32Proc.cpp
Re: Japanese IME test code [message #15922 is a reply to message #15903] Fri, 16 May 2008 09:14 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mobilehunter wrote on Thu, 15 May 2008 05:57

I tried the GetCaret.

But, still confused with view-relative point, please tell me a little about this.

Does the GetCaret's coordinate already in view-relative point?

index.php?t=getfile&id=1205&private=0




Basically, it does not matter. We can always fix the base GetIMEPoint implementation.

What matters is that GetIMEPoint should return view coordinates...

Mirek
Previous Topic: How to retrieve current language?
Next Topic: CJK characters can be higlighted as keywords
Goto Forum:
  


Current Time: Thu Mar 28 14:01:50 CET 2024

Total time taken to generate the page: 0.01116 seconds