/* 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.
 */
#ifndef __GDK_PRIVATE_H__
#define __GDK_PRIVATE_H__

#include <curses.h>
/* IDIOTS! calling library macros "clear" and "refresh" is asking for trouble */ 
#undef refresh
#undef clear
#include <gdk/gdktypes.h>

#define FULL ((void *) -1)
#define FX 8	/* Font size X */
#define FY 8
#define MinFX 80 /* Minimal size of window */
#define MinFY 80

typedef int KeySym;
extern int gdk_use_colors;

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */


typedef struct _GdkWindowPrivate       GdkWindowPrivate;
typedef struct _GdkWindowPrivate       GdkPixmapPrivate;
typedef struct _GdkImagePrivate	       GdkImagePrivate;
typedef struct _GdkGCPrivate	       GdkGCPrivate;
typedef struct _GdkColormapPrivate     GdkColormapPrivate;
typedef struct _GdkColorInfo           GdkColorInfo;
typedef struct _GdkVisualPrivate       GdkVisualPrivate;
typedef struct _GdkFontPrivate	       GdkFontPrivate;
typedef struct _GdkCursorPrivate       GdkCursorPrivate;
typedef struct _GdkEventFilter	       GdkEventFilter;
typedef struct _GdkClientFilter	       GdkClientFilter;
typedef struct _GdkColorContextPrivate GdkColorContextPrivate;
typedef struct _GdkRegionPrivate       GdkRegionPrivate;


struct _GdkWindowPrivate
{
  GdkWindow window;
  GdkWindow *parent;

  WINDOW *cwin;
  GdkRectangle cvisible;	/* Absolute coordinates */

  int visible;	
  gint16 x, xabs;
  gint16 y, yabs;
  gint16 cursorx, cursory;
  guint16 width;
  guint16 height;
  guint8 resize_count;
  guint8 window_type;
  guint ref_count;
  guint destroyed : 2;
  gint extension_events;
  gchar *title;
  char fill;

  GList *filters;
  GList *children;
};

struct _GdkImagePrivate
{
  GdkImage image;
};

struct _GdkGCPrivate
{
  GdkGC gc;
  GdkWindow *gwin;
  int foreground, background;
  GdkRectangle clip;
  int ref_count;
};

typedef enum {
  COLOR_INFO_IGNORE_ME
} GdkColorInfoFlags;

struct _GdkColorInfo
{
  GdkColorInfoFlags flags;
  guint ref_count;
};

struct _GdkColormapPrivate
{
  GdkColormap colormap;
};

struct _GdkVisualPrivate
{
  GdkVisual visual;
  void *xvisual;	/* Nasty hack for binary compatibility */
};

struct _GdkFontPrivate
{
  GdkFont font;
  guint ref_count;
};

struct _GdkCursorPrivate
{
  GdkCursor cursor;
};

struct _GdkDndCursorInfo {
};
typedef struct _GdkDndCursorInfo GdkDndCursorInfo;

struct _GdkDndGlobals {
};
typedef struct _GdkDndGlobals GdkDndGlobals;

struct _GdkEventFilter {
  GdkFilterFunc function;
  gpointer data;
};

struct _GdkClientFilter {
  GdkAtom       type;
  GdkFilterFunc function;
  gpointer      data;
};


struct _GdkColorContextPrivate
{
  GdkColorContext color_context;
};

struct _GdkRegionPrivate
{
  GdkRegion region;
};

typedef enum {
  GDK_DEBUG_MISC          = 1 << 0,
  GDK_DEBUG_EVENTS        = 1 << 1,
  GDK_DEBUG_DND           = 1 << 2,
  GDK_DEBUG_COLOR_CONTEXT = 1 << 3,
  GDK_DEBUG_XIM           = 1 << 4
} GdkDebugFlag;

void gdk_events_init (void);
void gdk_window_init (void);
void gdk_visual_init (void);
void gdk_dnd_init    (void);

void gdk_image_init  (void);
void gdk_image_exit (void);

void gdk_window_add_colormap_windows (GdkWindow *window);
void gdk_window_destroy_notify	     (GdkWindow *window);

/* If you pass x = y = -1, it queries the pointer
   to find out where it currently is.
   If you pass x = y = -2, it does anything necessary
   to know that the drag is ending.
*/
void gdk_dnd_display_drag_cursor(gint x,
				 gint y,
				 gboolean drag_ok,
				 gboolean change_made);

extern gint		 gdk_debug_level;
extern gint		 gdk_show_events;
extern gint		 gdk_use_xshm;
extern gint		 gdk_stack_trace;
extern gchar		*gdk_display_name;
extern gint		 gdk_screen;
extern GdkWindowPrivate	 gdk_root_parent;
extern GdkDndGlobals	 gdk_dnd;
extern GdkWindow	*selection_owner[];
extern gchar		*gdk_progclass;
extern gint		 gdk_error_code;
extern gint		 gdk_error_warnings;
extern gint              gdk_null_window_warnings;
extern GList            *gdk_default_filters;
extern const int         gdk_nevent_masks;
extern const int         gdk_event_mask_table[];

extern GdkWindowPrivate *gdk_xgrab_window;  /* Window that currently holds the
					     * x pointer grab
					     */

/* Debugging support */

#ifdef G_ENABLE_DEBUG

#define GDK_NOTE(type,action)		     G_STMT_START { \
    if (gdk_debug_flags & GDK_DEBUG_##type)		    \
       { action; };			     } G_STMT_END

#else /* !G_ENABLE_DEBUG */

#define GDK_NOTE(type,action)
      
#endif /* G_ENABLE_DEBUG */

extern guint gdk_debug_flags;


#ifdef __cplusplus
}
#endif /* __cplusplus */

extern GdkWindow *fg_window;
extern GdkWindow *kbd_window;
extern GdkVisual *system_visual;
extern GdkFont *only_font;

extern void gdk_window_expose (GdkWindowPrivate *win);
extern void gdk_font_init (void);
extern void gdk_color_init (void);
extern void gdk_initial (void); /* initial message */
extern void gdk_statusline (char *msg);
extern void gdk_statusline_err (char *msg);

extern int gdk_event_queue (GdkEvent *event, GdkWindowPrivate *window_private);
extern GdkEvent *gdk_event_new (void);

#endif /* __GDK_PRIVATE_H__ */

