⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glutevent.cpp

📁 mesa-6.5-minigui源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  ulong aChar = s[0];  BGLView::KeyDown(s,slen);    BPoint p;		switch (aChar) {		case B_FUNCTION_KEY:		switch(Window()->CurrentMessage()->FindInt32("key")) {			case B_F1_KEY:				aChar = GLUT_KEY_F1;				goto specialLabel;			case B_F2_KEY:				aChar = GLUT_KEY_F2;				goto specialLabel;			case B_F3_KEY:				aChar = GLUT_KEY_F3;				goto specialLabel;			case B_F4_KEY:				aChar = GLUT_KEY_F4;				goto specialLabel;			case B_F5_KEY:				aChar = GLUT_KEY_F5;				goto specialLabel;			case B_F6_KEY:				aChar = GLUT_KEY_F6;				goto specialLabel;			case B_F7_KEY:				aChar = GLUT_KEY_F7;				goto specialLabel;			case B_F8_KEY:				aChar = GLUT_KEY_F8;				goto specialLabel;			case B_F9_KEY:				aChar = GLUT_KEY_F9;				goto specialLabel;			case B_F10_KEY:				aChar = GLUT_KEY_F10;				goto specialLabel;			case B_F11_KEY:				aChar = GLUT_KEY_F11;				goto specialLabel;			case B_F12_KEY:				aChar = GLUT_KEY_F12;				goto specialLabel;			default:				return;		}		case B_LEFT_ARROW:			aChar = GLUT_KEY_LEFT;			goto specialLabel;		case B_UP_ARROW:			aChar = GLUT_KEY_UP;			goto specialLabel;		case B_RIGHT_ARROW:			aChar = GLUT_KEY_RIGHT;			goto specialLabel;		case B_DOWN_ARROW:			aChar = GLUT_KEY_DOWN;			goto specialLabel;		case B_PAGE_UP:			aChar = GLUT_KEY_PAGE_UP;			goto specialLabel;		case B_PAGE_DOWN:			aChar = GLUT_KEY_PAGE_DOWN;			goto specialLabel;		case B_HOME:			aChar = GLUT_KEY_HOME;			goto specialLabel;		case B_END:			aChar = GLUT_KEY_END;			goto specialLabel;		case B_INSERT:            aChar = GLUT_KEY_INSERT;specialLabel:				if (special) {				anyevents = specialEvent = true;				GetMouse(&p,&m_buttons);				specialKey = aChar;				specialX = (int)p.x;				specialY = (int)p.y;				goto setModifiers;	// set the modifier variable			}			return;		default:			break;	}			if (keyboard) {		anyevents = keybEvent = true;		GetMouse(&p,&m_buttons);		key = aChar;		keyX = (int)p.x;		keyY = (int)p.y;setModifiers:		modifierKeys = 0;		uint32 beMod = Window()->CurrentMessage()->FindInt32("modifiers");		if(beMod & B_SHIFT_KEY)			modifierKeys |= GLUT_ACTIVE_SHIFT;		if(beMod & B_CONTROL_KEY)			modifierKeys |= GLUT_ACTIVE_CTRL;		if(beMod & B_OPTION_KEY) {			// since the window traps B_COMMAND_KEY, we'll have to settle			// for the option key.. but we need to get the raw character,			// not the Unicode-enhanced version			key = Window()->CurrentMessage()->FindInt32("raw_char");			modifierKeys |= GLUT_ACTIVE_ALT;		}		gBlock.NewEvent();	}}/*********************************************************** *	CLASS:		GlutWindow * *	FUNCTION:	MouseDown * *	DESCRIPTION:  handles mouse and menustatus events ***********************************************************/void GlutWindow::MouseDown(BPoint point){	BGLView::MouseDown(point);	MouseCheck();}/*********************************************************** *	CLASS:		GlutWindow * *	FUNCTION:	MouseCheck * *	DESCRIPTION:  checks for button state changes ***********************************************************/void GlutWindow::MouseCheck(){	if (mouseEvent)		return;		// we already have an outstanding mouse event	BPoint point;	uint32 newButtons;	GetMouse(&point, &newButtons);	if (m_buttons != newButtons) {		if (newButtons&B_PRIMARY_MOUSE_BUTTON && !(m_buttons&B_PRIMARY_MOUSE_BUTTON)) {			button = GLUT_LEFT_BUTTON;			mouseState = GLUT_DOWN;		} else if (m_buttons&B_PRIMARY_MOUSE_BUTTON && !(newButtons&B_PRIMARY_MOUSE_BUTTON)) {			button = GLUT_LEFT_BUTTON;			mouseState = GLUT_UP;		} else if (newButtons&B_SECONDARY_MOUSE_BUTTON && !(m_buttons&B_SECONDARY_MOUSE_BUTTON)) {			button = GLUT_RIGHT_BUTTON;			mouseState = GLUT_DOWN;		} else if (m_buttons&B_SECONDARY_MOUSE_BUTTON && !(newButtons&B_SECONDARY_MOUSE_BUTTON)) {			button = GLUT_RIGHT_BUTTON;			mouseState = GLUT_UP;		} else if (newButtons&B_TERTIARY_MOUSE_BUTTON && !(m_buttons&B_TERTIARY_MOUSE_BUTTON)) {			button = GLUT_MIDDLE_BUTTON;			mouseState = GLUT_DOWN;		} else if (m_buttons&B_TERTIARY_MOUSE_BUTTON && !(newButtons&B_TERTIARY_MOUSE_BUTTON)) {			button = GLUT_MIDDLE_BUTTON;			mouseState = GLUT_UP;		}	} else {		return;		// no change, return	}	m_buttons = newButtons;	if (mouseState == GLUT_DOWN) {		BWindow *w = Window();		GlutMenu *m = __glutGetMenuByNum(menu[button]);		if (m) {			if (gState.menuStatus) {				anyevents = statusEvent = true;				menuNumber = menu[button];				menuStatus = GLUT_MENU_IN_USE;				statusX = (int)point.x;				statusY = (int)point.y;				gBlock.NewEvent();			}					BRect bounds = w->Frame();			point.x += bounds.left;			point.y += bounds.top;			GlutPopUp *bmenu = static_cast<GlutPopUp*>(m->CreateBMenu());	// start menu			bmenu->point = point;			bmenu->win = this;			thread_id menu_thread = spawn_thread(MenuThread, "menu thread", B_NORMAL_PRIORITY, bmenu);			resume_thread(menu_thread);			return;		}	}	if (mouse) {		anyevents = mouseEvent = true;		mouseX = (int)point.x;		mouseY = (int)point.y;		modifierKeys = 0;		uint32 beMod = modifiers();		if(beMod & B_SHIFT_KEY)			modifierKeys |= GLUT_ACTIVE_SHIFT;		if(beMod & B_CONTROL_KEY)			modifierKeys |= GLUT_ACTIVE_CTRL;		if(beMod & B_OPTION_KEY) {			modifierKeys |= GLUT_ACTIVE_ALT;		}		gBlock.NewEvent();	}}/*********************************************************** *	CLASS:		GlutWindow * *	FUNCTION:	MouseMoved * *	DESCRIPTION:  handles entry, motion, and passive events ***********************************************************/void GlutWindow::MouseMoved(BPoint point,						ulong transit, const BMessage *msg){	BGLView::MouseMoved(point,transit,msg);		if(transit != B_INSIDE_VIEW) {		if (entry) {			anyevents = entryEvent = true;			gBlock.NewEvent();		}		if (transit == B_ENTERED_VIEW) {			entryState = GLUT_ENTERED;			MakeFocus();	// make me the current focus			__glutSetCursor(cursor);		} else			entryState = GLUT_LEFT;	}		MouseCheck();	if(m_buttons) {		if(motion) {			anyevents = motionEvent = true;			motionX = (int)point.x;			motionY = (int)point.y;			gBlock.NewEvent();		}	} else {		if(passive) {			anyevents = passiveEvent = true;			passiveX = (int)point.x;			passiveY = (int)point.y;			gBlock.NewEvent();		}	}}/*********************************************************** *	CLASS:		GlutWindow * *	FUNCTION:	FrameResized * *	DESCRIPTION:  handles reshape event ***********************************************************/void GlutWindow::FrameResized(float width, float height){	BGLView::FrameResized(width, height);	if (visible) {		anyevents = reshapeEvent = true;		m_width = (int)(width)+1;		m_height = (int)(height)+1;		gBlock.NewEvent();	}}/*********************************************************** *	CLASS:		GlutWindow * *	FUNCTION:	Draw * *	DESCRIPTION:  handles reshape and display events ***********************************************************/void GlutWindow::Draw(BRect updateRect){	BGLView::Draw(updateRect);	BRect frame = Frame();	if (m_width != (frame.Width()+1) || m_height != (frame.Height()+1)) {		FrameResized(frame.Width(), frame.Height());	}	Window()->Lock();	if (visible) {		anyevents = displayEvent = true;		gBlock.NewEvent();	}	Window()->Unlock();}/*********************************************************** *	CLASS:		GlutWindow * *	FUNCTION:	Pulse * *	DESCRIPTION:  handles mouse up event (MouseUp is broken) ***********************************************************/void GlutWindow::Pulse(){	BGLView::Pulse();	if (m_buttons) {	// if there are buttons pressed		MouseCheck();	}}/*********************************************************** *	CLASS:		GlutWindow * *	FUNCTION:	ErrorCallback * *	DESCRIPTION:  handles GL error messages ***********************************************************/void GlutWindow::ErrorCallback(GLenum errorCode) {	__glutWarning("GL error: %s", gluErrorString(errorCode));}/*********************************************************** *	CLASS:		GlutWindow * *	FUNCTION:	MenuThread * *	DESCRIPTION:  a new thread to launch popup menu, wait *			wait for response, then clean up afterwards and *			send appropriate messages ***********************************************************/long GlutWindow::MenuThread(void *m) {	GlutPopUp *bmenu = static_cast<GlutPopUp*>(m);	GlutWindow *win = bmenu->win;	// my window	GlutBMenuItem *result = (GlutBMenuItem*)bmenu->Go(bmenu->point);	win->Window()->Lock();	win->anyevents = win->statusEvent = true;	win->menuStatus = GLUT_MENU_NOT_IN_USE;	win->menuNumber = bmenu->menu;	BPoint cursor;	uint32 buttons;	win->GetMouse(&cursor, &buttons);	win->statusX = (int)cursor.x;	win->statusY = (int)cursor.y;	if(result && result->menu) {		win->menuEvent = true;		win->menuNumber = result->menu;  // in case it was a submenu		win->menuValue = result->value;	}	win->Window()->Unlock();	gBlock.NewEvent();	delete bmenu;	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -