/*
 *	$Id: ruby.h,v 1.4 1991/11/08 17:41:30 mmnick Exp mmnick $
 *
 *	Copyright (c) 1991 by Markus M. Nick
 *	
 *	Ruby ist Freeware.  Beachten Sie bitte die Nutzungsbedingungen in 
 *	der Dokumentation `docs\ruby.tex'. 
 *
 *	Tabsize: 4
 *
 *	I assume that `short' has 16 Bits!
 */

#ifdef __cplusplus
extern "C" {
#endif

/* ==== Ruby's special extended USERBLK ==== */
typedef	struct {
			int cdecl (*ub_code) _((PARMBLK*));
			OBSPEC ub_spec;		/* original ob_spec */
			short ub_type;		/* original ob_type */
			long ruby_magic;	/* the RUBY_MAGIC */
			short text_offset;	/* offset for drawing the text (pixel) */
		} RUBY_USERBLK;

#define	RUBY_MAGIC	0x09800665L		/* g [m/s^2] */


/* ==== extended ob_flags ==== */

#define RUBY_BUTTON	0x8000		/* flag 15 */
#define	RUBY_TEXT	0x4000		/* flag 14 */

/* ==== eXtended ob_types (for `ruby()') ==== */

#define	XG_FLYBUTTON	17
#define	XG_TITLE		19
#define	XG_BOXTITLE		20
#define	XG_BUTTON		18		/* radio button / check box / button with key */
#define	XG_POPUP		22		/* circle button for popups / popup text button */
#define	XG_HELPBUT		21		/* exclusive help button */
#define	XG_UNDOBUT		31		/* exclusive undo button */

/* ==== eXtended ob_flags (for `ruby()') ==== */

#define	X_UNDOBUT		0x0800	/* XG_BUTTON: additional shortcut [Undo] */

/* ==== eXtended ob_types (Let 'em Fly!) ==== */

#define	LXG_HELPBUT	0x2200		/* exclusive help button */
#define	LXG_UNDOBUT	0x2100		/* exclusive undo button */

/* ==== eXtended ob_flags (Let 'em Fly!) ==== */

#define	LX_FLY		0x1000		/* fly button flag */
#define	LX_RUBY		0x0200		/* marks a RUBY_USERBLK */
#define	LX_LTMFIGNR	0x0800		/* tell's Let 'em Fly! to ignore the button */

/* ==== prototypes ==== */

void mmn_ruby _((OBJECT *tree));
void ruby _((OBJECT *tree));
BOOLEAN rsrc_ruby _((void));

/* in tree[obj] eine RUBY_USERBLK anlegen, voll initialisieren und 
	als ub_type den gleichnamigen Parameter einsetzen
	(fr tree[obj].ob_spec und .ob_type werden auch die neuen Werte 
	 eingesetzt)  */
RUBY_USERBLK *install_ruby_userblk _((OBJECT *tree, int obj, int ub_type));

/* ==== ruby options ==== */

struct RUBY_OPTIONS {
	char *version;
	int btn_10pt_idx;	/* 0/2: 10pt or 11pt check box or radio button */
	char/*void*/ *(*m_alloc) _((size_t siz));	/* pointer to memory allocation function */
};

#ifndef __ruby_c__
extern struct RUBY_OPTIONS ruby_options;

/* ==== other globals ==== */

/* ruby_no_mem() wird aufgerufen, wenn kein Speicher mehr fr die 
	RUBY_USERBLKs zur Verfgung steht.
	Voraussetzung: ruby_no_mem ist != 0 */
extern void (*ruby_no_mem) _((OBJECT *tree, int obj));

/* ruby_hook() wird aufgerufen, bevor sich ruby() in irgendeiner 
	Weise ber ein OBJECT hermacht.  Der Source `stuff\repldlin.c' 
	enhlt ein schnes Beispiel, das auch zeigt, wie man selbst 
	RUBY_USERDEFs kreiert... 

	return:	TRUE -> ruby_hook hat's erledigt, ruby() geht 
					zum nchsten OBJECT im Baum.
			FALSE -> ruby() soll selbst das OBJECT checken
*/
#endif

typedef BOOLEAN (*RUBY_HOOK) _((OBJECT *tree, int obj));

#ifndef __ruby_c__
extern RUBY_HOOK ruby_hook;
#endif 


/* ==== popup stuff ==== */

typedef BOOLEAN (*MITEM_SEL) _((OBJECT *menu, BOOLEAN *mo_choose, int sel_mitem, int *mitem, int *lastkey));

BOOLEAN ruby_popup _((OBJECT *menu, 
	int pulldown_box,	/* I: index of the popup */
	int px, int py,
	int ev_mbmask,		/* I: the buttons to look at (given to evnt_multi()) */
	int ev_mbstate,		/* I: the required button states (given to evnt_multi()) */
	BOOLEAN presel_1st,	/* I: TRUE: preselect 1st item */
	MITEM_SEL item_sel,	/* I: function called when an item is selected */
	GRECT *tit_rect,	/* I: title text frame (function terminates when entered) */
	BOOLEAN *mo_choose,	/* I: TRUE: choosing with mouse */
	int *mitem,			/* O: selected menu-item */
	int *lastkey,		/* O: key-code, der das Verlassen verursacht hat */
	BOOLEAN *bgr_saved));/*O: TRUE: background could be saved */

enum POP_ACTION { pop_next, pop_prev, pop_choose };

BOOLEAN pop_it_up _((
	OBJECT *tree,	/* I: the dialogue tree containing the button `btn' */
	int btn,		/* I: the button with containing the text of the popup selection */
	int info,		/* I: the index of the info text left handed to the popup button (will be highlighed) */
	OBJECT *pop,	/* I: the tree containing the popup menu */
	int popbox,		/* I: the index of the popup itself (usually 0) */
	enum POP_ACTION action,	/* I: which action to perform */
	BOOLEAN wrap_around,	/* I: auto wrap around (useful for cycling) */
	int active_state,		/* I: the state which marks the active button */
	BOOLEAN redraw_button,	/* I: automatic button redraw (only for G_BUTTON/G_STRING in both popup and button itself */
	int ev_mbmask,			/* I: the buttons to look at (given to evnt_multi()) */
	int ev_mbstate,			/* I: the required button states (given to evnt_multi()) */
	BOOLEAN key_call,		/* I: TRUE: call by shortcut, FALSE: call by mouse click */
	int *mitem,				/* I/O: the active/selected button */
	int *lastkey,			/* O: key-code, der das Verlassen verursacht hat */
	BOOLEAN *bgr_saved));	/* O: TRUE: background could be saved */

#ifndef __ruby_pop_c__
extern int release_time;/* Zeit, die auf das Loslassen der Maustaste vor 
							dem eigentlichen Popup gewartet wird */
#endif /* ndef __ruby_pop_c__ */


/* ==== Stuff from rubyinit.c ==== */

BOOLEAN ruby_init _((void));	/* see rubyinit.c for details and documentation */
void ruby_exit _((void));


/* ==== Stuff from repldlin.c ==== */

void install_dash_lines_hook _((void));



#ifdef __cplusplus
}
#endif

/* -eof- */
