#include #include #include ////////////////////// // test-simple.cxx ////////////////////// // // Fl_Tree -- This file is part of the Fl_Tree widget for FLTK // Copyright (C) 2009 by Greg Ercolano. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // void TreeCallback(Fl_Widget *w, void *data) { Fl_Tree *tree = (Fl_Tree*)w; fprintf(stderr, "TreeCallback: data=%d, ", (int)data); // Find item that was clicked Fl_Tree_Item *item = (Fl_Tree_Item*)tree->item_clicked(); if ( item ) { fprintf(stderr, "item='%s'\n", item->label()); // print item's label tree->deselect_all(); // deselect all items tree->select(item); // select this one // tree->redraw(); } else { fprintf(stderr, "(NO ITEM?)\n"); } } int main(int argc, const char *argv[]) { Fl_Double_Window win(250, 400, "Simple Tree"); // Create tree, add items Fl_Tree tree(10, 10, win.w()-20, win.h()-20); tree.add("Flintstones/Fred"); tree.add("Flintstones/Wilma"); tree.add("Flintstones/Pebbles"); tree.add("Simpsons/Homer"); tree.add("Simpsons/Marge"); tree.add("Simpsons/Bart"); tree.add("Simpsons/Lisa"); tree.close("/Simpsons"); tree.callback(TreeCallback, (void*)1234); win.end(); win.resizable(win); win.show(); return(Fl::run()); }