1 # data file for the Fltk User Interface Designer (fluid)
5 decl {\#include <stdio.h>} {public global
8 decl {\#include <FL/Fl.H>} {public global
11 decl {\#include <FL/Fl_Pixmap.H>} {public global
14 decl {\#include <FL/Fl_Group.H>} {public global
17 decl {\#include <FL/Fl_Tree.H>} {public global
20 decl {\#include <FL/fl_ask.H>} {public global
23 decl {\#include <FL/fl_message.H>} {public global
26 decl {\#include <FL/Fl_File_Chooser.H>} {public global
29 decl {\#include <FL/Fl_Preferences.H>} {public global
32 decl {\#include <FL/Fl_Color_Chooser.H>} {public global
35 decl {int G_cb_counter = 0;} {
36 comment {// Global callback event counter} private local
39 Function {reason_as_name(Fl_Tree_Reason reason)} {
40 comment {Return an Fl_Tree_Reason as a text string name} return_type {const char*}
42 code {switch ( reason ) {
43 case FL_TREE_REASON_NONE: return("none");
44 case FL_TREE_REASON_SELECTED: return("selected");
45 case FL_TREE_REASON_DESELECTED: return("deselected");
46 case FL_TREE_REASON_OPENED: return("opened");
47 case FL_TREE_REASON_CLOSED: return("closed");
48 default: return("???");
52 Function {Button_CB(Fl_Widget*w, void*data)} {return_type void
54 code {fprintf(stderr, "'%s' button pushed\\n", w->label());} {}
57 Function {AssignUserIcons()} {
58 comment {Assign user icons to the items} open
60 code {static const char *L_folder_xpm[] = {
76 static Fl_Pixmap L_folderpixmap(L_folder_xpm);
78 static const char *L_document_xpm[] = {
94 static Fl_Pixmap L_documentpixmap(L_document_xpm);
96 // Assign user icons to tree items
97 for ( Fl_Tree_Item *item = tree->first(); item; item=item->next())
98 if ( usericon_radio->value() )
99 // Assign custom icons
100 item->usericon(item->has_children() ? &L_folderpixmap : &L_documentpixmap);
102 // Don't assign custom icons
108 Function {RebuildTree()} {
109 comment {Rebuild the 'example tree' from scratch} open
111 code {// REBUILD THE TREE TO MAKE CURRENT "DEFAULT" PREFS TAKE EFFECT
117 tree->add("Bbb/child-01");
118 tree->add("Bbb/child-01/111");
119 tree->add("Bbb/child-01/222");
120 tree->add("Bbb/child-01/333");
121 tree->add("Bbb/child-02");
122 tree->add("Bbb/child-03");
123 tree->add("Bbb/child-04");
126 static Fl_Button *but = 0;
127 // Assign an FLTK widget to one of the items
129 if ( ( i = tree->find_item("Bbb/child-03") ) != NULL ) {
130 if ( !but ) { // only do this once at program startup
132 but = new Fl_Button(1,1,140,1,"ccc button"); // we control w() only
134 but->callback(Button_CB);
141 // Assign an FLTK group to one of the items with widgets
143 if ( ( i = tree->find_item("Bbb/child-04") ) != NULL ) {
144 static Fl_Group *grp = 0;
145 if ( !grp ) { // only do this once at program startup
147 grp = new Fl_Group(100,100,140,18); // build group.. tree handles position
148 grp->color(FL_WHITE);
150 Fl_Button *abut = new Fl_Button(grp->x()+0 ,grp->y()+2,65,15,"D1");
152 abut->callback(Button_CB);
153 Fl_Button *bbut = new Fl_Button(grp->x()+75,grp->y()+2,65,15,"D2");
155 bbut->callback(Button_CB);
164 // Add an 'Ascending' node, and create it sorted
165 tree->sortorder(FL_TREE_SORT_NONE);
166 tree->add("Ascending")->close();
167 tree->sortorder(FL_TREE_SORT_ASCENDING);
168 tree->add("Ascending/Zzz");
169 tree->add("Ascending/Xxx");
170 tree->add("Ascending/Aaa");
171 tree->add("Ascending/Bbb");
172 tree->add("Ascending/Yyy");
173 tree->add("Ascending/Ccc");
175 // Add a 'Descending' node, and create it sorted
176 tree->sortorder(FL_TREE_SORT_NONE);
177 tree->add("Descending")->close();
178 tree->sortorder(FL_TREE_SORT_DESCENDING);
179 tree->add("Descending/Zzz");
180 tree->add("Descending/Xxx");
181 tree->add("Descending/Aaa");
182 tree->add("Descending/Bbb");
183 tree->add("Descending/Yyy");
184 tree->add("Descending/Ccc");
186 // Add 500 items in numerical order
187 tree->sortorder(FL_TREE_SORT_NONE);
188 for ( int t=0; t<500; t++ ) {
190 sprintf(s, "500 Items/item %04d", t);
193 tree->close("500 Items"); // close the 500 items by default
197 tree->redraw();} {selected
201 Function {EditColor(Fl_Color val)} {
202 comment {Prompt the user to change the specified color} return_type Fl_Color
205 // Get the current color
206 Fl::get_color(val,r,g,b);
208 // Bring up a color chooser to edit it
209 fl_color_chooser("Choose Color",r,g,b);
211 // Return the new color the user picked
212 return(fl_rgb_color(r,g,b));} {}
219 xywh {800 102 1015 445} type Double visible
224 callback {G_cb_counter++; // Increment callback counter whenever tree callback is invoked
226 Fl_Tree_Item *item = tree->callback_item();
228 fprintf(stderr, "TREE CALLBACK: label='%s' userdata=%ld reason=%s\\n",
230 (long)(fl_intptr_t)tree->user_data(),
231 reason_as_name(tree->callback_reason()));
233 fprintf(stderr, "TREE CALLBACK: reason=%s item=(no item -- probably multiple items were changed at once)\\n",
234 reason_as_name(tree->callback_reason()));
236 tooltip {Test tree} xywh {15 22 280 411} box DOWN_BOX color 55 selection_color 15
241 code0 {o->resizable(0);}
245 tooltip {These controls only affect the selected items. If no items are selected, all existing items in tree are modified.} xywh {311 23 335 263} box GTK_DOWN_BOX color 47 labelsize 12 align 1
247 Fl_Value_Slider margintop_slider {
250 callback {int val = (int)margintop_slider->value();
251 tree->margintop(val);
253 tooltip {Changes the top margin for the tree widget} xywh {486 31 140 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
254 code0 {o->value(tree->margintop());}
255 code1 {o->range(0.0, 100.0);}
256 code2 {o->step(1.0);}
257 code3 {o->color(46); o->selection_color(FL_RED);}
259 Fl_Value_Slider marginleft_slider {
262 callback {int val = (int)marginleft_slider->value();
263 tree->marginleft(val);
265 tooltip {Changes the left margin for the tree widget} xywh {486 51 140 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
266 code0 {o->value(tree->marginleft());}
267 code1 {o->range(0.0, 100.0);}
268 code2 {o->step(1.0);}
269 code3 {o->color(46); o->selection_color(FL_RED);}
271 Fl_Value_Slider openchild_marginbottom_slider {
272 label {openchild_marginbottom()}
274 callback {int val = (int)openchild_marginbottom_slider->value();
275 tree->openchild_marginbottom(val);
277 tooltip {Changes the vertical space below an open child tree} xywh {486 71 140 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
278 code0 {o->value(tree->openchild_marginbottom());}
279 code1 {o->range(0.0, 100.0);}
280 code2 {o->step(1.0);}
281 code3 {o->color(46); o->selection_color(FL_RED);}
283 Fl_Choice collapseicons_chooser {
284 label {Collapse icons}
285 callback {static const char *L_open_xpm[] = {
291 "\#\#\#\#\#\#\#\#\#\#\#",
301 "\#\#\#\#\#\#\#\#\#\#\#"
319 static Fl_Pixmap L_openpixmap(L_open_xpm);
321 static const char *L_close_xpm[] = {
327 "\#\#\#\#\#\#\#\#\#\#\#",
337 "\#\#\#\#\#\#\#\#\#\#\#"
355 static Fl_Pixmap L_closepixmap(L_close_xpm);
357 switch ( collapseicons_chooser->value() ) {
359 tree->showcollapse(1);
364 tree->showcollapse(1);
365 tree->openicon(&L_openpixmap);
366 tree->closeicon(&L_closepixmap);
369 tree->showcollapse(0);
372 tooltip {Tests Fl_Tree::openicon() and Fl_Tree::closeicon()} xywh {486 96 140 21} down_box BORDER_BOX labelsize 12 textsize 11
376 xywh {10 10 36 21} labelsize 12
380 xywh {20 20 36 21} labelsize 12
384 xywh {30 30 36 21} labelsize 12
387 Fl_Choice connectorstyle_chooser {
389 callback {// CHANGE COLLAPSESTYLE
390 switch ( connectorstyle_chooser->value() ) {
391 case 0: tree->connectorstyle(FL_TREE_CONNECTOR_NONE); break;
392 case 1: tree->connectorstyle(FL_TREE_CONNECTOR_DOTTED); break;
393 case 2: tree->connectorstyle(FL_TREE_CONNECTOR_SOLID); break;
395 tooltip {Tests connectorstyle() bit flags} xywh {486 120 140 21} down_box BORDER_BOX labelsize 12 textsize 11
396 code0 {switch (tree->connectorstyle()) { case FL_TREE_CONNECTOR_NONE: connectorstyle_chooser->value(0); break; case FL_TREE_CONNECTOR_DOTTED: connectorstyle_chooser->value(1); break; case FL_TREE_CONNECTOR_SOLID: connectorstyle_chooser->value(2); break; }}
400 xywh {40 40 36 21} labelsize 12
404 xywh {20 20 36 21} labelsize 12
408 xywh {30 30 36 21} labelsize 12
411 Fl_Choice selectmode_chooser {
412 label {Selection Mode}
413 callback {// Set selection mode
414 switch ( selectmode_chooser->value() ) {
415 case 0: tree->selectmode(FL_TREE_SELECT_NONE); break; // None
416 case 1: tree->selectmode(FL_TREE_SELECT_SINGLE); break; // Single
417 case 2: tree->selectmode(FL_TREE_SELECT_MULTI); break; // Multi
418 default: tree->selectmode(FL_TREE_SELECT_SINGLE); break; // Single
420 tooltip {Sets how Fl_Tree handles mouse selection of tree items} xywh {486 144 140 21} down_box BORDER_BOX labelsize 12 textsize 11
421 code0 {selectmode_chooser->value(1);}
422 code1 {cb_selectmode_chooser(selectmode_chooser, (void*)0);}
426 xywh {40 40 36 21} labelsize 12
430 xywh {50 50 36 21} labelsize 12
434 xywh {60 60 36 21} labelsize 12
437 Fl_Choice whenmode_chooser {
439 callback {// Set when mode
440 switch ( whenmode_chooser->value() ) {
441 case 0: tree->when(FL_WHEN_RELEASE); break;
442 case 1: tree->when(FL_WHEN_CHANGED); break;
443 case 2: tree->when(FL_WHEN_NEVER); break;
444 default: tree->when(FL_WHEN_RELEASE); break;
446 tooltip {Sets when() the tree's callback is invoked} xywh {486 168 140 21} down_box BORDER_BOX labelsize 12 textsize 11
447 code0 {whenmode_chooser->value(1);}
448 code1 {cb_whenmode_chooser(whenmode_chooser, (void*)0);}
452 xywh {50 50 36 21} labelsize 12
456 xywh {60 60 36 21} labelsize 12
460 xywh {70 70 36 21} labelsize 12
463 Fl_Check_Button usericon_radio {
464 label {Enable user icons?}
466 callback {AssignUserIcons();}
467 tooltip {Tests Fl_Tree_Item::usericon()} xywh {486 194 20 16} down_box DOWN_BOX labelsize 12 align 7
468 code0 {usericon_radio->value(1);}
470 Fl_Check_Button showroot_radio {
473 callback {int onoff = showroot_radio->value();
474 tree->showroot(onoff);}
475 tooltip {Tests tree->showroot();} xywh {486 211 20 16} down_box DOWN_BOX labelsize 12 align 7
476 code0 {int onoff = tree->showroot(); showroot_radio->value(onoff);}
478 Fl_Check_Button visiblefocus_checkbox {
479 label {Visible focus?}
481 callback {int onoff = visiblefocus_checkbox->value();
482 tree->visible_focus(onoff);}
483 tooltip {Toggles the tree's visible_focus() box} xywh {486 228 20 16} down_box DOWN_BOX labelsize 12 align 7
484 code0 {int onoff = tree->visible_focus(); visiblefocus_checkbox->value(onoff);}
486 Fl_Button selection_color_button {
487 label {Selection Color}
488 callback {Fl_Color val = EditColor(tree->selection_color()); // Get color of first item in tree
489 selection_color_button->color(val); // update modified color to button
490 tree->selection_color(val);
492 tooltip {Changes the tree widget's selection color. Tests Fl_Tree::selection_color()} xywh {486 251 16 16} box DOWN_BOX labelsize 12 align 7
493 code0 {o->color(tree->selection_color());}
496 label {Test Operations}
497 tooltip {These controls only affect the defaults for new items that are created. These test the Fl_Tree_Prefs methods.} xywh {311 312 335 120} box GTK_DOWN_BOX color 47 labelsize 12 align 1
499 Fl_Box showitem_box {
502 xywh {331 335 70 82} box GTK_DOWN_BOX labelsize 11 align 1
506 callback {Fl_Tree_Item *item = tree->next_selected_item();
507 tree->show_item(item);}
508 tooltip {Tests show_item() with no position specified.
509 Makes the selected item visible IF it is off-screen.
510 No change made if it is not off-screen.} xywh {346 344 40 17} labelsize 11
514 callback {Fl_Tree_Item *item = tree->next_selected_item();
515 tree->show_item_top(item);}
516 tooltip {Test show_item_top().
517 Scrolls selected item to the top of the display
518 (only works if scrollbar showing)
522 3) Hit Top/Mid/Bot} xywh {346 361 40 16} labelsize 11
526 callback {Fl_Tree_Item *item = tree->next_selected_item();
527 tree->show_item_middle(item);}
528 tooltip {Tests show_item_middle().
529 Scrolls the selected item to the middle of the display
532 2) select 'item 0010'
533 3) Hit Top/Mid/Bot} xywh {346 377 40 16} labelsize 11
537 callback {Fl_Tree_Item *item = tree->next_selected_item();
538 tree->show_item_bottom(item);}
539 tooltip {Tests show_item_bottom().
540 Scrolls the selected item to the bottom of the display
543 2) select 'item 0010'
544 3) Hit Top/Mid/Bot} xywh {346 393 40 16} labelsize 11
546 Fl_Button loaddb_button {
547 label {Load Database...}
548 callback {const char *filename = fl_file_chooser("Select a Preferences style Database", "Preferences(*.prefs)", 0L);
551 Fl_Preferences prefs(filename, 0L, 0L);
555 tooltip {Load the contents of an Fl_Preferences database into the tree view} xywh {431 338 95 16} labelsize 9
557 Fl_Button insertabove_button {
559 callback {Fl_Tree_Item *item=tree->first();
561 if ( item->is_selected() ) {
562 tree->insert_above(item, "AaaAaa");
563 tree->insert_above(item, "BbbBbb");
564 tree->insert_above(item, "CccCcc");
570 tooltip {Inserts three items above the selected items} xywh {431 358 95 16} labelsize 9
572 Fl_Button rebuildtree_button {
574 callback {RebuildTree();}
575 tooltip {Rebuilds the tree with defaults} xywh {431 378 95 16} labelsize 9
577 Fl_Button showpathname_button {
578 label {Show Pathname}
579 callback {Fl_Tree_Item *item = tree->first_selected_item();
580 if ( !item ) { fl_message("No item was selected"); return; }
583 switch ( tree->item_pathname(pathname, sizeof(pathname), item) ) {
584 case 0: fl_message("Pathname for '%s' is: \\"%s\\"", (item->label() ? item->label() : "???"), pathname); break;
585 case -1: fl_message("item_pathname() returned -1 (NOT FOUND)"); break;
586 case -2: fl_message("item_pathname() returned -2 (STRING TOO LONG)"); break;
588 tooltip {Show the pathname for the selected item. Tests the Fl_Tree::item_pathname() method.} xywh {431 398 95 16} labelsize 9
590 Fl_Button clearall_button {
592 callback {tree->clear();
594 tooltip {Clears all items
595 Tests Fl_Tree::clear()} xywh {531 338 95 16} labelsize 9
597 Fl_Button testcallbackflag_button {
598 label {Test Callback Flag}
599 callback {Fl_Tree_Item *root = tree->root();
600 fprintf(stderr, "--- Checking docallback off\\n");
605 // open/close: Make sure these methods don't trigger cb
606 G_cb_counter = 0; tree->close(root, 0); if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n close(item) triggered cb!");
607 G_cb_counter = 0; tree->open(root, 0); if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n open(item) triggered cb!");
608 G_cb_counter = 0; tree->open_toggle(root, 0); if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n open_toggle(item) triggered cb!");
609 G_cb_counter = 0; tree->open("ROOT", 0); if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n open(path) triggered cb!");
610 G_cb_counter = 0; tree->close("ROOT", 0); if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n close(path) triggered cb!");
611 tree->open(root,0); // leave root open
613 // select/deselect: Make sure these methods don't trigger cb
614 G_cb_counter = 0; tree->select(root, 0); if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n select(item) triggered cb!");
615 G_cb_counter = 0; tree->deselect(root, 0); if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n deselect(item) triggered cb!");
616 G_cb_counter = 0; tree->select_toggle(root, 0); if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n select_toggle(item) triggered cb!");
617 G_cb_counter = 0; tree->deselect("ROOT", 0); if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n deselect(path) triggered cb!");
618 G_cb_counter = 0; tree->select("ROOT", 0); if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n select(path) triggered cb!");
619 tree->deselect("ROOT"); // leave deselected
623 // open/close: Make sure these methods don't trigger cb
624 G_cb_counter = 0; tree->close(root, 1); if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n close(item) cb wasn't triggered!");
625 G_cb_counter = 0; tree->open(root, 1); if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n open(item) cb wasn't triggered!");
626 G_cb_counter = 0; tree->open_toggle(root, 1); if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n open_toggle(item) cb wasn't triggered!");
627 G_cb_counter = 0; tree->open(root, 1); if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n open(item)[2] cb wasn't triggered!");
628 G_cb_counter = 0; tree->close(root, 1); if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n close(item)[2] cb wasn't triggered!");
629 G_cb_counter = 0; tree->open("ROOT", 1); if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n open(path) cb wasn't triggered!");
630 G_cb_counter = 0; tree->close("ROOT", 1); if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n close(path) cb wasn't triggered!");
631 tree->open(root,0); // leave root open
633 // select/deselect: Make sure these methods don't trigger cb
634 G_cb_counter = 0; tree->select(root, 1); if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n select(item) cb wasn't triggered!");
635 G_cb_counter = 0; tree->deselect(root, 1); if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n deselect(item) cb wasn't triggered!");
636 G_cb_counter = 0; tree->select_toggle(root, 1); if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n select_toggle(item) cb wasn't triggered!");
637 G_cb_counter = 0; tree->deselect("ROOT", 1); if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n deselect(path) cb wasn't triggered!");
638 G_cb_counter = 0; tree->select("ROOT", 1); if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n select(path) cb wasn't triggered!");
639 tree->deselect("ROOT"); // leave deselected
641 //// "default" TEST (should be same as 'on'
643 // open/close: Make sure these methods don't trigger cb
644 G_cb_counter = 0; tree->close(root); if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST: close(item) cb wasn't triggered!");
645 G_cb_counter = 0; tree->open(root); if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST: open(item) cb wasn't triggered!");
646 G_cb_counter = 0; tree->open_toggle(root); if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST: open_toggle(item) cb wasn't triggered!");
647 G_cb_counter = 0; tree->open("ROOT"); if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST: open(path) cb wasn't triggered!");
648 G_cb_counter = 0; tree->close("ROOT"); if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST: close(path) cb wasn't triggered!");
649 tree->open(root,0); // leave root open
651 // select/deselect: Make sure these methods don't trigger cb
652 G_cb_counter = 0; tree->select(root); if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST\\n select(item) cb wasn't triggered!");
653 G_cb_counter = 0; tree->deselect(root); if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST\\n deselect(item) cb wasn't triggered!");
654 G_cb_counter = 0; tree->select_toggle(root); if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST\\n select_toggle(item) cb wasn't triggered!");
655 G_cb_counter = 0; tree->deselect("ROOT"); if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST\\n deselect(path) cb wasn't triggered!");
656 G_cb_counter = 0; tree->select("ROOT"); if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST\\n select(path) cb wasn't triggered!");
657 tree->deselect("ROOT"); // leave deselected
659 fl_alert("TEST COMPLETED\\n If you didn't see any error dialogs, test PASSED.");}
660 tooltip {Test the 'docallback' argument can disable callbacks.} xywh {531 358 95 16} labelsize 9
663 label {Selected Items}
664 tooltip {These controls only affect the selected items. If no items are selected, all existing items in tree are modified.} xywh {661 23 335 263} box GTK_DOWN_BOX color 47 labelsize 12 align 1
666 Fl_Choice all_font_choice {
668 callback {// Find first item in tree
669 Fl_Tree_Item *item = tree->first();
672 // Get first item's font.
673 Fl_Font val = (Fl_Font)all_font_choice->value(); // Get font value
677 for ( item=tree->first(); item; item = tree->next(item) ) {
678 if ( item->is_selected() ) {
679 item->labelfont(val);
684 // No items selected? Do all..
686 for ( item=tree->first(); item; item = tree->next(item) ) {
687 item->labelfont(val);
692 tooltip {Changes the font for the selected items's labels. If none selected, all are changed. Tests Fl_Tree_Item::labelfont();} xywh {828 31 140 21} down_box BORDER_BOX labelsize 12 textsize 11
693 code0 {o->value((int)tree->item_labelfont()); // get tree's current font, assign to chooser}
697 xywh {30 30 36 21} labelsize 12
700 label {Helvetica Bold}
701 xywh {40 40 36 21} labelsize 12
704 label {Helvetica Italic}
705 xywh {55 55 36 21} labelsize 12
708 label {Helvetica Bold Italic}
709 xywh {60 60 36 21} labelsize 12
713 xywh {70 70 36 21} labelsize 12
717 xywh {80 80 36 21} labelsize 12
720 label {Courier Italic}
721 xywh {65 65 36 21} labelsize 12
724 label {Courier Bold Italic}
725 xywh {70 70 36 21} labelsize 12
729 xywh {80 80 36 21} labelsize 12
733 xywh {90 90 36 21} labelsize 12
737 xywh {75 75 36 21} labelsize 12
740 label {Times Bold Italic}
741 xywh {80 80 36 21} labelsize 12
745 xywh {90 90 36 21} labelsize 12
749 xywh {100 100 36 21} labelsize 12
753 xywh {85 85 36 21} labelsize 12
756 label {Zapf Dingbats}
757 xywh {90 90 36 21} labelsize 12
760 Fl_Value_Slider labelsize_slider {
763 callback {int size = (int)labelsize_slider->value();
768 for ( item=tree->first(); item; item = tree->next(item) ) {
769 if ( item->is_selected() ) {
770 item->labelsize(size);
775 // NO ITEMS SELECTED? DO ALL
777 for ( item=tree->first(); item; item = tree->next(item) ) {
778 item->labelsize(size);
783 tooltip {Changes the font size of the selected items's labels. If none selected, all are changed. Tests Fl_Tree_Item::labelsize();} xywh {828 55 140 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
784 code0 {o->value(tree->item_labelsize());}
785 code1 {o->range(5.0, 200.0);}
786 code2 {o->step(1.0);}
787 code3 {o->color(46); o->selection_color(FL_RED);}
789 Fl_Button all_labelfgcolor_button {
790 label {Label FG Color}
791 callback {// Find first item in tree
792 Fl_Tree_Item *item = tree->first();
795 // Get first item's color
796 Fl_Color val = EditColor(item->labelfgcolor()); // Get color of first item in tree
797 all_labelfgcolor_button->color(val); // update modified color to button
801 for ( item=tree->first(); item; item = tree->next(item) ) {
802 if ( item->is_selected() ) {
803 item->labelfgcolor(val);
808 // No items selected? Do all..
810 for ( item=tree->first(); item; item = tree->next(item) ) {
811 item->labelfgcolor(val);
816 tooltip {Changes the label fg color for the selected items. If none selected, all are changed. Tests Fl_Tree_Item::labelfgcolor();} xywh {828 81 16 16} box DOWN_BOX labelsize 12 align 7
817 code0 {o->color(tree->item_labelfgcolor());}
819 Fl_Button all_labelbgcolor_button {
820 label {Label BG Color}
821 callback {// Find first item in tree
822 Fl_Tree_Item *item = tree->first();
825 // Get first item's color
826 Fl_Color val = EditColor(item->labelbgcolor()); // Get color of first item in tree
827 all_labelbgcolor_button->color(val); // update modified color to button
831 for ( item=tree->first(); item; item = tree->next(item) ) {
832 if ( item->is_selected() ) {
833 item->labelbgcolor(val);
838 // No items selected? Do all..
840 for ( item=tree->first(); item; item = tree->next(item) ) {
841 item->labelbgcolor(val);
846 tooltip {Changes the label bg color for the selected items. If none selected, all are changed. Tests Fl_Tree_Item::labelbgcolor();} xywh {828 99 16 16} box DOWN_BOX labelsize 12 align 7
847 code0 {o->color(tree->item_labelbgcolor());}
849 Fl_Value_Slider connectorwidth_slider {
850 label {Connector Width}
852 callback {tree->connectorwidth((int)connectorwidth_slider->value());}
853 tooltip {Tests Fl_Tree::connectorwidth()} xywh {828 126 140 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
854 code0 {o->value(tree->connectorwidth());}
855 code1 {o->range(1.0, 100.0);}
856 code2 {o->step(1.0);}
857 code3 {o->color(46); o->selection_color(FL_RED);}
859 Fl_Light_Button deactivate_toggle {
861 callback {int onoff = deactivate_toggle->value() ? 0 : 1;
865 for ( item=tree->first(); item; item = tree->next(item) ) {
866 if ( item->is_selected() ) {
867 item->activate(onoff);
873 for ( item=tree->first(); item; item = tree->next(item) ) {
874 item->activate(onoff);
879 tooltip {Toggle the deactivation state of the selected items.
880 If none are selected, all are set.} xywh {734 154 95 16} selection_color 1 labelsize 9
882 Fl_Light_Button bold_toggle {
884 callback {int face = bold_toggle->value() ? FL_HELVETICA_BOLD : FL_HELVETICA;
889 for ( item=tree->first(); item; item = tree->next(item) ) {
890 if ( item->is_selected() ) {
891 item->labelfont(face);
896 // NO ITEMS SELECTED? DO ALL
898 for ( item=tree->first(); item; item = tree->next(item) ) {
899 item->labelfont(face);
904 tooltip {Toggles bold font for selected items
905 If nothing selected, all are changed} xywh {734 174 95 16} selection_color 1 labelsize 9
907 Fl_Button showselected_button {
908 label {Show Selected}
909 callback {fprintf(stderr, "--- SELECTED ITEMS\\n");
910 for ( Fl_Tree_Item *item = tree->first_selected_item();
912 item = tree->next_selected_item(item) ) {
913 fprintf(stderr, "\\t%s\\n", item->label() ? item->label() : "???");
915 tooltip {Clears the selected items} xywh {829 154 95 16} labelsize 9
917 Fl_Button clearselected_button {
918 label {Remove Selected}
919 callback {Fl_Tree_Item *item=tree->first();
921 if ( item->is_selected() ) {
922 if ( tree->remove(item) == -1 ) break;
923 item = tree->first();
930 tooltip {Removes the selected items} xywh {829 174 95 16} labelsize 9
932 Fl_Button selectall_button {
934 callback {tree->select_all(0);
936 tooltip {Selects all items in the tree} xywh {689 201 95 16} labelsize 9
938 Fl_Button deselectall_button {
940 callback {tree->deselect_all(0);
942 tooltip {Deselects all items in the tree} xywh {689 221 95 16} labelsize 9
944 Fl_Light_Button bbbselect_toggle {
946 callback {// Toggle select of just the Bbb item (not children)
947 Fl_Tree_Item *bbb = tree->find_item("/Bbb");
949 fl_alert("FAIL: Couldn't find item '/Bbb'???");
952 int onoff = bbbselect_toggle->value();
953 if ( onoff ) tree->select(bbb); // select /Bbb
954 else tree->deselect(bbb); // deselect /Bbb}
955 tooltip {Toggle selection of just the /Bbb item
956 (Not children)} xywh {784 201 95 16} selection_color 1 labelsize 9
958 Fl_Light_Button bbbselect2_toggle {
960 callback {// Toggle select of just the Bbb item and its immediate children
961 Fl_Tree_Item *bbb = tree->find_item("/Bbb");
963 fl_alert("FAIL: Couldn't find item '/Bbb'???");
966 int onoff = bbbselect2_toggle->value();
967 if ( onoff ) tree->select_all(bbb); // select /Bbb and its children
968 else tree->deselect_all(bbb); // deselect /Bbb and its children}
969 tooltip {Toggle selection of the /Bbb item and its children} xywh {784 221 95 16} selection_color 1 labelsize 9
971 Fl_Light_Button bbbchild02select_toggle {
972 label { Toggle child-02}
973 callback {// Toggle select of just the /Bbb/child-02 item
974 const char *pathname = "/Bbb/child-02";
975 int onoff = bbbchild02select_toggle->value();
977 if ( onoff ) err = tree->select(pathname);
978 else err = tree->deselect(pathname);
981 fl_alert("FAIL: Couldn't find item '%s'",pathname);
984 tooltip {Toggle the single item "/Bbb/child-02" using the item's "pathname".} xywh {784 241 95 16} selection_color 1 labelsize 9
986 Fl_Light_Button rootselect_toggle {
988 callback {// Toggle select of ROOT item and its children
989 Fl_Tree_Item *item = tree->find_item("/ROOT");
991 fl_alert("FAIL: Couldn't find item '/ROOT'???");
994 int onoff = rootselect_toggle->value();
995 if ( onoff ) tree->select(item); // select /ROOT and its children
996 else tree->deselect(item); // deselect /ROOT and its children}
997 tooltip {Toggle selection of the ROOT item} xywh {879 201 95 16} selection_color 1 labelsize 9
999 Fl_Light_Button rootselect2_toggle {
1000 label {Select ROOT+}
1001 callback {// Toggle select of ROOT item and its children
1002 Fl_Tree_Item *item = tree->find_item("/ROOT");
1004 fl_alert("FAIL: Couldn't find item '/ROOT'???");
1007 int onoff = rootselect2_toggle->value();
1008 if ( onoff ) tree->select_all(item); // select /ROOT and its children
1009 else tree->deselect_all(item); // deselect /ROOT and its children}
1010 tooltip {Toggle selection of the ROOT item and all children} xywh {879 221 95 16} selection_color 1 labelsize 9
1013 label {New Item Defaults}
1014 tooltip {These controls only affect the defaults for new items that are created. These test the Fl_Tree_Prefs methods.} xywh {661 312 335 120} box GTK_DOWN_BOX color 47 labelsize 12 align 1
1016 Fl_Button item_labelfgcolor_button {
1017 label item_labelfgcolor
1018 callback {Fl_Color val = EditColor(tree->item_labelfgcolor()); // Let user edit the color
1019 tree->item_labelfgcolor(val); // apply modified color to tree
1020 item_labelfgcolor_button->color(val); // update modified color to button}
1021 tooltip {Sets the *default* label foreground color for new items created. Does NOT affect existing items.} xywh {828 327 16 16} box DOWN_BOX labelsize 12 align 7
1022 code0 {o->color(tree->item_labelfgcolor());}
1024 Fl_Button item_labelbgcolor_button {
1025 label item_labelbgcolor
1026 callback {Fl_Color val = EditColor(tree->item_labelbgcolor()); // Let user edit the color
1027 tree->item_labelbgcolor(val); // apply modified color to tree
1028 item_labelbgcolor_button->color(val); // update modified color to button}
1029 tooltip {Sets the *default* label background color for new items created. Does NOT affect existing items.} xywh {828 345 16 16} box DOWN_BOX labelsize 12 align 7
1030 code0 {item_labelbgcolor_button->color(tree->item_labelbgcolor());}
1032 Fl_Choice item_font_choice {
1033 label {Item label font}
1034 callback {Fl_Font val = (Fl_Font)item_font_choice->value(); // get chooser's current font value
1035 tree->item_labelfont(val); // change font in tree}
1036 tooltip {Sets the default font used for new items created. Does NOT affect existing items.} xywh {828 371 140 21} down_box BORDER_BOX labelsize 12 textsize 12
1037 code0 {o->value((int)tree->item_labelfont()); // get tree's current font, assign to chooser}
1041 xywh {20 20 36 21} labelsize 12
1044 label {Helvetica Bold}
1045 xywh {30 30 36 21} labelsize 12
1048 label {Helvetica Italic}
1049 xywh {45 45 36 21} labelsize 12
1052 label {Helvetica Bold Italic}
1053 xywh {50 50 36 21} labelsize 12
1057 xywh {60 60 36 21} labelsize 12
1060 label {Courier Bold}
1061 xywh {70 70 36 21} labelsize 12
1064 label {Courier Italic}
1065 xywh {55 55 36 21} labelsize 12
1068 label {Courier Bold Italic}
1069 xywh {60 60 36 21} labelsize 12
1073 xywh {70 70 36 21} labelsize 12
1077 xywh {80 80 36 21} labelsize 12
1080 label {Times Italic}
1081 xywh {65 65 36 21} labelsize 12
1084 label {Times Bold Italic}
1085 xywh {70 70 36 21} labelsize 12
1089 xywh {80 80 36 21} labelsize 12
1093 xywh {90 90 36 21} labelsize 12
1097 xywh {75 75 36 21} labelsize 12
1100 label {Zapf Dingbats}
1101 xywh {80 80 36 21} labelsize 12
1104 Fl_Value_Slider item_labelsize_slider {
1105 label item_labelsize
1107 callback {tree->item_labelsize((int)item_labelsize_slider->value());}
1108 tooltip {Sets the default labelsize used for new items. Does NOT affect existing items.} xywh {828 396 140 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
1109 code0 {o->value((int)tree->item_labelsize());}
1110 code1 {o->range(1.0, 50.0);}
1111 code2 {o->step(1.0);}
1112 code3 {o->color(46); o->selection_color(FL_RED);}
1115 Fl_Box resizer_box {
1119 code {// Initialize Tree
1120 tree->root_label("ROOT");
1122 /*tree->show_self();*/} {}
1125 //Fl::scheme("gtk+");
1127 window->resizable(tree);
1128 window->size_range(window->w(), window->h(), 0, 0);
1130 if ( tree->when() == FL_WHEN_CHANGED ) whenmode_chooser->value(0);
1131 else if ( tree->when() == FL_WHEN_RELEASE ) whenmode_chooser->value(1);
1132 else if ( tree->when() == FL_WHEN_NEVER ) whenmode_chooser->value(2);} {}