Commit 3d737ee8 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Add GdkPangoRenderer, a subclass of PangoRenderer targeting GDK drawables.

Sat Nov 20 15:13:51 2004  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdkpango.[ch]: Add GdkPangoRenderer, a subclass of
	PangoRenderer targeting GDK drawables. Use to implement the old
	gdk_draw_layout() and friends.

	* gdk/gdkdraw.c gdk/gdkdrawable.h gdk/gdkwindow.c gdk/gdkpixmap.c:
	Add gdk_draw_glyphs_transformed() gdk_draw_trapezoids() and
	the corresponding members of GdkDrawableClass. Add a fallback
	implementation of gdk_draw_trapezoids() in terms of pixbufs.

	* gdk/gdkwindowing.h gdk/x11/gdkg-x11.h: Add
	_gdk_windowing_gc_get_foreground() to enable the fallback
	trapezoid implementation.

	* gdk/x11/gdkdrawable-x11.c gdk/x11/gdkdisplay-x11.h: Implement
	draw_glyph_transformed,	draw_trapezoids.

	* gdk/x11/gdkdrawable-x11.[ch]: Add
	_gdk_x11_drawable_draw_xtrapezoids, _gdk_x11_drawable_draw_xft_glyphs
	for use of GdkX11Renderer.

	* gdk/x11/gdkgc-x11.c gdk/x11/gdkprivate-x11.h: Implement
	GDK_TILED, GDK_STIPPLED, GDK_OPAQUE_STIPPLED in the RENDER codepath.

	* gdk/gdkpango-x11.c: Add GdkX11Renderer... a subclass of
	PangoXftRenderer that does tiles/stipples and fallback rendering
	of trapezoids without the RENDER extension.

	* gdk/gdkpango-x11.c gdk/x11/gdkscreen-x11.[ch] _gdk_x11_renderer_get:
	Add _gdk_x11_renderer_get() to get a singleton GdkX11Renderer
	for the screen.

	* gdk/x11/gdkdrawable-x11.c (get_impl_drawable): Fix a None/NULL
	confusion.

	* gtk/gtklabel.[ch] gtk/gtk.symbols: Add gtk_label_set/get_angle(),
	and an ::angle property.

	* gtk/gtklabel.c: Remove #if 0'd dead code gtk_label_paint_word().

	* gtk/gtktextdisplay.c: Switch to using a GtkTextRenderer subclass
	of GdkPangoRenderer for drawing.

	* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c: Switch to using
	gtk_attr_shape_new_with_data() to store backreferences to
	embedded pixmaps and widgets. Leave line_display->shaped_objects
	around for backwords compatibility.

	* gdk/gdkpango.[ch] (gdk_pango_context_set_colormap): Describe
	as deprecated, remove implementation.

	* gtk/gtkwidget.c (gtk_widget_create_pango_context): Remove
	call to gdk_pango_context_set_colormap.

	* demos/gtk-demo/Makefile.am demos/gtk-demo/rotated_text.c: Add
	a demo showing drawing rotated text.

	* tests/testgtk.c: Add a rotated-label test, and also a rotated
	drawing test (differs from demos/gtk-demo/rotated_text by also
	using a tile)
