/*
**   ----------------------------------------------------------------- 
**        Copyright (C) 1990, 1991 Sun Microsystems, Inc
**                   All rights reserved.
**         Notice of copyright on this source code
**         product does not indicate publication.
**   
**   RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by
**   the U.S. Government is subject to restrictions as set forth
**   in subparagraph (c)(1)(ii) of the Rights in Technical Data
**   and Computer Software Clause at DFARS 252.227-7013 (Oct. 1988)
**   and FAR 52.227-19 (c) (June 1987).
**   
**     Sun Microsystems, Inc., 2550 Garcia Avenue,
**     Mountain View, California 94043.
**   ----------------------------------------------------------------- 
*/
#ifndef _RootShellP_h
#define _RootShellP_h

#include <X11/Shell.h>
#include <Xol/RootShell.h>

typedef struct	_RootShellRec	*RootShellWidget;

typedef	void	(*RSAddShellProc)    OL_ARGS (( RootShellWidget, Widget ));
typedef	void	(*RSDeleteShellProc) OL_ARGS (( RootShellWidget, Widget ));

typedef	Widget	(*RSShellRegisteredProc) OL_ARGS (( RootShellWidget, Widget ));

typedef	void	(*RSAddRootProc)    OL_ARGS (( RootShellWidget,
					       RootShellWidgetClass ));
typedef	void	(*RSDeleteRootProc) OL_ARGS (( RootShellWidget,
					       RootShellWidgetClass ));

typedef	Widget	(*RSRootRegisteredProc) OL_ARGS (( WidgetClass, Screen *));

typedef	void	(*RSPropChangedProc) OL_ARGS (( Widget ));

extern void _OlAddShellToRootList      OL_ARGS(( Widget, WidgetClass ));
extern void _OlDeleteShellFromRootList OL_ARGS(( Widget, WidgetClass ));

extern void _OlAddShellToDisplayList      OL_ARGS (( Widget ));
extern void _OlDeleteShellFromDisplayList OL_ARGS (( Widget ));
extern void _OlAddShellToScreenList       OL_ARGS (( Widget ));
extern void _OlDeleteShellFromScreenList  OL_ARGS (( Widget ));

#define	XtInheritRSAddShell		((RSAddShellProc)_XtInherit)
#define	XtInheritRSDeleteShell		((RSDeleteShellProc)_XtInherit)
#define	XtInheritRSShellRegistered	((RSShellRegisteredProc)_XtInherit)
#define	XtInheritRSAddRoot		((RSAddRootProc)_XtInherit)
#define	XtInheritRSDeleteRoot		((RSDeleteRootProc)_XtInherit)
#define	XtInheritRSRootRegistered	((RSRootRegisteredProc)_XtInherit)

/***********************************************************************
 *
 * RootShell Widget Private Data
 *
 ***********************************************************************/

#define	VECTOR_INCR	10
#define	VECTORFULL(n, incr)	((n) == (((n) / (incr) + 1) * (incr)) - 1)

/* New fields for the RootShell widget class record */

typedef struct {
    XtResourceList		appl_res;
    Cardinal			num_appl_res;

    RSAddShellProc		add_shell;
    RSDeleteShellProc		delete_shell;
    RSShellRegisteredProc   	shell_registered;

    RSAddRootProc		add_root;
    RSDeleteRootProc		delete_root;
    RSRootRegisteredProc	root_registered;

    RSPropChangedProc		prop_changed;
    
    Widget	    		*root_shells;	/* instance list */
    Cardinal	    		num_roots;	/* num instances */

    XtPointer       		extension;      /* extension */
} RootShellClassPart;

typedef struct _RootShellClassRec {
  	CoreClassPart      	core_class;
	CompositeClassPart 	composite_class;
	ShellClassPart  	shell_class;
	OverrideShellClassPart  override_shell_class;
	RootShellClassPart	root_shell;
} RootShellClassRec;

externalref RootShellClassRec rootShellClassRec;

typedef struct {
	Widget		appl_shell;	
	Widget		*shells;		/* list of shells         */
	Cardinal	num_shells;		/* number of shells       */

#if 0
	Window		input_only;		/* dummy for destruction  */
#endif

	XtEventHandler	prop_notify;		
	XtCallbackList	prop_notify_callback;	

	Atom		root_property;		/* atom of monitored prop */
	String		property_string;	/* value of property	  */
	Time		last_update;		/* last update of prop    */

	XtPointer	user_data;		/* hook for user	  */
} RootShellPart;

