www.pudn.com > UCGUI390a.rar > mt_multitasking.c


/*********************************************************************
*													                 *
*					GPS Client base on ARM 3000						 *
*                                                                    *
**********************************************************************

----------------------------------------------------------------------
File        : MT_MultiTasking.c
Purpose     : 
----------------------------------------------------------------------
*/

#include "GUI.h"
#include "GUI_X.h"
#include "BUTTON.h"
#include "FRAMEWIN.h"
#include "DIALOG.h" 
#include "MENU.h"
#include "LISTVIEW.h"
#include "DROPDOWN.h"



#include 
#include 

#include "GPS_TypeDefine.h"

extern const GUI_FONT GUI_FontHZ_SimSun_13;

extern Configure GPS_MapShowCfgTbl[];
extern GUI_CONST_STORAGE GUI_BITMAP bmExit;
extern GUI_CONST_STORAGE GUI_BITMAP bmconfirm;
CHECKBOX_Handle _hChkBox_ShowFigure;
CHECKBOX_Handle _hChkBox_ShowName;
LISTVIEW_Handle _hListView;
char _isNavi;

WM_HWIN _hFrameMapWin;
Position pt_unit[46];
Position pt_school[2];

#include "GPS_Spec.h"

extern PolyLineSet	mainroad_set; 
extern PolyLineSet	generroad_set; 
extern PolygonSet	green_set; 
extern PositionSet	school_set;
extern PolygonSet   water_set;
extern PolygonSet   g_in_w_set;
extern PositionSet  unit_set;
extern GUI_POINT track[541];
GUI_POINT here;

#if GUI_OS == 0
  #error Multitasking sample requires task awareness (#define GUI_OS 1)
#endif

#define ID_BUTTON_CONFIGURE		(GUI_ID_USER +  0) 
#define ID_BUTTON_SEARCH		(GUI_ID_USER +  1) 
#define ID_BUTTON_NAVIGATION	(GUI_ID_USER +  2) 
#define ID_BUTTON_ABOUT			(GUI_ID_USER +  3) 
 
#define ID_MENU_CONFIGURE		(GUI_ID_USER +  4) 
#define ID_MENU_SEARCH			(GUI_ID_USER +  5) 
#define ID_MENU_NAVIGATION		(GUI_ID_USER +  6) 
#define ID_MENU_ABOUT			(GUI_ID_USER +  7)

#define ID_CONF					GUI_ID_USER + 200
#define ID_CONF_OK				ID_CONF + 0
#define ID_CONF_LISTVIEW		ID_CONF + 1
#define ID_CONF_CHK_SHOW_FIGURE	ID_CONF + 2
#define ID_CONF_CHK_SHOW_NAME	ID_CONF + 3

#define ID_NAVI					GUI_ID_USER + 220
#define ID_NAVI_DROP_SOUR		ID_NAVI + 0
#define ID_NAVI_DROP_TARG		ID_NAVI + 1

#define ID_SEARCH				GUI_ID_USER + 230
#define ID_SEARCH_DROP_SOUR		ID_SEARCH + 0
#define	ID_SEARCH_BUTTON_OK		ID_SEARCH + 1

/*******************************************************************
*
*       Define how to create a task and start multitasking
*
********************************************************************

  If not using embOS you have to change the hardware
  dependent macros to work with your OS

*/

#ifndef WIN32 
  #include "RTOS.h"    /* Definitions for embOS */
  #define CREATE_TASK(pTCB, pName, pFunc, Priority, pStack)  OS_CREATETASK(pTCB, pName, pFunc, Priority, pStack)
  #define START_MT()  OS_Terminate(0)
  #define Delay(t)    OS_Delay(t)
#else
  #include "SIM.h"     /* Definitions for the Win32 simulation */
  #define CREATE_TASK(pTCB, pName, pFunc, Priority, pStack)   SIM_CreateTask(pName, pFunc)
  #define START_MT()  SIM_Start()
  #define Delay(t)    SIM_Delay(t)
