//-----------------------------------------------------------------------------
// SYSTEM
//-----------------------------------------------------------------------------

#ifndef _NWSYSTEM_H_
#define _NWSYSTEM_H_

//-----------------------------------------------------------------------------

#define NWDEBUG
#define NWASSERT(x)	while(!(x))

#define NWMALLOC	hlMalloc
#define NWREALLOC	hlRealloc
#define NWFREE		hlFree

#define NWDELETE(x) if (x) { delete x; x = NULL; }

#define NWSCALX(x) ((x)*pGlobal->fAspectX)
#define NWSCALY(y) ((y)*pGlobal->fAspectY)

#define NW_PERIPHERAL PDS_PERIPHERAL
#define nwGetPeripheral pdGetPeripheral

extern NWINFORMATION sInfo;
//-----------------------------------------------------------------------------

#define NW_FORM_DRAW		(0x00000001)
#define NW_FORM_FRAME		(0x00000002)
#define NW_FORM_RESIZE		(0x00000010)
#define NW_FORM_SHADOW		(0x00000020)
#define NW_FORM_CAPTION		(0x00000100)
#define NW_FORM_SYSTEM		(0x00000200)
#define NW_FORM_MINIMUM		(0x00000400)
#define NW_FORM_MAXIMUM		(0x00000800)
#define NW_FORM_MAINMENU	(0x00001000)

#define NW_FORM_DESKTOP		(0)
#define NW_FORM_DIALOG		(	\
			NW_FORM_DRAW	|	\
			NW_FORM_SHADOW	|	\
			NW_FORM_FRAME	|	\
			NW_FORM_CAPTION	|	\
		0 )
#define NW_FORM_NORMAL		(	\
			NW_FORM_DRAW	|	\
			NW_FORM_SHADOW	|	\
			NW_FORM_FRAME	|	\
			NW_FORM_RESIZE	|	\
			NW_FORM_CAPTION	|	\
			NW_FORM_MINIMUM	|	\
			NW_FORM_MAXIMUM	|	\
			NW_FORM_SYSTEM	|	\
		0 )

//-----------------------------------------------------------------------------

typedef enum {
	NW_CLASS_IGNORE		= 0x0000	,
	NW_CLASS_BASE					,
	NW_CLASS_LIST					,
	NW_CLASS_RING					,
	NW_CLASS_IMAGELIST				,
	NW_CLASS_BITMAP					,
	NW_CLASS_FONT					,
	NW_CLASS_CURSOR					,
	NW_CLASS_COMMAND				,
	NW_CLASS_GLOBAL					,
	NW_CLASS_CONTROL	= 0x0100	,
	NW_CLASS_GRAPHIC				,
	NW_CLASS_POPUPMENU				,
	NW_CLASS_MENUITEM				,
	NW_CLASS_SCROLL					,
	NW_CLASS_EDIT					,
	NW_CLASS_SPINEDIT				,
	NW_CLASS_VIEW					,
	NW_CLASS_LISTBOX				,
	NW_CLASS_CAPTION				,
	NW_CLASS_BUTTON					,
	NW_CLASS_CHECKBOX				,
	NW_CLASS_FORM		= 0xffff	,
	NW_CLASS_PAD = 0xffffffff
} NWCLASSID;

typedef enum {
	NW_CURSOR_ARROW		,
	NW_CURSOR_WAIT		,
	NW_CURSOR_POINT		,
	NW_CURSOR_HAND		,
	NW_CURSOR_SIZENS	,
	NW_CURSOR_SIZEWE	,
	NW_CURSOR_SIZENWSE	,
	NW_CURSOR_SIZENESW	,
	NW_CURSOR_PAD = 0xffffffff
} NWCURSORNO;

typedef enum {
	NW_Z_DESKTOP	=0x00000000,
	NW_Z_BOTTOM		=0x00100000,
	NW_Z_NORMAL		=0x00200000,
	NW_Z_TOP		=0x00300000,
	NW_Z_TOPMOST	=0x00400000,
	NW_Z_EXTEND		=0x01000000,
	NW_Z_PAD = 0xffffffff
} NWZORDER;

