Example #1
0
	//
	// 函数:bool onMessage(UINT message, WPARAM wParam, LPARAM lParam)
	//
	// 目的:窗口消息处理函数
	//
	// 返回值:已处理,返回true,否则返回false
	//
	bool onMessage(UINT message, WPARAM wParam, LPARAM lParam)
	{
		// 如果是键盘消息,获取键盘状态
		if (message == WM_KEYDOWN || message == WM_KEYUP)
		{
			if (!getKeyboardState())
			{
				return false;
			}
		}
		
		// 获取鼠标状态
		getMouseState(message);

		bool handled = false;

		MSG_LISTENER_MAP::iterator at = myListenerMap.find(message);
		if (at != myListenerMap.end())
		{
			LISTENER_LIST& listeners = at->second;
			for (LISTENER_LIST::iterator it = listeners.begin(); 
				 it != listeners.end() && !handled; ++it)
			{
				YCIInputListener* listener = *it;
				if (listener->onMessage(message, wParam, lParam))
				{
					handled = true;
				}
			}
		}
		return handled;
	}
Example #2
0
bool Asnap::mouse(int x, int y, int state, int event)
{
	switch(event)
	{
		case mouseLDOWN:
		control->select();
		case mouseNORMAL:
		case mouseLUP:
		cursor(cursorHANDSEL);
		focus(this);
		{
			if(getKeyboardState()&keyboardLALT)
			{
				if(defpos!=-1)
					set(defpos);
				else
					set(0);
				father->notify(this, nyCHANGE);
				return true;
			}
		}
		switch(event)
		{
			case mouseLDOWN:
			mouseCapture(true);
			return true;
			
			case mouseLUP:
			{
				int	xx=(x-X)/28;
				int	yy=(y-Y)/18;
				if((xx>=0)&&(xx<4)&&(yy>=0)&&(yy<4))
				{
					set(yy*4+xx);
					father->notify(this, nyCHANGE);
					repaint();
				}
				mouseCapture(false);
				return TRUE;
			}
			break;
		}
		break;
	}
	return FALSE;
}
Example #3
0
EDLL bool Apaddle::mouse(int x, int y, int state, int event)
{
	switch(event)
	{
		case mouseLDOWN:
		control->select();
		case mouseNORMAL:
		case mouseLUP:
		cursor(cursorHANDSEL);
		focus(this);
		{
			if(getKeyboardState()&keyboardLALT)
			{
				if((defxx!=-1)&&(defyy!=-1))
					set(defxx, defyy);
				else if(defyy!=-1)
					set(0.f, defyy);
				else if(defxx!=-1)
					set(defxx, 0.f);
				else
					set(0.f, 0.f);
				father->notify(this, nyCHANGE);
				return true;
			}
		}
		switch(event)
		{
			case mouseLDOWN:
			mouseCapture(true);
			test=TRUE;
			x0=x;
			y0=y;
			xx0=xx;
			yy0=yy;
			break;
		}
		if(test&&(state&mouseL))
		{
			switch(mode)
			{
				case paddleX:
				{
					float	dy=0.05f*alib.mouseSensibility*(float)(y-y0);
					xx=mini(maxi(-dy+xx0+alib.mouseSensibility*(float)(x-x0), 0.f), 1.f);
					control->set(Acontrol::CONTROLER_01, xx);
					{
						char	str[256];
						sprintf(str, "%s [%1.2f]", tooltips?tooltips:"", xx);
						notify(this, nyTOOLTIPS, (dword)str);
					}
				}
				break;

				case paddleY:
				{
					int	dxi=x-x0;
					int	dyi=y-y0;
					if(abs(dxi)>=abs(dyi))
						dyi=0;
					else
						dxi=0;
					float	dx=0.05f*alib.mouseSensibility*(float)(dxi);
					float	dy=alib.mouseSensibility*(float)(dyi);
					yy=mini(maxi(yy-dy+dx, 0.f), 1.f);
					control->set(Acontrol::CONTROLER_01, yy);
					{
						char	str[256];
						sprintf(str, "%s [%1.2f]", tooltips?tooltips:"", yy);
						notify(this, nyTOOLTIPS, (dword)str);
					}
					x0=x;
					y0=y;
				}
				break;

				case paddleXY:
				xx=mini(maxi(xx0+alib.mouseSensibility*(float)(x-x0), 0.f), 1.f);
				yy=mini(maxi(yy0-alib.mouseSensibility*(float)(y-y0), 0.f), 1.f);
				control->set(Acontrol::CONTROLER_01, xx);
				control->set(Acontrol::CONTROLER_02, yy);
				{
					char	str[256];
					sprintf(str, "%s [%1.2f,%f1.2]", tooltips?tooltips:"", xx, yy);
					notify(this, nyTOOLTIPS, (dword)str);
				}
				break;
			}
			repaint();
			father->notify(this, nyCHANGE);
		}
		switch(event)
		{
			case mouseLUP:
			mouseCapture(FALSE);
			test=FALSE;
			break;
		}
		return TRUE;
	}
	return FALSE;
}