本文整理汇总了C++中util::Reference::addContent方法的典型用法代码示例。如果您正苦于以下问题:C++ Reference::addContent方法的具体用法?C++ Reference::addContent怎么用?C++ Reference::addContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util::Reference
的用法示例。
在下文中一共展示了Reference::addContent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int /*argc*/, char */*argv*/[]) {
Util::init();
Util::UI::Window::Properties properties;
properties.positioned = true;
properties.posX = 100;
properties.posY = 100;
properties.clientAreaWidth = 1024;
properties.clientAreaHeight = 768;
properties.title = "GUI Textfield and Buttons";
properties.compatibilityProfile = true;
auto window = Util::UI::createWindow(properties);
Util::UI::EventContext eventContext;
eventContext.getEventQueue().registerEventGenerator(std::bind(&Util::UI::Window::fetchEvents, window.get()));
GUI::GUI_Manager guiManager(&eventContext);
guiManager.setWindow(window.get());
Util::Reference<GUI::Window> guiWin = guiManager.createWindow(Geometry::Rect_f(10, 10, 200, 200), "Window");
Util::Reference<GUI::Textfield> guiText = guiManager.createTextfield("Text");
guiText->setRect(Geometry::Rect_f(0, 0, 40, 20));
guiWin->addContent(guiText.get());
Util::Reference<GUI::Button> guiButton = guiManager.createButton("Clear");
guiButton->setActionListener( [&guiText](GUI::Component *, const Util::StringIdentifier &) {
guiText->setText("");
return true;
});
guiButton->setRect(Geometry::Rect_f(0, 25, 40, 20));
guiWin->addContent(guiButton.get());
bool done = false;
while(!done) {
eventContext.getEventQueue().process();
while(eventContext.getEventQueue().getNumEventsAvailable() > 0) {
auto event = eventContext.getEventQueue().popEvent();
if(event.type == Util::UI::EVENT_QUIT ||
(event.type == Util::UI::EVENT_KEYBOARD &&
event.keyboard.pressed &&
event.keyboard.key == Util::UI::KEY_ESCAPE)) {
done = true;
} else {
guiManager.handleEvent(event);
}
}
guiManager.display();
window->swapBuffers();
}
return EXIT_SUCCESS;
}