www.pudn.com > emGUI.rar > device.c


/* 
 *  Screen Device Driver 
 * 
 * 
 *  COPYRIGHT (c) 2001 - 2010. 
 *  emTech System Corporation. 
 * 
 *  The license and distribution terms for this file may be 
 *  found in found in the file LICENSE. 
 */ 
 
/*	Huangf emcore@263.net 
 */ 
  
#include "emGUI.h" 
#include "lcd.h" 
 
#include  
 
static PSD scr_open( 
	PSD psd 
) 
{ 
	return psd; 
} 
 
static void scr_close( 
	PSD psd 
) 
{ 
} 
 
SCREENDEVICE scrdev = { 
	scr_open, 
	scr_close, 
	(void *)_lcd_putpixel, 
	(void *)_lcd_getpixel, 
	(void *)_lcd_hline, 
	(void *)_lcd_vline, 
	(void *)_lcd_fillrect, 
	(void *)_lcd_bitmap, 
	(void *)_lcd_switchbase, 
	(void *)_lcd_savescreen, 
	(void *)_lcd_restorescreen, 
	(void *)_lcd_calcmemgcsize 
}; 
 
int ScreenOpen() 
{ 
	if (scrdev.Open(&scrdev) == NULL){ 
		return FALSE; 
	} 
 
	return TRUE; 
} 
 
void ScreenClose() 
{ 
	scrdev.Close(&scrdev); 
} 
 
void DrawPixel( 
	unsigned short *base, 
	int	x, 
	int	y, 
	unsigned char c, 
	int mode 
) 
{ 
	int xorm = 0; 
	 
	if (mode == GR_XOR){ 
		xorm = 1; 
	} 
	scrdev.DrawPixel( 
		base, 
		x, 
		y, 
		c, 
		xorm 
	); 
}		 
 
int	ReadPixel( 
	unsigned short *base, 
	int x, 
	int y 
) 
{ 
	return scrdev.ReadPixel( 
		base, 
		x, 
		y 
	); 
	 
} 
 
int	DrawHorzLine( 
	unsigned short *base, 
	int x1, 
	int y, 
	int x2, 
	unsigned char c, 
	int mode 
) 
{ 
	int xorm = 0; 
	 
	if (mode == GR_XOR){ 
		xorm = 1; 
	} 
 
	return scrdev.DrawHorzLine( 
		base, 
		x1, 
		y, 
		x2, 
		c, 
		mode 
	); 
} 
 
int DrawVertLine( 
	unsigned short *base, 
	int x, 
	int y1, 
	int y2, 
	const char c, 
	int mode 
) 
{ 
	int xorm = 0; 
 
	if (mode == GR_XOR){ 
		xorm = 1; 
	} 
 
	return scrdev.DrawVertLine( 
		base, 
		x, 
		y1, 
		y2, 
		c, 
		mode 
	); 
} 
 
int FillRect( 
	unsigned short *base, 
	int x1, 
	int y1, 
	int x2,  
	int y2, 
	int c 
) 
{ 
	return scrdev.FillRect( 
		base, 
		x1, 
		y1, 
		x2, 
		y2, 
		c 
	); 
} 
 
int DrawBitmap( 
	unsigned short *base, 
	int x0, 
	int y0, 
	int width, 
	int height, 
	unsigned char *pcc, 
	int mode 
) 
{ 
	int xorm = 0; 
 
	if (mode == GR_XOR) 
		xorm = 1; 
	return scrdev.DrawBitmap( 
		base, 
		x0, 
		y0, 
		width, 
		height, 
		pcc, 
		mode 
	); 
} 
 
void SwitchDrawArea(void *drawArea) 
{ 
	scrdev.SwitchDrawArea(drawArea); 
} 
 
void SaveDrawArea( 
	void *drawarea, 
	void *memory, 
	int	 l, 
	int  t, 
	int  r, 
	int  b 
) 
{ 
	scrdev.SaveDrawArea( 
		drawarea, 
		memory, 
		l, 
		t, 
		r, 
		b 
	); 
} 
 
void RestoreDrawArea( 
	void *drawarea, 
	void *memory, 
	int	 l, 
	int  t, 
	int  r, 
	int  b 
) 
{ 
	scrdev.RestoreDrawArea( 
		drawarea, 
		memory, 
		l, 
		t, 
		r, 
		b 
	); 
} 
 
int CalcMemGCSize( 
	int l, 
	int t, 
	int r, 
	int b 
) 
{ 
	return scrdev.CalcMemGCSize( 
		l, 
		t, 
		r, 
		b 
	); 
}