From 0d0b0662300a6ca9f339ec6bdbdf555dec7f26a8 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Fri, 8 Dec 2000 15:44:24 +0000 Subject: [PATCH] Added tests to browser to test top/bottom/middle/make_visible methods. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1345 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- test/browser.cxx | 63 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/test/browser.cxx b/test/browser.cxx index b7ab42967..1fca5272d 100644 --- a/test/browser.cxx +++ b/test/browser.cxx @@ -1,5 +1,5 @@ // -// "$Id: browser.cxx,v 1.5.2.4 2000/06/05 21:21:16 mike Exp $" +// "$Id: browser.cxx,v 1.5.2.5 2000/12/08 15:44:24 easysw Exp $" // // Browser test program for the Fast Light Tool Kit (FLTK). // @@ -62,40 +62,77 @@ That was a blank line above this. #include #include #include +#include +#include #include #include #include #include +Fl_Select_Browser *browser; +Fl_Button *top, + *bottom, + *middle, + *visible; +Fl_Input *field; + void b_cb(Fl_Widget* o, void*) { printf("callback, selection = %d, event_clicks = %d\n", ((Fl_Browser*)o)->value(), Fl::event_clicks()); } +void show_cb(Fl_Widget *o, void *) { + int line = atoi(field->value()); + + if (o == top) + browser->topline(line); + else if (o == bottom) + browser->bottomline(line); + else if (o == middle) + browser->middleline(line); + else + browser->make_visible(line); +} + int main(int argc, char **argv) { int i; if (!Fl::args(argc,argv,i)) Fl::fatal(Fl::help); const char* fname = (i < argc) ? argv[i] : "browser.cxx"; Fl_Window window(400,400,fname); - window.box(FL_NO_BOX); // because it is filled with browser - Fl_Select_Browser browser(0,0,400,400,0); - browser.type(FL_MULTI_BROWSER); - //browser.type(FL_HOLD_BROWSER); - //browser.color(42); - browser.callback(b_cb); - // browser.scrollbar_right(); - //browser.has_scrollbar(Fl_Browser::BOTH_ALWAYS); - if (!browser.load(fname)) { + browser = new Fl_Select_Browser(0,0,400,350,0); + browser->type(FL_MULTI_BROWSER); + //browser->type(FL_HOLD_BROWSER); + //browser->color(42); + browser->callback(b_cb); + // browser->scrollbar_right(); + //browser->has_scrollbar(Fl_Browser::BOTH_ALWAYS); + if (!browser->load(fname)) { printf("Can't load %s, %s\n", fname, strerror(errno)); exit(1); } - browser.position(0); - window.resizable(&browser); + browser->position(0); + + field = new Fl_Input(50, 350, 350, 25, "Line #:"); + field->callback(show_cb); + + top = new Fl_Button(0, 375, 100, 25, "Top"); + top->callback(show_cb); + + bottom = new Fl_Button(100, 375, 100, 25, "Bottom"); + bottom->callback(show_cb); + + middle = new Fl_Button(200, 375, 100, 25, "Middle"); + middle->callback(show_cb); + + visible = new Fl_Button(300, 375, 100, 25, "Make Vis."); + visible->callback(show_cb); + + window.resizable(browser); window.show(argc,argv); return Fl::run(); } // -// End of "$Id: browser.cxx,v 1.5.2.4 2000/06/05 21:21:16 mike Exp $". +// End of "$Id: browser.cxx,v 1.5.2.5 2000/12/08 15:44:24 easysw Exp $". //