先上一个使用例子
#include <BGE/All>
using namespace bge;
Window* createButton(const std::string& name,const String& text)
{
Button* button = new Button(0,text);
button->setName(name);
button->setSize(Vector2f(92,42));
return button;
}
int main(int argc, char* 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 = new Panel(FloatRect(30,30,192,180),0);
GridLayout* layout = new GridLayout();
panel->setLayout(layout);
std::vector<float> widths;
widths.push_back(0.0f);
layout->setColumnWidths(widths);
std::vector<float> heights;
for(int k = 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"按键"),info);
info.columnIndex_ = 1; info.rowIndex_ = 0; layout->addWindow(createButton("button2",L"按键"),info);
info.columnIndex_ = 0; info.rowIndex_ = 1; layout->addWindow(createButton("button3",L"按键"),info);
info.columnIndex_ = 1; info.rowIndex_ = 1; layout->addWindow(createButton("button4",L"按键"),info);
info.columnIndex_ = 0;
info.rowIndex_ = 2;
info.horizontalSpan_ = 2;
Window* edit = new EditField(NULL,L"Edit Text");
edit->setSize(Vector2f(196,36));
layout->addWindow(edit,info);
info.columnIndex_ = 0;
info.rowIndex_ = 3;
info.horizontalSpan_ = 3;
layout->arrangeWithin();
FrameWindow* window = new FrameWindow();
window->enableMovement();
window->setText(L"BGE窗体");
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();
return 0;
}
在开发上参考了Qt等软件,当前支持常见控件 支持控件序列化 整体换肤 控件换肤
上面的代码显示的截图如下:
http://images2015.cnblogs.com/blog/676118/201601/676118-20160120092402484-466039328.png
不过当前还有一点小问题 修改完了再上代码
做这个不为什么 就是几年前一直想做个