
/*-----------------------------------------------------------------------*/
/*   FS-MTS  1.0  Ver.                                                   */
/*   Copyright (C) 2000 FIRST SAIL                                       */
/*   All Rights Reserved                                                 */
/*   Warning:                                                            */
/*       This program author is GuoHeng,this system is protected         */
/*   by copyright law and international Treaties . Unauthorized          */
/*   reproduction of  distribution of this  system, or any portion       */
/*   of it , may result in severe civil and criminal penalties ,         */
/*   and will be prosecuted to the maximum extern possible under         */
/*   the law.                                                            */
/*                                                                       */
/*   Update Date:2002-06-25                                              */
/*   Update Time:22:35:00                                                */
/*-----------------------------------------------------------------------*/

#ifndef  _SYMBOL_H_
#define  _SYMBOL_H_


#define  WINSAIL_USER

#ifdef __BORLANDC__
	#define FAR far
#else
	#define FAR
	#define _FAR
	
	#define _CLASSTYPE FAR 
	
	#define _PTRDEF(name) typedef name _FAR * P##name;
	#define _REFDEF(name) typedef name _FAR & R##name;
	#define _REFPTRDEF(name) typedef name _FAR * _FAR & RP##name;
	#define _PTRCONSTDEF(name) typedef const name _FAR * PC##name;
	#define _REFCONSTDEF(name) typedef const name _FAR & RC##name;
	#define _CLASSDEF(name) class _CLASSTYPE name; \
        _PTRDEF(name) \
		_REFDEF(name) \
		_REFPTRDEF(name) \
		_PTRCONSTDEF(name) \
		_REFCONSTDEF(name)
	

	#define _fmemcpy memcpy
	#define _fstrcpy strcpy
	#define _fstricmp stricmp
	#define _fstrcmp  strcmp
	#define _fstrlen  strlen
        #define _fmemset  memset

        #define farmalloc malloc
        #define farfree   free
#endif


//#define  LANGUAGE_VERSION_CHINESE  0
//#define  LANGUAGE_VERSION_ENGLISH  1

/***************************************/
#define CONST_SINGLE_T    3.14159f
#define CONST_DOUBLE_T    3.14159265359

typedef     char*   LPCTSTR;
typedef     void*   LPVOID;
typedef		int		COLOR;
typedef		int		HANDLE;
typedef		unsigned int	WORD;
typedef		unsigned char	BYTE;
typedef		int		BOOL;
typedef     unsigned long	DWORD;
typedef         DWORD           SORT;
typedef         int 		BOOL;
typedef         unsigned int    BOOLEN;
typedef   	int		HWND;
typedef	        DWORD		WPARAM;
typedef DWORD		LPARAM;
typedef long		LONG;
typedef long*       LPLONG;
typedef void        VOID;
typedef	DWORD	ULONG;
typedef         float		FLOAT;
typedef         int		INT;
typedef signed   short  SHORT;
typedef unsigned short  USHORT;
typedef unsigned short  WCHAR;

/****************************************/
#define         JUSTIFY_MIN_MAX(min, max, cur)  \
                if ((cur) > (max)) cur = (max); \
                if ((cur) < (min)) cur = (min);

#define         Min(a,b)        ((a>b)?b:a)
#define         Max(a,b)        ((a>b)?a:b)
//#define         min(a,b)        ((a>b)?b:a)
//#define         max(a,b)        ((a>b)?a:b)

/*****.**********************************/
#define MASK_BIT_KEYBOARD  0
#define MASK_BIT_MOUSE     1
#define MASK_BIT_VIRTUAL   2
#define MASK_CLEAR         8

/*****.**********************************/

#define         MSB_BUTTON_FLAGS    0x55AAu


#define         MB_OK               0x00000001L
#define         MB_YESNO	    0x00000002L
#define         MB_OKNO             0x00000003L
#define         MB_OKCANCEL         0x00000004L
#define         MB_OKNOCANCEL       0x00000005L
#define         MB_RETRYNOCANCEL    0x00000006L
#define         MB_RETRYOKCANCEL    0x00000007L
#define         MB_RETRYOKEXIT      0x00000008L