typedef  struct _RootShellRec {
	CorePart 	  core;
	CompositePart 	  composite;
	ShellPart 	  shell;
	OverrideShellPart override;
	RootShellPart	  root;
} RootShellRec /* , *RootShellWidget */;

/***********************************************************************
 *
 * DisplayShell Widget Private Data
 *
 ***********************************************************************/

typedef	struct {
	XtPointer	extension;
} DisplayShellClassPart;

typedef struct _DisplayShellClassRec {
  	CoreClassPart      	core_class;
	CompositeClassPart 	composite_class;
	ShellClassPart  	shell_class;
	OverrideShellClassPart  override_shell_class;
	RootShellClassPart	root_shell;
	DisplayShellClassPart	display_shell;
} DisplayShellClassRec;

externalref	DisplayShellClassRec	displayShellClassRec;

typedef	struct  _DisplayShellRec {
	/*
	 * per display application attributes 
	 */

	Cardinal	multi_click_timeout;	/* in milliseconds	    */
	int		beep_volume;		/* Beep volumn percentage   */
	OlDefine	beep;			/* Beep for which levels    */
	Boolean		select_does_preview;	/* Does select preview?	    */
	Boolean		grab_pointer;		/* can we grab the pointer  */
	Boolean		grab_server;		/* can we grab the server   */
	Cardinal	multi_object_count;
	OlBitMask	dont_care;		/*
						 * should use Modifiers,
						 * but can't find a
						 * repesentation type
						 */

	/*
	 * Resources that control accelerators
	 * and mnemonics:
	 */

	Modifiers	mnemonic_modifiers;
	OlDefine	show_mnemonics;
	OlDefine	show_accelerators;
	String		shift_name;
	String		lock_name;
	String		control_name;
	String		mod1_name;
	String		mod2_name;
	String		mod3_name;
	String		mod4_name;
	String		mod5_name;

	OlDefine	help_model;
	Boolean		mouse_status;

	Cardinal	key_remap_timeout;	/* in seconds	*/
#ifdef	sun
	Boolean		use_short_OlWinAttr;
#endif	sun
} DisplayShellPart;

typedef struct {
	CorePart 	  core;
	CompositePart 	  composite;
	ShellPart 	  shell;
	OverrideShellPart override;
	RootShellPart	  root;
	DisplayShellPart  display;
} DisplayShellRec, *DisplayShellWidget;

/***********************************************************************
 *
 * ScreenShell Widget Private Data
 *
 ***********************************************************************/

#define	XtInheritRSPropChangedProc	((RSPropChangedProc)_XtInherit)

typedef	struct {
	RSPropChangedProc	rm_prop_changed;
	XtPointer		extension;
} ScreenShellClassPart;

typedef struct _ScreenShellClassRec {
  	CoreClassPart      	core_class;
	CompositeClassPart 	composite_class;
	ShellClassPart  	shell_class;
	OverrideShellClassPart  override_shell_class;
	RootShellClassPart	root_shell;
	ScreenShellClassPart	screen_shell;
} ScreenShellClassRec;

externalref	ScreenShellClassRec	screenShellClassRec;

typedef	struct {
	OlDynamicScreenCallback	proc;
	XtPointer		closure;
} OlDSCBRec, *OlDynamicScreenCallbacks;

typedef	struct _ScreenShellRec {

	/* per screen application attributes */

	Cardinal	mouse_damping_factor;	/* in points	        */

	Boolean		three_d;		/* use 3-D visuals?	*/

	int		scale;
	char *		scale_map_file;		/* name of scale to screen
						 * resolution map file
						 */

	Dimension	drag_right_distance;
	Dimension	menu_mark_region;

	Pixel		input_focus_color;
	Pixel		text_font_color;
	Pixel		text_background;
	Pixel		control_background;
	Pixel		control_foreground;
	Pixel		control_font_color;
	Pixel		generic_background;	/* bg for everything else */

	_OlAppAttributes *app_attrs;		/* 
						 * only used if someone
						 * calls:
						 * _OlGetAppAttributesRef()
						 */

	OlDynamicScreenCallbacks	dyn_cbs;
	Cardinal			num_dyn_cbs;

	String		ol_cursor_font_name;
	Font		ol_cursor_font_id;
	XFontStruct	*ol_cursor_font_data;

	Boolean		doing_dynamic_res_processing;
} ScreenShellPart;

typedef struct {
	CorePart 	  core;
	CompositePart 	  composite;
	ShellPart 	  shell;
	OverrideShellPart override;
	RootShellPart	  root;
	ScreenShellPart	  screen;
} ScreenShellRec, *ScreenShellWidget;


#endif /* _RootShellP_h */
