mirror of
https://github.com/fltk/fltk.git
synced 2026-02-06 08:21:40 +08:00
Hopefully last fix for STR #2472. The DnD receive code has been changed from accepting
ASCII text and transmitting it unchanged to the FLTK widget into accepting either UTF-16 or CP1252 text and in both cases transmitting it to FLTK recoded into UTF-8. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8021 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -220,13 +220,45 @@ private:
|
||||
fmt.tymed = TYMED_HGLOBAL;
|
||||
fmt.dwAspect = DVASPECT_CONTENT;
|
||||
fmt.lindex = -1;
|
||||
fmt.cfFormat = CF_TEXT;
|
||||
// if it is ASCII text, return a copy of it
|
||||
fmt.cfFormat = CF_UNICODETEXT;
|
||||
// if it is UNICODE text, return a UTF-8-converted copy of it
|
||||
if ( data->GetData( &fmt, &medium )==S_OK )
|
||||
{
|
||||
void *stuff = GlobalLock( medium.hGlobal );
|
||||
Fl::e_length = strlen((char*)stuff);
|
||||
Fl::e_text = strdup((char*)stuff);
|
||||
unsigned srclen = 0;
|
||||
const wchar_t *wstuff = (const wchar_t *)stuff;
|
||||
while(*wstuff++) srclen++;
|
||||
wstuff = (const wchar_t *)stuff;
|
||||
unsigned utf8len = fl_utf8fromwc(NULL, 0, wstuff, srclen);
|
||||
Fl::e_length = utf8len;
|
||||
Fl::e_text = (char*)malloc(utf8len + 1);
|
||||
fl_utf8fromwc(Fl::e_text, Fl::e_length, wstuff, srclen);
|
||||
GlobalUnlock( medium.hGlobal );
|
||||
ReleaseStgMedium( &medium );
|
||||
currDragResult = 1;
|
||||
return currDragResult;
|
||||
}
|
||||
fmt.cfFormat = CF_TEXT;
|
||||
// if it is CP1252 text, return a UTF-8-converted copy of it
|
||||
if ( data->GetData( &fmt, &medium )==S_OK )
|
||||
{
|
||||
int len;
|
||||
char *p, *q, *last;
|
||||
unsigned u;
|
||||
void *stuff = GlobalLock( medium.hGlobal );
|
||||
Fl::e_text = (char*)malloc(3 * strlen((char*)stuff) + 10);
|
||||
p = (char*)stuff;
|
||||
last = p + strlen(p);
|
||||
q = Fl::e_text;
|
||||
while (p < last) {
|
||||
u = fl_utf8decode(p, last, &len);
|
||||
p += len;
|
||||
len = fl_utf8encode(u, q);
|
||||
q += len;
|
||||
}
|
||||
*q = 0;
|
||||
Fl::e_length = q - Fl::e_text;
|
||||
Fl::e_text = (char*)realloc(Fl::e_text, Fl::e_length + 1);
|
||||
GlobalUnlock( medium.hGlobal );
|
||||
ReleaseStgMedium( &medium );
|
||||
currDragResult = 1;
|
||||
|
||||
Reference in New Issue
Block a user