gtk/gdk/gdkgc.c
Owen Taylor e9b6bfcc01 Move all X specific code into the x11/ directory. Aside from shuffling
Mon Nov  8 14:47:04 1999  Owen Taylor  <otaylor@redhat.com>

	Move all X specific code into the x11/ directory.
	Aside from shuffling things around, did the following:

       * gdk/gdkprivate.h gdk/gdk.h gdk/x11/gdkmain-x11.h: Add
	 gdk_arg_context_* - a simple argument parsing system
	 in the style of popt.

       * gdk/gdkdrawable.[ch] gdk/gdkprivate.h gdk/gdkwindow.[ch]
	 gdk/x11/gdkprivate-x11.h:
	 Remove X specific stuff from GdkDrawable and GdkWindowPrivate -
	 add ->klass and ->klass_data fields. The klass_data
	 field points to an auxilliary structure that is
	 windowing system dependent.

       * gdk/gdkfont.c: Make most of the measurement functions
	 simply wrappers around gdk_text_extents().

       * gdk/gdkfont.c gdk/gdkprivate.h gdk/x11/gdkfont-x11.c: Add a
	 _gdk_font_strlen() function that hides the weird
	 behavior in gtk+-1.[02] where a string is interpreted
	 differently for 8-bit and 16-bit fonts.

       * gdk/gdkevents.c: Add a new function gdk_event_button_generate()
	 to store common code for synthesizing double/triple
	 press events.

       * gdk/gdkgc.[ch]: Virtualize in the same way as gdkdrawable.h.
	 Make all the function that modify an existing GC
	 simply wrappers around gdk_gc_set_values().

       * gdk/gdkcc.[ch]: Moved into x11/ directory in preparation
	 for throwing out later.

       * gdk/gdkfont.c gdk/gdkimage.c gdk/gdkcolor.c: Change GdkFontPrivate,
	 GdkImagePrivate and GdkColormapPrivate to have a
	 windowing system dependent part (GdkFontPrivateX etc.)
	 that "derives" from the system-independent part.

       * configure.in gdk/x11/Makefile.in gdk/x11/gdkinput*.c:
	 Got rid of the included-source-files for XInput in
	 favor of automake conditionals. (Which didn't exist
	 when XInput support was originally added.)

       * gdk/gdkrgb.c: Remove the visual id from the debugging
	 statements since that is X11 specific; print out
	 type/depth info instead.
1999-11-08 20:14:59 +00:00

306 lines
6.1 KiB
C

