示例#1
0
void SelectionManager::ResetCurrentComponent()
{
	if(m_foundComponent != 0)
	{
		MouseEvent exitEvent(m_foundComponent, MOUSE_EXITED, m_mouseX, m_mouseY, 0);
		m_foundComponent->ProcessMouseEvent(exitEvent);
	}
}
示例#2
0
文件: app.cpp 项目: gitrider/wxsj2
short wxApp::MacHandleAEQuit(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
{
    wxWindow* win = GetTopWindow() ;
    if ( win )
    {
        wxCommandEvent exitEvent(wxEVT_COMMAND_MENU_SELECTED, s_macExitMenuItemId);
        if (!win->ProcessEvent(exitEvent))
            win->Close(TRUE ) ;
    }
    else
    {
        ExitMainLoop() ;
    }
    return noErr ;
}
示例#3
0
void NewtonDemos::KeyDown(const wxKeyEvent &event)
{
	int keyCode = event.GetKeyCode();
	if (keyCode == WXK_ESCAPE)  {
		// send a display refresh event in case the runtime update is stopped bu the user.
		wxMenuEvent exitEvent (wxEVT_COMMAND_MENU_SELECTED, wxID_EXIT);
		GetEventHandler()->ProcessEvent(exitEvent);
	}

	m_shiftKey = event.ShiftDown();
	m_controlKey = event.ControlDown();

//	if (!event.GetModifiers()) {
		int code = keyCode & 0xff; 
		m_key[m_keyMap[code]] = true;
//	}
}
示例#4
0
		/** function to generate the multiplication equations
			@return If the user answered correctly or not.
		*/
bool equations::multiplication(){
	i=rand()%(difficulty*10)+1;
	j=rand()%(difficulty*10)+1;
	string t1,t2;
	char t3[20],t4[20];
	sprintf(t3,"%d",i);
	sprintf(t4,"%d",j);
	wraped->printEquations(t1.assign(t3),t2.assign(t4),mul);
	sscanf(getStr().c_str(),"%d",&k);
	if(i*j==k) 
	{
		correct++;
		wraped->printInfo("Correct!!",1);
		return true;
	}
	else if(k==9999) { state=eXit; exitEvent(this);}
	return false;
}
示例#5
0
int main()
{
	unsigned int N=0;
	correct=0;
	wrong=0;
/*
	cout<<"Enter no of equations you would like to solve ! You can quit in the middle by entering 9999"<<endl;
	cin>>N;
*/
	equations *set;	
	set=new equations("Enter no of equations you would like to solve ! and difficulty by seperating them with a space for example if you want to solve 10 equations of difficulty 1 then please input:2 1<Enter>.\n Also you can quit in the middle of the game by typing 9999 as the answer or press esc and enter to exit right away.");
	string inp=set->getStr();
	unsigned int difficulty;
	
	sscanf(inp.c_str(),"%d %d",&N,&difficulty);
	
#ifdef DEBUG
	printw("Eq:%d Diff:%d",N,difficulty);
	getch();
#endif
	set->difficulty=difficulty;
	// set up the random sead and also the starting time for measuing time taken.
	srand(time(&start));
	// Randomly pick the type of question for the user.
	while(N){
		switch((rand()%4+1)){
			case 1: if(!set->addition())	{set->wraped->printInfo("Wrong!!",2);wrong++;}
					break;
			case 2: if(!set->multiplication())	{set->wraped->printInfo("Wrong!!",2);wrong++;}
					break;
			case 3: if(!set->division())		{set->wraped->printInfo("Wrong!!",2);wrong++;}
					break;
			case 4: if(!set->subtraction())	{set->wraped->printInfo("Wrong!!",2);wrong++;}
					break;
			default: //not possible
				break;
		}
		N--;
	}

	state=eXit;	
	exitEvent(set);
	return 0;
}
示例#6
0
		/** function to generate the addition equations
			@return If the user answered correctly or not.
		*/
bool equations::addition(){
	/*
	cout<<"Eq:"<<(i=rand()%(difficulty*10)+1)<<"+"<<(j=rand()%(difficulty*10)+1)<<endl;
	*/
	i=rand()%(difficulty*10)+1;
	j=rand()%(difficulty*10)+1;
	string t1,t2;
	char t3[20],t4[20];
	sprintf(t3,"%d",i);
	sprintf(t4,"%d",j);
	wraped->printEquations(t1.assign(t3),t2.assign(t4),add);
	sscanf(getStr().c_str(),"%d",&k);
	if(i+j==k) 
	{	
		correct++;
		wraped->printInfo("Correct!!",1);
		return true;
	}
	else if(k==9999) { state=eXit; exitEvent(this);}
	return false;
}
示例#7
0
		/** funciton to generate the division equaitons
			@return If the user answered correctly or not.
		*/
bool equations::division(){
	/** Ensuring division by factors only */
	i=rand()%(difficulty*10)+1;
	j=rand()%(difficulty*10)+1;
	string t1,t2;
	char t3[20],t4[20];
	sprintf(t3,"%d",i*j);
	sprintf(t4,"%d",j);
	wraped->printEquations(t1.assign(t3),t2.assign(t4),div);
	sscanf(getStr().c_str(),"%d",&k);
	//cout<<"Eq:"<<i*j<<"/"<<j<<endl;
	//cin>>k;
	if(k==i) 
	{
		correct++;
		wraped->printInfo("Correct!!",1);
		return true;
	}
	else if(k==9999) { state=eXit; exitEvent(this);}
	return false;
}
示例#8
0
		/** function to generate the subtraction equaitons 
			@return If the user answered correctly or not.
		*/
bool equations::subtraction(){
	/** ensuring subtraction to be of positive result */
	i=rand()%(difficulty*10)+1;
	j=rand()%(difficulty*10)+1;
	unsigned int x,y;
//	cout<<"Eq:"<<(x=  (i>j) ? i:j)<< "-" <<( y=(i>j) ? j:i )<<endl;
	x=(i>j) ? i:j;
	y=(i>j) ? j:i; 
	string t1,t2;
	char t3[20],t4[20];
	sprintf(t3,"%d",x);
	sprintf(t4,"%d",y);
	wraped->printEquations(t1.assign(t3),t2.assign(t4),sub);
	sscanf(getStr().c_str(),"%d",&k);
//	cin>>k;
	if(x-y==k)
	{
		correct++;
		wraped->printInfo("Correct!!",1);
		return true;
	}
	else if(k==9999) { state=eXit; exitEvent(this);}
	return false;
}
示例#9
0
void WengoPhone::exitAfterTimeout() {
    exitEvent(*this);
}
示例#10
0
void SelectionManager::MouseMotion(int x, int y)
{
	// Mouse Dragging
	if( (m_foundComponent != 0) && (m_foundComponent == m_firstClickedComponent) && (m_bPressed) )
	{
		if(m_lastX == 0 && m_lastY == 0)
		{
			m_lastX = x;
			m_lastY = y;
		}

		int draggedX = x - m_lastX;
		int draggedY = y - m_lastY;

		MouseEvent dragEvent(m_foundComponent, MOUSE_DRAGGED, draggedX, draggedY, m_buttonPressed);
		m_foundComponent->ProcessMouseEvent(dragEvent);
	}
	else
	{
		// HACK - For components to work 'outside' of their boundaries
		if(m_firstClickedComponent && m_bPressed)
		{
			MouseEvent dragEvent(m_firstClickedComponent, MOUSE_DRAGGED_OUTSIDE, x, y, m_buttonPressed);
			m_firstClickedComponent->ProcessMouseEvent(dragEvent);
		}
	}


	// Mouse motion
	if(m_foundComponent != 0)
	{
		MouseEvent motionEvent(m_foundComponent, MOUSE_MOTION, x, y, 0);
		m_foundComponent->ProcessMouseEvent(motionEvent);
	}

	// Mouse enter and exit
	if(m_foundComponent != m_hoverOverComponent)
	{
		// Exit the current component that is set as hover
		if(m_hoverOverComponent != 0)
		{
			MouseEvent exitEvent(m_hoverOverComponent, MOUSE_EXITED, m_mouseX, m_mouseY, 0);
			m_hoverOverComponent->ProcessMouseEvent(exitEvent);
		}

		// Enter the new component
		if(m_foundComponent != 0)
		{
			MouseEvent enterEvent(m_foundComponent, MOUSE_ENTERED, m_mouseX, m_mouseY, 0);
			m_foundComponent->ProcessMouseEvent(enterEvent);

			if(m_foundComponent == m_firstClickedComponent && m_bPressed)
			{
				MouseEvent pressedEvent(m_foundComponent, MOUSE_PRESSED, m_mouseX, m_mouseY, 0);
				m_foundComponent->ProcessMouseEvent(pressedEvent);
			}
		}

		m_hoverOverComponent = m_foundComponent;
	}
	else if(m_foundComponent == 0)
	{
		// Exit the current component that is set as hover
		if(m_hoverOverComponent != 0)
		{
			MouseEvent exitEvent(m_hoverOverComponent, MOUSE_EXITED, m_mouseX, m_mouseY, 0);
			m_hoverOverComponent->ProcessMouseEvent(exitEvent);
		}
	}

	m_lastX = x;
	m_lastY = y;
}
示例#11
0
bool Lotus::eventFilter(QObject *obj, QEvent *event)
{
    if(obj == ui->btn_min){                          //最小化、最大化、关闭按钮换图
        if(event->type() == QEvent::Enter){
            ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton-hover.png"));
        }else if(event->type() == QEvent::Leave){
            ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton.png"));
        }else if(event->type() == QEvent::MouseButtonPress){
            ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton-hover.png"));
        }else if(event->type() == QEvent::MouseButtonRelease){
            QMouseEvent *me = (QMouseEvent *)event;
            QLabel *lb = (QLabel *)obj;
            if(me->x() > 0 && me->x() < lb->width() && me->y() > 0 && me->y() < lb->height()){
                //this->showMinimized();
                this->hide();
            }else{
                ui->btn_min->setPixmap(QPixmap(":/pixmap/image/miniButton.png"));
            }
        } else {
            return QObject::eventFilter(obj, event);
        }
        return false;
    }
    if(obj == ui->btn_close){                          //最小化、最大化、关闭按钮换图
        if(event->type() == QEvent::Enter){
            ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton-hover.png"));
        }else if(event->type() == QEvent::Leave){
            ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton.png"));
        }else if(event->type() == QEvent::MouseButtonPress){
            ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton-hover.png"));
        }else if(event->type() == QEvent::MouseButtonRelease){
            QMouseEvent *me = (QMouseEvent *)event;
            QLabel *lb = (QLabel *)obj;
            if(me->x() > 0 && me->x() < lb->width() && me->y() > 0 && me->y() < lb->height()){
                exitEvent();
            }else{
                ui->btn_close->setPixmap(QPixmap(":/pixmap/image/closeButton.png"));
            }
        } else {
            return QObject::eventFilter(obj, event);
        }
        return false;
    }

    if(obj==ui->avatar)
    {
        if(event->type() == QEvent::MouseButtonDblClick)
        {
            //qDebug()<<"click avatar";
            emit clickAvatarLabel();
        }
        return false;
    }
    if(obj==ui->aboutButton)
    {
        if(event->type() == QEvent::MouseButtonRelease)
        {
            //qDebug()<<"click avatar";
            clickAboutButton();
        }
        return false;
    }
    if(obj==systemTrayIcon)
    {
        if(event->type() == QEvent::MouseButtonPress||event->type() == QEvent::MouseButtonRelease)
        {
            qDebug()<<"systemTrayIcon systemTrayIcon";
            this->showNormal();
        }
        return false;
    }
    if(obj==ui->friendLabel||obj==ui->roomLabel||obj==ui->otherLabel)
    {
        if(event->type() == QEvent::MouseButtonRelease)
        {
            setWindowOpacity(1);
        }
        return false;
    }
    if(obj==ui->searchButton)
    {
        if(event->type() == QEvent::MouseButtonPress)
        {
            QMouseEvent *me = (QMouseEvent *)event;
            dragPos = me->globalPos() - frameGeometry().topLeft();
        }else if(event->type() == QEvent::MouseButtonRelease)
        {
            setWindowOpacity(1);
        }
        return false;
    }
    if(event->type() == QEvent::Enter){

         qDebug()<<"eventFilter~~~~Enter";
         if(lotusStatus==-1){
             if(topHide==true){
         topHideAnimation->setStartValue(QSize( lotusWidth,this->size().height()));
         topHideAnimation->setEndValue(QSize( lotusWidth, lotusHeight));
         topHideAnimation->start();
         lotusStatus=1;
             }else if(rightHide==true){
                 rightHideAnimation->setStartValue(QRect(this->x(),this->y(), this->size().width(),lotusHeight));
                 rightHideAnimation->setEndValue(QRect(QApplication::desktop()->width()-lotusWidth,this->y(), lotusWidth, lotusHeight));
                 rightHideAnimation->start();
                 lotusStatus=1;
             }
         }

    }else if(event->type() == QEvent::Leave){
            qDebug()<<"eventFilter~~~~Leave";
            if(lotusStatus==1){
                if(topHide==true){
            topHideAnimation->setStartValue(QSize( lotusWidth, lotusHeight));
            topHideAnimation->setEndValue(QSize( lotusWidth, 5));
            topHideAnimation->start();
            lotusStatus=-1;
                }else if(rightHide==true){
                    rightHideAnimation->setStartValue(QRect(this->x(),this->y(),lotusWidth,lotusHeight));
                    rightHideAnimation->setEndValue(QRect(QApplication::desktop()->width()-5,this->y(),5,lotusHeight));
                    rightHideAnimation->start();
                    lotusStatus=-1;
                }
            }

        }
    //return QObject::eventFilter(obj, event);
    return false;


}