⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 measure.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
	const U16	bt_w = 40, bt_h = 20, bt_y = PHY_LCD_H - bt_h - 1;
	const U16	sb_w = 20;

	orireg.left = 0;
	orireg.top = 0;
	orireg.right = 156;
	orireg.bottom = 216;

/*//for test
	temp = 10;
	for ( test = 0; test < 31; test++ )
		temp = temp * 10;
	test = 0x7fff * temp;
	right = (double)(*buffer);
	t1 = 2 << 1025;
	if ( test > right )
		temp = 1;
	else
		temp = 0;
*/
	memset( &oldreginfo, 0, sizeof(RECT) );

	mainwin = CreateWindow(	WNDCLASS_WIN,
							NULL,
							WS_BORDER,
							0,0,
							PHY_LCD_W,PHY_LCD_H,
							0,
							0,
							NULL);
	
	bt_zoom_in = CreateWindow(WNDCLASS_BUTTON, "放大", WS_CHILD|BS_REGULAR, 0,bt_y, bt_w, bt_h,mainwin,0,NULL);
	bt_zoom_out = CreateWindow(WNDCLASS_BUTTON, "缩小", WS_CHILD|BS_REGULAR, 40, bt_y, bt_w, bt_h,mainwin,0,NULL);
	bt_move = CreateWindow(WNDCLASS_BUTTON, "平移", WS_CHILD|BS_TOOLBAR, 80, bt_y, bt_w, bt_h,mainwin,0,NULL);
	bt_back = CreateWindow(WNDCLASS_BUTTON, "返回", WS_CHILD|BS_REGULAR, 120,bt_y, bt_w, bt_h,mainwin,0,NULL);

//	vsb = CreateWindow(WNDCLASS_SCROLL, "VertScroll", WS_CHILD|SBS_VERT, (U16)(PHY_LCD_W-sb_w-1),1,sb_w,198,mainwin,MAKELONG(1,1), NULL);
//	hsb = CreateWindow(WNDCLASS_SCROLL, "HorzScroll", WS_CHILD|SBS_HORZ, 1,(U16)(PHY_LCD_H-sb_w-bt_h-1),139,sb_w,mainwin,MAKELONG(1,1), NULL);

	hGC = GetGC();
