/*************************************************************************
*	CCI 用ライブラリ・ヘッダファイル
*************************************************************************/
#ifndef	_LIB_H
#define	_LIB_H

/*	"stdio.h"		------------------------------------------------*/
#ifndef	SEEK_SET
#define	SEEK_SET	(0)	/* From_beginning	*/
#define	SEEK_CUR	(1)	/* From_current		*/
#define	SEEK_END	(2)	/* From_end			*/
#endif

#ifndef	BUFSIZ
#	define	BUFSIZ		(512)
#endif

/*	"time.h"		------------------------------------------------*/
#ifndef	CLOCKS_PER_SEC
#	define	CLOCKS_PER_SEC	100
#endif

#ifndef	CANCEL
#	define	CANCEL	(-1)
#endif

#ifndef	C_BLACK
#define	C_BLACK		0
#define	C_BLUE		1
#define	C_RED		2
#define	C_MAGENTA	3
#define	C_GREEN		4
#define	C_CYAN		5
#define	C_YELLOW	6
#define	C_WHITE		7
#define	C_HBLACK	8
#define	C_HBLUE		9
#define	C_HRED		10
#define	C_HMAGENTA	11
#define	C_HGREEN	12
#define	C_HCYAN		13
#define	C_HYELLOW	14
#define	C_HWHITE	15

#define	C_THROUGH	0
#define	C_MBLACK	1
#endif

#ifndef	PSET
#define	PSET	0
#define	PRESET	1
#define	OR		2
#define	AND		3
#define	XOR		4
#define	NOT		5
#define	OPAQUE	9
#endif

#ifndef	MASKSET
#define	MASKSET		13
#define	MASKRESET	14
#define	MASTNOT		15
#endif

#ifndef	COLMIX
#define	COLMIX(c1,c2)	(0x1000|(((c1)&15)<<4)|((c2)&15))
#endif

/*************************************************************************
*	キー入力，かな漢字変換システム用
*************************************************************************/

#ifndef	KAN_ROUMAZIOFF
#define	KAN_ROUMAZIOFF	0x00000010
#define	KAN_ROUMAZI		0x00000020
#define	KAN_HANKAKU		0x00000040
#define	KAN_ZENKAKU		0x00000080
#define	KAN_EISUU		0x00000100
#define	KAN_KATAKANA	0x00000200
#define	KAN_HIRAGANA	0x00000400
#define	KAN_MODELOCKOFF	0x00000000
#define	KAN_MODELOCK	0x00010000
#define	KAN_EISYOU		0x00000000
#define	KAN_EIDAI		0x00020000
#endif

#ifndef	_KAN_KM
#define	_KAN_KM
int	_kan_km;
#endif

#ifndef	KAN_SETMODE_HAN
#define	KAN_SETMODE_HAN()	KBF_kan_setMode(KAN_HANKAKU|KAN_EISUU|KAN_EISYOU)
#endif

