1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
34 #include "gdkpixmap.h"
35 #include "gdkinternals.h"
40 *--------------------------------------------------------------
49 *--------------------------------------------------------------
55 if (!setlocale (LC_ALL, ""))
56 g_warning ("locale not supported by C library");
58 return g_win32_getlocale ();
62 gdk_im_begin (GdkIC *ic, GdkWindow* window)
72 gdk_im_decide_style (GdkIMStyle supported_style)
74 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
78 gdk_im_set_best_style (GdkIMStyle style)
80 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
90 gdk_ic_new (GdkICAttr *attr, GdkICAttributesType mask)
96 gdk_ic_destroy (GdkIC *ic)
101 gdk_ic_get_style (GdkIC *ic)
103 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
107 gdk_ic_attr_new (void)
113 gdk_ic_attr_destroy (GdkICAttr *attr)
118 gdk_ic_set_values (GdkIC *ic, ...)
123 gdk_ic_get_values (GdkIC *ic, ...)
128 gdk_ic_set_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
134 gdk_ic_get_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
140 gdk_ic_get_events (GdkIC *ic)
148 * Returns a multi-byte string converted from the specified array
149 * of wide characters. The string is newly allocated. The array of
150 * wide characters must be null-terminated. If the conversion is
151 * failed, it returns NULL.
153 * On Win32, we always use UTF-8.
156 gdk_wcstombs (const GdkWChar *src)
166 const GdkWChar c = *wcp++;
172 else if (c < 0x10000)
174 else if (c < 0x200000)
176 else if (c < 0x4000000)
182 mbstr = g_malloc (len + 1);
202 else if (c < 0x10000)
207 else if (c < 0x200000)
212 else if (c < 0x4000000)
226 case 6: bp[5] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
227 case 5: bp[4] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
228 case 4: bp[3] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
229 case 3: bp[2] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
230 case 2: bp[1] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
231 case 1: bp[0] = c | first;
244 * Converts the specified string into GDK wide characters, and,
245 * returns the number of wide characters written. The string 'src'
246 * must be null-terminated. If the conversion is failed, it returns
249 * On Win32, the string is assumed to be in UTF-8. Also note that
250 * GdkWChar is 32 bits, while wchar_t, and the wide characters the
251 * Windows API uses, are 16 bits!
254 /* First a helper function for not zero-terminated strings */
256 gdk_nmbstowcs (GdkWChar *dest,
267 while (cp != end && dest != dest + dest_max)
269 gint i, mask = 0, len;
277 else if ((c & 0xe0) == 0xc0)
282 else if ((c & 0xf0) == 0xe0)
287 else if ((c & 0xf8) == 0xf0)
292 else if ((c & 0xfc) == 0xf8)
297 else if ((c & 0xfc) == 0xfc)
308 *dest = (cp[0] & mask);
309 for (i = 1; i < len; i++)
311 if ((cp[i] & 0xc0) != 0x80)
314 *dest |= (cp[i] & 0x3f);
330 gdk_mbstowcs (GdkWChar *dest,
334 return gdk_nmbstowcs (dest, src, strlen (src), dest_max);
338 /* A version that converts to wchar_t wide chars */
341 gdk_nmbstowchar_ts (wchar_t *dest,
354 while (cp != end && wcp != dest + dest_max)
356 gint i, mask = 0, len;
364 else if ((c & 0xe0) == 0xc0)
369 else if ((c & 0xf0) == 0xe0)
374 else /* Other lengths are not possible with 16-bit wchar_t! */
380 *wcp = (cp[0] & mask);
381 for (i = 1; i < len; i++)
383 if ((cp[i] & 0xc0) != 0x80)
386 *wcp |= (cp[i] & 0x3f);