本文整理汇总了C++中Fl_Tree_Item::label方法的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Tree_Item::label方法的具体用法?C++ Fl_Tree_Item::label怎么用?C++ Fl_Tree_Item::label使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fl_Tree_Item
的用法示例。
在下文中一共展示了Fl_Tree_Item::label方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectPawn
void ResourceWindow::selectPawn(const std::string& name)
{
Fl_Tree_Item* tree = getTreeFromName("pawn");
for (int c = 0; c < tree->children(); c++)
{
Fl_Tree_Item* child = tree->child(c);
if (strcmp(child->label(), name.c_str()) == 0)
{
if (child->is_selected())
return;
resourceTree->deselect_all();
child->select();
resourceTree->redraw();
return;
}
}
tree = getTreeFromName("character");
for (int c = 0; c < tree->children(); c++)
{
Fl_Tree_Item* child = tree->child(c);
if (strcmp(child->label(), name.c_str()) == 0)
{
if (child->is_selected())
return;
resourceTree->deselect_all();
child->select();
resourceTree->redraw();
return;
}
}
}
示例2: switch
/// Add a new child to this item with the name 'new_label', with defaults from 'prefs'.
/// An internally managed copy is made of the label string.
/// Adds the item based on the value of prefs.sortorder().
///
Fl_Tree_Item *Fl_Tree_Item::add(const Fl_Tree_Prefs &prefs, const char *new_label) {
Fl_Tree_Item *item = new Fl_Tree_Item(prefs);
item->label(new_label);
item->_parent = this;
switch ( prefs.sortorder() ) {
case FL_TREE_SORT_NONE: {
_children.add(item);
return(item);
}
case FL_TREE_SORT_ASCENDING: {
for ( int t=0; t<_children.total(); t++ ) {
Fl_Tree_Item *c = _children[t];
if ( c->label() && strcmp(c->label(), new_label) > 0 ) {
_children.insert(t, item);
return(item);
}
}
_children.add(item);
return(item);
}
case FL_TREE_SORT_DESCENDING: {
for ( int t=0; t<_children.total(); t++ ) {
Fl_Tree_Item *c = _children[t];
if ( c->label() && strcmp(c->label(), new_label) < 0 ) {
_children.insert(t, item);
return(item);
}
}
_children.add(item);
return(item);
}
}
return(item);
}
示例3: treeCallBack
void ResourceWindow::treeCallBack( Fl_Widget* widget, void* data )
{
//LOG("Tree call back....");
Fl_Tree *tree = (Fl_Tree*)widget;
Fl_Tree_Item *item = (Fl_Tree_Item*)tree->callback_item(); // get selected item
ResourceWindow* window = (ResourceWindow*)data;
if (tree->callback_reason() == FL_TREE_REASON_SELECTED)
{
std::stringstream strstr;
strstr << window->getNameFromItem(item);
long specialNameIndex = (long) item->user_data();
if (specialNameIndex == 0) // assume any item with a special name doesn't need an additional label
strstr << "/" << item->label();
SBSelectionManager::getSelectionManager()->select(strstr.str());
}
if (tree->callback_reason() == FL_TREE_REASON_DESELECTED)
{
std::stringstream strstr;
strstr << window->getNameFromItem(item) << "/" << item->label();
//SBSelectionManager::getSelectionManager()->select("");
}
}
示例4: populateList
void ModelerUserInterface::populateList(GroupProperty* group, Fl_Tree_Item* parent) {
// Create a tree node for this group.
Fl_Tree_Item* item;
if (parent == NULL) {
// HACK: We have to add and remove a fake list item so that the tree
// control will create a root node to put it under.
m_controlsTree->remove(m_controlsTree->add("You shouldn't see this."));
item = m_controlsTree->root();
item->label(group->getName());
} else {
item = m_controlsTree->add(parent, group->getName());
}
item->user_data(group);
// Examine the group's property list for group properties.
PropertyList* controls = group->getProperties();
for (PropertyList::iterator iter = controls->begin();
iter != controls->end();
iter++) {
// See if it's a GroupProperty by attempting to cast it
GroupProperty* childGroup = dynamic_cast<GroupProperty*>(*iter);
// If it is, add it to the list.
if (childGroup) {
ModelerUserInterface::populateList(childGroup, item);
}
}
}
示例5: return
/// Insert a new item into current item's children at a specified position.
Fl_Tree_Item *Fl_Tree_Item::insert(const Fl_Tree_Prefs &prefs, const char *new_label, int pos) {
Fl_Tree_Item *item = new Fl_Tree_Item(prefs);
item->label(new_label);
item->_parent = this;
_children.insert(pos, item);
return(item);
}
示例6: copy_entity_name_cb
static void copy_entity_name_cb(Fl_Widget*, void *s) {
ObjectTree *self = (ObjectTree*)s;
Fl_Tree_Item *titem = self->first_selected_item();
if(!titem) return;
const char *str = titem->label();
if(str) Fl::copy(str, edelib_strnlen(str, 128), 1);
}
示例7: if
void
frmPrjTree::tree_event(Fl_Widget* w, void* v)
{
Fl_Tree *tree = static_cast<Fl_Tree*>(w);
Fl_Tree_Item *item = tree->callback_item(); // the item changed (can be NULL if more than one item was changed!)
switch ( tree->callback_reason() ) { // reason callback was invoked
case FL_TREE_REASON_OPENED:
printf("..item was opened..\n");
break;
case FL_TREE_REASON_CLOSED:
printf("..item was closed..\n");
break;
case FL_TREE_REASON_SELECTED:
frmmain->eventball.lastev=Q_DEL;
frmmain->ehq_scene.top().Handle(&frmmain->eventball);
frmmain->ehq_scene.top().clear();
printf("..item was selected..\n");
if(std::string(item->label()) == "View")
frmviewctrl->select(true);
else if(std::string(item->label()) == "Surface")
frmsurfctrl->select(true);
else if(std::string(item->label()) == "SFS Builder"){
// select ui panel
frmimageplane->select(true);
// add event handler to the scene queue
frmmain->ehq_scene.top().ins_top(&frmmain->dv->imageplane->eh);
frmmain->eventball.lastev=Q_ADD;
frmmain->dv->imageplane->eh.Handle(&frmmain->eventball);
}
else if(std::string(item->label()) == "Matting"){
frmmatting->select(true);
frmmain->ehq_scene.top().ins_top(&frmmain->dv->matting->eh);
frmmain->eventball.lastev=Q_ADD;
frmmain->dv->matting->eh.Handle(&frmmain->eventball);
}
break;
//case FL_TREE_REASON_RESELECTED:
// printf("..item was reselected (double-clicked, etc)..\n");
// break;
case FL_TREE_REASON_DESELECTED:
if(std::string(item->label()) == "View")
frmviewctrl->select(false);
else if(std::string(item->label()) == "Surface")
frmsurfctrl->select(false);
else if(std::string(item->label()) == "SFS Builder")
frmimageplane->select(false);
else if(std::string(item->label()) == "Matting")
frmmatting->select(false);
printf("..item was deselected..\n");
break;
}
}
示例8: populateCurveList
// TODO: populate the curve list once we actually have a list of curves.
void ModelerUserInterface::populateCurveList(Property* prop, Fl_Tree_Item* parent) {
// Create a tree node for this property
Fl_Tree_Item* item;
if (parent == NULL) {
// HACK: We have to add and remove a fake list item so that the tree
// control will create a root node to put it under.
curvesTree->remove(curvesTree->add("You shouldn't see this."));
item = curvesTree->root();
item->label(prop->getName());
} else {
item = curvesTree->add(parent, prop->getName());
}
item->labelfont(FL_HELVETICA_BOLD);
if (GroupProperty* g = dynamic_cast<GroupProperty*>(prop)) {
if (g->getCollapsed()) {
item->close();
}
} else if (dynamic_cast<RGBProperty*>(prop)) {
item->close();
}
// Examine the list of properties.
PropertyList* controls = prop->getProperties();
for (PropertyList::iterator iter = controls->begin();
iter != controls->end();
iter++) {
// For now, only RangeProperty is supported by the Curve interface.
// The RGBProperty is also indirectly supported because it can provide
// RangeProperties when its getProperties() method is called.
// TODO: make this work with more property types (using a new
// plotting widget?)
if (RangeProperty* range = dynamic_cast<RangeProperty*>(*iter)) {
// TODO: connect to Curve object instead of Property object.
Fl_Tree_Item* childNode = curvesTree->add(item, range->getName());
curveProps.push_back(range);
childNode->user_data((void*)(curveProps.size() - 1));
range->setCurveIndex(curveProps.size() - 1);
graph->addCurve(range->getValue(), range->getMin(),
range->getMax());
} else if ((*iter)->getProperties() != NULL) {
// Try to get a list of GroupProperties out of it.
populateCurveList(*iter, item);
}
}
}
示例9: init_appendai_list
void init_appendai_list() {
std::shared_ptr<AppendAIPatch> aip = std::dynamic_pointer_cast<AppendAIPatch>(mods->get("aip"));
Fl_Tree* tree = new Fl_Tree(5, 70+40, 254, 70, "Hybrid Enemies Mod");
if(!aip->valid()) {
tree->deactivate();
return;
}
Fl_Tree_Item* first = tree->first();
first->label("Enemy AI");
AppendAIPatch::entity_storage appended_ais = aip->appended_ai();
int idx = 0;
for(unsigned ai : appended_ais) {
first->add(Fl_Tree_Prefs(), AppendAIPatch::FriendlyName(ai).c_str())->user_data(new int(idx));
idx++;
}
new AddAIButton(150, 145+40, 35, 20, "Add");
new RemoveAIButton(190, 145+40, 70, 20, "Remove");
appended_ai_tree = tree;
}
示例10: TreeCallback
void TreeCallback()
{
Fl_Tree_Item *item = (Fl_Tree_Item*)tree->item_clicked();
cout << "Tree callback. Current selection is: ";
if(item)
{
cout << item->label();
//possibly write code here to populate outer fields?
} else {
cout << "none";
}
cout << endl;
string aStr("unknown");
string aTitle(item->label());
switch(tree->callback_reason())
{
case FL_TREE_REASON_NONE:
{
aStr = "none";
break;
}
case FL_TREE_REASON_OPENED:
{
aStr = "opened";
break;
}
case FL_TREE_REASON_CLOSED:
{
aStr = "closed";
break;
}
case FL_TREE_REASON_SELECTED:
{
aStr = "selected";
cout << "before" << endl;
Json::Value media = msc->getMedia(aTitle); //for SOME reason, this line mucks up
cout << "after" << endl;
/* MediaDescription file(media); */
/* titleInput->value(file.getTitle().c_str()); */
/* authorInput->value(file.getAuthor().c_str()); */
/* albumInput->value(file.getAlbum().c_str()); */
/* genreInput->value(file.getGenre().c_str()); */
/* mediaType->value(file.getMediaType()); */
/* filenameInput->value(file.getFilename().c_str()); */
/* titleInput->value(aTitle.c_str()); */
/* mediaType->value(1); */
break;
}
case FL_TREE_REASON_DESELECTED:
{
aStr = "deselected";
break;
}
dafault:
{
break;
}
}
cout << "Callback reason: " << aStr.c_str() << endl;
}
示例11: handle
int DnDTree::handle(int e)
{
switch(e)
{
case FL_DND_ENTER:
case FL_DND_DRAG:
case FL_DND_RELEASE:
return 1;
break;
case FL_DRAG:
{
Fl_Tree_Item* item = first_selected_item();
if(!item || !strcmp(item->label(), "ROOT"))
return 1;
Fl::copy(item->label(), strlen(item->label()), 0);
Fl::dnd();
return 1;
}
break;
case FL_PASTE:
{
Scene* scene = NeoEngine::getInstance()->getLevel()->getCurrentScene();
Fl_Tree::handle(FL_PUSH);
Fl_Tree_Item* item = first_selected_item();
if(item == NULL)
return 1;
Object3d* newParent = scene->getObjectByName(item->label());
Object3d* object = scene->getObjectByName(Fl::event_text());
if(newParent == NULL && object)
{
object->unLink();
this->do_callback(this, (long) 1);
return 1;
}
if(!object || !newParent)
{
fl_message("Object you tried to drag does not exist! This shouldn't happen!");
return 0;
}
Object3d* parent = object->getParent();
if(object == newParent)
return 1;
if(parent == newParent)
return 1;
if(object == parent)
return 1;
if(object == newParent->getParent())
EditorBackend::getInstance()->unlinkTwoObjects(object, newParent);
if(parent)
EditorBackend::getInstance()->unlinkTwoObjects(parent, object);
EditorBackend::getInstance()->linkTwoObjects(newParent, object);
this->do_callback(this, (long) 1);
return 1;
}
}
return Fl_Tree::handle(e);
}
示例12: file_system_tree_callback
/*
Unit testing only.
*/
void Fineline_File_System_Tree::file_system_tree_callback(Fl_Tree *flt, void *p)
{
Fl_Tree_Item * flti = flt->item_clicked();
cout << "Clicked on: " << flti->label() << endl;
return;
}
开发者ID:sanyaade-g2g-repos,项目名称:fineline-computer-forensics-timeline-tools,代码行数:9,代码来源:Fineline_File_System_Tree.cpp
示例13: OnSelect
void ResourceWindow::OnSelect(const std::string& value)
{
if (value == "")
{
// deselect all
resourceTree->select_only(NULL);
}
SmartBody::SBObject* object = SmartBody::SBScene::getScene()->getObjectFromString(value);
if (!object)
return;
Fl_Tree_Item* item = NULL;
SmartBody::SBCharacter* character = dynamic_cast<SmartBody::SBCharacter*>(object);
if (character)
{
// select a character
for (std::map<Fl_Tree_Item*, std::string>::iterator iter = _treeMap.begin();
iter != _treeMap.end();
iter++)
{
if ((*iter).second == "character")
{
item = (*iter).first;
// make sure that the parent is open so that the selection can be seen
resourceTree->open(item);
}
}
if (!item)
return;
}
else
{
SmartBody::SBPawn* pawn = dynamic_cast<SmartBody::SBPawn*>(object);
if (pawn)
{
// select a pawn
for (std::map<Fl_Tree_Item*, std::string>::iterator iter = _treeMap.begin();
iter != _treeMap.end();
iter++)
{
if ((*iter).second == "pawn")
{
item = (*iter).first;
// make sure that the parent is open so that the selection can be seen
resourceTree->open(item);
}
}
if (!item)
return;
}
}
if (!item)
return;
int numChildren = item->children();
for (int c = 0; c < numChildren; c++)
{
Fl_Tree_Item* child = item->child(c);
if (object->getName() == child->label())
{
resourceTree->select_only(child);
}
}
}
示例14: handle
int ResourceWindow::handle( int event )
{
int ret = Fl_Group::handle(event);
std::string dndText;
switch ( event ) {
case FL_DND_RELEASE:
//LOG("DND Release");
ret = 1;
break;
case FL_DND_ENTER: // return(1) for these events to 'accept' dnd
//LOG("DND Enter");
//Fl::belowmouse(this); // send the leave events first
//Fl::focus(this);
//handle(FL_FOCUS);
ret = 1;
break;
case FL_DND_DRAG:
ret = 1;
break;
case FL_DND_LEAVE:
//LOG("DND Leave");
ret = 1;
break;
case FL_PASTE: // handle actual drop (paste) operation
{
//label(Fl::event_text());
//fprintf(stderr, "PASTE: %s\n", Fl::event_text());
//LOG("PASTE: %s\n", Fl::event_text());
dndText = Fl::event_text();
bool hasAsset = processedDragAndDrop(dndText);
ret = 1;
}
break;
case FL_PUSH:
{// do 'copy/dnd' when someone clicks on box
if (Fl::event_button() == 2)
{
LOG("press middle button");
LOG("lastClickedItemPath = %s",lastClickedItemPath.c_str());
Fl_Tree_Item* lastItem = resourceTree->find_item(lastClickedItemPath.c_str());
if (lastItem)
{
const char* itemType = (const char*)lastItem->user_data();
bool sendDND = false;
std::string dndMsg = "";
if (strcmp(itemType, "skeleton") == 0)
{
std::string skName = lastItem->label();
dndMsg = "SKELETON:";
dndMsg += skName;
sendDND = true;
}
else if (strcmp(itemType, "pawn") == 0)
{
dndMsg = "PAWN:dummy";
sendDND = true;
}
//Fl::copy("message",7,0);
if (sendDND)
{
Fl::copy(dndMsg.c_str(),dndMsg.length(),0);
Fl::dnd();
}
ret = 1;
}
}
break;
}
case FL_KEYDOWN:
{
switch (Fl::event_key())
{
case FL_Delete:
{
// check pawns and characters for selection
Fl_Tree_Item* tree = getTreeFromName("pawn");
int numChildren = tree->children();
for (int c = 0; c < numChildren; c++)
{
Fl_Tree_Item* child = tree->child(c);
if (child->is_selected())
{
const char* name = child->label();
int confirm = fl_choice(vhcl::Format("Are you sure you want to delete '%s'?",name).c_str(), "No", "Yes", NULL);
if (confirm == 0)
return 0;
SmartBody::SBScene::getScene()->removePawn(name);
updateGUI();
return 1;
}
}
tree = getTreeFromName("character");
numChildren = tree->children();
for (int c = 0; c < numChildren; c++)
{
Fl_Tree_Item* child = tree->child(c);
if (child->is_selected())
{
//.........这里部分代码省略.........