//	hbmp = LoadBitmap( map_bkg001 );
//	DisplayBMP( hGC, 2, 2, hbmp );
	hbmp = LoadBitmap( seu_map1,NULL );
	SysDspCutBMP( hGC, 2, 2, hbmp, &orireg, 1 );

	for ( i = 0; i < 4; i++ )
	{
		ActiveAreaEnable( &area[i],INPUT_AREA, CONTINUOUS_MODE, regs[i].left, 
							regs[i].top, regs[i].right, regs[i].bottom, NULL );
	}

	while(!quit)
	{
		ASIXGetMessage(&msg, NULL, 0, 0);
		switch(msg.message)
		{
			case WM_COMMAND:
				if( msg.lparam == bt_back )
				{
					// 返回
					quit = 1;
				}
				else if( msg.lparam == bt_zoom_in )
				{
					//放大
					if( zoom_state == ZOOM_IN )
						zoom_state = ZOOM_ZERO;
					else
						zoom_state = ZOOM_IN;
					DrawHorz( hGC, GPC_BLACK, 2, 108, 156, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
					DrawVert( hGC, GPC_BLACK, 78, 2, 216, GPC_SOLID_LINE, GPC_REPLACE_STYLE );
				}
				else if( msg.lparam == bt_zoom_out )
				{
					// 缩小
					zoom_state = ZOOM_OUT;
//					ClearRec( hGC, GPC_WHITE, 2, 2, 156, 216, GPC_REPLACE_STYLE );
					SysDspCutBMP( hGC, 2, 2, hbmp, &orireg, 1 );
				}
				else if( msg.lparam == bt_move )
				{
					// 平移
					if ( move_state != STATE_MOVING )
						move_state = STATE_MOVING;
					else
						move_state = STATE_STOP;
				}
				break;
			case WM_VSCROLL:
				// 垂直滚动
				break;
			case WM_HSCROLL:
				// 水平滚动
				break;
			case WM_REPAINT:
//				DisplayBMP( hGC, 2, 2, hbmp );
//				ClearRec( hGC, GPC_WHITE, 2, 2, 156, 216, GPC_REPLACE_STYLE );
				SysDspCutBMP( hGC, 2, 2, hbmp, &orireg, 1 );
				break;
			case ASIX_PEN:
				if ( move_state == STATE_MOVING )
					GetPos( msg, &xpos, &ypos );
				break;
			case ASIX_INPUT_STATUS:
				if( zoom_state == ZOOM_IN )
				{
					// 选择区域放大
					for ( i = 0; i < 4; i++ )
					{
						if( msg.lparam == area[i] )
						{
							break;
						}
					}
					
					memcpy( &oldreginfo, &reginfo, sizeof(RECT) );
					reginfo.left = orireg.left + regs[i].left;
					reginfo.top = orireg.top + regs[i].top;
					reginfo.right = orireg.left + regs[i].right;
					reginfo.bottom = orireg.top + regs[i].bottom;
//					ClearRec( hGC, GPC_WHITE, 2, 2, 156, 216, GPC_REPLACE_STYLE );
					if ( oldreginfo.left != reginfo.left || oldreginfo.top != reginfo.top
					     || oldreginfo.right != reginfo.right || oldreginfo.bottom != reginfo.bottom )
						SysDspCutBMP( hGC, 2, 2, hbmp, &reginfo, 2 );
				}
				if ( move_state == STATE_MOVING )
				{
					if ( msg.wparam == PPSM_INPUT_PEN_UP )
					{
						if ( zoom_state == ZOOM_IN )
						{
							for ( i = 0; i < 4; i++ )
							{
								if( msg.lparam == area[i] )
								{
									break;
								}
							}
							reginfo.left = orireg.left + regs[i].left + xpos - 39;
							reginfo.top = orireg.top + regs[i].top + ypos - 54;
							reginfo.right = reginfo.left + 78;
							reginfo.bottom = reginfo.top + 108;
							if ( reginfo.left < 0 )
							{
								reginfo.left = 0;
								reginfo.right = 78;
							}
							if ( reginfo.right > MAP_RIGHT )
							{
								reginfo.right = MAP_RIGHT;
								reginfo.left = MAP_RIGHT - 78;
							}
							if ( reginfo.top < 0 )
							{
								reginfo.top = 0;
								reginfo.bottom = 108;
							}
							if ( reginfo.bottom > MAP_BOTTOM )
							{
								reginfo.bottom = MAP_BOTTOM;
								reginfo.top = MAP_BOTTOM - 108;
							}
						}
						
						orireg.left = orireg.left + xpos - 78;
						orireg.top = orireg.top + ypos - 108;
						orireg.right = orireg.left + 156;
						orireg.bottom = orireg.top + 216;
						if ( orireg.left < 0 )
						{
							orireg.left = 0;
							orireg.right = 156;
						}
						if ( orireg.right > MAP_RIGHT )
						{
							orireg.right = MAP_RIGHT;
							orireg.left = MAP_RIGHT - 156;
						}
						if ( orireg.top < 0 )
						{
							orireg.top = 0;
							orireg.bottom = 216;
						}
						if ( orireg.bottom > MAP_BOTTOM )
						{
							orireg.bottom = MAP_BOTTOM;
							orireg.top = MAP_BOTTOM - 216;
						}
						
						if ( zoom_state == ZOOM_IN )
							SysDspCutBMP( hGC, 2, 2, hbmp, &reginfo, 2 );
						else
							SysDspCutBMP( hGC, 2, 2, hbmp, &orireg, 1 );

					}
				}
				break;
			case ASIX_KEY:
				if ( move_state == STATE_MOVING )
				{
					switch( msg.wparam )
					{
						case KEY_Up:
							if ( orireg.top > 0 )
							{
								orireg.top -= 5;
								orireg.bottom -= 5;
							}
							break;
						case KEY_Down:
							if ( orireg.bottom < MAP_BOTTOM )
							{
								orireg.bottom += 5;
								orireg.top += 5;
							}
							break;
						case KEY_Right:
							if ( orireg.right < MAP_RIGHT )
							{
								orireg.right += 5;
								orireg.left += 5;
							}
							break;
						case KEY_Left:
							if ( orireg.left > 0 )
							{
								orireg.left -= 5;
								orireg.right -= 5;
							}
							break;
						default:
							break;
					}
				}
				if ( zoom_state == ZOOM_IN )
				{
					reginfo.left = orireg.left + regs[i].left;
					reginfo.top = orireg.top + regs[i].top;
					reginfo.right = orireg.left + regs[i].right;
					reginfo.bottom = orireg.top + regs[i].bottom;
					ClearRec( hGC, GPC_WHITE, 2, 2, 156, 216, GPC_REPLACE_STYLE );
					SysDspCutBMP( hGC, 2, 2, hbmp, &reginfo, 2 );
				}
				else
					SysDspCutBMP( hGC, 2, 2, hbmp, &orireg, 1 );
				break;
			case WM_QUIT:
				quit = 1;
				break;
		}
		DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam); 
	}
	
	FreeBitmap( hbmp);
	DestroyWindow( mainwin );

	return;
}