#endif


static void _cbButton(WM_MESSAGE* pMsg) {
	WM_DefaultProc(pMsg);
}

static int _Target_X;
static int _Target_Y;
static void SetTargetPosition(int x, int y)
{
	_Target_X = x;
	_Target_Y = y;
}

/******************************************************************* 
* 
*       _cbAboutBox 
*/ 
static void _cbAboutBox(WM_MESSAGE* pMsg) { 
	WM_HWIN hWin = pMsg->hWin; 
	switch (pMsg->MsgId)  
	{ 
	case WM_PAINT: 
		GUI_SetColor(GUI_BLACK); 
		GUI_SetFont(&GUI_Font8x8); 
		GUI_SetTextMode(GUI_TM_TRANS); 
		//GUI_DrawBitmap(&_Logo, 4, 4); 
		GUI_DispStringHCenterAt("GPS Client on ARM3000 V1.0", 49, 48); 
		GUI_DispStringHCenterAt("Compiled " __DATE__ " "__TIME__, 78, 68); 
		GUI_DispStringHCenterAt("(c) 2006-2007", 88, 87); 
 
		break; 
	case WM_NOTIFY_PARENT: 
		if (pMsg->Data.v == WM_NOTIFICATION_RELEASED)  
		{ 
			GUI_EndDialog(hWin, 1); 
		} 
		break; 
	default: 
		WM_DefaultProc(pMsg); 
	} 
} 
 
/********************************************************************* 
* 
*       _ShowAboutBox 
*/ 
static void _ShowAboutBox(void) { 
  WM_HWIN hFrame, hItem; 
  /* Create framewin */ 
  hFrame = FRAMEWIN_CreateEx(70, 70, 180, 100, WM_HBKWIN, WM_CF_SHOW, FRAMEWIN_CF_MOVEABLE, 0, "About GPS Client", &_cbAboutBox); 
  FRAMEWIN_SetClientColor   (hFrame, GUI_WHITE); 
  FRAMEWIN_SetFont          (hFrame, &GUI_Font8x8); 
  FRAMEWIN_SetTextAlign     (hFrame, GUI_TA_HCENTER); 
  /* Create dialog items */ 
  hItem = BUTTON_CreateEx(111, 7, 50, 32, WM_GetClientWindow(hFrame), WM_CF_SHOW, 0, GUI_ID_OK); 
  BUTTON_SetBitmap(hItem, 0, &bmExit); 
  /* Exec modal dialog */ 
  WM_SetFocus(hFrame); 
  WM_MakeModal(hFrame); 
  GUI_ExecCreatedDialog(hFrame); 
  //WM_SetFocus(hFrame); 
}


/********************************************************************* 
* 
*       _cbMapConfBox 
*/
static void _cbMapConfBox(WM_MESSAGE* pMsg) { 
	int row; 
	int chk_status; 
	switch (pMsg->MsgId)  
	{ 
	case WM_NOTIFY_PARENT: 
		if (pMsg->Data.v == WM_NOTIFICATION_RELEASED ||  
			pMsg->Data.v == WM_NOTIFICATION_SEL_CHANGED)  
		{ 
			WM_HWIN hWin = pMsg->hWin; 
			switch(WM_GetId(pMsg->hWinSrc)) 
			{ 
			case GUI_ID_OK: 
				GUI_EndDialog(hWin, 1); 
				break; 
			case ID_CONF_LISTVIEW: 
				row = LISTVIEW_GetSel(_hListView); 
				CHECKBOX_SetState(_hChkBox_ShowName,  
								GPS_MapShowCfgTbl[row].show_name[0]=='y' ? 1 : 0); 
				CHECKBOX_SetState(_hChkBox_ShowFigure,  
								GPS_MapShowCfgTbl[row].show_figure[0]=='y' ? 1 : 0 ); 
				break; 
			case ID_CONF_CHK_SHOW_FIGURE: 
				row = LISTVIEW_GetSel(_hListView); 
				chk_status = CHECKBOX_GetState(_hChkBox_ShowFigure); 
				GPS_MapShowCfgTbl[row].show_figure = chk_status ? "y" : "n"; 
				LISTVIEW_SetItemText(_hListView, 1, row, chk_status ? "y" : "n"); 
				break; 
			case ID_CONF_CHK_SHOW_NAME: 
				row = LISTVIEW_GetSel(_hListView); 
				chk_status = CHECKBOX_GetState(_hChkBox_ShowName); 
				GPS_MapShowCfgTbl[row].show_name = chk_status ? "y" : "n"; 
				LISTVIEW_SetItemText(_hListView, 2, row, chk_status ? "y" : "n"); 
				break; 
			} 
		} 
		 
		break; 
	default: 
		WM_DefaultProc(pMsg); 
	} 
} 
 
