fltk Namespace Reference


Classes

class  Adjuster
class  AssociationFunctor
 Class used by the foreach() functions. More...
class  AssociationType
 Base class for the association type. More...
class  Browser
class  Button
class  CheckButton
class  Choice
class  Clock
class  ClockOutput
class  CreatedWindow
class  CycleButton
class  Dial
class  Divider
class  FillDial
class  FillSlider
class  FlatBox
class  FloatInput
class  Font
class  FrameBox
class  gifImage
class  GlutWindow
class  GlWindow
class  Group
class  GSave
class  Guard
class  HighlightBox
class  HighlightButton
class  Image
struct  ImageType
class  Input
class  IntInput
class  InvisibleBox
class  Item
class  ItemGroup
class  LightButton
class  LineDial
class  List
class  Menu
class  MenuBar
class  MenuSection
class  MenuWindow
class  Monitor
class  MultiBrowser
class  MultiImage
class  MultiLineOutput
class  Mutex
class  NamedStyle
class  NumericInput
class  Output
class  PackedGroup
class  PopupMenu
class  Preferences
class  ProgressBar
class  RadioButton
class  RadioItem
class  Rectangle
class  RecursiveMutex
class  RepeatButton
class  ReturnButton
class  Scrollbar
class  ScrollGroup
class  ShapedWindow
class  SharedImage
class  SignalMutex
class  Slider
class  StatusBarGroup
class  StringArray
class  StringHierarchy
class  StringList
class  Style
class  StyleSet
class  Symbol
class  TabGroup
class  TabGroupPager
class  TextBuffer
class  TextDisplay
class  TextEditor
class  ThumbWheel
class  TiledImage
class  ToggleButton
class  ToggleItem
class  Tooltip
class  Valuator
class  ValueInput
class  ValueOutput
class  ValueSlider
class  Widget
class  Window
class  WizardGroup
class  WordwrapOutput
class  xbmImage
class  xpmFileImage
class  xpmImage

Typedefs

typedef void( Callback )(Widget *, void *)
typedef void( Callback0 )(Widget *)
typedef void( Callback1 )(Widget *, long)
typedef Callback * Callback_p
typedef void * GLContext
 Actually a GLXContext or HGLDC.
typedef const char *( HelpFunc )(Widget *, const char *)
typedef MenuBar SystemMenuBar
typedef void(* Text_Modify_Cb )(int pos, int nInserted, int nDeleted, int nRestyled, const char *deletedText, void *cbArg)
typedef void(* Text_Predelete_Cb )(int pos, int nDeleted, void *cbArg)
typedef void(* UnfinishedStyleCb )(int, void *)

Enumerations

enum  { BOLD, ITALIC, BOLD_ITALIC }
enum  { NO_AUTO_SWAP, NO_ERASE_OVERLAY }
enum  {
  LAYOUT_X, LAYOUT_Y, LAYOUT_XY, LAYOUT_W,
  LAYOUT_H, LAYOUT_WH, LAYOUT_XYWH, LAYOUT_CHILD,
  LAYOUT_USER, LAYOUT_DAMAGE
}
enum  { MENU_TOGGLE, MENU_RADIO, SUBMENU, MENU_DIVIDER }
enum  { TAB_LEFT, TAB_RIGHT, TAB_SELECTED }
enum  {
  WHEN_NEVER, WHEN_CHANGED, WHEN_RELEASE, WHEN_RELEASE_ALWAYS,
  WHEN_ENTER_KEY, WHEN_ENTER_KEY_ALWAYS, WHEN_ENTER_KEY_CHANGED, WHEN_NOT_CHANGED
}
enum  {
  DAMAGE_VALUE, DAMAGE_PUSHED, DAMAGE_SCROLL, DAMAGE_OVERLAY,
  DAMAGE_HIGHLIGHT, DAMAGE_CHILD, DAMAGE_CHILD_LABEL, DAMAGE_EXPOSE,
  DAMAGE_CONTENTS, DAMAGE_ALL
}

Functions

void add_symbol (const char *name, void(*drawit)(Color), int scalable)
cairo_surface_t * cairo_create_surface (Window *w)
bool color_chooser (const char *name, Color &c)
bool color_chooser (const char *name, uchar &r, uchar &g, uchar &b, uchar &a)
bool color_chooser (const char *name, uchar &r, uchar &g, uchar &b)
bool color_chooser (const char *name, float &r, float &g, float &b, float &a)
bool color_chooser (const char *name, float &r, float &g, float &b)
Cursor * cursor (void *raw)
Cursor * cursor (Image *, int x, int y)
void file_chooser_ok_label (const char *l)
Fontfont (int)
Fontfont (const char *name, int attrib=0)
ImageTypeguess_image (const char *name, const uchar *datas=0)
int list_fonts (Font **&arrayp)
void register_images ()
void restore_quartz_line_style ()
Color show_colormap (Color oldcol)
void unregister_images ()
double version ()
fltk/file_chooser.h
const char * dir_chooser (const char *message, const char *fname, int relative=0)
const char * file_chooser (const char *message, const char *pattern, const char *filename, int relative=0)
void file_chooser_callback (void(*cb)(const char *))
void use_system_file_chooser (bool=true)
fltk/gl.h
void gldrawimage (const uchar *, int x, int y, int w, int h, int d=3, int ld=0)
void gldrawtext (const char *, int n, float x, float y, float z=0)
void gldrawtext (const char *, float x, float y, float z=0)
void gldrawtext (const char *, int n)
void gldrawtext (const char *)
void glfillrect (int x, int y, int w, int h)
void glfinish ()
float glgetascent ()
float glgetdescent ()
float glgetwidth (const char *, int n)
float glgetwidth (const char *)
void glsetcolor (Color)
void glsetfont (Font *f, float size)
void glstart ()
void glstrokerect (int x, int y, int w, int h)

Variables

cairo_t * cr
Cursor *const CURSOR_ARROW
Cursor *const CURSOR_CROSS
Cursor *const CURSOR_DEFAULT
Cursor *const CURSOR_HAND
Cursor *const CURSOR_HELP
Cursor *const CURSOR_INSERT
Cursor *const CURSOR_MOVE
Cursor *const CURSOR_NESW
Cursor *const CURSOR_NO
Cursor *const CURSOR_NONE
Cursor *const CURSOR_NS
Cursor *const CURSOR_NWSE
Cursor *const CURSOR_WAIT
Cursor *const CURSOR_WE
ImageType image_filetypes []
const int PAGER_MENU
const int PAGER_SHRINK
const int USEDEFAULT
fltk/error.h
void(* error )(const char *,...)
void(* fatal )(const char *,...)
void(* warning )(const char *,...)

fltk/ask.h

enum  {
  BEEP_DEFAULT, BEEP_MESSAGE, BEEP_ERROR, BEEP_QUESTION,
  BEEP_PASSWORD, BEEP_NOTIFICATION
}
const char * cancel
NamedStyleicon_style
NamedStylemessage_style
const char * message_window_label
bool message_window_scrollable
float message_window_timeout
const char * no
const char * ok
const char * yes
void alert (const char *,...)
int ask (const char *,...)
void beep (int type=BEEP_DEFAULT)
bool beep_on_dialog ()
void beep_on_dialog (bool)
int choice (const char *q, const char *b0, const char *b1, const char *b2,...)
int choice_alert (const char *q, const char *b0, const char *b1, const char *b2,...)
const char * input (const char *label, const char *deflt=0,...)
void message (const char *,...)
const char * password (const char *label, const char *deflt=0,...)

fltk/events.h

enum  {
  NO_EVENT, PUSH, RELEASE, ENTER,
  LEAVE, DRAG, FOCUS, UNFOCUS,
  KEY, KEYUP, FOCUS_CHANGE, MOVE,
  SHORTCUT, DEACTIVATE, ACTIVATE, HIDE,
  SHOW, PASTE, TIMEOUT, MOUSEWHEEL,
  DND_ENTER, DND_DRAG, DND_LEAVE, DND_RELEASE,
  TOOLTIP
}
enum  {
  LeftButton, MiddleButton, RightButton, SpaceKey,
  BackSpaceKey, TabKey, ClearKey, ReturnKey,
  PauseKey, ScrollLockKey, EscapeKey, HomeKey,
  LeftKey, UpKey, RightKey, DownKey,
  PageUpKey, PageDownKey, EndKey, PrintKey,
  InsertKey, MenuKey, HelpKey, NumLockKey,
  Keypad, KeypadEnter, MultiplyKey, AddKey,
  SubtractKey, DecimalKey, DivideKey, Keypad0,
  Keypad1, Keypad2, Keypad3, Keypad4,
  Keypad5, Keypad6, Keypad7, Keypad8,
  Keypad9, KeypadLast, F0Key, F1Key,
  F2Key, F3Key, F4Key, F5Key,
  F6Key, F7Key, F8Key, F9Key,
  F10Key, F11Key, F12Key, LastFunctionKey,
  LeftShiftKey, RightShiftKey, LeftCtrlKey, RightCtrlKey,
  CapsLockKey, LeftMetaKey, RightMetaKey, LeftAltKey,
  RightAltKey, DeleteKey, LeftAccKey, RightAccKey,
  LeftCmdKey, RightCmdKey
}
enum  {
  SHIFT, CAPSLOCK, CTRL, ALT,
  NUMLOCK, META, SCROLLLOCK, BUTTON1,
  BUTTON2, BUTTON3, ANY_BUTTON, ACCELERATOR,
  COMMAND, OPTION
}
enum  {
  DEVICE_MOUSE, DEVICE_STYLUS, DEVICE_ERASER, DEVICE_CURSOR,
  DEVICE_AIRBRUSH, DEVICE_TOUCH
}
void add_event_handler (int(*h)(int, Window *))
void belowmouse (Widget &w)
void belowmouse (Widget *)
Widgetbelowmouse ()
unsigned BUTTON (int n)
bool compose (int &del)
void compose_reset ()
void copy (const char *stuff, int len, bool clipboard=false)
bool dnd ()
int event ()
unsigned event_button ()
void event_clicks (int i)
int event_clicks ()
int event_device ()
int event_dx ()
int event_dy ()
bool event_inside (const Rectangle &)
void event_is_click (bool)
bool event_is_click ()
unsigned event_key ()
unsigned event_key_repeated ()
bool event_key_state (unsigned)
unsigned event_length ()
const char * event_name (int event)
 return the corresponding str of an event, should not consume memory if api is not used
float event_pressure ()
bool event_state (unsigned i)
unsigned event_state ()
const char * event_text ()
int event_x ()
int event_x_root ()
float event_x_tilt ()
int event_y ()
int event_y_root ()
float event_y_tilt ()
void exit_modal ()
bool exit_modal_flag ()
void focus (Widget &w)
void focus (Widget *)
Widgetfocus ()
unsigned foreachShortcut (ShortcutFunctor &f)
unsigned foreachShortcut (const Widget *, ShortcutFunctor &)
bool get_key_state (unsigned)
void get_mouse (int &, int &)
bool grab ()
bool handle (int, Window *)
unsigned key (const char *name)
const char * key_name (unsigned key)
Widgetmodal ()
void modal (Widget *, bool grab=false)
void paste (Widget &receiver, bool clipboard=false)
void pushed (Widget &w)
void pushed (Widget *)
Widgetpushed ()
bool try_shortcut ()
bool warp_mouse (int, int)

fltk/Flags.h

enum  {
  NO_FLAGS, ALIGN_TOP, ALIGN_BOTTOM, ALIGN_LEFT,
  ALIGN_RIGHT, ALIGN_CENTER, ALIGN_INSIDE, ALIGN_CLIP,
  ALIGN_WRAP, ALIGN_MASK, ALIGN_POSITIONMASK, ALIGN_TOPLEFT,
  ALIGN_BOTTOMLEFT, ALIGN_TOPRIGHT, ALIGN_BOTTOMRIGHT, ALIGN_CENTERLEFT,
  ALIGN_CENTERRIGHT, ALIGN_INSIDE_TOP, ALIGN_INSIDE_BOTTOM, ALIGN_INSIDE_LEFT,
  ALIGN_INSIDE_TOPLEFT, ALIGN_INSIDE_BOTTOMLEFT, ALIGN_INSIDE_RIGHT, ALIGN_INSIDE_TOPRIGHT,
  ALIGN_INSIDE_BOTTOMRIGHT, ALIGN_MENU, ALIGN_BROWSER, INACTIVE,
  OUTPUT, STATE, SELECTED, INVISIBLE,
  HIGHLIGHT, CHANGED, COPIED_LABEL, RAW_LABEL,
  LAYOUT_VERTICAL, TAB_TO_FOCUS, CLICK_TO_FOCUS, INACTIVE_R,
  FOCUSED, PUSHED, RESIZE_NONE, RESIZE_FIT,
  RESIZE_FILL, OPENED
}
typedef Flags Align
typedef int Flags

fltk/run.h

enum  { READ, WRITE, EXCEPT }
typedef void(* FileHandler )(int fd, void *)
typedef void(* TimeoutHandler )(void *)
int damage_
const char *const help
void(* idle )()
void add_check (TimeoutHandler, void *=0)
void add_fd (int fd, FileHandler, void *=0)
void add_fd (int fd, int when, FileHandler, void *=0)
void add_idle (TimeoutHandler, void *=0)
void add_timeout (float t, TimeoutHandler, void *v=0)
int arg (int, char **, int &)
void args (int, char **)
int args (int, char **, int &, int(*)(int, char **, int &)=0)
void awake (void *message=0)
int check ()
int damage ()
void damage (int d)
void display (const char *)
bool enable_tablet_events ()
void flush ()
double get_time_secs ()
bool has_check (TimeoutHandler, void *=0)
bool has_idle (TimeoutHandler, void *=0)
bool has_timeout (TimeoutHandler, void *=0)
bool in_main_thread ()
void lock ()
int ready ()
void redraw ()
void remove_check (TimeoutHandler, void *=0)
void remove_fd (int, int when=-1)
void remove_idle (TimeoutHandler, void *=0)
void remove_timeout (TimeoutHandler, void *=0)
void repeat_timeout (float t, TimeoutHandler, void *=0)
int run ()
void set_idle (void(*cb)())
void * thread_message ()
void unlock ()
int wait (float time)
int wait ()

fltk/visual.h

enum  {
  RGB_COLOR, INDEXED_COLOR, SINGLE_BUFFER, DOUBLE_BUFFER,
  ACCUM_BUFFER, ALPHA_BUFFER, DEPTH_BUFFER, STENCIL_BUFFER,
  RGB24_COLOR, MULTISAMPLE, STEREO
}
bool glVisual (int)
void own_colormap ()
bool visual (int)

fltk/Color.h

enum  {
  NO_COLOR, FREE_COLOR, NUM_FREE_COLOR, GRAY00,
  GRAY05, GRAY10, GRAY15, GRAY20,
  GRAY25, GRAY30, GRAY33, GRAY35,
  GRAY40, GRAY45, GRAY50, GRAY55,
  GRAY60, GRAY65, GRAY66, GRAY70,
  GRAY75, GRAY80, GRAY85, GRAY90,
  GRAY95, GRAY99, BLACK, RED,
  GREEN, YELLOW, BLUE, MAGENTA,
  CYAN, WHITE, DARK_RED, DARK_GREEN,
  DARK_YELLOW, DARK_BLUE, DARK_MAGENTA, DARK_CYAN,
  WINDOWS_BLUE
}
typedef unsigned Color
Color color (const char *)
Color color (unsigned char g)
Color color (unsigned char r, unsigned char g, unsigned char b)
Color contrast (Color fg, Color bg)
Color get_color_index (Color index)
Color inactive (Color fg, Color bg)
Color inactive (Color fg)
Color lerp (Color c0, Color c1, float f)
Color nearest_index (Color)
Color parsecolor (const char *, unsigned length)
void set_background (Color)
void set_color_index (Color index, Color)
void split_color (Color c, unsigned char &r, unsigned char &g, unsigned char &b)

fltk/draw.h

enum  {
  SOLID, DASH, DOT, DASHDOT,
  DASHDOTDOT, CAP_FLAT, CAP_ROUND, CAP_SQUARE,
  JOIN_MITER, JOIN_ROUND, JOIN_BEVEL
}
typedef const uchar *(* DrawImageCallback )(void *data, int x, int y, int w, uchar *buffer)
const int * column_widths_
Color current_bgcolor_
Color current_color_
Fontcurrent_font_
float current_size_
Flags drawflags_
const Styledrawstyle_
const char * encoding_
const char * line_dashes_
int line_style_
float line_width_
void addarc (float x, float y, float w, float h, float a1, float a2)
void addchord (const Rectangle &r, float a, float a2)
void addcurve (float, float, float, float, float, float, float, float)
void addpie (const Rectangle &r, float a, float a2)
void addvertex (int x, int y)
void addvertex (float x, float y)
void addvertices (int n, const int v[][2])
void addvertices (int n, const float v[][2])
void addvertices_transformed (int n, const float v[][2])
void clipout (const Rectangle &)
void closepath ()
void column_widths (const int *i)
const int * column_widths ()
void concat (float, float, float, float, float, float)
Flags drawflags (Flags f)
Flags drawflags ()
void drawimage (DrawImageCallback, void *, PixelType, const Rectangle &)
void drawimage (const uchar *, PixelType, const Rectangle &, int linedelta)
void drawimage (const uchar *, PixelType, const Rectangle &)
void drawline (float x0, float y0, float x1, float y1)
void drawline (int x0, int y0, int x1, int y1)
void drawpoint (float x, float y)
void drawpoint (int x, int y)
const Styledrawstyle ()
void drawstyle (const Style *s, Flags)
void drawtext (void(*textfunction)(const char *, int, float, float), float(*getwidth)(const char *, int), const char *str, const Rectangle &r, Flags flags)
void drawtext (const char *, const Rectangle &, Flags)
void drawtext (const char *, int length, float x, float y)
void drawtext (const char *, float x, float y)
void drawtext_transformed (const char *, int n, float x, float y)
void fillpath ()
void fillrect (const Rectangle &r)
void fillrect (int, int, int, int)
void fillstrokepath (Color)
const char * get_encoding ()
float getascent ()
Color getbgcolor ()
Color getcolor ()
float getdescent ()
Fontgetfont ()
float getsize ()
float getwidth (const char *, int length)
float getwidth (const char *)
int intersect_with_clip (Rectangle &)
const char * line_dashes ()
int line_style ()
void line_style (int, float width=0, const char *dashes=0)
float line_width ()
void load_identity ()
void measure (float(*getwidth)(const char *, int), const char *, float &w, float &h, Flags=0)
void measure (const char *, int &w, int &h, Flags=0)
void newpath ()
bool not_clipped (const Rectangle &)
void pop_clip ()
void pop_matrix ()
void push_clip (int X, int Y, int W, int H)
 Same as push_clip(Rectangle(x,y,w,h)) but faster:.
