/*<Header>==============================================================
*
*	CLIP MANAGER / "EIN_CLP1.C"
*
*		[ EIN(tm) project : ウィンドゥクリップ操作補助関数群 ]
*
*	COPYRIGHT  Nam & OZZY  1994, All rights reserved.
*
*-----------------------------------------------------------------------
*	V1.0L01α	94.07.08/Nam	プロトタイプ(OZZYさんの関数を利用)
*</Header>==============================================================*/
#include	<stdio.h>
#include	<stdlib.h>
#include	<string.h>
#include	<snd.h>
#include	<winb.h>
#include	<te.h>
#include	<fntb.h>
#include	<gui.h>
#include	<egb.h>
#include	<msdos.cf>
#include	<loader.h>
#include	<math.h>
#include	<io.h>
#include	<guidbg.h>

#define	EIN_CLIP
#include	"..\eintm.h"

#ifndef NOERR
#define	NOERR	(0)
#endif
#ifndef ERROR
#define	ERROR	(1)
#endif

/* クリップデータ構造体 */
typedef struct {
	WINCLIP		*clip;
	WINCLIP		*visible;
	POINT		svPos;
}	EIN_CLIPWORK;						/* クリップデータ構造体 */

/*<Func>================================================================
*	int		EIN_clipOpen( char *work )
*
*	【概  要】	ウィンドウクリップ全画面化処理
*
*	【機  能】	実行関数内からウィンドウ枠を全画面にする
*
*	【入  力】	*work		:	クリップ退避用ワーク
*
*	【出  力】
*
*	【関数値】	== NOERR	正常終了
*
*	【注  意】	終了後は EIN_clipClose() を呼び出して下さい
*
*	【使用例】
*				char		clp[EINCLIPSIZE];
*
*				EIN_clipOpen( cl );
*				MG_mosDisp(2);
*				WGB_putBlock( guiEgbPtr, 3, (char *)&put ) ;
*				MG_mosDisp(3);
*				EIN_clipClose( clp );
*
*-----------------------------------------------------------------------
*	V11L10	1994.07.08/Nam	(OZZYさんの関数より)
*</Func>==============================================================*/
int		EIN_clipOpen( EIN_CLIPWORK *p )
{
	WINCLIP	*pwclp ;
	WINCTRL	*pctrl ;
	POINT	pos ;

	/* お約束のErrorTrap */
	if ( p == NULL ){
		return ERROR;
	}
	/*	座標系の一時変更	*/
	pos.x = 0 ; pos.y = 0 ;
	MG_PushOrigin( &pos, &p->svPos ) ;

	/*	画面全体のサイズを取得	*/
	MMI_GetControl( &pctrl ) ;
	pwclp = WIN_getClipMemory( &( pctrl->bound ), NULL ) ;

	/*	表示枠を設定する.	*/
	WIN_pushVisible( WIN_copyClip( pwclp ), &p->visible ) ;
	WIN_pushClip( pwclp, &p->clip ) ;

	return NOERR ;
}

/*<Func>================================================================
*	int		EIN_clipClose( char *work )
*
*	【概  要】	ウィンドウクリップ全画面化解除処理
*
*	【機  能】	実行関数内からウィンドウ枠を全画面解除する
*
*	【入  力】	*work		:	クリップ退避用ワーク
*
*	【出  力】	なし
*
*	【関数値】	== NOERR	正常終了
*
*	【注  意】	EIN_clipOpen() の後で呼び出して下さい
*
*	【参  照】	
*
*-----------------------------------------------------------------------
*	V11L10	1994.07.08/Nam	(OZZYさんの関数より)
*</Func>==============================================================*/
int		EIN_clipClose( EIN_CLIPWORK *p )
{
	/* お約束のErrorTrap */
	if ( p == NULL ){
		return ERROR;
	}
	/*	表示枠を復帰する.	*/
	WIN_popClip( p->clip ) ;
	WIN_popVisible( p->visible );
	/* 座標系の復帰 */
	MG_PopOrigin( &p->svPos );

	return NOERR ;
}