//#define         MB_ICONHAND         0x00000010L
//#define         MB_ICONQUESTION     0x00000020L
//#define         MB_ICONEXCLAMATION  0x00000030L
//#define         MB_ICONASTERISK     0x00000040L
//#define         MB_USERICON         0x00000080L
//#define         MB_ICONWARNING      MB_ICONEXCLAMATION
//#define         MB_ICONERROR        MB_ICONHAND
//#define         MB_ICONINFORMATION  MB_ICONASTERISK
//#define         MB_ICONSTOP         MB_ICONHAND

#define         MB_DEFBUTTON1       0x00000000L
#define         MB_DEFBUTTON2       0x00000100L
#define         MB_DEFBUTTON3       0x00000200L
   
#define         MB_ICONEXCLAMATION  0x00001000L
#define         MB_ICONINFORMATION  0x00002000L
#define         MB_ICONQUESTION     0x00004000L
#define         MB_ICONSTOP         0x00008000L

//#define         MB_DEFBUTTON4       0x00000300L


/****************************************/


#define     VK_EQU       0x0D3D
#define     VK_ADD       0x0D2B
#define     VK_SUB       0x0C2D
#define     VK_MUL       0x092A
#define     VK_DIV       0x352F

#define		VK_LEFT      0x4B00
#define		VK_RIGHT     0x4D00
#define		VK_UP        0x4800
#define		VK_DOWN      0x5000
#define         VK_HOME      0x4700
#define         VK_END       0x4F00
#define         VK_PGUP      0x4900
#define         VK_PGDOWN    0x5100
#define         VK_DEL       0x5300
#define         VK_TAB       0x0F09
#define		VK_ESC       0x011B
#define		VK_ENTER     0x1C0D
#define         VK_SPACE     0x3920
#define         VK_BACKSPACE 0x0E08
#define         VK_CTRLPGDOWN 0x7600
#define         VK_CTRLPGUP   0x8400
#define         VK_CTRLHOME   0x7700
#define         VK_CTRLEND    0x7500
#define         VK_INSERT     0x5200
#define         VK_F1        0x3B00
#define         VK_F2        0x3C00
#define         VK_F3        0x3D00
#define         VK_F4        0x3E00
#define         VK_F5        0x3F00
#define         VK_F6        0x4000
#define         VK_F7        0x4100
#define         VK_F8        0x4200
#define         VK_F9        0x4300
#define         VK_F10       0x4400

#define         VK_CTRL_F1   0x5E00
#define         VK_CTRL_F2   0x5F00
#define         VK_CTRL_F3   0x6000
#define         VK_CTRL_F4   0x6100
#define         VK_CTRL_F5   0x6200
#define         VK_CTRL_F6   0x6300
#define         VK_CTRL_F7   0x6400
#define         VK_CTRL_F8   0x6500
#define         VK_CTRL_F9   0x6600
#define         VK_CTRL_F10  0x6700
#define         VK_ALT_F1    0x6800
#define         VK_ALT_F2    0x6900
#define         VK_ALT_F3    0x6A00
#define         VK_ALT_F4    0x6B00
#define         VK_ALT_F5    0x6C00
#define         VK_ALT_F6    0x6D00
#define         VK_ALT_F7    0x6E00
#define         VK_ALT_F8    0x6F00
#define         VK_ALT_F9    0x7000
#define         VK_ALT_F10   0x7100
#define         VK_CTRL_F11  0x8900
#define         VK_CTRL_F12  0x8A00
#define         VK_ALT_F11   0x8B00
#define         VK_ALT_F12   0x8C00


#define         VK_C         0x2E43
#define         VK_E         0x1245
#define         VK_N         0x314E
#define         VK_R         0x1352
#define         VK_T         0x1454
#define         VK_X         0x2D58
#define         VK_Y         0x1559