/********************************************************************* 
* 
*       _ShowMapConfBox 
*/ 
static void _ShowMapConfBox(void) { 
	WM_HWIN hFrame, hClient, hItem; 
	 
	HEADER_Handle hHeader; 
	char* value[3]; 
	int i; 
	/* Create framewin */ 
	hFrame = FRAMEWIN_CreateEx(70, 10, 245, 220, WM_HBKWIN, WM_CF_SHOW,  
								FRAMEWIN_CF_MOVEABLE, 0, "Map settings", &_cbMapConfBox); 
	FRAMEWIN_SetClientColor   (hFrame, GUI_WHITE); 
	FRAMEWIN_SetFont          (hFrame, &GUI_Font8x8); 
	FRAMEWIN_SetTextAlign     (hFrame, GUI_TA_HCENTER); 
 
	hClient = WM_GetClientWindow(hFrame); 
	hItem = BUTTON_CreateEx(185, 167, 50, 32, hClient, WM_CF_SHOW, 0, GUI_ID_OK); 
	BUTTON_SetBitmap(hItem, 0, &bmExit); 
 
	/* Create checkbox */ 
	_hChkBox_ShowFigure = CHECKBOX_CreateEx(10, 154, 140, 0, hClient,  
											WM_CF_SHOW, 0, ID_CONF_CHK_SHOW_FIGURE); 
	CHECKBOX_SetText(_hChkBox_ShowFigure, "Show Figure"); 
	CHECKBOX_SetState(_hChkBox_ShowFigure, GPS_MapShowCfgTbl[0].show_figure[0]=='y' ? 1 : 0 ); 
	_hChkBox_ShowName = CHECKBOX_CreateEx(10, 174, 140, 0, hClient,  
											WM_CF_SHOW, 0, ID_CONF_CHK_SHOW_NAME); 
	CHECKBOX_SetText(_hChkBox_ShowName, "Show Name"); 
	CHECKBOX_SetState(_hChkBox_ShowName, GPS_MapShowCfgTbl[0].show_name[0]=='y' ? 1 : 0); 
 
	_hListView = LISTVIEW_CreateEx(2, 2 , 236, 150, hClient, WM_CF_SHOW, 0, ID_CONF_LISTVIEW); 
	hHeader = LISTVIEW_GetHeader(_hListView); 
	HEADER_SetHeight(hHeader,20); 
	LISTVIEW_AddColumn(_hListView, 90, "   Layer",         GUI_TA_LEFT); 
	LISTVIEW_AddColumn(_hListView,  70, "Show Figure",	GUI_TA_CENTER); 
	LISTVIEW_AddColumn(_hListView, 65, "Show Name",		GUI_TA_CENTER); 
	SCROLLBAR_CreateAttached(_hListView, SCROLLBAR_CF_VERTICAL); 
	for(i=0; i<20; i++) 
	{ 
		value[0] = GPS_MapShowCfgTbl[i].type_name; 
		value[1] = GPS_MapShowCfgTbl[i].show_figure; 
		value[2] = GPS_MapShowCfgTbl[i].show_name; 
		if( !strcmp(value[0],"")) break; 
		LISTVIEW_AddRow(_hListView, value); 
	} 
	LISTVIEW_SetSel(_hListView,0); 
	LISTVIEW_SetGridVis(_hListView,1); 
	/* Exec modal dialog */ 
	WM_SetFocus(hFrame); 
	WM_MakeModal(hFrame); 
	GUI_ExecCreatedDialog(hFrame); 
}