void push_clip (const Rectangle &)
void push_matrix ()
void push_no_clip ()
uchar * readimage (uchar *p, PixelType, const Rectangle &, int linedelta)
uchar * readimage (uchar *p, PixelType, const Rectangle &)
void rotate (float d)
void scale (float x)
void scale (float x, float y)
void scrollrect (const Rectangle &, int dx, int dy, void(*draw_area)(void *, const Rectangle &), void *)
void set_encoding (const char *)
void setbgcolor (Color c)
void setcolor (Color)
void setcolor_alpha (Color, float alpha)
void setdrawflags (Flags f)
void setfont (const char *, int attributes, float size)
void setfont (const char *, float size)
void setfont (Font *, float size)
void strokepath ()
void strokerect (const Rectangle &r)
void strokerect (int, int, int, int)
void transform (int &x, int &y, int &w, int &h)
void transform (const Rectangle &from, Rectangle &to)
void transform (int &x, int &y)
void transform (float &x, float &y)
void transform_distance (float &x, float &y)
void translate (int x, int y)
void translate (float x, float y)

fltk/PixelType.h

enum  PixelType {
  MASK, MONO, RGBx, RGB,
  RGBA, RGB32, ARGB32, RGBM,
  MRGB32
}
int depth (PixelType t)

fltk/Style.h

typedef Symbol Box
typedef bool(* Theme )()
Box *const BORDER_BOX
Box *const BORDER_FRAME
Font *const COURIER
Font *const COURIER_BOLD
Font *const COURIER_BOLD_ITALIC
Font *const COURIER_ITALIC
Box *const DIAMOND_DOWN_BOX
Box *const DIAMOND_UP_BOX
Box *const DOWN_BOX
Box *const EMBOSSED_BOX
LabelType *const EMBOSSED_LABEL
Box *const ENGRAVED_BOX
LabelType *const ENGRAVED_LABEL
Box *const FLAT_BOX
Font *const HELVETICA
Font *const HELVETICA_BOLD
Font *const HELVETICA_BOLD_ITALIC
Font *const HELVETICA_ITALIC
Box *const HIGHLIGHT_DOWN_BOX
Box *const HIGHLIGHT_UP_BOX
Box *const NO_BOX
LabelType *const NO_LABEL
LabelType *const NORMAL_LABEL
Box *const OFLAT_BOX
Box *const OSHADOW_BOX
Box *const OVAL_BOX
Box *const PLASTIC_DOWN_BOX
Box *const PLASTIC_UP_BOX
Box *const RFLAT_BOX
Box *const ROUND_DOWN_BOX
Box *const ROUND_UP_BOX
Box *const ROUNDED_BOX
Box *const RSHADOW_BOX
Font *const SCREEN_BOLD_FONT
Font *const SCREEN_FONT
Box *const SHADOW_BOX
LabelType *const SHADOW_LABEL
Font *const SYMBOL_FONT
LabelType *const SYMBOL_LABEL
Theme theme_
Box *const THIN_DOWN_BOX
Box *const THIN_UP_BOX
Font *const TIMES
Font *const TIMES_BOLD
Font *const TIMES_BOLD_ITALIC
Font *const TIMES_ITALIC
Box *const UP_BOX
Font *const ZAPF_DINGBATS
void load_theme ()
void reload_theme ()
bool reset_theme ()
void theme (Theme f)
Theme theme ()

fltk/filename.h

Some functions to manipulate filenames, to make portable programs.

typedef int( File_Sort_F )(const dirent *const *, const dirent *const *)
int alphasort (const dirent *const *, const dirent *const *)
int casealphasort (const dirent *const *, const dirent *const *)
int casenumericsort (const dirent *const *, const dirent *const *)
int filename_absolute (char *to, int tolen, const char *from, const char *cwd=0)
bool filename_exist (const char *)
char * filename_ext (char *a)
const char * filename_ext (const char *)
bool filename_isdir (const char *)
int filename_list (const char *d, dirent ***list)
int filename_list (const char *d, dirent ***list, File_Sort_F *sort)
bool filename_match (const char *, const char *pattern)
long int filename_mtime (const char *)
char * filename_name (char *a)
const char * filename_name (const char *)
int filename_relative (char *to, int tolen, const char *from, const char *cwd=0)
FL_FILESIZE_T filename_size (const char *)
int numericsort (const dirent *const *, const dirent *const *)

fltk/Threads.h

typedef pthread_t Thread
int create_thread (Thread &t, void *(*f)(void *), void *p)

fltk/win32.h

COLORREF current_xpixel
HDC dc
MSG msg
HINSTANCE xdisplay
HPALETTE xpalette
void clip_region (HRGN)
void draw_into (HBITMAP, int w, int h)
HDC getDC ()
HBRUSH setbrush ()
HPEN setpen ()
void stop_drawing (HWND)
void stop_drawing (HBITMAP)
TEXTMETRICW * textmetric ()
COLORREF xpixel (Color i)

fltk/x11.h

Atom dnd_action
Atom dnd_source_action
Atom * dnd_source_types
XWindow dnd_source_window
Atom dnd_type
ulong event_time
GC gc
XWindow message_window
Colormap xcolormap
XEvent xevent
XftDraw * xftc
int xscreen
XVisualInfo * xvisual
XWindow xwindow
void clip_region (Region)
void draw_into (XWindow, int w, int h)
Windowfind (XWindow xid)
bool handle ()
void open_display (Display *)
void stop_drawing (XWindow)
XftFont * xftfont ()
XWindow xid (const Window *w)

fltk/osx.h

CGContextRef quartz_gc
WindowPtr quartz_window
Handle system_menu
class SystemMenuBarsystem_menu_bar
void begin_quartz_image (CGRect &, const Rectangle &)
void clear_quartz_clipping ()
RgnHandle clip_region ()
void clip_region (RgnHandle)
void close_display ()
void draw_into (CGContextRef xid, int w, int h)
void end_quartz_image ()
void open_callback (void(*cb)(const char *name))
void open_display ()
void stop_drawing (CGImageRef xid)
HFONT xfont ()

Detailed Description


Typedef Documentation

fltk::Color is a typedef for a 32-bit integer containing r,g,b bytes and an "index" in the lowest byte (the first byte on a little-endian machine such as an x86). For instance 0xFF008000 is 255 red, zero green, and 128 blue. If rgb are not zero then the low byte is ignored, or may be treated as "alpha" by some code.

If the rgb is zero, the N is the color "index". This index is used to look up an fltk::Color in an internal table of 255 colors shown here. All the indexed colors may be changed by using set_color_index(). However fltk uses the ones between 32 and 255 and assummes they are not changed from their default values.

fl_show_colormap.gif
(this is not the X colormap used by fltk)

A Color of zero (fltk::NO_COLOR) will draw black but is ambiguous. It is returned as an error value or to indicate portions of a Style that should be inherited, and it is also used as the default label color for everything so that changing color zero can be used by the -fg switch. You should use fltk::BLACK (56) to get black.

Type of function passed to drawimage(). It must return a pointer to a horizontal row of w pixels, starting with the pixel at x and y (relative to the top-left corner of the image, not to the coordinate space drawimage() is called in). These pixels must be in the format described by type passed to drawimage() and must be the delta apart passed to drawimage().

userdata is the same as the argument passed to drawimage(). This can be used to point at a structure of information about the image.

Due to cropping, less than the whole image may be requested. So the callback may get an x greater than zero, the first y passed to it may be greater than zero, and x+w may be less than the width of the image. The passed buffer contains room for at least the number of pixels specified by the width passed to drawimage(). You can use this as temporary storage to construct a row of the image, and return a pointer offset by x into it.

typedef int fltk::Flags

Type returned by fltk::Widget::flags() and passed to fltk::Box and many other drawing functions.

typedef Flags fltk::Align

For back compatability with fltk1.1

typedef void(* fltk::TimeoutHandler)(void *)

Type of function passed to add_timeout(), add_check(), and add_idle()

typedef void(* fltk::FileHandler)(int fd, void *)

Type of function passed to add_fd()

A Theme is a function called by fltk just before it shows the first window, and also whenever it receives a signal from the operating system that the user's preferences have changed.

The Theme's job is to set all the NamedStyle structures to the correct values for the appearance selected by the user and operating system.

The return value is ignored but you should return true for future compatability.

This pointer is declared as a "C" function to make it easier to load the correct function by name from a plugin, if you would like to write a scheme where the appearance is controlled by plugins. Fltk provides a convienence function to portably load plugins called fltk::load_plugin() that you may want to use if you are writing such a system.

typedef pthread_t fltk::Thread

Hides whatever the system uses to identify a thread. Used so the "toy" interface is portable.


Enumeration Type Documentation

anonymous enum

Symbolic names for some of the indexed colors.

The 24-entry "gray ramp" is modified by fltk::set_background() so that the color fltk::GRAY75 is the background color, and the others are a nice range from black to a lighter version of the gray. These are used to draw box edges. The gray levels are chosen to be evenly spaced, listed here is the actual 8-bit and decimal gray level assigned by default. Also listed here is the letter used for fltk::FrameBox and the old fltk1.1 names used for these levels.

The remiander of the colormap is a 5x8x5 color cube. This cube is used to dither images on 8-bit screens X colormaps to reduce the number of colors used.

Enumerator:
NO_COLOR  Black, empty place holder in Style.
FREE_COLOR  Starting from index 16 is the FREE_COLOR area.
NUM_FREE_COLOR  Number of free color slots starting from index FREE_COLOR.
GRAY00  hex=00, dec=.00, framebox=A, fltk1 = GRAY0, GRAY_RAMP
GRAY05  hex=0d, dec=.05, framebox=B
GRAY10  hex=1a, dec=.10, framebox=C
GRAY15  hex=27, dec=.15, framebox=D
GRAY20  hex=34, dec=.20, framebox=E
GRAY25  hex=41, dec=.25, framebox=F
GRAY30  hex=4f, dec=.31, framebox=G
GRAY33  hex=5c, dec=.36, framebox=H, fltk1 = DARK3
GRAY35  hex=69, dec=.41, framebox=I
GRAY40  hex=76, dec=.46, framebox=J (18% gray card)
GRAY45  hex=83, dec=.51, framebox=K
GRAY50  hex=90, dec=.56, framebox=L
GRAY55  hex=9e, dec=.62, framebox=M
GRAY60  hex=ab, dec=.67, framebox=N, fltk1 = DARK2
GRAY65  hex=b8, dec=.72, framebox=O
GRAY66  hex=c5, dec=.77, framebox=P, fltk1 = DARK1, INACTIVE_COLOR
GRAY70  hex=d2, dec=.82, framebox=Q
GRAY75  hex=e0, dec=.88, framebox=R, fltk1 = GRAY, SELECTION_COLOR
GRAY80  hex=e5, dec=.90, framebox=S
GRAY85  hex=ea, dec=.92, framebox=T, fltk1 = LIGHT1
GRAY90  hex=f4, dec=.96, framebox=V, fltk1 = LIGHT2
GRAY95  hex=f9, dec=.98, framebox=W
GRAY99  hex=ff, dec=1.0, framebox=X, fltk1 = LIGHT3
BLACK  Corner of color cube.
RED  Corner of color cube.
GREEN  Corner of color cube.
YELLOW  Corner of color cube.
BLUE  Corner of color cube.
MAGENTA  Corner of color cube.
CYAN  Corner of color cube.
WHITE  Corner of color cube.
WINDOWS_BLUE  default selection_color

anonymous enum

Values of the bits stored in Widget::damage().

When redrawing your widgets you should look at the damage bits to see what parts of your widget need redrawing. The Widget::handle() method can then set individual damage bits to limit the amount of drawing that needs to be done, and the Widget::draw() method can test these bits to decide what to draw:

MyClass::handle(int event) {
  ...
  if (change_to_part1) damage(1);
  if (change_to_part2) damage(2);
  if (change_to_part3) damage(4);
}

MyClass::draw() {
  if (damage() & fltk::DAMAGE_ALL) {
    ... draw frame/box and other static stuff ...
  }
  if (damage() & (fltk::DAMAGE_ALL | 1)) draw_part1();
  if (damage() & (fltk::DAMAGE_ALL | 2)) draw_part2();
  if (damage() & (fltk::DAMAGE_ALL | 4)) draw_part3();
}

Except for DAMAGE_ALL, each widget is allowed to assign any meaning to any of the bits it wants. The enumerations are just to provide suggested meanings.

Enumerator:
DAMAGE_VALUE  A widget may use this to indicate that the displayed value has changed.
DAMAGE_PUSHED  A widget may use this to indicate that the user has pushed or released a button.
DAMAGE_SCROLL  A widget may use this to indicate that the displayed data has scrolled moved horizontally and/or vertically.
DAMAGE_OVERLAY  Same value as fltk::DAMAGE_SCROLL.
DAMAGE_HIGHLIGHT  A widget may use this to indicate that the mouse has entered/exited part of the widget.
DAMAGE_CHILD  A child of this group widget needs to be redrawn (non-group widgets can use this bit for their own purposes).
DAMAGE_CHILD_LABEL  An outside label of this widget needs to be redrawn. This is handled (and this bit is cleared) by the parent group.

Because anti-aliasing cannot be redrawn atop itself, this is not used anymore. Instead if an outside label needs to change the entire parent widget is redrawn.

DAMAGE_EXPOSE  Damage caused by damage() or by expose events from the operating system. If this and fltk::DAMAGE_ALL is on the widget should draw every pixel inside it's region.
DAMAGE_CONTENTS  Same as fltk::DAMAGE_EXPOSE but if fltk::DAMAGE_ALL is off a widget can use this for it's own purposes.
DAMAGE_ALL  This bit is set by redraw() and indicates that all of the widget (but not "holes" where the background shows through) needs to be redraw.

anonymous enum

Numbers passed to Widget::handle() and returned by event().

Enumerator:
NO_EVENT  Has the value zero. All fltk widgets return false if this is passed to their handle() method.

Fltk will produce this for unrecognized X events, if it can figure out what window to send them to. You can then subclass Window and add a handler for these events. Unfortunately this is not done on Windows due to the enormous number of garbage messages a program gets, you should instead use Windows pre-filtering functions to look for unknown messages.

PUSH  A mouse button has gone down with the mouse pointing at this widget. You can find out what button by calling fltk::event_button(). You find out the mouse position by calling fltk::event_x() and fltk::event_y(). These positions are relative to the corner of the widget whose handle() method is being called.

A widget indicates that it "wants" the mouse click by returning non-zero from its handle() method. It will then become the fltk::pushed() widget (this is done by the enclosing group widget) and will get fltk::DRAG and the matching fltk::RELEASE events.

RELEASE  A mouse button has been released. You can find out what button by calling fltk::event_button().

To receive fltk::RELEASE events you must return non-zero when passed a fltk::PUSH event.

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 fltk::belowmouse() widget and will receive fltk::MOVE and fltk::LEAVE events.
LEAVE  The mouse has moved out of the widget. To get this event you must return 1 in response to a fltk::ENTER event.
DRAG  The mouse has moved with a button held down. The current button state is in fltk::event_state(). The mouse position, relative to this widget, is in fltk::event_x() and fltk::event_y().

To receive fltk::DRAG events you must return non-zero when passed a fltk::PUSH event.

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 its handle() method. It then becomes the fltk::focus() widget and gets fltk::KEY, fltk::KEYUP and fltk::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 fltk::event_key() to figure out why it moved, for navigation it will be the key pressed and for switching windows it will be zero.

UNFOCUS  Sent to the previous fltk::focus() widget when another widget gets the focus.
KEY  A key press event. Fltk sends these directly to the fltk::focus() widget. If it returns zero then fltk will change the event into fltk::SHORTCUT and try the widgets under the mouse.

The key pressed can be found in fltk::event_key(). The text that the key should insert can be found with fltk::event_text() and its length is in fltk::event_length().

If you are actually doing text editing, you should use fltk::compose() to process the individual keystrokes into I18N characters.

KEYUP  Sent to the fltk::focus() widget. The key that was released can be found in fltk::event_key() (fltk::event_text() is not set).
FOCUS_CHANGE  Sent to all parents of the new fltk::focus() widget when the focus changes. This can be used to record which child has focus so it can be restored later, or to scroll a view to show the focus.
MOVE  The mouse has moved without any mouse buttons held down. This event is sent to the fltk::belowmouse() widget.
SHORTCUT  If the fltk::focus() widget is zero or it returns zero for an fltk::KEY event then FLTK tries sending this event to every widget it can, until one of them returns non-zero. fltk::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 fltk::add_handler(). A global shortcut will work no matter what windows are displayed or which one has the focus.

DEACTIVATE  The method Widget::deactivate() has been called on this widget or one of its parents. The function Widget::active_r() will now return false.
ACTIVATE  The method Widget::activate() has been called on this widget or one of its parents. The function Widget::active_r() will now return true.
HIDE  This widget is no longer visible, due to Widget::hide() being called on it or one of its parents, or due to a parent window being minimized. The function Widget::visible_r() will now return false.

If you implement a widget class it is important to call your base class with this same event. Fltk relies on this to communicate the visibility of widgets that are windows to the system.

SHOW  This widget is visible, due to Widget::show() being called on it or one of its parents, or due to a parent window being restored from minimized state. The function Widget::visible_r() will now return true.

If you implement a widget class it is important to call your base class with this same event. Fltk relies on this to communicate the visibility of widgets that are windows to the system.

PASTE  You should get this event some time after you call fltk::paste() or you return true for fltk::DND_RELEASE. The contents of fltk::event_text() is the text to insert and the number of characters is in fltk::event_length().
TIMEOUT  This event is generated if you called Widget::add_timeout().
MOUSEWHEEL  The wheel was moved on the mouse. fltk::event_dy() contains how many clicks the wheel moved, positive for up and negative for down. There is also a fltk::event_dx() for any kind of horizontal scrolling device but nothing produces that yet.
DND_ENTER  The user is dragging something over your widget. Return 1 if you are interested in getting fltk::DND_DRAG and fltk::DND_RELEASE events.

It is impossible to examine the text of the drag until you release it. There are system-specific variables that can be examined to determine the type of drag being done, but unless you are making a file-management application that wants to delete or rename the source files, you should not need this information.