#define         VK_ALT_A         0x1E00
#define         VK_ALT_B         0x3000
#define         VK_ALT_C         0x2E00
#define         VK_ALT_D         0x2000
#define         VK_ALT_E         0x1200
#define         VK_ALT_F         0x2100
#define         VK_ALT_G         0x2200
#define         VK_ALT_H         0x2300
#define         VK_ALT_I         0x1700
#define         VK_ALT_J         0x2400
#define         VK_ALT_K         0x2500
#define         VK_ALT_L         0x2600
#define         VK_ALT_M         0x3200
#define         VK_ALT_N         0x3100
#define         VK_ALT_O         0x1800
#define         VK_ALT_P         0x1900
#define         VK_ALT_Q         0x1000
#define         VK_ALT_R         0x1300
#define         VK_ALT_S         0x1F00
#define         VK_ALT_T         0x1400
#define         VK_ALT_U         0x1600
#define         VK_ALT_V         0x2F00
#define         VK_ALT_W         0x1100
#define         VK_ALT_X         0x2D00
#define         VK_ALT_Y         0x1500
#define         VK_ALT_Z         0x2C00

#define         VK_0             0x0B30
#define         VK_1             0x0231
#define         VK_2             0x0332
#define         VK_3             0x0433
#define         VK_4             0x0534
#define         VK_5             0x0635
#define         VK_6             0x0736
#define         VK_7             0x0837
#define         VK_8             0x0938
#define         VK_9             0x0A39
#define         VK_DOT           0x342E

#define         VK_CTRL_P        0x1910
#define         VK_CTRL_SPACE    0x3900
#define         VK_ALT_SPACE     0x3900

#define         VK_CTRL_H        0x2308
/****************************************/
#define         VK_KEY_DOWITH_OK         0xFFFF

#define         VK_MOUSE_TOTAL           0xFFF0
#define         VK_MOUSE_DOWN_LEFT       0xFFF1
#define         VK_MOUSE_DOWN_MIDDLE     0xFFF2
#define         VK_MOUSE_DOWN_RIGHT      0xFFF4
#define         VK_MOUSE_MOVE            0xFFF8
#define         VK_MOUSE_OVER            0xFFE0
#define         VK_MOUSE_DBL             0xFFE2
#define         VK_MOUSE_CLIENT_OUT      0xFFE4
#define         VK_MOUSE_SCREEN_OUT      0xFFE8
#define         VK_MOUSE_DOWN_LEFT_TIME1 0xFFEA
#define         VK_MOUSE_CHANGE_CHILD    0xFFEB

//....


#define         VK_SCROLL_UP         0xFFD2
#define         VK_SCROLL_DOWN       0xFFD4
#define         VK_SCROLL_VERT_POS   0xFFD8
#define         VK_SCROLL_LEFT       0xFFC0
#define         VK_SCROLL_RIGHT      0xFFC2
#define         VK_SCROLL_HERZ_POS   0xFFC4

/****************************************/
#define         KEYBOARD_STATE_RSHIFT     0
#define         KEYBOARD_STATE_LSHIFT     1
#define         KEYBOARD_STATE_CTRL       2
#define         KEYBOARD_STATE_ALT        3
#define         KEYBOARD_STATE_SCROLLLOCK 4
#define         KEYBOARD_STATE_NUMLOCK    5
#define         KEYBOARD_STATE_CAPSLOCK   6
#define         KEYBOARD_STATE_INSERT     7

/****************************************/

#ifndef		TRUE
#define		TRUE	1
#endif
#ifndef		FALSE
#define		FALSE	0
#endif
#ifndef         NULL
#define         NULL 0
#endif
/****************************************/
#define		    OBJECT_FRAME_WIDTH   3
#define		    WINDOW_FRAME_WIDTH   3
#define         BAR_MAX_COUNT         20
#define         MENU_MAX_COUNT        10
#define         BAR_INTERNAL          6
#define         BAR_WIDTH             (SystemFonSize*5)
#define         MENU_BAR_LENGTH	      (SystemFonSize*5)
#define         MAX_GRID_VOLUMN_COUNT 320
//#define         GRID_VOLUMN_COUNT     (128+4)
//#define         GRID_ITEM_COUNT	      50
#define         GRID_VOLUMN_WIDTH     (SystemFonSize*6)
#define         EDIT_BUFFER_SIZE      256
#define         MESSAGE_LEFT          5
#define		MAX_QULIST_COUNT      16
#define         MAX_SYSTEM_MSG_QULIST 16
#define         MAX_ACTIVATE_WINDOW   16
#define		MAX_FCOBJECTLIST      16
#define         GRID_CHARACTER_MAX    32
#define         SYSTEM_SCROLL_WIDTH   16//18
#define SYSTEM_SCROLL_BUTTON_HEIGHT  18
#define SYSTEM_SCROLL_BUTTON_HEIGHT2 18

