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"
40 /* If this variable is FALSE, it indicates that we should
41 * avoid trying to use multibyte conversion functions and
42 * assume everything is 1-byte per character
44 static gboolean gdk_use_mb;
47 *--------------------------------------------------------------
56 *--------------------------------------------------------------
63 gchar *current_locale;
67 if (!setlocale (LC_ALL,""))
68 g_warning ("locale not supported by C library");
70 current_locale = setlocale (LC_ALL, NULL);
75 GDK_NOTE (XIM, g_message ("%s multi-byte string functions.",
76 gdk_use_mb ? "Using" : "Not using"));
78 return current_locale;
82 gdk_im_begin (GdkIC *ic, GdkWindow* window)
92 gdk_im_decide_style (GdkIMStyle supported_style)
94 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
98 gdk_im_set_best_style (GdkIMStyle style)
100 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
110 gdk_ic_new (GdkICAttr *attr, GdkICAttributesType mask)
116 gdk_ic_destroy (GdkIC *ic)
121 gdk_ic_get_style (GdkIC *ic)
123 return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
127 gdk_ic_set_values (GdkIC *ic, ...)
132 gdk_ic_get_values (GdkIC *ic, ...)
137 gdk_ic_set_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
143 gdk_ic_get_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
149 gdk_ic_get_events (GdkIC *ic)
157 * Returns a multi-byte string converted from the specified array
158 * of wide characters. The string is newly allocated. The array of
159 * wide characters must be null-terminated. If the conversion is
160 * failed, it returns NULL.
163 gdk_wcstombs (const GdkWChar *src)
172 for (wcsl = 0; src[wcsl]; wcsl++)
174 src_alt = g_new (wchar_t, wcsl+1);
175 for (i = wcsl; i >= 0; i--)
177 mbsl = WideCharToMultiByte (CP_OEMCP, 0, src_alt, wcsl,
178 NULL, 0, NULL, NULL);
179 mbstr = g_new (guchar, mbsl + 1);
180 if (!WideCharToMultiByte (CP_OEMCP, 0, src_alt, wcsl,
181 mbstr, mbsl, NULL, NULL))
183 g_warning ("gdk_wcstombs: WideCharToMultiByte failed");
196 while (src[length] != 0)
199 mbstr = g_new (gchar, length + 1);
201 for (i=0; i<length+1; i++)
212 * Converts the specified string into wide characters, and, returns the
213 * number of wide characters written. The string 'src' must be
214 * null-terminated. If the conversion is failed, it returns -1.
217 gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
224 wcsl = MultiByteToWideChar (CP_OEMCP, 0, src, -1, NULL, 0);
225 wcstr = g_new (wchar_t, wcsl);
226 if (!MultiByteToWideChar (CP_OEMCP, 0, src, -1, wcstr, wcsl))
228 g_warning ("gdk_mbstowcs: MultiByteToWideChar failed");
234 for (i = 0; i < wcsl && wcstr[i]; i++)
244 for (i=0; i<dest_max && src[i]; i++)