DROPDOWN_Handle _hDropSource;
DROPDOWN_Handle _hDropTarget;
static void _cbShowNaviSetBox(WM_MESSAGE* pMsg)
{
	switch(pMsg->MsgId)
	{
	case WM_PAINT:
		GUI_SetColor(GUI_BLACK); 
		GUI_SetTextMode(GUI_TM_TRANS);
		GUI_SetFont(&GUI_FontHZ_SimSun_13); 
		GUI_DispStringAt ("起始:", 5, 103); 
		GUI_DispStringAt ("目标:", 5, 128);
		break;
	case WM_NOTIFY_PARENT: 
		if (pMsg->Data.v == WM_NOTIFICATION_RELEASED)
		{
			WM_HWIN hWin = pMsg->hWin;
			switch( WM_GetId(pMsg->hWinSrc) )
			{
			case GUI_ID_OK:
				GUI_EndDialog(hWin, 1); 
				break;
			}
		}
		break;
	default:
		WM_DefaultProc(pMsg);

	}
}

/********************************************************************* 
* 
*       _ShowNaviSetBox 
*/
static void _ShowNaviSetBox()
{
	WM_HWIN hFrame, hItem, hWin; 
	/* Create framewin */ 
	hFrame = FRAMEWIN_CreateEx(65, 0, 254, 240, WM_HBKWIN, WM_CF_SHOW, FRAMEWIN_CF_MOVEABLE, 0, "Navigation Setting", &_cbShowNaviSetBox); 
	FRAMEWIN_SetClientColor   (hFrame, GUI_WHITE); 
	FRAMEWIN_SetFont          (hFrame, &GUI_Font8x8); 
	FRAMEWIN_SetTextAlign     (hFrame, GUI_TA_HCENTER); 
	hWin = WM_GetClientWindow(hFrame); 
	/* Create dialog items */ 
	hItem = BUTTON_CreateEx(200, 18, 50, 32, hWin, WM_CF_SHOW, 0, GUI_ID_OK); 
	BUTTON_SetBitmap         (hItem, 0, &bmExit); 
	_hDropSource = DROPDOWN_CreateEx(45, 100, 150, 100, hWin, WM_CF_SHOW, 0, ID_NAVI_DROP_SOUR); 
	_hDropTarget = DROPDOWN_CreateEx(45, 125, 150, 100, hWin, WM_CF_SHOW, 0, ID_NAVI_DROP_TARG); 
	DROPDOWN_AddString(_hDropSource, "test"); 
 
	/* Exec modal dialog */ 
	WM_SetFocus(hFrame); 
	WM_MakeModal(hFrame); 
	GUI_ExecCreatedDialog(hFrame);
}

static void GoToTarget(int pos)
{
	int cur_x, cur_y;
	int goto_x, goto_y;
	goto_x = unit_set.pPts[pos].x;
	goto_y = unit_set.pPts[pos].y;
	cur_x = WM_GetWindowOrgX(_hFrameMapWin);
	cur_y = WM_GetWindowOrgY(_hFrameMapWin);
	SetTargetPosition(goto_x, goto_y);
	WM_MoveWindow(_hFrameMapWin, -(goto_x - 160 + cur_x), -(goto_y - 120 + cur_y));
}