parent 4ef26492
......@@ -22,6 +22,7 @@ demos = \
menus.c \
panes.c \
pixbufs.c \
rotated_text.c \
sizegroup.c \
stock_browser.c \
textview.c \
......
/* Rotated Text
*
* This demo shows how to use GDK and Pango to draw rotated and transformed
* text. The use of GdkPangoRenderer in this example is a somewhat advanced
* technique; most applications can simply use gdk_draw_layout(). We use
* it here mostly because that allows us to work in user coordinates - that is,
* coordinates prior to the application of the transformation matrix, rather
* than device coordinates.
*
* As of GTK+-2.6, the ability to draw transformed and anti-aliased graphics
* as shown in this example is only present for text. With GTK+-2.8, a new
* graphics system called "Cairo" will be introduced that provides these
* capabilities and many more for all types of graphics.
*/
#include <math.h>
#include <gtk/gtk.h>
static GtkWidget *window = NULL;
static gboolean
rotated_text_expose_event (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
{
#define RADIUS 150
#define N_WORDS 10
#define FONT "Sans Bold 27"
PangoRenderer *renderer;
PangoMatrix matrix = PANGO_MATRIX_INIT;
PangoContext *context;
PangoLayout *layout;
PangoFontDescription *desc;
int width = widget->allocation.width;
int height = widget->allocation.height;
double device_radius;
int i;
/* Get the default renderer for the screen, and set it up for drawing */
renderer = gdk_pango_renderer_get_default (gtk_widget_get_screen (widget));
gdk_pango_renderer_set_drawable (GDK_PANGO_RENDERER (renderer), widget->window);
gdk_pango_renderer_set_gc (GDK_PANGO_RENDERER (renderer), widget->style->black_gc);
/* Set up a transformation matrix so that the user space coordinates for
* the centered square where we draw are [-RADIUS, RADIUS], [-RADIUS, RADIUS]
* We first center, then change the scale */
device_radius = MIN (width, height) / 2.;
pango_matrix_translate (&matrix,
device_radius + (width - 2 * device_radius) / 2,
device_radius + (height - 2 * device_radius) / 2);
pango_matrix_scale (&matrix, device_radius / RADIUS, device_radius / RADIUS);
/* Create a PangoLayout, set the font and text */
context = gtk_widget_create_pango_context (widget);
layout = pango_layout_new (context);
pango_layout_set_text (layout, "Text", -1);
desc = pango_font_description_from_string (FONT);
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
/* Draw the layout N_WORDS times in a circle */
for (i = 0; i < N_WORDS; i++)
{
GdkColor color;
PangoMatrix rotated_matrix = matrix;
int width, height;
double angle = (360. * i) / N_WORDS;
/* Gradient from red at angle == 60 to blue at angle == 300 */
color.red = 65535 * (1 + cos ((angle - 60) * M_PI / 180.)) / 2;
color.green = 0;
color.blue = 65535 - color.red;
gdk_pango_renderer_set_override_color (GDK_PANGO_RENDERER (renderer),
PANGO_RENDER_PART_FOREGROUND, &color);
pango_matrix_rotate (&rotated_matrix, angle);
pango_context_set_matrix (context, &rotated_matrix);
/* Inform Pango to re-layout the text with the new transformation matrix */
pango_layout_context_changed (layout);
pango_layout_get_size (layout, &width, &height);
pango_renderer_draw_layout (renderer, layout,
- width / 2, - RADIUS * PANGO_SCALE);
}
/* Clean up default renderer, since it is shared */
gdk_pango_renderer_set_override_color (GDK_PANGO_RENDERER (renderer),
PANGO_RENDER_PART_FOREGROUND, NULL);
gdk_pango_renderer_set_drawable (GDK_PANGO_RENDERER (renderer), NULL);
gdk_pango_renderer_set_gc (GDK_PANGO_RENDERER (renderer), NULL);
/* free the objects we created */
g_object_unref (layout);
g_object_unref (context);
return FALSE;
}
GtkWidget *
do_rotated_text (GtkWidget *do_widget)
{
GtkWidget *drawing_area;
if (!window)
{
const GdkColor white = { 0, 0xffff, 0xffff, 0xffff };
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_screen (GTK_WINDOW (window),
gtk_widget_get_screen (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Rotated Text");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
drawing_area = gtk_drawing_area_new ();
gtk_container_add (GTK_CONTAINER (window), drawing_area);
/* This overrides the background color from the theme */
gtk_widget_modify_bg (drawing_area, GTK_STATE_NORMAL, &white);
g_signal_connect (drawing_area, "expose-event",
G_CALLBACK (rotated_text_expose_event), NULL);
gtk_window_set_default_size (GTK_WINDOW (window), 2 * RADIUS, 2 * RADIUS);
}
if (!GTK_WIDGET_VISIBLE (window))
{
gtk_widget_show_all (window);
}
else
{
gtk_widget_destroy (window);
window = NULL;
}
return window;
}
......@@ -134,6 +134,7 @@ gdk_drawable_unref
gdk_draw_arc
gdk_draw_drawable
gdk_draw_glyphs
gdk_draw_glyphs_transformed
gdk_draw_gray_image
gdk_draw_image
gdk_draw_indexed_image
......@@ -157,6 +158,7 @@ gdk_draw_segments
gdk_draw_string
gdk_draw_text
gdk_draw_text_wc
gdk_draw_trapezoids
gdk_drop_finish
gdk_drop_reply
gdk_error_trap_pop
......@@ -305,6 +307,13 @@ gdk_pango_context_get_for_screen
gdk_pango_context_set_colormap
gdk_pango_layout_get_clip_region
gdk_pango_layout_line_get_clip_region
gdk_pango_renderer_get_default
gdk_pango_renderer_get_type
gdk_pango_renderer_new
gdk_pango_renderer_set_drawable
gdk_pango_renderer_set_gc
gdk_pango_renderer_set_override_color
gdk_pango_renderer_set_stipple
gdk_parse_args
gdk_pixbuf_get_from_drawable
gdk_pixbuf_get_from_image
......
......@@ -25,6 +25,7 @@
*/
#include <config.h>
#include <math.h>
#include "gdkalias.h"
#include "gdkdrawable.h"
#include "gdkinternals.h"
......@@ -58,7 +59,11 @@ static void gdk_drawable_real_draw_pixbuf (GdkDrawable *draw
GdkRgbDither dither,
gint x_dither,
gint y_dither);
static void gdk_drawable_real_draw_trapezoids (GdkDrawable *drawable,
GdkGC *gc,
GdkTrapezoid *trapezoids,
gint n_trapezoids);
static void gdk_drawable_class_init (GdkDrawableClass *klass);
GType
......@@ -99,6 +104,7 @@ gdk_drawable_class_init (GdkDrawableClass *klass)
klass->get_clip_region = gdk_drawable_real_get_visible_region;
klass->get_visible_region = gdk_drawable_real_get_visible_region;
klass->draw_pixbuf = gdk_drawable_real_draw_pixbuf;
klass->draw_trapezoids = gdk_drawable_real_draw_trapezoids;
}
/* Manipulation of drawables
......@@ -873,12 +879,12 @@ gdk_draw_lines (GdkDrawable *drawable,
* @font: font to be used
* @x: X coordinate of baseline origin
* @y: Y coordinate of baseline origin
* @glyphs: glyphs to render
* @glyphs: the glyph string to draw
*
* This is a low-level function; 99% of text rendering should be done
* using gdk_draw_layout() instead.
*
* A glyph is a character in a font. This function draws a sequence of
* A glyph is a single image in a font. This function draws a sequence of
* glyphs. To obtain a sequence of glyphs you have to understand a
* lot about internationalized text handling, which you don't want to
* understand; thus, use gdk_draw_layout() instead of this function,
......@@ -900,6 +906,74 @@ gdk_draw_glyphs (GdkDrawable *drawable,
GDK_DRAWABLE_GET_CLASS (drawable)->draw_glyphs (drawable, gc, font, x, y, glyphs);
}
/**
* gdk_draw_glyphs_transformed:
* @drawable: a #GdkDrawable
* @gc: a #GdkGC
* @matrix: a #PangoMatrix, or %NULL to use an identity transformation
* @font: the font in which to draw the string
* @x: the x position of the start of the string (in Pango
* units in user space coordinates)
* @y: the y position of the baseline (in Pango units
* in user space coordinates)
* @glyphs: the glyph string to draw
*
* Renders a #PangoGlyphString onto a drawable, possibly
* transforming the layed-out coordinates through a transformation
* matrix. Note that the transformation matrix for @font is not
* changed, so to produce correct rendering results, the @font
* must have been loaded using a #PangoContext with an identical
* transformation matrix to that passed in to this function.
*
* See also gdk_draw_glyphs(), gdk_draw_layout().
*
* Since: 2.6
**/
void
gdk_draw_glyphs_transformed (GdkDrawable *drawable,
GdkGC *gc,
PangoMatrix *matrix,
PangoFont *font,
gint x,
gint y,
PangoGlyphString *glyphs)
{
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
g_return_if_fail (GDK_IS_GC (gc));
if (GDK_DRAWABLE_GET_CLASS (drawable)->draw_glyphs_transformed)
GDK_DRAWABLE_GET_CLASS (drawable)->draw_glyphs_transformed (drawable, gc, matrix,
font, x, y, glyphs);
}
/**
* gdk_draw_trapezoids:
* @drawable: a #GdkDrawable
* @gc: a #GdkGC
* @trapezoids: an array of #GdkTrapezoid structures
* @n_trapezoids: the number of trapezoids to draw
*
* Draws a set of anti-aliased trapezoids. The trapezoids are
* combined using saturation addition, then drawn over the background
* as a set. This is low level functionality used internally to implement
* rotated underlines and backgrouds when rendering a PangoLayout and is
* likely not useful for applications.
*
* Since: 2.6
**/
void
gdk_draw_trapezoids (GdkDrawable *drawable,
GdkGC *gc,
GdkTrapezoid *trapezoids,
gint n_trapezoids)
{
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
g_return_if_fail (GDK_IS_GC (gc));
g_return_if_fail (n_trapezoids == 0 || trapezoids != NULL);
GDK_DRAWABLE_GET_CLASS (drawable)->draw_trapezoids (drawable, gc,
trapezoids, n_trapezoids);
}
/**
* gdk_drawable_copy_to_image:
......@@ -1534,6 +1608,282 @@ gdk_drawable_real_draw_pixbuf (GdkDrawable *drawable,
g_object_unref (composited);
}
/************************************************************************/
/* Fallback rendering code for anti-aliased trapezoids. Note that this code
* is cut-and-pasted (with the substitution of GdkPixbuf for FT_Bitmap) between
* here and pangoft2-render.c.
*/
typedef struct {
double y;
double x1;
double x2;
} Position;
static void
draw_simple_trap (GdkPixbuf *pixbuf,
int pixbuf_x,
int pixbuf_y,
Position *t,
Position *b)
{
guchar *pixels = gdk_pixbuf_get_pixels (pixbuf);
int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
int pixbuf_width = gdk_pixbuf_get_width (pixbuf);
int pixbuf_height = gdk_pixbuf_get_height (pixbuf);
int iy = floor (t->y);
int x1, x2, x;
double dy = b->y - t->y;
guchar *dest;
if (iy < pixbuf_y || iy >= pixbuf_y + pixbuf_height)
return;
if (t->x1 < b->x1)
x1 = floor (t->x1);
else
x1 = floor (b->x1);
if (t->x2 > b->x2)
x2 = ceil (t->x2);
else
x2 = ceil (b->x2);
x1 = CLAMP (x1, pixbuf_x, pixbuf_x + pixbuf_width);
x2 = CLAMP (x2, pixbuf_x, pixbuf_x + pixbuf_width);
dest = pixels + (iy - pixbuf_y) * rowstride + (x1 - pixbuf_x) * 4;
for (x = x1; x < x2; x++, dest += 4)
{
double top_left = MAX (t->x1, x);
double top_right = MIN (t->x2, x + 1);
double bottom_left = MAX (b->x1, x);
double bottom_right = MIN (b->x2, x + 1);
double c = 0.5 * dy * ((top_right - top_left) + (bottom_right - bottom_left));
/* When converting to [0,255], we round up. This is intended
* to prevent the problem of pixels that get divided into
* multiple slices not being fully black.
*/
int ic = c * 256;
/* We already set the entire buffer to the destination color */
dest[3] = MIN (dest[3] + ic, 255);
}
}
static void
interpolate_position (Position *result,
Position *top,
Position *bottom,
double val,
double val1,
double val2)
{
result->y = (top->y * (val2 - val) + bottom->y * (val - val1)) / (val2 - val1);
result->x1 = (top->x1 * (val2 - val) + bottom->x1 * (val - val1)) / (val2 - val1);
result->x2 = (top->x2 * (val2 - val) + bottom->x2 * (val - val1)) / (val2 - val1);
}
/* This draws a trapezoid with the parallel sides aligned with
* the X axis. We do this by subdividing the trapezoid vertically
* into thin slices (themselves trapezoids) where two edge sides are each
* contained within a single pixel and then rasterizing each
* slice. There are frequently multiple slices within a single
* line so we have to accumulate to get the final result.
*/
static void
draw_trapezoid (GdkPixbuf *pixbuf,
int pixbuf_x,
int pixbuf_y,
GdkTrapezoid *trapezoid)
{
Position pos;
Position t;
Position b;
gboolean done = FALSE;
if (trapezoid->y1 == trapezoid->y2)
return;
pos.y = t.y = trapezoid->y1;
pos.x1 = t.x1 = trapezoid->x11;
pos.x2 = t.x2 = trapezoid->x21;
b.y = trapezoid->y2;
b.x1 = trapezoid->x12;
b.x2 = trapezoid->x22;
while (!done)
{
Position pos_next;
double y_next, x1_next, x2_next;
double ix1, ix2;
/* The algorithm here is written to emphasize simplicity and
* numerical stability as opposed to speed.
*
* While the end result is slicing up the polygon vertically,
* conceptually we aren't walking in the X direction, rather we
* are walking along the edges. When we compute crossing of
* horizontal pixel boundaries, we use the X coordinate as the
* interpolating variable, when we compute crossing for vertical
* pixel boundaries, we use the Y coordinate.
*
* This allows us to handle almost exactly horizontal edges without
* running into difficulties. (Almost exactly horizontal edges
* come up frequently due to inexactness in computing, say,
* a 90 degree rotation transformation)
*/
pos_next = b;
done = TRUE;
/* Check for crossing vertical pixel boundaries */
y_next = floor (pos.y) + 1;
if (y_next < pos_next.y)
{
interpolate_position (&pos_next, &t, &b,
y_next, t.y, b.y);
pos_next.y = y_next;
done = FALSE;
}
/* Check left side for crossing horizontal pixel boundaries */
ix1 = floor (pos.x1);
if (b.x1 < t.x1)
{
if (ix1 == pos.x1)
x1_next = ix1 - 1;
else
x1_next = ix1;
if (x1_next > pos_next.x1)
{
interpolate_position (&pos_next, &t, &b,
x1_next, t.x1, b.x1);
pos_next.x1 = x1_next;
done = FALSE;
}
}
else if (b.x1 > t.x1)
{
x1_next = ix1 + 1;
if (x1_next < pos_next.x1)
{
interpolate_position (&pos_next, &t, &b,
x1_next, t.x1, b.x1);
pos_next.x1 = x1_next;
done = FALSE;
}
}
/* Check right side for crossing horizontal pixel boundaries */
ix2 = floor (pos.x2);
if (b.x2 < t.x2)
{
if (ix2 == pos.x2)
x2_next = ix2 - 1;
else
x2_next = ix2;
if (x2_next > pos_next.x2)
{
interpolate_position (&pos_next, &t, &b,
x2_next, t.x2, b.x2);
pos_next.x2 = x2_next;
done = FALSE;
}
}
else if (trapezoid->x22 > trapezoid->x21)
{
x2_next = ix2 + 1;
if (x2_next < pos_next.x2)
{
interpolate_position (&pos_next, &t, &b,
x2_next, t.x2, b.x2);
pos_next.x2 = x2_next;
done = FALSE;
}
}
draw_simple_trap (pixbuf, pixbuf_x, pixbuf_y, &pos, &pos_next);
pos = pos_next;
}
}
static void
gdk_drawable_real_draw_trapezoids (GdkDrawable *drawable,
GdkGC *gc,
GdkTrapezoid *trapezoids,
gint n_trapezoids)
{
GdkPixbuf *pixbuf;
double min_x, max_x, min_y, max_y;
int x, y, width, height;
GdkColor color;
int i;
if (n_trapezoids == 0)
return;
/* compute bounding box */
min_x = max_x = trapezoids[0].x11;
min_y = max_y = trapezoids[0].y1;
for (i = 0; i < n_trapezoids; i++)
{
if (trapezoids[i].x11 < min_x) min_x = trapezoids[i].x11;
if (trapezoids[i].x21 > max_x) max_x = trapezoids[i].x21;
if (trapezoids[i].x12 < min_x) min_x = trapezoids[i].x12;
if (trapezoids[i].x22 > max_x) max_x = trapezoids[i].x22;
if (trapezoids[i].y1 < min_y) min_y = trapezoids[i].y1;
if (trapezoids[i].y2 > max_y) max_y = trapezoids[i].y2;
}
/* allocate temporary pixbuf */
x = floor (min_x);
width = ceil (max_x) - x;
y = floor (min_y);
height = ceil (max_y) - y;
if (width == 0 || height == 0)
return;
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
if (!pixbuf)
return;
/* Fill the pixbuf with the foreground color and alpha 0 */
_gdk_windowing_gc_get_foreground (gc, &color);
gdk_pixbuf_fill (pixbuf,
(((color.red & 0xff00) << 16) |
((color.green & 0xff00) << 8) |
((color.blue & 0xff00))));
/* draw the trapezoids into the alpha channel */
for (i = 0; i < n_trapezoids; i++)
draw_trapezoid (pixbuf, x, y, &trapezoids[i]);
/* composite that onto the drawable */
gdk_draw_pixbuf (drawable, gc, pixbuf,
0, 0, x, y, width, height,
GDK_RGB_DITHER_NORMAL, 0, 0);
g_object_unref (pixbuf);
}
/************************************************************************/
/**
* _gdk_drawable_get_scratch_gc:
* @drawable: A #GdkDrawable
......
......@@ -11,6 +11,7 @@ extern "C" {
#endif /* __cplusplus */
typedef struct _GdkDrawableClass GdkDrawableClass;
typedef struct _GdkTrapezoid GdkTrapezoid;
#define GDK_TYPE_DRAWABLE (gdk_drawable_get_type ())
#define GDK_DRAWABLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAWABLE, GdkDrawable))
......@@ -154,10 +155,20 @@ struct _GdkDrawableClass
gint dest_y,
gint width,
gint height);
void (*draw_glyphs_transformed) (GdkDrawable *drawable,
GdkGC *gc,
PangoMatrix *matrix,
PangoFont *font,
gint x,
gint y,
PangoGlyphString *glyphs);
void (*draw_trapezoids) (GdkDrawable *drawable,
GdkGC *gc,
GdkTrapezoid *trapezoids,
gint n_trapezoids);
/* Padding for future expansion */
void (*_gdk_reserved1) (void);
void (*_gdk_reserved2) (void);
void (*_gdk_reserved3) (void);
void (*_gdk_reserved4) (void);
void (*_gdk_reserved5) (void);
......@@ -173,6 +184,11 @@ struct _GdkDrawableClass
void (*_gdk_reserved16) (void);
};
struct _GdkTrapezoid
{
double y1, x11, x21, y2, x12, x22;
};
GType gdk_drawable_get_type (void);
/* Manipulation of drawables
......@@ -338,6 +354,18 @@ void gdk_draw_layout_with_colors (GdkDrawable *drawable,
const GdkColor *foreground,
const GdkColor *background);
void gdk_draw_glyphs_transformed (GdkDrawable *drawable,
GdkGC *gc,
PangoMatrix *matrix,
PangoFont *font,
gint x,
gint y,
PangoGlyphString *glyphs);
void gdk_draw_trapezoids (GdkDrawable *drawable,
GdkGC *gc,
GdkTrapezoid *trapezoids,
gint n_trapezoids);
#ifndef GDK_DISABLE_DEPRECATED
#define gdk_draw_pixmap gdk_draw_drawable
#define gdk_draw_bitmap gdk_draw_drawable
......@@ -360,7 +388,6 @@ GdkImage *gdk_drawable_copy_to_image (GdkDrawable *drawable,
GdkRegion *gdk_drawable_get_clip_region (GdkDrawable *drawable);
GdkRegion *gdk_drawable_get_visible_region (GdkDrawable *drawable);
gboolean gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
gint x,
gint y,
......
......@@ -320,6 +320,11 @@ void _gdk_windowing_display_set_sm_client_id (GdkDisplay *display,
GType _gdk_window_impl_get_type (void) G_GNUC_CONST;
GType _gdk_pixmap_impl_get_type (void) G_GNUC_CONST;
/* Queries the current foreground color of a GdkGC */
void _gdk_windowing_gc_get_foreground (GdkGC *gc,
GdkColor *color);
/************************************
* Initialization and exit routines *
************************************/
......
This diff is collapsed.
......@@ -28,12 +28,88 @@ extern "C" {
/* Pango interaction */
typedef struct _GdkPangoRenderer GdkPangoRenderer;
typedef struct _GdkPangoRendererClass GdkPangoRendererClass;
typedef struct _GdkPangoRendererPrivate GdkPangoRendererPrivate;
#define GDK_TYPE_PANGO_RENDERER (gdk_pango_renderer_get_type())
#define GDK_PANGO_RENDERER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PANGO_RENDERER, GdkPangoRenderer))
#define GDK_IS_PANGO_RENDERER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PANGO_RENDERER))
#define GDK_PANGO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PANGO_RENDERER, GdkPangoRendererClass))
#define GDK_IS_PANGO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PANGO_RENDERER))
#define GDK_PANGO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PANGO_RENDERER, GdkPangoRendererClass))
/**
* GdkPangoRenderer:
*
* #GdkPangoRenderer is a subclass of #PangoRenderer used for rendering
* Pango objects into GDK drawables. The default renderer for a particular
* screen is obtained with gdk_pango_renderer_get_default(); Pango
* functions like pango_renderer_draw_layout() and
* pango_renderer_draw_layout_line() are then used to draw objects with
* the renderer.
*
* In most simple cases, applications can just use gdk_draw_layout(), and
* don't need to directly use #GdkPangoRenderer at all. Using the
* #GdkPangoRenderer directly is most useful when working with a
* transformation such as a rotation, because the Pango drawing functions
* take user space coordinates (coordinates before the transformation)
* instead of device coordinates.
*
* In certain cases it can be useful to subclass #GdkPangoRenderer. Examples
* of reasons to do this are to add handling of custom attributes by
* overriding 'prepare_run' or to do custom drawing of embedded objects
* by overriding 'draw_shape'.
*
* Since: 2.6
**/
struct _GdkPangoRenderer
{
/*< private >*/
PangoRenderer parent_instance;
GdkPangoRendererPrivate *priv;
};
/**
* GdkPangoRendererClass:
*
* #GdkPangoRenderer is the class structure for #GdkPangoRenderer.
*
* Since: 2.6
**/
struct _GdkPangoRendererClass
{
/*< private >*/
PangoRendererClass parent_class;
};
GType gdk_pango_renderer_get_type (void) G_GNUC_CONST;
PangoRenderer *gdk_pango_renderer_new (GdkScreen *screen);
PangoRenderer *gdk_pango_renderer_get_default (GdkScreen *screen);
void gdk_pango_renderer_set_drawable (GdkPangoRenderer *gdk_renderer,
GdkDrawable *drawable);
void gdk_pango_renderer_set_gc (GdkPangoRenderer *gdk_renderer,
GdkGC *gc);
void gdk_pango_renderer_set_stipple (GdkPangoRenderer *gdk_renderer,
PangoRenderPart part,
GdkBitmap *stipple);
void gdk_pango_renderer_set_override_color (GdkPangoRenderer *gdk_renderer,
PangoRenderPart part,
const GdkColor *color);