/* 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.
 */
#include <curses.h>
#include <panel.h>
#include "gdk.h"
#include "gdkprivate.h"
#include <string.h>


GdkGC*
gdk_gc_new (GdkWindow *window)
{
  return gdk_gc_new_with_values (window, NULL, 0);
}

GdkGC*
gdk_gc_new_with_values (GdkWindow	*window,
			GdkGCValues	*values,
			GdkGCValuesMask	 values_mask)
{
  GdkWindowPrivate *window_private;
  GdkGC *gc;
  GdkGCPrivate *private;

  g_return_val_if_fail (window != NULL, NULL);

  window_private = (GdkWindowPrivate*) window;
  if (window_private->destroyed)
    return NULL;

  private = g_new (GdkGCPrivate, 1);
  gc = (GdkGC*) private;

  private->gwin = window;
  if (values_mask & GDK_GC_FOREGROUND)
    {
      fprintf( stderr, "gc_set_foreground/X: setting to %ld\n", values->foreground.pixel );
      private->foreground = values->foreground.pixel;
    }
  if (values_mask & GDK_GC_BACKGROUND)
    {
      fprintf( stderr, "gc_set_background/X: setting to %ld\n", values->background.pixel );
      private->background = values->background.pixel;
    }
  gdk_gc_set_clip_rectangle(gc, NULL);
  /* FIXME: should se rectangle to alue I was asked to set */
  return gc;
}

void
gdk_gc_destroy (GdkGC *gc)
{
  gdk_gc_unref (gc);
}

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);
  
  if (private->ref_count > 1)
    private->ref_count -= 1;
  else
    {
      memset (gc, 0, sizeof (GdkGCPrivate));
      g_free (gc);
    }
}

void
gdk_gc_get_values (GdkGC       *gc,
		   GdkGCValues *values)
{
  GdkGCPrivate *gcp = (GdkGCPrivate *) gc;
  values->foreground.pixel = gcp->foreground;
  values->background.pixel = gcp->background;
  values->font = only_font;
  values->function = 0;
  values->fill = 0;
  values->tile = NULL;
  values->stipple = NULL;
  values->clip_mask = NULL;
  values->subwindow_mode = 0;
  values->ts_x_origin = 0;
  values->ts_y_origin = 0;
  values->clip_x_origin = 0;
  values->clip_y_origin = 0;
  values->graphics_exposures = 0;
  values->line_width = 1;
  values->line_style = 0;
  values->cap_style = 0;
  values->join_style = 0;
}

void
gdk_gc_set_foreground (GdkGC	*gc,
		       GdkColor *color)
{
  GdkGCPrivate *private = (GdkGCPrivate *) gc;

  g_return_if_fail (gc != NULL);
  fprintf( stderr, "gc_set_foreground: setting to %ld\n", color->pixel );
  private->foreground = color->pixel;
}

void
gdk_gc_set_background (GdkGC	*gc,
		       GdkColor *color)
{
  GdkGCPrivate *private = (GdkGCPrivate *) gc;

  g_return_if_fail (gc != NULL);
  fprintf( stderr, "gc_set_background: setting to %ld\n", color->pixel );
  private->background = color->pixel;
}

void
gdk_gc_set_font (GdkGC	 *gc,
		 GdkFont *font)
{
}

void
gdk_gc_set_function (GdkGC	 *gc,
		     GdkFunction  function)
{
}

void
gdk_gc_set_fill (GdkGC	 *gc,
		 GdkFill  fill)
{
}

void
gdk_gc_set_tile (GdkGC	   *gc,
		 GdkPixmap *tile)
{
}

void
gdk_gc_set_stipple (GdkGC     *gc,
		    GdkPixmap *stipple)
{
}

void
gdk_gc_set_ts_origin (GdkGC *gc,
		      gint   x,
		      gint   y)
{
  g_warning( "gc_set_ts_origin: what is this good for?" );
}

void
gdk_gc_set_clip_origin (GdkGC *gc,
			gint   x,
			gint   y)
{
  g_warning( "gc_set_clip_origin: what is this good for?" );
}

void
gdk_gc_set_clip_mask (GdkGC	*gc,
		      GdkBitmap *mask)
{
  g_return_if_fail (gc != NULL);
  if (mask)
    g_warning( "gc_set_clip_mask: sorry, I refuse to clip using bitmap." );
}


void
gdk_gc_set_clip_rectangle (GdkGC	*gc,
			   GdkRectangle *rectangle)
{
  GdkGCPrivate *private = (GdkGCPrivate *) gc;

  g_return_if_fail (gc != NULL);
  if (rectangle)
    private->clip = *rectangle;
  else {
    private->clip.x = 0;
    private->clip.y = 0;
    private->clip.width = gdk_screen_width();
    private->clip.height = gdk_screen_height();
  }
} 

void
gdk_gc_set_clip_region (GdkGC		 *gc,
			GdkRegion	 *region)
{
  g_error( "gc_set_clip_region: just don't call me?" );
}

void
gdk_gc_set_subwindow (GdkGC	       *gc,
		      GdkSubwindowMode	mode)
{
}

void
gdk_gc_set_exposures (GdkGC *gc,
		      gint   exposures)
{
}

void
gdk_gc_set_line_attributes (GdkGC	*gc,
			    gint	 line_width,
			    GdkLineStyle line_style,
			    GdkCapStyle	 cap_style,
			    GdkJoinStyle join_style)
{
}

void
gdk_gc_set_dashes (GdkGC *gc,
		   gint	  dash_offset,
		   gchar  dash_list[],
		   gint   n)
{
}

void
gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc)
{
}

