diff options
| author | Bill Spitzak <spitzak@gmail.com> | 2000-05-13 20:03:20 +0000 |
|---|---|---|
| committer | Bill Spitzak <spitzak@gmail.com> | 2000-05-13 20:03:20 +0000 |
| commit | d5b47034a7575151963f1fc85a4630f68208e73a (patch) | |
| tree | 023ff7f35eeda76f2343cd895b4e2ea2101319b8 /test | |
| parent | 2d826eb564160432259480504537e5797eced931 (diff) | |
Added Fl::first_window(window) to change which window is at the top of
the window list. This window is used as the "parent" of any modal
windows you create so it is a good idea to be able to change it.
Normally it is whatever window got the last event.
Fixed Fl_Menu::global handler to use first_window so if a modal window
pops up in response it is parented to the window containing the
menubar rather than the current top window. This was an annoying bug!
Copied fl_line_style() and the line_style demo over from fltk 2.0
because I am tired of mailing this code to people. Better to advertise this
as "added fl_line_style() function to set line thickness, dash patterns,
and end caps".
Fixed the documentation for these changes.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1117 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
| -rw-r--r-- | test/Makefile | 8 | ||||
| -rw-r--r-- | test/demo.menu | 3 | ||||
| -rw-r--r-- | test/line_style.cxx | 123 |
3 files changed, 129 insertions, 5 deletions
diff --git a/test/Makefile b/test/Makefile index e6d5c6220..3f0169778 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile,v 1.19.2.3 2000/04/27 00:17:54 mike Exp $" +# "$Id: Makefile,v 1.19.2.4 2000/05/13 20:03:19 bill Exp $" # # Test/example program makefile for the Fast Light Tool Kit (FLTK). # @@ -34,7 +34,7 @@ CPPFILES =\ message.cxx minimum.cxx navigation.cxx output.cxx overlay.cxx pixmap.cxx \ pixmap_browser.cxx radio.cxx resizebox.cxx scroll.cxx shape.cxx shiny.cxx \ subwindow.cxx symbols.cxx tabs.cxx tile.cxx valuators.cxx fast_slow.cxx \ - resize.cxx pack.cxx inactive.cxx + resize.cxx pack.cxx inactive.cxx line_style.cxx ALL = CubeView adjuster arc ask bitmap boxtype browser button buttons checkers \ clock colbrowser color_chooser cube cursor curve demo doublebuffer \ @@ -42,7 +42,7 @@ ALL = CubeView adjuster arc ask bitmap boxtype browser button buttons checkers \ glpuzzle hello iconize image input keyboard label list_visuals \ mandelbrot menubar message minimum navigation output overlay pixmap \ pixmap_browser radio resizebox scroll shape shiny subwindow \ - symbols tabs tile valuators fast_slow resize pack inactive + symbols tabs tile valuators fast_slow resize pack inactive line_style all: $(ALL) @@ -102,5 +102,5 @@ install: @echo Nothing to install in test directory. # -# End of "$Id: Makefile,v 1.19.2.3 2000/04/27 00:17:54 mike Exp $". +# End of "$Id: Makefile,v 1.19.2.4 2000/05/13 20:03:19 bill Exp $". # diff --git a/test/demo.menu b/test/demo.menu index 97950db43..ae377e4ca 100644 --- a/test/demo.menu +++ b/test/demo.menu @@ -40,7 +40,7 @@ @d:labels:label @d:fl_arc:arc @d:fl_curve:curve - @d:fonts:fonts + @d:fl_line_style:line_style @main:Events:@u @u:navigation:navigation @@ -63,6 +63,7 @@ @o:color choosers:color_chooser r @o:file chooser:file_chooser @o:XForms Emulation:forms + @o:fonts:fonts @main:Tutorial\nfrom\nManual:@j @j:ask\n(modified):ask diff --git a/test/line_style.cxx b/test/line_style.cxx new file mode 100644 index 000000000..f0f65fb3c --- /dev/null +++ b/test/line_style.cxx @@ -0,0 +1,123 @@ +#include <FL/Fl.H> +#include <FL/Fl_Window.H> +#include <FL/Fl_Value_Slider.H> +#include <FL/fl_draw.H> +#include <FL/Fl_Choice.H> + +Fl_Window *form; +Fl_Slider *sliders[8]; +Fl_Choice *choice[3]; + +class test_box: public Fl_Window { + void draw(); +public: + test_box(int x,int y,int w,int h,const char *l=0) + : Fl_Window(x,y,w,h,l) {} +}*test; + +void test_box::draw() { + Fl_Window::draw(); + fl_color((uchar)(sliders[0]->value()), + (uchar)(sliders[1]->value()), + (uchar)(sliders[2]->value())); + char buf[5]; + buf[0] = char(sliders[4]->value()); + buf[1] = char(sliders[5]->value()); + buf[2] = char(sliders[6]->value()); + buf[3] = char(sliders[7]->value()); + buf[4] = 0; + fl_line_style( + (int)(choice[0]->mvalue()->user_data()) + + (int)(choice[1]->mvalue()->user_data()) + + (int)(choice[2]->mvalue()->user_data()), + (int)(sliders[3]->value()), + buf); + fl_rect(10,10,w()-20,h()-20); + fl_begin_line(); + fl_vertex(35, 35); + fl_vertex(w()-35, h()-35); + fl_vertex(w()-40, 35); + fl_vertex(35, h()/2); + fl_end_line(); + // you must reset the line type when done: + fl_line_style(FL_SOLID); +} + +Fl_Menu_Item style_menu[] = { + {"FL_SOLID", 0, 0, (void*)FL_SOLID}, + {"FL_DASH", 0, 0, (void*)FL_DASH}, + {"FL_DOT", 0, 0, (void*)FL_DOT}, + {"FL_DASHDOT",0, 0, (void*)FL_DASHDOT}, + {"FL_DASHDOTDOT", 0, 0, (void*)FL_DASHDOTDOT}, + {0} +}; + +Fl_Menu_Item cap_menu[] = { + {"default", 0, 0, 0}, + {"FL_CAP_FLAT", 0, 0, (void*)FL_CAP_FLAT}, + {"FL_CAP_ROUND", 0, 0, (void*)FL_CAP_ROUND}, + {"FL_CAP_SQUARE", 0, 0, (void*)FL_CAP_SQUARE}, + {0} +}; + +Fl_Menu_Item join_menu[] = { + {"default", 0, 0, 0}, + {"FL_JOIN_MITER", 0, 0, (void*)FL_JOIN_MITER}, + {"FL_JOIN_ROUND", 0, 0, (void*)FL_JOIN_ROUND}, + {"FL_JOIN_BEVEL", 0, 0, (void*)FL_JOIN_BEVEL}, + {0} +}; + +void do_redraw(Fl_Widget*,void*) +{ + test->redraw(); +} + +void makeform(const char *) { + form = new Fl_Window(500,210,"fl_line_style() test"); + sliders[0]= new Fl_Value_Slider(280,10,180,20,"R"); + sliders[0]->bounds(0,255); + sliders[1]= new Fl_Value_Slider(280,30,180,20,"G"); + sliders[1]->bounds(0,255); + sliders[2]= new Fl_Value_Slider(280,50,180,20,"B"); + sliders[2]->bounds(0,255); + choice[0]= new Fl_Choice(280,70,180,20,"Style"); + choice[0]->menu(style_menu); + choice[1]= new Fl_Choice(280,90,180,20,"Cap"); + choice[1]->menu(cap_menu); + choice[2]= new Fl_Choice(280,110,180,20,"Join"); + choice[2]->menu(join_menu); + sliders[3]= new Fl_Value_Slider(280,130,180,20,"Width"); + sliders[3]->bounds(0,20); + sliders[4] = new Fl_Slider(200,170,70,20,"Dash"); + sliders[4]->align(FL_ALIGN_TOP_LEFT); + sliders[4]->bounds(0,40); + sliders[5] = new Fl_Slider(270,170,70,20); + sliders[5]->bounds(0,40); + sliders[6] = new Fl_Slider(340,170,70,20); + sliders[6]->bounds(0,40); + sliders[7] = new Fl_Slider(410,170,70,20); + sliders[7]->bounds(0,40); + int i; + for (i=0;i<8;i++) { + sliders[i]->type(1); + if (i<4) sliders[i]->align(FL_ALIGN_LEFT); + sliders[i]->callback((Fl_Callback*)do_redraw); + sliders[i]->step(1); + } + for (i=0;i<3;i++) { + choice[i]->value(0); + choice[i]->callback((Fl_Callback*)do_redraw); + } + test=new test_box(10,10,190,190); + test->end(); + form->resizable(test); + form->end(); +} + +main(int argc, char **argv) { + makeform(argv[0]); + form->show(argc,argv); + return Fl::run(); +} + |
