Exemple #1
0
bool HandleCapture(HWND hwnd, UINT message, POINT MousePoint)
{
	if (capture_rect)
	{
		bool inside, hilite, release = false;
		inside = hilite = (PtInRect(capture_rect, MousePoint) != 0);

		if (message == WM_LBUTTONUP ||
			message == WM_MBUTTONUP ||
			message == WM_RBUTTONUP ||
			GetCapture() != hwnd)
		{
			release = true;
			hilite  = false;
		}

		if (pressed_state && (hilite != *pressed_state))
		{
			*pressed_state = hilite;
			InvalidateRect(hwnd, capture_rect, FALSE);
		}

		if (release)
			ReleaseButton(capture_rect);

		if (inside)
			MouseButtonEvent(message, button_id);

		return true;
	}
	return false;
}
Exemple #2
0
/**********************************************************************
 * 函数名称: SavePageRun
 * 功能描述: "Save页面"的运行函数: 显示菜单图标,根据用户输入作出反应
 * 输入参数: ptParentPageParams - 未用
 * 输出参数: 无
 * 返 回 值: 无
 ***********************************************************************/
static void SavePageRun(PT_PageParams ptParentPageParams)
{
	int iIndex;
	T_InputEvent tInputEvent;
	int bPressed = 0;
	int iIndexPressed = -1;
    	T_PageParams tPageParams;
	g_bSaveThreadShouldExit = 0;
   	tPageParams.iPageID = ID("save");
	
	/* 1. 显示页面 */
	ShowSavePage(&g_tSavePageLayout);

	/* 2. 创建串口传输和保存数据线程 */
	 pthread_create(&g_tSaveThreadID, NULL, SaveThreadFunction, NULL);
	/* 3. 调用GetInputEvent获得输入事件,进而处理 */
	while (1)
	{	
		iIndex = SavePageGetInputEvent(&g_tSavePageLayout, &tInputEvent);
		if (tInputEvent.iPressure == 0)
		{
			/* 如果是松开 */
			if (bPressed)
			{
				/* 曾经有按钮被按下 */
				ReleaseButton(&g_atSavePageIconsLayout[iIndexPressed]);
				bPressed = 0;

				if (iIndexPressed == iIndex) /* 按下和松开都是同一个按钮 */
				{
					switch (iIndexPressed)
					{
						case 1: /* "返回主目录"按钮 */
						{
							   pthread_mutex_lock(&g_tSaveThreadMutex);
						            g_bSaveThreadShouldExit = 1;   /* SaveThreadFunction线程检测到这个变量为1后会退出 */
						            pthread_mutex_unlock(&g_tSaveThreadMutex);
						            pthread_join(g_tSaveThreadID, NULL);  /* 等待子线程退出 */
							return;
						}
						default:
						{
							break;
						}
					}
				}

				iIndexPressed = -1;
			}
		}
		else
		{
			/* 按下状态 */
			if (iIndex != -1)
			{
				if (!bPressed)
				{
					/* 未曾按下按钮 */
					bPressed = 1;
					iIndexPressed = iIndex;
					PressButton(&g_atSavePageIconsLayout[iIndexPressed]);
				}
			}
		}		
	}	
}
/**********************************************************************
 * 函数名称: IntervalPageRun
 * 功能描述: "interval页面"的运行函数: 显示菜单图标,显示时间间隔,根据用户输入作出反应
 * 输入参数: ptParentPageParams - 未用
 * 输出参数: 无
 * 返 回 值: 无
 * 修改日期        版本号     修改人	      修改内容
 * -----------------------------------------------
 * 2013/02/08	     V1.0	  韦东山	      创建
 ***********************************************************************/
