本文整理汇总了C++中WindowApplication::OnMotion方法的典型用法代码示例。如果您正苦于以下问题:C++ WindowApplication::OnMotion方法的具体用法?C++ WindowApplication::OnMotion怎么用?C++ WindowApplication::OnMotion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindowApplication
的用法示例。
在下文中一共展示了WindowApplication::OnMotion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessMouseDragged
//----------------------------------------------------------------------------
static pascal OSStatus ProcessMouseDragged (EventHandlerCallRef, EventRef evt,
void*)
{
Point mouseLoc;
GetEventParameter(evt, kEventParamMouseLocation, typeQDPoint, 0,
sizeof(mouseLoc), 0, &mouseLoc);
EventMouseButton mouseButton;
GetEventParameter(evt, kEventParamMouseButton, typeMouseButton, 0,
sizeof(mouseButton), 0, &mouseButton);
UInt32 modifiers;
GetEventParameter(evt, kEventParamKeyModifiers, typeUInt32, 0,
sizeof(modifiers), 0, &modifiers);
WindowApplication* theApp =
(WindowApplication*)Application::TheApplication;
CGrafPtr currPort;
GetPort(&currPort);
SetPortWindowPort((WindowRef)(theApp->GetWindowID()));
GlobalToLocal(&mouseLoc);
SetPort(currPort);
theApp->OnMotion(mouseButton, mouseLoc.h, mouseLoc.v, modifiers);
// Allow standard handler to run.
return eventNotHandledErr;
}
示例2: MotionCallback
//----------------------------------------------------------------------------
static void MotionCallback (int x, int y)
{
WindowApplication* theApp =
(WindowApplication*)Application::TheApplication;
if (theApp)
{
theApp->OnMotion(gsButton, x, y, gsGLUTModifiers);
}
}
示例3: Main
//.........这里部分代码省略.........
}
if (evt.type == MotionNotify)
{
int button = 0;
index = GLXAPP_BUTTONDOWN + 1;
GetExtraData(index, sizeof(bool), &state);
if (state)
{
button = MOUSE_LEFT_BUTTON;
}
else
{
index = GLXAPP_BUTTONDOWN + 2;
GetExtraData(index, sizeof(bool), &state);
if (state)
{
button = MOUSE_MIDDLE_BUTTON;
}
else
{
index = GLXAPP_BUTTONDOWN + 3;
GetExtraData(index, sizeof(bool), &state);
if (state)
{
button = MOUSE_RIGHT_BUTTON;
}
}
}
if (button > 0)
{
theApp->OnMotion(button, evt.xmotion.x, evt.xmotion.y,
evt.xmotion.state);
}
else
{
theApp->OnPassiveMotion(evt.xmotion.x, evt.xmotion.y);
}
continue;
}
if (evt.type == KeyPress || evt.type == KeyRelease)
{
KeySym keySym = XKeycodeToKeysym(display,
evt.xkey.keycode, 0);
int key = (keySym & 0x00FF);
// Quit application if the KEY_TERMINATE key is pressed.
if (key == theApp->KEY_TERMINATE)
{
XDestroyWindow(display, window);
applicationRunning = false;
continue;
}
// Adjust for special keys that exist on the key pad and on
// the number pad.
if ((keySym & 0xFF00) != 0)
{
if (0x50 <= key && key <= 0x57)
{
// keypad Home, {L,U,R,D}Arrow, Pg{Up,Dn}, End
key += 0x45;
示例4: MsWindowEventHandler
//.........这里部分代码省略.........
theApp->OnMouseClick(WindowApplication::MOUSE_LEFT_BUTTON,
WindowApplication::MOUSE_DOWN, xPos, yPos, PtrToUint(wParam));
return 0;
}
case WM_LBUTTONUP:
{
int xPos = (int)(LOWORD(lParam));
int yPos = (int)(HIWORD(lParam));
theApp->OnMouseClick(WindowApplication::MOUSE_LEFT_BUTTON,
WindowApplication::MOUSE_UP, xPos, yPos, PtrToUint(wParam));
return 0;
}
case WM_MBUTTONDOWN:
{
int xPos = (int)(LOWORD(lParam));
int yPos = (int)(HIWORD(lParam));
theApp->OnMouseClick(WindowApplication::MOUSE_MIDDLE_BUTTON,
WindowApplication::MOUSE_DOWN, xPos, yPos, PtrToUint(wParam));
return 0;
}
case WM_MBUTTONUP:
{
int xPos = (int)(LOWORD(lParam));
int yPos = (int)(HIWORD(lParam));
theApp->OnMouseClick(WindowApplication::MOUSE_MIDDLE_BUTTON,
WindowApplication::MOUSE_UP, xPos, yPos, PtrToUint(wParam));
return 0;
}
case WM_RBUTTONDOWN:
{
int xPos = (int)(LOWORD(lParam));
int yPos = (int)(HIWORD(lParam));
theApp->OnMouseClick(WindowApplication::MOUSE_RIGHT_BUTTON,
WindowApplication::MOUSE_DOWN, xPos, yPos, PtrToUint(wParam));
return 0;
}
case WM_RBUTTONUP:
{
int xPos = (int)(LOWORD(lParam));
int yPos = (int)(HIWORD(lParam));
theApp->OnMouseClick(WindowApplication::MOUSE_RIGHT_BUTTON,
WindowApplication::MOUSE_UP, xPos, yPos, PtrToUint(wParam));
return 0;
}
case WM_MOUSEMOVE:
{
int xPos = (int)(LOWORD(lParam));
int yPos = (int)(HIWORD(lParam));
int button = -1;
if (wParam & MK_LBUTTON)
{
button = WindowApplication::MOUSE_LEFT_BUTTON;
}
else if (wParam & MK_MBUTTON)
{
button = WindowApplication::MOUSE_MIDDLE_BUTTON;
}
else if (wParam & MK_RBUTTON)
{
button = WindowApplication::MOUSE_RIGHT_BUTTON;
}
if (button >= 0)
{
theApp->OnMotion(button, xPos, yPos, PtrToUint(wParam));
}
else
{
theApp->OnPassiveMotion(xPos, yPos);
}
return 0;
}
case WM_MOUSEWHEEL:
{
short sWParam = (short)(HIWORD(wParam));
int delta = ((int)sWParam)/WHEEL_DELTA;
int xPos = (int)(LOWORD(lParam));
int yPos = (int)(HIWORD(lParam));
unsigned int modifiers = (unsigned int)(LOWORD(wParam));
theApp->OnMouseWheel(delta, xPos, yPos, modifiers);
return 0;
}
case WM_DESTROY:
{
// The DestroyWindow call when recreating the window for
// multisampling causes the application to terminate. It is
// not clear why the same problem did not occur in WM4.
if (!gsIgnoreWindowDestroy)
{
PostQuitMessage(0);
}
gsIgnoreWindowDestroy = false;
return 0;
}
}
return DefWindowProc(handle, message, wParam, lParam);
}