Пример #1
0
void ProgressData::setItemChanged(int itemID)
{
	if (itemChanged.size()> (unsigned int) itemID) itemChanged.at(itemID)=0;
	resetIdleTime(itemID);
	lastChangedItem=itemID;
	callEvent();
}
Пример #2
0
void ProgressData::increaseItemProgress(int itemID)
{
	if (itemProgress.size()>(unsigned int) itemID)
	{
		itemProgress.at(itemID) = itemProgress.at(itemID) + 1;
		callEvent();
	}
	else mError("Item ID is out of range");
}
Пример #3
0
void form::mouseLeave(SDL_Event *e){
	if(hovered){
		hovered = false;
		callEvent(e,event_leave);
	}
	if(hoveredControl>=0){
		children[hoveredControl]->mouseLeave(e);
	}
	hoveredControl = -2;
}
bool cPythonScript::callEventHandler( const QString& name, PyObject* args, bool ignoreErrors )
{
    PyObject* result = callEvent( name, args, ignoreErrors );
    bool handled = false;

    if ( result )
    {
        handled = PyObject_IsTrue( result ) == 0 ? false : true;
        Py_DECREF( result );
    }

    return handled;
}
Пример #5
0
//override the render.
void form::render(SDL_Surface *s){
	SDL_Surface *ts = SDL_CreateRGBSurface(SDL_SWSURFACE,width,height, 32,255<<16,255<<8,255,0);

	SDL_Event e;
	e.type = event_render;
	e.user.data1 = ts;
		
	SDL_Rect dRect = {left,top,width,height};
	SDL_BlitSurface(s,&dRect,ts,NULL);

	if(handler[event_render]!=NULL)callEvent(&e,event_render);
	else draw(ts);

	for(int i = 0; i < children.size(); i++){
		children[i]->render(ts);
	}

	SDL_BlitSurface(ts,NULL,s,&dRect);
	SDL_FreeSurface(ts);
}
Пример #6
0
void form::handleMouseMove(SDL_Event &e){
		if(within(left,top,width,height,e.motion.x,e.motion.y)){
			this->mouseEnter(&e);
		}else{
			this->mouseLeave(&e);
			//return;
		}
		if(_DEGUGG) cout<<name<<"\t"<<"Before: "<<e.motion.x<<","<<e.motion.y<<" After: ";
		//MOTION. trickkky.--------------------------------------------
		int state = SDL_GetMouseState(NULL,NULL);
		//this part handles the case of pointers dragging into the window. In which, ignore.
		if((state&SDL_BUTTON_LMASK)&&leftBindedControl==-2) return;
		if((state&SDL_BUTTON_MMASK)&&middleBindedControl==-2) return;
		if((state&SDL_BUTTON_RMASK)&&rightBindedControl==-2) return;

		//this part handles the case of pointers leaving, releasing and then entering.
		SDL_Event sim;
		sim.type = SDL_MOUSEBUTTONUP;
		sim.button.state = SDL_RELEASED;
		sim.button.type = SDL_MOUSEBUTTONUP;
		sim.button.x = e.motion.x;
		sim.button.y = e.motion.y;
		sim.button.which = 1;

		if(!(state&SDL_BUTTON_LMASK)&&leftBindedControl!=-2){
			sim.button.button = SDL_BUTTON_LEFT;
			SDL_PushEvent(&sim); SDL_PushEvent(&e);
			return;
		}
		if(!(state&SDL_BUTTON_MMASK)&&middleBindedControl!=-2){
			sim.button.button = SDL_BUTTON_MIDDLE;
			SDL_PushEvent(&sim); SDL_PushEvent(&e);
			return;
		}
		if(!(state&SDL_BUTTON_RMASK)&&rightBindedControl!=-2){
			sim.button.button = SDL_BUTTON_RIGHT;
			SDL_PushEvent(&sim); SDL_PushEvent(&e);
			return;
		}
		//by this point, if there is a button down, there is one corresponding binded control. If there is a button down, send to the corresponding control only
		e.motion.x -= left;
		e.motion.y -= top;
		if(_DEGUGG) cout<<e.motion.x<<","<<e.motion.y<<"\n";
		if(state){
			int control = max(leftBindedControl,max(rightBindedControl,middleBindedControl));
			if(control==-1){
				this->callEvent(&e,e.type);
			}else{
				if(within(children[control]->left,children[control]->top,
					children[control]->width,children[control]->height,
					e.motion.x,e.motion.y)){
						children[control]->mouseEnter(&e);
						children[control]->handleEvent(e);
						hoveredControl = control;
				}else{
					children[control]->mouseLeave(&e);
					children[control]->handleEvent(e);
					hoveredControl = -2;
				}
			}
				
		}else{
			//find which control this belongs to.
			int control = -2;
			if(within(left,top,width,height,e.motion.x,e.motion.y)) control = -1;
			for(int i = 0; i < children.size(); i++){
				if(within(children[i]->left,children[i]->top,children[i]->width,
					children[i]->height,e.motion.x,e.motion.y)){
					control = i;
				}
			}
			if(control!=hoveredControl){
				if(hoveredControl==-1) mouseLeave(&e);
				if(hoveredControl>=0) children[hoveredControl] -> mouseLeave(&e);	
			}
			if(control==-1){
				mouseEnter(&e);
				callEvent(&e,e.type);
			}
			if(control>=0){
				children[control]->mouseEnter(&e);
				children[control]->handleEvent(e);
			}
			hoveredControl = control;
		}

}
Пример #7
0
void scrollButton::mouseLeave(SDL_Event* e){
	if(hovered&&!leftDown){
		hovered = false;
		callEvent(e,event_leave);
	}
}