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 Library 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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library 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-1999. 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/.
35 #include "gdkpixmap.h"
36 #include "gdkprivate.h"
41 *--------------------------------------------------------------
50 *--------------------------------------------------------------
56 gchar *current_locale;
58 if (!setlocale (LC_ALL,""))
59 g_warning ("locale not supported by C library");
61 current_locale = setlocale (LC_ALL, NULL);
63 return current_locale;
67 gdk_im_begin (GdkIC *ic, GdkWindow* window)
77 gdk_im_decide_style (GdkIMStyle supported_style)
79 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
83 gdk_im_set_best_style (GdkIMStyle style)
85 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
95 gdk_ic_new (GdkICAttr *attr, GdkICAttributesType mask)
101 gdk_ic_destroy (GdkIC *ic)
106 gdk_ic_get_style (GdkIC *ic)
108 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
112 gdk_ic_set_values (GdkIC *ic, ...)
117 gdk_ic_get_values (GdkIC *ic, ...)
122 gdk_ic_set_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
128 gdk_ic_get_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
134 gdk_ic_get_events (GdkIC *ic)
142 * Returns a multi-byte string converted from the specified array
143 * of wide characters. The string is newly allocated. The array of
144 * wide characters must be null-terminated. If the conversion is
145 * failed, it returns NULL.
147 * On Win32, we always use UTF-8.
150 gdk_wcstombs (const GdkWChar *src)
160 const GdkWChar c = *wcp++;
166 else if (c < 0x10000)
168 else if (c < 0x200000)
170 else if (c < 0x4000000)
176 mbstr = g_malloc (len + 1);
196 else if (c < 0x10000)
201 else if (c < 0x200000)
206 else if (c < 0x4000000)
220 case 6: bp[5] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
221 case 5: bp[4] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
222 case 4: bp[3] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
223 case 3: bp[2] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
224 case 2: bp[1] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
225 case 1: bp[0] = c | first;
238 * Converts the specified string into GDK wide characters, and,
239 * returns the number of wide characters written. The string 'src'
240 * must be null-terminated. If the conversion is failed, it returns
243 * On Win32, thr string is assumed to be in UTF-8. Also note that
244 * GdkWChar is 32 bits, while wchar_t, and the wide characters the
245 * Windows API uses, are 16 bits!
248 /* First a helper function for not zero-terminated strings */
250 gdk_nmbstowcs (GdkWChar *dest,
261 while (cp != end && dest != dest + dest_max)
263 gint i, mask = 0, len;
271 else if ((c & 0xe0) == 0xc0)
276 else if ((c & 0xf0) == 0xe0)
281 else if ((c & 0xf8) == 0xf0)
286 else if ((c & 0xfc) == 0xf8)
291 else if ((c & 0xfc) == 0xfc)
302 *dest = (cp[0] & mask);
303 for (i = 1; i < len; i++)
305 if ((cp[i] & 0xc0) != 0x80)
308 *dest |= (cp[i] & 0x3f);
324 gdk_mbstowcs (GdkWChar *dest,
328 return gdk_nmbstowcs (dest, src, strlen (src), dest_max);
332 /* A version that converts to wchar_t wide chars */
335 gdk_nmbstowchar_ts (wchar_t *dest,
348 while (cp != end && wcp != dest + dest_max)
350 gint i, mask = 0, len;
358 else if ((c & 0xe0) == 0xc0)
363 else if ((c & 0xf0) == 0xe0)
368 else /* Other lengths are not possible with 16-bit wchar_t! */
374 *wcp = (cp[0] & mask);
375 for (i = 1; i < len; i++)
377 if ((cp[i] & 0xc0) != 0x80)
380 *wcp |= (cp[i] & 0x3f);