gdkgc.c

Go to the documentation of this file.
00001 /* GDK - The GIMP Drawing Kit
00002  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
00018  */
00019 
00020 /*
00021  * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
00022  * file for a list of people on the GTK+ Team.  See the ChangeLog
00023  * files for a list of changes.  These files are distributed with
00024  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
00025  */
00026 
00027 #include <string.h>
00028 
00029 #include "gdkgc.h"
00030 #include "gdkprivate.h"
00031 
00032 GdkGC *gdk_gc_alloc(void)
00033 {
00034    GdkGCPrivate *private;
00035 
00036    private = g_new(GdkGCPrivate, 1);
00037    private->ref_count = 1;
00038    private->klass = NULL;
00039    private->klass_data = NULL;
00040 
00041    return (GdkGC *) private;
00042 }
00043 
00044 GdkGC *gdk_gc_new(GdkDrawable * drawable)
00045 {
00046    g_return_val_if_fail(drawable != NULL, NULL);
00047 
00048    if (GDK_DRAWABLE_DESTROYED(drawable))
00049       return NULL;
00050 
00051    return gdk_gc_new_with_values(drawable, NULL, 0);
00052 }
00053 
00054 GdkGC *gdk_gc_new_with_values(GdkDrawable * drawable,
00055                               GdkGCValues * values,
00056                               GdkGCValuesMask values_mask)
00057 {
00058    g_return_val_if_fail(drawable != NULL, NULL);
00059 
00060    if (GDK_DRAWABLE_DESTROYED(drawable))
00061       return NULL;
00062 
00063    return ((GdkDrawablePrivate *) drawable)->klass->create_gc(drawable,
00064                                                               values,
00065                                                               values_mask);
00066 }
00067 
00068 GdkGC *gdk_gc_ref(GdkGC * gc)
00069 {
00070    GdkGCPrivate *private = (GdkGCPrivate *) gc;
00071 
00072    g_return_val_if_fail(gc != NULL, NULL);
00073    private->ref_count += 1;
00074 
00075    return gc;
00076 }
00077 
00078 void gdk_gc_unref(GdkGC * gc)
00079 {
00080    GdkGCPrivate *private = (GdkGCPrivate *) gc;
00081 
00082    g_return_if_fail(gc != NULL);
00083    g_return_if_fail(private->ref_count > 0);
00084 
00085    private->ref_count--;
00086 
00087    if (private->ref_count == 0)
00088       private->klass->destroy(gc);
00089 }
00090 
00091 void gdk_gc_get_values(GdkGC * gc, GdkGCValues * values)
00092 {
00093    g_return_if_fail(gc != NULL);
00094    g_return_if_fail(values != NULL);
00095 
00096    ((GdkGCPrivate *) gc)->klass->get_values(gc, values);
00097 }
00098 
00099 void
00100 gdk_gc_set_values(GdkGC * gc,
00101                   GdkGCValues * values, GdkGCValuesMask values_mask)
00102 {
00103    g_return_if_fail(gc != NULL);
00104    g_return_if_fail(values != NULL);
00105 
00106    ((GdkGCPrivate *) gc)->klass->set_values(gc, values, values_mask);
00107 }
00108 
00109 void gdk_gc_set_foreground(GdkGC * gc, GdkColor * color)
00110 {
00111    GdkGCValues values;
00112 
00113    g_return_if_fail(gc != NULL);
00114    g_return_if_fail(color != NULL);
00115 
00116    values.foreground = *color;
00117    gdk_gc_set_values(gc, &values, GDK_GC_FOREGROUND);
00118 }
00119 
00120 void gdk_gc_set_background(GdkGC * gc, GdkColor * color)
00121 {
00122    GdkGCValues values;
00123 
00124    g_return_if_fail(gc != NULL);
00125    g_return_if_fail(color != NULL);
00126 
00127    values.background = *color;
00128    gdk_gc_set_values(gc, &values, GDK_GC_BACKGROUND);
00129 }
00130 
00131 void gdk_gc_set_font(GdkGC * gc, GdkFont * font)
00132 {
00133    GdkGCValues values;
00134 
00135    g_return_if_fail(gc != NULL);
00136    g_return_if_fail(font != NULL);
00137 
00138    values.font = font;
00139    gdk_gc_set_values(gc, &values, GDK_GC_FONT);
00140 }
00141 
00142 void gdk_gc_set_function(GdkGC * gc, GdkFunction function)
00143 {
00144    GdkGCValues values;
00145 
00146    g_return_if_fail(gc != NULL);
00147 
00148    values.function = function;
00149    gdk_gc_set_values(gc, &values, GDK_GC_FUNCTION);
00150 }
00151 
00152 void gdk_gc_set_fill(GdkGC * gc, GdkFill fill)
00153 {
00154    GdkGCValues values;
00155 
00156    g_return_if_fail(gc != NULL);
00157 
00158    values.fill = fill;
00159    gdk_gc_set_values(gc, &values, GDK_GC_FILL);
00160 }
00161 
00162 void gdk_gc_set_tile(GdkGC * gc, GdkPixmap * tile)
00163 {
00164    GdkGCValues values;
00165 
00166    g_return_if_fail(gc != NULL);
00167 
00168    values.tile = tile;
00169    gdk_gc_set_values(gc, &values, GDK_GC_TILE);
00170 }
00171 
00172 void gdk_gc_set_stipple(GdkGC * gc, GdkPixmap * stipple)
00173 {
00174    GdkGCValues values;
00175 
00176    g_return_if_fail(gc != NULL);
00177 
00178    values.stipple = stipple;
00179    gdk_gc_set_values(gc, &values, GDK_GC_STIPPLE);
00180 }
00181 
00182 void gdk_gc_set_ts_origin(GdkGC * gc, gint x, gint y)
00183 {
00184    GdkGCValues values;
00185 
00186    g_return_if_fail(gc != NULL);
00187 
00188    values.ts_x_origin = x;
00189    values.ts_y_origin = y;
00190 
00191    gdk_gc_set_values(gc, &values, GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN);
00192 }
00193 
00194 void gdk_gc_set_clip_origin(GdkGC * gc, gint x, gint y)
00195 {
00196    GdkGCValues values;
00197 
00198    g_return_if_fail(gc != NULL);
00199 
00200    values.clip_x_origin = x;
00201    values.clip_y_origin = y;
00202 
00203    gdk_gc_set_values(gc, &values,
00204                      GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN);
00205 }
00206 
00207 void gdk_gc_set_clip_mask(GdkGC * gc, GdkBitmap * mask)
00208 {
00209    GdkGCValues values;
00210 
00211    g_return_if_fail(gc != NULL);
00212 
00213    values.clip_mask = mask;
00214    gdk_gc_set_values(gc, &values, GDK_GC_CLIP_MASK);
00215 }
00216 
00217 
00218 void gdk_gc_set_subwindow(GdkGC * gc, GdkSubwindowMode mode)
00219 {
00220    GdkGCValues values;
00221 
00222    g_return_if_fail(gc != NULL);
00223 
00224    values.subwindow_mode = mode;
00225    gdk_gc_set_values(gc, &values, GDK_GC_SUBWINDOW);
00226 }
00227 
00228 void gdk_gc_set_exposures(GdkGC * gc, gboolean exposures)
00229 {
00230    GdkGCValues values;
00231 
00232    g_return_if_fail(gc != NULL);
00233 
00234    values.graphics_exposures = exposures;
00235    gdk_gc_set_values(gc, &values, GDK_GC_EXPOSURES);
00236 }
00237 
00238 void
00239 gdk_gc_set_line_attributes(GdkGC * gc,
00240                            gint line_width,
00241                            GdkLineStyle line_style,
00242                            GdkCapStyle cap_style, GdkJoinStyle join_style)
00243 {
00244    GdkGCValues values;
00245 
00246    values.line_width = line_width;
00247    values.line_style = line_style;
00248    values.cap_style = cap_style;
00249    values.join_style = join_style;
00250 
00251    gdk_gc_set_values(gc, &values,
00252                      GDK_GC_LINE_WIDTH |
00253                      GDK_GC_LINE_STYLE |
00254                      GDK_GC_CAP_STYLE | GDK_GC_JOIN_STYLE);
00255 }
00256 
00257 void
00258 gdk_gc_set_dashes(GdkGC * gc, gint dash_offset, gint8 dash_list[], gint n)
00259 {
00260    g_return_if_fail(gc != NULL);
00261    g_return_if_fail(dash_list != NULL);
00262 
00263    ((GdkGCPrivate *) gc)->klass->set_dashes(gc, dash_offset, dash_list, n);
00264 }

Generated on Tue Jul 5 14:14:37 2011 for ROOT_528-00b_version by  doxygen 1.5.1