#ifndef CODE_KEYP_H
#define CODE_KEYP_H

/*-----------------------------------------------------------------------
 * Xclasses header file
 * ($Id: key_p.h,v 1.2 1998/07/29 23:02:33 schmitzj Exp $)
 * 
 * Copyright (C) 1998 Jürgen Schmitz
 *
 * 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 <Xclasses/Xdisplay.h>
#include <Xclasses/keyclass.h>
#include <Xclasses/dlist.h>
#include <Xclasses/gadget.h>

#define MAXKEYS	256

enum modes {K_EMPTY,K_FREE,K_SELECT,K_SEND,K_ACTIVATE,K_CALLBACK,K_CALLBACKSELECT};

struct keyarray
{
	enum modes		mode;
	unsigned int	key;
	unsigned int	qual;
	class gadget	*to;
	class gadget	*onlyfrom;

	int userdata;
	callback fcb;
// 	void (*hook)(XEvent *,KeySym,char *,int userdata);
// 	void *hookclass;
};

class pkeyclass
{
	friend class keyclass;

public:
	class keyclass *o;

	pkeyclass(void);
	~pkeyclass();

	struct node verkettung;
	Xwindows *win;
	keyarray mykeys[MAXKEYS];

	int Handle(XEvent *,KeySym,char *);
	int FreeHashEntry(unsigned int xkey);
	int FindHash(unsigned int xkey,unsigned int qual);
	int GetQualOf(XEvent *);
	void SendTo(enum modes mode,unsigned int xkey,unsigned int qual,gadget *g,int userd=0,void (*hook)(XEvent *,KeySym,char *,int)=NULL,void (callable::*chook)(XEvent *,KeySym,char *,int)=0,callable *hclass=NULL);
	void SendTo(enum modes mode,char *key,unsigned int qual,gadget *g,int userd=0,void (*hook)(XEvent *,KeySym,char *,int)=NULL,void (callable::*chook)(XEvent *,KeySym,char *,int)=0,callable *hclass=NULL);
};

#endif