/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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.
*/
/*
* 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 <string.h>
#include "gdkgc.h"
#include "gdkprivate.h"
GdkGC*
gdk_gc_alloc (void)
{
GdkGCPrivate *private;
private = g_new (GdkGCPrivate, 1);
private->ref_count = 1;
private->klass = NULL;
private->klass = NULL;
private->klass_data = NULL;
return (GdkGC *)private;
}
GdkGC*
gdk_gc_new (GdkDrawable *drawable)
{
g_return_val_if_fail (drawable != NULL, NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return NULL;
return gdk_gc_new_with_values (drawable, NULL, 0);
}
GdkGC*
gdk_gc_new_with_values (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask values_mask)
{
g_return_val_if_fail (drawable != NULL, NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return NULL;
return ((GdkDrawablePrivate *)drawable)->klass->create_gc (drawable,
values,
values_mask);
}
GdkGC *
gdk_gc_ref (GdkGC *gc)
{
GdkGCPrivate *private = (GdkGCPrivate*) gc;
g_return_val_if_fail (gc != NULL, NULL);
private->ref_count += 1;
return gc;
}
void
gdk_gc_unref (GdkGC *gc)
{
GdkGCPrivate *private = (GdkGCPrivate*) gc;
g_return_if_fail (gc != NULL);
g_return_if_fail (private->ref_count > 0);
private->ref_count--;
if (private->ref_count == 0)
private->klass->destroy (gc);
}
void
gdk_gc_get_values (GdkGC *gc,
GdkGCValues *values)
{
g_return_if_fail (gc != NULL);
g_return_if_fail (values != NULL);
((GdkGCPrivate *)gc)->klass->get_values (gc, values);
}
void
gdk_gc_set_values (GdkGC *gc,
GdkGCValues *values,
GdkGCValuesMask values_mask)
{
g_return_if_fail (gc != NULL);
g_return_if_fail (values != NULL);
((GdkGCPrivate *)gc)->klass->set_values (gc, values, values_mask);
}
void
gdk_gc_set_foreground (GdkGC *gc,
GdkColor *color)
{
GdkGCValues values;
g_return_if_fail (gc != NULL);
g_return_if_fail (color != NULL);
values.foreground = *color;
gdk_gc_set_values (gc, &values, GDK_GC_FOREGROUND);
}
void
gdk_gc_set_background (GdkGC *gc,
GdkColor *color)
{
GdkGCValues values;
g_return_if_fail (gc != NULL);
g_return_if_fail (color != NULL);
values.background = *color;
gdk_gc_set_values (gc, &values, GDK_GC_BACKGROUND);
}
void
gdk_gc_set_font (GdkGC *gc,
GdkFont *font)
{
GdkGCValues values;
g_return_if_fail (gc != NULL);
g_return_if_fail (font != NULL);
values.font = font;
gdk_gc_set_values (gc, &values, GDK_GC_FONT);
}
void
gdk_gc_set_function (GdkGC *gc,
GdkFunction function)
{
GdkGCValues values;
g_return_if_fail (gc != NULL);
values.function = function;
gdk_gc_set_values (gc, &values, GDK_GC_FUNCTION);
}
void
gdk_gc_set_fill (GdkGC *gc,
GdkFill fill)
{
GdkGCValues values;
g_return_if_fail (gc != NULL);
values.fill = fill;
gdk_gc_set_values (gc, &values, GDK_GC_FILL);
}
void
gdk_gc_set_tile (GdkGC *gc,
GdkPixmap *tile)
{
GdkGCValues values;
g_return_if_fail (gc != NULL);
values.tile = tile;
gdk_gc_set_values (gc, &values, GDK_GC_TILE);
}
void
gdk_gc_set_stipple (GdkGC *gc,
GdkPixmap *stipple)
{
GdkGCValues values;
g_return_if_fail (gc != NULL);
values.stipple = stipple;
gdk_gc_set_values (gc, &values, GDK_GC_STIPPLE);
}
void
gdk_gc_set_ts_origin (GdkGC *gc,
gint x,
gint y)
{
GdkGCValues values;
g_return_if_fail (gc != NULL);
values.ts_x_origin = x;
values.ts_x_origin = y;
gdk_gc_set_values (gc, &values,
GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN);
}
void
gdk_gc_set_clip_origin (GdkGC *gc,
gint x,
gint y)
{
GdkGCValues values;
g_return_if_fail (gc != NULL);
values.clip_x_origin = x;
values.clip_x_origin = y;
gdk_gc_set_values (gc, &values,
GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN);
}
void
gdk_gc_set_clip_mask (GdkGC *gc,
GdkBitmap *mask)
{
GdkGCValues values;
g_return_if_fail (gc != NULL);
values.clip_mask = mask;
gdk_gc_set_values (gc, &values, GDK_GC_CLIP_MASK);
}
void
gdk_gc_set_subwindow (GdkGC *gc,
GdkSubwindowMode mode)
{
GdkGCValues values;
g_return_if_fail (gc != NULL);
values.subwindow_mode = mode;
gdk_gc_set_values (gc, &values, GDK_GC_SUBWINDOW);
}
void
gdk_gc_set_exposures (GdkGC *gc,
gboolean exposures)
{
GdkGCValues values;
g_return_if_fail (gc != NULL);
values.graphics_exposures = exposures;
gdk_gc_set_values (gc, &values, GDK_GC_EXPOSURES);
}
void
gdk_gc_set_line_attributes (GdkGC *gc,
gint line_width,
GdkLineStyle line_style,
GdkCapStyle cap_style,
GdkJoinStyle join_style)
{
GdkGCValues values;
values.line_width = line_width;
values.line_style = line_style;
values.cap_style = cap_style;
values.join_style = join_style;
gdk_gc_set_values (gc, &values,
GDK_GC_LINE_WIDTH |
GDK_GC_LINE_STYLE |
GDK_GC_CAP_STYLE |
GDK_GC_JOIN_STYLE);
}
void
gdk_gc_set_dashes (GdkGC *gc,
gint dash_offset,
gchar dash_list[],
gint n)
{
g_return_if_fail (gc != NULL);
g_return_if_fail (dash_list != NULL);
((GdkGCPrivate *)gc)->klass->set_dashes (gc, dash_offset, dash_list, n);
}