static void IntervalPageRun(PT_PageParams ptParentPageParams)
{
	int iIndex;
	T_InputEvent tInputEvent;
	T_InputEvent tInputEventPrePress;
	int bPressed = 0;
	int iIndexPressed = -1;
	int iIntervalSecond = g_iIntervalSecond;
	PT_VideoMem ptDevVideoMem;
	int bFast = 0;  /* 表示快速加减 */

	ptDevVideoMem = GetDevVideoMem();

	/* 这两句只是为了避免编译警告 */
	tInputEventPrePress.tTime.tv_sec = 0;
	tInputEventPrePress.tTime.tv_usec = 0;
	
	/* 1. 显示页面 */
	ShowIntervalPage(&g_tIntervalPageLayout);

	/* 2. 创建Prepare线程 */

	/* 3. 调用GetInputEvent获得输入事件,进而处理 */
	tInputEvent.iPressure = 0; /* 避免编译警告 */
	while (1)
	{
		/*判断输入事件位于哪一个图标上*/
		iIndex = IntervalPageGetInputEvent(&g_tIntervalPageLayout, &tInputEvent);
 		if (tInputEvent.iPressure == 0)	/* 如果是松开 */
		{
			if (bPressed)/* 曾经有按钮被按下 */
			{
				bFast = 0;
				ReleaseButton(&g_atIntervalPageIconsLayout[iIndexPressed]);
				bPressed = 0;

				if (iIndexPressed == iIndex) /* 按下和松开都是同一个按钮 */
				{
					switch (iIndexPressed)
					{
						case 0: /* inc按钮 */
						{
							iIntervalSecond++;
							if (iIntervalSecond == 60)
							{
								iIntervalSecond = 0;
							}
							/* 为"interval页面"生成特殊图标: 绘制图标中的数字*/
							GenerateIntervalPageSpecialIcon(iIntervalSecond, ptDevVideoMem);
							break;
						}
						case 2: /* dec按钮 */
						{
							iIntervalSecond--;
							if (iIntervalSecond == -1)
							{
								iIntervalSecond = 59;
							}
							GenerateIntervalPageSpecialIcon(iIntervalSecond, ptDevVideoMem);
							break;
						}
						case 3: /* ok按钮 */
						{
							g_iIntervalSecond = iIntervalSecond;
							
							return;
							break;
						}
						case 4: /* cancel按钮 */
						{
							return;
							break;
						}
						default:
						{
							break;
						}
					}
				}
				
				iIndexPressed = -1;
			}
		}
		else
		{
			/* 按下状态 */
			if (iIndex != -1)
			{
				if (!bPressed && (iIndex != 1))
				{
					/* 未曾按下按钮 */
					bPressed = 1;
					iIndexPressed = iIndex;
					tInputEventPrePress = tInputEvent;  /* 记录下来 */
					PressButton(&g_atIntervalPageIconsLayout[iIndexPressed]);
				}

				/* 如果按下的是"inc.bmp"或"dec.bmp" 
				 * 连按2秒后, 飞快的递增或减小: 每50ms变化一次
				 */
				if ((iIndexPressed == 0) || (iIndexPressed == 2))
				{
					if (bFast && (TimeMSBetween(tInputEventPrePress.tTime, tInputEvent.tTime) > 50))
					{
						iIntervalSecond = iIndexPressed ? (iIntervalSecond - 1) : (iIntervalSecond + 1);
						if (iIntervalSecond == 60)
						{
							iIntervalSecond = 0;
						}
						else if (iIntervalSecond == -1)
						{
							iIntervalSecond = 59;
						}
						GenerateIntervalPageSpecialIcon(iIntervalSecond, ptDevVideoMem);
						tInputEventPrePress = tInputEvent;
					}
					
					if (TimeMSBetween(tInputEventPrePress.tTime, tInputEvent.tTime) > 2000)
					{
						bFast = 1;
						tInputEventPrePress = tInputEvent;
					}
					
				}
			}
		}		
	}
}
static void MainRunPage(struct PageIdetify *ptParentPageIdentify)
{
	int iIndex;
	int iError = 0;
	int iIndexPressed = -1;	/* 判断是否是在同一个图标上按下与松开 */
	int bPressedFlag = 0;
	struct InputEvent tInputEvent;
	struct PageIdetify tMainPageIdentify;

	tMainPageIdentify.iPageID = GetID("main");
	ShowMainPage(&g_tMainPageLayout);

	while(1){
		/* 该函数会休眠 */
		iIndex = MainGetInputEvent(&g_tMainPageLayout, &tInputEvent);

		if(tInputEvent.bPressure == 0){
			/* 说明曾经有按下,这里是松开 */
			if(bPressedFlag){
				bPressedFlag = 0;
				ReleaseButton(&g_atMainPageIconsLayout[iIndexPressed]);

				/* 在同一个按钮按下与松开 */
//				if(iIndexPressed != iIndex){
//					goto nextwhilecircle;
//				}
				switch(iIndexPressed){
					case 0: {
						GetPageOpr("browse")->RunPage(&tMainPageIdentify);
						ShowMainPage(&g_tMainPageLayout);
						break;
					}
					case 1: {
						GetPageOpr("auto")->RunPage(&tMainPageIdentify);
						ShowMainPage(&g_tMainPageLayout);
						break;
					}
					case 2: {
						GetPageOpr("setting")->RunPage(&tMainPageIdentify);
						ShowMainPage(&g_tMainPageLayout);
						break;
					}
					case 3: {
						return; /* 退出整个程序 */
					}
					default: {
						DebugPrint(DEBUG_EMERG"Somthing wrong\n");
						break;
					}
				}
				iIndexPressed = -1;
			}
		}else{
			if(iIndex != -1){
				if(0 == bPressedFlag){
					bPressedFlag = 1;
					iIndexPressed = iIndex;
					PressButton(&g_atMainPageIconsLayout[iIndexPressed]);

				}			
			}
		}
//nextwhilecircle:
	iError = 0;
	}
}