From 367f908d8ed5a3464b9676223a26ddf4e11bdb5b Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Thu, 7 Jan 1999 16:36:11 +0000 Subject: "Final" changes for first draft of 1.0 documentation. git-svn-id: file:///fltk/svn/fltk/trunk@187 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- documentation/Fl_Widget.html | 42 +- documentation/Makefile | 10 +- documentation/basics.html | 13 +- documentation/common.html | 10 +- documentation/drawing.html | 1464 ++++++++++++--------------------------- documentation/editor.html | 6 +- documentation/enumerations.html | 693 +++++++++--------- documentation/events.html | 572 ++++----------- documentation/fluid.html | 578 ++++++++-------- documentation/forms.html | 327 +++++---- documentation/functions.html | 1442 +++++++++++++++++++++++--------------- documentation/glut.html | 231 +++--- documentation/intro.html | 14 +- documentation/license.html | 8 +- documentation/opengl.html | 666 ++++++++---------- documentation/osissues.html | 550 +++++++-------- documentation/preface.html | 15 +- documentation/subclassing.html | 668 ++++++++---------- documentation/widgets.html | 5 + 19 files changed, 3321 insertions(+), 3993 deletions(-) diff --git a/documentation/Fl_Widget.html b/documentation/Fl_Widget.html index 5509a8f85..933e1ef7e 100644 --- a/documentation/Fl_Widget.html +++ b/documentation/Fl_Widget.html @@ -53,11 +53,11 @@ after these.
  • argument
  • box
  • callback -
  • changed -Microsoft Windows developers please note: case *is* significant +Microsoft Windows developers please note: case *is* significant under other operating systems, and the C standard uses the forward slash (/) to separate directories. The following #include directives are *not* recommended for portability reasons: @@ -71,9 +71,8 @@ header files. This can be done by selecting "Settings" from the

    You can build your Microsoft Windows applications as Console or WIN32 applications. If you want to use the standard C main() -function as the entry point, enter the name mainCRTStartup in -the "Entry-point symbol" field in the "Output" settings under the -"Link" tab. +function as the entry point, FLTK includes a WinMain() function +that will call your main() function for you.

    Note: The Visual C++ optimizer is known to cause problems with many programs. We only recommend using the "Favor Small Code" @@ -155,7 +154,7 @@ The boxtype value is the style of the box that is drawn around the widget. Usually this is FL_NO_BOX, which means that no box is drawn. In our "Hello, World!" example we use FL_UP_BOX, which means that a raised button border will be drawn around the -widget. You can learn more about boxtypes in Chapter +widget. You can learn more about boxtypes in Chapter 3.

    The x and y parameters determine where the widget @@ -170,7 +169,7 @@ governed by the underlying window system or hardware.

    Labels

    All widgets support labels. In the case of window widgets, the label -is used for the label in the title bar. Our example program calls the +is used for the label in the title bar. Our example program calls the labelfont, labelsize, and labeltype methods. @@ -185,7 +184,7 @@ directly.

    The labeltype method sets the type of label. FLTK supports normal, embossed, shadowed, symbol, and image labels. -

    A complete list of all label options can be found in +

    A complete list of all label options can be found in Chapter 3.

    Showing the Window

    diff --git a/documentation/common.html b/documentation/common.html index 2f75ea98b..18911c86b 100644 --- a/documentation/common.html +++ b/documentation/common.html @@ -1,7 +1,7 @@ -

    3 - Common Widgets and Attributes

    +

    3 - Common Widgets and Attributes

    This chapter describes many of the widgets that are provided with FLTK and covers how to query and set the standard attributes. @@ -119,7 +119,7 @@ window->size(width, height); Changing the size or position of a widget will cause a redraw of that widget and its children. -

    Colors

    +

    Colors

    FLTK manages a virtual color palette of "standard" colors. The standard colors are: @@ -148,7 +148,7 @@ Similarly, the label color can be set using the labelcolor() method: button->labelcolor(FL_WHITE); -

    Box Types

    +

    Box Types

    The type Fl_Boxtype stored and returned in Fl_Widget::box() is an enumeration defined in @@ -204,9 +204,9 @@ The last 4 arguments to Fl::set_boxtype() are the offsets for the bounding box that should be subtracted when drawing the label inside the box. -

    Labels and Label Types

    +

    Labels and Label Types

    -The label(), align, labelfont(), labelsize(), +The label(), align, labelfont(), labelsize(), and labeltype() methods control the labeling of widgets.

    label()

    diff --git a/documentation/drawing.html b/documentation/drawing.html index 2e78a7086..2d195d3de 100644 --- a/documentation/drawing.html +++ b/documentation/drawing.html @@ -1,9 +1,11 @@ -

    Chapter XXX - Drawing Things in FLTK

    +

    5 - Drawing Things in FLTK

    -

    When can you draw things in FLTK?

    +This chapter covers the drawing functions that are provided with FLTK. + +

    When Can You Draw Things in FLTK?

    There are only certain places you can execute drawing code in FLTK. Calling these functions at other places will result in undefined @@ -11,1285 +13,669 @@ behavior!
      -
    • The most common is inside the virtual method Fl_Widget::draw(). To write code here, -you must subclass one of the existing Fl_Widget classes and implement -your own version of draw(). - -

      - -

    • You can also write boxtypes and labeltypes. These are small procedures that can be -called by existing Fl_Widget draw() methods. These "types" are -identified by an 8-bit index that is stored in the widget's box(), -labeltype(), and possibly other properties. - -

      - -

    • You can call Fl_Window::make_current() to do -incremental update of a widget (use Fl_Widget::window() to find the -window). Under X this only works for the base Fl_Window class, not -for double buffered, overlay, or OpenGL windows! +
    • The most common is inside the virtual method Fl_Widget::draw(). To write code + here, you must subclass one of the existing Fl_Widget + classes and implement your own version of draw(). + +
    • You can also write boxtypes and labeltypes. These are small procedures + that can be called by existing Fl_Widget + draw() methods. These "types" are identified by an + 8-bit index that is stored in the widget's box(), + labeltype(), and possibly other properties. + +
    • You can call Fl_Window::make_current() + to do incremental update of a widget. Use Fl_Widget::window() to + find the window. Under X this only works for the base + Fl_Window class, not for double buffered, overlay, or + OpenGL windows!
    -

    FLTK Drawing functions
    #include <FL/fl_draw.H>

    +

    FLTK Drawing Functions

    + +To use the drawing functions you must first include the +<FL/fl_draw.H> header file. FLTK provides the following types +of drawing functions: -

    Clipping

    +

    Clipping

    -

    You can limit all your drawing to a rectangular region by calling -fl_clip, and put the drawings back by using fl_pop_clip. This -rectangle is measured in pixels (it is unaffected by the current -transformation matrix). +You can limit all your drawing to a rectangular region by calling +fl_clip, and put the drawings back by using +fl_pop_clip. This rectangle is measured in pixels (it is +unaffected by the current transformation matrix).

    In addition, the system may provide clipping when updating windows, this clip region may be more complex than a simple rectangle. -

    void fl_clip(int x, int y, int w, int h);

      +

      void fl_clip(int x, int y, int w, int h)

      -Intesect the current clip region with a rectangle and push this new +Intersect the current clip region with a rectangle and push this new region onto the stack. -

    void fl_pop_clip();

      +

      void fl_pop_clip()

      -Restore the previous clip region. You must call fl_pop_clip() once -for every time you call fl_clip(). If you return to FLTK with the -clip stack not empty unpredictable results occur. +Restore the previous clip region. You must call +fl_pop_clip() once for every time you call +fl_clip(). If you return to FLTK with the clip stack not +empty unpredictable results occur. -

    int fl_not_clipped(int x, int y, int w, int h);

      +

      int fl_not_clipped(int x, int y, int w, int h)

      Returns true if any of the rectangle intersects the current clip region. If this returns false you don't have to draw the object. -On X this returns 2 if the rectangle is partially clipped, and 1 if -it is entirely inside the clip region. +Under X this returns 2 if the rectangle is partially clipped, and 1 +if it is entirely inside the clip region. -

    int fl_clip_box(int x, int y, int w, int h,
    -    int& X, int& Y, int& W, int& H);

      +

      int fl_clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H)

      -Intersect the rectangle x,y,w,h with the current clip region and -returns the bounding box of the result in X,Y,W,H. Returns non-zero -if the resulting rectangle is different than the original. This can -be used to limit the necessary drawing to a rectangle. W and H are set to -zero if the rectangle is completely outside the region. +Intersect the rectangle x,y,w,h with the current clip region +and returns the bounding box of the result in X,Y,W,H. +Returns non-zero if the resulting rectangle is different than the +original. This can be used to limit the necessary drawing to a +rectangle. W and H are set to zero if the rectangle +is completely outside the region. -

    Colors

    +

    Colors

    -

    void fl_color(Fl_Color);

      +

      void fl_color(Fl_Color)

      -

      Set the color for all subsequent drawing operations. Fl_Color is -an enumeration type, all values are in the range 0-255. This is -not the X pixel, it is an internal table! The table provides -several general colors, a 24-entry gray ramp, and a 5x8x5 color cube. -All of these are named with poorly-documented symbols in <FL/Enumerations.H>. +Set the color for all subsequent drawing operations. Fl_Color +is an enumeration type, and all values are in the range 0-255. This is +not the X or WIN32 pixel, it is an index into an internal +table! The table provides several general colors, a 24-entry gray +ramp, and a 5x8x5 color cube. All of these are named with +poorly-documented symbols in <FL/Enumerations.H>. -

      Under X, a color cell will be allocated out of fl_colormap each -time you request an fl_color the first time. If the colormap fills up -then a least-squares algorithim is used to find the closest color. +

      For colormapped displays, a color cell will be allocated out of +fl_colormap the first time you use a color. If the colormap +fills up then a least-squares algorithm is used to find the closest +color. -

    Fl_Color fl_color();

      +

      Fl_Color fl_color()

      -Returns the last fl_color() that was set. This can be used for state +Returns the last fl_color() that was set. This can be used for state save/restore. -

    void Fl::set_color(Fl_Color, uchar r, uchar g, uchar b); -
    void Fl::get_color(Fl_Color, uchar &, uchar &, uchar &);

      - -Set or get an entry in the fl_color index table. You can set it to -any 8-bit rgb color. On X, if the index has been requested before, -the pixel is free'd. No pixel is allocated until fl_color(i) is used -again, and there is no guarantee that the same pixel will be used next -time. - -

    void fl_color(uchar r, uchar g, uchar -b);

      +

      void fl_color(uchar r, uchar g, uchar b)

      -

      Set the color for all subsequent drawing operations. The closest -possible match to the rgb color is used. Under X this works -perfectly for TrueColor visuals. For colormap visuals the nearest index -in the gray ramp or color cube is figured out, and fl_color(i) is done -with that, this can result in two approximations of the color and is -very inaccurate! +Set the color for all subsequent drawing operations. The closest +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. -


    Fast Shapes

    +

    Fast Shapes

    -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 -will be duplicated exactly on any platform FLTK is ported to. It is +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 will +be duplicated exactly on any platform FLTK is ported to. It is undefined whether these are affected by the transformation matrix, so you should only call these +href="#complex_shapes">transformation matrix, so you should only call these while it is the identity. -

    All arguments are integers. - -

    void fl_rectf(x, y, w, h);

      +

      void fl_rectf(int x, int y, int w, int h)

      Color a rectangle that exactly fills the given bounding box. -

    void fl_rectf(x, y, w, h, uchar r, uchar g, uchar b);

      +

      void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b)

      -Color a rectangle with "exactly" the passed r,g,b color. On screens -with less than 24 bits of color this is done by drawing a +Color a rectangle with "exactly" the passed r,g,b color. On +screens with less than 24 bits of color this is done by drawing a solid-colored block using fl_draw_image() so that dithering -is produced. If you have 24 bit color, this fills the rectangle with a -single pixel value and is about 1 zillion times faster. +href="#fl_draw_image">fl_draw_image() so that dithering is +produced. -

    void fl_rect(x, y, w, h);

      +

      void fl_rect(int x, int y, int w, int h)

      Draw a 1-pixel border inside this bounding box. -

    void fl_line(x, y, x1, y1); -
    void fl_line(x, y, x1, y1, x2, y2);

      +

      void fl_line(int x, int y, int x1, int y1)
      +void fl_line(int x, int y, int x1, int y1, int x2, int y2)

      Draw one or two 1-pixel thick lines between the given points. -

    void fl_loop(x, y, x1, y1, x2, y2); -
    void fl_loop(x, y, x1, y1, x2, y2, x3, y3); -

      +

      void fl_loop(int x, int y, int x1, int y1, int x2, int y2)
      +void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)

      Outline a 3 or 4-sided polygon with 1-pixel thick lines. -

    void fl_polygon(x, y, x1, y1, x2, y2); -
    void fl_polygon(x, y, x1, y1, x2, y2, x3, y3); -

      +

      void fl_polygon(int x, int y, int x1, int y1, int x2, int y2)
      +void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)

      Fill a 3 or 4-sided polygon. The polygon must be convex. -

    void fl_xyline(x, y, x1, y1); -
    void fl_xyline(x, y, x1, y1, x2); -
    void fl_xyline(x, y, x1, y1, x2, y3); -

      +

      void fl_xyline(int x, int y, int x1, int y1)
      +void fl_xyline(int x, int y, int x1, int y1, int x2)
      +void fl_xyline(int x, int y, int x1, int y1, int x2, int y3)

      Draw 1-pixel wide horizontal and vertical lines. A horizontal line is drawn first, then a vertical, then a horizontal. -

    void fl_yxline(x, y, y1); -
    void fl_yxline(x, y, y1, x2); -
    void fl_yxline(x, y, y1, x2, y3); -

      +

      void fl_yxline(int x, int y, int y1)
      +void fl_yxline(int x, int y, int y1, int x2)
      +void fl_yxline(int x, int y, int y1, int x2, int y3)

      Draw 1-pixel wide vertical and horizontal lines. A vertical line is drawn first, then a horizontal, then a vertical. -

    -void fl_arc(x, y, w, h, double a1, double a2);
    -void fl_pie(x, y, w, h, double a1, double a2);
    -void fl_chord(x, y, w, h, double a1, double a2);

      +

      void fl_arc(int x, int y, int w, int h, double a1, double a2)
      +void fl_pie(int x, int y, int w, int h, double a1, double a2)
      +void fl_chord(int x, int y, int w, int h, double a1, double a2)

      High-speed ellipse sections. These functions match the rather limited -circle drawing code provided by X and MSWindows. The advantage over using fl_arc is that they are faster because they often use -the hardware, and they draw much nicer small circles, since the small -sizes are often hard-coded bitmaps. +circle drawing code provided by X and MSWindows. The advantage over +using fl_arc is that they are faster +because they often use the hardware, and they draw much nicer small +circles, since the small sizes are often hard-coded bitmaps.

      If a complete circle is drawn it will fit inside the passed bounding box. The two angles are measured in degrees counterclockwise -from 3'oclock and are the starting and ending angle of the arc, a2 -must be greater or equal to a1. +from 3'oclock and are the starting and ending angle of the arc, a2 +must be greater or equal to a1. -

      fl_arc draws a 1-pixel thick line (notice this has a different -number of arguments than the fl_arc described +

      fl_arc() draws a 1-pixel thick line (notice this has a different +number of arguments than the fl_arc() described below. -

      fl_pie draws a filled-in pie slice. This slice may extend outside -the line drawn by fl_arc, to avoid this use w-1 and h-1. +

      fl_pie() draws a filled-in pie slice. This slice may extend outside +the line drawn by fl_arc, to avoid this use w - 1 and +h - 1. -

      fl_chord is not yet implemented. +

      fl_chord() is not yet implemented. -


    Complex Shapes

    +

    Complex Shapes

    These functions let you draw arbitrary shapes with 2-D linear -transformations. The functionality matches PostScript. The exact -pixels filled in is less defined than for the above calls, so that FLTK -can take advantage of drawing hardware. (Both Xlib and MSWindows round -all the transformed verticies to integers before drawing the line -segments. This severely limits the accuracy of these functions for -complex graphics. Try using OpenGL instead) - -

    All arguments are float. +transformations. The functionality matches that found in Adobe® +PostScriptTM. The exact pixels filled in is less defined +than for the above calls, so that FLTK can take advantage of drawing +hardware. The transformed vertices are rounded to integers before +drawing the line segments. This severely limits the accuracy of these +functions for complex graphics. Use OpenGL when greater accuracy +and/or performance is required. -

    void fl_push_matrix(); -
    void fl_pop_matrix();

      +

      void fl_push_matrix()
      +void fl_pop_matrix()

      Save and restore the current transformation. The maximum depth of the stack is 4. -

    void fl_scale(x, y); -
    void fl_scale(x); -
    void fl_translate(x, y); -
    void fl_rotate(d); -
    void fl_mult_matrix(a, b, c, d, x, y);

      +

      void fl_scale(float x, float y)
      +void fl_scale(float x)
      +void fl_translate(float x, float y)
      +void fl_rotate(float d)
      +void fl_mult_matrix(float a, float b, float c, float d, float x, float y)

      -Concat another transformation to the current one. The rotation angle -is in degrees (not radians) counter-clockwise. +Concatenate another transformation onto the current one. The rotation angle +is in degrees (not radians) and is counter-clockwise. -

    void fl_begin_line(); -
    void fl_end_line();

      +

      void fl_begin_line()
      +void fl_end_line()

      Start and end drawing 1-pixel thick lines. -

    void fl_begin_loop(); -
    void fl_end_loop();

      +

      void fl_begin_loop()
      +void fl_end_loop()

      Start and end drawing a closed sequence of 1-pixel thick lines. -

    void fl_begin_polygon(); -
    void fl_end_polygon();

      +

      void fl_begin_polygon()
      +void fl_end_polygon()

      Start and end drawing a convex filled polygon. -

    void fl_begin_complex_polygon(); -
    void fl_gap(); -
    void fl_end_complex_polygon();

      +

      void fl_begin_complex_polygon()
      +void fl_gap()
      +void fl_end_complex_polygon()

      Start and end drawing a complex filled polygon. This polygon may be concave, may have holes in it, or may be several disconnected pieces. -Call fl_gap() to seperate loops of the path (it is unnecessary but -harmless to call fl_gap() before the first vertex, after the last one, -or several times in a row). For portability, you should only draw -polygons that appear the same whether "even/odd" or "non-zero" -"winding rules" are used to fill them. This mostly means that holes -should be drawn in the opposite direction of the outside. +Call fl_gap() to seperate loops of the path (it is unnecessary +but harmless to call fl_gap() before the first vertex, after +the last one, or several times in a row). For portability, you should +only draw polygons that appear the same whether "even/odd" or +"non-zero" winding rules are used to fill them. This mostly means that +holes should be drawn in the opposite direction of the outside. -

      fl_gap() should only be called between -fl_begin/end_complex_polygon(). To outline the polygon, use -fl_begin_loop() and replace each fl_gap() with -fl_end_loop();fl_begin_loop(). +

      fl_gap() should only be called between +fl_begin_complex_polygon() and +fl_end_complex_polygon(). To outline the polygon, use +fl_begin_loop() and replace each fl_gap() with +fl_end_loop();fl_begin_loop(). -

    void fl_vertex(x, y);

      +

      void fl_vertex(float x, float y)

      Add a single vertex to the current path. -

    void fl_curve(int x,int y,int x1,int y1,int x2,int -y2,int x3,int y3);

      +

      void fl_curve(float x, float y, float x1, float y1, float x2, float y2, float x3, float y3)

      Add a series of points on a Bezier curve to the path. The curve ends -(and two of the points) are at x,y and x3,y3. +(and two of the points) are at x,y and x3,y3. -

    void fl_arc(x, y, r, start, end);

      +

      void fl_arc(float x, float y, float r, float start, float end)

      Add a series of points to the current path on the arc of a circle (you can get elliptical paths by using scale and rotate before calling -this). x,y are the center of the circle, and r is it's -radius. fl_arc() takes start and end angles that are -measured in degrees counter-clockwise from 3 o'clock. If end -is less than start then it draws clockwise. +this). x,y are the center of the circle, and r is +its radius. fl_arc() takes start and end +angles that are measured in degrees counter-clockwise from 3 o'clock. +If end is less than start then it draws the arc in a +clockwise direction. -

    void fl_circle(x, y, r);

      +

      void fl_circle(float x, float y, float r)

      -fl_circle() is equivalent to fl_arc(...,0,360) but may be faster. It -must be the only thing in the path: if you want a circle as -part of a complex polygon you must use fl_arc(). Under Xlib and -MSWindows this draws incorrectly if the transformation is both rotated -and non-square scaled. +fl_circle() is equivalent to fl_arc(...,0,360) but +may be faster. It must be the only thing in the path: if you +want a circle as part of a complex polygon you must use +fl_arc(). This draws incorrectly if the transformation is +both rotated and non-square scaled. -

    Text

    +

    Text

    -All text is drawn in the current font. It is +All text is drawn in the current font. It is undefined whether this location or the characters are modified by the current transformation. -

    void fl_draw(const char*, float x, float y); -
    void fl_draw(const char*, int n, float x, float y);

      +

      void fl_draw(const char *, float x, float y)
      +void fl_draw(const char *, int n, float x, float y)

      -Draw a null terminated string or an array of n characters +Draw a nul-terminated string or an array of n characters starting at the given location. -

    void fl_draw(const char*, int x,int y,int w,int h, Fl_Align);

      +

      void fl_draw(const char *, int x, int y, int w, int h, Fl_Align)

      Fancy string drawing function which is used to draw all the labels. The string is formatted and aligned inside the passed box. Handles '\t' and '\n', expands all other control characters to ^X, and aligns inside or against the edges of the box. See Fl_Widget::align() for values for -align. The value FL_ALIGN_INSIDE is ignored, this always -prints inside the box. +href="#Fl_Widget.align">Fl_Widget::align() for values for +align. The value FL_ALIGN_INSIDE is ignored, as this +function always prints inside the box. -

    void fl_measure(const char*, int& w, int& h);

      +

      void fl_measure(const char *, int &w, int &h)

      Measure how wide and tall the string will be when printed by the -fl_draw(...align) function. If the incoming w is non-zero it will -wrap to that width. +fl_draw(...align) function. If the incoming w is +non-zero it will wrap to that width. -

    int fl_height();

      +

      int fl_height()

      Recommended minimum line spacing for the current font. You can also -just use the value of size passed to fl_font(). +just use the value of size passed to +fl_font(). -

    int fl_descent();

      +

      int fl_descent()

      -Recommended distance above the bottom of a fl_height() tall box to -draw the text at so it looks centered vertically in that box. +Recommended distance above the bottom of a fl_height() tall +box to draw the text at so it looks centered vertically in that box. -

    float fl_width(const char*); -
    float fl_width(const char*, int n); -
    float fl_width(uchar);

      +

      float fl_width(const char*)
      +float fl_width(const char*, int n)
      +float fl_width(uchar)

      -Return the width of a null-terminated string, a sequence of n -characters, and a single character. +Return the width of a nul-terminated string, a sequence of n +characters, or a single character. -

    const char* fl_shortcut_label(ulong);

      +

      const char *fl_shortcut_label(ulong)

      Unparse a shortcut value as used by Fl_Button or Fl_Menu_Item into a human-readable string like -"Alt+N". This only works if the shortcut is a character key or a -numbered Function key. If the shortcut is zero an empty string is -returned. The return value points at a static buffer that is +href="#Fl_Button.shortcut">Fl_Button or Fl_Menu_Item into a human-readable +string like "Alt+N". This only works if the shortcut is a character +key or a numbered function key. If the shortcut is zero an empty +string is returned. The return value points at a static buffer that is overwritten with each call. -

    Fonts

    +

    Fonts

    -

    void fl_font(int face, int size);

      +

      void fl_font(int face, int size)

      Set the current font, which is then used by the routines described above. You may call this outside a draw context if necessary to call -fl_width(), but on X this will open the display. +fl_width(), but on X this will open the display. -

      The font is identified by a face and a size. The -size of the font is measured in pixels (ie. it is not -"resolution [in]dependent"). Lines should be spaced size +

      The font is identified by a face and a size. The +size of the font is measured in pixels (i.e. it is not +"resolution [in]dependent"). Lines should be spaced size pixels apart (or more). -

      The face is an index into an internal table. Initially only -the first 16 faces are filled in. There are symbolic names for them: -FL_HELVETICA, FL_TIMES, FL_COURIER, and modifier values FL_BOLD and -FL_ITALIC which can be added to these, and FL_SYMBOL and -FL_ZAPF_DINGBATS. Faces greater than 255 cannot be used in Fl_Widget -labels, since it stores the index as a byte. - -

    int fl_font();
    -int fl_size();

      - -Returns the face and size set by the most recent fl_font(a,b). This -can be used to save/restore the font. - -

    const char* Fl::get_font(int face);

      - -Get the string for this face. This string is different for each face. -Under X this value is passed to XListFonts to get all the sizes of -this face. - -

    const char* Fl::get_font_name(int face, int* attributes=0);

      +

      The face is an index into an internal table. Initially +only the first 16 faces are filled in. There are symbolic names for +them: FL_HELVETICA, FL_TIMES, FL_COURIER, +and modifier values FL_BOLD and FL_ITALIC which can +be added to these, and FL_SYMBOL and +FL_ZAPF_DINGBATS. Faces greater than 255 cannot be used in +Fl_Widget labels, since it stores the index as a byte. -Get a human-readable string describing the family of this face. This -is useful if you are presenting a choice to the user. There is no -guarantee that each face has a different name. The return value -points to a static buffer that is overwritten each call. +

      int fl_font()
      +int fl_size()

      -

      The integer pointed to by attributes (if the pointer is not -zero) is set to zero, FL_BOLD(1) or -FL_ITALIC(2) or FL_BOLD|FL_ITALIC (maybe -more attributes will be defined in the future). To locate a "family" -of fonts, search forward and back for a set with non-zero attributes, -these faces along with the face with a zero attribute before them -constitute a family. +Returns the face and size set by the most recent call to +fl_font(a,b). This can be used to save/restore the font. -

    int get_font_sizes(int face, int*& sizep);

      +

      Cursor

      -Return an array of sizes in sizep. The return value is the -length of this array. The sizes are sorted from smallest to largest -and indicate what sizes can be given to fl_font() that will be matched -exactly (fl_font() will pick the closest size for other sizes). A -zero in the first location of the array indicates a scalable font, -where any size works, although the array may list sizes that work -"better" than others. Warning: the returned array points at a static -buffer that is overwritten each call. Under X this will open the -display. - -

    int Fl::set_font(int face, const char*);

      - -Change a face. The string pointer is simply stored, the string is not -copied, so the string must be in static memory. - -

    int Fl::set_font(int face, int from);

      - -Copy one face to another. - -

    int Fl::set_fonts(const char* = 0);

      - -FLTK will open the display, and add every font on the server to the -face table. It will attempt to put "families" of faces together, so -that the normal one is first, followed by bold, italic, and bold -italic. - -

      The optional argument is a string to describe the set of fonts to -add. Passing NULL will select only fonts that have the ISO8859-1 -character set (and are thus usable by normal text). Passing "-*" will -select all fonts with any encoding as long as they have normal X font -names with dashes in them. Passing "*" will list every font that -exists (on X this may produce some strange output). Other values may -be useful but are system dependent. On MSWindows NULL selects fonts -with ISO8859-1 encoding and non-NULL selects all fonts. - -

      Return value is how many faces are in the table after this is done. - -


    Bitmaps, Pixmaps and Images

    - -Click here for information on drawing images - -

    Cursor

    - -

    void fl_cursor(Fl_Cursor, Fl_Color=FL_WHITE, Fl_Color=FL_BLACK);

      +

      void fl_cursor(Fl_Cursor, Fl_Color = FL_WHITE, Fl_Color = FL_BLACK)

      Change the cursor. Depending on the system this may affect the cursor everywhere, or only when it is pointing at the window that is current when you call this. For portability you should change the cursor back -to the default in response to FL_LEAVE events. +to the default in response to FL_LEAVE events. -

      The type Fl_Cursor is an enumeration defined in <Enumerations.H>. The +

      The type Fl_Cursor is an enumeration defined in <Enumerations.H>. The double-headed arrows are bitmaps provided by FLTK on X, the others are provided by system-defined cursors. Under X you can get any XC_cursor -value by passing Fl_Cursor((XC_foo/2)+1). - -

        -
      • FL_CURSOR_DEFAULT (0) usually an arrow -
      • FL_CURSOR_ARROW -
      • FL_CURSOR_CROSS - crosshair -
      • FL_CURSOR_WAIT - watch or hourglass -
      • FL_CURSOR_INSERT - I-beam -
      • FL_CURSOR_HAND - hand (uparrow on MSWindows) -
      • FL_CURSOR_HELP - question mark -
      • FL_CURSOR_MOVE - 4-pointed arrow -
      • FL_CURSOR_NS - up/down arrow -
      • FL_CURSOR_WE - left/right arrow -
      • FL_CURSOR_NWSE - diagonal arrow -
      • FL_CURSOR_NESW - diagonal arrow -
      • FL_CURSOR_NONE - invisible -
      - -

    Overlay rectangle

    +value by passing Fl_Cursor((XC_foo/2)+1). -

    void fl_overlay_rect(int x, int y, int w, int h);
    -void fl_overlay_clear();

      +

      The following standard cursors are available: -

      Big kludge to draw interactive selection rectangles without using -the overlay. FLTK will xor a single rectangle outline over a window. -Calling this will erase any previous rectangle (by xor'ing it), and -then draw the new one. Calling fl_overlay_clear() will erase the -rectangle without drawing a new one. Using this is tricky. You -should make a widget with both a handle() and draw() method. draw() -should call fl_overlay_clear() before doing anything else. Your -handle() method should call window()->make_current() and then -fl_overlay_rect() after FL_DRAG events, and should call -fl_overlay_clear() after a FL_RELEASE event. +

        +
      • FL_CURSOR_DEFAULT - the default cursor, usually an arrow +
      • FL_CURSOR_ARROW - an arrow pointer +
      • FL_CURSOR_CROSS - crosshair +
      • FL_CURSOR_WAIT - watch or hourglass +
      • FL_CURSOR_INSERT - I-beam +
      • FL_CURSOR_HAND - hand (uparrow on MSWindows) +
      • FL_CURSOR_HELP - question mark +
      • FL_CURSOR_MOVE - 4-pointed arrow +
      • FL_CURSOR_NS - up/down arrow +
      • FL_CURSOR_WE - left/right arrow +
      • FL_CURSOR_NWSE - diagonal arrow +
      • FL_CURSOR_NESW - diagonal arrow +
      • FL_CURSOR_NONE - invisible +
      -

    (back to contents) - - -Drawing Images in FLTK -

    Drawing Images in FLTK

    - -To draw images, you can either do it directly from data in your -memory, or you can create Fl_Bitmap or Fl_Image or Fl_Pixmap -objects. The advantage of drawing directly is that it is more -intuitive, and it is faster if the image data changes more often than -it is redrawn. The advantage of using the object is that FLTK will -cache translated forms of the image (on X it uses a server pixmap) and -thus redrawing it is much faster. - - -


    Direct Image Drawing
    -#include <FL/fl_draw.H>

    - -

    It is undefined whether the location or drawing of the image is +

    Overlays

    + +

    void fl_overlay_rect(int x, int y, int w, int h)
    +void fl_overlay_clear()

    + +These functions allow you to draw interactive selection rectangles +without using the overlay hardware. FLTK will XOR a single rectangle +outline over a window. Calling this will erase any previous rectangle +(by XOR'ing it), and then draw the new one. Calling +fl_overlay_clear() will erase the rectangle without drawing a +new one. + +

    Using this is tricky. You should make a widget with both a +handle() and draw() method. draw() should +call fl_overlay_clear() before doing anything else. Your +handle() method should call window()->make_current() +and then fl_overlay_rect() after FL_DRAG events, and +should call fl_overlay_clear() after a FL_RELEASE +event. + +

    Images

    + +To draw images, you can either do it directly from data in your memory, +or you can create Fl_Bitmap, Fl_Image, or Fl_Pixmap objects. The advantage of +drawing directly is that it is more intuitive, and it is faster if the +image data changes more often than it is redrawn. The advantage of +using the object is that FLTK will cache translated forms of the image +(on X it uses a server pixmap) and thus redrawing is much +faster. + +

    Direct Image Drawing

    + +It is undefined whether the location or drawing of the image is affected by the current transformation, so you should only call these when it is the identity. -

    All untyped arguments are integers. - -

    -void fl_draw_bitmap(const uchar*, X, Y, W, H, LD = 0);

      +

      void fl_draw_bitmap(const uchar *, int X, int Y, int W, int H, int LD = 0)

      This function is planned but not yet implemented (it may be impossible under X without allocating a pixmap). - -

    -void fl_draw_image(const uchar*, X, Y, W, H, D = 3, LD = 0);
    -void fl_draw_image_mono(const uchar*, X, Y, W, H, D = 1, LD = 0); -

    -typedef void (*fl_draw_image_cb)(void*, x, y, w, uchar*);
    -void fl_draw_image(fl_draw_image_cb, void*, X, Y, W, H, D = 3);
    -void fl_draw_image_mono(fl_draw_image_cb, void*, X, Y, W, H, D = 1); -

    -int fl_draw_pixmap(char** data, X, Y, Fl_Color=FL_GRAY);

    -int fl_measure_pixmap(char** data, int &w, int -&h);

      +

      int fl_measure_pixmap(char **data, int &w, int &h)

      -An XPM image contains the dimensions in it's data. This function +An XPM image contains the dimensions in its data. This function finds and returns the width and height. The return value is non-zero if it parsed the dimensions ok, and zero if there is any problem. -
    - - -


    class Fl_Bitmap -
    #include <FL/Fl_Bitmap.H>

    +

    class Fl_Bitmap

    -This object encapsulates the width, height, and bits of an Xbitmap -(XBM), and allows you to make an Fl_Widget use a bitmap as a label, or -to just draw the bitmap directly. Under X it will create an +This object encapsulates the width, height, and bits of an X bitmap +(XBM), and allows you to make an Fl_Widget use a bitmap as a +label, or to just draw the bitmap directly. Under X it will create an offscreen pixmap the first time it is drawn, and copy this each -subsequent time it is drawn. +subsequent time it is drawn. -

    Fl_Bitmap(const char *bits, int W, int H); -
    Fl_Bitmap(const uchar *bits, int W, int H);

    +

    Fl_Bitmap(const char *bits, int W, int H)
    +Fl_Bitmap(const uchar *bits, int W, int H)

    -Construct from an Xbitmap. The bits pointer is simply copied to the -object, so it must point at persistent storage. I provide two -constructors because various X implementations disagree about the type -of bitmap data. To use an XBM file, -#include "foo.xbm", and then do "new -Fl_Bitmap(foo_bits,foo_width,foo_height)" +Construct using an X bitmap. The bits pointer is simply copied to the +object, so it must point at persistent storage. The two constructors +are provided because various X implementations disagree about the type +of bitmap data. To use an XBM file use: + +
      +#include "foo.xbm"
      +...
      +Fl_Bitmap bitmap = new Fl_Bitmap(foo_bits, foo_width, foo_height);
      +
    -

    ~Fl_Bitmap()

    +

    ~Fl_Bitmap()

    The destructor will destroy any X pixmap created. It does not do anything to the bits data. -

    void draw(int x, int y, int w, int h, int ox=0, int oy=0);

    +

    void draw(int x, int y, int w, int h, int ox = 0, int oy = 0)

    -x,y,w,h indicates a destination rectangle. ox,oy,w,h is -a source rectangle. This source rectangle from the bitmap is drawn in -the destination. 1 bits are drawn with the current color, 0 bits are -unchanged. The source rectangle may extend outside the bitmap (i.e. ox -and oy may be negative and w and h may be bigger than the bitmap) and -this area is left unchanged. +x,y,w,h indicates a destination rectangle. ox,oy,w,h +is a source rectangle. This source rectangle from the bitmap is drawn +in the destination. 1 bits are drawn with the current color, 0 bits +are unchanged. The source rectangle may extend outside the bitmap +(i.e. ox and oy may be negative and w and +h may be bigger than the bitmap) and this area is left +unchanged. -

    void draw(int x, int y);

    +

    void draw(int x, int y)

    -Draws the bitmap with the upper-left corner at x,y. This is -the same as doing draw(x,y,this->w,this->h,0,0). +Draws the bitmap with the upper-left corner at x,y. This is +the same as doing draw(x,y,this->w,this->h,0,0). -

    void label(Fl_Widget *);

    +

    void label(Fl_Widget *)

    -Change the label() and the labeltype() of the widget to draw the -bitmap. 1 bits will be drawn with the labelcolor(), zero bits will be -unchanged. You can use the same bitmap for many widgets. +Change the label() and the labeltype() of the widget +to draw the bitmap. 1 bits will be drawn with the +labelcolor(), zero bits will be unchanged. You can use the +same bitmap for many widgets. - -


    class Fl_Pixmap -
    #include <FL/Fl_Pixmap.H>

    + +

    class Fl_Pixmap

    This object encapsulates the data from an XPM image, and allows you to -make an Fl_Widget use a pixmap as a label, or to just draw the pixmap -directly. Under X it will create an offscreen pixmap the first -time it is drawn, and copy this each subsequent time it is drawn. +make an Fl_Widget use a pixmap as a label, or to just draw the +pixmap directly. Under X it will create an offscreen pixmap the +first time it is drawn, and copy this each subsequent time it is +drawn.

    The current implementation converts the pixmap to 8 bit color data -and uses fl_draw_image() to draw +and uses fl_draw_image() to draw it. Thus you will get dithered colors on an 8 bit screen. -

    Fl_Pixmap(char * const * data);

    +

    Fl_Pixmap(char *const* data)

    + +Construct using XPM data. The data pointer is simply copied to the +object, so it must point at persistent storage. To use an XPM file do: -Construct from XPM data. The data pointer is simply copied to the -object, so it must point at persistent storage. To use an XPM file, -#include "foo.xpm", and then do "new -Fl_Pixmap(foo)" +
      +#include <FL/Fl_Pixmap.H>
      +#include "foo.xpm"
      +...
      +Fl_Pixmap pixmap = new Fl_Pixmap(foo);
      +
    -

    ~Fl_Pixmap()

    +

    ~Fl_Pixmap()

    The destructor will destroy any X pixmap created. It does not do anything to the data. -

    void draw(int x, int y, int w, int h, int ox=0, int oy=0);

    +

    void draw(int x, int y, int w, int h, int ox = 0, int oy = 0)

    -x,y,w,h indicates a destination rectangle. ox,oy,w,h is -a source rectangle. This source rectangle is copied to the -destination. The source rectangle may extend outside the pixmap -(i.e. ox and oy may be negative and w and h may be bigger than the -pixmap) and this area is left unchanged. +x,y,w,h indicates a destination rectangle. ox,oy,w,h +is a source rectangle. This source rectangle is copied to the +destination. The source rectangle may extend outside the pixmap (i.e. +ox and oy may be negative and w and +h may be bigger than the pixmap) and this area is left +unchanged. -

    void draw(int x, int y);

    +

    void draw(int x, int y)

    -Draws the image with the upper-left corner at x,y. This is -the same as doing draw(x,y,this->w,this->h,0,0). +Draws the image with the upper-left corner at x,y. This is +the same as doing draw(x,y,this->w,this->h,0,0). -

    void label(Fl_Widget *);

    +

    void label(Fl_Widget *)

    -Change the label() and the labeltype() of the widget to draw the -pixmap. You can use the same pixmap for many widgets. +Change the label() and the labeltype() of the widget +to draw the pixmap. You can use the same pixmap for many widgets. - -


    class Fl_Image -
    #include <FL/Fl_Image.H>

    -This object encapsulates a full-color RGB image, and allows you to -make an Fl_Widget use a Image as a label, or to just draw the Image -directly. Under X it will create an offscreen pixmap the first -time it is drawn, and copy this each subsequent time it is drawn. +

    class Fl_Image

    -

    See fl_draw_image() for what -happens. On 8 bit screens dithering is used. +This object encapsulates a full-color RGB image, and allows you to make +an Fl_Widget use an image as a label, or to just draw the +image directly. Under X it will create an offscreen pixmap the +first time it is drawn, and copy this each subsequent time it is +drawn. -

    Fl_Image(char uchar *data, int W, int H, int D=3, int LD=0);

    +

    Fl_Image(char uchar *data, int W, int H, int D = 3, int LD = 0)

    -Construct from a pointer to RGB data. W and H are the size of the -image in pixels. D is the delta between pixels (it may be more than 3 -to skip alpha or other data, or negative to flip the image -left/right). LD is the delta between lines (it may be more than D*W -to crop images, or negative to flip the image vertically). The data -pointer is simply copied to the object, so it must point at persistent -storage. +Construct using a pointer to RGB data. W and H are +the size of the image in pixels. D is the delta between +pixels (it may be more than 3 to skip alpha or other data, or negative +to flip the image left/right). LD is the delta between lines +(it may be more than D * W to crop images, or negative to flip +the image vertically). The data pointer is simply copied to the +object, so it must point at persistent storage. -

    ~Fl_Image()

    +

    ~Fl_Image()

    The destructor will destroy any X pixmap created. It does not do anything to the data. -

    void draw(int x, int y, int w, int h, int ox=0, int oy=0);

    - -x,y,w,h indicates a destination rectangle. ox,oy,w,h is -a source rectangle. This source rectangle is copied to the -destination. The source rectangle may extend outside the image -(i.e. ox and oy may be negative and w and h may be bigger than the -image) and this area is left unchanged. - -

    void draw(int x, int y);

    - -Draws the image with the upper-left corner at x,y. This is -the same as doing draw(x,y,this->w,this->h,0,0). - -

    void label(Fl_Widget *);

    - -Change the label() and the labeltype() of the widget to draw the -Image. You can use the same Image for many widgets. - -

    (back to contents) -FLTK enhancements to the XPM format -

    FLTK enhancements to the XPM format

    - -

    I made some additions to XPM that may be good, or intensely -disliked by X purists. I do not know if the changes are compatable -with current XPM. - -

    The change was to make a "compressed colormap" that avoids -XParseColor(), and gives the actual color values (which is really what -everybody wants!). Only colormaps of this form, and ones where the -colors are named as "#rrggbb", will be portable to non-X platforms. - -

    A compressed colormap is indicated by the number of colors being -negative. The colormap is then given as an array of 4*numcolors -characters. Each color is described by 4 characters: the index -character, and the red, green, and blue value (for 2-character indexes -each color needs 5 characters). - -

    XPM files support a single transparent index. I require this index -to be ' ' (space). To indicate that ' ' is transparent, it should be -first in the color table. To make ' ' not be transparent, put it -somewhere other than first in the table. - -

    To make the XPM files easily parseable, but still portable to most -C compilers, I suggest the following format: - -

    -/* XPM */
    -static char * name[] = {
    -/* width height ncolors chars_per_pixel */
    -"64 64 -4 1 ",
    -/* colormap */
    -"\
    - \x50\x50\x80\
    -.\xff\xff\x00\
    -r\xff\x00\x00\
    -b\x00\x00\x00",
    -/* pixels */
    -"        bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb        ",
    -"        bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb        ",
    -"        bb............................................bb        ",
    -...
    -
    - -

    All lines starting with "/*" are optional. Parsers should handle -'\' at the end of the line and \xNN and \NNN characters. This -requires the C compiler to parse \xNN characters. - - - -

    Chapter XXX - Drawing Things in FLTK

    - -

    When can you draw things in FLTK?

    - -There are only certain places you can execute drawing code in FLTK. -Calling these functions at other places will result in undefined -behavior! - -
      - -
    • The most common is inside the virtual method Fl_Widget::draw(). To write code here, -you must subclass one of the existing Fl_Widget classes and implement -your own version of draw(). - -

      +

      void draw(int x, int y, int w, int h, int ox = 0, int oy = 0)

      -
    • You can also write boxtypes and labeltypes. These are small procedures that can be -called by existing Fl_Widget draw() methods. These "types" are -identified by an 8-bit index that is stored in the widget's box(), -labeltype(), and possibly other properties. - -

      - -

    • You can call Fl_Window::make_current() to do -incremental update of a widget (use Fl_Widget::window() to find the -window). Under X this only works for the base Fl_Window class, not -for double buffered, overlay, or OpenGL windows! - -
    - -

    FLTK Drawing functions
    #include <FL/fl_draw.H>

    - - - -

    Clipping

    - -

    You can limit all your drawing to a rectangular region by calling -fl_clip, and put the drawings back by using fl_pop_clip. This -rectangle is measured in pixels (it is unaffected by the current -transformation matrix). - -

    In addition, the system may provide clipping when updating windows, -this clip region may be more complex than a simple rectangle. - -

    void fl_clip(int x, int y, int w, int h);

      - -Intesect the current clip region with a rectangle and push this new -region onto the stack. - -

    void fl_pop_clip();

      - -Restore the previous clip region. You must call fl_pop_clip() once -for every time you call fl_clip(). If you return to FLTK with the -clip stack not empty unpredictable results occur. - -

    int fl_not_clipped(int x, int y, int w, int h);

      - -Returns true if any of the rectangle intersects the current clip -region. If this returns false you don't have to draw the object. -On X this returns 2 if the rectangle is partially clipped, and 1 if -it is entirely inside the clip region. - -

    int fl_clip_box(int x, int y, int w, int h,
    -    int& X, int& Y, int& W, int& H);

      - -Intersect the rectangle x,y,w,h with the current clip region and -returns the bounding box of the result in X,Y,W,H. Returns non-zero -if the resulting rectangle is different than the original. This can -be used to limit the necessary drawing to a rectangle. W and H are set to -zero if the rectangle is completely outside the region. - -

    Colors

    - -

    void fl_color(Fl_Color);

      - -

      Set the color for all subsequent drawing operations. Fl_Color is -an enumeration type, all values are in the range 0-255. This is -not the X pixel, it is an internal table! The table provides -several general colors, a 24-entry gray ramp, and a 5x8x5 color cube. -All of these are named with poorly-documented symbols in <FL/Enumerations.H>. - -

      Under X, a color cell will be allocated out of fl_colormap each -time you request an fl_color the first time. If the colormap fills up -then a least-squares algorithim is used to find the closest color. - -

    Fl_Color fl_color();

      - -Returns the last fl_color() that was set. This can be used for state -save/restore. - -

    void Fl::set_color(Fl_Color, uchar r, uchar g, uchar b); -
    void Fl::get_color(Fl_Color, uchar &, uchar &, uchar &);

      - -Set or get an entry in the fl_color index table. You can set it to -any 8-bit rgb color. On X, if the index has been requested before, -the pixel is free'd. No pixel is allocated until fl_color(i) is used -again, and there is no guarantee that the same pixel will be used next -time. - -

    void fl_color(uchar r, uchar g, uchar -b);

      - -

      Set the color for all subsequent drawing operations. The closest -possible match to the rgb color is used. Under X this works -perfectly for TrueColor visuals. For colormap visuals the nearest index -in the gray ramp or color cube is figured out, and fl_color(i) is done -with that, this can result in two approximations of the color and is -very inaccurate! - -


    Fast Shapes

    - -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 -will be duplicated exactly on any platform FLTK is ported to. It is -undefined whether these are affected by the transformation matrix, so you should only call these -while it is the identity. - -

    All arguments are integers. - -

    void fl_rectf(x, y, w, h);

      - -Color a rectangle that exactly fills the given bounding box. - -

    void fl_rectf(x, y, w, h, uchar r, uchar g, uchar b);

      - -Color a rectangle with "exactly" the passed r,g,b color. On screens -with less than 24 bits of color this is done by drawing a -solid-colored block using fl_draw_image() so that dithering -is produced. If you have 24 bit color, this fills the rectangle with a -single pixel value and is about 1 zillion times faster. - -

    void fl_rect(x, y, w, h);

      - -Draw a 1-pixel border inside this bounding box. - -

    void fl_line(x, y, x1, y1); -
    void fl_line(x, y, x1, y1, x2, y2);

      - -Draw one or two 1-pixel thick lines between the given points. - -

    void fl_loop(x, y, x1, y1, x2, y2); -
    void fl_loop(x, y, x1, y1, x2, y2, x3, y3); -

      - -Outline a 3 or 4-sided polygon with 1-pixel thick lines. - -

    void fl_polygon(x, y, x1, y1, x2, y2); -
    void fl_polygon(x, y, x1, y1, x2, y2, x3, y3); -

      - -Fill a 3 or 4-sided polygon. The polygon must be convex. +x,y,w,h indicates a destination rectangle. ox,oy,w,h +is a source rectangle. This source rectangle is copied to the +destination. The source rectangle may extend outside the image (i.e. +ox and oy may be negative and w and +h may be bigger than the image) and this area is left +unchanged. -

    void fl_xyline(x, y, x1, y1); -
    void fl_xyline(x, y, x1, y1, x2); -
    void fl_xyline(x, y, x1, y1, x2, y3); -

      - -Draw 1-pixel wide horizontal and vertical lines. A horizontal line is -drawn first, then a vertical, then a horizontal. - -

    void fl_yxline(x, y, y1); -
    void fl_yxline(x, y, y1, x2); -
    void fl_yxline(x, y, y1, x2, y3); -

      - -Draw 1-pixel wide vertical and horizontal lines. A vertical line is -drawn first, then a horizontal, then a vertical. - -

    -void fl_arc(x, y, w, h, double a1, double a2);
    -void fl_pie(x, y, w, h, double a1, double a2);
    -void fl_chord(x, y, w, h, double a1, double a2);

      - -High-speed ellipse sections. These functions match the rather limited -circle drawing code provided by X and MSWindows. The advantage over using fl_arc is that they are faster because they often use -the hardware, and they draw much nicer small circles, since the small -sizes are often hard-coded bitmaps. - -

      If a complete circle is drawn it will fit inside the passed -bounding box. The two angles are measured in degrees counterclockwise -from 3'oclock and are the starting and ending angle of the arc, a2 -must be greater or equal to a1. - -

      fl_arc draws a 1-pixel thick line (notice this has a different -number of arguments than the fl_arc described -below. - -

      fl_pie draws a filled-in pie slice. This slice may extend outside -the line drawn by fl_arc, to avoid this use w-1 and h-1. - -

      fl_chord is not yet implemented. - -


    Complex Shapes

    - -These functions let you draw arbitrary shapes with 2-D linear -transformations. The functionality matches PostScript. The exact -pixels filled in is less defined than for the above calls, so that FLTK -can take advantage of drawing hardware. (Both Xlib and MSWindows round -all the transformed verticies to integers before drawing the line -segments. This severely limits the accuracy of these functions for -complex graphics. Try using OpenGL instead) - -

    All arguments are float. - -

    void fl_push_matrix(); -
    void fl_pop_matrix();

      - -Save and restore the current transformation. The maximum depth of the -stack is 4. - -

    void fl_scale(x, y); -
    void fl_scale(x); -
    void fl_translate(x, y); -
    void fl_rotate(d); -
    void fl_mult_matrix(a, b, c, d, x, y);

      - -Concat another transformation to the current one. The rotation angle -is in degrees (not radians) counter-clockwise. - -

    void fl_begin_line(); -
    void fl_end_line();

      - -Start and end drawing 1-pixel thick lines. - -

    void fl_begin_loop(); -
    void fl_end_loop();

      - -Start and end drawing a closed sequence of 1-pixel thick lines. - -

    void fl_begin_polygon(); -
    void fl_end_polygon();

      - -Start and end drawing a convex filled polygon. - -

    void fl_begin_complex_polygon(); -
    void fl_gap(); -
    void fl_end_complex_polygon();

      - -Start and end drawing a complex filled polygon. This polygon may be -concave, may have holes in it, or may be several disconnected pieces. -Call fl_gap() to seperate loops of the path (it is unnecessary but -harmless to call fl_gap() before the first vertex, after the last one, -or several times in a row). For portability, you should only draw -polygons that appear the same whether "even/odd" or "non-zero" -"winding rules" are used to fill them. This mostly means that holes -should be drawn in the opposite direction of the outside. - -

      fl_gap() should only be called between -fl_begin/end_complex_polygon(). To outline the polygon, use -fl_begin_loop() and replace each fl_gap() with -fl_end_loop();fl_begin_loop(). - -

    void fl_vertex(x, y);

      - -Add a single vertex to the current path. - -

    void fl_curve(int x,int y,int x1,int y1,int x2,int -y2,int x3,int y3);

      - -Add a series of points on a Bezier curve to the path. The curve ends -(and two of the points) are at x,y and x3,y3. - -

    void fl_arc(x, y, r, start, end);

      - -Add a series of points to the current path on the arc of a circle (you -can get elliptical paths by using scale and rotate before calling -this). x,y are the center of the circle, and r is it's -radius. fl_arc() takes start and end angles that are -measured in degrees counter-clockwise from 3 o'clock. If end -is less than start then it draws clockwise. - -

    void fl_circle(x, y, r);

      - -fl_circle() is equivalent to fl_arc(...,0,360) but may be faster. It -must be the only thing in the path: if you want a circle as -part of a complex polygon you must use fl_arc(). Under Xlib and -MSWindows this draws incorrectly if the transformation is both rotated -and non-square scaled. - -

    Text

    - -All text is drawn in the current font. It is -undefined whether this location or the characters are modified by the -current transformation. - -

    void fl_draw(const char*, float x, float y); -
    void fl_draw(const char*, int n, float x, float y);

      - -Draw a null terminated string or an array of n characters in the -current font, starting at the given location. - -

    void fl_draw(const char*, int x,int y,int w,int h, Fl_Align);

      - -Fancy string drawing function which is used to draw all the labels. -The string is formatted and aligned inside the passed box. Handles -'\t' and '\n', expands all other control characters to ^X, and aligns -inside or against the edges of the box. See Fl_Widget::align() for values for -align. The value FL_ALIGN_INSIDE is ignored, this always -prints inside the box. - -

    void fl_measure(const char*, int& w, int& h);

      - -Measure how wide and tall the string will be when printed by the -fl_draw(...align) function. If the incoming w is non-zero it will -wrap to that width. - -

    int fl_height();

      - -Recommended minimum line spacing for the current font. You can also -just use the value of size passed to fl_font(). - -

    int fl_descent();

      - -Recommended distance above the bottom of a fl_height() tall box to -draw the text at so it looks centered vertically in that box. - -

    float fl_width(const char*); -
    float fl_width(const char*, int n); -
    float fl_width(uchar);

      - -Return the width of a null-terminated string, a sequence of n -characters, and a single character. - -

    const char* fl_shortcut_label(ulong);

      - -Unparse a shortcut value as used by Fl_Button or Fl_Menu_Item into a human-readable string like -"Alt+N". This only works if the shortcut is a character key or a -numbered Function key. If the shortcut is zero an empty string is -returned. The return value points at a static buffer that is -overwritten with each call. - -

    Fonts

    - -

    void fl_font(int face, int size);

      - -Set the current font, which is then used by the routines described -above. You may call this outside a draw context if necessary to call -fl_width(), but on X this will open the display. - -

      The font is identified by a face and a size. The -size of the font is measured in pixels (ie. it is not -"resolution [in]dependent"). Lines should be spaced size -pixels apart (or more). - -

      The face is an index into an internal table. Initially only -the first 16 faces are filled in. There are symbolic names for them: -FL_HELVETICA, FL_TIMES, FL_COURIER, and modifier values FL_BOLD and -FL_ITALIC which can be added to these, and FL_SYMBOL and -FL_ZAPF_DINGBATS. Faces greater than 255 cannot be used in Fl_Widget -labels, since it stores the index as a byte. - -

    int fl_font();
    -int fl_size();

      - -Returns the face and size set by the most recent fl_font(a,b). This -can be used to save/restore the font. - -

    const char* Fl::get_font(int face);

      - -Get the string for this face. This string is different for each face. -Under X this value is passed to XListFonts to get all the sizes of -this face. - -

    const char* Fl::get_font_name(int face, int* attributes=0);

      - -Get a human-readable string describing the family of this face. This -is useful if you are presenting a choice to the user. There is no -guarantee that each face has a different name. The return value -points to a static buffer that is overwritten each call. - -

      The integer pointed to by attributes (if the pointer is not -zero) is set to zero, FL_BOLD(1) or -FL_ITALIC(2) or FL_BOLD|FL_ITALIC (maybe -more attributes will be defined in the future). To locate a "family" -of fonts, search forward and back for a set with non-zero attributes, -these faces along with the face with a zero attribute before them -constitute a family. - -

    int get_font_sizes(int face, int*& sizep);

      - -Return an array of sizes in sizep. The return value is the -length of this array. The sizes are sorted from smallest to largest -and indicate what sizes can be given to fl_font() that will be matched -exactly (fl_font() will pick the closest size for other sizes). A -zero in the first location of the array indicates a scalable font, -where any size works, although the array may list sizes that work -"better" than others. Warning: the returned array points at a static -buffer that is overwritten each call. Under X this will open the -display. - -

    int Fl::set_font(int face, const char*);

      - -Change a face. The string pointer is simply stored, the string is not -copied, so the string must be in static memory. - -

    int Fl::set_font(int face, int from);

      - -Copy one face to another. - -

    int Fl::set_fonts(const char* = 0);

      - -FLTK will open the display, and add every font on the server to the -face table. It will attempt to put "families" of faces together, so -that the normal one is first, followed by bold, italic, and bold -italic. - -

      The optional argument is a string to describe the set of fonts to -add. Passing NULL will select only fonts that have the ISO8859-1 -character set (and are thus usable by normal text). Passing "-*" will -select all fonts with any encoding as long as they have normal X font -names with dashes in them. Passing "*" will list every font that -exists (on X this may produce some strange output). Other values may -be useful but are system dependent. On MSWindows NULL selects fonts -with ISO8859-1 encoding and non-NULL selects all fonts. - -

      Return value is how many faces are in the table after this is done. - -


    Bitmaps, Pixmaps and Images

    - -Click here for information on drawing images - -

    Cursor

    - -

    void fl_cursor(Fl_Cursor, Fl_Color=FL_WHITE, Fl_Color=FL_BLACK);

      - -Change the cursor. Depending on the system this may affect the cursor -everywhere, or only when it is pointing at the window that is current -when you call this. For portability you should change the cursor back -to the default in response to FL_LEAVE events. - -

      The type Fl_Cursor is an enumeration defined in <Enumerations.H>. The -double-headed arrows are bitmaps provided by FLTK on X, the others are -provided by system-defined cursors. Under X you can get any XC_cursor -value by passing Fl_Cursor((XC_foo/2)+1). - -

        -
      • FL_CURSOR_DEFAULT (0) usually an arrow -
      • FL_CURSOR_ARROW -
      • FL_CURSOR_CROSS - crosshair -
      • FL_CURSOR_WAIT - watch or hourglass -
      • FL_CURSOR_INSERT - I-beam -
      • FL_CURSOR_HAND - hand (uparrow on MSWindows) -
      • FL_CURSOR_HELP - question mark -
      • FL_CURSOR_MOVE - 4-pointed arrow -
      • FL_CURSOR_NS - up/down arrow -
      • FL_CURSOR_WE - left/right arrow -
      • FL_CURSOR_NWSE - diagonal arrow -
      • FL_CURSOR_NESW - diagonal arrow -
      • FL_CURSOR_NONE - invisible -
      +

      void draw(int x, int y)

      -

    Overlay rectangle

    +Draws the image with the upper-left corner at x,y. This is +the same as doing draw(x,y,this->w,this->h,0,0). -

    void fl_overlay_rect(int x, int y, int w, int h);
    -void fl_overlay_clear();

      +

      void label(Fl_Widget *)

      -

      Big kludge to draw interactive selection rectangles without using -the overlay. FLTK will xor a single rectangle outline over a window. -Calling this will erase any previous rectangle (by xor'ing it), and -then draw the new one. Calling fl_overlay_clear() will erase the -rectangle without drawing a new one. Using this is tricky. You -should make a widget with both a handle() and draw() method. draw() -should call fl_overlay_clear() before doing anything else. Your -handle() method should call window()->make_current() and then -fl_overlay_rect() after FL_DRAG events, and should call -fl_overlay_clear() after a FL_RELEASE event. +Change the label() and the labeltype() of the widget +to draw the image. You can use the same image for many widgets. -

    (back to contents) diff --git a/documentation/editor.html b/documentation/editor.html index 60dca040c..5c31a16e7 100644 --- a/documentation/editor.html +++ b/documentation/editor.html @@ -1,7 +1,7 @@ -

    4 - Designing a Simple Text Editor

    +

    4 - Designing a Simple Text Editor

    This chapter takes you through the design of a simple FLTK-based text editor. @@ -295,7 +295,7 @@ We call the load_file() function to actually load the file.

    paste_cb()

    This callback function will send a FL_PASTE message to the input -widget using the Fl::paste() method: +widget using the Fl::paste() method:
       void paste_cb(void) {
      @@ -514,7 +514,7 @@ void load_file(char *newfile) {
       
    When loading the file we use the -input->replace() method to "replace" the text at the end of +input->replace() method to "replace" the text at the end of the buffer. The pos variable keeps track of the end of the buffer. diff --git a/documentation/enumerations.html b/documentation/enumerations.html index 355437a73..8d303bcc8 100644 --- a/documentation/enumerations.html +++ b/documentation/enumerations.html @@ -1,328 +1,373 @@ -

    C - FLTK Enumerations.H

    - -Here are the values of all the public-visible enumerations used by fltk: - -
    -#include <FL/Enumerations.H>
    -
    -//
    -// The FLTK version number; this is changed slightly from the beta versions
    -// because the old "const double" definition would not allow for conditional
    -// compilation...
    -//
    -// FL_VERSION is a double that describes the major and minor version numbers.
    -// Version 1.1 is actually stored as 1.01 to allow for more than 9 minor
    -// releases.
    -//
    -// The FL_MAJOR_VERSION, FL_MINOR_VERSION, and FL_PATCH_VERSION constants
    -// give the integral values for the major, minor, and patch releases
    -// respectively.
    -//
    -
    -#define FL_MAJOR_VERSION	1
    -#define FL_MINOR_VERSION	0
    -#define FL_PATCH_VERSION	0
    -#define FL_VERSION		((double)FL_MAJOR_VERSION + \
    -				 (double)FL_MINOR_VERSION * 0.01)
    -
    -typedef unsigned char uchar;
    -typedef unsigned long ulong;
    -typedef unsigned int u32; // you must fix if not 32 bits on your machine!
    -
    -enum Fl_Event {	// events
    -  FL_NO_EVENT		= 0,
    -  FL_PUSH		= 1,
    -  FL_RELEASE		= 2,
    -  FL_ENTER		= 3,
    -  FL_LEAVE		= 4,
    -  FL_DRAG		= 5,
    -  FL_FOCUS		= 6,
    -  FL_UNFOCUS		= 7,
    -  FL_KEYBOARD		= 8,
    -  FL_CLOSE		= 9,
    -  FL_MOVE		= 10,
    -  FL_SHORTCUT		= 11,
    -  FL_DEACTIVATE		= 13,
    -  FL_ACTIVATE		= 14,
    -  FL_HIDE		= 15,
    -  FL_SHOW		= 16,
    -  FL_PASTE		= 17,
    -  FL_SELECTIONCLEAR	= 18
    -};
    -
    -enum Fl_When { // Fl_Widget::when():
    -  FL_WHEN_NEVER		= 0,
    -  FL_WHEN_CHANGED	= 1,
    -  FL_WHEN_RELEASE	= 4,
    -  FL_WHEN_RELEASE_ALWAYS= 6,
    -  FL_WHEN_ENTER_KEY	= 8,
    -  FL_WHEN_ENTER_KEY_ALWAYS=10,
    -  FL_WHEN_NOT_CHANGED	= 2 // modifier bit to disable changed() test
    -};
    -
    -// Fl::event_key() and Fl::get_key(n) (use ascii letters for all other keys):
    -#define FL_Button	0xfee8 // use Fl_Button+n for mouse button n
    -#define FL_BackSpace	0xff08
    -#define FL_Tab		0xff09
    -#define FL_Enter	0xff0d
    -#define FL_Pause	0xff13
    -#define FL_Scroll_Lock	0xff14
    -#define FL_Escape	0xff1b
    -#define FL_Home		0xff50
    -#define FL_Left		0xff51
    -#define FL_Up		0xff52
    -#define FL_Right	0xff53
    -#define FL_Down		0xff54
    -#define FL_Page_Up	0xff55
    -#define FL_Page_Down	0xff56
    -#define FL_End		0xff57
    -#define FL_Print	0xff61
    -#define FL_Insert	0xff63
    -#define FL_Menu		0xff67 // the "menu/apps" key on XFree86
    -#define FL_Num_Lock	0xff7f
    -#define FL_KP		0xff80 // use FL_KP+'x' for 'x' on numeric keypad
    -#define FL_KP_Enter	0xff8d // same as Fl_KP+'\r'
    -#define FL_KP_Last	0xffbd // use to range-check keypad
    -#define FL_F		0xffbd // use FL_F+n for function key n
    -#define FL_F_Last	0xffe0 // use to range-check function keys
    -#define FL_Shift_L	0xffe1
    -#define FL_Shift_R	0xffe2
    -#define FL_Control_L	0xffe3
    -#define FL_Control_R	0xffe4
    -#define FL_Caps_Lock	0xffe5
    -#define FL_Meta_L	0xffe7 // the left MSWindows key on XFree86
    -#define FL_Meta_R	0xffe8 // the right MSWindows key on XFree86
    -#define FL_Alt_L	0xffe9
    -#define FL_Alt_R	0xffea
    -#define FL_Delete	0xffff
    -
    -// Fl::event_state():
    -#define FL_SHIFT	0x00010000
    -#define FL_CAPS_LOCK	0x00020000
    -#define FL_CTRL		0x00040000
    -#define FL_ALT		0x00080000
    -#define FL_NUM_LOCK	0x00100000 // most X servers do this?
    -#define FL_META		0x00400000 // correct for XFree86
    -#define FL_SCROLL_LOCK	0x00800000 // correct for XFree86
    -#define FL_BUTTON1	0x01000000
    -#define FL_BUTTON2	0x02000000
    -#define FL_BUTTON3	0x04000000
    -
    -enum Fl_Boxtype { // boxtypes (if you change these you must fix fl_boxtype.C):
    -  FL_NO_BOX = 0,	FL_FLAT_BOX,
    -
    -  FL_UP_BOX,		FL_DOWN_BOX,
    -  FL_UP_FRAME,		FL_DOWN_FRAME,
    -  FL_THIN_UP_BOX,	FL_THIN_DOWN_BOX,
    -  FL_THIN_UP_FRAME,	FL_THIN_DOWN_FRAME,
    -  FL_ENGRAVED_BOX,	FL_EMBOSSED_BOX,
    -  FL_ENGRAVED_FRAME,	FL_EMBOSSED_FRAME,
    -  FL_BORDER_BOX,	_FL_SHADOW_BOX,
    -  FL_BORDER_FRAME,	_FL_SHADOW_FRAME,
    -  _FL_ROUNDED_BOX,	_FL_RSHADOW_BOX,
    -  _FL_ROUNDED_FRAME,	_FL_RFLAT_BOX,
    -  _FL_ROUND_UP_BOX,	_FL_ROUND_DOWN_BOX,
    -  _FL_DIAMOND_UP_BOX,	_FL_DIAMOND_DOWN_BOX,
    -  _FL_OVAL_BOX,		_FL_OSHADOW_BOX,
    -  _FL_OVAL_FRAME,	_FL_OFLAT_BOX
    -};
    -extern Fl_Boxtype define_FL_ROUND_UP_BOX();
    -#define FL_ROUND_UP_BOX define_FL_ROUND_UP_BOX()
    -#define FL_ROUND_DOWN_BOX (Fl_Boxtype)(define_FL_ROUND_UP_BOX()+1)
    -extern Fl_Boxtype define_FL_SHADOW_BOX();
    -#define FL_SHADOW_BOX define_FL_SHADOW_BOX()
    -#define FL_SHADOW_FRAME (Fl_Boxtype)(define_FL_SHADOW_BOX()+2)
    -extern Fl_Boxtype define_FL_ROUNDED_BOX();
    -#define FL_ROUNDED_BOX define_FL_ROUNDED_BOX()
    -#define FL_ROUNDED_FRAME (Fl_Boxtype)(define_FL_ROUNDED_BOX()+2)
    -extern Fl_Boxtype define_FL_RFLAT_BOX();
    -#define FL_RFLAT_BOX define_FL_RFLAT_BOX()
    -extern Fl_Boxtype define_FL_RSHADOW_BOX();
    -#define FL_RSHADOW_BOX define_FL_RSHADOW_BOX()
    -extern Fl_Boxtype define_FL_DIAMOND_BOX();
    -#define FL_DIAMOND_UP_BOX define_FL_DIAMOND_BOX()
    -#define FL_DIAMOND_DOWN_BOX (Fl_Boxtype)(define_FL_DIAMOND_BOX()+1)
    -extern Fl_Boxtype define_FL_OVAL_BOX();
    -#define FL_OVAL_BOX define_FL_OVAL_BOX()
    -#define FL_OSHADOW_BOX (Fl_Boxtype)(define_FL_OVAL_BOX()+1)
    -#define FL_OVAL_FRAME (Fl_Boxtype)(define_FL_OVAL_BOX()+2)
    -#define FL_OFLAT_BOX (Fl_Boxtype)(define_FL_OVAL_BOX()+3)
    -
    -// conversions of box types to other boxtypes:
    -inline Fl_Boxtype down(Fl_Boxtype b) {return (Fl_Boxtype)(b|1);}
    -inline Fl_Boxtype frame(Fl_Boxtype b) {return (Fl_Boxtype)(b|2);}
    -
    -// back-compatability box types:
    -#define FL_FRAME FL_ENGRAVED_FRAME
    -#define FL_FRAME_BOX FL_ENGRAVED_BOX
    -#define FL_CIRCLE_BOX FL_ROUND_DOWN_BOX
    -#define FL_DIAMOND_BOX FL_DIAMOND_DOWN_BOX
    -
    -enum Fl_Labeltype {	// labeltypes:
    -  FL_NORMAL_LABEL	= 0,
    -  FL_NO_LABEL,
    -  _FL_SYMBOL_LABEL,
    -  _FL_SHADOW_LABEL,
    -  _FL_ENGRAVED_LABEL,
    -  _FL_EMBOSSED_LABEL,
    -  _FL_BITMAP_LABEL,
    -  _FL_PIXMAP_LABEL,
    -  _FL_IMAGE_LABEL,
    -  _FL_MULTI_LABEL,
    -  FL_FREE_LABELTYPE
    -};
    -extern Fl_Labeltype define_FL_SYMBOL_LABEL();
    -#define FL_SYMBOL_LABEL define_FL_SYMBOL_LABEL()
    -extern Fl_Labeltype define_FL_SHADOW_LABEL();
    -#define FL_SHADOW_LABEL define_FL_SHADOW_LABEL()
    -extern Fl_Labeltype define_FL_ENGRAVED_LABEL();
    -#define FL_ENGRAVED_LABEL define_FL_ENGRAVED_LABEL()
    -extern Fl_Labeltype define_FL_EMBOSSED_LABEL();
    -#define FL_EMBOSSED_LABEL define_FL_EMBOSSED_LABEL()
    -
    -enum Fl_Align {	// align() values
    -  FL_ALIGN_CENTER	= 0,
    -  FL_ALIGN_TOP		= 1,
    -  FL_ALIGN_BOTTOM	= 2,
    -  FL_ALIGN_LEFT		= 4,
    -  FL_ALIGN_RIGHT	= 8,
    -  FL_ALIGN_INSIDE	= 16,
    -  FL_ALIGN_CLIP		= 64,
    -  FL_ALIGN_WRAP		= 128,
    -  FL_ALIGN_TOP_LEFT	= FL_ALIGN_TOP | FL_ALIGN_LEFT,
    -  FL_ALIGN_TOP_RIGHT	= FL_ALIGN_TOP | FL_ALIGN_RIGHT,
    -  FL_ALIGN_BOTTOM_LEFT	= FL_ALIGN_BOTTOM | FL_ALIGN_LEFT,
    -  FL_ALIGN_BOTTOM_RIGHT	= FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT,
    -  FL_ALIGN_LEFT_TOP	= FL_ALIGN_TOP_LEFT,
    -  FL_ALIGN_RIGHT_TOP	= FL_ALIGN_TOP_RIGHT,
    -  FL_ALIGN_LEFT_BOTTOM	= FL_ALIGN_BOTTOM_LEFT,
    -  FL_ALIGN_RIGHT_BOTTOM	= FL_ALIGN_BOTTOM_RIGHT,
    -  FL_ALIGN_NOWRAP	= 0 // for back compatability
    -};
    -
    -enum Fl_Font {	// standard fonts
    -  FL_HELVETICA		= 0,
    -  FL_HELVETICA_BOLD,
    -  FL_HELVETICA_ITALIC,
    -  FL_HELVETICA_BOLD_ITALIC,
    -  FL_COURIER,
    -  FL_COURIER_BOLD,
    -  FL_COURIER_ITALIC,
    -  FL_COURIER_BOLD_ITALIC,
    -  FL_TIMES,
    -  FL_TIMES_BOLD,
    -  FL_TIMES_ITALIC,
    -  FL_TIMES_BOLD_ITALIC,
    -  FL_SYMBOL,
    -  FL_SCREEN,
    -  FL_SCREEN_BOLD,
    -  FL_ZAPF_DINGBATS,
    -
    -  FL_FREE_FONT		= 16,	// first one to allocate
    -  FL_BOLD		= 1,	// add this to helvetica, courier, or times
    -  FL_ITALIC		= 2	// add this to helvetica, courier, or times
    -};
    -
    -#define FL_NORMAL_SIZE	14	// default size of all labels & text
    -
    -enum Fl_Color {	// standard colors
    -  FL_BLACK		= 0,
    -  FL_RED		= 1,
    -  FL_GREEN		= 2,
    -  FL_YELLOW		= 3,
    -  FL_BLUE		= 4,
    -  FL_MAGENTA		= 5,
    -  FL_CYAN		= 6,
    -  FL_WHITE		= 7,
    -  FL_INACTIVE_COLOR	= 8,
    -  FL_SELECTION_COLOR	= 15,
    -
    -  FL_FREE_COLOR		= 16,
    -  FL_NUM_FREE_COLOR	= 16,
    -
    -  FL_GRAY_RAMP		= 32,
    -
    -  // boxtypes limit themselves to these colors so whole ramp is not allocated:
    -  FL_GRAY0		= 32,	// 'A'
    -  FL_DARK3		= 39,	// 'H'
    -  FL_DARK2		= 45,   // 'N'
    -  FL_DARK1		= 47,	// 'P'
    -  FL_GRAY		= 49,	// 'R' default color
    -  FL_LIGHT1		= 50,	// 'S'
    -  FL_LIGHT2		= 52,	// 'U'
    -  FL_LIGHT3		= 54,	// 'W'
    -
    -  FL_COLOR_CUBE		= 56
    -};
    -
    -inline Fl_Color inactive(Fl_Color c) {return (Fl_Color)(c|8);}
    -Fl_Color contrast(Fl_Color fg, Fl_Color bg);
    -#define FL_NUM_GRAY	24
    -inline Fl_Color fl_gray_ramp(int i) {return (Fl_Color)(i+FL_GRAY_RAMP);}
    -#define FL_NUM_RED	5
    -#define FL_NUM_GREEN	8
    -#define FL_NUM_BLUE	5
    -inline Fl_Color fl_color_cube(int r, int g, int b) {
    -  return (Fl_Color)((b*FL_NUM_RED + r) * FL_NUM_GREEN + g + FL_COLOR_CUBE);}
    -
    -enum Fl_Cursor {	// standard cursors
    -  FL_CURSOR_DEFAULT	= 0,
    -  FL_CURSOR_ARROW	= 35,
    -  FL_CURSOR_CROSS	= 66,
    -  FL_CURSOR_WAIT	= 76,
    -  FL_CURSOR_INSERT	= 77,
    -  FL_CURSOR_HAND	= 31,
    -  FL_CURSOR_HELP	= 47,
    -  FL_CURSOR_MOVE	= 27,
    -  // fltk provides bitmaps for these:
    -  FL_CURSOR_NS		= 78,
    -  FL_CURSOR_WE		= 79,
    -  FL_CURSOR_NWSE	= 80,
    -  FL_CURSOR_NESW	= 81,
    -  FL_CURSOR_NONE	= 255,
    -  // for back compatability (non MSWindows ones):
    -  FL_CURSOR_N		= 70,
    -  FL_CURSOR_NE		= 69,
    -  FL_CURSOR_E		= 49,
    -  FL_CURSOR_SE		= 8,
    -  FL_CURSOR_S		= 9,
    -  FL_CURSOR_SW		= 7,
    -  FL_CURSOR_W		= 36,
    -  FL_CURSOR_NW		= 68
    -  //FL_CURSOR_NS	= 22,
    -  //FL_CURSOR_WE	= 55,
    -};
    -
    -enum { // values for "when" passed to Fl::add_fd()
    -  FL_READ = 1,
    -  FL_WRITE = 4,
    -  FL_EXCEPT = 8
    -};
    -
    -enum Fl_Mode { // visual types and Fl_Gl_Window::mode() (values match Glut)
    -  FL_RGB	= 0,
    -  FL_INDEX	= 1,
    -  FL_SINGLE	= 0,
    -  FL_DOUBLE	= 2,
    -  FL_ACCUM	= 4,
    -  FL_ALPHA	= 8,
    -  FL_DEPTH	= 16,
    -  FL_STENCIL	= 32,
    -  FL_RGB8	= 64,
    -  FL_MULTISAMPLE= 128
    -};
    -
    -// damage masks
    -
    -enum Fl_Damage {
    -  FL_DAMAGE_CHILD    = 0x01,
    -  FL_DAMAGE_EXPOSE   = 0x02,
    -  FL_DAMAGE_SCROLL   = 0x04,
    -  FL_DAMAGE_OVERLAY  = 0x08,
    -  FL_DAMAGE_ALL      = 0x80
    -};
    -
    +

    C - FLTK Enumerations.H

    + +This appendix lists the enumerations provided in the +<FL/Enumerations.H> header file, organized by section. + +

    Version Numbers

    + +The FLTK version number is stored in a number of compile-time constants: + +
      + +
    • FL_MAJOR_VERSION - The major release number, currently + 1. + +
    • FL_MINOR_VERSION - The minor release number, currently + 0. + +
    • FL_PATCH_VERSION - The patch release number, currently + 0. + +
    • FL_VERSION - A combined floating-point version + number for the major and minor release numbers, currently 1.0. + +
    + +

    Events

    + +Events are identified by an Fl_Event enumeration value. The +following events are currently defined: + +
      + +
    • FL_NO_EVENT - No event occurred. + +
    • FL_PUSH - A mouse button was pushed. + +
    • FL_RELEASE - A mouse button was released. + +
    • FL_ENTER - The mouse pointer entered a widget. + +
    • FL_LEAVE - The mouse pointer left a widget. + +
    • FL_DRAG - The mouse pointer was moved with a button + pressed. + +
    • FL_FOCUS - A widget should receive keyboard focus. + +
    • FL_UNFOCUS - A widget loses keyboard focus. + +
    • FL_KEYBOARD - A key was pressed. + +
    • FL_CLOSE - A window was closed. + +
    • FL_MOVE - The mouse pointer was moved with no buttons + pressed. + +
    • FL_SHORTCUT - The user pressed a shortcut key. + +
    • FL_DEACTIVATE - The widget has been deactivated. + +
    • FL_ACTIVATE - The widget has been activated. + +
    • FL_HIDE - The widget has been hidden. + +
    • FL_SHOW - The widget has been shown. + +
    • FL_PASTE - The widget should paste the contents of the + clipboard. + +
    • FL_SELECTIONCLEAR - The widget should clear any selections + made for the clipboard. + +
    + +

    Callback "When" Conditions

    + +The following constants determine when a callback is performed: + +
      + +
    • FL_WHEN_NEVER - Never call the callback. + +
    • FL_WHEN_CHANGED - Do the callback only when the + widget value changes. + +
    • FL_WHEN_NOT_CHANGED - Do the callback whenever the + user interacts with the widget. + +
    • FL_WHEN_RELEASE - Do the callback when the button or + key is released and the value changes. + +
    • FL_WHEN_ENTER_KEY - Do the callback when the user presses + the ENTER key and the value changes. + +
    • FL_WHEN_RELEASE_ALWAYS - Do the callback when the button + or key is released, even if the value doesn't change. + +
    • FL_WHEN_ENTER_KEY_ALWAYS - Do the callback when the user + presses the ENTER key, even if the value doesn't change. + +
    + +

    Fl::event_key() Values

    + +The following constants define the non-ASCII keys on the keyboard for +FL_KEYBOARD and FL_SHORTCUT events: + +
      + +
    • FL_Button - A mouse button; use Fl_Button + + n for mouse button n. + +
    • FL_BackSpace - The backspace key. + +
    • FL_Tab - The tab key. + +
    • FL_Enter - The enter key. + +
    • FL_Pause - The pause key. + +
    • FL_Scroll_Lock - The scroll lock key. + +
    • FL_Escape - The escape key. + +
    • FL_Home - The home key. + +
    • FL_Left - The left arrow key. + +
    • FL_Up - The up arrow key. + +
    • FL_Right - The right arrow key. + +
    • FL_Down - The down arrow key. + +
    • FL_Page_Up - The page-up key. + +
    • FL_Page_Down - The page-down key. + +
    • FL_End - The end key. + +
    • FL_Print - The print (or print-screen) key. + +
    • FL_Insert - The insert key. + +
    • FL_Menu - The menu key. + +
    • FL_Num_Lock - The num lock key. + +
    • FL_KP - One of the keypad numbers; use FL_KP + + n for number n. + +
    • FL_KP_Enter - The enter key on the keypad. + +
    • FL_F - One of the function keys; use FL_F + + n for function key n. + +
    • FL_Shift_L - The lefthand shift key. + +
    • FL_Shift_R - The righthand shift key. + +
    • FL_Control_L - The lefthand control key. + +
    • FL_Control_R - The righthand control key. + +
    • FL_Caps_Lock - The caps lock key. + +
    • FL_Meta_L - The left meta/Windows key. + +
    • FL_Meta_R - The right meta/Windows key. + +
    • FL_Alt_L - The left alt key. + +
    • FL_Alt_R - The right alt key. + +
    • FL_Delete - The delete key. + +
    + +

    Fl::event_state() Values

    + +The following constants define bits in the Fl::event_state() +value: + +
      + +
    • FL_SHIFT - One of the shift keys is down. + +
    • FL_CAPS_LOCK - The caps lock is on. + +
    • FL_CTRL - One of the ctrl keys is down. + +
    • FL_ALT - One of the alt keys is down. + +
    • FL_NUM_LOCK - The num lock is on. + +
    • FL_META - One of the meta/Windows keys is down. + +
    • FL_SCROLL_LOCK - The scroll lock is on. + +
    • FL_BUTTON1 - Mouse button 1 is pushed. + +
    • FL_BUTTON2 - Mouse button 2 is pushed. + +
    • FL_BUTTON3 - Mouse button 3 is pushed. + +
    + +

    Alignment Values

    + +The following constants define bits that can be used with Fl_Widget::align() to control the +positioning of the label: + +
      + +
    • FL_ALIGN_CENTER - The label is centered. + +
    • FL_ALIGN_TOP - The label is top-aligned. + +
    • FL_ALIGN_BOTTOM - The label is bottom-aligned. + +
    • FL_ALIGN_LEFT - The label is left-aligned. + +
    • FL_ALIGN_RIGHT - The label is right-aligned. + +
    • FL_ALIGN_INSIDE - The label is put inside the widget. + +
    • FL_ALIGN_CLIP - The label is clipped to the widget. + +
    • FL_ALIGN_WRAP - The label text is wrapped as needed. + +
    + +

    Fonts

    + +The following constants define the standard FLTK fonts: + + + +
  • FL_HELVETICA - Helvetica (or Arial) normal. + +
  • FL_HELVETICA_BOLD - Helvetica (or Arial) bold. + +
  • FL_HELVETICA_ITALIC - Helvetica (or Arial) oblique. + +
  • FL_HELVETICA_BOLD_ITALIC - Helvetica (or Arial) bold-oblique. + +
  • FL_COURIER - Courier normal. + +
  • FL_COURIER_BOLD - Courier bold. + +
  • FL_COURIER_ITALIC - Courier italic. + +
  • FL_COURIER_BOLD_ITALIC - Courier bold-italic. + +
  • FL_TIMES - Times roman. + +
  • FL_TIMES_BOLD - Times bold. + +
  • FL_TIMES_ITALIC - Times italic. + +
  • FL_TIMES_BOLD_ITALIC - Times bold-italic. + +
  • FL_SYMBOL - Standard symbol font. + +
  • FL_SCREEN - Default monospaced screen font. + +
  • FL_SCREEN_BOLD - Default monospaced bold screen font. + +
  • FL_ZAPF_DINGBATS - Zapf-dingbats font. + + + +

    Colors

    + +The following color constants can be used to access the colors in the FLTK +standard color palette: + +
      + +
    • FL_BLACK + +
    • FL_RED + +
    • FL_GREEN + +
    • FL_YELLOW + +
    • FL_BLUE + +
    • FL_MAGENTA + +
    • FL_CYAN + +
    • FL_WHITE + +
    • FL_GRAY0 + +
    • FL_DARK3 + +
    • FL_DARK2 + +
    • FL_DARK1 + +
    • FL_GRAY + +
    • FL_LIGHT1 + +
    • FL_LIGHT2 + +
    • FL_LIGHT3 + +
    + +

    Cursors

    + +The following constants define the mouse cursors that are available in +FLTK: + +
      +
    • FL_CURSOR_DEFAULT - the default cursor, usually an arrow +
    • FL_CURSOR_ARROW - an arrow pointer +
    • FL_CURSOR_CROSS - crosshair +
    • FL_CURSOR_WAIT - watch or hourglass +
    • FL_CURSOR_INSERT - I-beam +
    • FL_CURSOR_HAND - hand (uparrow on MSWindows) +
    • FL_CURSOR_HELP - question mark +
    • FL_CURSOR_MOVE - 4-pointed arrow +
    • FL_CURSOR_NS - up/down arrow +
    • FL_CURSOR_WE - left/right arrow +
    • FL_CURSOR_NWSE - diagonal arrow +
    • FL_CURSOR_NESW - diagonal arrow +
    • FL_CURSOR_NONE - invisible +
    + +

    FD "When" Conditions

    + +
      + +
    • FL_READ - Call the callback when there is data to be + read. + +
    • FL_WRITE - Call the callback when data can be written + without blocking. + +
    • FL_EXCEPT - Call the callback if an exception occurs on + the file. + +
    + +

    Damage Masks

    + +The following damage mask bits are used by the standard FLTK widgets: + +
      + +
    • FL_DAMAGE_CHILD - A child needs to be redrawn. + +
    • FL_DAMAGE_EXPOSE - The window was exposed. + +
    • FL_DAMAGE_SCROLL - The Fl_Scroll widget was + scrolled. + +
    • FL_DAMAGE_OVERLAY - The overlay planes need to be redrawn. + +
    • FL_DAMAGE_ALL - Everything needs to be redrawn. + +
    + diff --git a/documentation/events.html b/documentation/events.html index b4b5f1513..c4bc8c052 100644 --- a/documentation/events.html +++ b/documentation/events.html @@ -1,499 +1,225 @@ -

    4 - Handling Events

    +

    6 - Handling Events

    This chapter discusses the FLTK event model and how to handle events in your program or widget.

    The FLTK Event Model

    -

    Mouse Events

    - -

    FL_PUSH

    - -

    FL_RELEASE

    - -

    FL_DRAG

    - -

    FL_MOVE

    - -

    Keyboard Events

    - -

    FL_KEYBOARD

    - -

    FL_SHORTCUT

    - -

    Widget Events

    - -

    FL_ACTIVATE

    - -

    FL_DEACTIVATE

    - -

    FL_HIDE

    - -

    FL_SHOW

    - -

    FL_FOCUS

    - -

    FL_UNFOCUS

    +Events are identified the small integer argument passed to the Fl_Widget::handle() virtual method. Other +information about the most recent event is stored in static locations +and acquired by calling the Fl::event_*() methods. This static +information remains valid until the next event is read from window +system (i.e. it is ok to look at it outside of the handle() method). -

    FL_ENTER

    - -

    FL_LEAVE

    - -

    FL_PASTE

    - -

    FL_SELECTIONCLEAR

    - - - -Events in Fltk - -

    Events in Fltk

    - -

    Events are identified the small integer argument passed to the Fl_Widget::handle() virtual method. -Other information about the most recent event is stored in static -locations and aquired by calling Fl::event_*(). This static -information remains valid until the next event is read from the X -server (that is, it is ok to look at it outside the handle() method). +

    Mouse Events

    -

    FL_PUSH (1)

      +

      FL_PUSH

      A mouse button has gone down with the mouse pointing at this widget. You can find out what button by calling Fl::event_button(). You find out the mouse -position by calling Fl::event_x() and -Fl::event_y(). +href="#event_button">Fl::event_button(). You find out the +mouse position by calling Fl::event_x() +and Fl::event_y().

      A widget indicates that it "wants" the mouse click by returning -non-zero from it's handle() method. -It will then become the Fl::pushed() widget and -will get FL_DRAG and the matching FL_RELEASE events. If handle() -returns zero then fltk will try sending the FL_PUSH to another widget. +non-zero from its handle() method. It +will then become the Fl::pushed() widget +and will get FL_DRAG and the matching FL_RELEASE +events. If handle() returns zero then FLTK will try sending +the FL_PUSH to another widget. -

    FL_DRAG (5)

      +

      FL_DRAG

      -The mouse has moved with the button held down. +The mouse has moved with a button held down. -

    FL_RELEASE (2)

    FL_ENTER (3)

      +

      FL_MOVE

      -The mouse has been moved to point at this widget. This can be used -for highlighting feedback. If a widget wants to highlight or -otherwise track the mouse, it indicates this by returning -non-zero from it's handle() method. -It then becomes the Fl::belowmouse() widget -and will receive FL_MOVE and FL_EXIT events. +The mouse has moved without any mouse buttons held down. This event +is sent to the belowmouse() widget. -

    FL_MOVE (10)

      +

      Focus Events

      -The mouse has moved without any mouse buttons held down. This event -is sent (sort of) to the belowmouse() widget. +

      FL_ENTER

      + +The mouse has been moved to point at this widget. This can be used for +highlighting feedback. If a widget wants to highlight or otherwise +track the mouse, it indicates this by returning non-zero from its handle() method. It then becomes the Fl::belowmouse() widget and will +receive FL_MOVE and FL_LEAVE events. -

    FL_LEAVE (4)

      +

      FL_LEAVE

      The mouse has moved out of the widget. -

    FL_FOCUS (6)

      +

      FL_FOCUS

      This indicates an attempt to give a widget the keyboard focus.

      If a widget wants the focus, it should change itself to display the -fact that it has the focus, and return non-zero from it's handle() method. It then becomes the Fl::focus() widget and gets FL_KEYBOARD and FL_UNFOCUS -events. +fact that it has the focus, and return non-zero from its handle() method. It then becomes the Fl::focus() widget and gets FL_KEYBOARD +and FL_UNFOCUS events.

      The focus will change either because the window manager changed which window gets the focus, or because the user tried to navigate using tab, arrows, or other keys. You can check Fl::event_key() to figure out why it moved. For -navigation it will be the key pressed, for instructions from the +href="#event_key">Fl::event_key() to figure out why it moved. For +navigation it will be the key pressed and for instructions from the window manager it will be zero. -

    FL_UNFOCUS (7)

      +

      FL_UNFOCUS

      -Sent to the old Fl::focus() when something else -gets the focus. +Sent to the previous Fl::focus() when +another widget gets the focus. + +

      Keyboard Events

      -

    FL_KEYBOARD (8)

      +

      FL_KEYBOARD

      A key press. The key pressed can be found in Fl::event_key(), or, more usefully, the text that -the key should insert can be found with Fl::event_text() and it's length is in Fl::event_length(). If you use the key -handle() should return 1. If you return zero then fltk assummes you -ignored the key. It will then attempt to send it to a parent widget. -If none of them want it, it will change the event into a FL_SHORTCUT -event. - -

    FL_SHORTCUT (11)

      - -If the Fl::focus() is zero or ignores an -FL_KEYBOARD event then fltk tries sending this event to every widget -it can, until one of them returns non-zero. FL_SHORTCUT is first sent -to the belowmouse widget, then it's parents and siblings, and -eventually to every widget in the window, trying to find an object -that returns non-zero. Fltk tries real hard to not let any keystrokes -be ignored! - -

      If the Fl::event_text() is a lower or -upper-case letter, and nothing wants the shortcut +href="#event_key">Fl::event_key(). The text that the key +should insert can be found with Fl::event_text() and its length is in +Fl::event_length(). If you use +the key handle() should return 1. If you return zero then +FLTK assummes you ignored the key. It will then attempt to send it to +a parent widget. If none of them want it, it will change the event into +a FL_SHORTCUT event. + +

      FL_SHORTCUT

      + +If the Fl::focus() is zero or ignores an +FL_KEYBOARD event then FLTK tries sending this event to every +widget it can, until one of them returns non-zero. +FL_SHORTCUT is first sent to the belowmouse() widget, +then its parents and siblings, and eventually to every widget in the +window, trying to find an object that returns non-zero. FLTK tries +really hard to not to ignore any keystrokes!

      You can also make "global" shortcuts by using Fl::add_handler(). A global shortcut will work -no matter what windows are displayed or which one has the focus. +href="#add_handler">Fl::add_handler(). A global shortcut +will work no matter what windows are displayed or which one has the +focus. + +

      Widget Events

      -

    FL_DEACTIVATE (13)

      +

      FL_DEACTIVATE

      This widget is no longer active, due to deactivate() being called on it or one -of it's parents. active() may still be true after this, the widget is -only active if active() is true on it and all it's parents. +href="#Fl_Widget.deactivate">deactivate() being called on +it or one of its parents. active() may still be true after this, the +widget is only active if active() is true on it and all its parents +(use active_r() to check this). -

    FL_ACTIVATE (14)

      +

      FL_ACTIVATE

      This widget is now active, due to active() being called on it or one -of it's parents. +href="#Fl_Widget.activate">activate() being called on it +or one of its parents. -

    FL_HIDE (15)

      +

      FL_HIDE

      This widget is no longer visible, due to hide() being called, or a parent group -or window having hide() be called, or due to a parent window being -iconized. visible() may still be true after this, the widget is -visible only if visible() is true for it and all it's parents. +href="#Fl_Widget.hide>hide() being called on it or one of its +parents, or due to a parent window being minimized. visible() +may still be true after this, but the widget is visible only if +visible() is true for it and all its parents (use +visible_r() to check this). -

    FL_SHOW (16)

      +

      FL_SHOW

      This widget is visible again, due to show() being called on it or one of -it's parents, or due to a parent window being deiconized. Child -Fl_Windows respond to this by actually creating the X window if not -done already, so if you subclass a window, be sure to pass FL_SHOW to -the base class handle() method! +href="#Fl_Widget.show">show() being called on it or one of +its parents, or due to a parent window being restored. Child +Fl_Windows respond to this by actually creating the window if not +done already, so if you subclass a window, be sure to pass FL_SHOW to +the base class handle() method! + +

      Clipboard Events

      - -

    FL_PASTE (17)

    FL_SELECTIONCLEAR (18)

      +

      FL_SELECTIONCLEAR

      -The Fl::selection_owner() will get this +The Fl::selection_owner() will get this event before the selection is moved to another widget. This indicates that some other widget or program has claimed the selection. -
    - - -

    Fl::event_*() methods

    +

    Fl::event_*() methods

    -Fltk keeps the information about the most recent event in static +FLTK keeps the information about the most recent event in static storage. This information is good until the next event is processed. -Thus it is valid inside handle() and callback() methods. +Thus it is valid inside handle() and callback() methods.

    These are all trivial inline functions and thus very fast and -small. The data is stored in static locations and remains valid until -the next X event is handled. - - -

    int Fl::event_button();

    int Fl::event_x() -
    int Fl::event_y()

    int Fl::event_x_root() -
    int Fl::event_y_root()

    void Fl::get_mouse(int &,int &)

    ulong Fl::event_state(); -
    unsigned int Fl::event_state(int);

    int Fl::event_key(); -
    int Fl::event_key(int); -
    int Fl::get_key(int);

    char * Fl::event_text()

    char * Fl::event_length()

    int Fl::event_is_click()

    void Fl::event_is_click(0)

    int Fl::event_clicks()

    void Fl::event_clicks(int)

    int Fl::event_inside(const Fl_Widget *) const ; -
    int Fl::event_inside(int,int,int,int);

    int Fl::test_shortcut(ulong) const ;

    Fl_Widget *Fl::focus() const; -
    void Fl::focus(Fl_Widget *);

    int Fl_Widget::take_focus();

    Fl_Widget *Fl::belowmouse() const; -
    void Fl::belowmouse(Fl_Widget *);

    Fl_Widget *Fl::pushed() const; -
    void Fl::pushed(Fl_Widget *);

    void Fl::add_handler(int (*f)(int));

    -

    Some versions of Make will accept rules like this to allow all .fl +Some versions of make will accept rules like this to allow all .fl files found to be compiled: -

    -.SUFFIXES : .fl .C .H
    -.fl.H :
    +
      +.SUFFIXES: .fl .cxx .h
      +.fl.h .fl.cxx:
       	fluid -c $<
      -.fl.C :
      -	fluid -c $<
      -
      - -

      Some versions of Make (gnumake) may prefer this syntax: - -

      -%.H: %.fl
      -        fluid -c $<
      -
      -%.C: %.fl
      -        fluid -c $<
      -
      +
    -

    The Widget Browser

    -

    + + + + + +
    -

    The main window shows a menu bar and a scrolling browser of all the +The main window shows a menu bar and a scrolling browser of all the defined widgets. The name of the .fl file being edited is shown in the window title.

    The widgets are stored in a hierarchy. You can open and close a level by clicking the "triangle" at the left of a widget. This -widget is the parent, and all the widgets listed below it are it's +widget is the parent, and all the widgets listed below it are its children. There can be zero children.

    The top level of the hierarchy is functions. Each of these -will produce a single C++ public function in the output .C file. -Calling the function will create all of it's child windows. +will produce a single C++ public function in the output .cxx file. +Calling the function will create all of its child windows.

    The second level of the hierarchy is windows. Each of these produces an instance of class Fl_Window. @@ -277,7 +247,12 @@ provide the well-known file-card tab interface. as "main_panel" in the example), or if unnamed as their type and label (such as "Button "the green""). -

    You select widgets by clicking on their names, which +

    + +You select widgets by clicking on their names, which highlights them (you can also select widgets from any displayed window). You can select many widgets by dragging the mouse across them, or by using shift+click to toggle them on and off. To select no @@ -289,74 +264,73 @@ this. widgets you have picked) by typing the F1 key. This will bring up a control panel or window from which you can change the widget. -

    Menu Items

    The menu bar at the top is duplicated as a pop-up menu on any displayed window. The shortcuts for all the menu items work in any window. The menu items are: -

    File/Open... (Alt+Shift+O)

      +

      File/Open... (Alt+Shift+O)

      Discard the current editing session and read in a different .fl file. You are asked for confirmation if you have changed the current data. -

      fluid can also read .fd files produced by the Forms and XForms -"fdesign" programs. It is best to read them with Merge. Fluid does not +

      FLUID can also read .fd files produced by the Forms and XForms +"fdesign" programs. It is best to read them with Merge. FLUID does not understand everything in a .fd file, and will print a warning message on the controlling terminal for all data it does not understand. You will probably need to edit the resulting setup to fix these errors. -Be careful not to save the file without changing the name, as fluid -will write over the .fd file with it's own format, which fdesign +Be careful not to save the file without changing the name, as FLUID +will write over the .fd file with its own format, which fdesign cannot read! -

    File/Save (Alt+s)

      +

      File/Save (Alt+s)

      Write the current data to the .fl file. If the file is unnamed -(because fluid was started with no name) then ask for a file name. +(because FLUID was started with no name) then ask for a file name. -

    File/Save As...(Alt+Shift+S)

      +

      File/Save As...(Alt+Shift+S)

      Ask for a new name to save the file as, and save it. -

    File/Merge... (Alt+i)

      +

      File/Merge... (Alt+i)

      Insert the contents of another .fl file, without changing the name of the current .fl file. All the functions (even if they have the same names as the current ones) are added, you will have to use cut/paste to put the widgets where you want. -

    File/Write code (Alt+Shift+C)

      +

      File/Write code (Alt+Shift+C)

      -"Compiles" the data into a .C and .H file. These are exactly the same -as the files you get when you run fluid with the -c switch. +"Compiles" the data into a .cxx and .h file. These are exactly the same +as the files you get when you run FLUID with the -c switch.

      The output file names are the same as the .fl file, with the -leading directory and trailing ".fl" stripped, and ".H" or ".C" +leading directory and trailing ".fl" stripped, and ".h" or ".cxx" appended. Currently there is no way to override this. -

    File/Quit (Alt+q)

      +

      File/Quit (Alt+q)

      -Exit fluid. You are asked for confirmation if you have changed the +Exit FLUID. You are asked for confirmation if you have changed the current data. -

    Edit/Undo (Alt+z)

      +

      Edit/Undo (Alt+z)

      Don't you wish... This isn't implemented yet. You should do save often so that any mistakes you make don't irretrivably destroy your data. -

    Edit/Cut (Alt+x)

      +

      Edit/Cut (Alt+x)

      Delete the selected widgets and all their children. These are saved to a "clipboard" file (/usr/tmp/cut_buffer.fl) and can be pasted back -into this fluid or any other one. +into this FLUID or any other one. -

    Edit/Copy (Alt+c)

      +

      Edit/Copy (Alt+c)

      Copy the selected widgets and all their children to the "clipboard" file. -

    Edit/Paste (Alt+c)

      +

      Edit/Paste (Alt+c)

      Paste in the widgets in the clipboard file. @@ -372,7 +346,7 @@ doing a paste.

      Cut/paste is the only way to change the parent of a widget. -

    Edit/Select All (Alt+a)

      +

      Edit/Select All (Alt+a)

      Select all widgets in the same group as the current selection. @@ -380,20 +354,20 @@ Select all widgets in the same group as the current selection. that group's parent. Repeatedly typing Alt+a will select larger and larger groups of widgets until everything is selected. -

    Edit/Open... (F1 or double click)

      +

      Edit/Open... (F1 or double click)

      If the current widget is a window and it is not displayed, display it. Otherwise open a control panel for the most recent (and possibly all) selected widgets. -

    Edit/Sort

      +

      Edit/Sort

      All the selected widgets are sorted into left to right, top to bottom -order. You need to do this to make navigation keys in fltk work +order. You need to do this to make navigation keys in FLTK work correctly. You may then fine-tune the sorting with "Earlier" and "Later". This does not affect the positions of windows or functions. -

    Edit/Earlier (F2)

      +

      Edit/Earlier (F2)

      All the selected widgets are moved one earlier in order amoung the children of their parent (if possible). This will affect navigation @@ -401,35 +375,35 @@ order, and if the widgets overlap it will affect how they draw, as the later widget is drawn on top of the earlier one. You can also use this to reorder functions and windows within functions. -

    Edit/Later (F3)

      +

      Edit/Later (F3)

      All the selected widgets are moved one later in order amoung the children of their parent (if possible). -

    Edit/Group (F7)

      +

      Edit/Group (F7)

      Create a new Fl_Group and make all the currently selected widgets be children of it. -

    Edit/Ungroup (F8)

      +

      Edit/Ungroup (F8)

      If all the children of a group are selected, delete that group and -make them all be children of it's parent. +make them all be children of its parent. -

    Edit/Overlays on/off (Alt+o)

      +

      Edit/Overlays on/off (Alt+o)

      Toggle the display of the red overlays off, without changing the selection. This makes it easier to see box borders and how the layout looks. The overlays will be forced back on if you change the selection. -

    Edit/Preferences (Alt+p)

      +

      Edit/Preferences (Alt+p)

      Currently the only preferences are for the "alignment grid" that all widgets snap to when you move them and resize them, and for the "snap" -which is how far a widget has to be dragged from it's original +which is how far a widget has to be dragged from its original position to actually change. -

    New/code/Function

      +

      New/code/Function

      Create a new C function. You will be asked for a name for the function. This name should be a legal C++ function template, without @@ -441,17 +415,17 @@ as returning an Fl_Window*. The unnamed window will be returned from it (more than one unnamed window is useless). If the function contains only named windows it will be declared as returning void. -

      It is possible to make the .C output be a self-contained program +

      It is possible to make the .cxx output be a self-contained program that can be compiled and executed. This is done by deleting the function name, in which case "main(argc,argv)" is used. The function will call show() on all the windows it creates and then call Fl::run(). This can be used to test resize behavior or other parts of the user interface. I'm not sure if it is possible to create really -useful programs using just Fluid. +useful programs using just FLUID.

      You can change the function name by double clicking the function. -

    New/Window

      +

      New/Window

      Create a new Fl_Window. It is added to the currently selected function, or to the function containing the currently selected item. @@ -461,7 +435,7 @@ to whatever size you require.

      You also get the window's control panel, which is almost exactly the same as any other Fl_Widget, and is described in the next chapter. -

    New/...

      +

      New/...

      All other items on the New menu are subclasses of Fl_Widget. Creating them will add them to the currently selected group or window, or the @@ -472,29 +446,28 @@ possible.

      When you create the widget you will get the widget's control panel, described in the next chapter. -

    Help/About fluid

      - -Pops up a panel showing the version of fluid. +

      Help/About FLUID

      -

    Help/Manual

      +Pops up a panel showing the version of FLUID. -Not yet implemented. Use netscape to read these pages instead. +

      Help/Manual

      -
    +Not yet implemented. Use a HTML or PDF file viewer to read these pages +instead. -

    The Widget Panel

    -When you double-click a widget or a set of widgets you will get the -"widget attribute panel": + + + + + +
    -

    +When you double-click a widget or a set of widgets you will get the +"widget attribute panel". -

    When you change attributes -using this panel, the changes are reflected immediately in the window. -It is useful to hit the "no overlay" button (or type Alt+o) to -hide the red overlay so you can see the widgets more accurately, -especially when setting the box type. +

    When you change attributes using this panel, the changes are +reflected immediately in the window. It is useful to hit the "no +overlay" button (or type Alt+o) to hide the red overlay so you can see +the widgets more accurately, especially when setting the box type.

    If you have several widgets selected, they may have different values for the fields. In this case the value for one of the @@ -502,12 +475,17 @@ widgets is shown. But if you change this value, all the selected widgets are changed to the new value.

    Hitting "OK" makes the changes permanent. Selecting a different -widget also makes the changes permanent. Fluid checks for simple +widget also makes the changes permanent. FLUID checks for simple syntax errors in any code (such as mismatched parenthesis) before saving any text. -

    "Revert" or "Cancel" put everything back to when you last brought -up the panel or hit OK. However in the current version of Fluid, +

    + +"Revert" or "Cancel" put everything back to when you last brought +up the panel or hit OK. However in the current version of FLUID, changes to "visible" attributes (such as the color, label, box) are not undone by revert or cancel. Changes to code like the callbacks is undone, however. @@ -515,55 +493,55 @@ is undone, however.

    Widget Attributes

    -

    Name (text field)

      +

      Name (text field)

      Name of a global C variable to declare, and to store a pointer to this widget into. This variable will be of type "<class>*". If the name is blank then no variable is created.

      You can name several widgets with "name[0]", "name[1]", "name[2]", -etc. This will cause Fluid to declare an array of pointers. The +etc. This will cause FLUID to declare an array of pointers. The array is big enough that the highest number found can be stored. All widgets that in the array must be the same type. -

    Type (upper-right pulldown menu)

      +

      Type (upper-right pulldown menu)

      Some classes have subtypes that modify their appearance or behavior. You pick the subtype off of this menu. -

    Box (pulldown menu)

      +

      Box (pulldown menu)

      The boxtype to draw as a background for the widget.

      Many widgets will work, and draw faster, with a "frame" instead of a "box". A frame does not draw the colored interior, leaving whatever -was already there visible. Be careful, as fluid may draw this ok but +was already there visible. Be careful, as FLUID may draw this ok but the real program leave unwanted stuff inside the widget.

      If a window is filled with child widgets, you can speed up -redrawing by changing the window's box type to "NO_BOX". Fluid will +redrawing by changing the window's box type to "NO_BOX". FLUID will display a checkerboard for any areas that are not colored in by boxes (notice that this checkerboard is not drawn by the resulting program, instead random garbage is left there). -

    Color

      +

      Color

      The color to draw the box with. -

    Color2

      +

      Color2

      -

      Some widgets will use this color for certain parts. Fluid does not +

      Some widgets will use this color for certain parts. FLUID does not always show the result of this: this is the color buttons draw in when pushed down, and the color of input fields when they have the focus. -

    Label

      +

      Label

      String to print next to or inside the button.

      You can put newlines into the string to make multiple lines, the easiest way is by typing ctrl+j. -

    Label style (pull down menu)

    Label alignement (buttons)

      +

      Label alignement (buttons)

      Where to draw the label. The arrows put it on that side of the widget, you can combine the to put it in the corner. The "box" button puts the label inside the widget, rather than outside. -

    Label font

      +

      Label font

      Font to draw the label in. Ignored by symbols, bitmaps, and pixmaps. Your program can change the actual font used by these "slots", in case you want some font other than the 16 provided. -

    Label size

      +

      Label size

      Point size for the font to draw the label in. Ignored by symbols, bitmaps, and pixmaps. To see the result without dismissing the panel, type the new number and then Tab. -

    Label color

      +

      Label color

      Color to draw the label. Ignored by pixmaps (bitmaps, however, do use this color as the foreground color). -

    Text font, size, color

      +

      Text font, size, color

      Some widgets display text, such as input fields, pull-down menus, browsers. You can change this here. -

    Visible

      +

      Visible

      If you turn this off the widget is hidden initially. Don't change this for windows or for the immediate children of a Tabs group. -

    Active

      +

      Active

      If you turn this off the widget is deactivated initially. Currently -no fltk widgets display the fact that they are inactive (like by graying +no FLTK widgets display the fact that they are inactive (like by graying out), but this may change in the future. -

    Resizable

      +

      Resizable

      If a window is resizable or has an immediate child that is resizable, then the user will be able to resize it. In addition all the size @@ -627,41 +605,41 @@ other children.

      You can get more complex behavior by making invisible boxes the resizable widget, or by using hierarchies of groups. Unfortunatley -the only way to test it is to compile the program. Resizing the fluid +the only way to test it is to compile the program. Resizing the FLUID window is not the same as what will happen in the user program. -

    Hotspot

      +

      Hotspot

      Each window may have exactly one hotspot (turning this on will turn off any others). This will cause it to be positioned with that widget -centered on the mouse. This position is determined when the fluid +centered on the mouse. This position is determined when the FLUID function is called, so you should call it immediately before showing the window. If you want the window to hide and then reappear at a new position, you should have your program set the hotspot itself just before show(). -

    subclass

      +

      subclass

      This is how you put your own subclasses of Fl_Widget in. Whatever identifier you type in here will be the class that is instantiated. -

      In addition, no #include header file is put in the .H file. You +

      In addition, no #include header file is put in the .h file. You must provide a #include line as the first of the "extra code" which declares your subclass.

      The class had better be similar to the class you are spoofing. It does not have to be a subclass. It is sometimes useful to change this -to another fltk class: currently the only way to get a double-buffered +to another FLTK class: currently the only way to get a double-buffered window is to change this field for the window to "Fl_Double_Window" -and to add "#include <FL/Fl_Double_Window.H>" to the extra code. +and to add "#include <FL/Fl_Double_Window.h>" to the extra code. -

    Extra code

      +

      Extra code

      These four fields let you type in literal lines of code to dump into -the .H or .C files. +the .h or .cxx files. -

      If the text starts with a '#' or the word "extern" then fluid -thinks this is an "include" line, and it is written to the .H file. +

      If the text starts with a '#' or the word "extern" then FLUID +thinks this is an "include" line, and it is written to the .h file. If the same include line occurs several times then only one copy is written. @@ -671,37 +649,37 @@ pointed to by the local variable 'w'. You can also access any arguments passed to the function here, and any named widgets that are before this one. -

      Fluid will check for matching parenthesis, braces, and quotes, but +

      FLUID will check for matching parenthesis, braces, and quotes, but does not do much other error checking. Be careful here, as it may be hard to figure out what widget is producing an error in the compiler. If you need more than 4 lines you probably should call a function in -your own .C code. +your own .cxx code. -

    Callback

      +

      Callback

      This can either be the name of a function, or a small snippet of -code. Fluid thinks that if there is any punctuation then it is code. +code. FLUID thinks that if there is any punctuation then it is code.

      A name names a function in your own code. It must be declared as "void <name>(<class>*,void*)". -

      A code snippet is inserted into a static function in the .C output +

      A code snippet is inserted into a static function in the .cxx output file. The function prototype is "void f(<class>* o, void* v)", so you can refer to -the widget as 'o' and the user_data as 'v'. Fluid will check for +the widget as 'o' and the user_data as 'v'. FLUID will check for matching parenthesis, braces, and quotes, but does not do much other error checking. Be careful here, as it may be hard to figure out what widget is producing an error in the compiler.

      If the callback is blank then no callback is set. -

    user_data

      +

      user_data

      This is a value for the user_data() of the widget. If blank the default value of zero is used. This can be any piece of C code that can be put "(void*)(<here>)". -

    User data type

      +

      User data type

      The "void*" in the callback function prototypes is replaced with this. You may want to use "long" for old XForms code. Be warned that @@ -709,7 +687,7 @@ anything other than "void*" is not guaranteed to work by the C++ spec! However on most architectures other pointer types are ok, and long is usually ok. -

    When

      +

      When

      When to do the callback. Can be "never", "changed", "release". The value of "enter key" is only useful for text input fields. The "no @@ -720,8 +698,6 @@ if the data is not changed. are not in the menu. You should use the extra code fields to put these values in. -
    -

    Selecting & Moving Widgets

    @@ -754,7 +730,7 @@ hierarchy. Hit the right arrow enough and you will select every widget in the window. Up/down widgets move to the previous/next widgets that overlap horizontally. If the navigation does not seem to work you probably need to "Sort" the widgets. This is important if -you have input fields, as fltk uses the same rules when using arrow keys +you have input fields, as FLTK uses the same rules when using arrow keys to move between input fields.

    To "open" a widget, double click it. To open several widgets @@ -764,7 +740,7 @@ select them and then type F1 or pick "Edit/Open" off the pop-up menu. the selection, so you can see the widget borders.

    You can resize the window by using the window manager border -controls. Fltk will attempt to round the window size to the nearest +controls. FLTK will attempt to round the window size to the nearest multiple of the grid size and makes it big enough to contain all the widgets (it does this using illegal X methods, so it is possible it will barf with some window managers!). Notice that the actual window @@ -775,21 +751,19 @@ child widgets may be different. almost identical to the panel for any other Fl_Widget. There are three extra items: -

    Border

      +

      Border

      This button turns the window manager border on or off. On most window managers you will have to close the window and reopen it to see the effect. -

    xclass

      +

      xclass

      The string typed into here is passed to the X window manager as the class. This can change the icon or window decorations. On most (all?) window managers you will have to close the window and reopen it to see the effect. -
    -

    Image Labels

    @@ -799,8 +773,8 @@ already been chosen, you can change the image used by picking "Image..." again. The name of the image will appear in the "label" field, but you can't edit it. -

    The contents of the image file are written to the .C file, -so if you wish to distribute the C code, you only need to copy the .C +

    The contents of the image file are written to the .cxx file, +so if you wish to distribute the C code, you only need to copy the .cxx file, not the images. If many widgets share the same image then only one copy is written. @@ -810,9 +784,9 @@ to the location the .fl file is (not necessarily the current directory). I recommend you either put the images in the same directory as the .fl file, or use absolute path names. -

    Notes for all image types

      +

      Notes for all image types

      -

      Fluid runs using the default visual of your X server. This may be +

      FLUID runs using the default visual of your X server. This may be 8 bits, which will give you dithered images. You may get better results in your actual program by adding the code "Fl::visual(FL_RGB)" to your code right before the first window is displayed. @@ -822,12 +796,12 @@ source X pixmap. Thus once you have put an image on a widget, it is nearly free to put the same image on many other widgets.

      If you are using a painting program to edit an image: the only way -to convince Fluid to read the image file again is to remove the image +to convince FLUID to read the image file again is to remove the image from all widgets that are using it (including ones in closed windows), -which will cause it to free it's internal copy, and then set the image -again. You may find it easier to exit Fluid and run it again. +which will cause it to free its internal copy, and then set the image +again. You may find it easier to exit FLUID and run it again. -

      Don't rely on how fltk crops images that are outside the widget, as +

      Don't rely on how FLTK crops images that are outside the widget, as this may change in future versions! The cropping of inside labels will probably be unchanged. @@ -838,57 +812,55 @@ and you want the image inside it, you must change the button's boxtype to FL_UP_FRAME (or another frame), otherwise when it is pushed it will erase the image. -

    XBM (X bitmap files)

      +

      XBM (X bitmap files)

      -

      Fluid will read X bitmap files. These files have C source code to +

      FLUID will read X bitmap files. These files have C source code to define a bitmap. Sometimes they are stored with the ".h" or ".bm" extension rather than the standard ".xbm". -

      Fluid will output code to construct an Fl_Bitmap widget and use it +

      FLUID will output code to construct an Fl_Bitmap widget and use it to label the widget. The '1' bits in the bitmap are drawn using the -label color of the widget. You can change the color in Fluid. The +label color of the widget. You can change the color in FLUID. The '0' bits are transparent.

      The program "bitmap" on the X distribution does an ok job of editing bitmaps. -

    XPM (X pixmap files)

    GIF files

      +

      GIF files

      -

      Fluid will also read GIF image files. These files are often used +

      FLUID will also read GIF image files. These files are often used on html documents to make icons. This lets you use nice icons that you steal off the net in your user interface. -

      Fluid converts these into (modified) xpm -format and uses an Fl_Pixmap widget to label the widget. Transparency -is handled the same as for xpm files. Notice that the conversion -removes the compression, so the code may be much bigger than the .gif -file. Only the first image of an animated gif file is used. +

      FLUID converts these into (modified) XPM format and uses an +Fl_Pixmap widget to label the widget. Transparency is handled the same +as for xpm files. Notice that the conversion removes the compression, +so the code may be much bigger than the .gif file. Only the first +image of an animated gif file is used.

      Behavior and performance with large .gif files is not guaranteed! -

    - -

    (back to contents) + + diff --git a/documentation/forms.html b/documentation/forms.html index 1d6614581..c1c69cf0e 100644 --- a/documentation/forms.html +++ b/documentation/forms.html @@ -3,182 +3,193 @@

    E - Forms Compatibility

    -Fluid (the Fast Light User Interface Designer) -can read the .fd files put out by all versions of Forms and XForms -fdesign. However, it will mangle them a bit, but it prints a warning -message about anything it does not understand. Fluid cannot write -fdesign files, so you should save to a new name so you don't write -over the old one. +This appendix describes the Forms compatibility included with FLTK. + +

    Importing Forms Layout Files

    + +FLUID can read the .fd files put out by all +versions of Forms and XForms fdesign. However, it will mangle them a +bit, but it prints a warning message about anything it does not +understand. FLUID cannot write fdesign files, so you should save to a +new name so you don't write over the old one.

    You will need to edit your main code considerably to get it to link -with the output from fluid. If you are not interested in this you may -have more immediate luck with the forms compatability header, +with the output from FLUID. If you are not interested in this you may +have more immediate luck with the forms compatibility header, <FL/forms.H>. -

    You should be able to compile existing Forms or XForms source code -by changing the -I switch to your compiler so that the forms.h file -supplied with FLTK is included. Take a look at forms.h to see how it -works, but the basic trick is lots of inline functions. -Most of the XForms demo programs work without changes. +

    Using the Compatibility Header File

    + +You should be able to compile existing Forms or XForms source code +by changing the include directory switch to your compiler so that the +forms.h file supplied with FLTK is included. Take a look at +forms.h to see how it works, but the basic trick is lots of +inline functions. Most of the XForms demo programs work without +changes. + +

    You will also have to compile your Forms or XForms program using a +C++ compiler. The FLTK library does not provide C bindings or header +files.

    Although FLTK was designed to be compatable with the GL Forms library (version 0.3 or so), XForms has bloated severely and it's interface is -X specific. Therefore, XForms compatability is no longer a goal of -FLTK. Compatability was limited to things that were free, or that -would add code that would not be linked in if the feature is unused. -I did not add anything that would make the FLTK widgets bigger, or that -used X types as arguments. +X-specific. Therefore, XForms compatibility is no longer a goal of +FLTK. Compatibility was limited to things that were free, or that +would add code that would not be linked in if the feature is unused, +or that was not X-specific.

    To use any new features of FLTK, you should rewrite your code to not -use the inline functions and instead use "pure" FLTK. This -will make it a lot cleaner and make it easier to figure out how to -call the FLTK functions. Unfortunately this conversion is harder than I -expeceted and even our inhouse code still uses forms.H a lot. +use the inline functions and instead use "pure" FLTK. This will make +it a lot cleaner and make it easier to figure out how to call the FLTK +functions. Unfortunately this conversion is harder than expected and +even Digital Domain's inhouse code still uses forms.H a lot.

    Problems you will encounter

    -