From 8c71138ba5500a3d1bf446357992e8f165101173 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 6 Feb 2006 11:25:14 +0000 Subject: =?UTF-8?q?Bug=20328067=20=E2=80=93=20Install=20pango-view?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2006-02-06 Behdad Esfahbod Bug 328067 – Install pango-view Added a rather generic framework for a pango-view example. All backends have their own pango*-view built, and a pango-view binary is built too, that can choose backend via --backend. This one is installed in bindir. * examples/Makefile.am: Updated, to build pangox-view, pangoft2-view, pangoxft-view, pangocairo-view, and pango-view. * examples/viewer.h, examples/viewer-x.c, examples/viewer-x.h examples/viewer-cairo.c, examples/viewer-cairo.h, examples/viewer-main.c, examples/viewer-pangox.c, examples/viewer-pangoft2.c, examples/viewer-pangoxft.c, examples/viewer-pangocairo.c, examples/pango-view.c, examples/pango-xview.c, examples/pango-ft2view.c, examples/pango-xftview.c, examples/pango-cairoview.c: Added. * examples/cairoview.c, examples/xftview.c, examples/pangoft2topgm.c, examples/viewer-qt.cc, examples/viewer-qt.h: Removed. * configure.in: Check for Cairo Xlib backend, also AC_DEFINE various backend bits. --- examples/viewer-pangox.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 examples/viewer-pangox.c (limited to 'examples/viewer-pangox.c') diff --git a/examples/viewer-pangox.c b/examples/viewer-pangox.c new file mode 100644 index 00000000..c4d499af --- /dev/null +++ b/examples/viewer-pangox.c @@ -0,0 +1,113 @@ +/* viewer-pangox.c: PangoX viewer backend. + * + * Copyright (C) 1999,2004,2005 Red Hat, Inc. + * Copyright (C) 2001 Sun Microsystems + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#include + +#include "renderdemo.h" +#include "viewer-x.h" + +#include + +static void +pangox_view_destroy (gpointer instance) +{ + XViewer *x = (XViewer *)instance; + + pango_x_shutdown_display (x->display); + + x_view_destroy (instance); +} + +static PangoContext * +pangox_view_get_context (gpointer instance) +{ + XViewer *x = (XViewer *) instance; + + return pango_x_get_context (x->display); +} + +typedef struct +{ + XViewer *x; + Drawable drawable; + GC gc; +} MyXContext; + +static void +render_callback (PangoLayout *layout, + int x, + int y, + gpointer context, + gpointer state) +{ + MyXContext *x_context = (MyXContext *) context; + + pango_x_render_layout (x_context->x->display, + x_context->drawable, + x_context->gc, + layout, + x, y); +} + +static void +pangox_view_render (gpointer instance, + gpointer surface, + PangoContext *context, + int width, + int height, + gpointer state) +{ + XViewer *x = (XViewer *) instance; + Pixmap pixmap = (Pixmap) surface; + GC gc; + MyXContext x_context; + + gc = XCreateGC (x->display, pixmap, 0, NULL); + + XSetForeground(x->display, gc, WhitePixel(x->display, x->screen)); + XFillRectangle (x->display, pixmap, gc, 0, 0, width, height); + + x_context.x = x; + x_context.drawable = pixmap; + x_context.gc = gc; + + XSetForeground(x->display, gc, BlackPixel(x->display, x->screen)); + do_output (context, render_callback, NULL, &x_context, state, NULL, NULL); + + XFlush(x->display); + + XFreeGC (x->display, gc); +} + +const PangoViewer pangox_viewer = { + "PangoX", + "x", + NULL, + x_view_create, + pangox_view_destroy, + pangox_view_get_context, + x_view_create_surface, + x_view_destroy_surface, + pangox_view_render, + NULL, + x_view_create_window, + x_view_destroy_window, + x_view_display +}; -- cgit v1.2.1