static void _cbShowSearchBox(WM_MESSAGE* pMsg)
{
	switch(pMsg->MsgId)
	{
	case WM_PAINT:
		GUI_SetColor(GUI_BLACK); 
		//GUI_SetFont(&GUI_Font8x8); 
		GUI_SetTextMode(GUI_TM_TRANS);
		GUI_SetFont(&GUI_FontHZ_SimSun_13); 
		GUI_DispStringAt ("目标:", 5, 23);
		break;
	case WM_NOTIFY_PARENT: 
		if (pMsg->Data.v == WM_NOTIFICATION_RELEASED)
		{
			WM_HWIN hWin = pMsg->hWin;
			switch( WM_GetId(pMsg->hWinSrc) )
			{
			case GUI_ID_OK:
				GUI_EndDialog(hWin, 1); 
				break;
			case ID_SEARCH_BUTTON_OK:
				GoToTarget(DROPDOWN_GetSel(_hDropTarget));
				GUI_EndDialog(hWin, 1);
				break;
			}
		}
		break;
	default:
		WM_DefaultProc(pMsg);

	}
}


extern const GUI_FONT GUI_FontHZ_SimSun_12;
static void _ShowSearchBox()
{
	WM_HWIN hFrame, hItem, hWin; 
	int i; 
 
	/* Create framewin */ 
	hFrame = FRAMEWIN_CreateEx(65, 0, 254, 240, WM_HBKWIN, WM_CF_SHOW, FRAMEWIN_CF_MOVEABLE, 0, "Search", &_cbShowSearchBox); 
	FRAMEWIN_SetClientColor   (hFrame, GUI_WHITE); 
	FRAMEWIN_SetFont          (hFrame, &GUI_Font8x8); 
	FRAMEWIN_SetTextAlign     (hFrame, GUI_TA_HCENTER); 
	hWin = WM_GetClientWindow(hFrame); 
	/* Create dialog items */ 
	hItem = BUTTON_CreateEx(200, 180, 50, 32, hWin, WM_CF_SHOW, 0, GUI_ID_OK); 
	BUTTON_SetBitmap         (hItem, 0, &bmExit); 
	hItem = BUTTON_CreateEx(100, 180, 50, 32, hWin, WM_CF_SHOW, 0, ID_SEARCH_BUTTON_OK); 
	BUTTON_SetBitmap         (hItem, 0, &bmconfirm); 
 
	_hDropTarget = DROPDOWN_CreateEx(35, 20, 170, 150, hWin, WM_CF_SHOW, 0, ID_SEARCH_DROP_SOUR);

	DROPDOWN_SetDefaultFont(&GUI_FontHZ_SimSun_12);
	DROPDOWN_SetFont(_hDropTarget, &GUI_FontHZ_SimSun_12);
	DROPDOWN_SetAutoScroll(_hDropTarget, 1);
	for(i=0; iMsgId) {
	case WM_NOTIFY_PARENT: 
		if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) { 
			WM_HWIN hItem = pMsg->hWinSrc; 
			switch (WM_GetId(hItem)) { 
				case ID_BUTTON_ABOUT: 
					_ShowAboutBox(); 
					break; 
				case ID_BUTTON_CONFIGURE: 
					_ShowMapConfBox(); 
					break; 
				case ID_BUTTON_NAVIGATION: 
					_ShowNaviSetBox(); 
					break; 
				case ID_BUTTON_SEARCH: 
					_ShowSearchBox(); 
					break; 
				case 1001: 
					enlarge(); 
					WM_Invalidate(_hFrameMapWin); 
					break; 
				case 1002: 
					shrink(); 
					WM_Invalidate(_hFrameMapWin); 
					break; 
			} 
		}//if
	case WM_KEY:
		x = WM_GetWindowOrgX(_hFrameMapWin);
		y = WM_GetWindowOrgY(_hFrameMapWin);
		key = GUI_GetKey();
		if( key == 17)		//up
		{
			if (y > 120)
			{
				break;
			}
			WM_MoveWindow(_hFrameMapWin, 0, 16);
		}
		else if(key == 19)	//down
		{
			if (y < -(_Height-120))
			{
				break;
			}
			WM_MoveWindow(_hFrameMapWin, 0, -16);
		}
		else if (key == 16)	//left
		{
			if (x > 160)
			{
				break;
			}
			WM_MoveWindow(_hFrameMapWin, 16, 0);
		}
		else if (key == 18)	//right
		{
			if (x < -(_Width-160))
			{
				break;
			}
			WM_MoveWindow(_hFrameMapWin, -16, 0);
		}
		break;
  default:
    WM_DefaultProc(pMsg);
  }
}