#ifndef	KAN_SETMODE_JNP
#define	KAN_SETMODE_JNP()	\
	_kan_km = KBF_kan_getMode();									\
	if ( _kan_km < 0 ) { KBF_kan_on(); _kan_km = KBF_kan_getMode();	\
	_kan_km = (_kan_km & 0xFFFFF0FF) | KAN_HIRAGANA;				\
	KBF_kan_setMode(_kan_km);
#endif

/*************************************************************************
*	マウス
*************************************************************************/

#ifndef	MOS_CON
#define	MOS_CON()	MOS_curDisp(1)
#define	MOS_COFF()	MOS_curDisp(0)
#define	MOS_DEC()	MOS_curDisp(2)
#define	MOS_INC()	MOS_curDisp(3)
#endif

/*************************************************************************
*	イベント処理用
*************************************************************************/

#define	GET_EVTSBJ_PTR(sbj)	GetEvtSbjPtr(sbj)
/*	構造体がつかえるようになれば sbj->ptr でOk	*/

#ifndef	EVT_CANCEL
#define	EVT_CANCEL	(-1)
#define	EVT_BREAK	(-2)
#endif

#ifndef	EVTIGN_MOUSE
#define	EVTIGN_MOUSE	(1)		/* マウスイベント禁止	*/
#define	EVTIGN_KEY		(2)		/* キーイベント禁止		*/
#endif

#ifndef	EVTYPE_KEY
#define	EVTYPE_KEY		(1)
#define	KEYEVT_ADR		(0)	/* キーアドレスが一致		*/
#define	KEYEVT_SHIFT	(1)	/* キーシフトも一致			*/
#endif

#ifndef	EVTYPE_MOUSE
#define	EVTYPE_MOUSE	(2)
#define	EVTYPE_MOS2		(3)	/* page 0 用マウスイベント	*/
#endif

#ifndef	BTN_LEFT
#define	BTN_LEFT		(1)
#define	BTN_RIGHT		(2)
#define	MOSEVT_BTN		(0x01)	/* ボタンタイプ					*/
#define	MOSEVT_NOT		(0x02)	/* ボタン反転タイプ				*/
#define	MOSEVT_NOACT	(0x03)	/* ボタン選択アクションなし		*/
#define	MOSEVT_AREA		(0x04)	/* 指定エリア					*/
#define	MOSEVT_OUTAREA	(0x05)	/* 指定エリア外					*/
#define	MOSEVT_BTNOLY	(0x06)	/* ボタンが押された場合			*/
#define	MOSEVT_MOVE		(0x07)	/* カーソルに移動があった場合	*/
#define	MOSEVT_OUTBTN	(0x08)	/* 範囲外でボタンON				*/

#define	MOSEVT_REPEAT	(0x10)	/* リピートタイプ（ボタン）		*/
#define	MOSEVT_QUICK	(0x10)	/* クイックタイプ（ﾘﾋﾟｰﾄと同じ）	*/
#endif

/*************************************************************************
*	ダイアログ用
*************************************************************************/

#ifndef	DLGPOS_MOS_SET_HOME
#define	DLGPOS_MOS_SET_HOME		(0x10010)	/* マウス位置（左上）	*/
#define	DLGPOS_MOS_SET_CENTER	(0x10020)	/* マウス位置中央		*/
#define	DLGPOS_CENTER_OF_SCN	(0x10030)	/* 画面中央				*/
#endif

#ifndef	DLGMSG_POS_CONTINUE
#define	DLGMSG_POS_CONTINUE		(-1)
#define	DLGMSG_POS_CENTERING	(-2)
#endif

/*************************************************************************
*	メニュー処理用
*************************************************************************/

/*	"apl028.h"		------------------------------------------------*/
#ifndef	MNU_BLK
#define	MNU_BLK	(0)
#define	MNU_MSG	(1)
#define	MNU_NOR	(2)
#define	MNU_DIG	(3)
#define	MNU_STR	(4)
#define	MNU_SEL	(5)
#define	MNU_IGN	(0x80)	/* 実行禁止	*/

#define	MNUATT_EXIT	(1)		/* EXIT ボタン付	*/
#define	MNUATT_LOOP	(2)		/* LOOP フラグ		*/
#endif

/*	check!!	"menu.h"	*/
#ifndef	MENU_SURE_OK
#define	MENU_SURE_OK		(1)
#define	SELBTN_ATT_LEFT		(0)	/* 左詰め表示				*/
#define	SELBTN_ATT_CENTER	(1)	/* メッセージのセンタリング	*/
#endif

/*************************************************************************
*	ファイルダイアログ
*************************************************************************/

#ifndef	FSORT_RVS
#	define	FSORT_RVS	(0x80)
#	define	FSORT_OFF	(0)
#	define	FSORT_FILE	(1)
#	define	FSORT_SUB	(2)
#	define	FSORT_DATE	(3)
#endif


/*************************************************************************
*	時間表記
*************************************************************************/

#ifndef	TM_SEC
#define	TM_SEC(tm)		(tm[0])	/* 0...59		*/
#define	TM_MIN(tm)		(tm[1])	/* 0...59		*/
#define	TM_HOUR(tm)		(tm[2])	/* 0...23		*/
#define	TM_MDAY(tm)		(tm[3])	/* 1...31		*/
#define	TM_MON(tm)		(tm[4])	/* 0...11		*/
#define	TM_YEAR(tm)		(tm[5])	/* 1900...		*/
#define	TM_WDAY(tm)		(tm[6])	/* Sunday 0...6	*/
#define	TM_YDAY(tm)		(tm[7])	/* 0...365		*/
#define	TM_ISDST(tm)	(tm[8])	/* daylight 	*/
#endif

/*************************************************************************
*	RS-232C
*************************************************************************/

#define	NTM_RSRESET()	NTM_rsPause( 0 )
#define	NTM_RSPAUSE()	NTM_rsPause( 1 )
#define	NTM_RSDEC()		NTM_rsPause( 2 )
#define	NTM_RSINC()		NTM_rsPause( 3 )
#define	NTM_RSDEC2()	NTM_rsPause( 4 )
#define	NTM_RSINC2()	NTM_rsPause( 5 )

#endif
