当前位置: 首页>>代码示例>>C++>>正文


C++ TRawEvent::SetDeviceNumber方法代码示例

本文整理汇总了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);
//.........这里部分代码省略.........
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:101,代码来源:TSPRITE.CPP


注:本文中的TRawEvent::SetDeviceNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。