void SetCode( void )
{
	MSG 	msg;
 	U32		mainwin;
 	U8		quit=0;
	U32		st_promt[5];
	S8		*prompt[5] = { "省", "市", "县", "乡", "村" };
	U32		bt_ok, bt_cancel;
	U32		lb_promt[5];
	U8		i, j;
	U16		st_y;
	U8		num;
	DISTRICT	*district, *subdis;
 
	struct LBOX_ITEM	*lb_item[5] =
	{
		province,
		city,
		county,
		countryside,
		village
	};

	const U16	title_x = 1, title_y = 1;
	const U16	title_w = PHY_LCD_W -2, title_h = 30;
	const U16	bt_w = 40, bt_h = 20, bt_y = PHY_LCD_H - bt_h -5;
	const U16	st_w = 16, st_h = 20, st_x = 25;
	const U16	lb_w = 80, lb_h = 20, lb_x = PHY_LCD_W - lb_w -25;

 	mainwin = CreateWindow(	WNDCLASS_WIN,
							"代码设置",
							WS_OVERLAPPEDWINDOW,
							0,0,
							PHY_LCD_W,PHY_LCD_H,
							0,
							0,
							NULL);
	
	
	bt_ok = CreateWindow(WNDCLASS_BUTTON, "确认", WS_CHILD|BS_REGULAR, 27,bt_y,bt_w,bt_h,mainwin,0,NULL);
	bt_cancel = CreateWindow(WNDCLASS_BUTTON, "取消", WS_CHILD|BS_REGULAR, 93,bt_y,bt_w,bt_h,mainwin,0,NULL);
	
	// initialize default choise
	district = ChinaDistrict;
	for( i = 1; i < 5; i++ )
	{
		if( district != NULL )
		{
			subdis = district[ParSelect.code[i-1]].sub;
			num = district[ParSelect.code[i-1]].subnum;
		}
		else
		{
			subdis = NULL;
			num = 0;
		}
		for( j = 0; j < num; j++ )
		{
			lb_item[i][j].item_status = ICON_ENABLE;
			lb_item[i][j].item_underline = UNUNDERLINE;
			lb_item[i][j].item_text = subdis[j].name;
		}
		lb_item[i][j].item_status = ICON_END;
		lb_item[i][j].item_underline = UNUNDERLINE;
		lb_item[i][j].item_text = NULL;
		district = subdis;
	}

	st_y = 35;
	for( i = 0; i < 5; i++ )
	{
		st_promt[i] = CreateWindow(WNDCLASS_STATIC, prompt[i], WS_CHILD|SS_TEXT, st_x,st_y,st_w,st_h,mainwin,0,NULL);
		lb_promt[i] = CreateWindow(WNDCLASS_LIST, prompt[i], WS_CHILD, lb_x,st_y,lb_w,lb_h,mainwin,0,(struct LBOX_ITEM	*)lb_item[i]);
		SelectListBox( lb_promt[i], ParSelect.code[i] );
		st_y += 35;
	}


	while(!quit)
	{
		ASIXGetMessage(&msg, NULL, 0, 0);
		switch(msg.message)
		{
			case WM_COMMAND:
				if( msg.lparam == bt_ok )
				{
					// 确认
					quit = 1;					
				}
				else if( msg.lparam == bt_cancel )
				{
					// 取消
					quit = 1;
				}
				break;
			case WM_LISTBOX:
				district = ChinaDistrict;
				for( i = 0; i < 5; i++ )
				{
					if( msg.lparam == lb_promt[i] )
					{
						U8	k;
						
						ParSelect.code[i] = (U8)msg.wparam;
						district = &district[ParSelect.code[i]];
						for( j = i+1; j < 5; j++ )
						{
							ParSelect.code[j] = 0;

							if( district != NULL )
							{
								subdis = district[ParSelect.code[j]].sub;
								num = district[ParSelect.code[j]].subnum;
							}
							else
							{
								subdis = NULL;
								num = 0;
							}
							for( k = 0; k < num; k++ )
							{
								lb_item[j][k].item_status = ICON_ENABLE;
								lb_item[j][k].item_underline = UNUNDERLINE;
								lb_item[j][k].item_text = subdis[k].name;
							}
							lb_item[j][k].item_status = ICON_END;
							lb_item[j][k].item_underline = UNUNDERLINE;
							lb_item[j][k].item_text = NULL;
							district = subdis;
							RepaintWindow( lb_promt[j], 0 );
						}
						break;
					}
					district = district[ParSelect.code[i]].sub;
				}
				break;
			case WM_QUIT:
				quit = 1;
				break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -