/*--------------------------------------------------------

    Windows utility library for sample

    Copyright (C) 2008 SEGA Corporation Library R&D Dept.
    All Rights Reserved.

    Module  : Windows utility library for sample
    File    : smpWin.h
    Create  : 2008/06/13 (Ver.0.10.01)
    Modify  : 2008/09/12 (Ver.0.10.02)
				SMPWIN_TYPE_FOCUS_IN
				SMPWIN_TYPE_FOCUS_OUT
				を追加。
			  2009/01/13 (Ver.0.10.03)
				smpWinShowWindow()、smpWinUpdateWindow() 関数を追加。
    Version : 0.10.03
    Note    : 

--------------------------------------------------------*/

#ifndef __SMPWIN_H__
#define __SMPWIN_H__

/* キーの状態 */
#define SMPWIN_STATE_SHIFTKEY		(1<<0)
#define SMPWIN_STATE_CONTROLKEY		(1<<1)
#define SMPWIN_STATE_ALTKEY			(1<<2)
#define SMPWIN_STATE_LEFTBUTTON		(1<<3)
#define SMPWIN_STATE_MIDDLEBUTTON	(1<<4)
#define SMPWIN_STATE_RIGHTBUTTON	(1<<5)

/* キーのコード */
#define SMPWIN_KEY_F1		(1<<8)
#define SMPWIN_KEY_F2		(2<<8)
#define SMPWIN_KEY_F3		(3<<8)
#define SMPWIN_KEY_F4		(4<<8)
#define SMPWIN_KEY_F5		(5<<8)
#define SMPWIN_KEY_F6		(6<<8)
#define SMPWIN_KEY_F7		(7<<8)
#define SMPWIN_KEY_F8		(8<<8)
#define SMPWIN_KEY_F9		(9<<8)
#define SMPWIN_KEY_F10		(10<<8)
#define SMPWIN_KEY_F11		(11<<8)
#define SMPWIN_KEY_F12		(12<<8)
#define SMPWIN_KEY_LEFT		(13<<8)
#define SMPWIN_KEY_UP		(14<<8)
#define SMPWIN_KEY_RIGHT	(15<<8)
#define SMPWIN_KEY_DOWN		(16<<8)

/* SMPWIN_TYPE_SIZE の state */
#define SMPWIN_SIZE_RESTORED	0
#define SMPWIN_SIZE_MINIMIZED	1
#define SMPWIN_SIZE_MAXIMIZED	2

/* イベントタイプ */
enum{
	SMPWIN_TYPE_NONE,

	SMPWIN_TYPE_DESTROY,

	SMPWIN_TYPE_FOCUS_IN,
	SMPWIN_TYPE_FOCUS_OUT,

	SMPWIN_TYPE_MOVE,

	SMPWIN_TYPE_SIZE,

	SMPWIN_TYPE_ENTERSIZEMOVE,
	SMPWIN_TYPE_EXITSIZEMOVE,

	SMPWIN_TYPE_KEY_DOWN,
	SMPWIN_TYPE_KEY_UP,

	SMPWIN_TYPE_LEFTBUTTON_DOWN,
	SMPWIN_TYPE_LEFTBUTTON_UP,
	SMPWIN_TYPE_MIDDLEBUTTON_DOWN,
	SMPWIN_TYPE_MIDDLEBUTTON_UP,
	SMPWIN_TYPE_RIGHTBUTTON_DOWN,
	SMPWIN_TYPE_RIGHTBUTTON_UP,

	SMPWIN_TYPE_MOUSE_WHEEL,

	SMPWIN_TYPE_MOUSE_MOVE
};

typedef
	struct{
		unsigned long	m_type;			/* イベントタイプ */

		long			m_winX;			/* ウインドウの座標 */
		long			m_winY;

		long			m_width;		/* クライアントエリアの幅 */
		long			m_height;		/* クライアントエリアの高 */

		long			m_mouseX;		/* マウスの位置(ウインドウ座標系) */
		long			m_mouseY;
		long			m_mouseOldX;
		long			m_mouseOldY;

		long			m_state;
		long			m_code;
	}SMPWINEvent;

typedef void (*SMPWIN_IDLE_PROC)(void);
typedef void (*SMPWIN_WIN_PROC)(unsigned long evtType, void *ptr);

#ifdef EXT
# undef EXT
#endif

#ifndef __SMPWIN_C__
# define EXT extern
#else
# define EXT
#endif

#ifdef __cplusplus
extern "C" {
#endif

EXT int smpWinShowWindow(void);
EXT int smpWinUpdateWindow(void);

EXT void smpWinMainLoopQuit(void);
EXT int smpWinMainLoop(void);

EXT int smpWinSetWinProc(SMPWIN_WIN_PROC winProc);
EXT int smpWinSetIdleProc(SMPWIN_IDLE_PROC idleProc);

EXT void *smpWinGetWindowHandle(void);

EXT int smpWinCreateWindow(const char *title, int x, int y, int width, int height);

EXT void smpWinEnd(void);
EXT int smpWinInit(void);

#ifdef __cplusplus
}
#endif

#endif	/* ifndef __SMPWIN_H__ */