#define         SYSTEM_SLIDER_WIDTH   24
#define         SYSTEM_PROCESS_WIDTH   24
#define         UNIT_CHARACTER_MAX    8
/****************************************/
#define         IDNULL                0
#define         IDOK                  1
#define         IDCANCEL              2
#define         IDYES                 3
#define         IDNO                  4
#define         IDRETRY               5
#define         IDCLOSE               6
#define         IDNORMAL              7
#define         IDABORT               8
#define         IDIGNORE              9
#define         IDTIME                10

#define         IDBUTTON1             50
#define         IDBUTTON2             51
#define         IDBUTTON3             52
#define         IDUSER                100



/****************************************/
#define         SCROLL_VERT           0x0
#define         SCROLL_HERZ           0x1
/****************************************/
#define STATISTIC_DAY                 0x1
#define STATISTIC_MONTH               0x2
#define STATISTIC_YEAR                0x3
/**********************************/
#define    MAX_OBJECT_LIST_COUNT  200
/**********************************/
typedef		struct	tagRECT
{
	int left;
	int top;
	int right;
	int bottom;
} RECT;
typedef struct tagPOINT
{
	int x;
	int y;
} POINT;

typedef struct _tagMSG
{
	HWND	hWnd;
	DWORD	dwMessage;
	WPARAM	wParam;
	LPARAM	lParam;
	DWORD	dwTime;
	POINT	poMouse;
}MSG;
typedef struct _tagQULIST
{
	DWORD	dwMessage;
	WPARAM	wParam;
	LPARAM	lParam;
	DWORD	dwTime;
	POINT	poMouse;
}QULIST;

struct DEVICEHEAD {
  DEVICEHEAD*       pNext;
  WORD            wAttrib;
  WORD       wStrategyOff;
  WORD       wInterruptOff;
  char       chDeviceName[8];
};

struct IOPACKET
{
    BYTE byLength;
    BYTE byDrives;
    BYTE byCommand;
    WORD wStatus;
    char chReserve[8];
    BYTE byMediaFlags;
    void FAR * pBuffer;
    WORD wSize;
    BYTE byCrc;
};

//=========================================================================
//=========================================================================
struct IME_HEAD
{
    char  bufFlags[4];
    WORD  wVersion;
    WORD  wHalfTable;
    WORD  wLinkTable;
    DWORD dwDataTable;

    WORD  wSize;
	WORD  wMaxCodes;
	char  bufUsedCodes[32];

    char  bufCaption[12];
    WORD  wWildChar;
    WORD  wMaxElement;
    DWORD dwNumRules;
};

struct IME_HALFTABLE
{
    DWORD dwChar;
    DWORD dwLoc;
};


class CRect
{
public:
	int nLeft;
	int nTop;
	int nRight;
	int nBottom;
public:
	CRect(){nLeft=0,nRight=0,nTop=0,nBottom=0;}
	CRect(int left,int top,int right,int bottom)
	{
		nLeft=left,nRight=right,nTop=top,nBottom=bottom;
	};
	int Width(){return((nRight<nLeft)?0:nRight-nLeft+1);}
	int Height(){return((nBottom<nTop)?0:nBottom-nTop+1);}

};

