1 // generated by Fast Light User Interface Designer (fluid) version 1.0300
5 // Global callback event counter
7 static int G_cb_counter
= 0;
10 Return an Fl_Tree_Reason as a text string name
12 const char* reason_as_name(Fl_Tree_Reason reason
) {
14 case FL_TREE_REASON_NONE
: return("none");
15 case FL_TREE_REASON_SELECTED
: return("selected");
16 case FL_TREE_REASON_DESELECTED
: return("deselected");
17 case FL_TREE_REASON_OPENED
: return("opened");
18 case FL_TREE_REASON_CLOSED
: return("closed");
19 default: return("???");
23 void Button_CB(Fl_Widget
*w
, void*data
) {
24 fprintf(stderr
, "'%s' button pushed\n", w
->label());
28 Assign user icons to the items
30 void AssignUserIcons() {
31 static const char *L_folder_xpm
[] = {
47 static Fl_Pixmap
L_folderpixmap(L_folder_xpm
);
49 static const char *L_document_xpm
[] = {
65 static Fl_Pixmap
L_documentpixmap(L_document_xpm
);
67 // Assign user icons to tree items
68 for ( Fl_Tree_Item
*item
= tree
->first(); item
; item
=item
->next())
69 if ( usericon_radio
->value() )
70 // Assign custom icons
71 item
->usericon(item
->has_children() ? &L_folderpixmap
: &L_documentpixmap
);
73 // Don't assign custom icons
80 Rebuild the 'example tree' from scratch
83 // REBUILD THE TREE TO MAKE CURRENT "DEFAULT" PREFS TAKE EFFECT
89 tree
->add("Bbb/child-01");
90 tree
->add("Bbb/child-01/111");
91 tree
->add("Bbb/child-01/222");
92 tree
->add("Bbb/child-01/333");
93 tree
->add("Bbb/child-02");
94 tree
->add("Bbb/child-03");
95 tree
->add("Bbb/child-04");
98 static Fl_Button
*but
= 0;
99 // Assign an FLTK widget to one of the items
101 if ( ( i
= tree
->find_item("Bbb/child-03") ) != NULL
) {
102 if ( !but
) { // only do this once at program startup
104 but
= new Fl_Button(1,1,140,1,"ccc button"); // we control w() only
106 but
->callback(Button_CB
);
113 // Assign an FLTK group to one of the items with widgets
115 if ( ( i
= tree
->find_item("Bbb/child-04") ) != NULL
) {
116 static Fl_Group
*grp
= 0;
117 if ( !grp
) { // only do this once at program startup
119 grp
= new Fl_Group(100,100,140,18); // build group.. tree handles position
120 grp
->color(FL_WHITE
);
122 Fl_Button
*abut
= new Fl_Button(grp
->x()+0 ,grp
->y()+2,65,15,"D1");
124 abut
->callback(Button_CB
);
125 Fl_Button
*bbut
= new Fl_Button(grp
->x()+75,grp
->y()+2,65,15,"D2");
127 bbut
->callback(Button_CB
);
136 // Add an 'Ascending' node, and create it sorted
137 tree
->sortorder(FL_TREE_SORT_NONE
);
138 tree
->add("Ascending")->close();
139 tree
->sortorder(FL_TREE_SORT_ASCENDING
);
140 tree
->add("Ascending/Zzz");
141 tree
->add("Ascending/Xxx");
142 tree
->add("Ascending/Aaa");
143 tree
->add("Ascending/Bbb");
144 tree
->add("Ascending/Yyy");
145 tree
->add("Ascending/Ccc");
147 // Add a 'Descending' node, and create it sorted
148 tree
->sortorder(FL_TREE_SORT_NONE
);
149 tree
->add("Descending")->close();
150 tree
->sortorder(FL_TREE_SORT_DESCENDING
);
151 tree
->add("Descending/Zzz");
152 tree
->add("Descending/Xxx");
153 tree
->add("Descending/Aaa");
154 tree
->add("Descending/Bbb");
155 tree
->add("Descending/Yyy");
156 tree
->add("Descending/Ccc");
158 // Add 500 items in numerical order
159 tree
->sortorder(FL_TREE_SORT_NONE
);
160 for ( int t
=0; t
<500; t
++ ) {
162 sprintf(s
, "500 Items/item %04d", t
);
165 tree
->close("500 Items"); // close the 500 items by default
173 Prompt the user to change the specified color
175 Fl_Color
EditColor(Fl_Color val
) {
177 // Get the current color
178 Fl::get_color(val
,r
,g
,b
);
180 // Bring up a color chooser to edit it
181 fl_color_chooser("Choose Color",r
,g
,b
);
183 // Return the new color the user picked
184 return(fl_rgb_color(r
,g
,b
));
187 Fl_Double_Window
*window
=(Fl_Double_Window
*)0;
189 Fl_Tree
*tree
=(Fl_Tree
*)0;
191 static void cb_tree(Fl_Tree
*, void*) {
192 G_cb_counter
++; // Increment callback counter whenever tree callback is invoked
194 Fl_Tree_Item
*item
= tree
->callback_item();
196 fprintf(stderr
, "TREE CALLBACK: label='%s' userdata=%ld reason=%s\n",
198 (long)(fl_intptr_t
)tree
->user_data(),
199 reason_as_name(tree
->callback_reason()));
201 fprintf(stderr
, "TREE CALLBACK: reason=%s item=(no item -- probably multiple items were changed at once)\n",
202 reason_as_name(tree
->callback_reason()));
206 Fl_Value_Slider
*margintop_slider
=(Fl_Value_Slider
*)0;
208 static void cb_margintop_slider(Fl_Value_Slider
*, void*) {
209 int val
= (int)margintop_slider
->value();
210 tree
->margintop(val
);
214 Fl_Value_Slider
*marginleft_slider
=(Fl_Value_Slider
*)0;
216 static void cb_marginleft_slider(Fl_Value_Slider
*, void*) {
217 int val
= (int)marginleft_slider
->value();
218 tree
->marginleft(val
);
222 Fl_Value_Slider
*openchild_marginbottom_slider
=(Fl_Value_Slider
*)0;
224 static void cb_openchild_marginbottom_slider(Fl_Value_Slider
*, void*) {
225 int val
= (int)openchild_marginbottom_slider
->value();
226 tree
->openchild_marginbottom(val
);
230 Fl_Choice
*collapseicons_chooser
=(Fl_Choice
*)0;
232 static void cb_collapseicons_chooser(Fl_Choice
*, void*) {
233 static const char *L_open_xpm
[] = {
267 static Fl_Pixmap
L_openpixmap(L_open_xpm
);
269 static const char *L_close_xpm
[] = {
303 static Fl_Pixmap
L_closepixmap(L_close_xpm
);
305 switch ( collapseicons_chooser
->value() ) {
307 tree
->showcollapse(1);
312 tree
->showcollapse(1);
313 tree
->openicon(&L_openpixmap
);
314 tree
->closeicon(&L_closepixmap
);
317 tree
->showcollapse(0);
322 Fl_Menu_Item menu_collapseicons_chooser
[] = {
323 {"Normal", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
324 {"Custom", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
325 {"Off", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
329 Fl_Choice
*connectorstyle_chooser
=(Fl_Choice
*)0;
331 static void cb_connectorstyle_chooser(Fl_Choice
*, void*) {
332 // CHANGE COLLAPSESTYLE
333 switch ( connectorstyle_chooser
->value() ) {
334 case 0: tree
->connectorstyle(FL_TREE_CONNECTOR_NONE
); break;
335 case 1: tree
->connectorstyle(FL_TREE_CONNECTOR_DOTTED
); break;
336 case 2: tree
->connectorstyle(FL_TREE_CONNECTOR_SOLID
); break;
340 Fl_Menu_Item menu_connectorstyle_chooser
[] = {
341 {"None", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
342 {"Dotted", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
343 {"Solid", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
347 Fl_Choice
*selectmode_chooser
=(Fl_Choice
*)0;
349 static void cb_selectmode_chooser(Fl_Choice
*, void*) {
350 // Set selection mode
351 switch ( selectmode_chooser
->value() ) {
352 case 0: tree
->selectmode(FL_TREE_SELECT_NONE
); break; // None
353 case 1: tree
->selectmode(FL_TREE_SELECT_SINGLE
); break; // Single
354 case 2: tree
->selectmode(FL_TREE_SELECT_MULTI
); break; // Multi
355 default: tree
->selectmode(FL_TREE_SELECT_SINGLE
); break; // Single
359 Fl_Menu_Item menu_selectmode_chooser
[] = {
360 {"None", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
361 {"Single", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
362 {"Multi", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
366 Fl_Choice
*whenmode_chooser
=(Fl_Choice
*)0;
368 static void cb_whenmode_chooser(Fl_Choice
*, void*) {
370 switch ( whenmode_chooser
->value() ) {
371 case 0: tree
->when(FL_WHEN_RELEASE
); break;
372 case 1: tree
->when(FL_WHEN_CHANGED
); break;
373 case 2: tree
->when(FL_WHEN_NEVER
); break;
374 default: tree
->when(FL_WHEN_RELEASE
); break;
378 Fl_Menu_Item menu_whenmode_chooser
[] = {
379 {"Changed", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
380 {"Released", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
381 {"Never", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
385 Fl_Check_Button
*usericon_radio
=(Fl_Check_Button
*)0;
387 static void cb_usericon_radio(Fl_Check_Button
*, void*) {
391 Fl_Check_Button
*showroot_radio
=(Fl_Check_Button
*)0;
393 static void cb_showroot_radio(Fl_Check_Button
*, void*) {
394 int onoff
= showroot_radio
->value();
395 tree
->showroot(onoff
);
398 Fl_Check_Button
*visiblefocus_checkbox
=(Fl_Check_Button
*)0;
400 static void cb_visiblefocus_checkbox(Fl_Check_Button
*, void*) {
401 int onoff
= visiblefocus_checkbox
->value();
402 tree
->visible_focus(onoff
);
405 Fl_Button
*selection_color_button
=(Fl_Button
*)0;
407 static void cb_selection_color_button(Fl_Button
*, void*) {
408 Fl_Color val
= EditColor(tree
->selection_color()); // Get color of first item in tree
409 selection_color_button
->color(val
); // update modified color to button
410 tree
->selection_color(val
);
414 Fl_Box
*showitem_box
=(Fl_Box
*)0;
416 static void cb_Show(Fl_Button
*, void*) {
417 Fl_Tree_Item
*item
= tree
->next_selected_item();
418 tree
->show_item(item
);
421 static void cb_Top(Fl_Button
*, void*) {
422 Fl_Tree_Item
*item
= tree
->next_selected_item();
423 tree
->show_item_top(item
);
426 static void cb_Mid(Fl_Button
*, void*) {
427 Fl_Tree_Item
*item
= tree
->next_selected_item();
428 tree
->show_item_middle(item
);
431 static void cb_Bot(Fl_Button
*, void*) {
432 Fl_Tree_Item
*item
= tree
->next_selected_item();
433 tree
->show_item_bottom(item
);
436 Fl_Button
*loaddb_button
=(Fl_Button
*)0;
438 static void cb_loaddb_button(Fl_Button
*, void*) {
439 const char *filename
= fl_file_chooser("Select a Preferences style Database", "Preferences(*.prefs)", 0L);
442 Fl_Preferences
prefs(filename
, 0L, 0L);
448 Fl_Button
*insertabove_button
=(Fl_Button
*)0;
450 static void cb_insertabove_button(Fl_Button
*, void*) {
451 Fl_Tree_Item
*item
=tree
->first();
453 if ( item
->is_selected() ) {
454 tree
->insert_above(item
, "AaaAaa");
455 tree
->insert_above(item
, "BbbBbb");
456 tree
->insert_above(item
, "CccCcc");
464 Fl_Button
*rebuildtree_button
=(Fl_Button
*)0;
466 static void cb_rebuildtree_button(Fl_Button
*, void*) {
470 Fl_Button
*showpathname_button
=(Fl_Button
*)0;
472 static void cb_showpathname_button(Fl_Button
*, void*) {
473 Fl_Tree_Item
*item
= tree
->first_selected_item();
474 if ( !item
) { fl_message("No item was selected"); return; }
477 switch ( tree
->item_pathname(pathname
, sizeof(pathname
), item
) ) {
478 case 0: fl_message("Pathname for '%s' is: \"%s\"", (item
->label() ? item
->label() : "???"), pathname
); break;
479 case -1: fl_message("item_pathname() returned -1 (NOT FOUND)"); break;
480 case -2: fl_message("item_pathname() returned -2 (STRING TOO LONG)"); break;
484 Fl_Button
*clearall_button
=(Fl_Button
*)0;
486 static void cb_clearall_button(Fl_Button
*, void*) {
491 Fl_Button
*testcallbackflag_button
=(Fl_Button
*)0;
493 static void cb_testcallbackflag_button(Fl_Button
*, void*) {
494 Fl_Tree_Item
*root
= tree
->root();
495 fprintf(stderr
, "--- Checking docallback off\n");
500 // open/close: Make sure these methods don't trigger cb
501 G_cb_counter
= 0; tree
->close(root
, 0); if ( G_cb_counter
) fl_alert("FAILED 'OFF' TEST\n close(item) triggered cb!");
502 G_cb_counter
= 0; tree
->open(root
, 0); if ( G_cb_counter
) fl_alert("FAILED 'OFF' TEST\n open(item) triggered cb!");
503 G_cb_counter
= 0; tree
->open_toggle(root
, 0); if ( G_cb_counter
) fl_alert("FAILED 'OFF' TEST\n open_toggle(item) triggered cb!");
504 G_cb_counter
= 0; tree
->open("ROOT", 0); if ( G_cb_counter
) fl_alert("FAILED 'OFF' TEST\n open(path) triggered cb!");
505 G_cb_counter
= 0; tree
->close("ROOT", 0); if ( G_cb_counter
) fl_alert("FAILED 'OFF' TEST\n close(path) triggered cb!");
506 tree
->open(root
,0); // leave root open
508 // select/deselect: Make sure these methods don't trigger cb
509 G_cb_counter
= 0; tree
->select(root
, 0); if ( G_cb_counter
) fl_alert("FAILED 'OFF' TEST\n select(item) triggered cb!");
510 G_cb_counter
= 0; tree
->deselect(root
, 0); if ( G_cb_counter
) fl_alert("FAILED 'OFF' TEST\n deselect(item) triggered cb!");
511 G_cb_counter
= 0; tree
->select_toggle(root
, 0); if ( G_cb_counter
) fl_alert("FAILED 'OFF' TEST\n select_toggle(item) triggered cb!");
512 G_cb_counter
= 0; tree
->deselect("ROOT", 0); if ( G_cb_counter
) fl_alert("FAILED 'OFF' TEST\n deselect(path) triggered cb!");
513 G_cb_counter
= 0; tree
->select("ROOT", 0); if ( G_cb_counter
) fl_alert("FAILED 'OFF' TEST\n select(path) triggered cb!");
514 tree
->deselect("ROOT"); // leave deselected
518 // open/close: Make sure these methods don't trigger cb
519 G_cb_counter
= 0; tree
->close(root
, 1); if ( !G_cb_counter
) fl_alert("FAILED 'ON' TEST\n close(item) cb wasn't triggered!");
520 G_cb_counter
= 0; tree
->open(root
, 1); if ( !G_cb_counter
) fl_alert("FAILED 'ON' TEST\n open(item) cb wasn't triggered!");
521 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!");
522 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!");
523 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!");
524 G_cb_counter
= 0; tree
->open("ROOT", 1); if ( !G_cb_counter
) fl_alert("FAILED 'ON' TEST\n open(path) cb wasn't triggered!");
525 G_cb_counter
= 0; tree
->close("ROOT", 1); if ( !G_cb_counter
) fl_alert("FAILED 'ON' TEST\n close(path) cb wasn't triggered!");
526 tree
->open(root
,0); // leave root open
528 // select/deselect: Make sure these methods don't trigger cb
529 G_cb_counter
= 0; tree
->select(root
, 1); if ( !G_cb_counter
) fl_alert("FAILED 'ON' TEST\n select(item) cb wasn't triggered!");
530 G_cb_counter
= 0; tree
->deselect(root
, 1); if ( !G_cb_counter
) fl_alert("FAILED 'ON' TEST\n deselect(item) cb wasn't triggered!");
531 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!");
532 G_cb_counter
= 0; tree
->deselect("ROOT", 1); if ( !G_cb_counter
) fl_alert("FAILED 'ON' TEST\n deselect(path) cb wasn't triggered!");
533 G_cb_counter
= 0; tree
->select("ROOT", 1); if ( !G_cb_counter
) fl_alert("FAILED 'ON' TEST\n select(path) cb wasn't triggered!");
534 tree
->deselect("ROOT"); // leave deselected
536 //// "default" TEST (should be same as 'on'
538 // open/close: Make sure these methods don't trigger cb
539 G_cb_counter
= 0; tree
->close(root
); if ( !G_cb_counter
) fl_alert("FAILED 'DEFAULT' TEST: close(item) cb wasn't triggered!");
540 G_cb_counter
= 0; tree
->open(root
); if ( !G_cb_counter
) fl_alert("FAILED 'DEFAULT' TEST: open(item) cb wasn't triggered!");
541 G_cb_counter
= 0; tree
->open_toggle(root
); if ( !G_cb_counter
) fl_alert("FAILED 'DEFAULT' TEST: open_toggle(item) cb wasn't triggered!");
542 G_cb_counter
= 0; tree
->open("ROOT"); if ( !G_cb_counter
) fl_alert("FAILED 'DEFAULT' TEST: open(path) cb wasn't triggered!");
543 G_cb_counter
= 0; tree
->close("ROOT"); if ( !G_cb_counter
) fl_alert("FAILED 'DEFAULT' TEST: close(path) cb wasn't triggered!");
544 tree
->open(root
,0); // leave root open
546 // select/deselect: Make sure these methods don't trigger cb
547 G_cb_counter
= 0; tree
->select(root
); if ( !G_cb_counter
) fl_alert("FAILED 'DEFAULT' TEST\n select(item) cb wasn't triggered!");
548 G_cb_counter
= 0; tree
->deselect(root
); if ( !G_cb_counter
) fl_alert("FAILED 'DEFAULT' TEST\n deselect(item) cb wasn't triggered!");
549 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!");
550 G_cb_counter
= 0; tree
->deselect("ROOT"); if ( !G_cb_counter
) fl_alert("FAILED 'DEFAULT' TEST\n deselect(path) cb wasn't triggered!");
551 G_cb_counter
= 0; tree
->select("ROOT"); if ( !G_cb_counter
) fl_alert("FAILED 'DEFAULT' TEST\n select(path) cb wasn't triggered!");
552 tree
->deselect("ROOT"); // leave deselected
554 fl_alert("TEST COMPLETED\n If you didn't see any error dialogs, test PASSED.");
557 Fl_Choice
*all_font_choice
=(Fl_Choice
*)0;
559 static void cb_all_font_choice(Fl_Choice
*, void*) {
560 // Find first item in tree
561 Fl_Tree_Item
*item
= tree
->first();
564 // Get first item's font.
565 Fl_Font val
= (Fl_Font
)all_font_choice
->value(); // Get font value
569 for ( item
=tree
->first(); item
; item
= tree
->next(item
) ) {
570 if ( item
->is_selected() ) {
571 item
->labelfont(val
);
576 // No items selected? Do all..
578 for ( item
=tree
->first(); item
; item
= tree
->next(item
) ) {
579 item
->labelfont(val
);
586 Fl_Menu_Item menu_all_font_choice
[] = {
587 {"Helvetica", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
588 {"Helvetica Bold", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
589 {"Helvetica Italic", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
590 {"Helvetica Bold Italic", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
591 {"Courier", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
592 {"Courier Bold", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
593 {"Courier Italic", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
594 {"Courier Bold Italic", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
595 {"Times", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
596 {"Times Bold", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
597 {"Times Italic", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
598 {"Times Bold Italic", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
599 {"Symbol", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
600 {"Screen", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
601 {"Screen bold", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
602 {"Zapf Dingbats", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
606 Fl_Value_Slider
*labelsize_slider
=(Fl_Value_Slider
*)0;
608 static void cb_labelsize_slider(Fl_Value_Slider
*, void*) {
609 int size
= (int)labelsize_slider
->value();
614 for ( item
=tree
->first(); item
; item
= tree
->next(item
) ) {
615 if ( item
->is_selected() ) {
616 item
->labelsize(size
);
621 // NO ITEMS SELECTED? DO ALL
623 for ( item
=tree
->first(); item
; item
= tree
->next(item
) ) {
624 item
->labelsize(size
);
631 Fl_Button
*all_labelfgcolor_button
=(Fl_Button
*)0;
633 static void cb_all_labelfgcolor_button(Fl_Button
*, void*) {
634 // Find first item in tree
635 Fl_Tree_Item
*item
= tree
->first();
638 // Get first item's color
639 Fl_Color val
= EditColor(item
->labelfgcolor()); // Get color of first item in tree
640 all_labelfgcolor_button
->color(val
); // update modified color to button
644 for ( item
=tree
->first(); item
; item
= tree
->next(item
) ) {
645 if ( item
->is_selected() ) {
646 item
->labelfgcolor(val
);
651 // No items selected? Do all..
653 for ( item
=tree
->first(); item
; item
= tree
->next(item
) ) {
654 item
->labelfgcolor(val
);
661 Fl_Button
*all_labelbgcolor_button
=(Fl_Button
*)0;
663 static void cb_all_labelbgcolor_button(Fl_Button
*, void*) {
664 // Find first item in tree
665 Fl_Tree_Item
*item
= tree
->first();
668 // Get first item's color
669 Fl_Color val
= EditColor(item
->labelbgcolor()); // Get color of first item in tree
670 all_labelbgcolor_button
->color(val
); // update modified color to button
674 for ( item
=tree
->first(); item
; item
= tree
->next(item
) ) {
675 if ( item
->is_selected() ) {
676 item
->labelbgcolor(val
);
681 // No items selected? Do all..
683 for ( item
=tree
->first(); item
; item
= tree
->next(item
) ) {
684 item
->labelbgcolor(val
);
691 Fl_Value_Slider
*connectorwidth_slider
=(Fl_Value_Slider
*)0;
693 static void cb_connectorwidth_slider(Fl_Value_Slider
*, void*) {
694 tree
->connectorwidth((int)connectorwidth_slider
->value());
697 Fl_Light_Button
*deactivate_toggle
=(Fl_Light_Button
*)0;
699 static void cb_deactivate_toggle(Fl_Light_Button
*, void*) {
700 int onoff
= deactivate_toggle
->value() ? 0 : 1;
704 for ( item
=tree
->first(); item
; item
= tree
->next(item
) ) {
705 if ( item
->is_selected() ) {
706 item
->activate(onoff
);
712 for ( item
=tree
->first(); item
; item
= tree
->next(item
) ) {
713 item
->activate(onoff
);
720 Fl_Light_Button
*bold_toggle
=(Fl_Light_Button
*)0;
722 static void cb_bold_toggle(Fl_Light_Button
*, void*) {
723 int face
= bold_toggle
->value() ? FL_HELVETICA_BOLD
: FL_HELVETICA
;
728 for ( item
=tree
->first(); item
; item
= tree
->next(item
) ) {
729 if ( item
->is_selected() ) {
730 item
->labelfont(face
);
735 // NO ITEMS SELECTED? DO ALL
737 for ( item
=tree
->first(); item
; item
= tree
->next(item
) ) {
738 item
->labelfont(face
);
745 Fl_Button
*showselected_button
=(Fl_Button
*)0;
747 static void cb_showselected_button(Fl_Button
*, void*) {
748 fprintf(stderr
, "--- SELECTED ITEMS\n");
749 for ( Fl_Tree_Item
*item
= tree
->first_selected_item();
751 item
= tree
->next_selected_item(item
) ) {
752 fprintf(stderr
, "\t%s\n", item
->label() ? item
->label() : "???");
756 Fl_Button
*clearselected_button
=(Fl_Button
*)0;
758 static void cb_clearselected_button(Fl_Button
*, void*) {
759 Fl_Tree_Item
*item
=tree
->first();
761 if ( item
->is_selected() ) {
762 if ( tree
->remove(item
) == -1 ) break;
763 item
= tree
->first();
772 Fl_Button
*selectall_button
=(Fl_Button
*)0;
774 static void cb_selectall_button(Fl_Button
*, void*) {
779 Fl_Button
*deselectall_button
=(Fl_Button
*)0;
781 static void cb_deselectall_button(Fl_Button
*, void*) {
782 tree
->deselect_all(0);
786 Fl_Light_Button
*bbbselect_toggle
=(Fl_Light_Button
*)0;
788 static void cb_bbbselect_toggle(Fl_Light_Button
*, void*) {
789 // Toggle select of just the Bbb item (not children)
790 Fl_Tree_Item
*bbb
= tree
->find_item("/Bbb");
792 fl_alert("FAIL: Couldn't find item '/Bbb'???");
795 int onoff
= bbbselect_toggle
->value();
796 if ( onoff
) tree
->select(bbb
); // select /Bbb
797 else tree
->deselect(bbb
); // deselect /Bbb;
800 Fl_Light_Button
*bbbselect2_toggle
=(Fl_Light_Button
*)0;
802 static void cb_bbbselect2_toggle(Fl_Light_Button
*, void*) {
803 // Toggle select of just the Bbb item and its immediate children
804 Fl_Tree_Item
*bbb
= tree
->find_item("/Bbb");
806 fl_alert("FAIL: Couldn't find item '/Bbb'???");
809 int onoff
= bbbselect2_toggle
->value();
810 if ( onoff
) tree
->select_all(bbb
); // select /Bbb and its children
811 else tree
->deselect_all(bbb
); // deselect /Bbb and its children;
814 Fl_Light_Button
*bbbchild02select_toggle
=(Fl_Light_Button
*)0;
816 static void cb_bbbchild02select_toggle(Fl_Light_Button
*, void*) {
817 // Toggle select of just the /Bbb/child-02 item
818 const char *pathname
= "/Bbb/child-02";
819 int onoff
= bbbchild02select_toggle
->value();
821 if ( onoff
) err
= tree
->select(pathname
);
822 else err
= tree
->deselect(pathname
);
825 fl_alert("FAIL: Couldn't find item '%s'",pathname
);
830 Fl_Light_Button
*rootselect_toggle
=(Fl_Light_Button
*)0;
832 static void cb_rootselect_toggle(Fl_Light_Button
*, void*) {
833 // Toggle select of ROOT item and its children
834 Fl_Tree_Item
*item
= tree
->find_item("/ROOT");
836 fl_alert("FAIL: Couldn't find item '/ROOT'???");
839 int onoff
= rootselect_toggle
->value();
840 if ( onoff
) tree
->select(item
); // select /ROOT and its children
841 else tree
->deselect(item
); // deselect /ROOT and its children;
844 Fl_Light_Button
*rootselect2_toggle
=(Fl_Light_Button
*)0;
846 static void cb_rootselect2_toggle(Fl_Light_Button
*, void*) {
847 // Toggle select of ROOT item and its children
848 Fl_Tree_Item
*item
= tree
->find_item("/ROOT");
850 fl_alert("FAIL: Couldn't find item '/ROOT'???");
853 int onoff
= rootselect2_toggle
->value();
854 if ( onoff
) tree
->select_all(item
); // select /ROOT and its children
855 else tree
->deselect_all(item
); // deselect /ROOT and its children;
858 Fl_Button
*item_labelfgcolor_button
=(Fl_Button
*)0;
860 static void cb_item_labelfgcolor_button(Fl_Button
*, void*) {
861 Fl_Color val
= EditColor(tree
->item_labelfgcolor()); // Let user edit the color
862 tree
->item_labelfgcolor(val
); // apply modified color to tree
863 item_labelfgcolor_button
->color(val
); // update modified color to button;
866 Fl_Button
*item_labelbgcolor_button
=(Fl_Button
*)0;
868 static void cb_item_labelbgcolor_button(Fl_Button
*, void*) {
869 Fl_Color val
= EditColor(tree
->item_labelbgcolor()); // Let user edit the color
870 tree
->item_labelbgcolor(val
); // apply modified color to tree
871 item_labelbgcolor_button
->color(val
); // update modified color to button;
874 Fl_Choice
*item_font_choice
=(Fl_Choice
*)0;
876 static void cb_item_font_choice(Fl_Choice
*, void*) {
877 Fl_Font val
= (Fl_Font
)item_font_choice
->value(); // get chooser's current font value
878 tree
->item_labelfont(val
); // change font in tree;
881 Fl_Menu_Item menu_item_font_choice
[] = {
882 {"Helvetica", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
883 {"Helvetica Bold", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
884 {"Helvetica Italic", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
885 {"Helvetica Bold Italic", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
886 {"Courier", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
887 {"Courier Bold", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
888 {"Courier Italic", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
889 {"Courier Bold Italic", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
890 {"Times", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
891 {"Times Bold", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
892 {"Times Italic", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
893 {"Times Bold Italic", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
894 {"Symbol", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
895 {"Screen", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
896 {"Screen bold", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
897 {"Zapf Dingbats", 0, 0, 0, 0, FL_NORMAL_LABEL
, 0, 12, 0},
901 Fl_Value_Slider
*item_labelsize_slider
=(Fl_Value_Slider
*)0;
903 static void cb_item_labelsize_slider(Fl_Value_Slider
*, void*) {
904 tree
->item_labelsize((int)item_labelsize_slider
->value());
907 Fl_Box
*resizer_box
=(Fl_Box
*)0;
909 int main(int argc
, char **argv
) {
910 { window
= new Fl_Double_Window(1015, 445, "tree");
911 { tree
= new Fl_Tree(15, 22, 280, 411, "Tree");
912 tree
->tooltip("Test tree");
913 tree
->box(FL_DOWN_BOX
);
914 tree
->color((Fl_Color
)55);
915 tree
->selection_color(FL_SELECTION_COLOR
);
916 tree
->labeltype(FL_NORMAL_LABEL
);
919 tree
->labelcolor(FL_FOREGROUND_COLOR
);
920 tree
->callback((Fl_Callback
*)cb_tree
, (void*)(1234));
921 tree
->align(Fl_Align(FL_ALIGN_TOP
));
922 tree
->when(FL_WHEN_RELEASE
);
925 { Fl_Group
* o
= new Fl_Group(300, 5, 705, 427);
926 { Fl_Box
* o
= new Fl_Box(311, 23, 335, 263, "Tree Globals");
927 o
->tooltip("These controls only affect the selected items. If no items are selected, all \
928 existing items in tree are modified.");
932 o
->align(Fl_Align(FL_ALIGN_TOP
));
934 { Fl_Value_Slider
* o
= margintop_slider
= new Fl_Value_Slider(486, 31, 140, 16, "margintop()");
935 margintop_slider
->tooltip("Changes the top margin for the tree widget");
936 margintop_slider
->type(1);
937 margintop_slider
->labelsize(12);
938 margintop_slider
->textsize(12);
939 margintop_slider
->callback((Fl_Callback
*)cb_margintop_slider
, (void*)(tree
));
940 margintop_slider
->align(Fl_Align(FL_ALIGN_LEFT
));
941 o
->value(tree
->margintop());
942 o
->range(0.0, 100.0);
944 o
->color(46); o
->selection_color(FL_RED
);
945 } // Fl_Value_Slider* margintop_slider
946 { Fl_Value_Slider
* o
= marginleft_slider
= new Fl_Value_Slider(486, 51, 140, 16, "marginleft()");
947 marginleft_slider
->tooltip("Changes the left margin for the tree widget");
948 marginleft_slider
->type(1);
949 marginleft_slider
->labelsize(12);
950 marginleft_slider
->textsize(12);
951 marginleft_slider
->callback((Fl_Callback
*)cb_marginleft_slider
, (void*)(tree
));
952 marginleft_slider
->align(Fl_Align(FL_ALIGN_LEFT
));
953 o
->value(tree
->marginleft());
954 o
->range(0.0, 100.0);
956 o
->color(46); o
->selection_color(FL_RED
);
957 } // Fl_Value_Slider* marginleft_slider
958 { Fl_Value_Slider
* o
= openchild_marginbottom_slider
= new Fl_Value_Slider(486, 71, 140, 16, "openchild_marginbottom()");
959 openchild_marginbottom_slider
->tooltip("Changes the vertical space below an open child tree");
960 openchild_marginbottom_slider
->type(1);
961 openchild_marginbottom_slider
->labelsize(12);
962 openchild_marginbottom_slider
->textsize(12);
963 openchild_marginbottom_slider
->callback((Fl_Callback
*)cb_openchild_marginbottom_slider
, (void*)(tree
));
964 openchild_marginbottom_slider
->align(Fl_Align(FL_ALIGN_LEFT
));
965 o
->value(tree
->openchild_marginbottom());
966 o
->range(0.0, 100.0);
968 o
->color(46); o
->selection_color(FL_RED
);
969 } // Fl_Value_Slider* openchild_marginbottom_slider
970 { collapseicons_chooser
= new Fl_Choice(486, 96, 140, 21, "Collapse icons");
971 collapseicons_chooser
->tooltip("Tests Fl_Tree::openicon() and Fl_Tree::closeicon()");
972 collapseicons_chooser
->down_box(FL_BORDER_BOX
);
973 collapseicons_chooser
->labelsize(12);
974 collapseicons_chooser
->textsize(11);
975 collapseicons_chooser
->callback((Fl_Callback
*)cb_collapseicons_chooser
);
976 collapseicons_chooser
->menu(menu_collapseicons_chooser
);
977 } // Fl_Choice* collapseicons_chooser
978 { connectorstyle_chooser
= new Fl_Choice(486, 120, 140, 21, "Line style");
979 connectorstyle_chooser
->tooltip("Tests connectorstyle() bit flags");
980 connectorstyle_chooser
->down_box(FL_BORDER_BOX
);
981 connectorstyle_chooser
->labelsize(12);
982 connectorstyle_chooser
->textsize(11);
983 connectorstyle_chooser
->callback((Fl_Callback
*)cb_connectorstyle_chooser
);
984 connectorstyle_chooser
->menu(menu_connectorstyle_chooser
);
985 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; }
986 } // Fl_Choice* connectorstyle_chooser
987 { selectmode_chooser
= new Fl_Choice(486, 144, 140, 21, "Selection Mode");
988 selectmode_chooser
->tooltip("Sets how Fl_Tree handles mouse selection of tree items");
989 selectmode_chooser
->down_box(FL_BORDER_BOX
);
990 selectmode_chooser
->labelsize(12);
991 selectmode_chooser
->textsize(11);
992 selectmode_chooser
->callback((Fl_Callback
*)cb_selectmode_chooser
);
993 selectmode_chooser
->menu(menu_selectmode_chooser
);
994 selectmode_chooser
->value(1);
995 cb_selectmode_chooser(selectmode_chooser
, (void*)0);
996 } // Fl_Choice* selectmode_chooser
997 { whenmode_chooser
= new Fl_Choice(486, 168, 140, 21, "When");
998 whenmode_chooser
->tooltip("Sets when() the tree\'s callback is invoked");
999 whenmode_chooser
->down_box(FL_BORDER_BOX
);
1000 whenmode_chooser
->labelsize(12);
1001 whenmode_chooser
->textsize(11);
1002 whenmode_chooser
->callback((Fl_Callback
*)cb_whenmode_chooser
);
1003 whenmode_chooser
->menu(menu_whenmode_chooser
);
1004 whenmode_chooser
->value(1);
1005 cb_whenmode_chooser(whenmode_chooser
, (void*)0);
1006 } // Fl_Choice* whenmode_chooser
1007 { usericon_radio
= new Fl_Check_Button(486, 194, 20, 16, "Enable user icons?");
1008 usericon_radio
->tooltip("Tests Fl_Tree_Item::usericon()");
1009 usericon_radio
->down_box(FL_DOWN_BOX
);
1010 usericon_radio
->labelsize(12);
1011 usericon_radio
->callback((Fl_Callback
*)cb_usericon_radio
, (void*)(tree
));
1012 usericon_radio
->align(Fl_Align(FL_ALIGN_LEFT_TOP
));
1013 usericon_radio
->value(1);
1014 } // Fl_Check_Button* usericon_radio
1015 { showroot_radio
= new Fl_Check_Button(486, 211, 20, 16, "Show root?");
1016 showroot_radio
->tooltip("Tests tree->showroot();");
1017 showroot_radio
->down_box(FL_DOWN_BOX
);
1018 showroot_radio
->labelsize(12);
1019 showroot_radio
->callback((Fl_Callback
*)cb_showroot_radio
, (void*)(tree
));
1020 showroot_radio
->align(Fl_Align(FL_ALIGN_LEFT_TOP
));
1021 int onoff
= tree
->showroot(); showroot_radio
->value(onoff
);
1022 } // Fl_Check_Button* showroot_radio
1023 { visiblefocus_checkbox
= new Fl_Check_Button(486, 228, 20, 16, "Visible focus?");
1024 visiblefocus_checkbox
->tooltip("Toggles the tree\'s visible_focus() box");
1025 visiblefocus_checkbox
->down_box(FL_DOWN_BOX
);
1026 visiblefocus_checkbox
->labelsize(12);
1027 visiblefocus_checkbox
->callback((Fl_Callback
*)cb_visiblefocus_checkbox
, (void*)(tree
));
1028 visiblefocus_checkbox
->align(Fl_Align(FL_ALIGN_LEFT_TOP
));
1029 int onoff
= tree
->visible_focus(); visiblefocus_checkbox
->value(onoff
);
1030 } // Fl_Check_Button* visiblefocus_checkbox
1031 { Fl_Button
* o
= selection_color_button
= new Fl_Button(486, 251, 16, 16, "Selection Color");
1032 selection_color_button
->tooltip("Changes the tree widget\'s selection color. Tests Fl_Tree::selection_color()");
1033 selection_color_button
->box(FL_DOWN_BOX
);
1034 selection_color_button
->labelsize(12);
1035 selection_color_button
->callback((Fl_Callback
*)cb_selection_color_button
);
1036 selection_color_button
->align(Fl_Align(FL_ALIGN_LEFT_TOP
));
1037 o
->color(tree
->selection_color());
1038 } // Fl_Button* selection_color_button
1039 { Fl_Box
* o
= new Fl_Box(311, 312, 335, 120, "Test Operations");
1040 o
->tooltip("These controls only affect the defaults for new items that are created. These\
1041 test the Fl_Tree_Prefs methods.");
1042 o
->box(FL_DOWN_BOX
);
1045 o
->align(Fl_Align(FL_ALIGN_TOP
));
1047 { showitem_box
= new Fl_Box(331, 335, 70, 82, "show_item()\n");
1048 showitem_box
->box(FL_DOWN_BOX
);
1049 showitem_box
->labelsize(11);
1050 showitem_box
->align(Fl_Align(FL_ALIGN_TOP
));
1051 } // Fl_Box* showitem_box
1052 { Fl_Button
* o
= new Fl_Button(346, 344, 40, 17, "Show");
1053 o
->tooltip("Tests show_item() with no position specified.\nMakes the selected item visibl\
1054 e IF it is off-screen.\nNo change made if it is not off-screen.");
1056 o
->callback((Fl_Callback
*)cb_Show
);
1058 { Fl_Button
* o
= new Fl_Button(346, 361, 40, 16, "Top");
1059 o
->tooltip("Test show_item_top().\nScrolls selected item to the top of the display\n(only\
1060 works if scrollbar showing)\nTo use:\n1) open \'500 items\'\n2) select item 0\
1061 010\n3) Hit Top/Mid/Bot");
1063 o
->callback((Fl_Callback
*)cb_Top
);
1065 { Fl_Button
* o
= new Fl_Button(346, 377, 40, 16, "Mid");
1066 o
->tooltip("Tests show_item_middle().\nScrolls the selected item to the middle of the dis\
1067 play\nTo use:\n 1) open \'500 items\'\n 2) select \'item 0010\'\n 3) Hit To\
1070 o
->callback((Fl_Callback
*)cb_Mid
);
1072 { Fl_Button
* o
= new Fl_Button(346, 393, 40, 16, "Bot");
1073 o
->tooltip("Tests show_item_bottom().\nScrolls the selected item to the bottom of the dis\
1074 play\nTo use:\n 1) open \'500 items\'\n 2) select \'item 0010\'\n 3) Hit To\
1077 o
->callback((Fl_Callback
*)cb_Bot
);
1079 { loaddb_button
= new Fl_Button(431, 338, 95, 16, "Load Database...");
1080 loaddb_button
->tooltip("Load the contents of an Fl_Preferences database into the tree view");
1081 loaddb_button
->labelsize(9);
1082 loaddb_button
->callback((Fl_Callback
*)cb_loaddb_button
);
1083 } // Fl_Button* loaddb_button
1084 { insertabove_button
= new Fl_Button(431, 358, 95, 16, "Insert Above");
1085 insertabove_button
->tooltip("Inserts three items above the selected items");
1086 insertabove_button
->labelsize(9);
1087 insertabove_button
->callback((Fl_Callback
*)cb_insertabove_button
);
1088 } // Fl_Button* insertabove_button
1089 { rebuildtree_button
= new Fl_Button(431, 378, 95, 16, "Rebuild Tree");
1090 rebuildtree_button
->tooltip("Rebuilds the tree with defaults");
1091 rebuildtree_button
->labelsize(9);
1092 rebuildtree_button
->callback((Fl_Callback
*)cb_rebuildtree_button
);
1093 } // Fl_Button* rebuildtree_button
1094 { showpathname_button
= new Fl_Button(431, 398, 95, 16, "Show Pathname");
1095 showpathname_button
->tooltip("Show the pathname for the selected item. Tests the Fl_Tree::item_pathname() m\
1097 showpathname_button
->labelsize(9);
1098 showpathname_button
->callback((Fl_Callback
*)cb_showpathname_button
);
1099 } // Fl_Button* showpathname_button
1100 { clearall_button
= new Fl_Button(531, 338, 95, 16, "Clear All");
1101 clearall_button
->tooltip("Clears all items\nTests Fl_Tree::clear()");
1102 clearall_button
->labelsize(9);
1103 clearall_button
->callback((Fl_Callback
*)cb_clearall_button
);
1104 } // Fl_Button* clearall_button
1105 { testcallbackflag_button
= new Fl_Button(531, 358, 95, 16, "Test Callback Flag");
1106 testcallbackflag_button
->tooltip("Test the \'docallback\' argument can disable callbacks.");
1107 testcallbackflag_button
->labelsize(9);
1108 testcallbackflag_button
->callback((Fl_Callback
*)cb_testcallbackflag_button
);
1109 } // Fl_Button* testcallbackflag_button
1110 { Fl_Box
* o
= new Fl_Box(661, 23, 335, 263, "Selected Items");
1111 o
->tooltip("These controls only affect the selected items. If no items are selected, all \
1112 existing items in tree are modified.");
1113 o
->box(FL_DOWN_BOX
);
1116 o
->align(Fl_Align(FL_ALIGN_TOP
));
1118 { Fl_Choice
* o
= all_font_choice
= new Fl_Choice(828, 31, 140, 21, "Label Font");
1119 all_font_choice
->tooltip("Changes the font for the selected items\'s labels. If none selected, all are \
1120 changed. Tests Fl_Tree_Item::labelfont();");
1121 all_font_choice
->down_box(FL_BORDER_BOX
);
1122 all_font_choice
->labelsize(12);
1123 all_font_choice
->textsize(11);
1124 all_font_choice
->callback((Fl_Callback
*)cb_all_font_choice
);
1125 all_font_choice
->menu(menu_all_font_choice
);
1126 o
->value((int)tree
->item_labelfont()); // get tree's current font, assign to chooser
1127 } // Fl_Choice* all_font_choice
1128 { Fl_Value_Slider
* o
= labelsize_slider
= new Fl_Value_Slider(828, 55, 140, 16, "Label Size");
1129 labelsize_slider
->tooltip("Changes the font size of the selected items\'s labels. If none selected, all \
1130 are changed. Tests Fl_Tree_Item::labelsize();");
1131 labelsize_slider
->type(1);
1132 labelsize_slider
->labelsize(12);
1133 labelsize_slider
->textsize(12);
1134 labelsize_slider
->callback((Fl_Callback
*)cb_labelsize_slider
, (void*)(tree
));
1135 labelsize_slider
->align(Fl_Align(FL_ALIGN_LEFT
));
1136 o
->value(tree
->item_labelsize());
1137 o
->range(5.0, 200.0);
1139 o
->color(46); o
->selection_color(FL_RED
);
1140 } // Fl_Value_Slider* labelsize_slider
1141 { Fl_Button
* o
= all_labelfgcolor_button
= new Fl_Button(828, 81, 16, 16, "Label FG Color");
1142 all_labelfgcolor_button
->tooltip("Changes the label fg color for the selected items. If none selected, all are \
1143 changed. Tests Fl_Tree_Item::labelfgcolor();");
1144 all_labelfgcolor_button
->box(FL_DOWN_BOX
);
1145 all_labelfgcolor_button
->labelsize(12);
1146 all_labelfgcolor_button
->callback((Fl_Callback
*)cb_all_labelfgcolor_button
);
1147 all_labelfgcolor_button
->align(Fl_Align(FL_ALIGN_LEFT_TOP
));
1148 o
->color(tree
->item_labelfgcolor());
1149 } // Fl_Button* all_labelfgcolor_button
1150 { Fl_Button
* o
= all_labelbgcolor_button
= new Fl_Button(828, 99, 16, 16, "Label BG Color");
1151 all_labelbgcolor_button
->tooltip("Changes the label bg color for the selected items. If none selected, all are \
1152 changed. Tests Fl_Tree_Item::labelbgcolor();");
1153 all_labelbgcolor_button
->box(FL_DOWN_BOX
);
1154 all_labelbgcolor_button
->labelsize(12);
1155 all_labelbgcolor_button
->callback((Fl_Callback
*)cb_all_labelbgcolor_button
);
1156 all_labelbgcolor_button
->align(Fl_Align(FL_ALIGN_LEFT_TOP
));
1157 o
->color(tree
->item_labelbgcolor());
1158 } // Fl_Button* all_labelbgcolor_button
1159 { Fl_Value_Slider
* o
= connectorwidth_slider
= new Fl_Value_Slider(828, 126, 140, 16, "Connector Width");
1160 connectorwidth_slider
->tooltip("Tests Fl_Tree::connectorwidth()");
1161 connectorwidth_slider
->type(1);
1162 connectorwidth_slider
->labelsize(12);
1163 connectorwidth_slider
->textsize(12);
1164 connectorwidth_slider
->callback((Fl_Callback
*)cb_connectorwidth_slider
, (void*)(tree
));
1165 connectorwidth_slider
->align(Fl_Align(FL_ALIGN_LEFT
));
1166 o
->value(tree
->connectorwidth());
1167 o
->range(1.0, 100.0);
1169 o
->color(46); o
->selection_color(FL_RED
);
1170 } // Fl_Value_Slider* connectorwidth_slider
1171 { deactivate_toggle
= new Fl_Light_Button(734, 154, 95, 16, " Deactivate");
1172 deactivate_toggle
->tooltip("Toggle the deactivation state of the selected items.\nIf none are selected, a\
1174 deactivate_toggle
->selection_color((Fl_Color
)1);
1175 deactivate_toggle
->labelsize(9);
1176 deactivate_toggle
->callback((Fl_Callback
*)cb_deactivate_toggle
);
1177 } // Fl_Light_Button* deactivate_toggle
1178 { bold_toggle
= new Fl_Light_Button(734, 174, 95, 16, " Bold Font");
1179 bold_toggle
->tooltip("Toggles bold font for selected items\nIf nothing selected, all are changed");
1180 bold_toggle
->selection_color((Fl_Color
)1);
1181 bold_toggle
->labelsize(9);
1182 bold_toggle
->callback((Fl_Callback
*)cb_bold_toggle
);
1183 } // Fl_Light_Button* bold_toggle
1184 { showselected_button
= new Fl_Button(829, 154, 95, 16, "Show Selected");
1185 showselected_button
->tooltip("Clears the selected items");
1186 showselected_button
->labelsize(9);
1187 showselected_button
->callback((Fl_Callback
*)cb_showselected_button
);
1188 } // Fl_Button* showselected_button
1189 { clearselected_button
= new Fl_Button(829, 174, 95, 16, "Remove Selected");
1190 clearselected_button
->tooltip("Removes the selected items");
1191 clearselected_button
->labelsize(9);
1192 clearselected_button
->callback((Fl_Callback
*)cb_clearselected_button
);
1193 } // Fl_Button* clearselected_button
1194 { selectall_button
= new Fl_Button(689, 201, 95, 16, "Select All");
1195 selectall_button
->tooltip("Selects all items in the tree");
1196 selectall_button
->labelsize(9);
1197 selectall_button
->callback((Fl_Callback
*)cb_selectall_button
);
1198 } // Fl_Button* selectall_button
1199 { deselectall_button
= new Fl_Button(689, 221, 95, 16, "Deselect All");
1200 deselectall_button
->tooltip("Deselects all items in the tree");
1201 deselectall_button
->labelsize(9);
1202 deselectall_button
->callback((Fl_Callback
*)cb_deselectall_button
);
1203 } // Fl_Button* deselectall_button
1204 { bbbselect_toggle
= new Fl_Light_Button(784, 201, 95, 16, " Select Bbb");
1205 bbbselect_toggle
->tooltip("Toggle selection of just the /Bbb item\n(Not children)");
1206 bbbselect_toggle
->selection_color((Fl_Color
)1);
1207 bbbselect_toggle
->labelsize(9);
1208 bbbselect_toggle
->callback((Fl_Callback
*)cb_bbbselect_toggle
);
1209 } // Fl_Light_Button* bbbselect_toggle
1210 { bbbselect2_toggle
= new Fl_Light_Button(784, 221, 95, 16, " Select Bbb+");
1211 bbbselect2_toggle
->tooltip("Toggle selection of the /Bbb item and its children");
1212 bbbselect2_toggle
->selection_color((Fl_Color
)1);
1213 bbbselect2_toggle
->labelsize(9);
1214 bbbselect2_toggle
->callback((Fl_Callback
*)cb_bbbselect2_toggle
);
1215 } // Fl_Light_Button* bbbselect2_toggle
1216 { bbbchild02select_toggle
= new Fl_Light_Button(784, 241, 95, 16, " Toggle child-02");
1217 bbbchild02select_toggle
->tooltip("Toggle the single item \"/Bbb/child-02\" using the item\'s \"pathname\".");
1218 bbbchild02select_toggle
->selection_color((Fl_Color
)1);
1219 bbbchild02select_toggle
->labelsize(9);
1220 bbbchild02select_toggle
->callback((Fl_Callback
*)cb_bbbchild02select_toggle
);
1221 } // Fl_Light_Button* bbbchild02select_toggle
1222 { rootselect_toggle
= new Fl_Light_Button(879, 201, 95, 16, "Select ROOT");
1223 rootselect_toggle
->tooltip("Toggle selection of the ROOT item");
1224 rootselect_toggle
->selection_color((Fl_Color
)1);
1225 rootselect_toggle
->labelsize(9);
1226 rootselect_toggle
->callback((Fl_Callback
*)cb_rootselect_toggle
);
1227 } // Fl_Light_Button* rootselect_toggle
1228 { rootselect2_toggle
= new Fl_Light_Button(879, 221, 95, 16, "Select ROOT+");
1229 rootselect2_toggle
->tooltip("Toggle selection of the ROOT item and all children");
1230 rootselect2_toggle
->selection_color((Fl_Color
)1);
1231 rootselect2_toggle
->labelsize(9);
1232 rootselect2_toggle
->callback((Fl_Callback
*)cb_rootselect2_toggle
);
1233 } // Fl_Light_Button* rootselect2_toggle
1234 { Fl_Box
* o
= new Fl_Box(661, 312, 335, 120, "New Item Defaults");
1235 o
->tooltip("These controls only affect the defaults for new items that are created. These\
1236 test the Fl_Tree_Prefs methods.");
1237 o
->box(FL_DOWN_BOX
);
1240 o
->align(Fl_Align(FL_ALIGN_TOP
));
1242 { Fl_Button
* o
= item_labelfgcolor_button
= new Fl_Button(828, 327, 16, 16, "item_labelfgcolor");
1243 item_labelfgcolor_button
->tooltip("Sets the *default* label foreground color for new items created. Does NOT aff\
1244 ect existing items.");
1245 item_labelfgcolor_button
->box(FL_DOWN_BOX
);
1246 item_labelfgcolor_button
->labelsize(12);
1247 item_labelfgcolor_button
->callback((Fl_Callback
*)cb_item_labelfgcolor_button
);
1248 item_labelfgcolor_button
->align(Fl_Align(FL_ALIGN_LEFT_TOP
));
1249 o
->color(tree
->item_labelfgcolor());
1250 } // Fl_Button* item_labelfgcolor_button
1251 { item_labelbgcolor_button
= new Fl_Button(828, 345, 16, 16, "item_labelbgcolor");
1252 item_labelbgcolor_button
->tooltip("Sets the *default* label background color for new items created. Does NOT aff\
1253 ect existing items.");
1254 item_labelbgcolor_button
->box(FL_DOWN_BOX
);
1255 item_labelbgcolor_button
->labelsize(12);
1256 item_labelbgcolor_button
->callback((Fl_Callback
*)cb_item_labelbgcolor_button
);
1257 item_labelbgcolor_button
->align(Fl_Align(FL_ALIGN_LEFT_TOP
));
1258 item_labelbgcolor_button
->color(tree
->item_labelbgcolor());
1259 } // Fl_Button* item_labelbgcolor_button
1260 { Fl_Choice
* o
= item_font_choice
= new Fl_Choice(828, 371, 140, 21, "Item label font");
1261 item_font_choice
->tooltip("Sets the default font used for new items created. Does NOT affect existing it\
1263 item_font_choice
->down_box(FL_BORDER_BOX
);
1264 item_font_choice
->labelsize(12);
1265 item_font_choice
->textsize(12);
1266 item_font_choice
->callback((Fl_Callback
*)cb_item_font_choice
);
1267 item_font_choice
->menu(menu_item_font_choice
);
1268 o
->value((int)tree
->item_labelfont()); // get tree's current font, assign to chooser
1269 } // Fl_Choice* item_font_choice
1270 { Fl_Value_Slider
* o
= item_labelsize_slider
= new Fl_Value_Slider(828, 396, 140, 16, "item_labelsize");
1271 item_labelsize_slider
->tooltip("Sets the default labelsize used for new items. Does NOT affect existing items\
1273 item_labelsize_slider
->type(1);
1274 item_labelsize_slider
->labelsize(12);
1275 item_labelsize_slider
->textsize(12);
1276 item_labelsize_slider
->callback((Fl_Callback
*)cb_item_labelsize_slider
, (void*)(tree
));
1277 item_labelsize_slider
->align(Fl_Align(FL_ALIGN_LEFT
));
1278 o
->value((int)tree
->item_labelsize());
1279 o
->range(1.0, 50.0);
1281 o
->color(46); o
->selection_color(FL_RED
);
1282 } // Fl_Value_Slider* item_labelsize_slider
1286 { resizer_box
= new Fl_Box(0, 263, 15, 14);
1287 } // Fl_Box* resizer_box
1289 } // Fl_Double_Window* window
1291 tree
->root_label("ROOT");
1293 /*tree->show_self();*/
1296 //Fl::scheme("gtk+");
1298 window
->resizable(tree
);
1299 window
->size_range(window
->w(), window
->h(), 0, 0);
1301 if ( tree
->when() == FL_WHEN_CHANGED
) whenmode_chooser
->value(0);
1302 else if ( tree
->when() == FL_WHEN_RELEASE
) whenmode_chooser
->value(1);
1303 else if ( tree
->when() == FL_WHEN_NEVER
) whenmode_chooser
->value(2);
1304 window
->show(argc
, argv
);