/*-
 * Copyright (c) 1999,2000 Qube Software, Ltd.
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of the source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 
 * 2. Any redistribution solely in binary form must conspicuously
 *    reproduce the following disclaimer in documentation provided with the
 *    binary redistribution.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'', WITHOUT ANY WARRANTIES, EXPRESS
 * OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  LICENSOR SHALL
 * NOT BE LIABLE FOR ANY LOSS OR DAMAGES RESULTING FROM THE USE OF THIS
 * SOFTWARE, EITHER ALONE OR IN COMBINATION WITH ANY OTHER SOFTWARE.
 * 
 * 	$Id: event.h,v 1.14 2000/06/19 16:32:09 n_hibma Exp $
 */

#ifndef __event_h__
#define __event_h__

#ifndef DRAW_BEGIN
#define DRAW_BEGIN	namespace Draw {
#define DRAW_END	};
#endif

#include <queue>


DRAW_BEGIN

struct Key
{
    enum {
#define DEFKEY(name, value) name = value,
#include "keysym.h"
#undef DEFKEY
	LastKey			// mainly to avoid compiler warning
    };
};

struct Event
{
    enum Type {			// can be or-ed together if needed
	NoEvent = 0x00,
	Mouse	= 0x01,
	Key	= 0x02,
	Window	= 0x04,
	All	= 0xff
    };

    enum Code {
	None        = 0x00,
	MousePosition,
	MouseMove,
	MouseAccel,
        MousePress,
        MouseRelease,
	MouseFocus,
	KeyPress,
	KeyRelease,
	KeyFocus,

	// Internal events

	// Active means visible to the user / active on the desktop
	WindowActive,
	// The user changed the window size.
	WindowSize,
	// The user changed the window position.
	WindowMove,
	// The user changed the window position and its size.
	WindowMoveSize,
	// The user has pressed the Maximize window button.
	WindowFullscreen,
	// The close button was pressed.
	WindowClose,

	// Called before and after the window has been made fullscreen.
	WindowFullscreenPre,
	WindowFullscreenPost,
	// Called before and after the window has been resized or moved.
	WindowPositionPre,
	WindowPositionPost,
	// Last event to be sent to the various handlers.
	WindowClosed,
    };

    int		ID;		// Producer ID

    Type	type;
    Code	code;

    int		deviceId;	// Id for the device that created the event

    union {
	struct {		// MousePosition
	    int x;
	    int y;
	    int z;
	} mousePosition;

	struct {		// MouseMoveAbs
	    int dx;
	    int dy;
	    int dz;
	} mouseMove;

	struct {		// MouseMoveRel
	    int ddx;
	    int ddy;
	    int ddz;
	} mouseAccel;

	unsigned int buttons;	// MousePress, MouseRelease, the buttons that
				// changed (bitmask)
	    
	unsigned int key;	// KeyPress, KeyRelease, the key that changed
				// (Key::A etc)

	bool fullscreen;	// Window fullscreen (or not that is)
	bool active;		// Window is active

	struct {		// WindowSize, WindowMove, WindowMoveSize
	    unsigned int width;
	    unsigned int height;
	} windowSize;

	bool focus;		// KeyboardFocus/MouseFocus
				// (true: focus gained, false: lost)
    };
};
DRAW_END

#endif /* __event_h__ */
