Example #1
0
int main()
{
	int res;
	MOUSEMSG m;

	initgraph(DRAWINGAREAWIDTH, DRAWINGAREAHEIGHT);  

	init();

	Speed = 100;

    while(1)	
	{
		if(MouseHit())
		{
			/* 检查鼠标信息 */
			m = GetMouseMsg();
			/* 根据信息进行操作 */
			GetMessage(m);
		}
	}
	
	closegraph(); 

	return 0;
}
Example #2
0
//主页菜单
int MainMenu(){
	int i = 1, y1 = 250;

	cleardevice();
	IMAGE img;

	loadimage(&img, "1.jpg", 1000, 600, true);
	putimage(0, 0, &img);

	//设置主菜单文字
	setlocale(LC_ALL, "chs");//解决中文乱码,在头文件locale.h中
	settextstyle(80, 0, "华文彩云",0,0,10000,0,0,0);
	settextcolor(MAGENTA);
	setbkmode(TRANSPARENT);/*处理文字后面的黑色,使文字后的背景为图片*/
	outtextxy(400, 150, "菜单");
	
	settextcolor(DARKGRAY);
	settextstyle(40, 0, "幼圆",0,0,1000,0,1,0);	
	int WIDTH = textwidth(_T("1 画图"));
	outtextxy(WDIS, 250, _T("1 画图"));
	outtextxy(WDIS, 300, _T("2 分形"));
	outtextxy(WDIS, 350, _T("3 配置"));
	outtextxy(WDIS, 400, _T("4 退出"));
	
	//获取鼠标信息
	FlushMouseMsgBuffer();
	while (true){
		if (MouseHit()){   //检测
			m = GetMouseMsg();//获取鼠标状态
			if (m.uMsg == WM_LBUTTONDOWN){
				while (m.x >= WDIS&&m.x <=  WIDTH+WDIS&&m.y >= 250 && m.y <= 425){
					if (m.y >= y1&&m.y <= 25 + y1)
						return i;
					else if (y1 >= 400)
						break;
					else
						y1 += 50, i++;
				}
			}		

		}
		//通过按键也可以实现主菜单跳转
		if (_kbhit()){
			char c = _getch();
			if (c >= '1'&&c <= '4')
				return (c - '0');
		}
	}
	_getch();
	closegraph();

}
Example #3
0
bool Checkbox::handleEvent( const WM_Base &wm )
{
    switch(MouseHit(this, wm)) {
    case WH_HitMouseLeftDown:
        m_pressing = true;
        return true;
    case WH_HitMouseLeftUp:
        if(m_pressing) {
            toggle();
            m_pressing = false;
        }
        return true;
    }
    return super::handleEvent(wm);
}
Example #4
0
bool Button::handleEvent( const WM_Base &wm )
{
    switch(MouseHit(this, wm)) {
    case WH_HitMouseLeftDown:
        setFocus(true);
        m_pressing = true;
        return true;
    case WH_HitMouseLeftUp:
        push();
        m_pressing = false;
        return true;
    case WH_MissMouseLeftUp:
        m_pressing = false;
        break;
    }
    return super::handleEvent(wm);
}
Example #5
0
iuiAPI WidgetHit MouseHit(Widget *w, const WM_Base &wm)
{
    return MouseHit(Rect(w->getPositionAbs(), w->getSize()), wm);
}