#include <stdio.h>
#include <dos.h>
#define False                            0
#define True                          1
#define S8X8                             8    //    8*8        获取ASCII ROM字符集首地址
#define S14X8                        14    //    14*81    获取ASCII ROM字符集首地址
#define S16X8                           16    //    16*8    获取ASCII ROM字符集首地址
#define VBE320X200X256               0X13
#define VBE640X480X256               0X101
#define VBE800X600X256               0X103
#define VBE1024X768X256              0X105
//////////////////////////////////////////////////////////////////
//计算在特定分辨率下,x,y坐标的内存偏移量,计算值可能大于65536字节。
//////////////////////////////////////////////////////////////////
#define VRAM_GRAPH_320(x,y)         (((unsigned long)y<<8L)+((unsigned long)y<<6L)+((unsigned long)x))
#define VRAM_GRAPH_512(x,y)         (((unsigned long)y<<9L)+((unsigned long)x))
#define VRAM_GRAPH_640(x,y)         (((unsigned long)y<<9L)+((unsigned long)y<<7L)+((unsigned long)x))
#define VARM_GRAPH_800(x,y)            (((unsigned long)y<<9L)+((unsigned long)y<<8L)+((unsigned long)y<<5L)+((unsigned long)(x)))
#define VRAM_GRAPH_1024(x,y)         (((unsigned long)y<<10L)+((unsigned long)x))
#define RGB(r, g, b)                (((r)&0xE0)|(((g)&0xE0)>>3)|(((b)&0xC0)>>6))
//////////////////////////////////////////////////////////////////////////////
//  COLOR DEFINE
//////////////////////////////////////////////////////////////////////////////
#define     BLACK           0
#define     BLUE            1
#define     GREEN            2
#define     CYAN            3
#define     RED                4
#define     MAGENTA            5
#define     BROWN            6
#define     LIGHTGRAY        7
#define     DARKGRAY        8
#define     LIGHTBLUE       9
#define     LIGHTGREEN      10
#define     LIGHTCYAN       11
#define     LIGHTRED        12
#define     LIGHTMAGENTA     13
#define     YELLOW            14
#define     WHITE            15
//////////////////////////////////////////////////////////////////////////////
//  FILL PATTEREN DEFINE
//////////////////////////////////////////////////////////////////////////////
#define     EMPTY_FILL        0             /* fills area in background color */
#define     SOLID_FILL        1             /* fills area in solid fill color */
#define     LINE_FILL        2             /* --- fill */
#define     LTSLASH_FILL    3             /* /// fill */
#define     SLASH_FILL        4            /* /// fill with thick lines */
#define     BKSLASH_FILL    5           /* \\\ fill with thick lines */
#define     LTBKSLASH_FILL    6             /* \\\ fill */
#define     HATCH_FILL        7             /* light hatch fill */
#define     XHATCH_FILL        8            /* heavy cross hatch fill */
#define     INTERLEAVE_FILL    9            /* interleaving line fill */
#define     WIDE_DOT_FILL    10          /* Widely spaced dot fill */
#define     CLOSE_DOT_FILL    11             /* Closely spaced dot fill */
#define     USER_FILL        12          /* user defined fill */
int Back_Color,Fore_Color,Fill_Color;
/////////////////////////////////////////////////////////////////////////////////////////////////
//    设置 bar 填充颜色(同 Turbo C)
/////////////////////////////////////////////////////////////////////////////////////////////////
void _Cdecl setfillstyle(int __pattern,int color)
{
    __pattern++;            // no use
    Fill_Color = color;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
//    设置前景色(同 Turbo C)
/////////////////////////////////////////////////////////////////////////////////////////////////
void _Cdecl setcolor(int color)
{
    Fore_Color = color;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
//    获取前景色(同 Turbo C)
/////////////////////////////////////////////////////////////////////////////////////////////////
int _Cdecl getcolor(void)
{
    return (Fore_Color);
}
/////////////////////////////////////////////////////////////////////////////////////////////////
//    设置背景色(同 Turbo C)
/////////////////////////////////////////////////////////////////////////////////////////////////
void _Cdecl setbkcolor(int color)
{
    Back_Color = color;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
//    获取背景色(同 Turbo C)
/////////////////////////////////////////////////////////////////////////////////////////////////
int _Cdecl getbkcolor(void)
{
    return (Back_Color);
}
/////////////////////////////////////////////////////////////////////////////////////////////////
//    获取填充色
/////////////////////////////////////////////////////////////////////////////////////////////////
int _Cdecl getfillcolor(void)
{
    return (Fill_Color);
}
/*********************************************************************************************/
//    画一条凹凸立体线
/*********************************************************************************************/
void _Cdecl Double_VLine(int x1,int y1,int y2)
{
    int gcolor = getcolor();
    setcolor(DARKGRAY);
    Vline(x1,y1,y2);
    setcolor(WHITE);
    Vline(x1+1,y1,y2);
    setcolor(gcolor);
}
/*********************************************************************************************/
//    画一个凸按钮
/*********************************************************************************************/
void _Cdecl GuiConProtrudingBox(int x1,int y1,int x2,int y2)
{
    int bcolor = getbkcolor();        //    获取背景色
    int gcolor = getcolor();        //    获取前景色
    int fcolor = getfillcolor();    //    获取填充色
    setcolor(WHITE);
    Hline(x1-1,y1-1,x2+1);
    Hline(x1  ,y1  ,x2);
    Vline(x1-1,y1-1,y2+1);
    Vline(x1  ,y1  ,y2);
    setcolor(DARKGRAY);
    Hline(x1-1,y2+1,x2+1);
    Hline(x1  ,y2  ,x2);
    Vline(x2  ,y1  ,y2);
    Vline(x2+1,y1-1,y2+1);
    setfillstyle(SOLID_FILL,LIGHTGRAY);
    Bar(x1+1,y1+1,x2-1,y2-1);
    setbkcolor(bcolor);                //    恢复背景色
    setcolor(gcolor);                //    恢复前景色
    setfillstyle(SOLID_FILL,fcolor);//    恢复填充色
}
/*********************************************************************************************/
//    显示一个凹按钮
/*********************************************************************************************/
void _Cdecl GuiConCaveBox(int x1,int y1,int x2,int y2)
{
    int bcolor = getbkcolor();
    int gcolor = getcolor();
    int fcolor = getfillcolor();
    setcolor(DARKGRAY);
    Hline(x1-1,y1-1,x2+1);
    Hline(x1,y1,x2);
    Vline(x1-1,y1-1,y2+1);
    Vline(x1,y1,y2);
    setcolor(WHITE);
    Hline(x1,y2,x2);
    Hline(x1-1,y2+1,x2+1);
    Vline(x2,y1,y2);
    Vline(x2+1,y1-1,y2+1);
    setfillstyle(SOLID_FILL,LIGHTGRAY);
    Bar(x1+1,y1+1,x2-1,y2-1);
    setbkcolor(bcolor);
    setcolor(gcolor);
    setfillstyle(SOLID_FILL,fcolor);
}
/*********************************************************************************************/
//    画一个凹矩形
/*********************************************************************************************/
void _Cdecl GuiConProtrudingRectangle(int x1,int y1,int x2,int y2)
{
    int bcolor = getbkcolor();
    int gcolor = getcolor();
    setcolor(WHITE);
    Hline(x1  ,y1  ,x2);
    Vline(x1  ,y1  ,y2);
    setcolor(DARKGRAY);
    Hline(x1  ,y2  ,x2);
    Vline(x2  ,y1  ,y2);
    setfillstyle(SOLID_FILL,LIGHTGRAY);
    Bar(x1+1,y1+1,x2-1,y2-1);
    setbkcolor(bcolor);
    setcolor(gcolor);
    setbkcolor(bcolor);
    setcolor(gcolor);
}
/*********************************************************************************************/
//    画一个凹矩形
/*********************************************************************************************/
void _Cdecl GuiConCaveRectangle(int x1,int y1,int x2,int y2)
{
    int bcolor = getbkcolor();
    int gcolor = getcolor();
    setcolor(DARKGRAY);
    Hline(x1,y1,x2);
    Vline(x1,y1,y2);
    setcolor(WHITE);
    Hline(x1,y2,x2);
    Vline(x2,y1,y2);
    setbkcolor(bcolor);
    setcolor(gcolor);
}



											
	    

	


										
					
	