DND_DRAG  The user moved the mouse some more while dragging something. You might use this to move around a cursor indicating where the insertion will go.
DND_LEAVE  The user moved out of the widget without releasing the dragged object.
DND_RELEASE  The user let go of the mouse and dropped something on your widget. Return 1 if you are interested in getting this data. In this case you will get an fltk::PASTE event with the text of object. This is usually a URL string, such as a filename with "file:" on the start. All fltk widgets just insert the data as text into text editors.
TOOLTIP  NYI. Sent when the mouse hovers over the widget long enough for it to pop up a tooltip. The base class handle() actually pops up the tooltip.

anonymous enum

Values returned by event_key(), passed to event_key_state() and get_key_state(), and used for the low 16 bits of add_shortcut().

The actual values returned are based on X11 keysym values, though fltk always returns "unshifted" values much like Windows does. A given key always returns the same value no matter what shift keys are held down. Use event_text() to see the results of any shift keys.

The lowercase letters 'a' through 'z' and the ascii symbols '`', '-', '=', '[', ']', '\', ',', '.', '/', ';', '\'' and space are used to identify the keys in the main keyboard.

On X systems unrecognized keys are returned unchanged as their X keysym value. If they have no keysym it uses the scan code or'd with 0x8000, this is what all those blue buttons on a Microsoft keyboard will do. I don't know how to get those buttons on Windows.

Enumerator:
LeftButton  PUSH/RELEASE set event_key to this
MiddleButton  PUSH/RELEASE set event_key to this
RightButton  PUSH/RELEASE set event_key to this
SpaceKey  Same as ' ' or 32
BackSpaceKey  Backspace
TabKey  Tab
ClearKey  On some systems with NumLock off '5' produces this
ReturnKey  Main Enter key, Windows and X documentation calls this "Return"
PauseKey  Pause + Break button
ScrollLockKey  Scroll Lock button
EscapeKey  Esc
HomeKey  Home
LeftKey  Left
UpKey  Up arrow
RightKey  Right arrow
DownKey  Down arrow
PageUpKey  Page Up
PageDownKey  Page Down
EndKey  End
PrintKey  Print Scrn key + SysRq key
InsertKey  Insert
MenuKey  Key in lower-right with picture of popup menu
HelpKey  Help key on Macintosh keyboards
NumLockKey  NumLock key
Keypad  Add ASCII to get keypad keys
KeypadEnter  Keypad+'\r'
MultiplyKey  Keypad+'*'
AddKey  Keypad+'+'
SubtractKey  Keypad+'-'
DecimalKey  Keypad+'.'
DivideKey  Keypad+'/'
Keypad0  Keypad+'0'
Keypad1  Keypad+'1'
Keypad2  Keypad+'2'
Keypad3  Keypad+'3'
Keypad4  Keypad+'4'
Keypad5  Keypad+'5'
Keypad6  Keypad+'6'
Keypad7  Keypad+'7'
Keypad8  Keypad+'8'
Keypad9  Keypad+'9'
KeypadLast  Keypad+'=', largest legal keypad key
F0Key  Add a number to get function key
F1Key  F0Key+1
F2Key  F0Key+2
F3Key  F0Key+3
F4Key  F0Key+4
F5Key  F0Key+5
F6Key  F0Key+6
F7Key  F0Key+7
F8Key  F0Key+8
F9Key  F0Key+9
F10Key  F0Key+10
F11Key  F0Key+11
F12Key  F0Key+12
LastFunctionKey  F0Key+35, largest legal function key
LeftShiftKey  Left-hand Shift
RightShiftKey  Right-hand Shift
LeftCtrlKey  Left-hand Ctrl
RightCtrlKey  Right-hand Ctrl
CapsLockKey  Caps Lock
LeftMetaKey  The left "Windows" or "Apple" key
RightMetaKey  The right "Windows" or "Apple" key
LeftAltKey  Left-hand Alt (option on Mac)
RightAltKey  Right-hand Alt (option on Mac)
DeleteKey  Delete

anonymous enum

Flags returned by event_state(), and used as the high 16 bits of Widget::add_shortcut() values (the low 16 bits are all zero, so these may be or'd with key values).

The inline function BUTTON(n) will turn n (1-8) into the flag for a mouse button.

Enumerator:
SHIFT  Either shift key held down
CAPSLOCK  Caps lock is toggled on
CTRL  Either ctrl key held down
ALT  Either alt key held down
NUMLOCK  Num Lock turned on
META  "Windows" or the "Apple" keys held down
SCROLLLOCK  Scroll Lock turned on
BUTTON1  Left mouse button held down
BUTTON2  Middle mouse button held down
BUTTON3  Right mouse button held down
ANY_BUTTON  Any mouse button (up to 8)
ACCELERATOR  ALT on Windows/Linux, CTRL on OS/X, use for menu accelerators.
COMMAND  CTRL on Windows/Linux, META on OS/X, use for menu shortcuts.
OPTION  ALT|META on Windows/Linux, just ALT on OS/X, use as a drag modifier.

anonymous enum

Device identifier returned by event_device(). This enumeration is useful to get the device type that caused a PUSH, RELEASE, DRAG or MOVE event

Enumerator:
DEVICE_MOUSE  Event triggered by the system mouse
DEVICE_STYLUS  Event triggered by a pen on a tablet, givin pressure and tilt information
DEVICE_ERASER  Event triggered by an eraser on a tablet, givin pressure and tilt information
DEVICE_CURSOR  Event triggered by a puck style device on a tablet
DEVICE_AIRBRUSH  Event triggered by an airbrush on a tablet, giving pressure and tilt information
DEVICE_TOUCH  Event triggered by touch a touch screen device

anonymous enum

Enumerator:
ALIGN_TOP  Label is centered above widget.
ALIGN_BOTTOM  Label is centered below widget.
ALIGN_LEFT  Label is to left of widget.
ALIGN_RIGHT  Label is to right of widget.
ALIGN_CENTER  (0) The label is centered inside widget
ALIGN_INSIDE  Label is inside widget, image centered.
ALIGN_CLIP  The label is clipped to the widget.
ALIGN_WRAP  The label is word-wrapped.
ALIGN_MASK  Used to split align() from flags().
ALIGN_POSITIONMASK  Used to split align() from flags().
ALIGN_TOPLEFT  Label is left-justified above widget.
ALIGN_BOTTOMLEFT  Label is left-justified below widget.
ALIGN_TOPRIGHT  Label is right-justified above widget.
ALIGN_BOTTOMRIGHT  Label is right-justified below widget.
ALIGN_CENTERLEFT  Label is centered in space left of widget.
ALIGN_CENTERRIGHT  Label is centered in space left of widget.
ALIGN_INSIDE_TOP  Label is inside widget at top.
ALIGN_INSIDE_BOTTOM  Label is inside widget at bottom.
ALIGN_INSIDE_LEFT  Label is inside widget at left.
ALIGN_INSIDE_TOPLEFT  Label is inside widget at top left.
ALIGN_INSIDE_BOTTOMLEFT  Label is inside widget at bottom left.
ALIGN_INSIDE_RIGHT  Label is inside widget at right.
ALIGN_INSIDE_TOPRIGHT  Label is inside widget at top right.
ALIGN_INSIDE_BOTTOMRIGHT  Label is inside widget bottom right.
ALIGN_MENU  Label is inside widget bottom right.
ALIGN_BROWSER  Label is inside widget bottom right.
INACTIVE  !active()
OUTPUT  does not get events, draw text colors
STATE  state(), value() for buttons
SELECTED  chosen in browser/menu, draw selected colors
INVISIBLE  !visible(), draw_frame()
HIGHLIGHT  draw highlighted
CHANGED  value changed since last callback
COPIED_LABEL  copy_label() was called
RAW_LABEL  don't interpret & or @ in label
LAYOUT_VERTICAL  fltk::Pack puts this widget vertical
TAB_TO_FOCUS  Widget::tab_to_focus();.
CLICK_TO_FOCUS  Widget::click_to_focus().
INACTIVE_R  draw it grayed-out
FOCUSED  draw with keyboard focus
PUSHED  draw pushed-in
RESIZE_NONE  default behavior
RESIZE_FIT  proportionnaly resize img in widget
RESIZE_FILL  resize img to fill the widget
OPENED  opened browser hierarchy parent

anonymous enum

Values of the bits stored in Widget::layout_damage().

When a widget resized or moved (or when it is initially created), flags are set in Widget::layout_damage() to indicate the layout is damaged. This will cause the virtual function Widget::layout() to be called just before fltk attempts to draw the windows on the screen. This is useful because often calculating the new layout is quite expensive, this expense is now deferred until the user will actually see the new size.

Some Group widgets such as fltk::PackedGroup will also use the virtual Widget::layout() function to find out how big a widget should be. A Widget is allowed to change it's own dimensions in layout() (except it is not allowed to change it if called a second time with no changes other than it's x/y position). This allows widgets to resize to fit their contents.

The layout bits are turned on by calling Widget::relayout().

Enumerator:
LAYOUT_X  Widget::x() changed by resize()
LAYOUT_Y  Widget::y() changed by resize()
LAYOUT_XY  Same as LAYOUT_X|LAYOUT_Y
LAYOUT_W  Widget::w() changed by resize()
LAYOUT_H  Widget::h() changed by resize()
LAYOUT_WH  Same as LAYOUT_W|LAYOUT_H
LAYOUT_XYWH  Same as LAYOUT_XY|LAYOUT_WH
LAYOUT_CHILD  Widget::layout() needs to be called on a child of this group widget.
LAYOUT_USER  The moving/resizing is being caused by the user and not internal code.
LAYOUT_DAMAGE  Widget::relayout() was called.

Enumeration describing how colors are stored in an array of bytes that is a pixel. This is used as an argument for fltk::drawimage(), fltk::readimage(), and fltk::Image.

Notice that the order of the bytes in memory of ARGB32 or RGB32 is a,r,g,b on a little-endian machine and b,g,r,a on a big-endian machine. Due to the use of these types by Windows, this is often the fastest form of data, if you have a choice. To convert an fltk::Color to RGB32, shift it right by 8 (for ARGB32 shift the alpha left 24 and or it in).

More types may be added in the future. The set is as minimal as possible while still covering the types I have actually encountered.

Enumerator:
MASK  1 byte of inverted mask, filled with current color
MONO  1 byte of gray scale
RGBx  bytes in r,g,b,a,r,g,b,a... order, a byte is ignored
RGB  bytes in r,g,b,r,g,b... order
RGBA  bytes in r,g,b,a,r,g,b,a... order
RGB32  32-bit words containiing 0xaarrggbb (aa is ignored)
ARGB32  32-bit words containing 0xaarrggbb
RGBM  unpremultiplied bytes in r,g,b,a order
MRGB32  unpremultiplied 0xaarrggbb


Function Documentation

void fltk::message ( const char *  fmt,
  ... 
)

fl_message.gif
Displays a printf-style message in a pop-up box with an "OK" button, waits for the user to hit the button. The message will wrap to fit the window, or may be many lines by putting '\n' characters into it. The enter key is a shortcut for the OK button.

References beep(), beep_on_dialog(), and ok.

Referenced by handle().

void fltk::alert ( const char *  fmt,
  ... 
)

fl_alert.gif
Same as fltk::message() except for the "!" symbol.

References beep(), beep_on_dialog(), and ok.

int fltk::ask ( const char *  fmt,
  ... 
)

fl_ask.gif
Displays a printf-style message in a pop-up box with an "Yes" and "No" button and waits for the user to hit a button. The return value is 1 if the user hits Yes, 0 if they pick No. The enter key is a shortcut for Yes and ESC is a shortcut for No.

If message_window_timeout is used, then -1 will be returned if the timeout expires.

References beep(), beep_on_dialog(), no, and yes.

int fltk::choice ( const char *  fmt,
const char *  b0,
const char *  b1,
const char *  b2,
  ... 
)

fl_choice.gif
Shows the message with three buttons below it marked with the strings b0, b1, and b2. Returns 0, 1, or 2 depending on which button is hit. If one of the strings begins with the special character '*' then the associated button will be the default which is selected when the enter key is pressed. ESC is a shortcut for b2.

If message_window_timeout is used, then -1 will be returned if the timeout expires.

References beep(), and beep_on_dialog().

int fltk::choice_alert ( const char *  fmt,
const char *  b0,
const char *  b1,
const char *  b2,
  ... 
)

Same as choice() except a "!" icon is used instead of a "?"

References beep(), and beep_on_dialog().

const char * fltk::input ( const char *  fmt,
const char *  defstr = 0,
  ... 
)

fl_input.gif
Pops up a window displaying a string, lets the user edit it, and return the new value. The cancel button returns NULL. The returned pointer is only valid until the next time fltk::input() is called. Due to back-compatability, the arguments to any printf commands in the label are after the default value.

If message_window_timeout is used, then 0 will be returned if the timeout expires.

References beep(), and beep_on_dialog().

const char * fltk::password ( const char *  fmt,
const char *  defstr = 0,
  ... 
)

fl_password.gif
Same as fltk::input() except an fltk::SecretInput field is used.

References beep(), and beep_on_dialog().

void fltk::beep ( int  type = BEEP_DEFAULT  ) 

Generates a simple beep message

References open_display(), and xdisplay.

Referenced by alert(), ask(), choice(), choice_alert(), input(), message(), and password().

void fltk::beep_on_dialog ( bool  b  ) 

You can enable beep on default message dialog (like ask, choice, input, ...) by using this function with true (default is false)

Referenced by alert(), ask(), choice(), choice_alert(), input(), message(), and password().

bool fltk::beep_on_dialog (  ) 

You get the state enable beep on default message dialog (like ask, choice, input, ...) by using this function with true (default is false)

fltk::Color fltk::color ( const char *  name  ) 

Turn a string into a color. If name is null this returns NO_COLOR. Otherwise it returns fltk::parsecolor(name, strlen(name)).

References color(), NO_COLOR, and parsecolor().

Referenced by color().

fltk::Color fltk::parsecolor ( const char *  name,
unsigned  length 
)

Turn the first n bytes of name into an fltk color. This allows you to parse a color out of the middle of a string.

Recognized values are:

  • "" turns into NO_COLOR
  • "0"-"99" decimal fltk color number, only works for indexed color range
  • "0xnnn" hex value of any fltk color number
  • "rgb" or "#rgb" three hex digits for rgb
  • "rrggbb" or "#rrggbb" 2 hex digits for each of rgb
  • "rrggbbaa" or "#rrggbbaa" fltk color number in hex
  • "rrrgggbbb" or "#rrrgggbbb" 3 hex digits for each of rgb
  • "rrrrggggbbbb" or "#rrrrggggbbbb" 4 hex digits for each of rgb
  • 17 "web safe colors" as defined by CSS 2.1
  • If FLTK is compiled to use X11, then XParseColor() is tried
  • all other strings return NO_COLOR.

References NO_COLOR, open_display(), xcolormap, and xdisplay.

Referenced by color().

Color fltk::lerp ( Color  color0,
Color  color1,
float  weight 
)

Return (1-weight)*color0 + weight*color1. weight is clamped to the 0-1 range before use.

References get_color_index().

Referenced by fltk::Slider::draw_ticks(), and inactive().

Color fltk::inactive ( Color  fg  ) 

Same as lerp(fg, getbgcolor(), .5). This is for back-compatability only?

References lerp().

Referenced by fltk::Input::draw(), and drawstyle().

Color fltk::inactive ( Color  fg,
Color  bg 
)

Same as lerp(fg, bg, .5), it grays out the color.

References lerp().

Color fltk::contrast ( Color  fg,
Color  bg 
)

Returns fg if fltk decides it can be seen well when drawn against bg. Otherwise it returns either fltk::BLACK or fltk::WHITE.

References BLACK, split_color(), and WHITE.

Referenced by fltk::Slider::draw(), fltk::Item::draw(), fltk::Input::draw(), fltk::Button::draw(), and drawstyle().

void fltk::split_color ( Color  i,
unsigned char &  r,
unsigned char &  g,
unsigned char &  b 
)

Set r,g,b to the 8-bit components of this color. If it is an indexed color they are looked up in the table, otherwise they are simply copied out of the color number.

Referenced by color_chooser(), contrast(), drawtext_transformed(), fillstrokepath(), glsetcolor(), set_background(), setcolor(), and setcolor_alpha().

void fltk::set_color_index ( Color  i,
Color  color 
)

Set one of the indexed colors to the given rgb color. i must be in the range 0-255, and c must be a non-indexed rgb color.

Referenced by set_background().

Color fltk::get_color_index ( Color  color  ) 

Return the rgb form of color. If it is an indexed color that entry is returned. If it is an rgb color it is returned unchanged.

Referenced by lerp(), and fltk::StyleSet::make_current().

void fltk::set_background ( Color  c  ) 

fltk::GRAY75 is replaced with the passed color, and all the other fltk::GRAY* colors are replaced with a color ramp (or sometimes a straight line) so that using them for highlighted edges of raised buttons looks correct.

References GRAY00, GRAY75, GRAY99, set_color_index(), and split_color().

Referenced by load_theme(), fltk::StyleSet::make_current(), and reload_theme().

Color fltk::nearest_index ( Color  i  ) 

Find an indexed color in the range 56-127 that is closest to this color. If this is an indexed color it is returned unchanged.

References BLACK.

Referenced by glsetcolor().

bool fltk::color_chooser ( const char *  name,
float &  r,
float &  g,
float &  b 
)

fl_color_chooser.jpg

fltk::color_chooser() pops up a window to let the user pick an arbitrary RGB color. They can pick the hue and saturation in the "hue box" on the left (hold down CTRL to just change the saturation), and the brighness using the vertical slider. Or they can type the 8-bit numbers into the RGB fltk::ValueInput fields, or drag the mouse across them to adjust them. The pull-down menu lets the user set the input fields to show RGB, HSV, or 8-bit RGB (0 to 255).

This returns non-zero if the user picks ok, and updates the RGB values. If the user picks cancel or closes the window this returns zero and leaves RGB unchanged.

This version takes and returns numbers in the 0-1 range.

There is also a class fltk::ColorChooser which you can use to imbed a color chooser into another control panel.

bool fltk::color_chooser ( const char *  name,
float &  r,
float &  g,
float &  b,
float &  a 
)

Same but user can also select an alpha value. Currently the color chips do not remember or set the alpha!

bool fltk::color_chooser ( const char *  name,
uchar &  r,
uchar &  g,
uchar &  b 
)

Same but it takes and returns 8-bit numbers for the rgb arguments.

bool fltk::color_chooser ( const char *  name,
uchar &  r,
uchar &  g,
uchar &  b,
uchar &  a 
)

Same but with 8-bit alpha chosen by the user.

bool fltk::color_chooser ( const char *  name,
Color &  c 
)

Same but it takes and returns an fltk::Color number. No alpha.