/****************************************************/
#define   SHAPE_RECT                    0x0000
#define   SHAPE_CIRCLE                  0x0001
#define   SHAPE_ELLIPSE                 0x0002
/****************************************************/
#define   STANDAND_DATA_COUNT             2048L
#define   BETWEEN(a,b,c)                 (((b)>=(c)&&(a)<=(c))?1:0)
#define   DELAY(a)                       {(bAfxRealTime)?delay(a):delay(a+2000);}
/****************************************************/
#define  ALIGN_LEFT    0
#define  ALIGN_MIDDLE  1
#define  ALIGN_RIGHT   2
/***************************************/
#define  BIT_0        0x0
#define  BIT_1        0x1
#define  BIT_2        0x2
#define  BIT_3        0x3
#define  BIT_4        0x4
#define  BIT_5        0x5
#define  BIT_6        0x6
#define  BIT_7        0x7
#define  BIT_8        0x8
#define  BIT_9        0x9
#define  BIT_10       0xA
#define  BIT_11       0xB
#define  BIT_12       0xC
#define  BIT_13       0xD
#define  BIT_14       0xE
#define  BIT_15       0xF
/***************************************/


#define DELETE(a) {if ((a) != NULL) delete (a); (a) = NULL;}


#define  pi 3.1415926
#define  MAX(a,b)  ((a>b)?a:b)
#define  MIN(a,b)  ((a<b)?a:b)
#define ERROR_VALUE          0xFFFF

//-----------------------------------------------
#define  SAIL_BINRARY(a,b,c,d,e,f,g,h)  ((BYTE)(a<<7)+\
					(BYTE)(b<<6)+\
					(BYTE)(c<<5)+\
					(BYTE)(d<<4)+\
					(BYTE)(e<<3)+\
					(BYTE)(f<<2)+\
					(BYTE)(g<<1)+\
					(BYTE)(h<<0))
//-----------------------------------------------
#define SAIL_SHIFT8(a)   ((a)<<8)
#define SAIL_SHIFT16(a)  ((a)<<16)
#define SAIL_LOBYTE(a)   ((BYTE)((a)&0xFF))
#define SAIL_HIBYTE(a)   ((((DWORD)(a))>>8)&0xFF)
#define SAIL_LOWORD(a)   ((WORD)((WORD)(((DWORD)(a))&0xFFFFL)))
#define SAIL_HIWORD(a)   ((WORD)((((DWORD)(a))>>16)&0xFFFFL))

#define SHIFT8(a)   ((a)<<8)
#define SHIFT16(a)  ((a)<<16)
#define LOBYTE(a)   ((BYTE)((a)&0xFF))
#define HIBYTE(a)   ((((DWORD)(a))>>8)&0xFF)
#define LOWORD(a)   ((WORD)((WORD)(((DWORD)(a))&0xFFFFL)))
#define HIWORD(a)   ((WORD)((((DWORD)(a))>>16)&0xFFFFL))

#define TR_WORD(a)  ((((WORD)(a)) >>  8 ) | \
                    (((WORD)(a)) <<  8 ))
#define TR_DWORD(a)  ((((DWORD)(a)) >>  24 ) | \
                     (((DWORD)(a)) <<  24 ) | \
                     ((((DWORD)(a)) >>  8 ) & 0x0000FF00lu) | \
                     ((((DWORD)(a)) <<  8 ) & 0x00FF0000lu))

//-----------------------------------------------
#define MAX_TEST_TIMES  10
#define MEMORY_TIME_ADDRESS    0x46CL

#define IRQ_MASK_TIME     0
#define IRQ_MASK_KEYBOARD 1
#define IRQ_MASK_RESERVED 2
#define IRQ_MASK_COM1     3
#define IRQ_MASK_COM2     4
#define IRQ_MASK_HARDDISK 5
#define IRQ_MASK_SOFTDISK 6
#define IRQ_MASK_PRINTER  7


#define AROUND_STATE_CCW  0
#define AROUND_STATE_CW   1
#define AROUND_STATE_STOP 2

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



struct COMPLEX
{
	double x;
	double y;
};

#include <Bitmap.h>
#include <Icon.h>
#include <GIf.h>
#include <Jpeg.h>


#define TIMER_586CPU_VALUE     500u
#define MULTIPLIER_TIME_VALUE  (1193L)
#define MULTIPLIER_TIME_VALUE2 (1193L << 1)

#include <Private.h>

#endif