/*******************************************************************
*
*       _cbCallbackT1
*/
static void _cbCallbackMapWindow(WM_MESSAGE * pMsg) {

	GUI_POINT p[4] = {{0,0},{40,0},{30,-10},{40,-24}};

	WM_HWIN hWin = (FRAMEWIN_Handle)(pMsg->hWin);
	switch (pMsg->MsgId) 
	{
	case WM_PAINT:
		GUI_SetBkColor(0xe080ff);
		GUI_SetColor(GUI_WHITE);
		GUI_SetTextAlign(GUI_TA_HCENTER | GUI_TA_VCENTER);
		GUI_Clear();
		
		GUI_SetFont(&GUI_Font6x8);
		GUI_SetPenSize((int)(8*_Width/960)+1);
		GPS_DrawPolyLine(&mainroad_set);
		GUI_SetPenSize((int)(5*_Width/960)+1);
		GPS_DrawPolyLine(&generroad_set);
		GPS_DrawPolygon(&green_set);
		GPS_DrawPolygon(&water_set);
		GPS_DrawPolygon(&g_in_w_set);
		GPS_DrawPosition(&school_set);
		GPS_DrawPosition(&unit_set);
		
		GUI_SetColor(GUI_RED);
		GUI_SetDrawMode(GUI_DRAWMODE_TRANS);
		GUI_FillPolygon(&p, 4, _Target_X+3, _Target_Y-3);
		GUI_SetDrawMode(GUI_DRAWMODE_NORMAL);
		
		break;

	case WM_TOUCH:
		//
		break;
	case WM_KEY:
		break;
	default:
		WM_DefaultProc(pMsg);
	}
}

/*******************************************************************
*
*       _cbBackgroundWin
*/
static void _cbBackgroundWin(WM_MESSAGE* pMsg) {
	
  switch (pMsg->MsgId) {
  case WM_PAINT:
    /* Handle only the paint message */
    GUI_SetBkColor(0x00CC00);
    GUI_Clear();
    GUI_SetFont(&GUI_Font24_ASCII);
    GUI_DispStringHCenterAt("GPS Client on ARM3000\n", 160, 5);
    GUI_SetFont(&GUI_Font13_1);
    GUI_DispStringAt("USTC SSE Software Development Practice", 5, 35);
	
	//
  default:
    WM_DefaultProc(pMsg);
  }
}