References split_color().

void fltk::push_matrix (  ) 

Save the current transformation on a stack, so you can restore it with pop_matrix().

FLTK provides an arbitrary 2-D affine transformation (rotation, scale, skew, reflections, and translation). This is very similar to PostScript, PDF, SVG, and Cairo.

Due to limited graphics capabilities of some systems, not all drawing functions will be correctly transformed, except by the integer portion of the translation. Don't rely on this as we may be fixing this without notice.

Referenced by fltk::Choice::draw(), fltk::Widget::draw_background(), fltk::Group::draw_child(), fltk::Menu::draw_in(), drawtext(), and fltk::Group::update_child().

void fltk::pop_matrix (  ) 

Put the transformation back to the way it was before the last push_matrix(). Calling this without a matching push_matrix will crash!

Referenced by fltk::Choice::draw(), fltk::Widget::draw_background(), fltk::Group::draw_child(), fltk::Menu::draw_in(), drawtext(), and fltk::Group::update_child().

void fltk::scale ( float  x,
float  y 
)

Scale the current transformation by multiplying it by

x 0 0
0 y 0
0 0 1

References concat().

void fltk::scale ( float  x  ) 

Scale the current transformation by multiplying it by

x 0 0
0 x 0
0 0 1

References concat().

void fltk::translate ( float  x,
float  y 
)

Translate the current transformation by multiplying it by

1 0 0
0 1 0
x y 1

References concat().

Referenced by fltk::Choice::draw(), fltk::Widget::draw_background(), fltk::Group::draw_child(), fltk::Menu::draw_in(), fltk::Widget::make_current(), and fltk::Group::update_child().

void fltk::translate ( int  x,
int  y 
)

This integer version is provided because it is much faster than the floating-point version. However C++ will not "resolve" which one you want to call if you try passing doubles as arguments. To get it to compile, make sure you cast the arguments to float (add 'f' after floating-point constants). Use the 'f' versions (ie sinf(), cosf(), etc) of the math functions from <fltk/math.h> to produce floats and get maximum calculation speed.

References concat().

void fltk::rotate ( float  d  ) 

Rotate the current transformation counter-clockwise by d degrees (not radians!!). This is done by multiplying the matrix by:

cos -sin 0
sin  cos 0
0     0  1

References concat().

void fltk::concat ( float  a,
float  b,
float  c,
float  d,
float  x,
float  y 
)

Multiply the current transformation by

a b 0
c d 0
x y 1

Referenced by rotate(), scale(), and translate().

void fltk::load_identity (  ) 

Replace the current transform with the identity transform, which puts 0,0 in the top-left corner of the window and each unit is 1 pixel in size.

Referenced by draw_into(), and drawtext().

void fltk::transform ( float &  x,
float &  y 
)

Replace x and y transformed into device coordinates. Device-specific code can use this to draw things using the fltk transformation matrix. If the backend is Cairo or another API that does transformations, this may return xy unchagned.

Referenced by addchord(), addcurve(), addpie(), addvertex(), addvertices(), clipout(), fltk::Input::draw(), drawline(), drawpoint(), drawtext(), fillrect(), not_clipped(), push_clip(), scrollrect(), strokerect(), and transform().

void fltk::transform_distance ( float &  x,
float &  y 
)

Replace x and y with the tranformed coordinates, ignoring translation. This transforms a vector which is measuring a distance between two positions, rather than a position.

Referenced by addarc(), and transform().

void fltk::transform ( int &  x,
int &  y 
)

Replace x and y with the transformed coordinates, rounded to the nearest integer.

void fltk::transform ( const Rectangle from,
Rectangle to 
)

