1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Portable drawing function header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2009-01-01 19:11:32 +03:00
|
|
|
// Copyright 1998-2009 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-08 01:07:12 +04:00
|
|
|
/**
|
|
|
|
\file fl_draw.H
|
|
|
|
\brief utility header to pull drawing functions together
|
|
|
|
*/
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
#ifndef fl_draw_H
|
|
|
|
#define fl_draw_H
|
|
|
|
|
|
|
|
#include "Enumerations.H" // for the color names
|
2008-12-27 22:22:30 +03:00
|
|
|
#include "Fl_Window.H" // for fl_set_spot()
|
2010-03-14 21:07:24 +03:00
|
|
|
#include "Fl_Device.H"
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2001-08-06 03:58:54 +04:00
|
|
|
// Image class...
|
|
|
|
class Fl_Image;
|
|
|
|
|
|
|
|
// Label flags...
|
|
|
|
FL_EXPORT extern char fl_draw_shortcut;
|
2010-03-24 13:24:37 +03:00
|
|
|
/** \brief The device that currently receives all graphics requests */
|
2010-03-22 09:17:47 +03:00
|
|
|
FL_EXPORT extern Fl_Device *fl_device;
|
2001-08-06 03:58:54 +04:00
|
|
|
|
2008-12-28 14:21:03 +03:00
|
|
|
/** \addtogroup fl_attributes
|
|
|
|
@{
|
|
|
|
*/
|
2010-03-21 11:26:40 +03:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
// Colors:
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Sets the color for all subsequent drawing operations.
|
|
|
|
For colormapped displays, a color cell will be allocated out of
|
|
|
|
\p 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.
|
|
|
|
If no valid graphical context (fl_gc) is available,
|
|
|
|
the foreground is not set for the current window.
|
2010-03-24 13:24:37 +03:00
|
|
|
\param[in] c color
|
2010-03-21 11:26:40 +03:00
|
|
|
*/
|
2010-03-24 13:24:37 +03:00
|
|
|
inline void fl_color(Fl_Color c) {fl_device->color(c); }; // select indexed color
|
2008-10-16 01:38:38 +04:00
|
|
|
/** for back compatibility - use fl_color(Fl_Color c) instead */
|
|
|
|
inline void fl_color(int c) {fl_color((Fl_Color)c);}
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
If no valid graphical context (fl_gc) is available,
|
|
|
|
the foreground is not set for the current window.
|
|
|
|
\param[in] r,g,b color components
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_color(uchar r, uchar g, uchar b) {fl_device->color(r,g,b); }; // select actual color
|
2010-03-24 13:24:37 +03:00
|
|
|
/** \brief The current color */
|
1999-02-17 01:00:04 +03:00
|
|
|
extern FL_EXPORT Fl_Color fl_color_;
|
2008-10-08 01:07:12 +04:00
|
|
|
/**
|
|
|
|
Returns the last fl_color() that was set.
|
|
|
|
This can be used for state save/restore.
|
|
|
|
*/
|
1999-02-17 01:00:04 +03:00
|
|
|
inline Fl_Color fl_color() {return fl_color_;}
|
2008-12-28 14:21:03 +03:00
|
|
|
/** @} */
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-12-28 14:21:03 +03:00
|
|
|
/** \addtogroup fl_drawings
|
|
|
|
@{
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
// clip:
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Intersects the current clip region with a rectangle and pushes this
|
|
|
|
new region onto the stack.
|
|
|
|
\param[in] x,y,w,h position and size
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_push_clip(int x, int y, int w, int h) {fl_device->push_clip(x,y,w,h); };
|
2008-10-08 01:07:12 +04:00
|
|
|
/** The fl_clip() name is deprecated and will be removed from future releases */
|
2002-06-12 00:58:12 +04:00
|
|
|
#define fl_clip fl_push_clip
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Pushes an empty clip region onto the stack so nothing will be clipped.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_push_no_clip() {fl_device->push_no_clip(); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Restores the previous clip region.
|
|
|
|
|
|
|
|
You must call fl_pop_clip() once for every time you call fl_push_clip().
|
|
|
|
Unpredictable results may occur if the clip stack is not empty when
|
|
|
|
you return to FLTK.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_pop_clip() {fl_device->pop_clip(); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Does the rectangle intersect the current clip region?
|
|
|
|
\param[in] x,y,w,h position and size of rectangle
|
|
|
|
\returns non-zero if any of the rectangle intersects the current clip
|
|
|
|
region. If this returns 0 you don't have to draw the object.
|
|
|
|
|
|
|
|
\note
|
|
|
|
Under X this returns 2 if the rectangle is partially clipped,
|
|
|
|
and 1 if it is entirely inside the clip region.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline int fl_not_clipped(int x, int y, int w, int h) {return fl_device->not_clipped(x,y,w,h); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Intersects the rectangle with the current clip region and returns the
|
|
|
|
bounding box of the result.
|
|
|
|
|
|
|
|
Returns non-zero if the resulting rectangle is different to the original.
|
|
|
|
This can be used to limit the necessary drawing to a rectangle.
|
|
|
|
\p W and \p H are set to zero if the rectangle is completely outside
|
|
|
|
the region.
|
|
|
|
\param[in] x,y,w,h position and size of rectangle
|
|
|
|
\param[out] X,Y,W,H position and size of resulting bounding box.
|
|
|
|
\p W and \p H are set to zero if the rectangle is
|
|
|
|
completely outside the region.
|
|
|
|
\returns Non-zero if the resulting rectangle is different to the original.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline int fl_clip_box(int x , int y, int w, int h, int& X, int& Y, int& W, int& H)
|
|
|
|
{return fl_device->clip_box(x,y,w,h,X,Y,W,H); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/** Undoes any clobbering of clip done by your program */
|
|
|
|
extern void fl_restore_clip();
|
|
|
|
/**
|
|
|
|
Replaces the top of the clipping stack with a clipping region of any shape.
|
|
|
|
|
|
|
|
Fl_Region is an operating system specific type.
|
|
|
|
\param[in] r clipping region
|
|
|
|
*/
|
2010-03-22 08:50:49 +03:00
|
|
|
FL_EXPORT void fl_clip_region(Fl_Region r);
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
returns the current clipping region.
|
|
|
|
*/
|
|
|
|
extern Fl_Region fl_clip_region();
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// points:
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Draws a single pixel at the given coordinates
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_point(int x, int y) { fl_device->point(x,y); };
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2000-05-14 00:03:20 +04:00
|
|
|
// line type:
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Sets how to draw lines (the "pen").
|
|
|
|
If you change this it is your responsibility to set it back to the default
|
|
|
|
using \c fl_line_style(0).
|
|
|
|
|
|
|
|
\param[in] style A bitmask which is a bitwise-OR of a line style, a cap
|
|
|
|
style, and a join style. If you don't specify a dash type you
|
|
|
|
will get a solid line. If you don't specify a cap or join type
|
|
|
|
you will get a system-defined default of whatever value is
|
|
|
|
fastest.
|
|
|
|
\param[in] width The thickness of the lines in pixels. Zero results in the
|
|
|
|
system defined default, which on both X and Windows is somewhat
|
|
|
|
different and nicer than 1.
|
|
|
|
\param[in] dashes A pointer to an array of dash lengths, measured in pixels.
|
|
|
|
The first location is how long to draw a solid portion, the next
|
|
|
|
is how long to draw the gap, then the solid, etc. It is terminated
|
|
|
|
with a zero-length entry. A \c NULL pointer or a zero-length
|
|
|
|
array results in a solid line. Odd array sizes are not supported
|
|
|
|
and result in undefined behavior.
|
|
|
|
|
|
|
|
\note Because of how line styles are implemented on Win32 systems,
|
|
|
|
you \e must set the line style \e after setting the drawing
|
|
|
|
color. If you set the color after the line style you will lose
|
|
|
|
the line style settings.
|
|
|
|
\note The \p dashes array does not work under Windows 95, 98 or Me,
|
|
|
|
since those operating systems do not support complex line styles.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_line_style(int style, int width=0, char* dashes=0) {fl_device->line_style(style,width,dashes); };
|
2000-05-14 00:03:20 +04:00
|
|
|
enum {
|
2008-10-17 00:56:43 +04:00
|
|
|
FL_SOLID = 0, ///< line style: <tt>___________</tt>
|
|
|
|
FL_DASH = 1, ///< line style: <tt>_ _ _ _ _ _</tt>
|
|
|
|
FL_DOT = 2, ///< line style: <tt>. . . . . .</tt>
|
|
|
|
FL_DASHDOT = 3, ///< line style: <tt>_ . _ . _ .</tt>
|
|
|
|
FL_DASHDOTDOT = 4, ///< line style: <tt>_ . . _ . .</tt>
|
|
|
|
|
|
|
|
FL_CAP_FLAT = 0x100, ///< cap style: end is flat
|
|
|
|
FL_CAP_ROUND = 0x200, ///< cap style: end is round
|
|
|
|
FL_CAP_SQUARE = 0x300, ///< cap style: end wraps end point
|
|
|
|
|
|
|
|
FL_JOIN_MITER = 0x1000, ///< join style: line join extends to a point
|
|
|
|
FL_JOIN_ROUND = 0x2000, ///< join style: line join is rounded
|
|
|
|
FL_JOIN_BEVEL = 0x3000 ///< join style: line join is tidied
|
2000-05-14 00:03:20 +04:00
|
|
|
};
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
// rectangles tweaked to exactly fill the pixel rectangle:
|
2010-03-21 11:26:40 +03:00
|
|
|
|
2009-02-20 11:24:32 +03:00
|
|
|
/** Draws a 1-pixel border \e inside the given bounding box */
|
2010-03-21 11:26:40 +03:00
|
|
|
inline void fl_rect(int x, int y, int w, int h) { fl_device->rect(x,y,w,h); };
|
|
|
|
|
|
|
|
/** Draws with passed color a 1-pixel border \e inside the given bounding box */
|
2001-08-04 16:21:34 +04:00
|
|
|
inline void fl_rect(int x, int y, int w, int h, Fl_Color c) {fl_color(c); fl_rect(x,y,w,h);}
|
2010-03-21 11:26:40 +03:00
|
|
|
/** Colors with current color a rectangle that exactly fills the given bounding box */
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_rectf(int x, int y, int w, int h) { fl_device->rectf(x,y,w,h); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/** Colors with passsed color a rectangle that exactly fills the given bounding box */
|
2001-08-04 16:21:34 +04:00
|
|
|
inline void fl_rectf(int x, int y, int w, int h, Fl_Color c) {fl_color(c); fl_rectf(x,y,w,h);}
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2009-03-15 22:38:13 +03:00
|
|
|
/**
|
|
|
|
Color a rectangle with "exactly" the passed <tt>r,g,b</tt> 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 the correct color
|
|
|
|
shade is produced.
|
|
|
|
*/
|
|
|
|
/* note: doxygen comment here to avoid triplication in os-speciic files */
|
|
|
|
FL_EXPORT void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b);
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
// line segments:
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Draws a line from (x,y) to (x1,y1)
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_line(int x, int y, int x1, int y1) {fl_device->line(x,y,x1,y1); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Draws a line from (x,y) to (x1,y1) and another from (x1,y1) to (x2,y2)
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_line(int x, int y, int x1, int y1, int x2, int y2) {fl_device->line(x,y,x1,y1,x2,y2); };
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// closed line segments:
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Outlines a 3-sided polygon with lines
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_loop(int x, int y, int x1, int y1, int x2, int y2) {fl_device->loop(x,y,x1,y1,x2,y2); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Outlines a 4-sided polygon with lines
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)
|
|
|
|
{fl_device->loop(x,y,x1,y1,x2,y2,x3,y3); };
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// filled polygons
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Fills a 3-sided polygon. The polygon must be convex.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_polygon(int x, int y, int x1, int y1, int x2, int y2) {fl_device->polygon(x,y,x1,y1,x2,y2); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Fills a 4-sided polygon. The polygon must be convex.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)
|
|
|
|
{ fl_device->polygon(x,y,x1,y1,x2,y2,x3,y3); };
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// draw rectilinear lines, horizontal segment first:
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Draws a horizontal line from (x,y) to (x1,y)
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_xyline(int x, int y, int x1) {fl_device->xyline(x,y,x1);};
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Draws a horizontal line from (x,y) to (x1,y), then vertical from (x1,y) to (x1,y2)
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_xyline(int x, int y, int x1, int y2) {fl_device->xyline(x,y,x1,y2);};
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Draws a horizontal line from (x,y) to (x1,y), then a vertical from (x1,y) to (x1,y2)
|
|
|
|
and then another horizontal from (x1,y2) to (x3,y2)
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_xyline(int x, int y, int x1, int y2, int x3) {fl_device->xyline(x,y,x1,y2,x3);};
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// draw rectilinear lines, vertical segment first:
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Draws a vertical line from (x,y) to (x,y1)
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_yxline(int x, int y, int y1) {fl_device->yxline(x,y,y1);};
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Draws a vertical line from (x,y) to (x,y1), then a horizontal from (x,y1) to (x2,y1)
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_yxline(int x, int y, int y1, int x2) {fl_device->yxline(x,y,y1,x2);};
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Draws a vertical line from (x,y) to (x,y1) then a horizontal from (x,y1)
|
|
|
|
to (x2,y1), then another vertical from (x2,y1) to (x2,y3)
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_yxline(int x, int y, int y1, int x2, int y3) {fl_device->yxline(x,y,y1,x2,y3);};
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// circular lines and pie slices (code in fl_arci.C):
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Draw ellipse sections using integer coordinates.
|
|
|
|
|
|
|
|
These functions match the rather limited circle drawing code provided by X
|
|
|
|
and WIN32. The advantage over using fl_arc with floating point coordinates
|
|
|
|
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 o'clock and
|
|
|
|
are the starting and ending angle of the arc, \p a2 must be greater or equal
|
|
|
|
to \p a1.
|
|
|
|
|
|
|
|
fl_arc() draws a series of lines to approximate the arc. Notice that the
|
|
|
|
integer version of fl_arc() has a different number of arguments than the
|
2010-03-24 13:24:37 +03:00
|
|
|
double version fl_arc(double x, double y, double r, double start, double end)
|
2010-03-21 11:26:40 +03:00
|
|
|
|
|
|
|
\param[in] x,y,w,h bounding box of complete circle
|
|
|
|
\param[in] a1,a2 start and end angles of arc measured in degrees
|
|
|
|
counter-clockwise from 3 o'clock. \p a2 must be greater
|
|
|
|
than or equal to \p a1.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_arc(int x, int y, int w, int h, double a1, double a2) {fl_device->arc(x,y,w,h,a1,a2); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Draw filled ellipse sections using integer coordinates.
|
|
|
|
|
|
|
|
Like fl_arc(), but 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.
|
|
|
|
|
|
|
|
\param[in] x,y,w,h bounding box of complete circle
|
|
|
|
\param[in] a1,a2 start and end angles of arc measured in degrees
|
|
|
|
counter-clockwise from 3 o'clock. \p a2 must be greater
|
|
|
|
than or equal to \p a1.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_pie(int x, int y, int w, int h, double a1, double a2) {fl_device->pie(x,y,w,h,a1,a2); };
|
2008-10-15 01:42:24 +04:00
|
|
|
/** fl_chord declaration is a place holder - the function does not yet exist */
|
1999-02-17 01:00:04 +03:00
|
|
|
FL_EXPORT void fl_chord(int x, int y, int w, int h, double a1, double a2); // nyi
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// scalable drawing code (code in fl_vertex.C and fl_arc.C):
|
1999-02-17 01:00:04 +03:00
|
|
|
FL_EXPORT void fl_push_matrix();
|
|
|
|
FL_EXPORT void fl_pop_matrix();
|
|
|
|
FL_EXPORT void fl_scale(double x, double y);
|
|
|
|
FL_EXPORT void fl_scale(double x);
|
|
|
|
FL_EXPORT void fl_translate(double x, double y);
|
|
|
|
FL_EXPORT void fl_rotate(double d);
|
|
|
|
FL_EXPORT void fl_mult_matrix(double a, double b, double c, double d, double x,double y);
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Starts drawing a list of points. Points are added to the list with fl_vertex()
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_begin_points() {fl_device->begin_points(); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Starts drawing a list of lines.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_begin_line() {fl_device->begin_line(); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Starts drawing a closed sequence of lines.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_begin_loop() {fl_device->begin_loop(); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Starts drawing a convex filled polygon.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_begin_polygon() {fl_device->begin_polygon(); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Adds a single vertex to the current path.
|
|
|
|
\param[in] x,y coordinate
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_vertex(double x, double y) {fl_device->vertex(x,y); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Add a series of points on a Bezier curve to the path.
|
|
|
|
The curve ends (and two of the points) are at X0,Y0 and X3,Y3.
|
|
|
|
\param[in] X0,Y0 curve start point
|
|
|
|
\param[in] X1,Y1 curve control point
|
|
|
|
\param[in] X2,Y2 curve control point
|
|
|
|
\param[in] X3,Y3 curve end point
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3)
|
|
|
|
{fl_device->curve(X0,Y0,X1,Y1,X2,Y2,X3,Y3); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
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 fl_arc().
|
|
|
|
\param[in] x,y,r center and radius of circular arc
|
|
|
|
\param[in] start,end angles of start and end of arc measured in degrees
|
|
|
|
counter-clockwise from 3 o'clock. If \p end is less than \p start
|
|
|
|
then it draws the arc in a clockwise direction.
|
|
|
|
*/
|
|
|
|
inline void fl_arc(double x, double y, double r, double start, double end) {fl_device->arc(x,y,r,start,end); };
|
|
|
|
/**
|
|
|
|
fl_circle() is equivalent to fl_arc(x,y,r,0,360), but may be faster.
|
|
|
|
|
|
|
|
It must be the \e only thing in the path: if you want a circle as part of
|
|
|
|
a complex polygon you must use fl_arc()
|
|
|
|
\param[in] x,y,r center and radius of circle
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_circle(double x, double y, double r) {fl_device->circle(x,y,r); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Ends list of points, and draws.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_end_points() {fl_device->end_points(); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Ends list of lines, and draws.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_end_line() {fl_device->end_line(); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Ends closed sequence of lines, and draws.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_end_loop() {fl_device->end_loop(); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Ends convex filled polygon, and draws.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_end_polygon() {fl_device->end_polygon(); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Starts drawing a complex filled polygon.
|
|
|
|
|
|
|
|
The polygon may be concave, may have holes in it, or may be several
|
|
|
|
disconnected pieces. Call fl_gap() to separate loops of the path.
|
|
|
|
|
|
|
|
To outline the polygon, use fl_begin_loop() and replace each fl_gap()
|
|
|
|
with fl_end_loop();fl_begin_loop() pairs.
|
|
|
|
|
|
|
|
\note
|
|
|
|
For portability, you should only draw polygons that appear the same
|
|
|
|
whether "even/odd" or "non-zero" winding rules are used to fill them.
|
|
|
|
Holes should be drawn in the opposite direction to the outside loop.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_begin_complex_polygon() {fl_device->begin_complex_polygon(); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Call fl_gap() to separate loops of the path.
|
|
|
|
|
|
|
|
It is unnecessary but harmless to call fl_gap() before the first vertex,
|
|
|
|
after the last vertex, or several times in a row.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_gap() {fl_device->gap(); };
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Ends complex filled polygon, and draws.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_end_complex_polygon() {fl_device->end_complex_polygon(); };
|
1998-10-06 22:21:25 +04:00
|
|
|
// get and use transformed positions:
|
1999-02-17 01:00:04 +03:00
|
|
|
FL_EXPORT double fl_transform_x(double x, double y);
|
|
|
|
FL_EXPORT double fl_transform_y(double x, double y);
|
|
|
|
FL_EXPORT double fl_transform_dx(double x, double y);
|
|
|
|
FL_EXPORT double fl_transform_dy(double x, double y);
|
2010-03-21 11:26:40 +03:00
|
|
|
/**
|
|
|
|
Adds coordinate pair to the vertex list without further transformations.
|
|
|
|
\param[in] xf,yf transformed coordinate
|
|
|
|
*/
|
|
|
|
inline void fl_transformed_vertex(double xf, double yf) {fl_device->transformed_vertex(xf,yf); };
|
2008-12-28 14:21:03 +03:00
|
|
|
/** @} */
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2009-02-16 01:20:50 +03:00
|
|
|
/** \addtogroup fl_attributes
|
2008-12-28 14:21:03 +03:00
|
|
|
@{ */
|
2008-10-28 23:58:44 +03:00
|
|
|
/* NOTE: doxygen comments here to avoid triplication in os-specific sources */
|
2010-03-21 11:26:40 +03:00
|
|
|
|
|
|
|
// Fonts:
|
2008-10-28 23:58:44 +03:00
|
|
|
/**
|
2009-02-20 11:24:32 +03:00
|
|
|
Sets the current font, which is then used in various drawing routines.
|
|
|
|
You may call this outside a draw context if necessary to call fl_width(),
|
2008-10-28 23:58:44 +03:00
|
|
|
but on X this will open the display.
|
|
|
|
|
2009-03-24 04:40:44 +03:00
|
|
|
The font is identified by a \p face and a \p size.
|
2008-10-28 23:58:44 +03:00
|
|
|
The size of the font is measured in pixels and not "points".
|
2009-03-24 04:40:44 +03:00
|
|
|
Lines should be spaced \p size pixels apart or more.
|
2008-10-28 23:58:44 +03:00
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_font(Fl_Font face, Fl_Fontsize size) { fl_device->font(face,size); };
|
2008-12-28 14:21:03 +03:00
|
|
|
extern FL_EXPORT Fl_Font fl_font_; ///< current font index
|
|
|
|
|
2008-10-28 23:58:44 +03:00
|
|
|
/**
|
2009-03-24 04:40:44 +03:00
|
|
|
Returns the \p face set by the most recent call to fl_font().
|
2009-02-20 11:24:32 +03:00
|
|
|
This can be used to save/restore the font.
|
2008-10-28 23:58:44 +03:00
|
|
|
*/
|
2008-04-23 23:09:28 +04:00
|
|
|
inline Fl_Font fl_font() {return fl_font_;}
|
2010-03-24 13:24:37 +03:00
|
|
|
/** \brief current font size */
|
2008-08-16 01:11:21 +04:00
|
|
|
extern FL_EXPORT Fl_Fontsize fl_size_;
|
2008-10-28 23:58:44 +03:00
|
|
|
/**
|
2009-03-24 04:40:44 +03:00
|
|
|
Returns the \p size set by the most recent call to fl_font().
|
2009-02-20 11:24:32 +03:00
|
|
|
This can be used to save/restore the font.
|
2008-10-28 23:58:44 +03:00
|
|
|
*/
|
2008-08-16 01:11:21 +04:00
|
|
|
inline Fl_Fontsize fl_size() {return fl_size_;}
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// information you can get about the current font:
|
2008-10-28 23:58:44 +03:00
|
|
|
/**
|
2009-02-20 11:24:32 +03:00
|
|
|
Returns the recommended minimum line spacing for the current font.
|
2009-03-24 04:40:44 +03:00
|
|
|
You can also use the value of \p size passed to fl_font()
|
2008-10-28 23:58:44 +03:00
|
|
|
*/
|
1999-02-17 01:00:04 +03:00
|
|
|
FL_EXPORT int fl_height(); // using "size" should work ok
|
Applied patch from STR#2115.
This fix to fl_height(int,int) solves the "digital drit"
problem in Fl_Text_Editor, where doing insert/delete
operations was leaving a trail of dead pixels.
Also fixes problem with font display problem in fluid's
code editor. See the STR for screenshots of the problem.
NOTE: THIS IS A WORKAROUND FOR A DEEPER PROBLEM.
Somewhere during the port of UTF8, the actual pixel size
of the displayed font is a little off, causing FLTK to
miscalculate line height, causing 'digital drit'.
It used to be that when you specified a font size,
the font's actual displayed pixel size matched the
font size value.
This fix makes the fl_height(int,int) function more robust,
actually inquiring the font system for its font size, instead
of assuming the font size is the same as the 'size' argument.
Since Fl_Text_Editor makes use of this function, it helps
that widget calculate font sizes correctly.
The real fix will be restoring FLTK's old behavior where the
font size specified is the actual pixel size of the displayed font.
Then this function can be reverted to just returning the 'size' argument.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6845 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2009-08-29 00:14:41 +04:00
|
|
|
FL_EXPORT int fl_height(int font, int size);
|
2008-10-28 23:58:44 +03:00
|
|
|
/**
|
2009-02-20 11:24:32 +03:00
|
|
|
Returns the recommended distance above the bottom of a fl_height() tall box to
|
2008-10-28 23:58:44 +03:00
|
|
|
draw the text at so it looks centered vertically in that box.
|
|
|
|
*/
|
1999-02-17 01:00:04 +03:00
|
|
|
FL_EXPORT int fl_descent();
|
2008-11-19 23:34:27 +03:00
|
|
|
/** Return the typographical width of a nul-terminated string */
|
2008-10-28 23:58:44 +03:00
|
|
|
FL_EXPORT double fl_width(const char* txt);
|
2009-03-24 04:40:44 +03:00
|
|
|
/** Return the typographical width of a sequence of \p n characters */
|
2008-10-28 23:58:44 +03:00
|
|
|
FL_EXPORT double fl_width(const char* txt, int n);
|
2009-02-16 01:20:50 +03:00
|
|
|
/** Return the typographical width of a single character :
|
|
|
|
\note if a valid fl_gc is NOT found then it uses the first window gc,
|
2008-12-04 23:20:30 +03:00
|
|
|
or the screen gc if no fltk window is available when called. */
|
2009-12-08 01:04:55 +03:00
|
|
|
FL_EXPORT double fl_width(unsigned int);
|
2009-02-16 01:20:50 +03:00
|
|
|
/** Determine the minimum pixel dimensions of a nul-terminated string.
|
|
|
|
|
|
|
|
Usage: given a string "txt" drawn using fl_draw(txt, x, y) you would determine
|
|
|
|
its pixel extents on the display using fl_text_extents(txt, dx, dy, wo, ho)
|
|
|
|
such that a bounding box that exactly fits around the text could be drawn with
|
|
|
|
fl_rect(x+dx, y+dy, wo, ho). Note the dx, dy values hold the offset of the first
|
|
|
|
"colored in" pixel of the string, from the draw origin.
|
|
|
|
*/
|
|
|
|
FL_EXPORT void fl_text_extents(const char*, int& dx, int& dy, int& w, int& h); // NO fltk symbol expansion will be performed
|
2009-03-24 04:40:44 +03:00
|
|
|
/** Determine the minimum pixel dimensions of a sequence of \p n characters.
|
2009-02-16 01:20:50 +03:00
|
|
|
\see fl_text_extents(const char*, int& dx, int& dy, int& w, int& h)
|
|
|
|
*/
|
2008-11-19 23:34:27 +03:00
|
|
|
FL_EXPORT void fl_text_extents(const char*, int n, int& dx, int& dy, int& w, int& h);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-12-28 14:21:03 +03:00
|
|
|
// font encoding:
|
2009-03-15 14:27:56 +03:00
|
|
|
// Note: doxygen comments here to avoid duplication for os-sepecific cases
|
|
|
|
/**
|
|
|
|
convert text from Windows/X11 latin1 charcter set to local encoding.
|
|
|
|
\param[in] t character string (latin1 encoding)
|
|
|
|
\param[in] n optional number of characters to convert (default is all)
|
|
|
|
\returns pointer to internal buffer containing converted characters
|
|
|
|
*/
|
|
|
|
FL_EXPORT const char *fl_latin1_to_local(const char *t, int n=-1);
|
|
|
|
/**
|
|
|
|
convert text from local encoding to Windowx/X11 latin1 character set.
|
|
|
|
\param[in] t character string (local encoding)
|
|
|
|
\param[in] n optional number of characters to convert (default is all)
|
|
|
|
\returns pointer to internal buffer containing converted characters
|
|
|
|
*/
|
|
|
|
FL_EXPORT const char *fl_local_to_latin1(const char *t, int n=-1);
|
|
|
|
/**
|
|
|
|
convert text from Mac Roman charcter set to local encoding.
|
|
|
|
\param[in] t character string (Mac Roman encoding)
|
|
|
|
\param[in] n optional number of characters to convert (default is all)
|
|
|
|
\returns pointer to internal buffer containing converted characters
|
|
|
|
*/
|
|
|
|
FL_EXPORT const char *fl_mac_roman_to_local(const char *t, int n=-1);
|
|
|
|
/**
|
|
|
|
convert text from local encoding to Mac Roman character set.
|
|
|
|
\param[in] t character string (local encoding)
|
|
|
|
\param[in] n optional number of characters to convert (default is all)
|
|
|
|
\returns pointer to internal buffer containing converted characters
|
|
|
|
*/
|
|
|
|
FL_EXPORT const char *fl_local_to_mac_roman(const char *t, int n=-1);
|
2008-12-28 14:21:03 +03:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/** \addtogroup fl_drawings
|
|
|
|
@{ */
|
2008-10-28 23:58:44 +03:00
|
|
|
/**
|
2009-02-20 11:24:32 +03:00
|
|
|
Draws a nul-terminated string starting at the given location.
|
|
|
|
|
2008-10-28 23:58:44 +03:00
|
|
|
Text is aligned to the left and to the baseline of the font.
|
2009-03-24 04:40:44 +03:00
|
|
|
To align to the bottom, subtract fl_descent() from \p y.
|
2009-02-20 11:24:32 +03:00
|
|
|
To align to the top, subtract fl_descent() and add fl_height().
|
|
|
|
This version of fl_draw provides direct access to the text drawing
|
2008-10-28 23:58:44 +03:00
|
|
|
function of the underlying OS. It does not apply any special handling
|
|
|
|
to control characters.
|
|
|
|
*/
|
|
|
|
FL_EXPORT void fl_draw(const char* str, int x, int y);
|
2009-04-24 13:28:30 +04:00
|
|
|
/**
|
|
|
|
Draws a nul-terminated string starting at the given location and
|
|
|
|
rotating \p angle degrees counterclockwise.
|
|
|
|
This version of fl_draw provides direct access to the text drawing
|
2010-03-21 11:26:40 +03:00
|
|
|
function of the underlying OS and is supported by Xft, Win32 and MacOS
|
|
|
|
fltk subsets.
|
2009-04-24 13:28:30 +04:00
|
|
|
*/
|
2010-03-21 11:26:40 +03:00
|
|
|
FL_EXPORT void fl_draw(int angle, const char* str, int x, int y);
|
2008-10-28 23:58:44 +03:00
|
|
|
/**
|
2009-03-24 04:40:44 +03:00
|
|
|
Draws an array of \p n characters starting at the given location.
|
2008-10-28 23:58:44 +03:00
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_draw(const char* str, int n, int x, int y) {fl_device->draw(str,n,x,y); };
|
2009-04-24 13:28:30 +04:00
|
|
|
/**
|
|
|
|
Draws an array of \p n characters starting at the given location,
|
|
|
|
rotating \p angle degrees counterclockwise.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_draw(int angle,const char* str, int n, int x, int y) {fl_device->draw(angle,str,n,x,y); };
|
2008-10-28 23:58:44 +03:00
|
|
|
/**
|
2009-03-24 04:40:44 +03:00
|
|
|
Draws an array of \p n characters right to left starting at given location.
|
2008-10-28 23:58:44 +03:00
|
|
|
*/
|
2008-09-11 03:56:49 +04:00
|
|
|
FL_EXPORT void fl_rtl_draw(const char*, int n, int x, int y);
|
2008-10-28 23:58:44 +03:00
|
|
|
FL_EXPORT void fl_measure(const char* str, int& x, int& y,
|
|
|
|
int draw_symbols = 1);
|
|
|
|
FL_EXPORT void fl_draw(const char* str, int x, int y, int w, int h,
|
|
|
|
Fl_Align align,
|
|
|
|
Fl_Image* img=0, int draw_symbols = 1);
|
|
|
|
FL_EXPORT void fl_draw(const char* str, int x, int y, int w, int h,
|
|
|
|
Fl_Align align,
|
|
|
|
void (*callthis)(const char *,int,int,int),
|
|
|
|
Fl_Image* img=0, int draw_symbols = 1);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// boxtypes:
|
1999-02-17 01:00:04 +03:00
|
|
|
FL_EXPORT void fl_frame(const char* s, int x, int y, int w, int h);
|
|
|
|
FL_EXPORT void fl_frame2(const char* s, int x, int y, int w, int h);
|
|
|
|
FL_EXPORT void fl_draw_box(Fl_Boxtype, int x, int y, int w, int h, Fl_Color);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// images:
|
2009-03-15 14:27:56 +03:00
|
|
|
/**
|
|
|
|
signature of image generation callback function.
|
|
|
|
\param[in] data user data passed to function
|
|
|
|
\param[in] x,y,w position and width of scan line in image
|
2009-03-24 04:40:44 +03:00
|
|
|
\param[out] buf buffer for generated image data. You must copy \p w
|
|
|
|
pixels from scanline \p y, starting at pixel \p x
|
2009-03-15 14:27:56 +03:00
|
|
|
to this buffer.
|
|
|
|
*/
|
|
|
|
typedef void (*Fl_Draw_Image_Cb)(void* data,int x,int y,int w,uchar* buf);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Draw an 8-bit per color RGB or luminance image.
|
|
|
|
\param[in] buf points at the "r" data of the top-left pixel.
|
|
|
|
Color data must be in <tt>r,g,b</tt> order.
|
|
|
|
\param[in] X,Y position where to put top-left corner of image
|
|
|
|
\param[in] W,H size of the image
|
|
|
|
\param[in] D delta to add to the pointer between pixels. it may be
|
|
|
|
any value greater than or equal to 3, or it can be
|
|
|
|
negative to flip the image horizontally
|
|
|
|
\param[in] L delta to add to the pointer between lines (if 0 is
|
2009-03-24 04:40:44 +03:00
|
|
|
passed it uses \p W * \p D), and may be larger than
|
|
|
|
\p W * \p D to crop data, or negative to flip the
|
2009-03-15 14:27:56 +03:00
|
|
|
image vertically
|
|
|
|
|
|
|
|
It is highly recommended that you put the following code before the
|
|
|
|
first <tt>show()</tt> of \e any window in your program to get rid of
|
|
|
|
the dithering if possible:
|
|
|
|
\code
|
|
|
|
Fl::visual(FL_RGB);
|
|
|
|
\endcode
|
|
|
|
Gray scale (1-channel) images may be drawn. This is done if
|
|
|
|
<tt>abs(D)</tt> is less than 3, or by calling fl_draw_image_mono().
|
|
|
|
Only one 8-bit sample is used for each pixel, and on screens with
|
|
|
|
different numbers of bits for red, green, and blue only gray colors
|
2009-03-24 04:40:44 +03:00
|
|
|
are used. Setting \p D greater than 1 will let you display one channel
|
2009-03-15 14:27:56 +03:00
|
|
|
of a color image.
|
|
|
|
|
|
|
|
\par Note:
|
|
|
|
The X version does not support all possible visuals. If FLTK cannot
|
|
|
|
draw the image in the current visual it will abort. FLTK supports
|
|
|
|
any visual of 8 bits or less, and all common TrueColor visuals up
|
|
|
|
to 32 bits.
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0)
|
|
|
|
{ fl_device->draw_image(buf, X, Y, W, H, D, L); };
|
2009-03-15 14:27:56 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
Draw a gray-scale (1 channel) image.
|
|
|
|
\see fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L)
|
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0)
|
|
|
|
{ fl_device->draw_image_mono(buf, X, Y, W, H, D, L); };
|
2009-03-15 14:27:56 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
Draw image using callback function to generate image data.
|
|
|
|
You can generate the image as it is being drawn, or do arbitrary
|
|
|
|
decompression of stored data, provided it can be decompressed to
|
|
|
|
individual scan lines easily.
|
|
|
|
\param[in] cb callback function to generate scan line data
|
|
|
|
\param[in] data user data passed to callback function
|
|
|
|
\param[in] X,Y
|
|
|
|
\param[in] W,H
|
|
|
|
\param[in] D
|
|
|
|
\see fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L)
|
|
|
|
|
2009-03-24 04:40:44 +03:00
|
|
|
The callback function \p cb is called with the <tt>void*</tt> \p data
|
2009-03-15 14:27:56 +03:00
|
|
|
user data pointer to allow access to a structure of information about
|
2009-03-24 04:40:44 +03:00
|
|
|
the image, and the \p x, \p y, and \p w of the scan line desired from
|
|
|
|
the image. 0,0 is the upper-left corner of the image, not \p X, \p Y.
|
2009-03-15 14:27:56 +03:00
|
|
|
A pointer to a buffer to put the data into is passed. You must copy
|
2009-03-24 04:40:44 +03:00
|
|
|
\p w pixels from scanline \p y, starting at pixel \p x, to this buffer.
|
2009-03-15 14:27:56 +03:00
|
|
|
|
2009-03-24 04:40:44 +03:00
|
|
|
Due to cropping, less than the whole image may be requested. So \p x
|
|
|
|
may be greater than zero, the first \p y may be greater than zero,
|
|
|
|
and \p w may be less than \p W. The buffer is long enough to store
|
|
|
|
the entire \p W * \p D pixels, this is for convenience with some
|
2009-03-15 14:27:56 +03:00
|
|
|
decompression schemes where you must decompress the entire line at
|
2009-03-24 04:40:44 +03:00
|
|
|
once: decompress it into the buffer, and then if \p x is not zero,
|
|
|
|
copy the data over so the \p x'th pixel is at the start of the buffer.
|
2009-03-15 14:27:56 +03:00
|
|
|
|
2009-03-24 04:40:44 +03:00
|
|
|
You can assume the \p y's will be consecutive, except the first one
|
2009-03-15 14:27:56 +03:00
|
|
|
may be greater than zero.
|
|
|
|
|
2009-03-24 04:40:44 +03:00
|
|
|
If \p D is 4 or more, you must fill in the unused bytes with zero.
|
2009-03-15 14:27:56 +03:00
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
inline void fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3)
|
|
|
|
{ fl_device->draw_image(cb, data, X, Y, W, H, D); };
|
2009-03-15 14:27:56 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
Draw gray-scale image using callback function to generate image data.
|
|
|
|
\see fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D)
|
|
|
|
*/
|
|
|
|
FL_EXPORT void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1);
|
|
|
|
|
2009-03-15 22:38:13 +03:00
|
|
|
/**
|
|
|
|
Checks whether platform supports true alpha blending for RGBA images.
|
|
|
|
\returns 1 if true alpha blending supported by platform
|
|
|
|
\returns 0 not supported so FLTK will use screen door transparency
|
|
|
|
*/
|
|
|
|
/* note: doxygen comment here to avoid triplication in os-speciic files */
|
2006-09-15 19:35:16 +04:00
|
|
|
FL_EXPORT char fl_can_do_alpha_blending();
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2009-03-15 22:38:13 +03:00
|
|
|
/**
|
|
|
|
Read an RGB(A) image from the current window or off-screen buffer.
|
|
|
|
\param[in] p pixel buffer, or NULL to allocate one
|
|
|
|
\param[in] X,Y position of top-left of image to read
|
|
|
|
\param[in] W,H width and height of image to read
|
|
|
|
\param[in] alpha alpha value for image (0 fr none)
|
|
|
|
\returns pointer to pixel buffer, or NULL if allocation failed.
|
|
|
|
|
2009-03-24 04:40:44 +03:00
|
|
|
The \p p argument points to a buffer that can hold the image and must
|
|
|
|
be at least \p W*H*3 bytes when reading RGB images, or \p W*H*4 bytes
|
2009-03-15 22:38:13 +03:00
|
|
|
when reading RGBA images. If NULL, fl_read_image() will create an
|
|
|
|
array of the proper suze which can be freed using <tt>delete[]</tt>.
|
|
|
|
|
2009-03-24 04:40:44 +03:00
|
|
|
The \p alpha parameter controls whether an alpha channel is created
|
2009-03-15 22:38:13 +03:00
|
|
|
and the value that is placed in the alpha channel. If 0, no alpha
|
|
|
|
channel is generated.
|
|
|
|
*/
|
|
|
|
/* note: doxygen comment here to avoid triplication in os-speciic files */
|
|
|
|
FL_EXPORT uchar *fl_read_image(uchar *p,int X,int Y,int W,int H,int alpha=0);
|
2002-05-30 19:09:03 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
// pixmaps:
|
1999-02-17 01:00:04 +03:00
|
|
|
FL_EXPORT int fl_draw_pixmap(/*const*/ char* const* data, int x,int y,Fl_Color=FL_GRAY);
|
2009-03-15 22:38:13 +03:00
|
|
|
FL_EXPORT int fl_draw_pixmap(const char* const* cdata, int x,int y,Fl_Color=FL_GRAY);
|
1999-02-17 01:00:04 +03:00
|
|
|
FL_EXPORT int fl_measure_pixmap(/*const*/ char* const* data, int &w, int &h);
|
2009-03-15 22:38:13 +03:00
|
|
|
FL_EXPORT int fl_measure_pixmap(const char* const* cdata, int &w, int &h);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// other:
|
2002-08-20 23:42:14 +04:00
|
|
|
FL_EXPORT void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
|
|
|
|
void (*draw_area)(void*, int,int,int,int), void* data);
|
2009-12-08 01:04:55 +03:00
|
|
|
FL_EXPORT const char* fl_shortcut_label(unsigned int shortcut);
|
|
|
|
FL_EXPORT const char* fl_shortcut_label(unsigned int shortcut, const char **eom);
|
2009-03-15 23:52:46 +03:00
|
|
|
FL_EXPORT void fl_overlay_rect(int x,int y,int w,int h);
|
1999-02-17 01:00:04 +03:00
|
|
|
FL_EXPORT void fl_overlay_clear();
|
2009-03-15 23:52:46 +03:00
|
|
|
FL_EXPORT void fl_cursor(Fl_Cursor, Fl_Color fg=FL_BLACK, Fl_Color bg=FL_WHITE);
|
2008-09-11 03:56:49 +04:00
|
|
|
FL_EXPORT const char* fl_expand_text(const char* from, char* buf, int maxbuf,
|
|
|
|
double maxw, int& n, double &width,
|
|
|
|
int wrap, int draw_symbols = 0);
|
|
|
|
|
|
|
|
// XIM:
|
2009-03-16 00:24:43 +03:00
|
|
|
/** \todo provide user documentation for fl_set_status function */
|
2008-09-11 03:56:49 +04:00
|
|
|
FL_EXPORT void fl_set_status(int X, int Y, int W, int H);
|
2009-03-16 00:24:43 +03:00
|
|
|
/** \todo provide user documentation for fl_set_spot function */
|
2008-12-27 22:22:30 +03:00
|
|
|
FL_EXPORT void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win=0);
|
2009-03-16 00:24:43 +03:00
|
|
|
/** \todo provide user documentation for fl_reset_spot function*/
|
2008-09-11 03:56:49 +04:00
|
|
|
FL_EXPORT void fl_reset_spot(void);
|
|
|
|
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// XForms symbols:
|
1999-02-17 01:00:04 +03:00
|
|
|
FL_EXPORT int fl_draw_symbol(const char* label,int x,int y,int w,int h, Fl_Color);
|
|
|
|
FL_EXPORT int fl_add_symbol(const char* name, void (*drawit)(Fl_Color), int scalable);
|
2008-12-28 14:21:03 +03:00
|
|
|
/** @} */
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
#endif
|
1998-10-20 01:39:29 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|