/*******************************************************************
*
*       _Task_0
*/
extern GUI_CONST_STORAGE GUI_BITMAP bmLaySelect;
extern GUI_CONST_STORAGE GUI_BITMAP bmNavi;
extern GUI_CONST_STORAGE GUI_BITMAP bmSearch;
extern GUI_CONST_STORAGE GUI_BITMAP bmenlarge;
extern GUI_CONST_STORAGE GUI_BITMAP bmshrink;
static void _Task_0(void) {

	BUTTON_Handle hButton_SetMap;	//this button is to call the map setting dialog
	BUTTON_Handle hButton_Search;	//this button is to call the map search dialog
	BUTTON_Handle hButton_SetNavi;	//this button is to call the dialog that set the start and end of navigation
	BUTTON_Handle hButton_About;
	BUTTON_Handle hBtn_Enlarge;
	BUTTON_Handle hBtn_Shrink;
	FRAMEWIN_Handle hFrameWin;
	WM_HWIN         hChildWin;
	/* Create frame window */
	//GUI_SetFont( &GUI_Font16_ASCII );
	FRAMEWIN_SetDefaultFont( &GUI_Font16_ASCII );
	hFrameWin = FRAMEWIN_CreateEx(0, 0, 64, 240, WM_HBKWIN, WM_CF_SHOW | WM_CF_STAYONTOP,
				 WM_CF_MEMDEV, 0, "Menu", _cbCallbackMenuWindow);
	//FRAMEWIN_AddMinButton(hFrameWin,FRAMEWIN_BUTTON_RIGHT,1);
	/* Create child window */
	//hChildWin = WM_CreateWindowAsChild(0, 0, 0, 0, WM_GetClientWindow(hFrameWin), 
	//									WM_CF_SHOW | WM_CF_MEMDEV, NULL, 0);
	FRAMEWIN_AddMinButton(hFrameWin,FRAMEWIN_BUTTON_RIGHT,1);
	FRAMEWIN_SetTitleHeight(hFrameWin, 20);
	FRAMEWIN_SetActive(hFrameWin, 0);

	hChildWin = WM_GetClientWindow(hFrameWin);

	hButton_SetMap = BUTTON_CreateEx(1, 4, 56, 48, hChildWin, WM_CF_SHOW, 0, ID_BUTTON_CONFIGURE);
	BUTTON_SetBitmap(hButton_SetMap, 0, &bmLaySelect);

	hButton_Search = BUTTON_CreateEx(1, 58, 56, 48, hChildWin, WM_CF_SHOW, 0,ID_BUTTON_SEARCH);
	BUTTON_SetBitmap(hButton_Search, 0, &bmSearch);

	hBtn_Enlarge = BUTTON_CreateEx(1, 112, 25, 38, hChildWin, WM_CF_SHOW, 0,1001);
	BUTTON_SetBitmap(hBtn_Enlarge, 0, &bmenlarge);
	hBtn_Shrink = BUTTON_CreateEx(32, 112, 25, 38, hChildWin, WM_CF_SHOW, 0,1002);
	BUTTON_SetBitmap(hBtn_Shrink, 0, &bmshrink);

	hButton_About = BUTTON_CreateEx(1, 166, 56, 48, hChildWin, WM_CF_SHOW, 0,ID_BUTTON_ABOUT);
	BUTTON_SetText(hButton_About,"About");

	/* Make sure the right window is active... */
	WM_SelectWindow(hChildWin);
	WM_SetFocus(hFrameWin);
	GUI_Exec();
}

/*******************************************************************
*
*       _Task_1
*/


static void _Task_1(void) {

	_hFrameMapWin = WM_CreateWindow(0, 0, _Width, _Height, WM_CF_SHOW | WM_CF_MEMDEV, _cbCallbackMapWindow, 0);
	while(1){
		GUI_Delay(200);
		GUI_Exec();
	}

}

/*******************************************************************
*
*       MainTask
*
********************************************************************
*/

#ifndef WIN32
  /* Stacks */
  static OS_STACKPTR int Stack_0[600];
  static OS_STACKPTR int Stack_1[600];
  static OS_STACKPTR int Stack_2[600];
  static OS_TASK aTCB[3];               /* Task control blocks */
#endif

#include "stdio.h"