Transform the rectangle from into device coordinates and put it into to. This only works correctly for 90 degree rotations, for other transforms this will produce an axis-aligned rectangle with the same area (this is useful for inscribing circles, and is about the best that can be done for device functions that don't handle rotation.

References fltk::Rectangle::empty(), fltk::Rectangle::h(), fltk::Rectangle::set(), transform(), transform_distance(), fltk::Rectangle::w(), fltk::Rectangle::x(), and fltk::Rectangle::y().

void fltk::transform ( int &  X,
int &  Y,
int &  W,
int &  H 
)

Same as transform(Rectangle(X,Y,W,H),to) but replaces XYWH with the transformed rectangle. This may be faster as it avoids the rectangle construction.

References transform(), and transform_distance().

void fltk::push_clip ( const Rectangle r  ) 

void fltk::push_clip ( int  x,
int  y,
int  w,
int  h 
)

Same as push_clip(Rectangle(x,y,w,h)) but faster:.

Same as push_clip(Rectangle(x,y,r,h)) except faster as it avoids the construction of an intermediate rectangle object.

Pushes the intersection of the current region and this rectangle onto the clip stack.

References transform(), and XRectangleRegion().

void fltk::clipout ( const Rectangle r1  ) 

Remove rectangle from the current clip region, thus making it a more complex shape. This does not push the stack, it just replaces the top of it.

Some graphics backends (OpenGL and Cairo, at least) do not support non-rectangular clip regions. This call does nothing on those.

Remove the rectangle from the current clip region, thus making it a more complex shape. This does not push the stack, it just replaces the top of it.

Some graphics backends (OpenGL and Cairo, at least) do not support non-rectangular clip regions. This call does nothing on those.

References fltk::Rectangle::b(), fltk::Rectangle::empty(), fltk::Rectangle::h(), fltk::Rectangle::r(), transform(), fltk::Rectangle::w(), fltk::Rectangle::x(), XRectangleRegion(), and fltk::Rectangle::y().

void fltk::pop_clip (  ) 

Restore the previous clip region. You must call fltk::pop_clip() exactly once for every time you call fltk::push_clip(). If you return to FLTK with the clip stack not empty unpredictable results occur.

Referenced by fltk::TiledImage::_draw(), fltk::Input::draw(), fltk::Choice::draw(), fltk::Widget::draw_background(), fltk::Menu::draw_in(), fltk::Widget::draw_label(), and drawtext().

void fltk::push_no_clip (  ) 

Pushes an empty clip region on the stack so nothing will be clipped. This lets you draw outside the current clip region. This should only be used to temporarily ignore the clip region to draw into an offscreen area.

bool fltk::not_clipped ( const Rectangle r1  ) 

Returns true if any or all of rectangle is inside the clip region.

Returns true if any or all of the Rectangle is inside the clip region.

References fltk::Rectangle::b(), fltk::Rectangle::h(), fltk::Rectangle::r(), transform(), fltk::Rectangle::w(), fltk::Rectangle::x(), and fltk::Rectangle::y().

Referenced by fltk::Group::draw_child(), and fltk::Group::update_child().

int fltk::intersect_with_clip ( Rectangle r  ) 

Intersect a transform()'d rectangle with the current clip region and change it to the smaller rectangle that surrounds (and probably equals) this intersection area.

This can be used by device-specific drawing code to limit complex pixel operations (like drawing images) to the smallest rectangle needed to update the visible area.

Return values:

  • 0 if it does not intersect, and W and H are set to zero.
  • 1 if if the result is equal to the rectangle (i.e. it is entirely inside or equal to the clip region)
  • 2 if it is partially clipped.

References fltk::Rectangle::b(), fltk::Rectangle::empty(), fltk::Rectangle::h(), fltk::Rectangle::r(), fltk::Rectangle::set(), fltk::Rectangle::set_b(), fltk::Rectangle::set_r(), fltk::Rectangle::set_x(), fltk::Rectangle::set_y(), fltk::Rectangle::w(), fltk::Rectangle::x(), XRectangleRegion(), and fltk::Rectangle::y().

Referenced by fltk::TiledImage::_draw(), fltk::Window::flush(), and glstart().

void fltk::setcolor ( Color  color  ) 

void fltk::setcolor_alpha ( Color  color,
float  alpha 
)

Sets the current rgb and alpha to draw in, on rendering systems that allow it. If alpha is not supported this is the same as setcolor(). The color you pass should not premultiplied by the alpha value, that would be a different, nyi, call.

References split_color().

Color fltk::getcolor (  )  [inline]

Returns the last Color passed to setcolor().

Referenced by fltk::PopupMenu::draw(), fltk::Input::draw(), drawtext(), and drawtext_transformed().

void fltk::setbgcolor ( Color  c  )  [inline]

Set the "background" color. This is not used by the drawing functions, but many box and image types will refer to it by calling getbgcolor().

Referenced by fltk::Slider::draw(), fltk::Item::draw(), fltk::Button::draw(), and drawstyle().

Color fltk::getbgcolor (  )  [inline]

Returns the last Color passed to setbgcolor(). To actually draw in the bg color, do this:

  Color saved = getcolor();
  setcolor(getbgcolor());
  draw_stuff();
  setcolor(saved)

Referenced by fltk::Item::draw(), fltk::Input::draw(), and fltk::Slider::draw_ticks().

void fltk::drawstyle ( const Style style,
Flags  flags 
)

Draw using this style. Set drawstyle() to this, drawflags() to flags, calls setcolor() and setbgcolor() with appropriate colors for this style and the given flags, and calls setfont(). This is called by the draw() methods on most fltk widgets. The calling Widget picks what flags to pass to the Symbols so that when they call this they get the correct colors for each part of the widget.

Flags that are understood:

  • HIGHLIGHT: if highlight_color() is non-zero, set bg to highlight_color() and fg to highlight_textcolor().
  • OUTPUT: Normally color(), textcolor(), textfont(), and textsize() are used. If this flag is set buttoncolor(), labelcolor(), labelfont(), and labelsize() are used. Widgets will set this true for any internal buttons, but false for the main area.
  • INACTIVE_R: Change the fg to a gray color.

It then further modifies fg so that it contrasts with the bg.

References fltk::Style::buttoncolor(), fltk::Style::color(), contrast(), HIGHLIGHT, fltk::Style::highlight_color(), fltk::Style::highlight_textcolor(), inactive(), INACTIVE_R, fltk::Style::labelcolor(), fltk::Style::labelfont(), fltk::Style::labelsize(), OUTPUT, setbgcolor(), setcolor(), setfont(), fltk::Style::textcolor(), fltk::Style::textfont(), and fltk::Style::textsize().

Referenced by fltk::Slider::draw(), fltk::PopupMenu::draw(), fltk::Item::draw(), fltk::Input::draw(), fltk::Choice::draw(), fltk::Button::draw(), fltk::Widget::draw_frame(), fltk::Menu::draw_in(), fltk::Widget::draw_label(), and fltk::Group::draw_outside_label().

const Style * fltk::drawstyle (  )  [inline]

Return the last style sent to drawstyle(s,f). Some drawing functions (such as glyphs) look in this for box types. If this has not been called it is Widget::default_style.

void fltk::setdrawflags ( Flags  f  )  [inline]

Store a set of bit flags that may influence the drawing of some fltk::Symbol subclasses, such as boxes. Generally you must also use setcolor() and setbgcolor() to set the color you expect as not all symbols draw differently depending on the flags.

The flags are usually copied from the flags() on a Widget.

Some commonly-used flags:

  • INACTIVE_R : Draw inactive, fill images with solid fg color
  • VALUE: Draw turned on or checked
  • SELECTED: Draw as though selected in a browser or menu.
  • HIGHLIGHT: Draw as though highlighted by the mouse pointing at it
  • PUSHED: Draw as though pushed by the user
  • FOCUSED: Draw as though it has keyboard focus
  • INVISIBLE: Some boxes don't draw their interior if this is set

See also:
fltk::drawstyle()

Referenced by fltk::Widget::draw_frame().

Flags fltk::drawflags (  )  [inline]

Flags fltk::drawflags ( Flags  f  )  [inline]

Same as (drawflags() & f), returns true if any of the flags in f are set.

void fltk::line_style ( int  style,
float  width = 0,
const char *  dashes = 0 
)

Set how to draw lines (the "pen"). If you change this it is your responsibility to set it back to the default with fltk::line_style(0).

style is a bitmask in which you 'or' the following values. If you don't specify a dash type you will get a solid line. If you don't specify a cap or join type you will get a system-defined default of whatever value is fastest.

  • fltk::SOLID -------
  • fltk::DASH - - - -
  • fltk::DOT ·········
  • fltk::DASHDOT - · - ·
  • fltk::DASHDOTDOT - ·· - ··
  • fltk::CAP_FLAT
  • fltk::CAP_ROUND
  • fltk::CAP_SQUARE (extends past end point 1/2 line width)
  • fltk::JOIN_MITER (pointed)
  • fltk::JOIN_ROUND
  • fltk::JOIN_BEVEL (flat)

width is the number of pixels thick to draw the lines. Zero results in the system-defined default, which on both X and Windows is somewhat different and nicer than 1.

dashes is a pointer to an array of dash lengths, measured in pixels, if set then the dash pattern in style is ignored. The first location is how long to draw a solid portion, the next is how long to draw the gap, then the solid, etc. It is terminated with a zero-length entry. A null pointer or a zero-length array results in a solid line. Odd array sizes are not supported and result in undefined behavior. The dashes array is ignored on Windows 95/98.

int fltk::line_style (  )  [inline]

Return the last value sent to line_style(int,width,dashes), indicating the cap and join types and the built-in dash patterns.

float fltk::line_width (  )  [inline]

Return the last value for width sent to line_style(int,width,dashes).

const char * fltk::line_dashes (  )  [inline]

Return the last value for dashes sent to line_style(int,width,dashes). Note that the actual pointer is returned, which may not point at legal data if a local array was passed, so this is only useful for checking if it is NULL or not.

void fltk::newpath (  ) 

Clear the current "path". This is normally done by fltk::fillpath() or any other drawing command.

void fltk::addvertex ( float  X,
float  Y 
)

Add a single vertex to the current path. (if the path is empty or a closepath() was done, this is equivalent to a "moveto" in PostScript, otherwise it is equivalent to a "lineto").

References transform().

Referenced by addarc(), and addpie().

void fltk::addvertex ( int  X,
int  Y 
)

This integer version is provided because it is much faster than the floating-point version. However C++ will not "resolve" which one you want to call if you try passing doubles as arguments. To get it to compile, make sure you cast the arguments to float (add 'f' after floating-point constants). Use the 'f' versions (ie sinf(), cosf(), etc) of the math functions from <fltk/math.h> to produce floats and get maximum calculation speed.

References transform().

void fltk::addvertices ( int  n,
const float  array[][2] 
)

Add a whole set of vertices to the current path. This is much faster than calling fltk::addvertex once for each point.

References transform().

Referenced by addarc().

void fltk::addvertices ( int  n,
const int  array[][2] 
)

Add a whole set of integer vertices to the current path.

References transform().

void fltk::addvertices_transformed ( int  n,
const float  array[][2] 
)

Adds a whole set of vertcies that have been produced from values returned by fltk::transform(). This is how curve() and arc() are implemented.

Referenced by addcurve().

void fltk::addcurve ( float  x0,
float  y0,
float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3 
)

Add a series of points on a Bezier spline to the path. The curve ends (and two of the points) are at x,y and x3,y3. The "handles" are at x1,y1 and x2,y2.

References addvertices_transformed(), and transform().

void fltk::addarc ( float  l,
float  t,
float  w,
float  h,
float  start,
float  end 
)

Add a series of points to the current path on the arc of an ellipse. The ellipse in inscribed in the l,t,w,h rectangle, and the start and end angles are measured in degrees counter-clockwise from 3 o'clock, 45 points at the upper-right corner of the rectangle. If end is less than start then it draws the arc in a clockwise direction.

References addvertex(), addvertices(), and transform_distance().

Referenced by addchord(), and addpie().

void fltk::addpie ( const Rectangle r,
float  start,
float  end 
)

Add a pie-shaped closed piece to the path, inscribed in the rectangle so if it is stroked with the default line width it exactly fills the rectangle (this is slightly smaller than addarc() will draw). If you want a full circle use addchord().

This tries to take advantage of the primitive calls provided by Xlib and GDI32. Limitations are that you can only draw one per path, that rotated coordinates don't work, and doing anything other than fillpath() will produce unpredictable results.

See also:
addchord()

References addarc(), addvertex(), closepath(), fltk::Rectangle::h(), transform(), fltk::Rectangle::w(), fltk::Rectangle::x(), and fltk::Rectangle::y().

void fltk::addchord ( const Rectangle r,
float  start,
float  end 
)

Add an isolated circular arc to the path. It is inscribed in the rectangle so if it is stroked with the default line width it exactly fills the rectangle (this is slightly smaller than addarc() will draw). If the angles are 0 and 360 a closed circle is added.

This tries to take advantage of the primitive calls provided by Xlib and GDI32. Limitations are that you can only draw one, a rotated current transform does not work.

References addarc(), closepath(), fltk::Rectangle::h(), transform(), fltk::Rectangle::w(), fltk::Rectangle::x(), and fltk::Rectangle::y().

void fltk::closepath (  ) 

Similar to drawing another vertex back at the starting point, but fltk knows the path is closed. The next addvertex() will start a new disconnected part of the shape.

It is harmless to call fltk::closepath() several times in a row, or to call it before the first point. Sections with less than 3 points in them will not draw anything when filled.

Referenced by addchord(), addpie(), fillpath(), and fillstrokepath().

void fltk::strokepath (  ) 

Draw a line between all the points in the path (see fltk::line_style() for ways to set the thicknesss and dot pattern of the line), then clear the path.

References fltk::Rectangle::b(), fltk::Rectangle::center_x(), fltk::Rectangle::center_y(), dc, fltk::Rectangle::empty(), gc, fltk::Rectangle::h(), fltk::Rectangle::r(), setpen(), fltk::Rectangle::w(), fltk::Rectangle::x(), xdisplay, xwindow, and fltk::Rectangle::y().

Referenced by fillstrokepath().

void fltk::fillpath (  ) 

Does fltk::closepath() and then fill with the current color, and then clear the path.

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.

Warning: result is somewhat different on X and Win32! Use fillstrokepath() to make matching shapes. In my opinion X is correct, we may change the Win32 version to match in the future, perhaps by making the current pen invisible?

References fltk::Rectangle::b(), fltk::Rectangle::center_x(), fltk::Rectangle::center_y(), closepath(), dc, fltk::Rectangle::empty(), gc, fltk::Rectangle::h(), fltk::Rectangle::r(), setbrush(), setpen(), fltk::Rectangle::w(), fltk::Rectangle::x(), xdisplay, xwindow, and fltk::Rectangle::y().

void fltk::fillstrokepath ( Color  color  ) 

Does fltk::fill(), then sets the current color to linecolor and does fltk::stroke with the same closed path, and then clears the path.

This seems to produce very similar results on X and Win32. Also it takes advantage of a single GDI32 call that does this and should be faster.

References fltk::Rectangle::b(), fltk::Rectangle::center_x(), fltk::Rectangle::center_y(), closepath(), dc, gc, fltk::Rectangle::h(), fltk::Rectangle::r(), setbrush(), setcolor(), setpen(), split_color(), strokepath(), fltk::Rectangle::w(), fltk::Rectangle::x(), xdisplay, xwindow, and fltk::Rectangle::y().

void fltk::fillrect ( int  x,
int  y,
int  w,
int  h 
)

void fltk::strokerect ( int  x,
int  y,
int  w,
int  h 
)

Draw a line inside this bounding box (currently correct only for 0-thickness lines).

References dc, gc, setpen(), transform(), xdisplay, and xwindow.

void fltk::drawline ( int  x,
int  y,
int  x1,
int  y1 
)

Draw a straight line between the two points.

If line_width() is zero, this tries to draw as though a 1x1 square pen is moved between the first centers of pixels to the lower-right of the start and end points. Thus if y==y1 this will fill a rectangle with the corners x,y and x1+1,y+1. This may be 1 wider than you expect, but is necessary for compatability with previous fltk versions (and is due to the original X11 behavior).

If line_width() is not zero then the results depend on the back end. It also may not produce consistent results if the ctm is not an integer translation or if the line is not horizontal or vertical.

References current_xpixel, dc, gc, setpen(), transform(), xdisplay, and xwindow.

Referenced by fltk::Slider::draw_ticks(), and drawpoint().

void fltk::drawline ( float  x,
float  y,
float  x1,
float  y1 
)

Draw a straight line between the two points.

References current_xpixel, dc, gc, setpen(), transform(), xdisplay, and xwindow.

void fltk::drawpoint ( int  x,
int  y 
)

Draw a dot at the given point. If line_width() is zero this is a single pixel to the lower-right of x,y. If line_width() is non-zero this is a dot drawn with the current pen and line caps.

References current_xpixel, dc, drawline(), fillrect(), gc, transform(), xdisplay, and xwindow.

void fltk::drawpoint ( float  X,
float  Y 
)

Draw a dot at the given point. If line_width() is zero this is the single pixel containing X,Y, or the one to the lower-right if X and Y transform to integers. If line_width() is non-zero this is a dot drawn with the current pen and line caps (currently draws nothing in some api's unless the line_style has CAP_ROUND).

References current_xpixel, dc, drawline(), fillrect(), gc, transform(), xdisplay, and xwindow.

void fltk::setfont ( fltk::Font font,
float  psize 
)

Set the current font and font scaling so the size is size pixels. The size is unaffected by the current transformation matrix (you may be able to use fltk::transform() to get the size to get a properly scaled font).

The size is given in pixels. Many pieces of software express sizes in "points" (for mysterious reasons, since everything else is measured in pixels!). To convert these point sizes to pixel sizes use the following code:

const fltk::Monitor& monitor = fltk::Monitor::all();
float pixels_per_point = monitor.dpi_y()/72.0;
float font_pixel_size = font_point_size*pixels_per_point;

See the fltk::Font class for a description of what can be passed as a font. For most uses one of the built-in constant fonts like fltk::HELVETICA can be used.

References fltk::Font::attributes_, fltk::Font::name_, and xdisplay.

Referenced by fltk::Input::draw(), fltk::Slider::draw_ticks(), drawstyle(), drawtext(), glsetfont(), fltk::Tooltip::layout(), fltk::Item::layout(), measure(), and fltk::Widget::measure_label().

const char * fltk::get_encoding (  )  [inline]

Returns the string sent to the most recent set_encoding().

void fltk::set_encoding ( const char *  f  ) 

Obsolete function to encourage FLTK to choose a 256-glyph font with the given encoding. You must call setfont() after changing this for it to have any effect.

Notice that this is obsolete! Only the non-Xft X version actually uses it and that may be eliminated as well. In addition FLTK uses UTF-8 internally, and assummes that any font it prints with is using Unicode encoding (or ISO-8859-1 if there are only 256 characters).

The default is "iso10646-1"

Font * fltk::getfont (  )  [inline]

Return the Font sent to the last setfont().

float fltk::getsize (  )  [inline]

Return the size sent to the last setfont(). You should use this as a minimum line spacing (using ascent()+descent() will produce oddly spaced lines for many fonts).

Referenced by fltk::Slider::draw_ticks(), and measure().

float fltk::getwidth ( const char *  text  ) 

Return the width of a nul-terminated UTF-8 string drawn in the font set by the most recent setfont().

Referenced by fltk::Input::draw(), fltk::Slider::draw_ticks(), drawtext(), fltk::Menu::layout_in(), and measure().

float fltk::getwidth ( const char *  text,
int  n 
)

Return the width of the first n bytes of this UTF-8 string drawn in the font set by the most recent setfont().

References utf8towc(), and xdisplay.

float fltk::getascent (  ) 

Return the distance from the baseline to the top of letters in the current font.

Referenced by fltk::Rectangle::baseline_y().

float fltk::getdescent (  ) 

Return the distance from the baseline to the bottom of letters in the current font.

Referenced by fltk::Rectangle::baseline_y(), and fltk::Slider::draw_ticks().

void fltk::drawtext_transformed ( const char *  text,
int  n,
float  x,
float  y 
)

Draw text starting at a point returned by fltk::transform(). This is needed for complex text layout when the current transform may not match the transform being used by the font.

References current_xpixel, getcolor(), split_color(), and utf8towc().

Referenced by drawtext().

void fltk::drawtext ( const char *  text,
float  x,
float  y 
)

Draw a nul-terminated string.

Referenced by fltk::Input::draw(), fltk::Slider::draw_ticks(), and drawtext().

void fltk::drawtext ( const char *  text,
int  n,
float  x,
float  y 
)

Draw the first n bytes (not characters if utf8 is used) starting at the given position.

References drawtext_transformed(), and transform().

void fltk::measure ( const char *  str,
int &  w,
int &  h,
Flags  flags = 0 
)

Measure the size of box necessary for drawtext() to draw the given string inside of it. The flags are used to set the alignment, though this should not make a difference except for fltk::ALIGN_WRAP. To correctly measure wrap w must be preset to the width you want to wrap at if fltk::ALIGN_WRAP is on in the flags! w and h are changed to the size of the resulting box.

References getsize(), getwidth(), and setfont().

Referenced by fltk::Widget::draw_label(), fltk::Tooltip::layout(), fltk::Item::layout(), and fltk::Widget::measure_label().

void fltk::measure ( float(*)(const char *, int)  getwidth,
const char *  str,
float &  w,
float &  h,
Flags  flags = 0 
)

This lets you pass your own measurement function to measure the widths of printed text. Also returns floating point sizes.

References getwidth(), and setfont().

void fltk::drawtext ( const char *  str,
const Rectangle r1,
Flags  flags 
)

This is the fancy string-drawing function that is used to draw all labels in fltk. The string is formatted and aligned inside the passed rectangle. This also:

  • Breaks the text into lines at \n characters. Word-wraps (if flags has fltk::ALIGN_WRAP set) so the words fit in the columns.
  • Looks up "@xyz;" sequeces to see if they are a Symbol, if so it prints that symbol instead. This is skipped if the flags has fltk::RAW_LABEL set.
  • Parses "&x" combinations to produce Microsoft style underscores, unless RAW_LABEL flag is set.
  • Splits it at every \t tab character and uses column_widths() to set each section into a column.

References drawtext(), drawtext_transformed(), getwidth(), load_identity(), pop_matrix(), push_matrix(), setcolor(), setfont(), and transform().

void fltk::drawtext ( void(*)(const char *, int, float, float)  textfunction,
float(*)(const char *, int)  getwidth,
const char *  str,
const Rectangle r,
Flags  flags 
)

Provides access to some of the @-string formatting for another graphics API. Most symbols will not work, but you will be able to access the line break and justifications, and commands that change the font, size, and color. I use this to format labels for that are drawn in OpenGL.

textfunction is called to draw all text. It's arguments are a pointer to a UTF-8 string, the length in bytes of that string, and two float numbers for the x and y to draw the text at.

textfunction may use getfont(), getsize(), and getcolor() to find out the settings and recreate them on the output device.

References ALIGN_BOTTOM, ALIGN_TOP, fltk::Rectangle::b(), drawflags(), fillrect(), getcolor(), getwidth(), fltk::Rectangle::h(), INACTIVE_R, pop_clip(), push_clip(), setcolor(), setfont(), fltk::Symbol::text(), fltk::Rectangle::w(), fltk::Rectangle::x(), and fltk::Rectangle::y().

void fltk::drawimage ( const uchar *  pointer,
fltk::PixelType  type,
const Rectangle r 
)

Same except line_delta is set to r.w() times depth(type), indicating the rows are packed together one after another with no gap.

References depth(), and fltk::Rectangle::w().

void fltk::drawimage ( const uchar *  pointer,
fltk::PixelType  type,
const Rectangle r,
int  line_delta 
)

Draw a image (a rectangle of pixels) stored in your program's memory. The current transformation (scale, rotate) is applied.

  • pointer points at the first byte of the top-left pixel.
  • type describes how to interpret the bytes of each pixel.
  • rectangle: the image is put in the top-left corner and the width and height declare how many pixels the image has.
  • line_delta is how much to add to pointer to go 1 pixel down. By setting line_delta to larger than depth(type)*r.w() you can crop a picture out of a larger buffer. You can also set it negative for images that are stored with bottom-to-top in memory, notice that in this case pointer still points at the top-left pixel, which is at the end of your buffer minus one line_delta.

The X version of FLTK will abort() if the default visual is one it cannot use for images. To avoid this call fltk::visual(fltk::RGB) at the start of your program.

References fltk::Image::draw(), fltk::Rectangle::h(), fltk::Image::setimage(), and fltk::Rectangle::w().

void fltk::drawimage ( DrawImageCallback  cb,
void *  userdata,
fltk::PixelType  type,
const Rectangle r 
)

Call the passed function to provide each scan line of the image. This lets you 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).

callback is called with the void* data argument (this can be used to point at a structure of information about the image), the x, y, and number of pixels desired from the image, measured from the upper-left corner of the image. It is also given a buffer of at least w pixels that can be used as temporary storage, for instance to decompress a line read from a file. You can then return a pointer to this buffer, or to somewhere inside it.

The callback must return n pixels of the format described by type.

The xywh rectangle describes the area to draw. The callback is called with y values between 0 and h-1. Due to cropping not all pixels may be asked for. You can assumme y will be asked for in increasing order.

References fltk::Image::draw(), fltk::Rectangle::h(), fltk::Image::linebuffer(), fltk::Image::setpixels(), fltk::Image::setpixeltype(), fltk::Image::setsize(), and fltk::Rectangle::w().

uchar * fltk::readimage ( uchar *  p,
PixelType  type,
const Rectangle &  r 
)

Same except linedelta is set to r.w()*depth(type).

References depth(), and fltk::Rectangle::w().

uchar * fltk::readimage ( uchar *  p,
PixelType  type,
const Rectangle &  rectangle,
int  linedelta 
)

Reads a 2-D image off the current drawing destination. The resulting data can be passed to fltk::drawimage() or the 8-bit pixels examined or stored by your program.

The return value is either p or NULL if there is some problem (such as an inability to read from the current output surface, or if the rectangle is empty).

p points to the location to store the first byte of the upper-left pixel of the image. The caller must allocate this buffer.

type can be fltk::RGB or fltk::RGBA (possibly other types will be supported in the future).

rectangle indicates the position on the surface in the current transformation to read from and the width and height of the resulting image. What happens when the current transformation is rotated or scaled is undefined. If the rectangle extends outside the current drawing surface, or into areas obscured by overlapping windows, the result in those areas is undefined.

linedelta is how much to add to a pointer to advance from one pixel to the one below it. Any bytes skipped over are left with undefined values in them. Negative values can be used to store the image upside-down, however p should point to 1 line before the end of the buffer, as it still points to the top-left pixel.

void fltk::scrollrect ( const Rectangle &  r,
int  dx,
int  dy,
void(*)(void *, const Rectangle &)  draw_area,
void *  data 
)

Move the contents of a rectangle by dx and dy. The area that was previously outside the rectangle or obscured by other windows is then redrawn by calling draw_area for each rectangle. This is a drawing function and can only be called inside the draw() method of a widget.

If dx and dy are zero this returns without doing anything.

If dx or dy are larger than the rectangle then this just calls draw_area for the entire rectangle. This is also done on systems (Quartz) that do not support copying screen regions.

References dc, gc, fltk::Rectangle::h(), transform(), fltk::Rectangle::w(), fltk::Rectangle::x(), xdisplay, xwindow, and fltk::Rectangle::y().

int fltk::event (  )  [inline]

Returns the most recent event handled, such as fltk::PUSH or fltk::KEY. This is useful so callbacks can find out why they were called.

Referenced by handle(), fltk::Input::handle(), modal(), and fltk::Menu::try_popup().

int fltk::event_x (  )  [inline]

Returns the distance the mouse is to the right of the left edge of the widget. Widget::send() modifies this as needed before calling the Widget::handle() method.

Referenced by fltk::Slider::handle(), fltk::NumericInput::handle(), fltk::Group::handle(), fltk::Input::mouse_position(), fltk::PopupMenu::popup(), and fltk::Menu::try_popup().

int fltk::event_y (  )  [inline]

Returns the distance the mouse is below the top edge of the widget. Widget::send() modifies this as needed before calling the Widget::handle() method.

Referenced by fltk::Slider::handle(), fltk::Group::handle(), fltk::Input::mouse_position(), fltk::PopupMenu::popup(), and fltk::Menu::try_popup().

int fltk::event_dx (  )  [inline]

For fltk::MOUSEWHEEL events this is how many clicks the user moved in the x and y directions (currently dx is always zero).

Referenced by fltk::Valuator::handle().

int fltk::event_dy (  )  [inline]

Reserved for future use if horizontal mouse wheels (or some kind of joystick on the mouse) becomes popular.

Referenced by fltk::Valuator::handle(), and fltk::NumericInput::handle().

int fltk::event_x_root (  )  [inline]

Return the absolute horizontal position of the mouse. Usually this is relative to the left edge of the screen, but multiple Monitor setup may change that.

To find the absolute position of the current widget, subtract event_x_root()-event_x().

Referenced by fltk::Tooltip::layout(), show_colormap(), and fltk::Menu::try_popup().

int fltk::event_y_root (  )  [inline]

Return the absolute vertical position of the mouse. Zero is at the top.

Referenced by fltk::Tooltip::layout(), show_colormap(), and fltk::Menu::try_popup().

int fltk::event_clicks (  )  [inline]

Returns the number of extra times the mouse was clicked. For a normal fltk::PUSH this is zero, if the user "double-clicks" this is 1, and it is N-1 for each subsequent click.

Referenced by fltk::Item::handle(), and fltk::Input::handle().

void fltk::event_clicks ( int  i  )  [inline]

Setting this value can be used to make callbacks think things were (or were not) double-clicked, and thus act differently.

bool fltk::event_is_click (  )  [inline]

This is true for a short time after the mouse key is pressed. You test this on the RELEASE events to decide if the user "clicked" or "held" the mouse. It is very useful to do different actions depending on this.

This turns off after a timeout (implemented on X only, currently), when the mouse is moved more than 5 pixels, and when the user presses other mouse or keyboard buttons while the mouse is down.

On X this is used to decide if a click is a double-click, it is if this is still on during the next mouse press. On Windows and OS/X the system's indication is used for double-click.

Referenced by fltk::Input::handle(), and modal().

void fltk::event_is_click ( bool   )  [inline]

You can set this to zero with fltk::event_is_click(0), this can be used to prevent the next mouse click from being considered a double click. Only false works, attempts to set this true are ignored.

unsigned fltk::event_state (  )  [inline]

This is a bitfield of what shift states were on and what mouse buttons were held down during the most recent event. The flags to pass are described under fltk::SHIFT.

Because Emacs screws up if any key returns the predefined META flag, lots of X servers have really botched up the key assignments trying to make Emacs work. Fltk tries to work around this but you may find that Alt or Meta don't work, since I have seen at least 3 mutually incompatible arrangements. Non-XFree86 machines may also have selected different values so that NUMLOCK, META, and SCROLLLOCK are mixed up. In addition X reports the state before the last key was pressed so the state looks backwards for any shift keys, currently fltk only fixes this bug for the mouse buttons.

Referenced by dnd(), fltk::Menu::draw_in(), event_key_state(), fltk::Tooltip::exit(), fltk::Valuator::handle(), handle(), fltk::NumericInput::handle(), fltk::Input::handle(), fltk::Input::handle_key(), fltk::Group::navigation_key(), fltk::Widget::send(), and fltk::Widget::test_label_shortcut().

bool fltk::event_state ( unsigned  mask  )  [inline]

Same as event_state()&mask, returns true if any of the passed bits were turned on during the last event. So doing event_state(SHIFT) will return true if the shift keys are held down. This is provided to make the calling code easier to read. The flags to pass are described under fltk::SHIFT.

unsigned fltk::event_key (  )  [inline]

Returns which key on the keyboard was last pushed. Most non-keyboard events set this to values that do not correspond to any keys, so you can test this in callbacks without having to test first if the event really was a keystroke. The values returned are described under fltk::SpaceKey.

Referenced by compose(), fltk::Valuator::handle(), fltk::Slider::handle(), handle(), fltk::NumericInput::handle(), fltk::Input::handle(), fltk::Input::handle_key(), and fltk::Group::navigation_key().

unsigned fltk::event_button (  )  [inline]

Returns which mouse button was pressed or released by a PUSH or RELEASE event. Returns garbage for other events, so be careful (this actually is the same as event_key(), the buttons have been assigned the key values 1,2,3, etc.

Referenced by fltk::Slider::handle(), and fltk::Input::handle().

bool fltk::event_key_state ( unsigned  key  ) 

Returns true if the given key was held down (or pressed) during the last event. This is constant until the next event is read from the server. The possible values for the key are listed under fltk::SpaceKey.

On Win32 event_key_state(KeypadEnter) does not work.

References event_state(), F0Key, LeftMetaKey, MenuKey, RightAltKey, RightMetaKey, and xdisplay.

Referenced by get_key_state().

const char * fltk::event_text (  )  [inline]

Returns the ASCII text (in the future this may be UTF-8) produced by the last fltk::KEY or fltk::PASTE or possibly other event. A zero-length string is returned for any keyboard function keys that do not produce text. This pointer points at a static buffer and is only valid until the next event is processed.

Under X this is the result of calling XLookupString().

Referenced by fltk::Input::handle(), fltk::Input::handle_key(), and fltk::Widget::test_label_shortcut().

unsigned fltk::event_length (  )  [inline]

Returns the length of the text in fltk::event_text(). There will always be a nul at this position in the text. However there may be a nul before that if the keystroke translates to a nul character or you paste a nul character.

Referenced by fltk::Input::handle(), and fltk::Input::handle_key().

unsigned fltk::event_key_repeated (  )  [inline]

True if the most recent KEY event was caused by a repeating held-down key on the keyboard. The value increments for each repeat.

Note: older versions of fltk reused event_clicks() for this. This made it impossible to design a GUI where the user holds down keyboard keys while clicking the mouse, as well as being pretty hard to understand. So we had to change it for fltk 2.

bool fltk::event_inside ( const Rectangle r  ) 

Returns true if the current fltk::event_x() and fltk::event_y() put it inside the Rectangle. You should always call this rather than doing your own comparison so you are consistent about edge effects.

References fltk::Rectangle::contains().

bool fltk::compose ( int &  del  ) 

Use of this function is very simple. Any text editing widget should call this for each fltk::KEY event.

If true is returned, then it has modified the fltk::event_text() and fltk::event_length() to a set of bytes to insert (it may be of zero length!). It will also set the del parameter to the number of bytes to the left of the cursor to delete, this is used to delete the results of the previous call to fltk::compose(). Compose may consume the key, which is indicated by returning true, but both the length and del are set to zero.

Compose returns false if it thinks the key is a function key that the widget should handle itself, and not an attempt by the user to insert text.

Though the current implementation returns immediately, future versions may take quite awhile, as they may pop up a window or do other user-interface things to allow international characters to be selected.

References ALT, event_key(), META, RightAltKey, RightCtrlKey, and SCROLLLOCK.

Referenced by fltk::Input::handle_key().

void fltk::compose_reset (  )  [inline]

If the user moves the cursor, be sure to call fltk::compose_reset(). The next call to fltk::compose() will start out in an initial state. In particular it will not set "del" to non-zero. This call is very fast so it is ok to call it many times and in many places.

Referenced by focus().

bool fltk::try_shortcut (  ) 

Try sending the current KEY event as a SHORTCUT event.

Normally the focus() gets all keystrokes, and shortcuts are only tested if that widget indicates it is uninterested by returning zero from Widget::handle(). However in some cases the focus wants to use the keystroke only if it is not a shortcut. The most common example is Emacs-style editing keystrokes in text editing widgets, which conflict with Microsoft-compatable menu key bindings, but we want the editing keys to work if there is no conflict.

This will send a SHORTCUT event just like the focus returned zero, to every widget in the focus window, and to the add_handler() calls, if any. It will return true if any widgets were found that were interested in it. A handle() method can call this in a KEY event. If it returns true, return 1 immediatly, as the shortcut will have executed and may very well have destroyed your widget. If this returns false, then do what you want the key to do.

References handle(), and SHORTCUT.

Referenced by fltk::Input::handle_key().

const char * fltk::key_name ( unsigned  hotkey  ) 

Unparse a fltk::Widget::shortcut(), an fltk::event_key(), or an fltk::event_key() or'd with fltk::event_state(). Returns a pointer to a human-readable string like "Alt+N". If hotkey is zero an empty string is returned. The return value points at a static buffer that is overwritten with each call.

The opposite function is fltk::key().

References ALT, CTRL, F0Key, F9Key, key(), Keypad, KeypadLast, LastFunctionKey, META, and SHIFT.

Referenced by fltk::Menu::draw_in(), and fltk::Menu::layout_in().

unsigned fltk::key ( const char *  name  ) 

Turn a string into a fltk::event_key() value or'd with fltk::event_shift() flags. The returned value can be used by by fltk::Widget::add_shortcut(). Any error, or a null or zero-length string, returns 0.

Currently this understands prefixes of "Alt+", "Shift+", and "Ctrl+" to turn on fltk::ALT, fltk::SHIFT, and fltk::CTRL. Case is ignored and the '+' can be a '-' instead and the prefixes can be in any order. You can also use '#' instead of "Alt+", '+' instead of "Shift+", and '^' instead of Ctrl+.

After the shift prefixes there can either be a single ASCII letter, "Fn" where n is a number to indicate a function key, or "0xnnnn" to get an arbitrary fltk::event_key() enumeration value.

The inverse function to turn a number into a string is fltk::key_name(). Currently this function does not parse some strings fltk::key_name() can return, such as the names of arrow keys!

References ALT, COMMAND, CTRL, F0Key, META, SHIFT, and strncasecmp().

Referenced by fltk::Group::handle(), and key_name().

unsigned fltk::foreachShortcut ( const Widget widget,
ShortcutFunctor &  f 
)

Call the handle() method from the passed ShortcutFunctor object for every Widget::shortcut() assignment known. If any return true then this immediately returns that shortcut value, else this returns zero after calling it for the last one. This is most useful for making a display of shortcuts for the user, or implementing a shortcut editor.

class ListShortcuts : public ShortcutFunctor {
public:
  bool handle(const Widget* widget, unsigned key) {
    printf("Widget=%s shortcut=%s\n",
           widget->label() ? widget->label() : "NULL",
           key_name(key));
    return false;
  }
};
f() {
  ListShortcuts listShortcuts;
  fltk::foreachShortcut(listShortcuts);
}

If widget is not null, only do assignments for that widget, this is much faster than searching the entire list. This is useful for drawing the shortcuts on a widget (though most fltk widgets only draw the first one).

bool fltk::get_key_state ( unsigned  key  ) 

Returns true if the given key is held down now. This is different than event_key_state() as that returns how the key was during the last event. This can also be slower as it requires a round-trip query to the window server. The values to pass are described under fltk::SpaceKey.

On Win32 fltk::get_key_state(fltk::KeypadEnter) does not work.

References event_key_state(), open_display(), and xdisplay.

void fltk::get_mouse ( int &  x,
int &  y 
)

Return where the mouse is on the screen by doing a round-trip query to the server. You should use fltk::event_x_root() and fltk::event_y_root() if possible, but this is necessary if you are not sure if a mouse event has been processed recently (such as to position your first window). If the display is not open, this will open it.

References open_display(), xdisplay, and xscreen.

Referenced by fltk::Window::hotspot().

bool fltk::warp_mouse ( int  x,
int  y 
)

Change where the mouse is on the screen. Returns true if successful, false on failure (exactly what success and failure means depends on the os).

References xdisplay, and xscreen.

bool fltk::handle ( int  event,
Window window 
)

This is the function called from the system-specific code for all events that can be passed to Widget::handle().

You can call it directly to fake events happening to your widgets. Currently data other than the event number can only be faked by writing to the undocumented fltk::e_* variables, for instance to make event_x() return 5, you should do fltk::e_x = 5. This may change in future versions.

This will redirect events to the modal(), pushed(), belowmouse(), or focus() widget depending on those settings and the event type. It will turn MOVE into DRAG if any buttons are down. If the resulting widget returns 0 (or the window or widget is null) then the functions pointed to by add_event_handler() are called.

References ANY_BUTTON, belowmouse(), fltk::Widget::contains(), fltk::Group::current(), DND_DRAG, DND_ENTER, DND_LEAVE, DND_RELEASE, DRAG, fltk::Tooltip::enter(), ENTER, event_key(), event_name(), event_state(), fltk::Tooltip::exit(), focus(), HIDE, KEY, KEYUP, LEAVE, MOUSEWHEEL, MOVE, fltk::Widget::parent(), PUSH, pushed(), RELEASE, fltk::Widget::send(), SHORTCUT, and SHOW.

Referenced by handle(), modal(), and try_shortcut().

void fltk::add_event_handler ( int(*)(int, Window *)  h  ) 

Install a function to parse unrecognized events. If FLTK cannot figure out what to do with an event, it calls each of these functions (most recent first) until one of them returns non-zero. If none of them returns non zero then the event is ignored.

Currently this is called for these reasons:

  • If there is a keystroke that no widgets are interested in, this is called with fltk::SHORTCUT. You can use this to implement global hotkeys.
  • Unrecognized X events cause this to be called with NO_EVENT. The Window parameter is set if fltk can figure out the target window and it is an fltk one. You can then use system specific code to access the event data and figure out what to do. This is not done on Windows due to the enormous number of garbage messages a program gets, you should instead use Windows pre-filtering functions to look at these.
  • Events it gets with a window id it does not recognize cause this to be called, with the Window parameter set to null. This can only happen on X, on Windows any unknown windows should have their own message handling function that does not call fltk.
  • This may be called with other event types when the widget fltk wants to send it to returns zero. However the exact rules when this happens may change in future versions.

Referenced by fltk::Menu::global().

Widget * fltk::belowmouse (  )  [inline]

Get the widget that is below the mouse. This is the last widget to respond to an fltk::ENTER event as long as the mouse is still pointing at it. This is for highlighting buttons and bringing up tooltips. It is not used to send fltk::PUSH or fltk::MOVE directly, for several obscure reasons, but those events typically go to this widget.

Referenced by dnd(), handle(), fltk::Widget::send(), and fltk::Widget::throw_focus().

void fltk::belowmouse ( Widget o  ) 

Change the fltk::belowmouse() widget, the previous one and all parents (that don't contain the new widget) are sent fltk::LEAVE events. Changing this does not send fltk::ENTER to this or any widget, because sending fltk::ENTER is supposed to test if the widget wants the mouse (by it returning non-zero from handle()).

References fltk::Widget::clear_flag(), fltk::Widget::contains(), DND_LEAVE, fltk::Widget::handle(), HIGHLIGHT, LEAVE, and fltk::Widget::parent().

Widget * fltk::pushed (  )  [inline]

Get the widget that is being pushed. fltk::DRAG or fltk::RELEASE (and any more fltk::PUSH) events will be sent to this widget. This is null if no mouse button is being held down, or if no widget responded to the fltk::PUSH event.

Referenced by handle(), fltk::Widget::send(), and fltk::Widget::throw_focus().

void fltk::pushed ( Widget o  ) 

Change the fltk::pushed() widget. This sends no events.

Widget * fltk::focus (  )  [inline]

Returns the widgets that will receive fltk::KEY events. This is NULL if the application does not have focus now, or if no widgets accepted focus.

Referenced by fltk::Widget::activate(), fltk::Widget::focused(), handle(), fltk::Group::handle(), fltk::TabGroup::selected_child(), fltk::Widget::send(), fltk::Browser::set_focus(), and fltk::Widget::take_focus().

void fltk::focus ( Widget o  ) 

Change fltk::focus() to the given widget, the previous widget and all parents (that don't contain the new widget) are sent fltk::UNFOCUS events, the new widget is sent an fltk::FOCUS event, and all parents of it get fltk::FOCUS_CHANGE events.

fltk::focus() is set whether or not the applicaton has the focus or if the widgets accept the focus. You may want to use fltk::Widget::take_focus() instead, it will test first.

References fltk::Widget::clear_flag(), compose_reset(), fltk::Widget::contains(), fltk::Window::first(), FOCUS, FOCUS_CHANGE, FOCUSED, fltk::Widget::handle(), fltk::Widget::is_window(), fltk::Widget::parent(), fltk::Widget::set_flag(), UNFOCUS, and fltk::Widget::window().

void fltk::copy ( const char *  stuff,
int  len,
bool  clipboard = false 
)

Change the current selection. The block of text is copied to an internal buffer by FLTK (be careful if doing this in response to an fltk::PASTE as this may be the same buffer returned by event_text()).

The block of text may be retrieved (from this program or whatever program last set it) with fltk::paste().

There are actually two buffers. If clipboard is true then the text goes into the user-visible selection that is moved around with cut/copy/paste commands (on X this is the CLIPBOARD selection). If clipboard is false then the text goes into a less-visible buffer used for temporarily selecting text with the mouse and for drag & drop (on X this is the XA_PRIMARY selection).

References event_time, message_window, and xdisplay.

Referenced by vsnprintf().

void fltk::paste ( Widget receiver,
bool  clipboard = false 
)

This is what a widget does when a "paste" command (like Ctrl+V or the middle mouse click) is done to it. Cause an fltk::PASTE event to be sent to the receiver with the contents of the current selection in the fltk::event_text(). The selection can be set by fltk::copy().

There are actually two buffers. If clipboard is true then the text is from the user-visible selection that is moved around with cut/copy/paste commands (on X this is the CLIPBOARD selection). If clipboard is false then the text is from a less-visible buffer used for temporarily selecting text with the mouse and for drag & drop (on X this is the XA_PRIMARY selection).

The reciever should be prepared to be called directly by this, or for it to happen later, or possibly not at all. This allows the window system to take as long as necessary to retrieve the paste buffer (or even to screw up completely) without complex and error-prone synchronization code most toolkits require.

References event_time, fltk::Window::first(), fltk::Widget::handle(), PASTE, xdisplay, and xid().

Referenced by dnd(), fltk::Input::handle(), and fltk::Input::handle_key().

bool fltk::dnd (  ) 

Drag and drop the data set by the most recent fltk::copy() (with the clipboard argument false). Returns true if the data was dropped on something that accepted it.

By default only blocks of text are dragged. You can use system-specific variables to change the type of data.

References ANY_BUTTON, belowmouse(), fltk::Widget::cursor(), dnd_action, DND_DRAG, DND_ENTER, DND_LEAVE, DND_RELEASE, dnd_source_action, dnd_source_types, dnd_source_window, dnd_type, event_state(), event_time, fltk::Window::first(), message_window, msg, paste(), version(), wait(), xdisplay, xid(), and xscreen.

Referenced by fltk::Input::handle().

void fltk::modal ( Widget widget,
bool  grab = false 
)

Restricts events to a certain widget.

First thing: much of the time fltk::Window::exec() will do what you want, so try using that.

This function sets the passed widget as the "modal widget". All user events are directed to it or a child of it, preventing the user from messing with other widgets. The modal widget does not have to be visible or even a child of an fltk::Window for this to work (but if it not visible, fltk::event_x() and fltk::event_y() are meaningless, use fltk::event_x_root() and fltk::event_y_root()).

The calling code is responsible for saving the current value of modal() and grab() and restoring them by calling this after it is done. The code calling this should then loop calling fltk::wait() until fltk::exit_modal_flag() is set or you otherwise decide to get out of the modal state. It is the calling code's responsibility to monitor this flag and restore the modal widget to it's previous value when it turns on.

grab indicates that the modal widget should get events from anywhere on the screen. This is done by messing with the window system. If fltk::exit_modal() is called in response to an fltk::PUSH event (rather than waiting for the drag or release event) fltk will "repost" the event so that it is handled after modal state is exited. This may also be done for keystrokes in the future. On both X and WIN32 grab will not work unless you have some visible window because the system interface needs a visible window id. On X be careful that your program does not enter an infinite loop while grab() is on, it will lock up your screen!

References fltk::Group::current(), event(), event_is_click(), event_time, fltk::Window::first(), handle(), MOVE, PUSH, xdisplay, and xid().

Referenced by fltk::CreatedWindow::create(), fltk::Window::destroy(), fltk::Window::exec(), handle(), fltk::Window::show(), and fltk::Menu::try_popup().

Widget * fltk::modal (  )  [inline]

Returns the current modal widget, or null if there isn't one. It is useful to test these in timeouts and file descriptor callbacks in order to block actions that should not happen while the modal window is up. You also need these in order to save and restore the modal state.

bool fltk::grab (  )  [inline]

returns the current value of grab (this is always false if modal() is null).

Referenced by fltk::Window::exec(), handle(), fltk::Window::show(), and fltk::Menu::try_popup().

void fltk::exit_modal (  )  [inline]

Turns on exit_modal_flag(). This may be used by user callbacks to cancel modal state. See also fltk::Window::make_exec_return().

Referenced by fltk::Window::make_exec_return(), and fltk::Widget::throw_focus().

bool fltk::exit_modal_flag (  )  [inline]

True if exit_modal() has been called. The flag is also set by the destruction or hiding of the modal widget, and on Windows by other applications taking the focus when grab is on.

Referenced by fltk::Window::exec(), and fltk::Menu::try_popup().

int fltk::filename_absolute ( char *  output,
int  length,
const char *  input,
const char *  pwd = 0 
)

Return the filename from expanded to a full "absolute" path name by prepending the current directory:

  • output is a pointer to a buffer that the result is written to.
  • length is the size of output. No more than length-1 bytes are written, plus a trailing nul.
  • input is the initial filename. Must be different than output!
  • cwd is the directory that filename is relative to. If this is NULL then the result of getcwd() is used.

The return value is the number of bytes this wants to write to output. If this value is greater or equal to length, then you know the output has been truncated, and you can call this again with a buffer of n+1 bytes.

Leading "./" sequences in input are removed, and "../" sequences are removed as well as the matching trailing part of the prefixed directory. Technically this is incorrect if symbolic links are used but this matches the behavior of most programs.

If the pwd argument is null, this also expands names starting with '~' to the user or another user's HOME directory. To expand a filename starting with ~ in the current directory you must start it with "./~".

If input is a zero-length string then the pwd is returned with a slash added to the end.

References strlcpy().

int fltk::filename_relative ( char *  to,
int  tolen,
const char *  from,
const char *  cwd = 0 
)

Does the opposite of filename_absolute(). Produces the shortest possible name in output that is relative to the current directory. If the filename does not start with any text that matches the current directory then it is returned unchanged.

Return value is the number of characters it wants to write to output.

References strlcat(), and strlcpy().

const char * fltk::filename_name ( const char *  name  ) 

Returns a pointer to after the last slash in name. If the name ends with a slash then this returns a pointer to the NUL. If there is no slash this returns a pointer to the start of name.

Referenced by fltk::Window::label(), and fltk::Window::show().

const char * fltk::filename_ext ( const char *  buf  ) 

Returns a pointer to the last period in filename_name(f), or a pointer to the trailing nul if none. Notice that this points at the period, not after it!

bool fltk::filename_match ( const char *  s,
const char *  p 
)

Returns true if filename s matches pattern p. The following glob syntax is used by pattern:

  • "\x" quotes the character x so it must be matched exactly
  • "*" matches any sequence of 0 or more characters.
  • "?" matches any single character.
  • "[set]" matches any character in the set. Set can contain any single characters, or a-z to represent a range. To match ] or - they must be the first characters. To match ^ or ! they must not be the first characters.
  • "[^set]" or "[!set]" matches any character not in the set.
  • "{X|Y|Z}" or "{X,Y,Z}" matches any one of the subexpressions literally.
  • lowercase letters match both upper and lowercase
  • all other characters must match exactly

bool fltk::filename_exist ( const char *  name  ) 

Returns true if the file exists .

bool fltk::filename_isdir ( const char *  name  ) 

Returns true if the file exists and is a directory.

FL_FILESIZE_T fltk::filename_size ( const char *  name  ) 

Returns the size of the file in bytes. Returns zero if it does not exist.

long int fltk::filename_mtime ( const char *  name  ) 

Returns the modification time of the file as a Unix timestamp (number of seconds since the start of 1970 in GMT). Returns 0 if the file does not exist.

double fltk::version (  ) 

Returns the value of FL_VERSION that FLTK was compiled with. This can be compared to the FL_VERSION macro to see if the shared library of fltk your program linked with is up to date.

Referenced by fltk::CreatedWindow::create(), dnd(), and enable_tablet_events().

fltk::Font * fltk::font ( int  i  )  [related]

For back-compatabilty with FLTK1, this turns an integer into one of the built-in fonts. 0 = HELVETICA.

References font().

Referenced by font(), and fltk::Font::font().

void fltk::glstart (  ) 

Set up an OpenGL context to draw into the current window being drawn by fltk. This will allow you to use OpenGL to update a normal window. The current transformation is reproduced, and the current clipping is simulated with glScissor() calls (which can only do a rectangle).

You must use glfinish() to exit this mode before any normal fltk drawing calls are done.

You should call glvisual() at program startup if you intend to use this. This may be used to change how windows are created so this call works.

I would like this to work reliably, but it is not real good now on any platforms. In particular it does not cooperate with the double-buffering schemes. It does appear to work on X when you turn off double buffering, it also works if OpenGL is entirely software, such as MESA.

Do not call glstart()/glfinish() when drawing into a GlWindow!

References fltk::Rectangle::b(), fltk::Window::drawing_window(), glVisual(), fltk::Rectangle::h(), intersect_with_clip(), fltk::Rectangle::w(), fltk::Rectangle::x(), and xvisual.

void fltk::glfinish (  ) 

Turn off the effects of a previous glstart(). You must call this before using normal fltk drawing methods.

void fltk::glsetcolor ( Color  i  ) 

Set the current OpenGL color to a FLTK color, or as close as possible.

References BLACK, nearest_index(), split_color(), and xpixel().

void fltk::glstrokerect ( int  x,
int  y,
int  w,
int  h 
)

Draw a 1-thick line just inside the given rectangle.

void fltk::glfillrect ( int  x,
int  y,
int  w,
int  h 
) [inline]

Inline wrapper for glRecti(x,y,x+w,y+h).

void fltk::glsetfont ( fltk::Font font,
float  size 
)

Make the current OpenGL font (as used by gldrawtext()) be as similar as possible to an FLTK Font. Currently the font is aliased except on X.

References fltk::Font::name(), setfont(), and xfont().

void fltk::gldrawtext ( const char *  str  ) 

Draw text at the current glRasterPos in the current font selected with fltk::glsetfont(). You can use glRasterPos2f() or similar calls to set the position before calling this.

The string is in UTF-8, although only characters in ISO-8859-1 are drawn correctly, others draw as question marks.

Referenced by gldrawtext().

void fltk::gldrawtext ( const char *  text,
int  n 
)

Draw the first n bytes of text at the current glRasterPos.

References utf8toa().

void fltk::gldrawtext ( const char *  str,
float  x,
float  y,
float  z = 0 
)

Draw text at the given point in 3D space transformed to the screen.

References gldrawtext().

void fltk::gldrawtext ( const char *  str,
int  n,
float  x,
float  y,
float  z = 0 
)

Draw the first n bytes of text at the given point in 3D space transformed to the screen.

References gldrawtext().

void fltk::gldrawimage ( const uchar *  b,
int  x,
int  y,
int  w,
int  h,
int  d = 3,
int  ld = 0 
)

Uses glDrawPixels to draw an image using the same arguments as drawimage(). If you are in the normal OpenGL coordinate system with 0,0 in the lower-left, the first pixel is memory is the lower-left corner.

void fltk::open_display (  ) 

Opens the display. Does nothing if it is already open. You should call this if you wish to do X calls and there is a chance that your code will be called before the first show() of a window. This is called automatically Window::show().

This may call fltk::abort() if there is an error opening the display.

References fatal, and xdisplay.

Referenced by fltk::Monitor::all(), beep(), enable_tablet_events(), fltk::Font::encodings(), get_key_state(), get_mouse(), fltk::Monitor::list(), parsecolor(), fltk::Window::show(), and fltk::Font::sizes().

void fltk::close_display (  ) 

This closes the X connection. You do not need to call this to exit, and in fact it is faster to not do so! It may be useful to call this if you want your program to continue without the X connection. You cannot open the display again, and probably cannot call any FLTK functions.

References remove_fd(), and xdisplay.

Region fltk::clip_region (  ) 

Return the current region as a system-specific structure. You must include <fltk/x.h> to use this. Returns null if there is no clipping.

Return the current region as a system-specific structure. You must include <fltk/x.h> to use this. Returns null if there is no clipping.

References clip_region().

const char * fltk::xfont (  ) 

Returns the operating-system dependent structure defining the current font. You must include <fltk/x.h> to use this.

References fltk::Font::attributes_, fltk::Font::name_, and xdisplay.

Referenced by glsetfont().

int fltk::depth ( PixelType  t  )  [inline]

Turn a PixelType into the number of bytes needed to hold a pixel.

Referenced by fltk::Image::depth(), drawimage(), readimage(), fltk::Image::setimage(), and fltk::Image::setpixels().

void fltk::display ( const char *  d  ) 

Startup method to set what X display to use. This uses setenv() to change the $DISPLAY environment variable, so it will affect programs that are exec'd by this one.

This does some "uglification" required by X. If there is no colon in the string it appends ":0.0" to it. Thus a plain machine name may be used.

On non-X systems this sets the environment variable anyway, even though it probably will not affect the display used. It appears that putenv is missing on some versions of Windows so I commented it all out there, sigh.

Referenced by arg().

int fltk::arg ( int  argc,
char **  argv,
int &  i 
)

Consume a single switch from argv, starting at word i. Returns the number of words eaten (1 or 2, or 0 if it is not recognized) and adds the same value to i. You can use this function if you prefer to control the incrementing through the arguments yourself. The arguments recognized are listed under args().

The args() argument parser is entirely optional. It was written to make demo programs easy to write, although some minor work was done to make it usable by more complex programs. But there is no requirement that you call it or even acknoledge it's existence, if you prefer to use your own code to parse switches.

References display(), and error.

Referenced by args(), and fltk::Widget::do_callback().

int fltk::args ( int  argc,
char **  argv,
int &  i,
int(*)(int, char **, int &)  cb = 0 
)

Consume all switches from argv.

To use the switch parser, call fltk::args(argc,argv) near the start of your program. This does not open the display, instead switches that need the display open are stashed into static variables. Then you must display your first window by calling window->show(argc,argv), which will do anything stored in the static variables.

callback lets you define your own switches. It is called with the same argc and argv, and with i the index of each word. The callback should return zero if the switch is unrecognized, and not change i. It should return non-zero if the switch is recognized, and add at least 1 to i (it can add more to consume words after the switch). This function is called before any other tests, so you can override any FLTK switch (this is why fltk can use very short switches instead of the long ones all other toolkits force you to use).

On return i is set to the index of the first non-switch. This is either:

  • The first word that does not start with '-'.
  • The word "-" (used by many programs to name stdin as a file)
  • The first word after "--" (GNU standard end-of-switches switch)
  • The first unrecognized switch (return value is 0).
  • argc

The return value is i unless an unrecognized switch is found, in which case it is zero. If your program takes no arguments other than switches you should produce an error if the return value is less than argc.

All switches may be abbreviated one letter and case is ignored:

  • -iconic Window::iconize() will be done to the window.
  • -geometry WxH Window is resized to this width & height
  • -geometry +X+Y Initial window position
  • -geometry WxH+X+Y Window is resized and positioned.
  • -display host or -display host:n.n The X display to use (ignored under WIN32).
  • -name string will set the Window::label()
  • -bg color Call set_background() with the named color. Use "#rrggbb" to set it in hex.
  • -background color is the same as -bg color

References arg().

Referenced by args(), fltk::StatusBarGroup::set(), and fltk::Window::show().

void fltk::args ( int  argc,
char **  argv 
)

The second form of fltk::args() is useful if your program does not have command line switches of its own. It parses all the switches, and if any are not recognized it calls fltk::fatal(fltk::help).

References args(), and error.

bool fltk::enable_tablet_events (  ) 

Call this to indicate that you are interested in getting more information from a pen tablet device. It does some necessary overhead to enable tablets on X and Windows. In the future FLTK may do this automatically without you calling this.

If a tablet is detected, fltk::event_pressure() will return the pen pressure as a float value between 0 and 1. Some tablets also support event_x_tilt() and event_y_tilt().

References open_display(), version(), and xdisplay.

int fltk::wait (  ) 

Same as fltk::wait(infinity). Call this repeatedly to "run" your program. You can also check what happened each time after this returns, which is quite useful for managing program state.

Referenced by check(), dnd(), fltk::Window::exec(), run(), and fltk::Menu::try_popup().

int fltk::wait ( float  time_to_wait  ) 

Waits until "something happens", or the given time interval passes. It can return much sooner than the time if something happens.

What this really does is call all idle callbacks, all elapsed timeouts, call fltk::flush() to get the screen to update, and then wait some time (zero if there are idle callbacks, the shortest of all pending timeouts, or the given time), for any events from the user or any fltk::add_fd() callbacks. It then handles the events and calls the callbacks and then returns.

The return value is zero if nothing happened before the passed time_to_wait expired. It is non-zero if any events or timeouts came in.

References flush().

int fltk::check (  ) 

Same as fltk::wait(0). Calling this during a big calculation will keep the screen up to date and the interface responsive:

while (!calculation_done()) {
  calculate();
  fltk::check();
  if (user_hit_abort_button()) break;
}

References wait().

Referenced by register_images().

int fltk::ready (  ) 

Test to see if any events or callbacks are pending. This will return true if fltk::check() would do anything other than update the screen. Since this will not draw anything or call any code, it is safe to call this if your program is in an inconsistent state. This is also useful if your calculation is updating widgets but you do not want or need the overhead of the screen updating every time you check for events.

while (!calculation_done()) {
  calculate();
  if (fltk::ready()) {
    do_expensive_cleanup();
    fltk::check();
    if (user_hit_abort_button()) break;
  }
}

int fltk::run (  ) 

Calls fltk::wait() as long as any windows are not closed. When all the windows are hidden or destroyed (checked by seeing if Window::first() is null) this will return with zero. A program can also exit by having a callback call exit() or abort().

Most fltk programs will end main() with return fltk::run();.

References fltk::Window::first(), and wait().

void fltk::flush (  ) 

write all preferences to disk

  • this function works only with the base preference group
  • this function is rarely used as deleting the base preferences flushes automatically

Get the display up to date. This is done by calling layout() on all Window objects with layout_damage() and then calling draw() on all Window objects with damage(). (actually it calls Window::flush() and that calls draw(), but normally you can ignore this). This will also flush the X i/o buffer, update the cursor shape, update Windows window sizes, and other operations to get the display up to date.

wait() calls this before it waits for events.

Referenced by fltk::CreatedWindow::create(), and wait().

void fltk::redraw ( void   ) 

Redraws all widgets. This is a good idea if you have made global changes to the styles.

References fltk::CreatedWindow::next, fltk::Widget::redraw(), and fltk::CreatedWindow::window.

Referenced by fltk::ProgressBar::position(), reload_theme(), and fltk::ProgressBar::step().

int fltk::damage (  )  [inline]

True if any Widget::redraw() calls have been done since the last fltk::flush(). This indicates that flush() will do something. Currently the meaning of any bits are undefined.

Window flush() routines can set this to indicate that flush() should be called again after waiting for more events. This is useful in some instances such as X windows that are waiting for a mapping event before being drawn.

Referenced by fltk::Widget::redraw().

double fltk::get_time_secs (  ) 

Return portable time that increases by 1.0 each second.

On Windows it represents the time since system start, on Unixes, it's the gettimeofday().

Using a double, the numerical precision exceeds 1/1040000 even for the Unix gettimeofday value (which is seconds since 1970). However you should only store the difference between these values in a float.

The precision of the returned value depends on the OS, but the minimum precision is 20ms.

void fltk::add_timeout ( float  time,
TimeoutHandler  cb,
void *  arg = 0 
)

Add a one-shot timeout callback. The function will be called by fltk::wait() at t seconds after this function is called. The optional void* argument is passed to the callback.

void fltk::repeat_timeout ( float  time,
TimeoutHandler  cb,
void *  arg = 0 
)

Similar to add_timeout(), but rather than the time being measured from "now", it is measured from when the system call elapsed that caused this timeout to be called. This will result in far more accurate spacing of the timeout callbacks, it also has slightly less system call overhead. (It will also use all your machine time if your timeout code and fltk's overhead take more than t seconds, as the real timeout will be reduced to zero).

Outside a timeout callback this acts like add_timeout().

This code will print "TICK" each second on stdout, with a fair degree of accuracy:

void callback(void*) {
  printf("TICK\n");
  fltk::repeat_timeout(1.0,callback);
}

main() {
  fltk::add_timeout(1.0,callback);
  for (;;) fltk::wait();
}

bool fltk::has_timeout ( TimeoutHandler  cb,
void *  arg = 0 
)

Returns true if the timeout exists and has not been called yet.

void fltk::remove_timeout ( TimeoutHandler  cb,
void *  arg = 0 
)

Removes all pending timeout callbacks that match the function and arg. Does nothing if there are no matching ones that have not been called yet.

void fltk::add_check ( TimeoutHandler  cb,
void *  arg = 0 
)

Fltk will call this callback just before it flushes the display and waits for events. This is different than add_idle() because it is only called once, then fltk calls the system and tells it not to return until an event happens. If several checks have been added fltk calls them all, the most recently added one first.

This can be used by code that wants to monitor the application's state, such as to keep a display up to date. The advantage of using a check callback is that it is called only when no events are pending. If events are coming in quickly, whole blocks of them will be processed before this is called once. This can save significant time and avoid the application falling behind the events:

bool state_changed; // anything that changes the display turns this on

void check(void*) {
  if (!state_changed) return;
  state_changed = false;
  do_expensive_calculation();
  widget->redraw();
}

main() {
  fltk::add_check(1.0,check);
  return fltk::run();
}

bool fltk::has_check ( TimeoutHandler  cb,
void *  arg = 0 
)

Return true if add_check() has been done with this cb and arg, and remove_check() has not been done.

void fltk::remove_check ( TimeoutHandler  cb,
void *  arg = 0 
)

Remove all matching check callback, if any exists. You can call this from inside the check callback if you want.

void fltk::add_idle ( TimeoutHandler  cb,
void *  data = 0 
)

Adds a callback function that is called every time by fltk::wait() and also makes it act as though the timeout is zero (this makes fltk::wait() return immediately, so if it is in a loop it is called repeatedly, and thus the idle fucntion is called repeatedly). The idle function can be used to get background processing done.

You can have multiple idle callbacks. They are called one after another in a round-robin fashion, checking for events between each.

fltk::wait() and fltk::check() call idle callbacks, but fltk::ready() does not.

The idle callback can call any FLTK functions, including fltk::wait(), fltk::check(), and fltk::ready(). In this case fltk will not recursively call the idle callback.

bool fltk::has_idle ( TimeoutHandler  cb,
void *  data = 0 
)

Returns true if the specified idle callback is currently installed.

void fltk::remove_idle ( TimeoutHandler  cb,
void *  data = 0 
)

Removes the specified idle callback, if it is installed.

void fltk::add_fd ( int  n,
int  events,
FileHandler  cb,
void *  v = 0 
)

Add file descriptor fd to listen to. When the fd becomes ready for reading fltk::wait() will call the callback function and then return. The callback is passed the fd and the arbitrary void* argument.

The second argument is a bitfield to indicate when the callback should be done. You can or these together to make the callback be called for multiple conditions:

  • fltk::READ - Call the callback when there is data to be read.
  • fltk::WRITE - Call the callback when data can be written without blocking.
  • fltk::EXCEPT - Call the callback if an exception occurs on the file.

Under UNIX any file descriptor can be monitored (files, devices, pipes, sockets, etc.) Due to limitations in Microsoft Windows, WIN32 applications can only monitor sockets (? and is the when value ignored?)

References remove_fd().

Referenced by add_fd(), and open_display().

void fltk::add_fd ( int  fd,
FileHandler  cb,
void *  v = 0 
)

Same as add_fd(fd, READ, cb, v);

References add_fd().

void fltk::remove_fd ( int  n,
int  events = -1 
)

Remove all the callbacks (ie for all different when values) for the given file descriptor. It is harmless to call this if there are no callbacks for the file descriptor. If when is given then those bits are removed from each callback for the file descriptor, and the callback removed only if all of the bits turn off.

Referenced by add_fd(), and close_display().

void fltk::lock (  ) 

A multi-threaded fltk program must surround all calls to any fltk functions with lock() and unlock() pairs. This is a "recursive lock", a thread can call lock() n times, and it must call unlock() n times before it really is unlocked.

If another thread calls lock() while it is locked, it will block (not return from lock()) until the first thread unlocks.

The main thread must call lock() once before any call to fltk to initialize the thread system.

The X11 version of fltk uses XInitThreads(), XLockDisplay(), and XUnlockDisplay(). This should allow an fltk program to cooperate with other packages updating the display using Xlib calls.

void fltk::unlock (  ) 

Releases the lock that was set using the fltk::lock() method. Child threads should call this method as soon as they are finished accessing FLTK. If some other thread is waiting for fltk::lock() to return, it will get control.

void fltk::awake ( void *  message = 0  ) 

A child thread can call this to cause the main thread's call to wait() to return (with the lock locked) even if there are no events ready. The main purpose of this is to get the main thread to redraw the screen, but it will also cause fltk::wait() to return so the program's code can do something.

You should call this immediately before fltk::unlock() for best performance.

The message argument can be retrieved by the other thread using fltk::thread_message().

void * fltk::thread_message (  ) 

Returns an argument sent to the most recent awake(), or returns null if none. Warning: this is almost useless for communication as the current implementation only has a one-entry queue and only returns the most recent awake() result.

bool fltk::in_main_thread (  ) 

Returns true if the current thread is the main thread, i.e. the one that called wait() first. Many fltk calls such as wait() will not

work correctly if this is not true. This function must be surrounded by lock() and unlock() just like all other fltk functions, the return value is wrong if you don't hold the fltk lock!

Warning: in_main_thread() is wrong if the main thread calls fltk::unlock() and another thread calls fltk::lock() (the assumption is that the main thread only calls wait()). Current fix is to do the following unsupported code:

  fltk::in_main_thread_ = false;
  fltk::unlock();
  wait_for_something_without_calling_fltk_wait();
  fltk::lock();
  fltk::in_main_thread_ = true;

ImageType * fltk::guess_image ( const char *  name,
const uchar *  datas = 0 
)

Try to guess the filetype Beware that calling this force you to link in all image types !

References fltk::ImageType::name, and fltk::ImageType::test.

void fltk::register_images (  ) 

Makes it so SharedImage can identify image files of the types compiled into fltk. These are XPM, PNG, and Jpeg images.

References fltk::SharedImage::add_handler(), and check().

Color fltk::show_colormap ( Color  oldcol  ) 

Older style of color chooser that only chooses the "indexed" fltk colors. This pops up a panel of the 256 colors you can access with "indexed" fltk::Color values and lets the user pick one of them.

If the user clicks on one of them, the new index is returned.

If they type Esc or click outside the window, the old index is returned.

fl_show_colormap.gif

References event_x_root(), and event_y_root().

fltk::theme (  )  [inline]

Returns the current Theme function. By default this points at fltk_theme().

Referenced by fltk::StyleSet::make_current(), and fltk::StyleSet::StyleSet().

fltk::theme ( Theme  f  )  [inline]

Change what function fltk should call to set the appearance. If you change this after any windows may have been shown, you should call reload_theme().

void fltk::load_theme (  ) 

Call the theme() function if it has not already been called. Normally FLTK calls this just before the first Window::show() is done. You need to call this earlier to execute code such as measuring labels that may depend on the theme.

References set_background().

Referenced by fltk::Window::show().

void fltk::reload_theme (  ) 

Does nothing if load_theme() has not been called yet. If load_theme() has been called, this calls the theme() function again and then call redraw(). If the theme function is written correctly, this should change the display to the new theme. You should call this if you change the theme() or if external information changes such that the result of your theme() function changes.

FLTK will call this automatically when it gets a message from the system indicating the user's preferences have changed.

References redraw(), reset_theme(), and set_background().

Referenced by handle().

bool fltk::reset_theme (  ) 

Change the theme to the compiled-in default by calling the revert function of all NamedStyle structures. A theme() function may want to call this to clear the previous settings.

References fltk::NamedStyle::next.

Referenced by reload_theme().

int fltk::create_thread ( Thread &  t,
void *(*)(void *)  f,
void *  p 
) [inline]

Fork a new thread and make it run f(p). Returns negative number on error, otherwise t is set to the new thread.

bool fltk::visual ( int  flags  ) 

X-specific crap to allow you to force the "visual" used by fltk to one you like, rather than the "default visual" which in many cases has less capabilities than your machine really has! For instance fltk::visual(fltk::RGB_COLOR) will get you a full color display instead of an 8-bit colormap, if possible.

You must call this before you show() any windows. The integer argument is an 'or' of the following:

  • fltk::INDEXED_COLOR indicates that a colormapped visual is ok. This call will normally fail if a TrueColor visual cannot be found.
  • fltk::RGB_COLOR this value is zero and may be passed to indicate that fltk::INDEXED_COLOR is not wanted.
  • fltk::RGB24_COLOR indicates that the visual must have at least 8 bits of red, green, and blue (Windows calls this "millions of colors").
  • fltk::DOUBLE_BUFFER indicates that hardware accelerated double buffering is wanted.
  • Other bits used by glVisual() and GlWindow::mode() are ignored by this.

This returns true if the system has the capabilities by default or FLTK suceeded in turing them on. Your program will still work even if this returns false (it just won't look as good).

On non-X systems this just returns true or false indicating if the system supports the passed values.

Referenced by open_display().

bool fltk::glVisual ( int  mode  ) 

Same as fltk::visual(int) except choose a visual that is also capable of drawing OpenGL. On modern X servers this is true by default, but on older ones OpenGL will crash if the visual is not selected with this.

mode is the same bitflags accepted by GlWindow::mode(). This causes all windows (and thus glstart()) to have these capabilities.

References xcolormap, and xvisual.

Referenced by glstart().

void fltk::own_colormap (  ) 

Makes FLTK use its own X colormap. This may make FLTK display better and will reduce conflicts with other programs that want lots of colors. However the colors may flash as you move the cursor between windows. This function is pretty much legacy nowadays as all modern systems are full color, on such systems this does nothing.

You must call this before you show() any windows. If you call visual(int) you must call this after that.

HDC fltk::getDC (  ) 

Return an arbitrary HDC which you can use for Win32 functions that need one as an argument. The returned value is short-lived and may be destroyed the next time anything is drawn into a window!

COLORREF fltk::xpixel ( Color  i  ) 

Returns the X pixel number used to draw the given FLTK color. If a colormapped visual is being used, this may allocate it, or find the nearest match.

References BLACK.

Referenced by glsetcolor().

HPEN fltk::setpen (  ) 

Set the current "pen" in the DC to match the most recent setcolor() and line_style() calls. This is stupid-expensive on Windows so we defer it until the pen is needed.

References current_xpixel, and dc.

Referenced by drawline(), fillpath(), fillstrokepath(), strokepath(), and strokerect().

HBRUSH fltk::setbrush (  ) 

Set the current "brush" in the DC to match the most recent setcolor() and line_style() calls. This is stupid-expensive on Windows so we defer it until the brush is needed.

References current_xpixel, and dc.

Referenced by fillpath(), and fillstrokepath().

void fltk::stop_drawing ( HWND  window  ) 

Destroy any dc or other objects used to draw into this window.

void fltk::open_display ( Display *  d  ) 

You can make fltk "open" a display that has already been opened, perhaps by another GUI library. Calling this will set xdisplay to the passed display and also read information FLTK needs from it. Don't call this if the display is already open!

References add_fd(), message_window, RGB, visual(), xcolormap, xdisplay, xscreen, and xvisual.

bool fltk::handle (  ) 

Make FLTK act as though it just got the event stored in xevent. You can use this to feed artifical X events to it, or to use your own code to get events from X.

Besides feeding events your code should call flush() periodically so that FLTK redraws its windows.

This function will call any widget callbacks from the widget code. It will not return until they complete, for instance if it pops up a modal window with fltk::ask() it will not return until the user clicks yes or no.

References ALT, belowmouse(), CapsLockKey, ClearKey, DeleteKey, dnd_action, DND_DRAG, DND_ENTER, DND_LEAVE, DND_RELEASE, dnd_source_action, dnd_source_types, dnd_source_window, dnd_type, fltk::Widget::do_callback(), DownKey, EndKey, ENTER, event(), event_time, F0Key, fltk::Window::first(), focus(), grab(), fltk::Rectangle::h(), fltk::Widget::handle(), handle(), HomeKey, InsertKey, KEY, Keypad, KEYUP, fltk::Widget::layout_damage(), LAYOUT_USER, LeftAltKey, LeftCtrlKey, LeftKey, LeftMetaKey, LeftShiftKey, MenuKey, message(), META, modal(), MOUSEWHEEL, MOVE, NUMLOCK, NumLockKey, PageDownKey, PageUpKey, fltk::Widget::parent(), PASTE, PUSH, RELEASE, reload_theme(), fltk::Widget::resize(), RightAltKey, RightCtrlKey, RightKey, RightMetaKey, RightShiftKey, ScrollLockKey, fltk::Rectangle::set(), SHIFT, UpKey, fltk::Widget::visible(), fltk::Rectangle::w(), fltk::Widget::window(), fltk::Rectangle::x(), xdisplay, xevent, xid(), xscreen, and fltk::Rectangle::y().

void fltk::clip_region ( Region  r  ) 

Replace the top of the clip stack.

References clip_region().

Referenced by clip_region(), and fltk::Window::flush().

void fltk::draw_into ( XWindow  window,
int  w,
int  h 
)

Fltk can draw into any X window or pixmap that uses the fltk::xvisual. This will reset the transformation and clip region and leave the font, color, etc at unpredictable values. The w and h arguments must be the size of the window and are used by fltk::not_clipped().

Before you destroy the window or pixmap you must call fltk::stop_drawing() so that it can destroy any temporary structures that were created by this.

References load_identity(), warning, xcolormap, xdisplay, xvisual, and xwindow.

Referenced by fltk::Window::flush().

void fltk::stop_drawing ( XWindow  window  ) 

Destroy any "graphics context" structures that point at this window or Pixmap. They will be recreated if you call draw_into() again.

Unfortunately some graphics libraries will crash if you don't do this. Even if the graphics context is not used, destroying it after destroying it's target will cause a crash. Sigh.

References xwindow.

Referenced by fltk::Window::free_backbuffer(), and fltk::Window::system_layout().

WindowPtr fltk::xid ( const Window *  window  )  [inline]

Returns the XID for a window, or zero if show() has not been called on it.

Referenced by fltk::Window::borders(), fltk::Window::destroy(), dnd(), fltk::Window::first(), handle(), modal(), paste(), fltk::Window::show(), and fltk::GlWindow::swap_buffers().


Variable Documentation

This Style is used for the 50x50 icon area on the left of all the popup windows. You can change the colors or font used here.

This Style is used for the label area for all the popup windows. You can change the textfont() or textsize() to make them print differently.

Set this to change the title of message(), alert(), ask(), choice(), etc. windows.

Set this to a positive value to cause the message(), alert(), ask(), choice(), etc. windows to close automatically after this timeout. If the timeout expires, -1 will be returned by the functions that return int. The timeout value is in seconds.

When this is set to true, then (all) message windows will use scrollbars if the given message is too long.

const char * fltk::no

You can change this string to convert fltk to a foreign language.

Referenced by ask().

const char * fltk::yes

You can change this string to convert fltk to a foreign language.

Referenced by ask().

const char * fltk::ok

You can change this string to convert fltk to a foreign language.

Referenced by alert(), and message().

const char * fltk::cancel

You can change this string to convert fltk to a foreign language.

void(* fltk::warning)(const char *format,...) ( const char *  ,
  ... 
)

fltk will call this when it wants to report a recoverable problem. The display may be messed up but the user can probably keep working. (all X protocol errors call this). The default version on Unix prints a message to stderr, on Windows it pops up a MessageBox.

Referenced by draw_into(), fltk::TextBuffer::insert_column(), fltk::TextBuffer::overlay_rectangular(), and fltk::TextBuffer::replace_rectangular().

void(* fltk::error)(const char *format,...) ( const char *  ,
  ... 
)

fltk will call this when it wants to report a recoverable problem. but in this case the display is so messed up it is unlikely the user can continue. Very little calls this now. The default version on Unix prints a message to stderr, on Windows it pops up a MessageBox, and then both versions call exit(1).

You may be able to use longjmp or an exception to get back to your own code.

Referenced by arg(), args(), and fltk::GlWindow::make_current().

void(* fltk::fatal)(const char *format,...) ( const char *  ,
  ... 
)

fltk will call this when it wants to report a problem that it cannot recover from. You must not make any fltk calls again. The default version is the same function as error().

Referenced by open_display().

const char *const fltk::help

This is a portion of the string printed by fltk::args() detects an invalid argument on the command-line. You can add this to your own error or help message to show the fltk switches. It's value is (no newline at start or the end):

 -d[isplay] host:n.n
 -g[eometry] WxH+X+Y
 -n[ame] windowname
 -i[conic]
 -bg color

Box *const fltk::UP_BOX

A up button in fltk's standard theme.

Inset box in fltk's standard theme

1-pixel-thick raised box.

1-pixel-thick inset box.

Referenced by fltk::Slider::draw().

2-pixel thick engraved line around edge.

2-pixel thick raised line around edge.

1-pixel thick gray line around rectangle.

Draws a flat rectangle of getbgcolor().

Draws nothing normally, and as THIN_UP_BOX when the mouse pointer points at it or the value of the widget is turned on.

Draws nothing normally, and as THIN_DOWN_BOX when the mouse pointer points at it or the value of the widget is turned on.

Raised oval or circle.

Inset oval or circle.

Raised diamond shape used to draw Motif-style checkboxes.

Diamond shape used to draw Motif-style checkboxes.

Box *const fltk::NO_BOX

Draws nothing. Can be used as a box to make the background of a widget invisible. Also some widgets check specifically for this and change their behavior or drawing methods.

Referenced by fltk::Widget::draw(), fltk::Button::draw(), fltk::InvisibleBox::handle(), fltk::Widget::hide(), fltk::Widget::redraw_highlight(), and fltk::Group::remove().

Round-cornered rectangle with a black border.

Round-cornered rectangle with a black border and gray shadow.

Round-cornered rectangle with no border.

Ellipse with a black border.

Ellipse with a black border and gray shadow.

Ellipse with no border.

Obsolete. Draws colored edge and draws nothing inside rectangle.

Box designed to vaguely resemble a certain fruit-themed operating system.

Pushed in version of PLASTIC_UP_BOX

HINSTANCE fltk::xdisplay

HPALETTE fltk::xpalette

If non-zero this is the palette alloced by fltk on an 8-bit screen. Hopefully you can ignore this, I'm not even sure it works anymore.

MSG fltk::msg

The most recent message read by GetMessage() (which is called by fltk::wait(). This may not be the most recent message sent to an FLTK window (because our fun-loving friends at MicroSoft decided that calling the handle procedures directly would be a good idea sometimes...)

Referenced by dnd().

HDC fltk::dc

The device context that is currently being drawn into.

Referenced by drawline(), drawpoint(), fillpath(), fillrect(), fillstrokepath(), scrollrect(), setbrush(), setpen(), strokepath(), strokerect(), and fltk::GlWindow::swap_buffers().

The color picked by the most recent setcolor(Color).

Referenced by drawline(), drawpoint(), drawtext_transformed(), fillrect(), setbrush(), and setpen().

This dummy 1x1 window is created by fltk::open_display() and is never destroyed. You can use it to communicate with the window manager or other programs.

Referenced by copy(), dnd(), fltk::Monitor::list(), and open_display().

Which screen number to use. This is set by fltk::open_display() to the default screen. You can change it by setting this to a different value immediately afterwards.

Referenced by fltk::Monitor::all(), fltk::CreatedWindow::create(), dnd(), fltk::Font::encodings(), get_mouse(), handle(), fltk::Window::iconize(), open_display(), fltk::Font::sizes(), and warp_mouse().

XVisualInfo * fltk::xvisual

The X visual that FLTK will use for all windows. These are set by fltk::open_display() to the default visual. You can change them before calling Window::show() the first time. Typical code for changing the default visual is:

fltk::args(argc, argv); // do this first so $DISPLAY is set
fltk::open_display();
fltk::xvisual = find_a_good_visual(fltk::xdisplay, fltk::xscreen);
if (!fltk::xvisual) fltk::abort(&quot;No good visual&quot;);
fltk::xcolormap = make_a_colormap(fltk::xdisplay, fltk::xvisual->visual, fltk::xvisual->depth);
// it is now ok to show() windows:
window->show(argc, argv);

A portable interface to get a TrueColor visual (which is probably the only reason to do this) is to call fltk::visual(int).

Referenced by fltk::Monitor::all(), fltk::Window::create(), draw_into(), fltk::Window::flush(), glstart(), glVisual(), and open_display().

Colormap fltk::xcolormap

The colormap being used by FLTK. This is needed as an argument for many Xlib calls. You can also set this immediately after open_display() is called to your own colormap. The function own_colormap() can be used to make FLTK create a private one. FLTK uses the same colormap for all windows and there is no way to change that, sorry.

Referenced by fltk::Window::create(), draw_into(), fltk::Window::flush(), glVisual(), open_display(), and parsecolor().

XEvent fltk::xevent

The most recent X event.

Referenced by handle().

The last timestamp from an X event that reported it (not all do). Many X calls (like cut and paste) need this value.

Referenced by copy(), dnd(), handle(), modal(), and paste().

The X id of the window being dragged from.

Referenced by dnd(), and handle().

Zero-terminated list of atoms describing the formats of the source data. This is set on the DND_ENTER event. The following code will print them all as text, a typical value is "text/plain;charset=UTF-8" (gag).

for (int i = 0; dnd_source_types[i]; i++) {
  char* x = XGetAtomName(xdisplay, dnd_source_types[i]);
  puts(x);
  XFree(x);
}

You can set this and dnd_source_action before calling dnd() to change information about the source. You must set both of these, if you don't fltk will default to "text/plain" as the type and XdndActionCopy as the action. To set this change it to point at your own array. Only the first 3 types are sent. Also, FLTK has no support for reporting back what type the target requested, so all your types must use the same block of data.

Referenced by dnd(), and handle().

The program can set this when returning non-zero for a DND_RELEASE event to indicate the translation wanted. FLTK presets this to "text/plain" so that is returned if you don't set it (supposedly it should be limited to one of the values in dnd_source_types, but "text/plain" appears to always work).

Referenced by dnd(), and handle().

The action the source program wants to perform. Due to oddities in the Xdnd design this variable is not set on the fltk::DND_ENTER event, instead it is set on each DND_DRAG event, and it may change each time.

To print the string value of the Atom use this code:

char* x = XGetAtomName(xdisplay, dnd_source_action);
puts(x);
XFree(x);

You can set this before calling fltk::dnd() to communicate a different action. See dnd_source_types, which you must also set.

Referenced by dnd(), and handle().

The dnd_* variables allow your fltk program to use the Xdnd protocol to manipulate files and interact with file managers. You can ignore these if you just want to drag & drop blocks of text. I have little information on how to use these, I just tried to clean up the Xlib interface and present the variables nicely.

The program can set this variable before returning non-zero for a DND_DRAG event to indicate what it will do to the object. Fltk presets this to XdndActionCopy so that is what is returned if you don't set it.

Referenced by dnd(), and handle().

The single X GC used for all drawing. This is initialized by the first call to Window::make_current(). This may be removed if we use Cairo or XRender only.

Most Xlib drawing calls look like this:

XDrawSomething(xdisplay, xwindow, gc, ...);

Referenced by drawline(), drawpoint(), fillpath(), fillrect(), fillstrokepath(), fltk::Window::flush(), scrollrect(), strokepath(), and strokerect().

XWindow fltk::xwindow

Set by Window::make_current() and/or draw_into() to the window being drawn into. This may be different than the xid() of the window, as it may be the back buffer which has a different id.

Referenced by draw_into(), drawline(), drawpoint(), fillpath(), fillrect(), fillstrokepath(), scrollrect(), stop_drawing(), strokepath(), and strokerect().


Wed Jun 17 08:58:24 2009. FLTK ©2007 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.