/*
    GDAM - Geoff & Dave's Audio Mixer
    Copyright (C) 1999    Dave Benson, Geoff Matters.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser 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
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser 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

    Contact:
        daveb@ffem.org <Dave Benson>
        geoff@ugcs.caltech.edu <Geoff Matters>
*/
#ifndef __GDAM_KEYBOARD_H_
#define __GDAM_KEYBOARD_H_


typedef struct _GdamKeyboard GdamKeyboard;
typedef struct _GdamKeyboardClass GdamKeyboardClass;

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

#include "gdamkeyboardtrap.h"

#define GDAM_KEYBOARD_ALT_MASK			(1<<24)
#define GDAM_KEYBOARD_CTRL_MASK			(1<<25)

/* You have to use the value of the key (i.e. `a' instead of `A')
 * instead of SHIFT_MASK. */
/*#define GDAM_KEYBOARD_SHIFT_MASK		(1<<26)*/

#define GDAM_KEYBOARD_CONNECT_PRESS		(1<<0)
#define GDAM_KEYBOARD_CONNECT_RELEASE		(1<<1)

GtkType gdam_keyboard_get_type();
#define GDAM_TYPE_KEYBOARD			(gdam_keyboard_get_type ())
#define GDAM_KEYBOARD(obj)              (GTK_CHECK_CAST ((obj), GDAM_TYPE_KEYBOARD, GdamKeyboard))
#define GDAM_KEYBOARD_CLASS(klass)      (GTK_CHECK_CLASS_CAST ((klass), GDAM_TYPE_KEYBOARD, GdamKeyboardClass))
#define GDAM_IS_KEYBOARD(obj)           (GTK_CHECK_TYPE ((obj), GDAM_TYPE_KEYBOARD))
#define GDAM_IS_KEYBOARD_CLASS(klass)   (GTK_CHECK_CLASS_TYPE ((klass), GDAM_TYPE_KEYBOARD))

struct _GdamKeyboardClass {
	GtkObjectClass		object_class;

};
struct _GdamKeyboard {
	GtkObject			object;

	/* trap_map{widget}{key} is the relevant KeyboardTrap. */
	GHashTable*			trap_map;
};

/* There is just one globally shared keyboard in our current model. */
GdamKeyboard*       gdam_keyboard_get_instance();


GdamKeyboardTrap*   gdam_keyboard_get_trap   (GdamKeyboard*  keyboard,
                                              GtkWidget*     widget,
                                              int            key);

void                gdam_keyboard_remove_trap(GdamKeyboard*  keyboard,
                                              GtkWidget*     widget,
                                              int            key);

/* Sets up a widget to handle hotkey events */
void                gdam_keyboard_connect_widget
                                             (GtkWidget*     widget);

/* Given a string such as "a" or "control-[" returns corresponding gdk keyval */
guint 		    gdam_keyboard_parse_key_code (const char* keyname);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif
