diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2010-07-10 09:44:45 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2010-07-10 09:44:45 +0000 |
| commit | 32716d6b1e8a90cbe61b60994323029ec6abe85c (patch) | |
| tree | 9c047f9cbf6a6581ef408dfabdab0aebde240a1b /test | |
| parent | 8306c3d0b31d4e60a9ba9c4d0ca4ed6a32226de1 (diff) | |
Updated the Fluid IDE support for the current source file structure. Changed the Fl_Tree rendering code around a bit to make the tree more like MSWindows on Windows and more like Apple on Apple machines. I hope you guys like it. I also moved the function to load Fl_Preferences into an Fl_Tree into the Fl_Tree class where it belongs.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7672 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
| -rw-r--r-- | test/demo.cxx | 2 | ||||
| -rw-r--r-- | test/tree.cxx | 96 | ||||
| -rw-r--r-- | test/tree.fl | 107 | ||||
| -rw-r--r-- | test/tree.h | 3 |
4 files changed, 158 insertions, 50 deletions
diff --git a/test/demo.cxx b/test/demo.cxx index 221f47eb8..cca6243de 100644 --- a/test/demo.cxx +++ b/test/demo.cxx @@ -92,7 +92,7 @@ const char *default_menu[] = { "@e:Block\\nAttack!:blocks\n", "@e:Checkers:checkers\n", "@e:Sudoku:sudoku\n", - "@e:Print\nsupport:device\n", + "@e:Print\\nsupport:device\n", "\n", "@main:Other\\nTests:@o\n", "@o:Color Choosers:color_chooser\n", diff --git a/test/tree.cxx b/test/tree.cxx index 580794165..fbecc7be1 100644 --- a/test/tree.cxx +++ b/test/tree.cxx @@ -218,6 +218,23 @@ Fl_Choice *collapseicons_chooser=(Fl_Choice *)0; static void cb_collapseicons_chooser(Fl_Choice*, void*) { 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", @@ -231,10 +248,29 @@ static void cb_collapseicons_chooser(Fl_Choice*, void*) { "...@@@@....", "...@@@.....", "...@@......", - "...@......."}; + "...@......." +#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", @@ -248,7 +284,9 @@ static const char *L_close_xpm[] = { "..@@@@@@@..", "...@@@@@...", "....@@@....", - ".....@....."}; + ".....@....." +#endif + }; static Fl_Pixmap L_closepixmap(L_close_xpm); switch ( collapseicons_chooser->value() ) { @@ -270,7 +308,7 @@ switch ( collapseicons_chooser->value() ) { Fl_Menu_Item menu_collapseicons_chooser[] = { {"Normal", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0}, - {"Arrow", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0}, + {"Custom", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0}, {"Off", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 11, 0}, {0,0,0,0,0,0,0,0,0} }; @@ -519,6 +557,18 @@ static void cb_clearall_button(Fl_Button*, void*) { tree->redraw(); } +Fl_Button *loaddb_button=(Fl_Button *)0; + +static void cb_loaddb_button(Fl_Button*, void*) { + const char *filename = fl_file_chooser("Select a Preferences style Databse", "Preferences(*.prefs)", 0L); +if (filename) { + tree->clear(); + Fl_Preferences prefs(filename, 0L, 0L); + tree->load(prefs); + tree->redraw(); +}; +} + int main(int argc, char **argv) { { window = new Fl_Double_Window(580, 695, "tree"); { tree = new Fl_Tree(15, 15, 550, 390); @@ -538,7 +588,6 @@ int main(int argc, char **argv) { margintop_slider->tooltip("Changes the top margin for the tree widget"); margintop_slider->type(1); margintop_slider->labelsize(12); - margintop_slider->step(0.01); margintop_slider->textsize(12); margintop_slider->callback((Fl_Callback*)cb_margintop_slider, (void*)(tree)); margintop_slider->align(Fl_Align(FL_ALIGN_LEFT)); @@ -551,7 +600,6 @@ int main(int argc, char **argv) { marginleft_slider->tooltip("Changes the left margin for the tree widget"); marginleft_slider->type(1); marginleft_slider->labelsize(12); - marginleft_slider->step(0.01); marginleft_slider->textsize(12); marginleft_slider->callback((Fl_Callback*)cb_marginleft_slider, (void*)(tree)); marginleft_slider->align(Fl_Align(FL_ALIGN_LEFT)); @@ -564,7 +612,6 @@ int main(int argc, char **argv) { openchild_marginbottom_slider->tooltip("Changes the vertical space below an open child tree"); openchild_marginbottom_slider->type(1); openchild_marginbottom_slider->labelsize(12); - openchild_marginbottom_slider->step(0.01); openchild_marginbottom_slider->textsize(12); openchild_marginbottom_slider->callback((Fl_Callback*)cb_openchild_marginbottom_slider, (void*)(tree)); openchild_marginbottom_slider->align(Fl_Align(FL_ALIGN_LEFT)); @@ -578,7 +625,6 @@ int main(int argc, char **argv) { d"); labelsize_slider->type(1); labelsize_slider->labelsize(12); - labelsize_slider->step(0.01); labelsize_slider->textsize(12); labelsize_slider->callback((Fl_Callback*)cb_labelsize_slider, (void*)(tree)); labelsize_slider->align(Fl_Align(FL_ALIGN_LEFT)); @@ -591,29 +637,28 @@ d"); connectorwidth_slider->tooltip("Tests Fl_Tree::connectorwidth()"); connectorwidth_slider->type(1); connectorwidth_slider->labelsize(12); - connectorwidth_slider->step(0.01); connectorwidth_slider->textsize(12); connectorwidth_slider->callback((Fl_Callback*)cb_connectorwidth_slider, (void*)(tree)); connectorwidth_slider->align(Fl_Align(FL_ALIGN_LEFT)); o->value(tree->connectorwidth()); - o->range(10.0, 100.0); + o->range(1.0, 100.0); o->step(1.0); o->color(46); o->selection_color(FL_RED); } // Fl_Value_Slider* connectorwidth_slider - { usericon_radio = new Fl_Check_Button(145, 520, 130, 16, "Enable user icons?"); + { usericon_radio = new Fl_Check_Button(145, 525, 130, 16, "Enable user icons?"); usericon_radio->tooltip("Tests Fl_Tree_Item::usericon()"); usericon_radio->down_box(FL_DOWN_BOX); usericon_radio->labelsize(11); usericon_radio->callback((Fl_Callback*)cb_usericon_radio, (void*)(tree)); } // Fl_Check_Button* usericon_radio - { showroot_radio = new Fl_Check_Button(145, 539, 130, 16, "Show root?"); + { showroot_radio = new Fl_Check_Button(145, 544, 130, 16, "Show root?"); showroot_radio->tooltip("Tests Fl_Tree_Item::usericon()"); showroot_radio->down_box(FL_DOWN_BOX); showroot_radio->labelsize(11); showroot_radio->callback((Fl_Callback*)cb_showroot_radio, (void*)(tree)); int onoff = tree->showroot(); showroot_radio->value(onoff); } // Fl_Check_Button* showroot_radio - { collapseicons_chooser = new Fl_Choice(145, 564, 110, 16, "Collapse icons"); + { collapseicons_chooser = new Fl_Choice(145, 572, 110, 16, "Collapse icons"); collapseicons_chooser->tooltip("Tests Fl_Tree::openicon() and Fl_Tree::closeicon()"); collapseicons_chooser->down_box(FL_BORDER_BOX); collapseicons_chooser->labelsize(11); @@ -621,16 +666,16 @@ d"); collapseicons_chooser->callback((Fl_Callback*)cb_collapseicons_chooser); collapseicons_chooser->menu(menu_collapseicons_chooser); } // Fl_Choice* collapseicons_chooser - { connectorstyle_chooser = new Fl_Choice(145, 584, 110, 16, "Line style"); + { connectorstyle_chooser = new Fl_Choice(145, 592, 110, 16, "Line style"); connectorstyle_chooser->tooltip("Tests connectorstyle() bit flags"); connectorstyle_chooser->down_box(FL_BORDER_BOX); connectorstyle_chooser->labelsize(11); connectorstyle_chooser->textsize(11); connectorstyle_chooser->callback((Fl_Callback*)cb_connectorstyle_chooser); connectorstyle_chooser->menu(menu_connectorstyle_chooser); - connectorstyle_chooser->value(1); // tree's default is 'dotted' + 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; } } // Fl_Choice* connectorstyle_chooser - { labelcolor_chooser = new Fl_Choice(145, 604, 110, 16, "Item Text Color"); + { labelcolor_chooser = new Fl_Choice(145, 612, 110, 16, "Item Text Color"); labelcolor_chooser->tooltip("Changes the label color for the selected items\nIf no items selected, all are\ changed"); labelcolor_chooser->down_box(FL_BORDER_BOX); @@ -639,7 +684,7 @@ d"); labelcolor_chooser->callback((Fl_Callback*)cb_labelcolor_chooser); labelcolor_chooser->menu(menu_labelcolor_chooser); } // Fl_Choice* labelcolor_chooser - { selectmode_chooser = new Fl_Choice(145, 624, 110, 16, "Selection Mode"); + { selectmode_chooser = new Fl_Choice(145, 632, 110, 16, "Selection Mode"); selectmode_chooser->tooltip("Sets how Fl_Tree handles mouse selection of tree items"); selectmode_chooser->down_box(FL_BORDER_BOX); selectmode_chooser->labelsize(11); @@ -649,7 +694,7 @@ d"); selectmode_chooser->value(1); cb_selectmode_chooser(selectmode_chooser, (void*)0); } // Fl_Choice* selectmode_chooser - { whenmode_chooser = new Fl_Choice(145, 644, 110, 16, "When"); + { whenmode_chooser = new Fl_Choice(145, 652, 110, 16, "When"); whenmode_chooser->tooltip("Sets when() the tree\'s callback is invoked"); whenmode_chooser->down_box(FL_BORDER_BOX); whenmode_chooser->labelsize(11); @@ -688,37 +733,42 @@ d"); bbbchild02select_toggle->labelsize(11); bbbchild02select_toggle->callback((Fl_Callback*)cb_bbbchild02select_toggle); } // Fl_Light_Button* bbbchild02select_toggle - { deactivate_toggle = new Fl_Light_Button(280, 625, 90, 16, " Deactivate"); + { deactivate_toggle = new Fl_Light_Button(280, 633, 90, 16, " Deactivate"); deactivate_toggle->tooltip("Toggle the deactivation state of the selected items.\nIf none are selected, a\ ll are set."); deactivate_toggle->labelsize(11); deactivate_toggle->callback((Fl_Callback*)cb_deactivate_toggle); } // Fl_Light_Button* deactivate_toggle - { bold_toggle = new Fl_Light_Button(280, 644, 90, 16, " Bold Font"); + { bold_toggle = new Fl_Light_Button(280, 652, 90, 16, " Bold Font"); bold_toggle->tooltip("Toggles bold font for selected items\nIf nothing selected, all are changed"); bold_toggle->labelsize(11); bold_toggle->callback((Fl_Callback*)cb_bold_toggle); } // Fl_Light_Button* bold_toggle - { insertabove_button = new Fl_Button(380, 624, 90, 16, "Insert Above"); + { insertabove_button = new Fl_Button(380, 632, 90, 16, "Insert Above"); insertabove_button->tooltip("Inserts three items above the selected items"); insertabove_button->labelsize(11); insertabove_button->callback((Fl_Callback*)cb_insertabove_button); } // Fl_Button* insertabove_button - { rebuildtree_button = new Fl_Button(380, 644, 90, 16, "Rebuild Tree"); + { rebuildtree_button = new Fl_Button(380, 652, 90, 16, "Rebuild Tree"); rebuildtree_button->tooltip("Rebuilds the tree with defaults"); rebuildtree_button->labelsize(11); rebuildtree_button->callback((Fl_Callback*)cb_rebuildtree_button); } // Fl_Button* rebuildtree_button - { clearselected_button = new Fl_Button(475, 624, 90, 16, "Clear Selected"); + { clearselected_button = new Fl_Button(475, 632, 90, 16, "Clear Selected"); clearselected_button->tooltip("Clears the selected items"); clearselected_button->labelsize(11); clearselected_button->callback((Fl_Callback*)cb_clearselected_button); } // Fl_Button* clearselected_button - { clearall_button = new Fl_Button(475, 644, 90, 16, "Clear All"); + { clearall_button = new Fl_Button(475, 652, 90, 16, "Clear All"); clearall_button->tooltip("Clears all items\nTests Fl_Tree::clear()"); clearall_button->labelsize(11); clearall_button->callback((Fl_Callback*)cb_clearall_button); } // Fl_Button* clearall_button + { loaddb_button = new Fl_Button(380, 612, 90, 16, "Load Database..."); + loaddb_button->tooltip("Load the contents of an Fl_Preferences databse into the tree view"); + loaddb_button->labelsize(11); + loaddb_button->callback((Fl_Callback*)cb_loaddb_button); + } // Fl_Button* loaddb_button window->end(); } // Fl_Double_Window* window // Initialize Tree diff --git a/test/tree.fl b/test/tree.fl index a5070891a..9e70d00dd 100644 --- a/test/tree.fl +++ b/test/tree.fl @@ -20,7 +20,13 @@ decl {\#include <FL/Fl_Tree.H>} {public global decl {\#include <FL/fl_ask.H>} {public global } -Function {Button_CB(Fl_Widget*w, void*data)} {open return_type void +decl {\#include <FL/Fl_File_Chooser.H>} {selected public global +} + +decl {\#include <FL/Fl_Preferences.H>} {public global +} + +Function {Button_CB(Fl_Widget*w, void*data)} {return_type void } { code {fprintf(stderr, "'%s' button pushed\\n", w->label());} {} } @@ -109,7 +115,7 @@ Function {} {open } { Fl_Window window { label tree open - xywh {1105 30 580 695} type Double visible + xywh {1105 44 580 695} type Double visible } { Fl_Group tree { user_data 1234 @@ -130,7 +136,7 @@ if ( item ) { callback {int val = (int)margintop_slider->value(); tree->margintop(val); tree->redraw();} - tooltip {Changes the top margin for the tree widget} xywh {190 414 240 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12 + tooltip {Changes the top margin for the tree widget} xywh {190 414 240 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);} @@ -142,7 +148,7 @@ tree->redraw();} callback {int val = (int)marginleft_slider->value(); tree->marginleft(val); tree->redraw();} - tooltip {Changes the left margin for the tree widget} xywh {190 434 240 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12 + tooltip {Changes the left margin for the tree widget} xywh {190 434 240 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);} @@ -154,7 +160,7 @@ tree->redraw();} 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 {190 454 240 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12 + tooltip {Changes the vertical space below an open child tree} xywh {190 454 240 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);} @@ -183,7 +189,7 @@ if ( ! count ) { tree->redraw();} tooltip {Changes the font size of the selected items -If none selected, all are changed} xywh {190 474 240 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12 +If none selected, all are changed} xywh {190 474 240 16} type Horizontal labelsize 12 align 4 textsize 12 code0 {o->value(tree->labelsize());} code1 {o->range(5.0, 200.0);} code2 {o->step(1.0);} @@ -193,9 +199,9 @@ If none selected, all are changed} xywh {190 474 240 16} type Horizontal labelsi label {Connector width} user_data tree callback {tree->connectorwidth((int)connectorwidth_slider->value());} - tooltip {Tests Fl_Tree::connectorwidth()} xywh {190 494 240 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12 + tooltip {Tests Fl_Tree::connectorwidth()} xywh {190 494 240 16} type Horizontal labelsize 12 align 4 textsize 12 code0 {o->value(tree->connectorwidth());} - code1 {o->range(10.0, 100.0);} + code1 {o->range(1.0, 100.0);} code2 {o->step(1.0);} code3 {o->color(46); o->selection_color(FL_RED);} } @@ -250,19 +256,36 @@ if ( usericon_radio->value() ) { if ( ( i = tree->find_item("Bbb/bgb/222") ) != NULL ) i->usericon(0); if ( ( i = tree->find_item("Bbb/bgb/333") ) != NULL ) i->usericon(0); }} - tooltip {Tests Fl_Tree_Item::usericon()} xywh {145 520 130 16} down_box DOWN_BOX labelsize 11 + tooltip {Tests Fl_Tree_Item::usericon()} xywh {145 525 130 16} down_box DOWN_BOX labelsize 11 } Fl_Check_Button showroot_radio { label {Show root?} user_data tree callback {int onoff = showroot_radio->value(); tree->showroot(onoff);} - tooltip {Tests Fl_Tree_Item::usericon()} xywh {145 539 130 16} down_box DOWN_BOX labelsize 11 + tooltip {Tests Fl_Tree_Item::usericon()} xywh {145 544 130 16} down_box DOWN_BOX labelsize 11 code0 {int onoff = tree->showroot(); showroot_radio->value(onoff);} } 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", @@ -276,10 +299,29 @@ tree->showroot(onoff);} "...@@@@....", "...@@@.....", "...@@......", - "...@......."}; + "...@......." +\#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", @@ -293,7 +335,9 @@ static const char *L_close_xpm[] = { "..@@@@@@@..", "...@@@@@...", "....@@@....", - ".....@....."}; + ".....@....." +\#endif + }; static Fl_Pixmap L_closepixmap(L_close_xpm); switch ( collapseicons_chooser->value() ) { @@ -311,14 +355,14 @@ switch ( collapseicons_chooser->value() ) { tree->showcollapse(0); break; }} open - tooltip {Tests Fl_Tree::openicon() and Fl_Tree::closeicon()} xywh {145 564 110 16} down_box BORDER_BOX labelsize 11 textsize 11 + tooltip {Tests Fl_Tree::openicon() and Fl_Tree::closeicon()} xywh {145 572 110 16} down_box BORDER_BOX labelsize 11 textsize 11 } { MenuItem {} { label Normal xywh {0 0 36 21} labelsize 11 } MenuItem {} { - label Arrow + label Custom xywh {10 10 36 21} labelsize 11 } MenuItem {} { @@ -334,8 +378,8 @@ switch ( connectorstyle_chooser->value() ) { case 1: tree->connectorstyle(FL_TREE_CONNECTOR_DOTTED); break; case 2: tree->connectorstyle(FL_TREE_CONNECTOR_SOLID); break; }} open - tooltip {Tests connectorstyle() bit flags} xywh {145 584 110 16} down_box BORDER_BOX labelsize 11 textsize 11 - code0 {connectorstyle_chooser->value(1); // tree's default is 'dotted'} + tooltip {Tests connectorstyle() bit flags} xywh {145 592 110 16} down_box BORDER_BOX labelsize 11 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 @@ -380,7 +424,7 @@ if ( ! count ) { tree->redraw();} open tooltip {Changes the label color for the selected items -If no items selected, all are changed} xywh {145 604 110 16} down_box BORDER_BOX labelsize 11 textsize 11 +If no items selected, all are changed} xywh {145 612 110 16} down_box BORDER_BOX labelsize 11 textsize 11 } { MenuItem {} { label Black @@ -408,7 +452,7 @@ switch ( selectmode_chooser->value() ) { 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 {145 624 110 16} down_box BORDER_BOX labelsize 11 textsize 11 + tooltip {Sets how Fl_Tree handles mouse selection of tree items} xywh {145 632 110 16} down_box BORDER_BOX labelsize 11 textsize 11 code0 {selectmode_chooser->value(1);} code1 {cb_selectmode_chooser(selectmode_chooser, (void*)0);} } { @@ -434,7 +478,7 @@ switch ( whenmode_chooser->value() ) { 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 {145 644 110 16} down_box BORDER_BOX labelsize 11 textsize 11 + tooltip {Sets when() the tree's callback is invoked} xywh {145 652 110 16} down_box BORDER_BOX labelsize 11 textsize 11 code0 {whenmode_chooser->value(1);} code1 {cb_whenmode_chooser(whenmode_chooser, (void*)0);} } { @@ -527,7 +571,7 @@ if ( count == 0 ) { tree->redraw();} tooltip {Toggle the deactivation state of the selected items. -If none are selected, all are set.} xywh {280 625 90 16} labelsize 11 +If none are selected, all are set.} xywh {280 633 90 16} labelsize 11 } Fl_Light_Button bold_toggle { label { Bold Font} @@ -551,7 +595,7 @@ if ( ! count ) { tree->redraw();} tooltip {Toggles bold font for selected items -If nothing selected, all are changed} xywh {280 644 90 16} labelsize 11 +If nothing selected, all are changed} xywh {280 652 90 16} labelsize 11 } Fl_Button insertabove_button { label {Insert Above} @@ -566,12 +610,12 @@ while (item) { } tree->redraw();} - tooltip {Inserts three items above the selected items} xywh {380 624 90 16} labelsize 11 + tooltip {Inserts three items above the selected items} xywh {380 632 90 16} labelsize 11 } Fl_Button rebuildtree_button { label {Rebuild Tree} callback {RebuildTree();} - tooltip {Rebuilds the tree with defaults} xywh {380 644 90 16} labelsize 11 + tooltip {Rebuilds the tree with defaults} xywh {380 652 90 16} labelsize 11 } Fl_Button clearselected_button { label {Clear Selected} @@ -586,14 +630,25 @@ while (item) { } tree->redraw();} - tooltip {Clears the selected items} xywh {475 624 90 16} labelsize 11 + tooltip {Clears the selected items} xywh {475 632 90 16} labelsize 11 } Fl_Button clearall_button { label {Clear All} callback {tree->clear(); -tree->redraw();} selected +tree->redraw();} tooltip {Clears all items -Tests Fl_Tree::clear()} xywh {475 644 90 16} labelsize 11 +Tests Fl_Tree::clear()} xywh {475 652 90 16} labelsize 11 + } + Fl_Button loaddb_button { + label {Load Database...} + callback {const char *filename = fl_file_chooser("Select a Preferences style Databse", "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 databse into the tree view} xywh {380 612 90 16} labelsize 11 } } code {// Initialize Tree diff --git a/test/tree.h b/test/tree.h index e479bff11..c25437b93 100644 --- a/test/tree.h +++ b/test/tree.h @@ -9,6 +9,8 @@ #include <FL/Fl_Group.H> #include <FL/Fl_Tree.H> #include <FL/fl_ask.H> +#include <FL/Fl_File_Chooser.H> +#include <FL/Fl_Preferences.H> void Button_CB(Fl_Widget*w, void*data); void RebuildTree(); #include <FL/Fl_Double_Window.H> @@ -44,6 +46,7 @@ extern Fl_Button *insertabove_button; extern Fl_Button *rebuildtree_button; extern Fl_Button *clearselected_button; extern Fl_Button *clearall_button; +extern Fl_Button *loaddb_button; extern Fl_Menu_Item menu_collapseicons_chooser[]; extern Fl_Menu_Item menu_connectorstyle_chooser[]; extern Fl_Menu_Item menu_labelcolor_chooser[]; |
