// Simulate the selection of OK and Cancel buttons when Alt+K and
// Alt+C are pressed.  CMyPropertySheet is a CPropertySheet-derived 
// class.
BOOL CMyPropertySheet::PreTranslateMessage(MSG* pMsg) 
{
   if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
   {
      BOOL altkey = GetKeyState(VK_MENU) < 0;
      if (altkey)
      {
         BOOL handled = TRUE;
         switch(toupper((int)pMsg->wParam))
         {
         case 'C':                     // for Alt+C - Cancel button
            PressButton(PSBTN_CANCEL);   // or EndDialog(IDCANCEL);
            break;

         case 'K':                     // for Alt+K - OK button
            PressButton(PSBTN_OK);      // or EndDialog(IDOK);
            break;

         default:
            handled = FALSE;
         }

         if (handled)
            return TRUE;
      }
   }

   return CPropertySheet::PreTranslateMessage(pMsg);
}
Exemplo n.º 2
0
LRESULT CNewDocWizIntro::OnDoubleClickList(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	if (m_Data->m_nSelectedItem >= 0)
		PressButton(PSBTN_NEXT);

	return S_OK;
}
Exemplo n.º 3
0
/** \brief jump to a Blu-ray root or popup menu
 */
bool BDRingBuffer::GoToMenu(const QString str, int64_t pts)
{
    if (!m_isHDMVNavigation || pts < 0)
        return false;

    if (!m_topMenuSupported)
    {
        VERBOSE(VB_PLAYBACK, LOC + "Top Menu not supported");
        return false;
    }

    VERBOSE(VB_PLAYBACK, LOC + QString("GoToMenu %1").arg(str));

    if (str.compare("root") == 0)
    {
        if (bd_menu_call(bdnav, pts))
        {
            VERBOSE(VB_PLAYBACK, LOC + QString("Invoked Top Menu (pts %1)")
                                                .arg(pts));
            return true;
        }
    }
    else if (str.compare("popup") == 0)
    {
        PressButton(BD_VK_POPUP, pts);
        return true;
    }
    else
        return false;

    return false;
}
Exemplo n.º 4
0
// flag is to enable finish button push
void CNewProfileWizard::DoFinish()
{
	if (m_pNamePage && ::IsWindow(m_pNamePage->GetSafeHwnd()))
		m_pNamePage->DoFinish();

	if (m_pProfileNamePage && ::IsWindow(m_pProfileNamePage->GetSafeHwnd())) {
		if (m_pProfileNamePage->DoFinish())     {
			if (m_bUpgrade) {
				if (m_pConfirmPage && ::IsWindow(m_pConfirmPage->GetSafeHwnd()))
					m_pConfirmPage->DoFinish();
			} else {
				login_CreateEmptyProfileDir(m_pProfilePath, this, m_bExistingDir); 

#ifdef MOZ_MAIL_NEWS
				if (m_pSendMailPage && ::IsWindow(m_pSendMailPage->GetSafeHwnd()))
					m_pSendMailPage->DoFinish();
				if (m_pReceiveMailPage && ::IsWindow(m_pReceiveMailPage->GetSafeHwnd()))
					m_pReceiveMailPage->DoFinish();   
				if (m_pReadNewsPage && ::IsWindow(m_pReadNewsPage->GetSafeHwnd()))
					m_pReadNewsPage->DoFinish(); 
#endif // MOZ_MAIL_NEWS               
			}

			if (theApp.m_bPEEnabled)
			{
				// PE: upgrad case
				if(m_bMucEnabled && m_bUpgrade && m_pMucEditPage 
					&& ::IsWindow(m_pMucEditPage->GetSafeHwnd()))
						m_pMucEditPage->DoFinish();

				// PE: dialer thread: 
				if(m_bMucEnabled && m_pMucEditPage 
					&& ::IsWindow(m_pMucEditPage->GetSafeHwnd()))
						m_pMucEditPage->DoFinish();

				// PE: account setup thread
				else if (m_bASWEnabled && m_pASWReadyPage 
					&& ::IsWindow(m_pASWReadyPage->GetSafeHwnd()))
						m_pASWReadyPage->DoFinish();

				// PE: network thread
				else 
				{
					CMucProc        m_mucProc;
					m_mucProc.SetDialOnDemand("",FALSE);
				}
			}

			PressButton(PSBTN_FINISH);
		}
	}
}
Exemplo n.º 5
0
void CNewProfileWizard::DoBack()
{
	PressButton(PSBTN_BACK);

	if(theApp.m_bPEEnabled)
	{
		CPropertyPage* curPage = GetActivePage();
		
		if(curPage == m_pASWReadyPage)  
			SetActivePage(m_pProfileNamePage);
		
		if(curPage == m_pMucReadyPage && m_bUpgrade)
			SetActivePage(m_pProfileNamePage);

		if(curPage == m_pMucIntroPage && m_bUpgrade)
			SetActivePage(m_pIntroPage);
	}
}
Exemplo n.º 6
0
void CNewProfileWizard::DoNext()
{
	PressButton(PSBTN_NEXT);

	if(theApp.m_bPEEnabled)
	{
		CPropertyPage* curPage = GetActivePage();

		if(curPage == m_pMucIntroPage && m_bUpgrade)    // skip muc intro page
				SetActivePage(m_pNamePage);
		
		if(curPage == m_pNamePage && ::IsWindow(m_pNamePage->GetSafeHwnd()))
				m_pNamePage->ShowHideEmailName();
		
		if(curPage == m_pASWReadyPage)
		{
			if(!m_bASWEnabled)
			{
				if (m_bUpgrade) 
					SetActivePage(m_pMucEditPage);
				else
#ifdef MOZ_MAIL_NEWS               
					SetActivePage(m_pSendMailPage);
#else
					SetActivePage(m_pMucReadyPage);
#endif /* MOZ_MAIL_NEWS */
			}
		}
		
#ifdef MOZ_MAIL_NEWS      
		if(curPage == m_pReceiveMailPage)
			m_pReadNewsPage->SetFinish(!m_bMucEnabled);
#endif /* MOZ_MAIL_NEWS */
		
		if(curPage == m_pMucReadyPage || curPage == m_pMucEditPage)
			SetTitle(m_title);
	}
}
Exemplo n.º 7
0
void CSpiroView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	if (m_bDrawingActive)
		return;

	if (m_bDroppingAnchor || m_bDroppingWheel)
	{
		ASSERT(!m_bDrawingDone);
		CWheel* pWheelDrop = NULL;
		CRing*	pRingDrop = NULL;
		CSpiroDoc* pDoc = GetDocument();
		ENSURE(pDoc != NULL);

		//convert the client coordinates to logical coordinates
		CDC* pDC = GetDC();
		ENSURE(pDC != NULL);
		OnPrepareDC(pDC);

		// Convert client coordinates to Logical coordinates
		CPoint pointScaled(point);
		pDC->DPtoLP(&pointScaled);
		point.x = pointScaled.x * m_nZoomDenom / m_nZoomNumer;  // undo scaling effects
		point.y = pointScaled.y * m_nZoomDenom / m_nZoomNumer;

		CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
		ENSURE(pFrame != NULL && pFrame->IsKindOf(RUNTIME_CLASS(CMainFrame)));

		if (m_bDroppingAnchor)
		{
			ASSERT(m_iPieceDropped >= 0 && m_iPieceDropped < TOTALRINGS);
			pRingDrop = new CRing(CRing::m_rgnRads[m_iPieceDropped] - RINGWIDTH,
				CRing::m_rgnRads[m_iPieceDropped],
				CRing::m_rgco[m_iPieceDropped], RGB(0, 0, 0));

			ENSURE(pRingDrop != NULL);  
			m_bDroppingAnchor = false;
			ENSURE(m_pAnchor == NULL);
			m_pAnchor = pRingDrop;
			m_pAnchor->SetPosition(point);
			m_dDataAnchorFirst = m_pAnchor->GetFigData();
		}
		else if (m_bDroppingWheel)
		{
			CBasePiece** ppPiece = (m_pAnchor == NULL? &m_pAnchor : &m_pWheel);
			ASSERT(m_iPieceDropped >= 0 && m_iPieceDropped < TOTALWHEELS);
			pWheelDrop = new CWheel(CWheel::m_rgnRads[m_iPieceDropped],
								CWheel::m_rgco[m_iPieceDropped],
								CWheel::m_rgcoPattern[m_iPieceDropped]);
								

			ENSURE(pWheelDrop != NULL);
			ENSURE(*ppPiece == NULL);
			*ppPiece = pWheelDrop;
			m_bDroppingWheel = false;
			(*ppPiece)->SetPosition(point);

			if (m_pWheel != NULL)
			{
				m_pWheel->SetWheelMode();

				// set the default pen location. pDC and zoom ration are dummies
				m_pWheel->SetPenLocation(this, pDC, CPoint(0, 0), 1, 1);

				ENSURE(m_pAnchor != NULL);

				CPoint ptContact;
				double dAngle;
				// Get contact position from the anchor and set wheel position
				// Decides if wheel is internal in case of being a ring
				m_pAnchor->GetContactPosition(pointScaled, m_nZoomNumer, 
										m_nZoomDenom, ptContact, dAngle);
			
				if (m_pWheel->GetPerimeter() >= m_pAnchor->GetPerimeter())
				{
					pointScaled.x = 0;
					pointScaled.y = 0;   // force the wheel out of the ring

					// get contact position again to make sure it's right
					m_pAnchor->GetContactPosition(pointScaled, m_nZoomNumer, 
											m_nZoomDenom, ptContact, dAngle);
				}

 				m_pWheel->SetPosition(ptContact, dAngle);
				m_dDataWheelFirst = m_pWheel->GetFigData();
				m_ptWheelPosFirst = m_pWheel->m_ptPos;
				PressButton(0);  // get the color settings for the new wheel
				CreateFigure();
			}

			m_iPieceDropped += TOTALRINGS + 1;
#ifdef _DEBUG
			int nID = pFrame->m_wndToolBarSpiro.GetItemID(m_iPieceDropped);
			ASSERT(nID >= ID_ENORMOUSWHEEL && nID <= ID_TINYWHEEL);
#endif
		}

		// uncheck the button used to select the piece in the toolbar
		UINT nButtonID = pFrame->m_wndToolBarSpiro.GetItemID(m_iPieceDropped);
		pFrame->m_wndToolBarSpiro.GetToolBarCtrl().CheckButton(nButtonID, FALSE);

		// invalidate the region holding the ring
		CRgn	rgn;  // region occupied by the piece
		(m_pWheel != NULL? m_pWheel : m_pAnchor)->GetDevPieceRgn(pDC,
									&rgn, m_nZoomNumer, m_nZoomDenom, false);

		InvalidateRgn(&rgn, FALSE);
		m_iPieceDropped = -1; // reset to keep control on values.
		ReleaseDC(pDC);
		return;
	}

	// check if the user wants to drag the pen position

	CDC* pDC = GetDC();
	ENSURE(pDC != NULL);
	OnPrepareDC(pDC);
	CPoint pointScaled(point);
	pDC->DPtoLP(&pointScaled);   // gets the logical coord point value with scale into account

	if (m_pWheel != NULL)
	{
		if (m_pWheel->HitTest(pDC, point, m_nZoomNumer, m_nZoomDenom) == HIT_PEN_LOCATION)  // start drag operation
		{
			MSG		msg;

			// if there is a WM_LBUTTONUP in the queue do not drag pencil location
			if (!::PeekMessage(&msg, m_hWnd, WM_LBUTTONUP, WM_LBUTTONUP, PM_NOREMOVE))
			{
				ClientToScreen(&point); // convert to screen coordinates
				CRect rectWindow;
				GetWindowRect(&rectWindow);
				point.x -= rectWindow.left;
				point.y -= rectWindow.top;  // point relative to windows corner

				CImageList& il = GetApp()->m_imageList;
				::ShowCursor(FALSE);
				il.BeginDrag(0, CPoint(0, 47));
				il.DragEnter(this, point);
				m_bMovingPencil = true;
				SetCapture();
			}
		}
	}

	for (;;) 
	{
		CRgn	rgn;
		MSG		msg;

		if (::PeekMessage(&msg, m_hWnd, WM_LBUTTONUP, WM_LBUTTONUP, PM_NOREMOVE))  // no drag is being requested
			break;

		if (m_pWheel != NULL)
		{
			m_pWheel->GetLogPieceRgn(&rgn, m_nZoomNumer, m_nZoomDenom);
			if (rgn.PtInRegion(pointScaled))  // clicked on wheel.  Don't do anything
				break;

			rgn.DeleteObject();
		}

		if (m_pAnchor != NULL)
		{
			m_pAnchor->GetLogPieceRgn(&rgn, m_nZoomNumer, m_nZoomDenom);
			if (rgn.PtInRegion(pointScaled))   // clicked on the anchor
				break;

			rgn.DeleteObject();
		}

		// find now if the user clicked on a Figure.  The current Figure cannot be dragged.  This is by design
		CSpiroDoc*	pDoc = GetDocument();
		INT_PTR		iPic;
		CFigure*	pFigure;
		CSpiroRect	rect;

		for (iPic = pDoc->m_arrPFigures.GetUpperBound(); iPic >= 0; iPic--)
		{
			pFigure = (CFigure*)pDoc->m_arrPFigures.GetAt(iPic);
			ENSURE(pFigure != NULL);
			pFigure->GetBoundingRect(&rect);
			rect.Scale(m_nZoomNumer, m_nZoomDenom);
			if (pointScaled.x < rect.left || pointScaled.x >= rect.right ||
					pointScaled.y > rect.top || pointScaled.y <= rect.bottom)
			{
				continue;
			}

			bool bCopy = (nFlags & MK_CONTROL) == MK_CONTROL;
			m_pFigureDrag = (bCopy? new CFigure(pFigure) : pFigure);

			if (!bCopy)
				pDoc->m_arrPFigures.RemoveAt(iPic);

			ENSURE(m_pILDragFigure == NULL);

			// First draw the Figure into a memery DC using an allocated bitmap
			CDC	dcMem;
			ENSURE(pDC != NULL);

			VERIFY(dcMem.CreateCompatibleDC(pDC));
			dcMem.SetMapMode(MM_SPIRO);
			dcMem.SetViewportOrg(0, 0);
			dcMem.SetWindowOrg(rect.left, rect.top);

			CSpiroRect	rectBitmap(rect);
			dcMem.LPtoDP(&rectBitmap);
			ASSERT(rectBitmap.left == 0 && rectBitmap.top == 0);

			int			nWidth = rectBitmap.right;
			int			nHeight = rectBitmap.bottom;

			CBitmap*	pbmOld = NULL;
			
			ASSERT(m_pBitmapDragFigure == NULL);
			m_pBitmapDragFigure = new CBitmap();
			m_pBitmapDragFigure->CreateCompatibleBitmap(pDC, nWidth, nHeight);
			pbmOld = dcMem.SelectObject(m_pBitmapDragFigure);

		//	dcMem.PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), WHITENESS);
			CBrush	brush;
			brush.CreateStockObject(WHITE_BRUSH);
			dcMem.FillRect(&rect, &brush);
			m_pFigureDrag->Draw(&dcMem, m_nZoomNumer, m_nZoomDenom, NULL, &rect);
			dcMem.SelectObject(pbmOld);
			// Then create an imagelist and add the bitmap to it
			ASSERT(m_pILDragFigure == NULL);
			m_pILDragFigure = new CImageList();				
			VERIFY(m_pILDragFigure->Create(nWidth, nHeight, ILC_COLOR | ILC_MASK, 1, 1));
			VERIFY(m_pILDragFigure->Add(m_pBitmapDragFigure, RGB(255, 255, 255)) == 0);

			m_bStartDrag = true;  // Enter the drag on first mouse move

			//calculate the hot spot for the figure
			m_ptHotSpotDragFigure.x = pointScaled.x - rect.left;
			m_ptHotSpotDragFigure.y = pointScaled.y - rect.bottom;
			pDC->SetWindowOrg(0, rect.top - rect.bottom);
			pDC->SetViewportOrg(0, 0);
			pDC->LPtoDP(&m_ptHotSpotDragFigure);
			m_pILDragFigure->BeginDrag(0, m_ptHotSpotDragFigure);
			SetCapture();
			break;
		}

		break;
	}

	ReleaseDC(pDC);
	CScrollView::OnLButtonDown(nFlags, point);
}
Exemplo n.º 8
0
void CSpiroView::OnYellow() 
{
	PressButton(ID_YELLOW);	
}
Exemplo n.º 9
0
RobotInitForm::RobotInitForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::RobotInitForm)
{
    ui->setupUi(this);
    //初始化定时器
    PButtonTimer = new QTimer(this);
    PButtonTimer->setInterval(PBQTIMER_STEP);
    connect(PButtonTimer, SIGNAL(timeout()), this, SLOT(PressButton()));
    connect(ui->Ax1DButton,SIGNAL(pressed()), this,SLOT(PressButton()));
    connect(ui->Ax1UButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->Ax2DButton,SIGNAL(pressed()), this,SLOT(PressButton()));
    connect(ui->Ax2UButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->Ax3DButton,SIGNAL(pressed()), this,SLOT(PressButton()));
    connect(ui->Ax3UButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->Ax4DButton,SIGNAL(pressed()), this,SLOT(PressButton()));
    connect(ui->Ax4UButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->Ax5DButton,SIGNAL(pressed()), this,SLOT(PressButton()));
    connect(ui->Ax5UButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->Ax6DButton,SIGNAL(pressed()), this,SLOT(PressButton()));
    connect(ui->Ax6UButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->DPosButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->UPosButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->FPosButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->BPosButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->RPosButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->LPosButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->XOriUButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->XOriDButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->YOriDButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->YOriUButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->ZOriDButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->ZOriUButton,SIGNAL(pressed()),this, SLOT(PressButton()));
    connect(ui->TurnZeroButton,SIGNAL(pressed()),this,SLOT(ResetRobot()));
    connect(ui->LinePathShow,SIGNAL(clicked()),this,SLOT(LinePathPlan()));
    this->hide();

}
Exemplo n.º 10
0
void CSpiroView::OnGreen() 
{
	PressButton(ID_GREEN);	
}
Exemplo n.º 11
0
void CSpiroView::OnBlue() 
{
	PressButton(ID_BLUE);	
}
Exemplo n.º 12
0
void CSpiroView::OnBlack() 
{
	PressButton(ID_BLACK);
}
Exemplo n.º 13
0
/**********************************************************************
 * 函数名称: 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;
					}
					
				}
			}
		}		
	}
}
Exemplo n.º 14
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]);
				}
			}
		}		
	}	
}
Exemplo n.º 15
0
int main() {

    int r;

#if GRAPHICS
    struct Button *but,*button;
    boolean quit=FALSE;
    context = (struct Context *)malloc(sizeof(struct Context));

    but= context->Buttons= CreateButton(RUN_BUTTON,"RUN/STOP",WINDOW_W-50,WINDOW_H-90);
    but= but->Next=CreateButton(DISPLAY_RATE_UP_BUTTON,"+",WINDOW_W-40,WINDOW_H-60);
    but= but->Next=CreateButton(DISPLAY_RATE_DOWN_BUTTON,"-",WINDOW_W-60,WINDOW_H-60);
    but= but->Next=CreateButton(QUIT_BUTTON,"QUIT",WINDOW_W-50,WINDOW_H-30);

    display_rate=1L;

    OpenGraphics();
#endif

    robots = (struct Robot **)malloc(NR*sizeof(struct Robot*));

    for (r=0;r<NR;r++) {
        robots[r] = (struct Robot *)malloc(sizeof(struct Robot));
    }

    InitFiles();
    InitGlobal();

    for (r=0;r<NR;r++) {
        InitRobot(r,robots[r]);
    }

#if GRAPHICS
    while(quit == FALSE) {
        button=PressButton(context);
        switch(button->Value) {
        case QUIT_BUTTON:  
            quit = TRUE;
            break;
        case DISPLAY_RATE_UP_BUTTON:
            display_rate*=10L;
            if (display_rate>100000L) display_rate=100000L;
            display_rate-=display_rate%10L;
            if (display_rate<1L) display_rate=1L;
            DrawWindow(context);
            break;
        case DISPLAY_RATE_DOWN_BUTTON:
            if (display_rate>9L) display_rate/=10L;
            display_rate-=display_rate%10L;
            if (display_rate<1L) display_rate=1L;
            DrawWindow(context);
            break;

        case RUN_BUTTON:
#endif
            do { 

                for (r=0;r<NR;r++) {
                    RunRobot(r,robots[r]);
                    EvalRobot(t,r,robots[r]);
                }
                t++;
                if (t>TM) {
#if GRAPHICS
                    CloseGraphics();
#endif
                    return(1);
                    exit(1);
                }

#if GRAPHICS
                if (t%display_rate==0L) {
                    DrawWindow(context);
#if DISTY*(DISTY-2)
                    if (t%(250L*display_rate)==0L) {
                        DrawPlate(0,0,WINDOW_W-1,WINDOW_H-1,BLACK,PLATE_UP);
                    }
#endif
                }
#endif
            }
#if GRAPHICS
            while (UnpressButton(context,button)==FALSE); 
            break;
#else
            while (TRUE); 
#endif
#if GRAPHICS
        }
        button->State = PLATE_UP;
    }

    CloseGraphics();
#endif
    return(1);
}
Exemplo n.º 16
0
bool BDRingBuffer::HandleAction(const QStringList &actions, int64_t pts)
{
    if (!m_isHDMVNavigation)
        return false;

    if (actions.contains(ACTION_MENUTEXT))
    {
        PressButton(BD_VK_POPUP, pts);
        return true;
    }

    if (!IsInMenu())
        return false;

    bool handled = true;
    if (actions.contains(ACTION_UP) ||
        actions.contains(ACTION_CHANNELUP))
    {
        PressButton(BD_VK_UP, pts);
    }
    else if (actions.contains(ACTION_DOWN) ||
             actions.contains(ACTION_CHANNELDOWN))
    {
        PressButton(BD_VK_DOWN, pts);
    }
    else if (actions.contains(ACTION_LEFT) ||
             actions.contains(ACTION_SEEKRWND))
    {
        PressButton(BD_VK_LEFT, pts);
    }
    else if (actions.contains(ACTION_RIGHT) ||
             actions.contains(ACTION_SEEKFFWD))
    {
        PressButton(BD_VK_RIGHT, pts);
    }
    else if (actions.contains(ACTION_0))
    {
        PressButton(BD_VK_0, pts);
    }
    else if (actions.contains(ACTION_1))
    {
        PressButton(BD_VK_1, pts);
    }
    else if (actions.contains(ACTION_2))
    {
        PressButton(BD_VK_2, pts);
    }
    else if (actions.contains(ACTION_3))
    {
        PressButton(BD_VK_3, pts);
    }
    else if (actions.contains(ACTION_4))
    {
        PressButton(BD_VK_4, pts);
    }
    else if (actions.contains(ACTION_5))
    {
        PressButton(BD_VK_5, pts);
    }
    else if (actions.contains(ACTION_6))
    {
        PressButton(BD_VK_6, pts);
    }
    else if (actions.contains(ACTION_7))
    {
        PressButton(BD_VK_7, pts);
    }
    else if (actions.contains(ACTION_8))
    {
        PressButton(BD_VK_8, pts);
    }
    else if (actions.contains(ACTION_9))
    {
        PressButton(BD_VK_9, pts);
    }
    else if (actions.contains(ACTION_SELECT))
    {
        PressButton(BD_VK_ENTER, pts);
    }
    else
        handled = false;

    return handled;
}
Exemplo n.º 17
0
void CSpiroView::OnPurple() 
{
	PressButton(ID_PURPLE);	
}
Exemplo n.º 18
0
void CSpiroView::OnRed() 
{
	PressButton(ID_RED);	
}
Exemplo n.º 19
0
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;
	}
}