本文整理汇总了C++中TextButton::setCallback方法的典型用法代码示例。如果您正苦于以下问题:C++ TextButton::setCallback方法的具体用法?C++ TextButton::setCallback怎么用?C++ TextButton::setCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextButton
的用法示例。
在下文中一共展示了TextButton::setCallback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Dialog::Dialog(std::shared_ptr<DialogData> p) {
using namespace DialogSettings;
sizePolicy = WidgetSizePolicy::PREFER;
layout._setPos(IntPair{borderSz, borderSz});
layout.setMargins(0, 0, 0, 0);
layout.setWidgetAlignment(WidgetAlignmentHoriz::LEFT, WidgetAlignmentVert::TOP);
layout.setSpacing(widgetSpacing);
// process data
assert(p);
data = p;
assert(!data->title.empty());
assert(!data->message.empty());
assert(!data->buttonText.empty());
TextRenderer* tr = GameData::instance().resources->getDefaultTR();
WidgetText* textTitle = new WidgetText;
textTitle->enableBackground(colTitleBg);
textTitle->setRenderer(tr);
textTitle->setTextColor(colText);
textTitle->setText(data->title);
WidgetText* textMessage = new WidgetText;
textMessage->setRenderer(tr);
textMessage->setTextColor(colText);
textMessage->setText(data->message);
// add buttons
HorizontalLayout* hLayout = new HorizontalLayout;
hLayout->setWidgetAlignment(WidgetAlignmentHoriz::LEFT, WidgetAlignmentVert::TOP);
hLayout->setSpacing(btnSpacing);
std::shared_ptr<TextButton::Style> buttonStyle = std::make_shared<TextButton::Style>();
buttonStyle->tr = tr;
buttonStyle->outlineSz = 0;
buttonStyle->colText = colBtnText;
buttonStyle->colBgOut = colBtnBgOut;
buttonStyle->colBgOver = colBtnBgOver;
buttonStyle->colBgDown = colBtnBgDown;
TextButton* button;
for (std::size_t i = 0; i < data->buttonText.size(); ++i) {
button = new TextButton;
button->setStyle(buttonStyle);
button->setText(data->buttonText[i]);
button->setCallback(std::bind(&self_type::buttonCallback, this, i));
hLayout->add(button);
}
// add to layout
layout.add(textTitle);
layout.add(textMessage);
layout.add(hLayout);
// finalize
layout._setParent(this);
_resize(getPrefSize(), WidgetResizeFlag::SELF);
}