]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkdraw.c
[ Merges from gtk-1-2 ]
[~andy/gtk] / gdk / gdkdraw.c
index 3d39d3faacc73ee1d566f82b2333311f07039a52..8ae417e4aa6b7fe95f92ff052aa5f515de58eb31 100644 (file)
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
  */
+
+/*
+ * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+ */
+
 #include <X11/Xlib.h>
 #include <X11/Xos.h>
 #include "gdk.h"
@@ -292,6 +301,66 @@ gdk_draw_text (GdkDrawable *drawable,
     g_error("undefined font type\n");
 }
 
+void
+gdk_draw_text_wc (GdkDrawable   *drawable,
+                 GdkFont        *font,
+                 GdkGC          *gc,
+                 gint            x,
+                 gint            y,
+                 const GdkWChar *text,
+                 gint            text_length)
+{
+  GdkWindowPrivate *drawable_private;
+  GdkFontPrivate *font_private;
+  GdkGCPrivate *gc_private;
+
+  g_return_if_fail (drawable != NULL);
+  g_return_if_fail (font != NULL);
+  g_return_if_fail (gc != NULL);
+  g_return_if_fail (text != NULL);
+
+  drawable_private = (GdkWindowPrivate*) drawable;
+  if (drawable_private->destroyed)
+    return;
+  gc_private = (GdkGCPrivate*) gc;
+  font_private = (GdkFontPrivate*) font;
+
+  if (font->type == GDK_FONT_FONT)
+    {
+      XFontStruct *xfont = (XFontStruct *) font_private->xfont;
+      gchar *text_8bit;
+      gint i;
+      XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid);
+      text_8bit = g_new (gchar, text_length);
+      for (i=0; i<text_length; i++) text_8bit[i] = text[i];
+      XDrawString (drawable_private->xdisplay, drawable_private->xwindow,
+                   gc_private->xgc, x, y, text_8bit, text_length);
+      g_free (text_8bit);
+    }
+  else if (font->type == GDK_FONT_FONTSET)
+    {
+      if (sizeof(GdkWChar) == sizeof(wchar_t))
+       {
+         XwcDrawString (drawable_private->xdisplay, drawable_private->xwindow,
+                        (XFontSet) font_private->xfont,
+                        gc_private->xgc, x, y, (wchar_t *)text, text_length);
+       }
+      else
+       {
+         wchar_t *text_wchar;
+         gint i;
+         text_wchar = g_new (wchar_t, text_length);
+         for (i=0; i<text_length; i++) text_wchar[i] = text[i];
+         XwcDrawString (drawable_private->xdisplay, drawable_private->xwindow,
+                        (XFontSet) font_private->xfont,
+                        gc_private->xgc, x, y, text_wchar, text_length);
+         g_free (text_wchar);
+       }
+    }
+  else
+    g_error("undefined font type\n");
+}
+
 void
 gdk_draw_pixmap (GdkDrawable *drawable,
                 GdkGC       *gc,
@@ -432,12 +501,14 @@ gdk_draw_lines (GdkDrawable *drawable,
   g_return_if_fail (gc != NULL);
 
   drawable_private = (GdkWindowPrivate*) drawable;
+  if (drawable_private->destroyed)
+    return;
   gc_private = (GdkGCPrivate*) gc;
 
   XDrawLines (drawable_private->xdisplay,
-            drawable_private->xwindow,
-            gc_private->xgc,
-            (XPoint *) points,
-            npoints,
-            CoordModeOrigin);
+             drawable_private->xwindow,
+             gc_private->xgc,
+             (XPoint *) points,
+             npoints,
+             CoordModeOrigin);
 }