void MultTask_MainTask(void) {

	int i,j,offset;
	PolyLine pl_g_road[27];
	PolyLine pl_m_road[3];

	PolyLine pl_outline_green;
	PolyLine pl_outline_green_back[2];
	Polygon		pyn_green;
	Polygon		pyn_green_back[2];

	PolyLine pl_outline_water[2];
	Polygon		pyn_water[2];


	GUI_Init();

	WM_SetCreateFlags(WM_CF_MEMDEV);              /* Use memory devices on all windows to avoid flicker */
	WM_SetCallback(WM_HBKWIN, _cbBackgroundWin);  /* Set callback for background window */
	
	//ReadMapFile();

	offset = 0;
	for (i=0; i<_g_road_count; i++)
	{
		pl_g_road[i].points = _pt_gen_road + offset;
		pl_g_road[i].count = _g_road_desc[i].count;
		pl_g_road[i].name = _g_road_desc[i].name;
		offset+=_g_road_desc[i].count;
	}

	offset = 0;
	for (i=0; i<_m_road_count; i++)
	{
		pl_m_road[i].points = _pt_m_road + offset;
		pl_m_road[i].count = _m_road_desc[i].count;
		pl_m_road[i].name = _m_road_desc[i].name;
		offset+=_m_road_desc[i].count;
	}

	//单位
	for (i=0; i<_unit_count; i++)
	{
		pt_unit[i].name  = _unit[i].name;
		pt_unit[i].x = _unit[i].x;
		pt_unit[i].y = _unit[i].y;
	}

	//学校
	for (i=0; i<2; i++)
	{
		pt_school[i].name  = _school[i].name;
		pt_school[i].x = _school[i].x;
		pt_school[i].y = _school[i].y;
	}

	pl_outline_green.points = _pt_green;
	pl_outline_green.count	= 35;
	pyn_green.outline = &pl_outline_green;
	pyn_green.name = "公共绿地";

	pl_outline_green_back[0].points = _pt_green_back;
	pl_outline_green_back[0].count = 35;
	pl_outline_green_back[0].name = "岛";
	pl_outline_green_back[1].points = _pt_green_back+35;
	pl_outline_green_back[1].count = 118;
	pl_outline_green_back[1].name = "岛";
	pyn_green_back[0].outline = &pl_outline_green_back[0];
	pyn_green_back[0].name = "岛";
	pyn_green_back[1].outline = &pl_outline_green_back[1];
	pyn_green_back[1].name = "岛";


	pl_outline_water[0].points = _pt_water;
	pl_outline_water[0].count = 74;
	pl_outline_water[1].points = _pt_water + 74;
	pl_outline_water[1].count = 164;
	pyn_water[0].outline = &pl_outline_water[0];
	pyn_water[0].name = "基湖";
	pyn_water[1].outline = &pl_outline_water[1];
	pyn_water[1].name = "荔湖";

	mainroad_set.pPLs = pl_m_road;
	mainroad_set.iPLCount = _m_road_count;

	generroad_set.pPLs = pl_g_road;
	generroad_set.iPLCount = _g_road_count;

	green_set.pPoly = &pyn_green;
	green_set.iPolyCount =  1;
	
	g_in_w_set.pPoly = pyn_green_back;
	g_in_w_set.iPolyCount = 2;

	school_set.pPts = pt_school;
	school_set.iPtsCount = 2;

	unit_set.pPts = pt_unit;
	unit_set.iPtsCount = 46;

	water_set.pPoly = pyn_water;
	water_set.iPolyCount = 2;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	mainroad_set.color = GUI_WHITE; 
	mainroad_set.type_id = 100; 
	mainroad_set.type_name = "main_road"; 
 
	generroad_set.color = GUI_WHITE; 
	generroad_set.type_id = 101; 
	generroad_set.type_name = "general_raod"; 
 
	green_set.color = GUI_GREEN; 
	green_set.type_id = 102; 
	green_set.type_name = "green_belt"; 
 
	school_set.color = GUI_RED;
	school_set.type_id = 103;
	school_set.type_name = "school";

	unit_set.color=GUI_YELLOW;
	unit_set.type_id=104;
	unit_set.type_name="unit";

	water_set.color=GUI_BLUE;
	water_set.type_id=105;
	water_set.type_name="water_belt";

	g_in_w_set.color=GUI_GREEN;
	g_in_w_set.type_id=106;
	g_in_w_set.type_name="ginw_belt";

	GPS_InsertConf("main_road",100);
	GPS_InsertConf("general_raod",101);
	GPS_InsertConf("green_belt",102);
	GPS_InsertConf("school",103);
	GPS_InsertConf("unit",104);
	GPS_InsertConf("water_belt",105);
	GPS_InsertConf("ginw_belt",106);

  _Task_0();
  _Task_1();
}

void MainTask(void) {

	MultTask_MainTask();
	while(1);
  //MainTask_Game();
}