/* $Id: WidgetsP.h,v 1.3 1997/06/16 20:50:44 archer Exp $
 *	WIDGETSP.H - Global Widget Library definitions
 *
 * Defines the basic X11_widget type insides.
 */
#ifndef _widget_widgetsp_h_included
#define _widget_widgetsp_h_included
#include "config.h"
#include <Widget/Widgets.h>
#include <Widget/Color.h>
/**
 ** A few includes
 **/
#include <sys/types.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif


/**
 ** Extended types
 **/
typedef void		(*x11__handler)(X11_widget,XEvent *);
typedef unsigned int	x11__size;
typedef int		x11__pos;


/**
 ** Basic structure
 **/
struct x11__o {
	X11_widget	list;
	X11_widget	parent;
	X11_widget	child, sibling;
	X11_widget	shell;
/*
 * X11 elements
 */
	Window		id;	/* None until needed */
	long		event_mask;
	Cursor		use_cursor;
	X11_color	border_color,
			background, foreground,
			active_fg, active_bk,
			focus_color,
			tl_color, br_color;
	x11__size	w, h;
	x11__size	border2;	/* border x 2 */
	x11__size	shadow_thickness,
			focus_thickness;
	x11__size	margin_inside;
	x11__pos	x, y;
/*
 * X11 Events Methods
 */
	x11__handler	on_button_press;
	x11__handler	on_button_release;
	x11__handler	on_enter_window;
	x11__handler	on_exit_window;
	x11__handler	on_expose;
	x11__handler	on_key_press;
	x11__handler	on_motion_notify;
	x11__handler	on_resize_window;
	x11__handler	on_special_event;
/*
 * Internal Methods
 */
	x11__handler	on_destruction;
	x11__handler	on_focus_change;
	x11__handler	on_geometry_check;
	x11__handler	on_window_create;
/*
 * Container information
 */
	x11__size	w_min, h_min;
	x11__size	margin_w, margin_h;
	x11__size	hint_w, hint_h;
	x11__pos	hint_x, hint_y;
	boolean		fixed_w, fixed_h,
			fixed_x, fixed_y;
	boolean		labelling;
/*
 * State information
 */
	boolean		has_focus,
			is_depressed,
			is_disabled,
			is_selected,
			is_active,
			is_default;
	boolean		can_focus,
			auto_focus,
			can_active,
			can_default;
	boolean		unmanaged,
			unmapped;
/*
 * Resources
 */
	char		*class;
	char		name[32];
};
#define W_WIDGET	((X11_widget)wdg)
#define OBJECT_P	((X11_widget)object)


/**
 ** Global variables
 **/
extern Display		*x11__screen;
extern X11_widget	x11__widget_root;
extern Window		x11__root_id;
extern GC		x11__default_gc;
extern X11_color	x11__black_pixel,
			x11__white_pixel;
extern boolean		x11__is_monochrome;


/**
 ** Prototypes for widgets
 **/
#define allocator(t)	(t *)x11__widget_malloc(sizeof(t));
extern char		*x11__widget_malloc(int);


/**
 ** Core widget
 **/
extern void	x11__core_press(X11_widget, XEvent *);
extern void	x11__core_release(X11_widget, XEvent *);
extern void	x11__core_enter(X11_widget, XEvent *);
extern void	x11__core_exit(X11_widget, XEvent *);
extern void	x11__core_motion(X11_widget, XEvent *);
extern void	x11__core_geometry(X11_widget, XEvent *);
extern void	x11__core_resize(X11_widget, XEvent *);
extern void	x11__widget_grow(X11_widget);
extern void	x11__core_create(X11_widget, XEvent *);
extern void	x11__core_setup(X11_widget,X11_widget,char *,char *);
extern GC	x11__widget_gc(X11_widget);


/**
 ** Resource management
 **/
extern void	x11__resource_basic(X11_widget);
extern void	x11__resource_init(char *,char *,int *,char **);
extern int	x11__resource_integer(char *, int);
extern void	x11__resource_lookup(X11_widget);
extern char	*x11__resource_value(char *);


/**
 ** Special debugging prototype
 **/
#ifdef DEBUGGING_X11
#define xassert(e,p) if (!(e)) { printf("file %s, line %d:\n",__FILE__,__LINE__);printf p;putchar('\n');abort(); }
#endif


#endif /*_widget_widgetsp_h_included*/
