本文整理汇总了C++中wt::WContainerWidget::widget方法的典型用法代码示例。如果您正苦于以下问题:C++ WContainerWidget::widget方法的具体用法?C++ WContainerWidget::widget怎么用?C++ WContainerWidget::widget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wt::WContainerWidget
的用法示例。
在下文中一共展示了WContainerWidget::widget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MyTreeTableNode
MyTreeTableNode *MyTreeTableNode::addNode(MyTreeTableNode *parent, Wt::WString name, const long start, const long stop, bool mini ) {
MyTreeTableNode *node = new MyTreeTableNode(name, 0, parent);
Wt::WContainerWidget *labelArea = node->labelArea();
Wt::WWidget *labelWidget = labelArea->widget(0); //See source of WTreeNode.
labelArea->removeWidget(labelWidget);
node->startWidget = new TimeWidget(); //We make these, even if we're doing the mini-tree. We use these widgets to store the actual data, so that if we need the start or stop time, we can get them out of the widget and get the right numbers, even if we haven't saved the fragment set yet.
node->startWidget->setTime(start);
node->stopWidget = new TimeWidget();
node->stopWidget->setTime(stop);
if (mini)
{
node->startButton = new Wt::WPushButton(name);
}
else
{
node->editWidget = new Wt::WInPlaceEdit();
std::string str = name.toUTF8();
str.erase(std::remove(str.begin(), str.end(), ' '), str.end()); //This removes whitespace
if(str.length()<1)
{
node->editWidget->setText(Wt::WString::Empty);
node->editWidget->setPlaceholderText("New Node");
}
else
{
node->editWidget->setText(name);
}
node->editWidget->valueChanged().connect(std::bind([=]() {
std::string str = node->editWidget->text().toUTF8();
str.erase(std::remove(str.begin(), str.end(), ' '), str.end()); //This removes whitespace
if(str.length()<1)
{
node->editWidget->setText(Wt::WString::Empty);
}
node->text = node->editWidget->text();
}));
node->text = node->editWidget->text();
node->startButton = new Wt::WPushButton("|>");
}
//todo: add doubleclick trick to allow modal edit
node->startButton->clicked().connect(std::bind([=]() {
if(start == -1)
{ //We've clicked the startbutton on a group, so we need to find the first non-group widget.
if (node->childNodes().size() > 0)
{
//So, there are children.. In this case take the first child and pretend we've clicked that startButton. It'll be recursive.
MyTreeTableNode *firstChild = dynamic_cast<MyTreeTableNode*> (*(node->childNodes()).begin());
return firstChild->startButton->clicked().emit(Wt::WMouseEvent());
}
else
{ //Where in a childless group, so we cannot play anything!
return;
}
}
Wt::Json::Object jStartBefore = zmq_conn::interact("inputs?");
Wt::Json::Array aStartBefore = jStartBefore.get("before");
signed long long startBefore = aStartBefore[2];
zmq_conn::interact(Wt::WString("event:stop")); //Probably needed to help stop the track from stopping the middle of a play
Wt::WString command="play:"+std::to_string(start - startBefore * 1000);
zmq_conn::interact(command);
}));
labelArea->addWidget(node->startButton);
if(mini)
{
}
else
{ //0 is startbutton now
//node->setColumnWidget(1, node->startButton);
node->setColumnWidget(1,node->editWidget );
node->setColumnWidget(2, node->startWidget);
node->setColumnWidget(3, node->stopWidget);
}
return node;
}