本文整理汇总了C++中TRawEvent::SetDeviceNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ TRawEvent::SetDeviceNumber方法的具体用法?C++ TRawEvent::SetDeviceNumber怎么用?C++ TRawEvent::SetDeviceNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRawEvent
的用法示例。
在下文中一共展示了TRawEvent::SetDeviceNumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PointerCursorVisibleL
void CTTSprite::PointerCursorVisibleL()
{
if (!TestBase()->ConfigurationSupportsPointerEventTesting())
{
INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
return;
}
// The pointer events need time to have an affect on the wserv
static const TInt eventPropagationDelay = 100 * 1000; // 100 ms
TInt screenNumber = TheClient->iScreen->GetScreenNumber();
if(screenNumber != 0) // pointer events only supported on emulator screen 0
{
LOG_MESSAGE(_L("Pointer Cursor Visible only runs on screen 0"));
return;
}
// set up objects used in test
// 50x50 red rectangle colour 24
CFbsBitmap bitmap;
User::LeaveIfError(bitmap.Load(TEST_BITMAP_NAME, 8));
TSize bmSize = bitmap.SizeInPixels();
TPoint bmSample = TPoint(bmSize.iWidth / 2, bmSize.iHeight / 2);
TRgb bmColour;
bitmap.GetPixel(bmColour, bmSample);
TEST(bmColour == KRgbRed);
// single window, size of screen
RWindow win(TheClient->iWs);
User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),1));
win.Activate();
// setup cursor mode
TheClient->iWs.SetPointerCursorMode(EPointerCursorWindow);
// setup cursor to contain single 50x50 red bitmap
RWsPointerCursor iCursor1 = RWsPointerCursor(TheClient->iWs);
TSpriteMember member;
SetUpMember(member);
member.iBitmap=&bitmap;
User::LeaveIfError(iCursor1.Construct(0));
User::LeaveIfError(iCursor1.AppendMember(member));
User::LeaveIfError(iCursor1.Activate());
win.SetCustomPointerCursor(iCursor1);
iCursor1.UpdateMember(0);
// draw a green rect, size of screen as defined background and wait till it is rendered
win.BeginRedraw();
TheGc->Activate(win);
TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
TheGc->SetBrushColor(KRgbGreen);
TSize wSize = win.Size();
TheGc->DrawRect(TRect(TPoint(0,0), wSize));
TheGc->Deactivate();
win.EndRedraw();
TheClient->iWs.Finish();
// #### do test ####
// define locations of simulated pointer events and sample positions of where we expect to see the cursor
// The cursor will be moved and a check will be made to see if this has actually happened
TPoint pos1(wSize.iWidth / 2, wSize.iHeight / 2); // top left of cursor at centre screen
TPoint sample1(pos1 + bmSample); // centre of sprite at pos1
TPoint pos2 = pos1 - bmSize; // bottom right of cursor at centre screen
TPoint sample2 = pos2 + bmSample; // centre of sprite at pos2
TRgb pixel;
// check initial state of screen at both sample positions
TheClient->iScreen->GetPixel(pixel, sample1);
TEST(pixel == KRgbGreen);
TheClient->iScreen->GetPixel(pixel, sample2);
TEST(pixel == KRgbGreen);
TRawEvent e; // to simulate pointer events
// simulate button 1 down event at pos1
e.Set(TRawEvent::EButton1Down, pos1.iX, pos1.iY);
e.SetDeviceNumber(screenNumber);
UserSvr::AddEvent(e);
User::After(eventPropagationDelay);
// check red cursor visible on top of background
TheClient->iScreen->GetPixel(pixel, sample1);
TEST(pixel == KRgbRed);
// simulate button 1 up event
e.Set(TRawEvent::EButton1Up, pos1.iX, pos1.iY);
UserSvr::AddEvent(e);
User::After(eventPropagationDelay);
// Move cursor away to pos2
e.Set(TRawEvent::EButton1Down, pos2.iX, pos2.iY);
e.SetDeviceNumber(screenNumber);
UserSvr::AddEvent(e);
//.........这里部分代码省略.........