本文整理汇总了C++中Fl_Tree_Item::clear_children方法的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Tree_Item::clear_children方法的具体用法?C++ Fl_Tree_Item::clear_children怎么用?C++ Fl_Tree_Item::clear_children使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fl_Tree_Item
的用法示例。
在下文中一共展示了Fl_Tree_Item::clear_children方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle
int RemoveAIButton::handle(int evt) {
if(evt == 2) {
if(appended_ai_tree)
{
std::shared_ptr<AppendAIPatch> aip = std::dynamic_pointer_cast<AppendAIPatch>(mods->get("aip"));
Fl_Tree_Item* first = appended_ai_tree->first();
if(first->is_selected()) {
for(int child = 0; child < first->children(); child++) {
delete (int*)(first->child(child)->user_data());
}
first->clear_children();
aip->undo();
aip->set_appended_ai(AppendAIPatch::entity_storage());
mods_window->redraw();
return Fl_Button::handle(evt);
}
for(int pos = 0; pos < first->children(); pos++)
{
if(!first->child(pos)->is_selected()) {
continue;
}
Fl_Tree_Item* selected = first->child(pos);
int appended_idx = *(int*)selected->user_data();
//correct indices after removal
for(int child = 0; child < first->children(); child++) {
int* idx = (int*)(first->child(child)->user_data());
if(*idx > appended_idx) {
(*idx)--;
}
}
AppendAIPatch::entity_storage appended = aip->appended_ai();
appended.erase(appended.begin()+appended_idx);
aip->set_appended_ai(appended);
delete (int*)(selected->user_data());
appended_ai_tree->remove(selected);
}
mods_window->redraw();
if(aip->appended_ai().empty()) {
aip->undo();
}
}
}
return Fl_Button::handle(evt);
}