typedef enum {
	NW_COLOR_BODY		,
	NW_COLOR_BODYEDGE	,
	NW_COLOR_FONT		,
	NW_COLOR_CAPTION	,
	NW_COLOR_CAPTIONEDGE,
	NW_COLOR_CAPTIONFONT,
	NW_COLOR_BACKGROUND	,
	NW_COLOR_MENU		,
	NW_COLOR_MENUFONT	,
	NW_COLOR_CHECKBOX	,
	NW_COLOR_PAD = 0xffffffff
} NWCOLORARRAY;

typedef enum {
	NW_MSG_IDLE			,
	NW_MSG_COMMAND		,
	NW_MSG_SYSCOMMAND	,
	NW_MSG_PAINT		,
	NW_MSG_MOUSE_DOWN	,
	NW_MSG_MOUSE_UP		,
	NW_MSG_MOUSE_MOVE	,
	NW_MSG_KEY_DOWN		,
	NW_MSG_KEY_UP		,
	NW_MSG_DIALOG		,
	NW_MSG_RESIZE		,
	NW_MSG_SHOW			,
	NW_MSG_HIDE			,
	NW_MSG_SHORTCUT		,
	NW_MSG_PAD = 0xffffffff
} NWMSG;

typedef enum {
	NW_SYS_CLOSE	= 0x0100	,
	NW_SYS_MINIMUM				,
	NW_SYS_MAXIMUM				,
	NW_SYS_NORMAL				,
	NW_SYS_ACTIVATE				,
	NW_CMD_ONCLICK	= 0x1000	,
	NW_CMD_ONMOUSEDOWN			,
	NW_CMD_ONMOUSEMOVE			,
	NW_CMD_ONMOUSEUP			,
	NW_CMD_ONPAINT				,
	NW_CMD_ONACTIVATE			,
	NW_CMD_ONKEYDOWN			,
	NW_CMD_ONKEYUP				,
	NW_CMD_ONDIALOG				,
	NW_CMD_ONRESIZE				,
	NW_CMD_ONSHOW				,
	NW_CMD_ONHIDE				,
	NW_CMD_ONSHORTCUT			,
	NW_CMD_ONIDLE				,
	NW_CMD_PAD = 0xffffffff
} NWCMD;

typedef enum {
	NW_FORMSTATUS_NORMAL	,
	NW_FORMSTATUS_MINIMUM	,
	NW_FORMSTATUS_MAXIMUM	,
	NW_FORMSTATUS_PAD = 0xffffffff
} NWFORMSTATUS;

typedef enum {
	NW_CHECKSTYLE_CHECK		,
	NW_CHECKSTYLE_CIRCLE	,
	NW_CHECKSTYLE_BOX		,
	NW_CHECKSTYLE_CROSS		,
	NW_CHECKSTYLE_PAD = 0xffffffff
} NWCHECKSTYLE;

typedef enum {
	NW_CALLBACK_FONT_CHANGING	,
	NW_CALLBACK_FONT_CHANGED	,
	NW_CALLBACK_PAD = 0xffffffff
} NWCALLBACKCONTEXT;

#define NW_DLG_YES		(0x00000001)
#define NW_DLG_NO		(0x00000002)
#define NW_DLG_OK		(0x00000004)
#define NW_DLG_CANCEL	(0x00000008)
#define NW_DLG_RETRY	(0x00000010)
#define NW_DLG_ABORT	(0x00000020)

typedef enum {
	NW_DLGRET_YES		,
	NW_DLGRET_NO		,
	NW_DLGRET_OK		,
	NW_DLGRET_CANCEL	,
	NW_DLGRET_RETRY		,
	NW_DLGRET_ABORT		,
	NW_DLGRET_PAD = 0xffffffff
} NWDLGRET;

