diff options
| -rw-r--r-- | FL/Fl.H | 5 | ||||
| -rw-r--r-- | FL/fl_draw.H | 22 | ||||
| -rw-r--r-- | documentation/Fl_Window.html | 18 | ||||
| -rw-r--r-- | documentation/drawing.html | 41 | ||||
| -rw-r--r-- | documentation/functions.html | 20 | ||||
| -rw-r--r-- | src/Fl.cxx | 24 | ||||
| -rw-r--r-- | src/Fl_Menu_global.cxx | 5 | ||||
| -rw-r--r-- | src/Makefile | 5 | ||||
| -rw-r--r-- | test/Makefile | 8 | ||||
| -rw-r--r-- | test/demo.menu | 3 | ||||
| -rw-r--r-- | test/line_style.cxx | 123 |
11 files changed, 237 insertions, 37 deletions
@@ -1,5 +1,5 @@ // -// "$Id: Fl.H,v 1.8.2.4 2000/04/25 22:15:43 mike Exp $" +// "$Id: Fl.H,v 1.8.2.5 2000/05/13 20:03:14 bill Exp $" // // Main header file for the Fast Light Tool Kit (FLTK). // @@ -105,6 +105,7 @@ public: static FL_EXPORT void (*error)(const char*, ...); static FL_EXPORT void (*fatal)(const char*, ...); static FL_EXPORT Fl_Window* first_window(); + static FL_EXPORT void first_window(Fl_Window*); static FL_EXPORT Fl_Window* next_window(const Fl_Window*); static FL_EXPORT Fl_Window* modal() {return modal_;} static FL_EXPORT Fl_Window* grab() {return grab_;} @@ -210,5 +211,5 @@ public: #endif // -// End of "$Id: Fl.H,v 1.8.2.4 2000/04/25 22:15:43 mike Exp $". +// End of "$Id: Fl.H,v 1.8.2.5 2000/05/13 20:03:14 bill Exp $". // diff --git a/FL/fl_draw.H b/FL/fl_draw.H index 786ffdc91..75ed41f08 100644 --- a/FL/fl_draw.H +++ b/FL/fl_draw.H @@ -1,5 +1,5 @@ // -// "$Id: fl_draw.H,v 1.9.2.2 2000/04/25 22:15:58 mike Exp $" +// "$Id: fl_draw.H,v 1.9.2.3 2000/05/13 20:03:14 bill Exp $" // // Portable drawing function header file for the Fast Light Tool Kit (FLTK). // @@ -46,6 +46,24 @@ FL_EXPORT int fl_clip_box(int, int, int, int, int& x, int& y, int& w, int& h); // points: FL_EXPORT void fl_point(int x, int y); +// line type: +FL_EXPORT void fl_line_style(int style, int width=0, char* dashes=0); +enum { + FL_SOLID = 0, + FL_DASH = 1, + FL_DOT = 2, + FL_DASHDOT = 3, + FL_DASHDOTDOT = 4, + + FL_CAP_FLAT = 0x100, + FL_CAP_ROUND = 0x200, + FL_CAP_SQUARE = 0x300, + + FL_JOIN_MITER = 0x1000, + FL_JOIN_ROUND = 0x2000, + FL_JOIN_BEVEL = 0x3000 +}; + // rectangles tweaked to exactly fill the pixel rectangle: FL_EXPORT void fl_rect(int x, int y, int w, int h); FL_EXPORT void fl_rectf(int x, int y, int w, int h); @@ -161,5 +179,5 @@ FL_EXPORT int fl_add_symbol(const char* name, void (*drawit)(Fl_Color), int scal #endif // -// End of "$Id: fl_draw.H,v 1.9.2.2 2000/04/25 22:15:58 mike Exp $". +// End of "$Id: fl_draw.H,v 1.9.2.3 2000/05/13 20:03:14 bill Exp $". // diff --git a/documentation/Fl_Window.html b/documentation/Fl_Window.html index 350a28c7c..87ac71072 100644 --- a/documentation/Fl_Window.html +++ b/documentation/Fl_Window.html @@ -49,32 +49,30 @@ exit(0)</TT> if this is the last top-level window. </P> </UL> </TD><TD align=left valign=top> <UL> -<LI><A href=#Fl_Window.first_window>first_window</A></LI> <LI><A href=#Fl_Window.free_position>free_position</A></LI> <LI><A href=#Fl_Window.fullscreen>fullscreen</A></LI> <LI><A href=#Fl_Window.fullscreen_off>fullscreen_off</A></LI> <LI><A href=#Fl_Window.hide>hide</A></LI> +<LI><A href=#Fl_Window.hotspot>hotspot</A></LI> </UL> </TD><TD align=left valign=top> <UL> -<LI><A href=#Fl_Window.hotspot>hotspot</A></LI> <LI><A href=#Fl_Window.iconize>iconize</A></LI> <LI><A href=#Fl_Window.iconlabel>iconlabel</A></LI> <LI><A href=#Fl_Window.label>label</A></LI> <LI><A href=#Fl_Window.make_current>make_current</A></LI> +<LI><A href=#Fl_Window.modal>modal</A></LI> </UL> </TD><TD align=left valign=top> <UL> -<LI><A href=#Fl_Window.modal>modal</A></LI> -<LI><A href=#Fl_Window.next_window>next_window</A></LI> <LI><A href=#Fl_Window.non_modal>non_modal</A></LI> <LI><A href=#Fl_Window.resize>resize</A></LI> <LI><A href=#Fl_Window.set_modal>set_modal</A></LI> +<LI><A href=#Fl_Window.set_non_modal>set_non_modal</A></LI> +<LI><A href=#Fl_Window.show>show</A></LI> </UL> </TD><TD align=left valign=top> <UL> -<LI><A href=#Fl_Window.set_non_modal>set_non_modal</A></LI> -<LI><A href=#Fl_Window.show>show</A></LI> <LI><A href=#Fl_Window.shown>shown</A></LI> <LI><A href=#Fl_Window.size_range>size_range</A></LI> <LI><A href=#Fl_Window.xclass>xclass</A></LI> @@ -172,13 +170,7 @@ FL_SHOW</TT> events and <TT>visible()</TT> is turned on and off. </P> <P>There is no way to control what is drawn in the icon except with the string passed to <TT>Fl_Window::xclass()</TT>. You should not rely on window managers displaying the icons. </P> -<H4><A name=Fl_Window.first_window>Fl_Window *Fl::first_window()</A></H4> - Returns the first <TT>shown()</TT> window in the widget hierarchy. If -no windows are displayed <TT>first_window</TT> returns <TT>NULL</TT>. -<H4><A name=Fl_Window.next_window>Fl_Window *Fl::next_window(const -Fl_Window*)</A></H4> - Returns the next <TT>shown()</TT> window in the hierarchy. You can -use this call to iterate through all the windows that are shown(). + <H4><A name=Fl_Window.resize>void Fl_Window::resize(int,int,int,int)</A></H4> Change the size and position of the window. If <TT>shown()</TT> is true, these changes are communicated to the window server (which may diff --git a/documentation/drawing.html b/documentation/drawing.html index e29450c21..225806ee6 100644 --- a/documentation/drawing.html +++ b/documentation/drawing.html @@ -27,6 +27,7 @@ drawing functions: <UL> <LI><A href=#clipping>Clipping</A></LI> <LI><A href=#colors>Colors</A></LI> +<LI><A href=#lines>Line dashes and thickness</A></LI> <LI><A href=#fast>Fast Shapes</A></LI> <LI><A href=#complex>Complex Shapes</A></LI> <LI><A href=#text>Text</A></LI> @@ -82,6 +83,46 @@ for state save/restore. possible match to the RGB color is used. The RGB color is used directly on TrueColor displays. For colormap visuals the nearest index in the gray ramp or color cube is used. + +<h3><A name=lines>Line dashes and thickness</a></h3> + +<h4>void fl_line_style(int style, int width=0, char* dashes=0)</h4> + +Set how to draw lines (the "pen"). If you change this it is your +responsibility to set it back to the default with +<tt>fl_line_style(0)</tt>. + +<p><i>style</i> is a bitmask in which you 'or' the following values. If +you don't specify a dash type you will get a solid line. If you don't +specify a cap or join type you will get a system-defined default of +whatever value is fastest. + +<ul> +<li><tt>FL_SOLID -------</tt> +<li><tt>FL_DASH - - - -</tt> +<li><tt>FL_DOT .......</tt> +<li><tt>FL_DASHDOT - . - .</tt> +<li><tt>FL_DASHDOTDOT - .. -</tt> +<li><tt>FL_CAP_FLAT</tt> +<li><tt>FL_CAP_ROUND</tt> +<li><tt>FL_CAP_SQUARE</tt> (extends past end point 1/2 line width) +<li><tt>FL_JOIN_MITER</tt> (pointed) +<li><tt>FL_JOIN_ROUND</tt> +<li><tt>FL_JOIN_BEVEL</tt> (flat) +</ul> + +<p><i>width</i> is the number of pixels thick to draw the lines. Zero +results in the system-defined default, which on both X and Windows is +somewhat different and nicer than 1. + +<p><i>dashes</i> is a pointer to an array of dash lengths, measured in +pixels. The first location is how long to draw a solid portion, the +next is how long to draw the gap, then the solid, etc. It is +terminated with a zero-length entry. A null pointer or a zero-length +array results in a solid line. Odd array sizes are not supported and +result in undefined behavior. <i>The dashes array does not work on +Windows 95/98, use the dash styles instead.</i> + <H3><A name=fast>Fast Shapes</A></H3> These are used to draw almost all the FLTK widgets. They draw on exact pixel boundaries and are as fast as possible, and their behavior diff --git a/documentation/functions.html b/documentation/functions.html index c875420e8..638a3853b 100644 --- a/documentation/functions.html +++ b/documentation/functions.html @@ -478,8 +478,23 @@ only valid until the next event is processed. absolute position of an <TT>Fl_Window</TT> on the screen, use the difference between <TT>event_x_root(),event_y_root()</TT> and <TT> event_x(),event_y()</TT>. + <H3><A name=first_window>static Fl_Window *Fl::first_window()</A></H3> - Returns the first top-level window in the widget hierarchy. +Returns the first top-level window in the list of shown() windows. If +a modal() window is shown this is the top-most modal window, otherwise +it is the most recent window to get an event. + +<H3><A name=next_window>static Fl_Window *Fl::next_window(Fl_Window *)</A></H3> +Returns the next top-level window in the list of shown() windows. You can +use this call to iterate through all the windows that are shown(). + +<H3><A name=first_window>static void Fl::first_window(Fl_Window*)</A></H3> +Sets the window that is returned by first_window. The window is +removed from wherever it is in the list and inserted at the top. This +is not done if Fl::modal() is on or if the window is not shown(). +Because the first window is used to set the "parent" of modal windows, +this is often useful. + <H3><A name=flush>static void Fl::flush()</A></H3> Causes all the windows that need it to be redrawn and graphics forced out through the pipes. This is what <TT>wait()</TT> does before @@ -591,9 +606,6 @@ windows <TT>shown()</TT>. The <TT>modal()</TT> window has its <TT>handle()</TT> method called for all events, and no other windows will have <TT>handle()</TT> called (<A href=#grab><TT>grab()</TT></A> overrides this). -<H3><A name=next_window>static Fl_Window *Fl::next_window(Fl_Window *)</A> -</H3> - Returns the next top-level window in the widget hierarchy. <H3><A name=own_colormap>static void Fl::own_colormap()</A></H3> Makes FLTK use its own colormap. This may make FLTK display better and will reduce conflicts with other programs that want lots of colors. diff --git a/src/Fl.cxx b/src/Fl.cxx index c2252a923..62b504eba 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1,6 +1,6 @@ #include <stdio.h> // -// "$Id: Fl.cxx,v 1.24.2.20 2000/05/11 21:58:09 bill Exp $" +// "$Id: Fl.cxx,v 1.24.2.21 2000/05/13 20:03:17 bill Exp $" // // Main event handling code for the Fast Light Tool Kit (FLTK). // @@ -272,14 +272,24 @@ Fl_Window* fl_find(Window xid) { return 0; } -void Fl::redraw() { - for (Fl_X* x = Fl_X::first; x; x = x->next) x->w->redraw(); +Fl_Window* Fl::first_window() { + Fl_X* x = Fl_X::first; + return x ? x->w : 0; } -Fl_Window* Fl::first_window() {Fl_X* x = Fl_X::first; return x ? x->w : 0;} - Fl_Window* Fl::next_window(const Fl_Window* w) { - Fl_X* x = Fl_X::i(w)->next; return x ? x->w : 0;} + Fl_X* x = Fl_X::i(w)->next; + return x ? x->w : 0; +} + +void Fl::first_window(Fl_Window* window) { + if (!window || !window->shown()) return; + fl_find(fl_xid(window)); +} + +void Fl::redraw() { + for (Fl_X* x = Fl_X::first; x; x = x->next) x->w->redraw(); +} //////////////////////////////////////////////////////////////// // Event handlers: @@ -696,5 +706,5 @@ void Fl_Window::flush() { } // -// End of "$Id: Fl.cxx,v 1.24.2.20 2000/05/11 21:58:09 bill Exp $". +// End of "$Id: Fl.cxx,v 1.24.2.21 2000/05/13 20:03:17 bill Exp $". // diff --git a/src/Fl_Menu_global.cxx b/src/Fl_Menu_global.cxx index 032c27375..24be52073 100644 --- a/src/Fl_Menu_global.cxx +++ b/src/Fl_Menu_global.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Menu_global.cxx,v 1.5.2.1 2000/04/25 22:16:28 mike Exp $" +// "$Id: Fl_Menu_global.cxx,v 1.5.2.2 2000/05/13 20:03:18 bill Exp $" // // Global menu shortcut code for the Fast Light Tool Kit (FLTK). // @@ -34,6 +34,7 @@ static Fl_Menu_* the_widget; static int handler(int e) { if (e != FL_SHORTCUT || Fl::modal()) return 0; + Fl::first_window(the_widget->window()); return the_widget->handle(e); } @@ -43,5 +44,5 @@ void Fl_Menu_::global() { } // -// End of "$Id: Fl_Menu_global.cxx,v 1.5.2.1 2000/04/25 22:16:28 mike Exp $". +// End of "$Id: Fl_Menu_global.cxx,v 1.5.2.2 2000/05/13 20:03:18 bill Exp $". // diff --git a/src/Makefile b/src/Makefile index c6cd4ece3..0f24c28d9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile,v 1.18.2.10 2000/04/25 22:16:37 mike Exp $" +# "$Id: Makefile,v 1.18.2.11 2000/05/13 20:03:18 bill Exp $" # # Library makefile for the Fast Light Tool Kit (FLTK). # @@ -114,6 +114,7 @@ CPPFILES = \ fl_file_chooser.cxx \ fl_font.cxx \ fl_labeltype.cxx \ + fl_line_style.cxx \ fl_oval_box.cxx \ fl_overlay.cxx \ fl_overlay_visual.cxx \ @@ -206,5 +207,5 @@ install: $(LIBRARY) $(DSONAME) ln -s FL $(includedir)/Fl # -# End of "$Id: Makefile,v 1.18.2.10 2000/04/25 22:16:37 mike Exp $". +# End of "$Id: Makefile,v 1.18.2.11 2000/05/13 20:03:18 bill Exp $". # 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(); +} + |
