summaryrefslogtreecommitdiff
path: root/test/tree.fl
blob: 13269b576b7ad24237e713a96bce8882b0a63f26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
# data file for the Fltk User Interface Designer (fluid)
version 1.0300 
header_name {.h} 
code_name {.cxx}
decl {\#include <stdio.h>} {public global
} 

decl {\#include <FL/Fl.H>} {public global
} 

decl {\#include <FL/Fl_Pixmap.H>} {public global
} 

decl {\#include <FL/Fl_Group.H>} {public global
} 

decl {\#include <FL/Fl_Tree.H>} {public global
} 

decl {\#include <FL/fl_ask.H>} {public global
} 

decl {\#include <FL/fl_message.H>} {public global
} 

decl {\#include <FL/Fl_File_Chooser.H>} {public global
} 

decl {\#include <FL/Fl_Preferences.H>} {public global
} 

decl {\#include <FL/Fl_Color_Chooser.H>} {public global
} 

decl {int G_cb_counter = 0;} {
  comment {// Global callback event counter} private local
} 

Function {reason_as_name(Fl_Tree_Reason reason)} {
  comment {Return an Fl_Tree_Reason as a text string name} return_type {const char*}
} {
  code {switch ( reason ) {
      case FL_TREE_REASON_NONE:       return("none");
      case FL_TREE_REASON_SELECTED:   return("selected");
      case FL_TREE_REASON_DESELECTED: return("deselected");
      case FL_TREE_REASON_OPENED:     return("opened");
      case FL_TREE_REASON_CLOSED:     return("closed");
\#if FLTK_ABI_VERSION >= 10302
	  case FL_TREE_REASON_RESELECTED: return("reselected");
\#endif
      default:                        return("???");
    }} {}
} 

Function {Button_CB(Fl_Widget*w, void*data)} {return_type void
} {
  code {fprintf(stderr, "'%s' button pushed\\n", w->label());} {}
} 

Function {AssignUserIcons()} {
  comment {Assign user icons to the items} open
} {
  code {static const char *L_folder_xpm[] = {
    "11 11 3 1",
    ".  c None",
    "x  c \#d8d833",
    "@  c \#808011",
    "...........",
    ".....@@@@..",
    "....@xxxx@.",
    "@@@@@xxxx@@",
    "@xxxxxxxxx@",
    "@xxxxxxxxx@",
    "@xxxxxxxxx@",
    "@xxxxxxxxx@",
    "@xxxxxxxxx@",
    "@xxxxxxxxx@",
    "@@@@@@@@@@@"};
static Fl_Pixmap L_folderpixmap(L_folder_xpm);

static const char *L_document_xpm[] = {
    "11 11 3 1",
    ".  c None",
    "x  c \#d8d8f8",
    "@  c \#202060",
    ".@@@@@@@@@.",
    ".@xxxxxxx@.",
    ".@xxxxxxx@.",
    ".@xxxxxxx@.",
    ".@xxxxxxx@.",
    ".@xxxxxxx@.",
    ".@xxxxxxx@.",
    ".@xxxxxxx@.",
    ".@xxxxxxx@.",
    ".@xxxxxxx@.",
    ".@@@@@@@@@."};
static Fl_Pixmap L_documentpixmap(L_document_xpm);

// Assign user icons to tree items
for ( Fl_Tree_Item *item = tree->first(); item; item=item->next())
    if ( usericon_radio->value() )
        // Assign custom icons
        item->usericon(item->has_children() ? &L_folderpixmap : &L_documentpixmap);
    else
    	// Don't assign custom icons
        item->usericon(0);

tree->redraw();} {}
} 

Function {RebuildTree()} {
  comment {Rebuild the 'example tree' from scratch} open
} {
  code {// REBUILD THE TREE TO MAKE CURRENT "DEFAULT" PREFS TAKE EFFECT
tree->clear();
tree->add("Aaa");
tree->add("Bbb");
tree->add("Ccc");
tree->add("Ddd");
tree->add("Bbb/child-01");
tree->add("Bbb/child-01/111");
tree->add("Bbb/child-01/222");
tree->add("Bbb/child-01/333");
tree->add("Bbb/child-02");
tree->add("Bbb/child-03");
tree->add("Bbb/child-04");

{
    static Fl_Button *but = 0;
    // Assign an FLTK widget to one of the items
    Fl_Tree_Item *i;
    if ( ( i = tree->find_item("Bbb/child-03") ) != NULL ) {
        if ( !but ) {		// only do this once at program startup
            tree->begin();
            but = new Fl_Button(1,1,140,1,"ccc button");     // we control w() only
            but->labelsize(10);
	    but->callback(Button_CB);
        }
        i->widget(but);
        tree->end();
    }
}
{
    // Assign an FLTK group to one of the items with widgets
    Fl_Tree_Item *i;
    if ( ( i = tree->find_item("Bbb/child-04") ) != NULL ) {
        static Fl_Group *grp = 0;
        if ( !grp ) {		// only do this once at program startup
            tree->begin();
              grp = new Fl_Group(100,100,140,18); // build group.. tree handles position
              grp->color(FL_WHITE);
              grp->begin();
                Fl_Button *abut = new Fl_Button(grp->x()+0 ,grp->y()+2,65,15,"D1");
                abut->labelsize(10);
		abut->callback(Button_CB);
                Fl_Button *bbut = new Fl_Button(grp->x()+75,grp->y()+2,65,15,"D2");
                bbut->labelsize(10);
		bbut->callback(Button_CB);
              grp->end();
              grp->resizable(grp);
            tree->end();
        }
        i->widget(grp);
    }
}

// Add an 'Ascending' node, and create it sorted
tree->sortorder(FL_TREE_SORT_NONE);
tree->add("Ascending")->close();
tree->sortorder(FL_TREE_SORT_ASCENDING);
tree->add("Ascending/Zzz");
tree->add("Ascending/Xxx");
tree->add("Ascending/Aaa");
tree->add("Ascending/Bbb");
tree->add("Ascending/Yyy");
tree->add("Ascending/Ccc");

// Add a 'Descending' node, and create it sorted
tree->sortorder(FL_TREE_SORT_NONE);
tree->add("Descending")->close();
tree->sortorder(FL_TREE_SORT_DESCENDING);
tree->add("Descending/Zzz");
tree->add("Descending/Xxx");
tree->add("Descending/Aaa");
tree->add("Descending/Bbb");
tree->add("Descending/Yyy");
tree->add("Descending/Ccc");

// Add 500 items in numerical order
tree->sortorder(FL_TREE_SORT_NONE);
for ( int t=0; t<500; t++ ) {
    static char s[80];
    sprintf(s, "500 Items/item %04d", t);
    tree->add(s);
}
tree->close("500 Items");	// close the 500 items by default

AssignUserIcons();

tree->redraw();} {}
} 

Function {EditColor(Fl_Color val)} {
  comment {Prompt the user to change the specified color} return_type Fl_Color
} {
  code {uchar r,g,b;
// Get the current color
Fl::get_color(val,r,g,b);

// Bring up a color chooser to edit it
fl_color_chooser("Choose Color",r,g,b);

// Return the new color the user picked
return(fl_rgb_color(r,g,b));} {}
} 

Function {} {open
} {
  Fl_Window window {
    label tree open
    xywh {800 102 1015 445} type Double visible
  } {
    Fl_Group tree {
      label Tree
      user_data 1234
      callback {G_cb_counter++; // Increment callback counter whenever tree callback is invoked
\#if FLTK_ABI_VERSION >= 10302
	  tree->item_reselect_mode(FL_TREE_SELECTABLE_ALWAYS);
\#endif
Fl_Tree_Item *item = tree->callback_item();
if ( item ) {
  fprintf(stderr, "TREE CALLBACK: label='%s' userdata=%ld reason=%s\\n",
          item->label(),
          (long)(fl_intptr_t)tree->user_data(),
	  reason_as_name(tree->callback_reason()));
} else {
  fprintf(stderr, "TREE CALLBACK: reason=%s item=(no item -- probably multiple items were changed at once)\\n",
          reason_as_name(tree->callback_reason()));
}} open selected
      tooltip {Test tree} xywh {15 22 280 411} box DOWN_BOX color 55 selection_color 15
      class Fl_Tree
    } {}
    Fl_Group {} {open
      xywh {300 5 705 427}
      code0 {o->resizable(0);}
    } {
      Fl_Box {} {
        label {Tree Globals}
        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
      }
      Fl_Value_Slider margintop_slider {
        label {margintop()}
        user_data tree
        callback {int val = (int)margintop_slider->value();
tree->margintop(val);
tree->redraw();}
        tooltip {Changes the top margin for the tree widget} xywh {486 31 140 16} type Horizontal labelsize 12 align 4 textsize 12
        code0 {o->value(tree->margintop());}
        code1 {o->range(0.0, 100.0);}
        code2 {o->step(1.0);}
        code3 {o->color(46); o->selection_color(FL_RED);}
      }
      Fl_Value_Slider marginleft_slider {
        label {marginleft()}
        user_data tree
        callback {int val = (int)marginleft_slider->value();
tree->marginleft(val);
tree->redraw();}
        tooltip {Changes the left margin for the tree widget} xywh {486 51 140 16} type Horizontal labelsize 12 align 4 textsize 12
        code0 {o->value(tree->marginleft());}
        code1 {o->range(0.0, 100.0);}
        code2 {o->step(1.0);}
        code3 {o->color(46); o->selection_color(FL_RED);}
      }
      Fl_Value_Slider openchild_marginbottom_slider {
        label {openchild_marginbottom()}
        user_data tree
        callback {int val = (int)openchild_marginbottom_slider->value();
tree->openchild_marginbottom(val);
tree->redraw();}
        tooltip {Changes the vertical space below an open child tree} xywh {486 71 140 16} type Horizontal labelsize 12 align 4 textsize 12
        code0 {o->value(tree->openchild_marginbottom());}
        code1 {o->range(0.0, 100.0);}
        code2 {o->step(1.0);}
        code3 {o->color(46); o->selection_color(FL_RED);}
      }
      Fl_Choice collapseicons_chooser {
        label {Collapse icons}
        callback {static const char *L_open_xpm[] = {
\#ifdef __APPLE__
  "11 11 3 1",
  ".	c \#fefefe",
  "\#	c \#444444",
  "@	c \#000000",
  "\#\#\#\#\#\#\#\#\#\#\#",
  "\#.........\#",
  "\#.........\#",
  "\#....@....\#",
  "\#....@....\#",
  "\#..@@@@@..\#",
  "\#....@....\#",
  "\#....@....\#",
  "\#.........\#",
  "\#.........\#",
  "\#\#\#\#\#\#\#\#\#\#\#"
\#else
    "11 11 2 1",
    ".  c None",
    "@  c \#000000",
    "...@.......",
    "...@@......",
    "...@@@.....",
    "...@@@@....",
    "...@@@@@...",
    "...@@@@@@..",
    "...@@@@@...",
    "...@@@@....",
    "...@@@.....",
    "...@@......",
    "...@......."
\#endif
    };
static Fl_Pixmap L_openpixmap(L_open_xpm);

static const char *L_close_xpm[] = {
\#ifdef __APPLE__
  "11 11 3 1",
  ".	c \#fefefe",
  "\#	c \#444444",
  "@	c \#000000",
  "\#\#\#\#\#\#\#\#\#\#\#",
  "\#.........\#",
  "\#.........\#",
  "\#.........\#",
  "\#.........\#",
  "\#..@@@@@..\#",
  "\#.........\#",
  "\#.........\#",
  "\#.........\#",
  "\#.........\#",
  "\#\#\#\#\#\#\#\#\#\#\#"
\#else
    "11 11 2 1",
    ".  c None",
    "@  c \#000000",
    "...........",
    "...........",
    "...........",
    "...........",
    "...........",
    "@@@@@@@@@@@",
    ".@@@@@@@@@.",
    "..@@@@@@@..",
    "...@@@@@...",
    "....@@@....",
    ".....@....."
\#endif
    };
static Fl_Pixmap L_closepixmap(L_close_xpm);

switch ( collapseicons_chooser->value() ) {
    case 0:
        tree->showcollapse(1);
        tree->openicon(0);
        tree->closeicon(0);
        break;
    case 1:
        tree->showcollapse(1);
        tree->openicon(&L_openpixmap);
        tree->closeicon(&L_closepixmap);
        break;
    case 2:
        tree->showcollapse(0);
        break;
}}
        tooltip {Tests Fl_Tree::openicon() and Fl_Tree::closeicon()} xywh {486 96 140 21} down_box BORDER_BOX labelsize 12 textsize 11
      } {
        MenuItem {} {
          label Normal
          xywh {10 10 36 21} labelsize 12
        }
        MenuItem {} {
          label Custom
          xywh {20 20 36 21} labelsize 12
        }
        MenuItem {} {
          label Off
          xywh {30 30 36 21} labelsize 12
        }
      }
      Fl_Choice connectorstyle_chooser {
        label {Line style}
        callback {// CHANGE COLLAPSESTYLE
switch ( connectorstyle_chooser->value() ) {
    case 0: tree->connectorstyle(FL_TREE_CONNECTOR_NONE);     break;
    case 1: tree->connectorstyle(FL_TREE_CONNECTOR_DOTTED);   break;
    case 2: tree->connectorstyle(FL_TREE_CONNECTOR_SOLID);    break;
}}
        tooltip {Tests connectorstyle() bit flags} xywh {486 120 140 21} down_box BORDER_BOX labelsize 12 textsize 11
        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; }}
      } {
        MenuItem {} {
          label None
          xywh {40 40 36 21} labelsize 12
        }
        MenuItem {} {
          label Dotted
          xywh {20 20 36 21} labelsize 12
        }
        MenuItem {} {
          label Solid
          xywh {30 30 36 21} labelsize 12
        }
      }
      Fl_Choice selectmode_chooser {
        label {Selection Mode}
        callback {// Set selection mode
switch ( selectmode_chooser->value() ) {
    case 0:  tree->selectmode(FL_TREE_SELECT_NONE);   break;	// None
    case 1:  tree->selectmode(FL_TREE_SELECT_SINGLE); break;	// Single
    case 2:  tree->selectmode(FL_TREE_SELECT_MULTI);  break; 	// Multi
    default: tree->selectmode(FL_TREE_SELECT_SINGLE); break;	// Single
}}
        tooltip {Sets how Fl_Tree handles mouse selection of tree items} xywh {486 144 140 21} down_box BORDER_BOX labelsize 12 textsize 11
        code0 {selectmode_chooser->value(1);}
        code1 {cb_selectmode_chooser(selectmode_chooser, (void*)0);}
      } {
        MenuItem {} {
          label None
          xywh {40 40 36 21} labelsize 12
        }
        MenuItem {} {
          label Single
          xywh {50 50 36 21} labelsize 12
        }
        MenuItem {} {
          label Multi
          xywh {60 60 36 21} labelsize 12
        }
      }
      Fl_Choice whenmode_chooser {
        label When
        callback {// Set when mode
switch ( whenmode_chooser->value() ) {
  case 0:  tree->when(FL_WHEN_RELEASE);   break;
  case 1:  tree->when(FL_WHEN_CHANGED);   break;
  case 2:  tree->when(FL_WHEN_NEVER);     break;
  default: tree->when(FL_WHEN_RELEASE);   break;
}}
        tooltip {Sets when() the tree's callback is invoked} xywh {486 168 140 21} down_box BORDER_BOX labelsize 12 textsize 11
        code0 {whenmode_chooser->value(1);}
        code1 {cb_whenmode_chooser(whenmode_chooser, (void*)0);}
      } {
        MenuItem {} {
          label Changed
          xywh {50 50 36 21} labelsize 12
        }
        MenuItem {} {
          label Released
          xywh {60 60 36 21} labelsize 12
        }
        MenuItem {} {
          label Never
          xywh {70 70 36 21} labelsize 12
        }
      }
      Fl_Check_Button usericon_radio {
        label {Enable user icons?}
        user_data tree
        callback {AssignUserIcons();}
        tooltip {Tests Fl_Tree_Item::usericon()} xywh {486 194 20 16} down_box DOWN_BOX labelsize 12 align 7
        code0 {usericon_radio->value(1);}
      }
      Fl_Check_Button showroot_radio {
        label {Show root?}
        user_data tree
        callback {int onoff = showroot_radio->value();
tree->showroot(onoff);}
        tooltip {Tests tree->showroot();} xywh {486 211 20 16} down_box DOWN_BOX labelsize 12 align 7
        code0 {int onoff = tree->showroot(); showroot_radio->value(onoff);}
      }
      Fl_Check_Button visiblefocus_checkbox {
        label {Visible focus?}
        user_data tree
        callback {int onoff = visiblefocus_checkbox->value();
tree->visible_focus(onoff);}
        tooltip {Toggles the tree's visible_focus() box} xywh {486 228 20 16} down_box DOWN_BOX labelsize 12 align 7
        code0 {int onoff = tree->visible_focus(); visiblefocus_checkbox->value(onoff);}
      }
      Fl_Button selection_color_button {
        label {Selection Color}
        callback {Fl_Color val = EditColor(tree->selection_color());		// Get color of first item in tree
selection_color_button->color(val);	// update modified color to button
tree->selection_color(val);
tree->redraw();}
        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
        code0 {o->color(tree->selection_color());}
      }
      Fl_Box {} {
        label {Test Operations}
        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
      }
      Fl_Box showitem_box {
        label {show_item()
}
        xywh {331 335 70 82} box GTK_DOWN_BOX labelsize 11 align 1
      }
      Fl_Button {} {
        label Show
        callback {Fl_Tree_Item *item = tree->next_selected_item();
tree->show_item(item);}
        tooltip {Tests show_item() with no position specified.
Makes the selected item visible IF it is off-screen.
No change made if it is not off-screen.} xywh {346 344 40 17} labelsize 11
      }
      Fl_Button {} {
        label Top
        callback {Fl_Tree_Item *item = tree->next_selected_item();
tree->show_item_top(item);}
        tooltip {Test show_item_top().
Scrolls selected item to the top of the display
(only works if scrollbar showing)
To use:
1) open '500 items'
2) select item 0010
3) Hit Top/Mid/Bot} xywh {346 361 40 16} labelsize 11
      }
      Fl_Button {} {
        label Mid
        callback {Fl_Tree_Item *item = tree->next_selected_item();
tree->show_item_middle(item);}
        tooltip {Tests show_item_middle().
Scrolls the selected item to the middle of the display
To use:
  1) open '500 items'
  2) select 'item 0010'
  3) Hit Top/Mid/Bot} xywh {346 377 40 16} labelsize 11
      }
      Fl_Button {} {
        label Bot
        callback {Fl_Tree_Item *item = tree->next_selected_item();
tree->show_item_bottom(item);}
        tooltip {Tests show_item_bottom().
Scrolls the selected item to the bottom of the display
To use:
  1) open '500 items'
  2) select 'item 0010'
  3) Hit Top/Mid/Bot} xywh {346 393 40 16} labelsize 11
      }
      Fl_Button loaddb_button {
        label {Load Database...}
        callback {const char *filename = fl_file_chooser("Select a Preferences style Database", "Preferences(*.prefs)", 0L);
if (filename) {
  tree->clear();
  Fl_Preferences prefs(filename, 0L, 0L);
  tree->load(prefs);
  tree->redraw();
}}
        tooltip {Load the contents of an Fl_Preferences database into the tree view} xywh {431 338 95 16} labelsize 9
      }
      Fl_Button insertabove_button {
        label {Insert Above}
        callback {Fl_Tree_Item *item=tree->first();
while (item) {
    if ( item->is_selected() ) {
        tree->insert_above(item, "AaaAaa");
        tree->insert_above(item, "BbbBbb");
        tree->insert_above(item, "CccCcc");
    }
    item = item->next();
}

tree->redraw();}
        tooltip {Inserts three items above the selected items} xywh {431 358 95 16} labelsize 9
      }
      Fl_Button rebuildtree_button {
        label {Rebuild Tree}
        callback {RebuildTree();}
        tooltip {Rebuilds the tree with defaults} xywh {431 378 95 16} labelsize 9
      }
      Fl_Button showpathname_button {
        label {Show Pathname}
        callback {Fl_Tree_Item *item = tree->first_selected_item();
if ( !item ) { fl_message("No item was selected"); return; }

char pathname[256];
switch ( tree->item_pathname(pathname, sizeof(pathname), item) ) {
    case  0: fl_message("Pathname for '%s' is: \\"%s\\"", (item->label() ? item->label() : "???"), pathname); break;
    case -1: fl_message("item_pathname() returned -1 (NOT FOUND)"); break;
    case -2: fl_message("item_pathname() returned -2 (STRING TOO LONG)"); break;
}}
        tooltip {Show the pathname for the selected item. Tests the Fl_Tree::item_pathname() method.} xywh {431 398 95 16} labelsize 9
      }
      Fl_Button clearall_button {
        label {Clear All}
        callback {tree->clear();
tree->redraw();}
        tooltip {Clears all items
Tests Fl_Tree::clear()} xywh {531 338 95 16} labelsize 9
      }
      Fl_Button testcallbackflag_button {
        label {Test Callback Flag}
        callback {Fl_Tree_Item *root = tree->root();
fprintf(stderr, "--- Checking docallback off\\n");
if (!root) return;

//// "OFF" TEST

// open/close: Make sure these methods don't trigger cb
G_cb_counter = 0; tree->close(root, 0);       if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n close(item) triggered cb!");
G_cb_counter = 0; tree->open(root, 0);        if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n open(item) triggered cb!");
G_cb_counter = 0; tree->open_toggle(root, 0); if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n open_toggle(item) triggered cb!");
G_cb_counter = 0; tree->open("ROOT", 0);      if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n open(path) triggered cb!");
G_cb_counter = 0; tree->close("ROOT", 0);     if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n close(path) triggered cb!");
tree->open(root,0);	// leave root open

// select/deselect: Make sure these methods don't trigger cb
G_cb_counter = 0; tree->select(root, 0);        if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n select(item) triggered cb!");
G_cb_counter = 0; tree->deselect(root, 0);      if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n deselect(item) triggered cb!");
G_cb_counter = 0; tree->select_toggle(root, 0); if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n select_toggle(item) triggered cb!");
G_cb_counter = 0; tree->deselect("ROOT", 0);    if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n deselect(path) triggered cb!");
G_cb_counter = 0; tree->select("ROOT", 0);      if ( G_cb_counter ) fl_alert("FAILED 'OFF' TEST\\n select(path) triggered cb!");
tree->deselect("ROOT"); // leave deselected

//// "ON" TEST

// open/close: Make sure these methods don't trigger cb
G_cb_counter = 0; tree->close(root, 1);       if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n close(item) cb wasn't triggered!");
G_cb_counter = 0; tree->open(root, 1);        if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n open(item) cb wasn't triggered!");
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!");
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!");
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!");
G_cb_counter = 0; tree->open("ROOT", 1);      if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n open(path) cb wasn't triggered!");
G_cb_counter = 0; tree->close("ROOT", 1);     if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n close(path) cb wasn't triggered!");
tree->open(root,0);	// leave root open

// select/deselect: Make sure these methods don't trigger cb
G_cb_counter = 0; tree->select(root, 1);        if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n select(item) cb wasn't triggered!");
G_cb_counter = 0; tree->deselect(root, 1);      if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n deselect(item) cb wasn't triggered!");
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!");
G_cb_counter = 0; tree->deselect("ROOT", 1);    if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n deselect(path) cb wasn't triggered!");
G_cb_counter = 0; tree->select("ROOT", 1);      if ( !G_cb_counter ) fl_alert("FAILED 'ON' TEST\\n select(path) cb wasn't triggered!");
tree->deselect("ROOT"); // leave deselected

//// "default" TEST (should be same as 'on'

// open/close: Make sure these methods don't trigger cb
G_cb_counter = 0; tree->close(root);       if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST: close(item) cb wasn't triggered!");
G_cb_counter = 0; tree->open(root);        if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST: open(item) cb wasn't triggered!");
G_cb_counter = 0; tree->open_toggle(root); if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST: open_toggle(item) cb wasn't triggered!");
G_cb_counter = 0; tree->open("ROOT");      if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST: open(path) cb wasn't triggered!");
G_cb_counter = 0; tree->close("ROOT");     if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST: close(path) cb wasn't triggered!");
tree->open(root,0);	// leave root open

// select/deselect: Make sure these methods don't trigger cb
G_cb_counter = 0; tree->select(root);        if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST\\n select(item) cb wasn't triggered!");
G_cb_counter = 0; tree->deselect(root);      if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST\\n deselect(item) cb wasn't triggered!");
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!");
G_cb_counter = 0; tree->deselect("ROOT");    if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST\\n deselect(path) cb wasn't triggered!");
G_cb_counter = 0; tree->select("ROOT");      if ( !G_cb_counter ) fl_alert("FAILED 'DEFAULT' TEST\\n select(path) cb wasn't triggered!");
tree->deselect("ROOT"); // leave deselected

fl_alert("TEST COMPLETED\\n If you didn't see any error dialogs, test PASSED.");}
        tooltip {Test the 'docallback' argument can disable callbacks.} xywh {531 358 95 16} labelsize 9
      }
      Fl_Button testrootshowself_button {
        label {Root Show Self}
        callback {Fl_Tree_Item *root = tree->root();
fprintf(stderr, "--- Show Tree\\n");
if (root) root->show_self();}
        tooltip {Test the root->'show_self() method to show the entire tree} xywh {530 378 95 16} labelsize 9
      }
      Fl_Box {} {
        label {Selected Items}
        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
      }
      Fl_Choice all_font_choice {
        label {Label Font}
        callback {// Find first item in tree
Fl_Tree_Item *item = tree->first();
if ( !item ) return;

// Get first item's font.
Fl_Font val = (Fl_Font)all_font_choice->value(); // Get font value

// Do selected items
int count = 0;
for ( item=tree->first(); item; item = tree->next(item) ) {
    if ( item->is_selected() ) {
        item->labelfont(val);
        count++;
    }
}

// No items selected? Do all..
if ( ! count ) {
    for ( item=tree->first(); item; item = tree->next(item) ) {
        item->labelfont(val);
    }
}

tree->redraw();}
        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
        code0 {o->value((int)tree->item_labelfont());   // get tree's current font, assign to chooser}
      } {
        MenuItem {} {
          label Helvetica
          xywh {30 30 36 21} labelsize 12
        }
        MenuItem {} {
          label {Helvetica Bold}
          xywh {40 40 36 21} labelsize 12
        }
        MenuItem {} {
          label {Helvetica Italic}
          xywh {55 55 36 21} labelsize 12
        }
        MenuItem {} {
          label {Helvetica Bold Italic}
          xywh {60 60 36 21} labelsize 12
        }
        MenuItem {} {
          label Courier
          xywh {70 70 36 21} labelsize 12
        }
        MenuItem {} {
          label {Courier Bold}
          xywh {80 80 36 21} labelsize 12
        }
        MenuItem {} {
          label {Courier Italic}
          xywh {65 65 36 21} labelsize 12
        }
        MenuItem {} {
          label {Courier Bold Italic}
          xywh {70 70 36 21} labelsize 12
        }
        MenuItem {} {
          label Times
          xywh {80 80 36 21} labelsize 12
        }
        MenuItem {} {
          label {Times Bold}
          xywh {90 90 36 21} labelsize 12
        }
        MenuItem {} {
          label {Times Italic}
          xywh {75 75 36 21} labelsize 12
        }
        MenuItem {} {
          label {Times Bold Italic}
          xywh {80 80 36 21} labelsize 12
        }
        MenuItem {} {
          label Symbol
          xywh {90 90 36 21} labelsize 12
        }
        MenuItem {} {
          label Screen
          xywh {100 100 36 21} labelsize 12
        }
        MenuItem {} {
          label {Screen bold}
          xywh {85 85 36 21} labelsize 12
        }
        MenuItem {} {
          label {Zapf Dingbats}
          xywh {90 90 36 21} labelsize 12
        }
      }
      Fl_Value_Slider labelsize_slider {
        label {Label Size}
        user_data tree
        callback {int size = (int)labelsize_slider->value();

// DO SELECTED ITEMS
int count = 0;
Fl_Tree_Item *item;
for ( item=tree->first(); item; item = tree->next(item) ) {
    if ( item->is_selected() ) {
        item->labelsize(size);
        count++;
    }
}

// NO ITEMS SELECTED? DO ALL
if ( ! count ) {
    for ( item=tree->first(); item; item = tree->next(item) ) {
        item->labelsize(size);
    }
}

tree->redraw();}
        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 textsize 12
        code0 {o->value(tree->item_labelsize());}
        code1 {o->range(5.0, 200.0);}
        code2 {o->step(1.0);}
        code3 {o->color(46); o->selection_color(FL_RED);}
      }
      Fl_Button all_labelfgcolor_button {
        label {Label FG Color}
        callback {// Find first item in tree
Fl_Tree_Item *item = tree->first();
if ( !item ) return;

// Get first item's color
Fl_Color val = EditColor(item->labelfgcolor());		// Get color of first item in tree
all_labelfgcolor_button->color(val);			// update modified color to button

// Do selected items
int count = 0;
for ( item=tree->first(); item; item = tree->next(item) ) {
    if ( item->is_selected() ) {
        item->labelfgcolor(val);
        count++;
    }
}

// No items selected? Do all..
if ( ! count ) {
    for ( item=tree->first(); item; item = tree->next(item) ) {
        item->labelfgcolor(val);
    }
}

tree->redraw();}
        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
        code0 {o->color(tree->item_labelfgcolor());}
      }
      Fl_Button all_labelbgcolor_button {
        label {Label BG Color}
        callback {// Find first item in tree
Fl_Tree_Item *item = tree->first();
if ( !item ) return;

// Get first item's color
Fl_Color val = EditColor(item->labelbgcolor());		// Get color of first item in tree
all_labelbgcolor_button->color(val);			// update modified color to button

// Do selected items
int count = 0;
for ( item=tree->first(); item; item = tree->next(item) ) {
    if ( item->is_selected() ) {
        item->labelbgcolor(val);
        count++;
    }
}

// No items selected? Do all..
if ( ! count ) {
    for ( item=tree->first(); item; item = tree->next(item) ) {
        item->labelbgcolor(val);
    }
}

tree->redraw();}
        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
        code0 {o->color(tree->item_labelbgcolor());}
      }
      Fl_Value_Slider connectorwidth_slider {
        label {Connector Width}
        user_data tree
        callback {tree->connectorwidth((int)connectorwidth_slider->value());}
        tooltip {Tests Fl_Tree::connectorwidth()} xywh {828 126 140 16} type Horizontal labelsize 12 align 4 textsize 12
        code0 {o->value(tree->connectorwidth());}
        code1 {o->range(1.0, 100.0);}
        code2 {o->step(1.0);}
        code3 {o->color(46); o->selection_color(FL_RED);}
      }
      Fl_Light_Button deactivate_toggle {
        label { Deactivate}
        callback {int onoff = deactivate_toggle->value() ? 0 : 1;

Fl_Tree_Item *item;
int count = 0;
for ( item=tree->first(); item; item = tree->next(item) ) {
    if ( item->is_selected() ) {
        item->activate(onoff);
        ++count;
    }
}

if ( count == 0 ) {
    for ( item=tree->first(); item; item = tree->next(item) ) {
        item->activate(onoff);
    }
}

tree->redraw();}
        tooltip {Toggle the deactivation state of the selected items.
If none are selected, all are set.} xywh {734 154 95 16} selection_color 1 labelsize 9
      }
      Fl_Light_Button bold_toggle {
        label { Bold Font}
        callback {int face = bold_toggle->value() ? FL_HELVETICA_BOLD : FL_HELVETICA;

// DO SELECTED ITEMS
int count = 0;
Fl_Tree_Item *item;
for ( item=tree->first(); item; item = tree->next(item) ) {
    if ( item->is_selected() ) {
        item->labelfont(face);
        count++;
    }
}

// NO ITEMS SELECTED? DO ALL
if ( ! count ) {
    for ( item=tree->first(); item; item = tree->next(item) ) {
        item->labelfont(face);
    }
}

tree->redraw();}
        tooltip {Toggles bold font for selected items
If nothing selected, all are changed} xywh {734 174 95 16} selection_color 1 labelsize 9
      }
      Fl_Button showselected_button {
        label {Show Selected}
        callback {fprintf(stderr, "--- SELECTED ITEMS\\n");
for ( Fl_Tree_Item *item = tree->first_selected_item();
      item;
      item = tree->next_selected_item(item) ) {
  fprintf(stderr, "\\t%s\\n", item->label() ? item->label() : "???");
}}
        tooltip {Clears the selected items} xywh {829 154 95 16} labelsize 9
      }
      Fl_Button clearselected_button {
        label {Remove Selected}
        callback {Fl_Tree_Item *item=tree->first();
while (item) {
    if ( item->is_selected() ) {
    	if ( tree->remove(item) == -1 ) break;
    	item = tree->first();
    } else {
        item = item->next();
    }
}

tree->redraw();}
        tooltip {Removes the selected items} xywh {829 174 95 16} labelsize 9
      }
      Fl_Button selectall_button {
        label {Select All}
        callback {tree->select_all(0);
tree->redraw();}
        tooltip {Selects all items in the tree} xywh {689 219 95 16} labelsize 9
      }
      Fl_Button deselectall_button {
        label {Deselect All}
        callback {tree->deselect_all(0);
tree->redraw();}
        tooltip {Deselects all items in the tree} xywh {689 239 95 16} labelsize 9
      }
      Fl_Light_Button bbbselect_toggle {
        label { Select Bbb}
        callback {// Toggle select of just the Bbb item (not children)
Fl_Tree_Item *bbb = tree->find_item("/Bbb");
if ( !bbb) {
  fl_alert("FAIL: Couldn't find item '/Bbb'???");
  return;
}
int onoff = bbbselect_toggle->value();
if ( onoff ) tree->select(bbb);		// select /Bbb
else         tree->deselect(bbb);	// deselect /Bbb}
        tooltip {Toggle selection of just the /Bbb item
(Not children)} xywh {784 219 95 16} selection_color 1 labelsize 9
      }
      Fl_Light_Button bbbselect2_toggle {
        label { Select Bbb+}
        callback {// Toggle select of just the Bbb item and its immediate children
Fl_Tree_Item *bbb = tree->find_item("/Bbb");
if ( !bbb) {
  fl_alert("FAIL: Couldn't find item '/Bbb'???");
  return;
}
int onoff = bbbselect2_toggle->value();
if ( onoff ) tree->select_all(bbb);		// select /Bbb and its children
else         tree->deselect_all(bbb);	// deselect /Bbb and its children}
        tooltip {Toggle selection of the /Bbb item and its children} xywh {784 239 95 16} selection_color 1 labelsize 9
      }
      Fl_Light_Button bbbchild02select_toggle {
        label { Toggle child-02}
        callback {// Toggle select of just the /Bbb/child-02 item
const char *pathname = "/Bbb/child-02";
int onoff = bbbchild02select_toggle->value();
int err = 0;
if ( onoff ) err = tree->select(pathname);
else         err = tree->deselect(pathname);

if ( err == -1 ) {
  fl_alert("FAIL: Couldn't find item '%s'",pathname);
  return;
}}
        tooltip {Toggle the single item "/Bbb/child-02" using the item's "pathname".} xywh {784 259 95 16} selection_color 1 labelsize 9
      }
      Fl_Light_Button rootselect_toggle {
        label {Select ROOT}
        callback {// Toggle select of ROOT item and its children
Fl_Tree_Item *item = tree->find_item("/ROOT");
if ( !item) {
  fl_alert("FAIL: Couldn't find item '/ROOT'???");
  return;
}
int onoff = rootselect_toggle->value();
if ( onoff ) tree->select(item);	// select /ROOT and its children
else         tree->deselect(item);	// deselect /ROOT and its children}
        tooltip {Toggle selection of the ROOT item} xywh {879 219 95 16} selection_color 1 labelsize 9
      }
      Fl_Light_Button rootselect2_toggle {
        label {Select ROOT+}
        callback {// Toggle select of ROOT item and its children
Fl_Tree_Item *item = tree->find_item("/ROOT");
if ( !item) {
  fl_alert("FAIL: Couldn't find item '/ROOT'???");
  return;
}
int onoff = rootselect2_toggle->value();
if ( onoff ) tree->select_all(item);	// select /ROOT and its children
else         tree->deselect_all(item);	// deselect /ROOT and its children}
        tooltip {Toggle selection of the ROOT item and all children} xywh {879 239 95 16} selection_color 1 labelsize 9
      }
      Fl_Box {} {
        label {New Item Defaults}
        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
      }
      Fl_Button item_labelfgcolor_button {
        label item_labelfgcolor
        callback {Fl_Color val = EditColor(tree->item_labelfgcolor());	// Let user edit the color
tree->item_labelfgcolor(val);				// apply modified color to tree
item_labelfgcolor_button->color(val);			// update modified color to button}
        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
        code0 {o->color(tree->item_labelfgcolor());}
      }
      Fl_Button item_labelbgcolor_button {
        label item_labelbgcolor
        callback {Fl_Color val = EditColor(tree->item_labelbgcolor());	// Let user edit the color
tree->item_labelbgcolor(val);				// apply modified color to tree
item_labelbgcolor_button->color(val);			// update modified color to button}
        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
        code0 {item_labelbgcolor_button->color(tree->item_labelbgcolor());}
      }
      Fl_Choice item_font_choice {
        label {Item label font}
        callback {Fl_Font val = (Fl_Font)item_font_choice->value(); // get chooser's current font value
tree->item_labelfont(val);			  // change font in tree}
        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
        code0 {o->value((int)tree->item_labelfont());   // get tree's current font, assign to chooser}
      } {
        MenuItem {} {
          label Helvetica
          xywh {20 20 36 21} labelsize 12
        }
        MenuItem {} {
          label {Helvetica Bold}
          xywh {30 30 36 21} labelsize 12
        }
        MenuItem {} {
          label {Helvetica Italic}
          xywh {45 45 36 21} labelsize 12
        }
        MenuItem {} {
          label {Helvetica Bold Italic}
          xywh {50 50 36 21} labelsize 12
        }
        MenuItem {} {
          label Courier
          xywh {60 60 36 21} labelsize 12
        }
        MenuItem {} {
          label {Courier Bold}
          xywh {70 70 36 21} labelsize 12
        }
        MenuItem {} {
          label {Courier Italic}
          xywh {55 55 36 21} labelsize 12
        }
        MenuItem {} {
          label {Courier Bold Italic}
          xywh {60 60 36 21} labelsize 12
        }
        MenuItem {} {
          label Times
          xywh {70 70 36 21} labelsize 12
        }
        MenuItem {} {
          label {Times Bold}
          xywh {80 80 36 21} labelsize 12
        }
        MenuItem {} {
          label {Times Italic}
          xywh {65 65 36 21} labelsize 12
        }
        MenuItem {} {
          label {Times Bold Italic}
          xywh {70 70 36 21} labelsize 12
        }
        MenuItem {} {
          label Symbol
          xywh {80 80 36 21} labelsize 12
        }
        MenuItem {} {
          label Screen
          xywh {90 90 36 21} labelsize 12
        }
        MenuItem {} {
          label {Screen bold}
          xywh {75 75 36 21} labelsize 12
        }
        MenuItem {} {
          label {Zapf Dingbats}
          xywh {80 80 36 21} labelsize 12
        }
      }
      Fl_Value_Slider item_labelsize_slider {
        label item_labelsize
        user_data tree
        callback {tree->item_labelsize((int)item_labelsize_slider->value());}
        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 textsize 12
        code0 {o->value((int)tree->item_labelsize());}
        code1 {o->range(1.0, 50.0);}
        code2 {o->step(1.0);}
        code3 {o->color(46); o->selection_color(FL_RED);}
      }
      Fl_Button swapselected_button {
        label {Swap Selected}
        callback {Fl_Tree_Item *item=tree->first();
Fl_Tree_Item *a = 0, *b = 0;
while (item) {
    if ( item->is_selected() ) {
             if ( !a ) a = item;
        else if ( !b ) b = item;
        else {
          fl_alert("Too many items selected. (must select only two)");
          return;
        }
    }
    item = item->next();
}
if ( !a || !b ) {
  fl_alert("Too few items selected. (you must select two)");
  return;
}
Fl_Tree_Item *pa = a->parent();
Fl_Tree_Item *pb = b->parent();
if ( pa != pb ) {
  fl_alert("The two selected items must be siblings");
  return;
}
pa->swap_children(a,b);
tree->redraw();}
        tooltip {Tests the Fl_Tree_Item::swap_children() method
Swaps two selected items (items must be siblings)} xywh {829 194 95 16} labelsize 9
      }
      Fl_Button add20k_button {
        label {Add 20,000}
        callback {static int item_id = 501;
Fl_Tree_Item *item=tree->first();
while (item) {
    if ( item->is_selected() ) {
        Fl_Tree_Item *parent = item->parent();
        if ( parent == 0 ) parent = tree->root();
        char s[80];
        for ( int i=0; i<20000; i++ ) {
            sprintf(s, "Item \#%d", item_id+i);
            tree->add(parent, s);
        }
        item_id += 20000;
        break;
    }
    item = item->next();
}
tree->redraw();}
        tooltip {Adds 20,000 items to the selected item's parent} xywh {530 398 95 16} labelsize 9
      }
    }
    Fl_Box resizer_box {
      xywh {0 263 15 14}
    }
  }
  code {// Initialize Tree
tree->root_label("ROOT");
RebuildTree();
/*tree->show_self();*/} {}
  code {// FLTK stuff

//Fl::scheme("gtk+");

window->resizable(tree);
window->size_range(window->w(), window->h(), 0, 0);

     if ( tree->when() == FL_WHEN_CHANGED ) whenmode_chooser->value(0);
else if ( tree->when() == FL_WHEN_RELEASE ) whenmode_chooser->value(1);
else if ( tree->when() == FL_WHEN_NEVER   ) whenmode_chooser->value(2);} {}
}