//-----------------------------------------------------------------------------
class NWCLASS;
typedef NWCLASS *PNWCLASS;
class NWLIST;
typedef NWLIST *PNWLIST;
class NWRING;
typedef NWRING *PNWRING;
class NWIMAGELIST;
typedef NWIMAGELIST *PNWIMAGELIST;
class NWCOMMAND;
typedef NWCOMMAND *PNWCOMMAND;
class NWBITMAP;
typedef NWBITMAP *PNWBITMAP;
class NWFONT;
typedef NWFONT *PNWFONT;
class NWCURSOR;
typedef NWCURSOR *PNWCURSOR;
class NWGLOBAL;
typedef NWGLOBAL *PNWGLOBAL;
class NWCONTROL;
typedef NWCONTROL *PNWCONTROL;
class NWGRAPHIC;
typedef NWGRAPHIC *PNWGRAPHIC;
class NWCAPTION;
typedef NWCAPTION *PNWCAPTION;
class NWBUTTON;
typedef NWBUTTON *PNWBUTTON;
class NWCHECKBOX;
typedef NWCHECKBOX *PNWCHECKBOX;
class NWSCROLL;
typedef NWSCROLL *PNWSCROLL;
class NWEDIT;
typedef NWEDIT *PNWEDIT;
class NWSPINEDIT;
typedef NWSPINEDIT *PNWSPINEDIT;
class NWVIEW;
typedef NWVIEW *PNWVIEW;
class NWLISTBOX;
typedef NWLISTBOX *PNWLISTBOX;
class NWPOPUPMENU;
typedef NWPOPUPMENU *PNWPOPUPMENU;
class NWMENUITEM;
typedef NWMENUITEM *PNWMENUITEM;
class NWFORM;
typedef NWFORM *PNWFORM;
class NWCONSOL;
typedef NWCONSOL *PNWCONSOL;
class NWINFO;
typedef NWINFO *PNWINFO;
class NWPERFORM;
typedef NWPERFORM *PNWPERFORM;
class NWTEXVIEW;
typedef NWTEXVIEW *PNWTEXVIEW;
class NWPERI;
typedef NWPERI *PNWPERI;
class NWFIBER;
typedef NWFIBER *PNWFIBER;
class NWDESKTOP;
typedef NWDESKTOP *PNWDESKTOP;

typedef void* NWHANDLE;
typedef void (*PNWCALLBACK)( NWCALLBACKCONTEXT eCtx, void* pParam );

//-----------------------------------------------------------------------------

typedef enum {									// アラインコントロール
	alNone		,								// なし
	alTop		,								// 上辺
	alBottom	,								// 下辺
	alLeft		,								// 左辺
	alRight		,								// 右辺
	alClient	,								// 領域
	alPad = 0xffffffff
} NWALIGN, *PNWALIGN;

typedef struct {								// ポイント構造体
	int			nX;
	int			nY;
} NWPOINT, *PNWPOINT;

typedef struct {								// 矩形構造体
	int			nX;
	int			nY;
	int			nW;
	int			nH;
} NWRECT, *PNWRECT;

typedef struct {								// カーソル情報
	PNWBITMAP	pBM;
	int			nX;
	int			nY;
	int			nW;
	int			nH;
	int			nCX;
	int			nCY;
} NWCSRINFO, *PNWCSRINFO;

typedef unsigned long NWCOLOR, *PNWCOLOR;		// カラー情報
typedef union {
	struct {
		unsigned char b;
		unsigned char g;
		unsigned char r;
		unsigned char a;
	} ARGB;
	NWCOLOR		c;
} NWPACKED;

typedef struct {
	int			nFormat;
	int			nW;
	int			nH;
	void*		pMemory;
} NWTEXTURE, *PNWTEXTURE;

typedef struct {
	int			nGBIX;
	int			nNext0;
	int			nGlobalIndex;
	int			pad;
	int			nPVRT;
	int			nNext1;
	int			nTextureType;
	short		nW;
	short		nH;
} NWPVR, *PNWPVR;

typedef struct {
	float		fX;
	float		fY;
	float		fU;
	float		fV;
	NWCOLOR		sColor;
} NWVERTEX, *PNWVERTEX;

typedef struct {
	PNWCONTROL	pTarget;
	NWMSG		eMsg;
	int			nParamW;
	void*		pParamL;
} NWMESSAGE, *PNWMESSAGE;

typedef struct {
	PNWCONTROL	pSender;
	int			nParam[7];
} NWPARAM, *PNWPARAM;

typedef struct _MENU_ {
	int			bEnabled;
	int			bVisible;
	int			nIconIndex;
	int			nTag;
	int			nAccelKey;
	char		*pCaption;
	NWCMD		eCommand;
	_MENU_		**ppSubMenu;
} NWMENUTEMPLATE, *PNWMENUTEMPLATE;

typedef struct {
	PNWBITMAP	pBitmap;
	NWRECT		sRect;
} NWIMAGETIP, *PNWIMAGETIP;

//-----------------------------------------------------------------------------
#endif
