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


C++ PlatformWindow::AddSubWidget方法代码示例

本文整理汇总了C++中PlatformWindow::AddSubWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ PlatformWindow::AddSubWidget方法的具体用法?C++ PlatformWindow::AddSubWidget怎么用?C++ PlatformWindow::AddSubWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlatformWindow的用法示例。


在下文中一共展示了PlatformWindow::AddSubWidget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

//The following is the entry point for the command-line version
int main(int argc, char **argv)
{

    //This sets the video driver
    setenv("SDL_VIDEODRIVER", "dga",1);
    setenv("SDL_VIDEODRIVER", "x11",1);



    //Make a few new colors.
    cout << "Creating new colors\n";
    PColor  red =  PColor("red");
    PColor  grey = PColor("grey");
    grey.SetAlpha(150);
 
    PlatformEnvironment * myEnv = new PlatformEnvironment();
    myEnv->Initialize();
 
    PlatformWindow * myWindow = new PlatformWindow();
    myWindow->Initialize();
    myWindow->SetBackgroundColor(grey);
    
    PKeyboard * myKeyboard = new PlatformKeyboard();


    //Add window to environment.
    myEnv->AddWindow(myWindow);

    
    //Now make an Image Widget.
    PlatformImageBox * myImage1 = new PlatformImageBox;
    if(!myImage1->LoadImage("media/images/pebl.bmp"))
        cout << "Loading image1 failed\n" ;
    

    //Make another image, just for kicks.
    PlatformImageBox * myImage2 = new PlatformImageBox;
    if(!myImage2->LoadImage("media/images/pebl.png"))
        cout << "Loading image2 failed\n" ;

   //Make a font.
    cout << "Creating a font\n";
    PlatformFont * myFont1 = new PlatformFont("media/fonts/VeraSe.ttf", PFS_Normal, 22, red, grey, true );
    PlatformFont * myFont2 = new PlatformFont("media/fonts/VeraSe.ttf", PFS_Normal, 22, red, grey, false );


    cout << "Creating PlatformWord object\n";
    //Now, make a 'word object.
    PlatformWord * myWord1 = new PlatformWord("Hello World: anti-aliased", myFont1);
    myWord1->SetPosition(30,30);

    PlatformWord * myWord2 = new PlatformWord("Hello World:aliased", myFont2);
    myWord2->SetPosition(30,50);




    myWindow->AddSubWidget(myImage1);
    myWindow->AddSubWidget(myImage2);
    myWindow->AddSubWidget(myWord1);
    myWindow->AddSubWidget(myWord2);

  
    myEnv->Draw();
    myKeyboard->WaitForAnyKeyDown();
    myKeyboard->WaitForAllKeysUp();


    myImage1->SetPosition(10,10);
    myImage2->SetPosition(10,200);
    myEnv->Draw();
    myKeyboard->WaitForAnyKeyDown();
    myKeyboard->WaitForAllKeysUp();

    

    myImage1->SetPosition(100,20);
    myImage2->SetPosition(100,300);
    myEnv->Draw();
    myKeyboard->WaitForAllKeysUp();
    myKeyboard->WaitForAnyKeyDown();



    myImage1->SetPosition(200,200);
    myImage2->SetPosition(200,400);
    myEnv->Draw();
    myKeyboard->WaitForAllKeysUp();

    myKeyboard->WaitForAnyKeyDown();


    for(int i= 0; i<500;i+=10){      
        myImage1->SetPosition(i,400);
        myEnv->Draw();
    }


    myKeyboard->WaitForAllKeysUp();        
//.........这里部分代码省略.........
开发者ID:cryptoatropine,项目名称:pebl-language,代码行数:101,代码来源:WindowTest.cpp


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