#include <BGE/All>
usingnamespaceBge
window* Createbutton (ConstSTD::string& Name,Conststring& text)
{
button* button =NewButton (0, text);
Button->setname (name);
Button->setsize (VECTOR2F ( the, the));
returnbutton
}
intMainintargcChar* argv[])
{
Filesystem::instance (). Initial (argv[0]);
Filesystem::instance (). Setresourcepackage ("Data.zip");
Windowmanager::instance (). Initialize ("Simkai.ttf",false);
device* device = Device::create ();
Device->initial ();
Device->createwindow (640,480, Bge::string ("BGE Window"));
panel* Panel =NewPanel (Floatrect ( -, -,192, the),0);
gridlayout* layout =NewGridLayout ();
Panel->setlayout (layout);
std::vector<float> widths;
Widths.push_back (0.0f);
Layout->setcolumnwidths (widths);
std::vector<float> Heights;
for(intK =0; K <3; ++K)
Heights.push_back (48.0f);
Heights.push_back (0.0f);
Layout->setrowheights (heights);
Gridcellinfo info;
Info.columnindex_ =0; Info.rowindex_ =0; Layout->addwindow (Createbutton ("button1", L"Key"), info);
Info.columnindex_ =1; Info.rowindex_ =0; Layout->addwindow (Createbutton ("Button2", L"Key"), info);
Info.columnindex_ =0; Info.rowindex_ =1; Layout->addwindow (Createbutton ("Button3", L"Key"), info);
Info.columnindex_ =1; Info.rowindex_ =1; Layout->addwindow (Createbutton ("Button4", L"Key"), info);
Info.columnindex_ =0;
Info.rowindex_ =2;
Info.horizontalspan_ =2;
window* edit =NewEditField (null,l"Edit Text");
Edit->setsize (VECTOR2F (196, $));
Layout->addwindow (Edit,info);
Info.columnindex_ =0;
Info.rowindex_ =3;
Info.horizontalspan_ =3;
Layout->arrangewithin ();
framewindow* window =NewFrameWindow ();
Window->enablemovement ();
Window->settext (L"BGE Form");
Window->setclientpanel (panel);
Windowmanager::instance (). AddWindow (window);
while(Device->isrunning ())
{
Device->prerender ();
Windowmanager::instance (). Update ();
Device->swapbuffers ();
Device->pollevents ();
}
Windowmanager::instance (). terminate ();
Device->closewindow ();
Device->terminate ();
Device->deletelater ();
return0;
}
Shown below:
in the development of reference to software such as QT, support common controls, control serialization, the whole skin, control skin Change
The above code to write quite verbose actually can write like this:
intMainintargcChar* argv[])
{
Filesystem::instance (). Initial (argv[0]);
Filesystem::instance (). Setresourcepackage ("Data.zip");
Windowmanager::instance (). Initialize ("Simkai.ttf",false);
device* device = Device::create ();
Device->initial ();
Device->createwindow (640,480, Bge::string ("BGE Window"));
window* window = Windowmanager::instance (). CreateWindow ("Ui.xml");
if(window)
Windowmanager::instance (). AddWindow (window);
while(Device->isrunning ())
{
Device->prerender ();
Windowmanager::instance (). Update ();
Device->swapbuffers ();
Device->pollevents ();
}
Windowmanager::instance (). terminate ();
Device->closewindow ();
Device->terminate ();
Device->deletelater ();
return0;
}
It's not something else to do.
Now a little bit of a problem, modified I will be on the source
A drink of advice ~
A new OpenGL-based GUI library