FLTK
FLTK
3 Programming Manual
This software and manual are provided under the terms of the GNU Library General Public License.
Permission is granted to reproduce this manual or any portion for any purpose,
provided this copyright and permission notice are preserved.
November 3, 2014
Contents
2 Preface 5
2.1 Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Copyrights and Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3 Introduction to FLTK 7
3.1 History of FLTK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3 Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.4 What Does ”FLTK” Mean? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.5 Building and Installing FLTK Under UNIX and Apple OS X . . . . . . . . . . . . . . . . 9
3.6 Building FLTK Under Microsoft Windows . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.7 Internet Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.8 Reporting Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4 FLTK Basics 13
4.1 Writing Your First FLTK Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.2 Compiling Programs with Standard Compilers . . . . . . . . . . . . . . . . . . . . . . . . 15
4.3 Compiling Programs with Makefiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.4 Compiling Programs with Microsoft Visual C++ . . . . . . . . . . . . . . . . . . . . . . . 17
4.5 Naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.6 Header Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
i
ii CONTENTS
8 Handling Events 59
8.1 The FLTK Event Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
8.2 Mouse Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
8.3 Focus Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
8.4 Keyboard Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
8.5 Widget Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
8.6 Clipboard Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
8.7 Drag and Drop Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
8.8 Other events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
8.9 Fl::event ∗() methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
8.10 Event Propagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
8.11 FLTK Compose-Character Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
10 Using OpenGL 73
10.1 Using OpenGL in FLTK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
10.2 Making a Subclass of Fl Gl Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
10.3 Using OpenGL in Normal FLTK Windows . . . . . . . . . . . . . . . . . . . . . . . . . 75
10.4 OpenGL Drawing Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
10.5 Speeding up OpenGL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
10.6 Using OpenGL Optimizer with FLTK . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
This software and manual are provided under the terms of the GNU Library General Public License.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright
and permission notice are preserved.
3
4 CHAPTER 1. FLTK PROGRAMMING MANUAL
• Image Labels
Chapter 2
Preface
This manual describes the Fast Light Tool Kit (”FLTK”) version 1.3.3, a C++ Graphical User Interface
(”GUI”) toolkit for UNIX, Microsoft Windows and Apple OS X.
Each of the chapters in this manual is designed as a tutorial for using FLTK, while the appendices
provide a convenient reference for all FLTK widgets, functions, and operating system interfaces.
This manual may be printed, modified, and/or used under the terms of the FLTK license provided
in Software License.
2.1 Organization
This manual is organized into the following chapters and appendices:
• Introduction to FLTK
• FLTK Basics
• Handling Events
• Using OpenGL
• Advanced FLTK
• FLTK Enumerations
• GLUT Compatibility
• Forms Compatibility
5
6 CHAPTER 2. PREFACE
• Developer Information
• Software License
2.2 Conventions
This manual was generated using Doxygen (see http://www.doxygen.org/) to process the source
code itself, special comments in the code, and additional documentation files. In general, Doxygen recog-
nizes and denotes the following entities as shown:
2.3 Abbreviations
The following abbreviations are used in this manual:
X11
The X Window System version 11.
Xlib
The X Window System interface library.
MS Windows, WIN32
The Microsoft Windows Application Programmer’s Interface for Windows 2000, Windows XP, Win-
dows Vista, and Windows 7. FLTK uses the preprocessor definition WIN32 for the 32 bit and 64 bit
MS Windows API.
OS X, APPLE
The Apple desktop operating sytem OS X 10.0 and later. MacOS 8 and 9 support was dropped after
FLTK 1.0.10. FLTK uses the preprocessor definition APPLE for OS X.
Introduction to FLTK
The Fast Light Tool Kit (”FLTK”, pronounced ”fulltick”) is a cross-platform C++ GUI toolkit for UNI-
X®/Linux® (X11), Microsoft® Windows®, and Apple® OS X®.
FLTK provides modern GUI functionality without the bloat and supports 3D graphics via OpenG-
L® and its built-in GLUT emulation. It was originally developed by Mr. Bill Spitzak and is currently
maintained by a small group of developers across the world with a central repository in the US.
7
8 CHAPTER 3. INTRODUCTION TO FLTK
so he rewrote it to use X for all drawing, greatly speeding it up on these machines. That is the version you
have now.
Digital Domain has since withdrawn support for FLTK. While Bill is no longer able to actively develop
it, he still contributes to FLTK in his free time and is a part of the FLTK development team.
3.2 Features
FLTK was designed to be statically linked. This was done by splitting it into many small objects and
designing it so that functions that are not used do not have pointers to them in the parts that are used, and
thus do not get linked in. This allows you to make an easy-to-install program or to modify FLTK to the
exact requirements of your application without worrying about bloat. FLTK works fine as a shared library,
though, and is now included with several Linux distributions.
Here are some of the core features unique to FLTK:
• sizeof(Fl Widget) == 64 to 92.
• The ”core” (the ”hello” program compiled & linked with a static FLTK library using gcc on a 486
and then stripped) is 114K.
• The FLUID program (which includes every widget) is 538k.
• Written directly atop core libraries (Xlib, WIN32 or Cocoa) for maximum speed, and carefully opti-
mized for code size and performance.
• Precise low-level compatibility between the X11, WIN32 and MacOS versions - only about 10% of
the code is different.
• Interactive user interface builder program. Output is human-readable and editable C++ source code.
• Support for overlay hardware, with emulation if none is available.
• Very small & fast portable 2-D drawing library to hide Xlib, WIN32, or QuickDraw.
• OpenGL/Mesa drawing area widget.
• Support for OpenGL overlay hardware on both X11 and WIN32, with emulation if none is available.
• Text widgets with cut & paste, undo, and support for Unicode text and international input methods.
• Compatibility header file for the GLUT library.
• Compatibility header file for the XForms library.
3.3 Licensing
FLTK comes with complete free source code. FLTK is available under the terms of the GNU Library
General Public License with exceptions that allow for static linking. Contrary to popular belief, it can be
used in commercial software - even Bill Gates could use it!
By default configure will look for a C++ compiler named CC, c++, g++, or gcc in that order. To use
another compiler you need to set the CXX environment variable:
CXX=xlC; export CXX
setenv CXX "xlC"
The CC environment variable can also be used to override the default C compiler (cc or gcc), which
is used for a few FLTK source files.
You can run configure yourself to get the exact setup you need. Type ”./configure <options>”, where
options are:
–enable-cygwin
–bindir=/path
–datadir=/path
–libdir=/path
–includedir=/path
–mandir=/path
–prefix=/dir
When the configure script is done you can just run the ”make” command. This will build the library, FLUID
tool, and all of the test programs.
To install the library, become root and type ”make install”. This will copy the ”fluid” executable to
”bindir”, the header files to ”includedir”, and the library files to ”libdir”.
This will build the fltk libraries and they can then be utilised directly from the build location. NOTE:
this may be simpler than ”installing” them in many cases as different tool chains on Windows have different
ideas about where the files should be ”installed” to.
For example, if you ”install” the libraries using Msys/MinGW with the following command:
make install
Then Msys will ”install” the libraries to where it thinks the path ”/usr/local/” leads to. If you only ever
build code from within the Msys environment this works well, but the actual ”Windows path” these files
are located in will be something like ”C:\msys\1.0\local\lib”, depending on where your Msys installation
is rooted, which may not be useful to other tools.
If you want to install your built fltk libraries in a non-standard location you may do:
sh configure --prefix=C:/FLTK
make
Where the value passed to ”prefix” is the path at which you would like fltk to be installed.
A subsequent invocation of ”make install” will then place the fltk libraries and header files into that
path.
The other options to ”configure” may also be used to tailor the build to suit your environment.
FLTK Basics
This chapter teaches you the basics of compiling programs that use FLTK.
#include <FL/Fl.H>
#include <FL/Fl Window.H>
#include <FL/Fl Box.H>
After including the required header files, the program then creates a window. All following widgets will
automatically be children of this window.
Fl Window *window = new Fl Window(340,180);
Then we create a box with the ”Hello, World!” string in it. FLTK automatically adds the new box to
window, the current grouping widget.
Fl Box *box = new Fl Box(20,40,300,100,"Hello, World!");
Next, we set the type of box and the font, size, and style of the label:
box->box(FL UP BOX);
box->labelfont(FL BOLD+FL ITALIC);
box->labelsize(36);
box->labeltype(FL SHADOW LABEL);
We tell FLTK that we will not add any more widgets to window.
window->end();
Finally, we show the window and enter the FLTK event loop:
13
14 CHAPTER 4. FLTK BASICS
window->show(argc, argv);
return Fl::run();
The resulting program will display the window in Figure 4.1. You can quit the program by closing the
window or pressing the ESCape key.
The x and y parameters determine where the widget or window is placed on the screen. In FLTK the
top left corner of the window or screen is the origin (i.e. x = 0, y = 0) and the units are in pixels.
The width and height parameters determine the size of the widget or window in pixels. The maxi-
mum widget size is typically governed by the underlying window system or hardware.
label is a pointer to a character string to label the widget with or NULL. If not specified the label
defaults to NULL. The label string must be in static storage such as a string constant because FLTK does
not make a copy of it - it just uses the pointer.
4.1.5 Labels
All widgets support labels. In the case of window widgets, the label is used for the label in the title bar.
Our example program calls the labelfont(), labelsize(), and labeltype() methods.
The labelfont() method sets the typeface and style that is used for the label, which for this example
we are using FL BOLD and FL ITALIC. You can also specify typefaces directly.
The labelsize() method sets the height of the font in pixels.
The labeltype() method sets the type of label. FLTK supports normal, embossed, and shadowed
labels internally, and more types can be added as desired.
A complete list of all label options can be found in the section on Labels and Label Types.
Fl::run() does not return until all of the windows under FLTK control are closed by the user or your
program.
The fltk-config script included with FLTK can be used to get the options that are required by your
compiler:
CC ‘fltk-config --cxxflags‘ ...
Similarly, when linking your application you will need to tell the compiler to use the FLTK library:
CC ... -L/usr/local/lib -lfltk -lXext -lX11 -lm
gcc ... -L/usr/local/lib -lfltk -lXext -lX11 -lm
Aside from the ”fltk” library, there is also a ”fltk forms” library for the XForms compatibility classes,
”fltk gl” for the OpenGL and GLUT classes, and ”fltk images” for the image file classes, Fl Help Dialog
widget, and system icon support.
Note
The libraries are named ”fltk.lib”, ”fltkgl.lib”, ”fltkforms.lib”, and ”fltkimages.lib”, respectively un-
der Windows.
As before, the fltk-config script included with FLTK can be used to get the options that are required
by your linker:
CC ... ‘fltk-config --ldflags‘
The forms, GL, and images libraries are included with the ”--use-foo” options, as follows:
CC ... ‘fltk-config --use-forms --ldflags‘
CC ... ‘fltk-config --use-gl --ldflags‘
CC ... ‘fltk-config --use-images --ldflags‘
CC ... ‘fltk-config --use-forms --use-gl --use-images --ldflags‘
Finally, you can use the fltk-config script to compile a single source file as a FLTK program:
fltk-config --compile filename.cpp
fltk-config --use-forms --compile filename.cpp
fltk-config --use-gl --compile filename.cpp
fltk-config --use-images --compile filename.cpp
fltk-config --use-forms --use-gl --use-images --compile filename.cpp
TARGET = cube
OBJS = CubeMain.o CubeView.o CubeViewUI.o
SRCS = CubeMain.cxx CubeView.cxx CubeViewUI.cxx
.SUFFIXES: .o .cxx
%.o: %.cxx
$(CXX) $(CXXFLAGS) $(DEBUG) -c $<
all: $(TARGET)
$(LINK) -o $(TARGET) $(OBJS) $(LDSTATIC)
$(TARGET): $(OBJS)
CubeMain.o: CubeMain.cxx CubeViewUI.h
CubeView.o: CubeView.cxx CubeView.h CubeViewUI.h
CubeViewUI.o: CubeViewUI.cxx CubeView.h
4.5 Naming
All public symbols in FLTK start with the characters ’F’ and ’L’:
Note
Case is significant on many operating systems, and the C standard uses the forward slash (/) to sepa-
rate directories. Do not use any of the following include lines:
#include <FL\Fl xyz.H>
#include <fl/fl xyz.h>
#include <Fl/fl xyz.h>
18 CHAPTER 4. FLTK BASICS
Chapter 5
This chapter describes many of the widgets that are provided with FLTK and covers how to query and set
the standard attributes.
5.1 Buttons
FLTK provides many types of buttons:
All of these buttons just need the corresponding <FL/Fl xyz Button.H> header file. The con-
structor takes the bounding box of the button and optionally a label string:
Fl Button *button = new Fl Button(x, y, width, height, "label");
Fl Light Button *lbutton = new Fl Light Button(x, y, width, height);
Fl Round Button *rbutton = new Fl Round Button(x, y, width, height, "label");
Each button has an associated type() which allows it to behave as a push button, toggle button, or
radio button:
19
20 CHAPTER 5. COMMON WIDGETS AND ATTRIBUTES
For toggle and radio buttons, the value() method returns the current button state (0 = off, 1 = on). The
set() and clear() methods can be used on toggle buttons to turn a toggle button on or off, respectively.
Radio buttons can be turned on with the setonly() method; this will also turn off other radio buttons in
the same group.
5.2 Text
FLTK provides several text widgets for displaying and receiving text:
The Fl Output and Fl Multiline Output widgets allow the user to copy text from the output field but not
change it.
The value() method is used to get or set the string that is displayed:
The string is copied to the widget’s own storage when you set the value() of the widget.
The Fl Text Display and Fl Text Editor widgets use an associated Fl Text Buffer class for the value,
instead of a simple string.
5.3 Valuators
Unlike text widgets, valuators keep track of numbers instead of strings. FLTK provides the following
valuators:
• Fl Counter - A widget with arrow buttons that shows the current value.
The value() method gets and sets the current value of the widget. The minimum() and maximum()
methods set the range of values that are reported by the widget.
5.4 Groups
The Fl Group widget class is used as a general purpose ”container” widget. Besides grouping radio buttons,
the groups are used to encapsulate windows, tabs, and scrolled windows. The following group classes are
available with FLTK:
• Fl Group - The base container class; can be used to group any widgets together.
• Fl Pack - A collection of widgets that are packed into the group area.
If you change a widget’s size or position after it is displayed you will have to call redraw() on the
widget’s parent.
5.6 Colors
FLTK stores the colors of widgets as an 32-bit unsigned number that is either an index into a color palette
of 256 colors or a 24-bit RGB color. The color palette is not the X or MS Windows colormap, but instead
is an internal table with fixed contents.
See the Colors section of Drawing Things in FLTK for implementation details.
There are symbols for naming some of the more common colors:
• FL BLACK
• FL RED
• FL GREEN
• FL YELLOW
• FL BLUE
• FL MAGENTA
• FL CYAN
• FL WHITE
• FL WHITE
Other symbols are used as the default colors for all FLTK widgets.
• FL FOREGROUND COLOR
• FL BACKGROUND COLOR
• FL INACTIVE COLOR
• FL SELECTION COLOR
The full list of named color values can be found in FLTK Enumerations.
A color value can be created from its RGB components by using the fl rgb color() function, and
decomposed again with Fl::get color():
Fl Color c = fl rgb color(85, 170, 255); // RGB to Fl Color
Fl::get color(c, r, g, b); // Fl Color to RGB
button->labelcolor(FL WHITE);
The Fl Color encoding maps to a 32-bit unsigned integer representing RGBI, so it is also possible to
specify a color using a hex constant as a color map index:
button->color(0x000000ff); // colormap index #255 (FL WHITE)
Note
If TrueColor is not available, any RGB colors will be set to the nearest entry in the colormap.
FL NO BOX means nothing is drawn at all, so whatever is already on the screen remains. The FL -
... FRAME types only draw their edges, leaving the interior unchanged. The blue color in Figure 3-3 is
the area that is not drawn by the frame types.
Note:
This interface has changed in FLTK 2.0!
The drawing function is passed the bounding box and background color for the widget:
A simple drawing function might fill a rectangle with the given color and then draw a black outline:
fl down() returns the ”pressed” or ”down” version of a box. If no ”down” version of a given box exists,
the behavior of this function is undefined and some random box or frame is returned. See Drawing
Functions for more details.
fl frame() returns the unfilled, frame-only version of a box. If no frame version of a given box exists,
the behavior of this function is undefined and some random box or frame is returned. See Drawing
Functions for more details.
fl box() returns the filled version of a frame. If no filled version of a given frame exists, the behavior
of this function is undefined and some random box or frame is returned. See Drawing Functions for
more details.
Adding Your Box Type
The Fl::set boxtype() method adds or replaces the specified box type:
The last 4 arguments to Fl::set boxtype() are the offsets for the x, y, width, and height values that
should be subtracted when drawing the label inside the box.
A complete box design contains four box types in this order: a filled, neutral box (UP BOX), a filled,
depressed box (DOWN BOX), and the same as outlines only (UP FRAME and DOWN FRAME). The function
fl down(Fl Boxtype) expects the neutral design on a boxtype with a numerical value evenly dividable by
two. fl frame(Fl Boxtype) expects the UP BOX design at a value dividable by four.
5.8. LABELS AND LABEL TYPES 25
label()
The label() method sets the string that is displayed for the label. Symbols can be included with the
label string by escaping them using the ”@” symbol - ”@@” displays a single at sign. Figure 3-4 shows
the available symbols.
The @ sign may also be followed by the following optional ”formatting” characters, in this order:
• ’#’ forces square scaling, rather than distortion to the widget’s shape.
• [0-9] - rotates by a multiple of 45 degrees. ’5’ and ’6’ do no rotation while the others point in the
direction of that key on a numeric keypad. ’0’, followed by four more digits rotates the symbol by
that amount in degrees.
Thus, to show a very large arrow pointing downward you would use the label string ”@+92->”.
26 CHAPTER 5. COMMON WIDGETS AND ATTRIBUTES
align()
The align() method positions the label. The following constants are defined and may be OR’d together
as needed:
• FL ALIGN LEFT TOP - The label appears to the left of the widget, aligned at the top. Outside
labels only.
• FL ALIGN RIGHT TOP - The label appears to the right of the widget, aligned at the top. Outside
labels only.
• FL ALIGN LEFT BOTTOM - The label appears to the left of the widget, aligned at the bottom.
Outside labels only.
• FL ALIGN RIGHT BOTTOM - The label appears to the right of the widget, aligned at the bottom.
Outside labels only.
• FL ALIGN TEXT OVER IMAGE - show the label text over the image.
• FL ALIGN IMAGE OVER TEXT - show the label image over the text (default).
• FL ALIGN IMAGE NEXT TO TEXT - The image will appear to the left of the text.
• FL ALIGN TEXT NEXT TO IMAGE - The image will appear to the right of the text.
• FL ALIGN IMAGE BACKDROP - The image will be used as a background for the widget.
labeltype()
The labeltype() method sets the type of the label. The following standard label types are included:
The image() and deimage() methods set an image that will be displayed with the widget. The
deimage() method sets the image that is shown when the widget is inactive, while the image() method
sets the image that is shown when the widget is active.
To make an image you use a subclass of Fl Image.
Making Your Own Label Types
Label types are actually indexes into a table of functions that draw them. The primary purpose of this is to
use this to draw the labels in ways inaccessible through the fl font() mechanism (e.g. FL ENGRAVED L-
ABEL) or with program-generated letters or symbology.
Label Type Functions
To setup your own label type you will need to write two functions: one to draw and one to measure the
label. The draw function is called with a pointer to a Fl Label structure containing the label information,
the bounding box for the label, and the label alignment:
void xyz draw(const Fl Label *label, int x, int y, int w, int h,
Fl Align align) {
...
}
The label should be drawn inside this bounding box, even if FL ALIGN INSIDE is not enabled. The
function is not called if the label value is NULL.
The measure function is called with a pointer to a Fl Label structure and references to the width and
height:
void xyz measure(const Fl Label *label, int &w, int &h) {
...
}
The function should measure the size of the label and set w and h to the size it will occupy.
Adding Your Label Type
The Fl::set labeltype() method creates a label type using your draw and measure functions:
#define XYZ LABEL FL FREE LABELTYPE
The label type number n can be any integer value starting at the constant FL FREE LABELTYPE. Once
you have added the label type you can use the labeltype() method to select your label type.
The Fl::set labeltype() method can also be used to overload an existing label type such as FL NORMA-
L LABEL.
Making your own symbols
It is also possible to define your own drawings and add them to the symbol list, so they can be rendered as
part of any label.
To create a new symbol, you implement a drawing function void drawit(Fl Color c) which
typically uses the functions described in Drawing Complex Shapes to generate a vector shape inside a
two-by-two units sized box around the origin. This function is then linked into the symbols table using
fl add symbol():
28 CHAPTER 5. COMMON WIDGETS AND ATTRIBUTES
int fl add symbol(const char *name, void (*drawit)(Fl Color), int scalable)
name is the name of the symbol without the ”@”; scalable must be set to 1 if the symbol is
generated using scalable vector drawing functions.
5.9 Callbacks
Callbacks are functions that are called when the value of a widget changes. A callback function is sent a
Fl Widget pointer of the widget that changed and a pointer to data that you provide:
The callback() method sets the callback function for a widget. You can optionally pass a pointer
to some data needed for the callback:
Normally callbacks are performed only when the value of the widget changes. You can change this
using the Fl Widget::when() method:
Note:
You cannot delete a widget inside a callback, as the widget may still be accessed by FLTK after your
callback is completed. Instead, use the Fl::delete widget() method to mark your widget for deletion
when it is safe to do so.
Hint:
Many programmers new to FLTK or C++ try to use a non-static class method instead of a static class
method or function for their callback. Since callbacks are done outside a C++ class, the this pointer
is not initialized for class methods.
To work around this problem, define a static method in your class that accepts a pointer to the class,
and then have the static method call the class method(s) as needed. The data pointer you provide to the
callback() method of the widget can be a pointer to the instance of your class.
class Foo {
void my callback(Fl Widget *w);
static void my static callback(Fl Widget *w, void *f) { ((Foo *)f)->my callback(w); }
...
}
...
5.10 Shortcuts
Shortcuts are key sequences that activate widgets such as buttons or menu items. The shortcut()
method sets the shortcut for a widget:
button->shortcut(FL Enter);
button->shortcut(FL SHIFT + ’b’);
button->shortcut(FL CTRL + ’b’);
button->shortcut(FL ALT + ’b’);
button->shortcut(FL CTRL + FL ALT + ’b’);
button->shortcut(0); // no shortcut
The shortcut value is the key event value - the ASCII value or one of the special keys described in
Fl::event key() Values combined with any modifiers like Shift , Alt , and Control.
30 CHAPTER 5. COMMON WIDGETS AND ATTRIBUTES
Chapter 6
This chapter takes you through the design of a simple FLTK-based text editor.
4. Save to a file.
5. Cut/copy/delete/paste functions.
31
32 CHAPTER 6. DESIGNING A SIMPLE TEXT EDITOR
6.3 Variables
Our text editor will need some global variables to keep track of things:
int changed = 0;
char filename[256] = "";
Fl Text Buffer *textbuf;
The textbuf variable is the text editor buffer for our window class described previously. We’ll cover
the other variables as we build the application.
{ "&Edit", 0, 0, 0, FL SUBMENU },
{ "&Undo", FL COMMAND + ’z’, (Fl Callback *)undo cb, 0, FL MENU DIVIDER },
{ "Cu&t", FL COMMAND + ’x’, (Fl Callback *)cut cb },
{ "&Copy", FL COMMAND + ’c’, (Fl Callback *)copy cb },
{ "&Paste", FL COMMAND + ’v’, (Fl Callback *)paste cb },
{ "&Delete", 0, (Fl Callback *)delete cb },
{ 0 },
{ "&Search", 0, 0, 0, FL SUBMENU },
{ "&Find...", FL COMMAND + ’f’, (Fl Callback *)find cb },
{ "F&ind Again", FL COMMAND + ’g’, find2 cb },
{ "&Replace...", FL COMMAND + ’r’, replace cb },
{ "Re&place Again", FL COMMAND + ’t’, replace2 cb },
{ 0 },
{ 0 }
};
Once we have the menus defined we can create the Fl Menu Bar widget and assign the menus to it
with:
Fl Menu Bar *m = new Fl Menu Bar(0, 0, 640, 30);
m->copy(menuitems);
So that we can keep track of changes to the file, we also want to add a ”modify” callback:
textbuf->add modify callback(changed cb, w);
textbuf->call modify callbacks();
6.7 Callbacks
Now that we’ve defined the GUI components of our editor, we need to define our callback functions.
The set title() function is one that we will write to set the changed status on the current file.
We’re doing it this way because we want to show the changed status in the window’s title bar.
If the search string cannot be found we use the fl alert() convenience function to display a message to
that effect.
filename[0] = ’\0’;
textbuf->select(0, textbuf->length());
textbuf->remove selection();
changed = 0;
textbuf->call modify callbacks();
}
6.7. CALLBACKS 35
exit(0);
}
if (find[0] == ’\0’) {
// Search string is blank; get a new one...
e->replace dlg->show();
return;
}
e->replace dlg->hide();
if (found) {
// Found a match; update the position and replace text...
textbuf->select(pos, pos+strlen(find));
36 CHAPTER 6. DESIGNING A SIMPLE TEXT EDITOR
textbuf->remove selection();
textbuf->insert(pos, replace);
textbuf->select(pos, pos+strlen(replace));
e->editor->insert position(pos+strlen(replace));
e->editor->show insert position();
}
else fl alert("No occurrences of \’%s\’ found!", find);
}
e->replace dlg->hide();
e->editor->insert position(0);
int times = 0;
if (found) {
// Found a match; update the position and replace text...
textbuf->select(pos, pos+strlen(find));
textbuf->remove selection();
textbuf->insert(pos, replace);
e->editor->insert position(pos+strlen(replace));
e->editor->show insert position();
times++;
}
}
The save file() function saves the current file to the specified filename.
6.8. OTHER FUNCTIONS 37
The save file() function saves the current file to the specified filename.
if (r == 1) {
save cb(); // Save the file...
return !changed;
}
return (r == 2) ? 1 : 0;
}
int loading = 0;
void load file(char *newfile, int ipos) {
loading = 1;
int insert = (ipos != -1);
changed = insert;
if (!insert) strcpy(filename, "");
int r;
if (!insert) r = textbuf->loadfile(newfile);
else r = textbuf->insertfile(newfile, ipos);
if (r)
fl alert("Error reading from file \’%s\’:\n%s.", newfile, strerror(errno));
else
if (!insert) strcpy(filename, newfile);
loading = 0;
textbuf->call modify callbacks();
}
When loading the file we use the Fl Text Buffer::loadfile() method to ”replace” the text in the buffer,
or the Fl Text Buffer::insertfile() method to insert text in the buffer from the named file.
w->label(title);
}
window->show(1, argv);
return Fl::run();
}
As noted in Compiling Programs with Standard Compilers, you may need to include compiler and
linker options to tell them where to find the FLTK library. Also, the CC command may also be called gcc
or c++ on your system.
Congratulations, you’ve just built your own text editor!
6.11. THE FINAL PRODUCT 39
The color member sets the color for the text, the font member sets the FLTK font index to use, and
the size member sets the pixel size of the text. The attr member is currently not used.
For our text editor we’ll define 7 styles for plain code, comments, keywords, and preprocessor directives-
:
Fl Text Display::Style Table Entry styletable[] = { // Style table
{ FL BLACK, FL COURIER, FL NORMAL SIZE }, // A - Plain
40 CHAPTER 6. DESIGNING A SIMPLE TEXT EDITOR
You’ll notice that the comments show a letter next to each style - each style in the style buffer is
referenced using a character starting with the letter ’A’.
You call the highlight data() method to associate the style data and buffer with the text editor
widget:
Fl Text Buffer *stylebuf;
Finally, you need to add a callback to the main text buffer so that changes to the text buffer are mirrored
in the style buffer:
textbuf->add modify callback(style update, w->editor);
The style update() function, like the change cb() function described earlier, is called when-
ever text is added or removed from the text buffer. It mirrors the changes in the style buffer and then updates
the style data as necessary:
//
// ’style update()’ - Update the style buffer...
//
void
style update(int pos, // I - Position of update
int nInserted, // I - Number of inserted chars
int nDeleted, // I - Number of deleted chars
int nRestyled, // I - Number of restyled chars
const char *deletedText, // I - Text that was deleted
void *cbArg) { // I - Callback data
int start, // Start of text
end; // End of text
char last, // Last style on line
style, // Style data
text; // Text data
// comment character...
start = textbuf->line start(pos);
end = textbuf->line end(pos + nInserted - nDeleted);
text = textbuf->text range(start, end);
style = stylebuf->text range(start, end);
last = style[end - start - 1];
end = textbuf->length();
text = textbuf->text range(start, end);
style = stylebuf->text range(start, end);
free(text);
free(style);
}
The style parse() function scans a copy of the text in the buffer and generates the necessary style
characters for display. It assumes that parsing begins at the start of a line:
//
// ’style parse()’ - Parse text and produce style data.
//
void
style parse(const char *text,
char *style,
int length) {
char current;
int col;
int last;
char buf[255],
bufptr;
const char *temp;
for (current = *style, col = 0, last = 0; length > 0; length --, text ++) {
if (current == ’A’) {
// Check for directives, comments, strings, and keywords...
if (col == 0 && *text == ’#’) {
// Set style to directive
current = ’E’;
} else if (strncmp(text, "//", 2) == 0) {
current = ’B’;
} else if (strncmp(text, "/*", 2) == 0) {
current = ’C’;
} else if (strncmp(text, "\\\"", 2) == 0) {
// Quoted quote...
*style++ = current;
*style++ = current;
text ++;
length --;
col += 2;
continue;
} else if (*text == ’\"’) {
current = ’D’;
} else if (!last && islower(*text)) {
// Might be a keyword...
for (temp = text, bufptr = buf;
islower(*temp) && bufptr < (buf + sizeof(buf) - 1);
*bufptr++ = *temp++);
if (!islower(*temp)) {
*bufptr = ’\0’;
42 CHAPTER 6. DESIGNING A SIMPLE TEXT EDITOR
bufptr = buf;
text --;
length ++;
last = 1;
continue;
} else if (bsearch(&bufptr, code keywords,
sizeof(code keywords) / sizeof(code keywords[0]),
sizeof(code keywords[0]), compare keywords)) {
while (text < temp) {
*style++ = ’G’;
text ++;
length --;
col ++;
}
text --;
length ++;
last = 1;
continue;
}
}
}
} else if (current == ’C’ && strncmp(text, "*/", 2) == 0) {
// Close a C comment...
style++ = current;
style++ = current;
text ++;
length --;
current = ’A’;
col += 2;
continue;
} else if (current == ’D’) {
// Continuing in string...
if (strncmp(text, "\\\"", 2) == 0) {
// Quoted end quote...
style++ = current;
style++ = current;
text ++;
length --;
col += 2;
continue;
} else if (*text == ’\"’) {
// End quote...
style++ = current;
col ++;
current = ’A’;
continue;
}
}
if (*text == ’\n’) {
// Reset column and possibly reset the style
col = 0;
if (current == ’B’ || current == ’E’) current = ’A’;
}
}
}
Chapter 7
This chapter covers the drawing functions that are provided with FLTK.
• The most common place is inside the virtual Fl Widget::draw() method. To write code here, you
must subclass one of the existing Fl Widget classes and implement your own version of draw().
• You can also create custom boxtypes and labeltypes. These involve writing small procedures that
can be called by existing Fl Widget::draw() methods. These ”types” are identified by an 8-bit index
that is stored in the widget’s box(), labeltype(), and possibly other properties.
• You can call Fl Window::make current() to do incremental update of a widget. Use Fl Widget-
::window() to find the window.
• Boxes
• Clipping
• Colors
• Drawing Text
• Fonts
• Character Encoding
• Drawing Overlays
43
44 CHAPTER 7. DRAWING THINGS IN FLTK
• Drawing Images
• Image Classes
• Offscreen Drawing
7.2.1 Boxes
FLTK provides three functions that can be used to draw boxes for buttons and other UI controls. Each
function uses the supplied upper-lefthand corner and width and height to determine where to draw the box.
void fl draw box(Fl Boxtype b, int x, int y, int w, int h, Fl Color c);
The fl draw box() function draws a standard boxtype b in the specified color c.
The fl frame() and fl frame2() functions draw a series of line segments around the given box.
The string s must contain groups of 4 letters which specify one of 24 standard grayscale values, where
’A’ is black and ’X’ is white. The results of calling these functions with a string that is not a multiple
of 4 characters in length are undefined.
The only difference between fl frame() and fl frame2() is the order of the line segments:
• For fl frame() the order of each set of 4 characters is: top, left, bottom, right.
• For fl frame2() the order of each set of 4 characters is: bottom, right, top, left.
7.2.2 Clipping
You can limit all your drawing to a rectangular region by calling fl push clip(), and put the drawings
back by using fl pop clip(). This rectangle is measured in pixels and is unaffected by the current
transformation matrix.
In addition, the system may provide clipping when updating windows which may be more complex
than a simple rectangle.
void fl push clip(int x, int y, int w, int h)
void fl clip(int x, int y, int w, int h)
Intersect the current clip region with a rectangle and push this new region onto the stack.
The fl clip() version is deprecated and will be removed from future releases.
Note: You must call fl pop clip() once for every time you call fl push clip(). If you return to
FLTK with the clip stack not empty unpredictable results occur.
Returns non-zero if any of the rectangle intersects the current clip region. If this returns 0 you don’t
have to draw the object.
Note: Under X this returns 2 if the rectangle is partially clipped, and 1 if it is entirely inside the clip
region.
int fl clip box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
Intersect the rectangle x,y,w,h with the current clip region and returns the bounding box of the
result in X,Y,W,H. Returns non-zero if the resulting rectangle is different than the original. This
can be used to limit the necessary drawing to a rectangle. W and H are set to zero if the rectangle is
completely outside the region.
Replace the top of the clip stack with a clipping region of any shape. Fl Region is an operating system
specific type. The second form returns the current clipping region.
7.3 Colors
FLTK manages colors as 32-bit unsigned integers, encoded as RGBI. When the ”RGB” bytes are non-zero,
the value is treated as RGB. If these bytes are zero, the ”I” byte will be used as an index into the colormap.
Colors with both ”RGB” set and an ”I” >0 are reserved for special use.
Values from 0 to 255, i.e. the ”I” index value, represent colors from the FLTK 1.3.x standard colormap
and are allocated as needed on screens without TrueColor support. The Fl Color enumeration type defines
the standard colors and color cube for the first 256 colors. All of these are named with symbols in <FL/-
Enumerations.H>. Example:
\image html fltk-colormap.png "FLTK default colormap (Fl_Color 0x00 - 0xff)"
\image latex fltk-colormap.png "FLTK default colormap (Fl_Color 0x00 - 0xff)" width=6cm
Color values greater than 255 are treated as 24-bit RGB values. These are mapped to the closest color
supported by the screen, either from one of the 256 colors in the FLTK 1.3.x colormap or a direct RGB
value on TrueColor screens.
Fl Color fl rgb color(uchar r, uchar g, uchar b)
Fl Color fl rgb color(uchar grayscale)
Generate Fl Color out of specified 8-bit RGB values or one 8-bit grayscale value.
Sets the color for all subsequent drawing operations. Please use the first form: the second form is only
provided for back compatibility.
46 CHAPTER 7. DRAWING THINGS IN FLTK
For colormapped displays, a color cell will be allocated out of fl colormap the first time you use a
color. If the colormap fills up then a least-squares algorithm is used to find the closest color.
Fl Color fl color()
Returns the last color that was set using fl color(). This can be used for state save/restore.
Set the color for all subsequent drawing operations. The closest possible match to the RGB color is
used. The RGB color is used directly on TrueColor displays. For colormap visuals the nearest index
in the gray ramp or color cube is used.
Generate RGB values from a colormap index value i. The first returns the RGB as a 32-bit unsigned
integer, and the second decomposes the RGB into three 8-bit values.
The first gets color values from the user preferences or the system, and the other routines are used to
apply those values.
Fl::own colormap()
Fl::free color(Fl Color i, int overlay)
Fl::set color(Fl Color i, unsigned c)
Fl::free color() and Fl::set color() are used to remove and replace entries from the
colormap.
There are two predefined graphical interfaces for choosing colors. The function fl show colormap() shows
a table of colors and returns an Fl Color index value. The Fl Color Chooser widget provides a standard
RGB color chooser.
As the Fl Color encoding maps to a 32-bit unsigned integer representing RGBI, it is also possible to
specify a color using a hex constant as a color map index:
// COLOR MAP INDEX
color(0x000000II)
------ |
| |
| Color map index (8 bits)
Must be zero
Note
If TrueColor is not available, any RGB colors will be set to the nearest entry in the colormap.
Set how to draw lines (the ”pen”). If you change this it is your responsibility to set it back to the default
with fl line style(0).
Note: Because of how line styles are implemented on MS Windows systems, you must set the line
style after setting the drawing color. If you set the color after the line style you will lose the line style
settings!
style is a bitmask which is a bitwise-OR of 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.
• FL SOLID -------
• FL DASH - - - -
• FL DOT .......
• FL DASHDOT - . - .
• FL DASHDOTDOT - .. -
• FL CAP FLAT
• FL CAP ROUND
• FL CAP SQUARE (extends past end point 1/2 line width)
• FL JOIN MITER (pointed)
• FL JOIN ROUND
• FL 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.
48 CHAPTER 7. DRAWING THINGS IN FLTK
dashes is a pointer to an array of dash lengths, measured in pixels. The first location is how long to
draw a solid portion, the next is how long to draw the gap, then the solid, etc. It is terminated with a
zero-length entry. A NULL pointer or a zero-length array results in a solid line. Odd array sizes are not
supported and result in undefined behavior.
Note: The dashes array does not work under Windows 95, 98, or Me, since those operating systems
do not support complex line styles.
Color a rectangle with ”exactly” the passed r,g,b color. On screens with less than 24 bits of color
this is done by drawing a solid-colored block using fl draw image() so that the correct color shade is
produced.
void fl loop(int x, int y, int x1, int y1, int x2, int y2)
void fl loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)
void fl polygon(int x, int y, int x1, int y1, int x2, int y2)
void fl polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)
Draw horizontal and vertical lines. A horizontal line is drawn first, then a vertical, then a horizontal.
Draw vertical and horizontal lines. A vertical line is drawn first, then a horizontal, then a vertical.
Draw ellipse sections using integer coordinates. These functions match the rather limited circle draw-
ing code provided by X and MS Windows. The advantage over using fl arc() with floating point
coordinates is that they are faster because they often use the hardware, and they draw much nicer small
circles, since the small sizes are often hard-coded bitmaps.
If a complete circle is drawn it will fit inside the passed bounding box. The two angles are measured
in degrees counter-clockwise from 3’oclock and are the starting and ending angle of the arc, a2 must
be greater or equal to a1.
fl arc() draws a series of lines to approximate the arc. Notice that the integer version of fl arc()
has a different number of arguments to the other fl arc() function described later in this chapter.
fl pie() draws a filled-in pie slice. This slice may extend outside the line drawn by fl arc(); to
avoid this use w-1 and h-1.
void fl scroll(int X, int Y, int W, int H, int dx, int dy, void (draw area)(void, int,int,int,int), void∗ data)
Scroll a rectangle and draw the newly exposed portions. The contents of the rectangular area is first
shifted by dx and dy pixels. The callback is then called for every newly exposed rectangular area,
Save and restore the current transformation. The maximum depth of the stack is 32 entries.
50 CHAPTER 7. DRAWING THINGS IN FLTK
Concatenate another transformation onto the current one. The rotation angle is in degrees (not radians)
and is counter-clockwise.
Transform a coordinate or a distance using the current transformation matrix. After transforming a co-
ordinate pair, it can be added to the vertex list without any further translations using fl transformed-
vertex().
Start and end drawing a list of points. Points are added to the list with fl vertex().
Start and end drawing a complex filled polygon. This polygon may be concave, may have holes in it,
or may be several disconnected pieces. Call fl gap() to separate loops of the path. It is unnecessary
but harmless to call fl gap() before the first vertex, after the last one, or several times in a row.
fl gap() should only be called between fl begin complex polygon() and fl end complex-
polygon(). To outline the polygon, use fl begin loop() and replace each fl gap() with a
fl end loop();fl begin loop() pair.
7.3. COLORS 51
Note: For portability, you should only draw polygons that appear the same whether ”even/odd” or
”non-zero” winding rules are used to fill them. Holes should be drawn in the opposite direction of the
outside loop.
void fl curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3)
Add a series of points on a Bezier curve to the path. The curve ends (and two of the points are) at
X0,Y0 and X3,Y3.
Add a series of points to the current path on the arc of a circle; you can get elliptical paths by using
scale and rotate before calling fl arc(). The center of the circle is given by x and y, and r is its
radius. fl arc() takes start and end angles that are measured in degrees counter-clockwise from
3 o’clock. If end is less than start then it draws the arc in a clockwise direction.
fl circle(...) is equivalent to fl arc(...,0,360) but may be faster. It must be the only thing in the
path: if you want a circle as part of a complex polygon you must use fl arc().
Note: fl circle() draws incorrectly if the transformation is both rotated and non-square scaled.
Draw a nul-terminated string or an array of n characters starting at the given location. Text is aligned
to the left and to the baseline of the font. To align to the bottom, subtract fl descent() from y. To
align to the top, subtract fl descent() and add fl height(). This version of fl draw() provides
direct access to the text drawing function of the underlying OS. It does not apply any special handling
to control characters.
void fl draw(const char∗ str, int x, int y, int w, int h, Fl Align align, Fl Image∗ img, int draw symbols)
Fancy string drawing function which is used to draw all the labels. The string is formatted and aligned
inside the passed box. Handles ’\t’ and ’\n’, expands all other control characters to ∧ X, and aligns
inside or against the edges of the box described by x, y, w and h. See Fl Widget::align() for values for
align. The value FL ALIGN INSIDE is ignored, as this function always prints inside the box.
If img is provided and is not NULL, the image is drawn above or below the text as specified by the
align value.
52 CHAPTER 7. DRAWING THINGS IN FLTK
The draw symbols argument specifies whether or not to look for symbol names starting with the
”@” character.
void fl measure(const char ∗str, int& w, int& h, int draw symbols)
Measure how wide and tall the string will be when printed by the fl draw(...align) function. This
includes leading/trailing white space in the string, kerning, etc.
Refer to the full documentation for fl measure() for details on usage and how to avoid common pitfalls.
See Also
fl text extents() – measure the ’inked’ area of a string
fl width() – measure the pixel width of a string or single character
fl height() – measure the pixel height of the current font
fl descent() – the height of the descender for the current font
int fl height()
Recommended minimum line spacing for the current font. You can also just use the value of size
passed to fl font().
See Also
fl text extents(), fl measure(), fl width(), fl descent()
int fl descent()
Recommended distance above the bottom of a fl height() tall box to draw the text at so it looks
centered vertically in that box.
double fl width(const char∗ txt)
double fl width(const char∗ txt, int n)
double fl width(unsigned int unicode char)
Return the pixel width of a nul-terminated string, a sequence of n characters, or a single character in
the current font.
See Also
fl measure(), fl text extents(), fl height(), fl descent()
void fl text extents(const char∗ txt, int& dx, int& dy, int& w, int& h)
Determines the minimum pixel dimensions of a nul-terminated string, ie. the ’inked area’.
Given a string ”txt” drawn using fl draw(txt, x, y) you would determine its pixel extents on the display
using fl text extents(txt, dx, dy, wo, ho) such that a bounding box that exactly fits around the inked
area of the text could be drawn with fl rect(x+dx, y+dy, wo, ho).
Refer to the full documentation for fl text extents() for details on usage.
7.3. COLORS 53
See Also
fl measure(), fl width(), fl height(), fl descent()
const char∗ fl shortcut label(int shortcut)
Unparse a shortcut value as used by Fl Button or Fl Menu Item into a human-readable string like ”-
Alt+N”. This only works if the shortcut is a character key or a numbered function key. If the shortcut
is zero an empty string is returned. The return value points at a static buffer that is overwritten with
each call.
7.3.5 Fonts
FLTK supports a set of standard fonts based on the Times, Helvetica/Arial, Courier, and Symbol typefaces,
as well as custom fonts that your application may load. Each font is accessed by an index into a font table.
Initially only the first 16 faces are filled in. There are symbolic names for them: FL HELVETICA,
FL TIMES, FL COURIER, and modifier values FL BOLD and FL ITALIC which can be added to these,
and FL SYMBOL and FL ZAPF DINGBATS. Faces greater than 255 cannot be used in Fl Widget labels,
since Fl Widget stores the index as a byte.
void fl font(int face, int size)
Set the current font, which is then used by the routines described above. You may call this outside a
draw context if necessary to call fl width(), but on X this will open the display.
The font is identified by a face and a size. The size of the font is measured in pixels and not
”points”. Lines should be spaced size pixels apart or more.
int fl font()
int fl size()
Returns the face and size set by the most recent call to fl font(a,b). This can be used to
save/restore the font.
fl overlay rect() draws a selection rectangle, erasing any previous rectangle by XOR’ing it first.
fl overlay clear() will erase the rectangle without drawing a new one.
Using these functions is tricky. You should make a widget with both a handle() and draw()
method. draw() should call fl overlay clear() before doing anything else. Your handle()
method should call window()->make current() and then fl overlay rect() after FL D-
RAG events, and should call fl overlay clear() after a FL RELEASE event.
54 CHAPTER 7. DRAWING THINGS IN FLTK
Draw an 8-bit per color RGB or luminance image. The pointer points at the ”r” data of the top-left
pixel. Color data must be in r,g,b order. The top left corner is given by X and Y and the size of
the image is given by W and H. D is the delta to add to the pointer between pixels, it may be any value
greater or equal to 3, or it can be negative to flip the image horizontally. L is the delta to add to the
pointer between lines (if 0 is passed it uses W∗D). and may be larger than W∗D to crop data, or negative
to flip the image vertically.
It is highly recommended that you put the following code before the first show() of any window in
your program to get rid of the dithering if possible:
Fl::visual(FL RGB);
Gray scale (1-channel) images may be drawn. This is done if abs(D) is less than 3, or by calling
fl draw image mono(). Only one 8-bit sample is used for each pixel, and on screens with different
numbers of bits for red, green, and blue only gray colors are used. Setting D greater than 1 will let you
display one channel of a color image.
Note: The X version does not support all possible visuals. If FLTK cannot draw the image in the
current visual it will abort. FLTK supports any visual of 8 bits or less, and all common TrueColor
visuals up to 32 bits.
typedef void (∗Fl Draw Image Cb)(void ∗data,int x,int y,int w,uchar ∗buf)
void fl draw image(Fl Draw Image Cb cb,void ∗data,int X,int Y,int W,int H,int D)
void fl draw image mono(Fl Draw Image Cb cb,void ∗data,int X,int Y,int W,int H,int D)
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.
The callback is called with the void∗ user data pointer which can be used to point at a structure of
information about the image, and the x, y, and w of the scan line desired from the image. 0,0 is the
upper-left corner of the image, not X,Y. A pointer to a buffer to put the data into is passed. You must
copy w pixels from scanline y, starting at pixel x, to this buffer.
Due to cropping, less than the whole image may be requested. So x may be greater than zero, the first
y may be greater than zero, and w may be less than W. The buffer is long enough to store the entire
W∗D pixels, this is for convenience with some decompression schemes where you must decompress
the entire line at once: decompress it into the buffer, and then if x is not zero, copy the data over so the
x’th pixel is at the start of the buffer.
7.4. DRAWING IMAGES 55
You can assume the y’s will be consecutive, except the first one may be greater than zero.
Draws XPM image data, with the top-left corner at the given position. The image is dithered on 8-
bit displays so you won’t lose color space for programs displaying both images and pixmaps. This
function returns zero if there was any error decoding the XPM data.
Transparent colors are replaced by the optional Fl Color argument. To draw with true transparency
you must use the Fl Pixmap class.
An XPM image contains the dimensions in its data. This function finds and returns the width and
height. The return value is non-zero if the dimensions were parsed ok and zero if there was any
problem.
Read a RGB(A) image from the current window or off-screen buffer. The p argument points to a buffer
that can hold the image and must be at least W∗H∗3 bytes when reading RGB images and W∗H∗4 bytes
when reading RGBA images. If NULL, fl read image() will create an array of the proper size
which can be freed using delete[].
The alpha parameter controls whether an alpha channel is created and the value that is placed in the
alpha channel. If 0, no alpha channel is generated.
• Fl Bitmap
• Fl Pixmap
56 CHAPTER 7. DRAWING THINGS IN FLTK
• Fl RGB Image
The Fl Bitmap class encapsulates a mono-color bitmap image. The draw() method draws the image
using the current drawing color.
The Fl Pixmap class encapsulates a colormapped image. The draw() method draws the image using
the colors in the file, and masks off any transparent colors automatically.
The Fl RGB Image class encapsulates a full-color (or grayscale) image with 1 to 4 color components.
Images with an even number of components are assumed to contain an alpha channel that is used for
transparency. The transparency provided by the draw() method is either a 24-bit blend against the existing
window contents or a ”screen door” transparency mask, depending on the platform and screen color depth.
char fl can do alpha blending()
fl can do alpha blending() will return 1, if your platform supports true alpha blending for
RGBA images, or 0, if FLTK will use screen door transparency.
FLTK also provides several image classes based on the three standard image types for common file formats:
• Fl GIF Image
• Fl JPEG Image
• Fl PNG Image
• Fl PNM Image
• Fl XBM Image
• Fl XPM Image
Each of these image classes load a named file of the corresponding format. The Fl Shared Image class
can be used to load any type of image file - the class examines the file and constructs an image of the
appropriate type.
Finally, FLTK provides a special image class called Fl Tiled Image to tile another image object in the
specified area. This class can be used to tile a background image in a Fl Group widget, for example.
virtual void Fl Tiled Image::copy();
virtual Fl Image∗ Fl Tiled Image::copy(int w, int h);
The copy() method creates a copy of the image. The second form specifies the new size of the image
- the image is resized using the nearest-neighbor algorithm.
void Fl Tiled Image::draw(int x, int y, int w, int h, int ox, int oy);
The draw() method draws the image object. x,y,w,h indicates a destination rectangle. ox,oy,w,h
is a source rectangle. This source rectangle is copied to the destination. The source rectangle may ex-
tend outside the image, i.e. ox and oy may be negative and w and h may be bigger than the image,
and this area is left unchanged.
Draws the image with the upper-left corner at x,y. This is the same as doing draw(x,y,img->w(),img-
>h(),0,0).
7.4. DRAWING IMAGES 57
Send all subsequent drawing commands to this offscreen buffer. FLTK can draw into a buffer at any
time. There is no need to wait for an Fl Widget::draw() to occur.
void fl copy offscreen(int x, int y, int w, int h, Fl Offscreen osrc, int srcx, int srcy)
Copy a rectangular area of the size w∗h from srcx,srcy in the offscreen buffer into the current buffer
at x,y.
58 CHAPTER 7. DRAWING THINGS IN FLTK
Chapter 8
Handling Events
This chapter discusses the FLTK event model and how to handle events in your program or widget.
8.2.2 FL DRAG
The mouse has moved with a button held down. The current button state is in Fl::event state(). The mouse
position is in Fl::event x() and Fl::event y().
In order to receive FL DRAG events, the widget must return non-zero when handling FL PUSH.
8.2.3 FL RELEASE
A mouse button has been released. You can find out what button by calling Fl::event button().
In order to receive the FL RELEASE event, the widget must return non-zero when handling FL PUSH.
59
60 CHAPTER 8. HANDLING EVENTS
8.2.4 FL MOVE
The mouse has moved without any mouse buttons held down. This event is sent to the Fl::belowmouse()
widget.
In order to receive FL MOVE events, the widget must return non-zero when handling FL ENTER.
8.2.5 FL MOUSEWHEEL
The user has moved the mouse wheel. The Fl::event dx() and Fl::event dy() methods can be used to find
the amount to scroll horizontally and vertically.
8.3.2 FL LEAVE
The mouse has moved out of the widget.
In order to receive the FL LEAVE event, the widget must return non-zero when handling FL ENTER.
8.3.3 FL FOCUS
This indicates an attempt to give a widget the keyboard focus.
If a widget wants the focus, it should change itself to display the fact that it has the focus, and return
non-zero from its handle() method. It then becomes the Fl::focus() widget and gets FL KEYDOWN,
FL KEYUP, and FL UNFOCUS events.
The focus will change either because the window manager changed which window gets the focus, or
because the user tried to navigate using tab, arrows, or other keys. You can check Fl::event key() to figure
out why it moved. For navigation it will be the key pressed and for interaction with the window manager it
will be zero.
8.3.4 FL UNFOCUS
This event is sent to the previous Fl::focus() widget when another widget gets the focus or the window
loses focus.
If you are writing a text-editing widget you may also want to call the Fl::compose() function to translate
individual keystrokes into characters.
FL KEYUP events are sent to the widget that currently has focus. This is not necessarily the same
widget that received the corresponding FL KEYDOWN event because focus may have changed between
events.
Todo Add details on how to detect repeating keys, since on some X servers a repeating key will generate
both FL KEYUP and FL KEYDOWN, such that to tell if a key is held, you need Fl::event key(int)
to detect if the key is being held down during FL KEYUP or not.
8.4.2 FL SHORTCUT
If the Fl::focus() widget is zero or ignores an FL KEYBOARD event then FLTK tries sending this event to
every widget it can, until one of them returns non-zero. FL SHORTCUT is first sent to the Fl::belowmouse()
widget, then its parents and siblings, and eventually to every widget in the window, trying to find an object
that returns non-zero. FLTK tries really hard to not to ignore any keystrokes!
You can also make ”global” shortcuts by using Fl::add handler(). A global shortcut will work no matter
what windows are displayed or which one has the focus.
8.5.2 FL ACTIVATE
This widget is now active, due to activate() being called on it or one of its parents.
8.5.3 FL HIDE
This widget is no longer visible, due to hide() being called on it or one of its parents, or due to a parent
window being minimized. Please note that although visible() may still return true for this widget after
receiving this event, it is only truly visible if visible() is true for both it and all of its parents. (You can use
visible r() to check this).
8.5.4 FL SHOW
This widget is visible again, due to show() being called on it or one of its parents, or due to a parent window
being restored. A child Fl Window will respond to this by actually creating the window if not done already,
so if you subclass a window, be sure to pass FL SHOW to the base class handle() method!
Note
The events in this chapter (”Widget Events”), i.e. FL ACTIVATE, FL DEACTIVATE, FL SHOW,
and FL HIDE, are the only events deactivated and invisible widgets can usually get, depending on
their states. Under certain circumstances, there may also be FL LEAVE or FL UNFOCUS events
delivered to deactivated or hidden widgets.
62 CHAPTER 8. HANDLING EVENTS
8.6.2 FL SELECTIONCLEAR
The Fl::selection owner() will get this event before the selection is moved to another widget. This indicates
that some other widget or program has claimed the selection. Motif programs used this to clear the selection
indication. Most modern programs ignore this.
8.8.2 FL FULLSCREEN
The application window has been changed from normal to fullscreen, or from fullscreen to normal. If you
are using a X window manager which supports Extended Window Manager Hints, this event will not be
delivered until the change has actually happened.
• Fl::event button()
• Fl::event clicks()
• Fl::event dx()
• Fl::event dy()
• Fl::event inside()
• Fl::event is click()
• Fl::event key()
• Fl::event length()
• Fl::event state()
• Fl::event text()
• Fl::event x()
• Fl::event x root()
• Fl::event y()
• Fl::event y root()
• Fl::get key()
• Fl::get mouse()
• Fl::test shortcut()
• Fl::add handler()
64 CHAPTER 8. HANDLING EVENTS
• Fl::belowmouse()
• Fl::focus()
• Fl::grab()
• Fl::modal()
• Fl::pushed()
• Fl::release() (deprecated, see Fl::grab(0))
• Fl Widget::take focus()
FLTK propagates events along the widget hierarchy depending on the kind of event and the status of the
UI. Some events are injected directly into the widgets, others may be resent as new events to a different
group of receivers.
Mouse click events are first sent to the window that caused them. The window then forwards the event
down the hierarchy until it reaches the widget that is below the click position. If that widget uses the given
event, the widget is marked ”pushed” and will receive all following mouse motion (FL DRAG) events until
the mouse button is released.
Mouse motion (FL MOVE) events are sent to the Fl::belowmouse() widget, i.e. the widget that returned
1 on the last FL ENTER event.
Mouse wheel events are sent to the window that caused the event. The window propagates the event
down the tree, first to the widget that is below the mouse pointer, and if that does not succeed, to all other
widgets in the group. This ensures that scroll widgets work as expected with the widget furthest down in
the hierarchy getting the first opportunity to use the wheel event, but also giving scroll bars, that are not
directly below the mouse a chance.
Keyboard events are sent directly to the widget that has keyboard focus. If the focused widget rejects
the event, it is resent as a shortcut event, first to the top-most window, then to the widget below the mouse
pointer, propagating up the hierarchy to all its parents. Those send the event also to all widgets that are
not below the mouse pointer. Now if that did not work out, the shortcut is sent to all registered shortcut
handlers.
If we are still unsuccessful, the event handler flips the case of the shortcut letter and starts over. Finally,
if the key is ”escape”, FLTK sends a close event to the top-most window.
All other events are pretty much sent right away to the window that created the event.
Widgets can ”grab” events. The grabbing window gets all events exclusively, but usually by the same
rules as described above.
Windows can also request exclusivity in event handling by making the window modal.
• Fl::compose()
• Fl::compose reset()
This chapter describes how to add your own widgets or extend existing widgets in FLTK.
9.1 Subclassing
New widgets are created by subclassing an existing FLTK widget, typically Fl Widget for controls and
Fl Group for composite widgets.
A control widget typically interacts with the user to receive and/or display a value of some sort.
A composite widget holds a list of child widgets and handles moving, sizing, showing, or hiding them
as needed. Fl Group is the main composite widget class in FLTK, and all of the other composite widgets
(Fl Pack, Fl Scroll, Fl Tabs, Fl Tile, and Fl Window) are subclasses of it.
You can also subclass other existing widgets to provide a different look or user-interface. For example,
the button widgets are all subclasses of Fl Button since they all interact with the user via a mouse button
click. The only difference is the code that draws the face of the button.
Fl Widget’s protected constructor sets x(), y(), w(), h(), and label() to the passed values and
initializes the other instance variables to:
type(0);
box(FL NO BOX);
color(FL BACKGROUND COLOR);
selection color(FL BACKGROUND COLOR);
labeltype(FL NORMAL LABEL);
labelstyle(FL NORMAL STYLE);
65
66 CHAPTER 9. ADDING AND EXTENDING WIDGETS
• clear visible()
• damage()
• draw box()
• draw focus()
• draw label()
• set flag()
• set visible()
• test shortcut()
• type()
The first form indicates that a partial update of the object is needed. The bits in mask are OR’d into
damage(). Your draw() routine can examine these bits to limit what it is drawing. The public method
Fl Widget::redraw() simply does Fl Widget::damage(FL DAMAGE ALL), but the implementa-
tion of your widget can call the public damage(n).
The second form indicates that a region is damaged. If only these calls are done in a window (no calls
to damage(n)) then FLTK will clip to the union of all these calls before drawing anything. This
can greatly speed up incremental displays. The mask bits are OR’d into damage() unless this is a
Fl Window widget.
The third form returns the bitwise-OR of all damage(n) calls done since the last draw().
When redrawing your widgets you should look at the damage bits to see what parts of your widget
need redrawing. The handle() method can then set individual damage bits to limit the amount of
drawing that needs to be done:
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() & FL DAMAGE ALL) {
... draw frame/box and other static stuff ...
9.4. PROTECTED METHODS OF FL WIDGET 67
Todo Clarify Fl Window::damage(uchar) handling - seems confused/wrong? ORing value doesn’t match
setting behaviour in FL Widget.H!
void Fl Widget::draw box() const
void Fl Widget::draw box(Fl Boxtype t, Fl Color c) const
The first form draws this widget’s box(), using the dimensions of the widget. The second form uses
t as the box type and c as the color for the box.
void Fl Widget::draw focus()
void Fl Widget::draw focus(Fl Boxtype t, int x, int y, int w, int h) const
Draws a focus box inside the widget’s bounding box. The second form allows you to specify a different
bounding box.
void Fl Widget::draw label() const
void Fl Widget::draw label(int x, int y, int w, int h) const
void Fl Widget::draw label(int x, int y, int w, int h, Fl Align align) const
The first form is the usual function for a draw() method to call to draw the widget’s label. It does
not draw the label if it is supposed to be outside the box (on the assumption that the enclosing group
will draw those labels).
The second form uses the passed bounding box instead of the widget’s bounding box. This is useful
so ”centered” labels are aligned with some feature, like a moving slider.
The third form draws the label anywhere. It acts as though FL ALIGN INSIDE has been forced on
so the label will appear inside the passed bounding box. This is designed for parent groups to draw
labels with.
void Fl Widget::set flag(int c)
Calling set flag(SHORTCUT LABEL) modifies the behavior of draw label() so that ’&’ characters
cause an underscore to be printed under the next letter.
void Fl Widget::set visible()
void Fl Widget::clear visible()
Fast inline versions of Fl Widget::hide() and Fl Widget::show(). These do not send the FL HIDE and
FL SHOW events to the widget.
int Fl Widget::test shortcut()
static int Fl Widget::test shortcut(const char ∗s)
The first version tests Fl Widget::label() against the current event (which should be a FL SHORTCUT
event). If the label contains a ’&’ character and the character after it matches the keypress, this returns
true. This returns false if the SHORTCUT LABEL flag is off, if the label is NULL, or does not have a
’&’ character in it, or if the keypress does not match the character.
68 CHAPTER 9. ADDING AND EXTENDING WIDGETS
The second version lets you do this test against an arbitrary string.
Todo Clarify Fl Widget::test shortcut() explanations. Fl Widget.h says Internal Use only, but subclassing
chapter gives details!
The property Fl Widget::type() can return an arbitrary 8-bit identifier, and can be set with the protected
method type(uchar t). This value had to be provided for Forms compatibility, but you can use it
for any purpose you want. Try to keep the value less than 100 to not interfere with reserved values.
FLTK does not use RTTI (Run Time Typing Information), to enhance portability. But this may change
in the near future if RTTI becomes standard everywhere.
If you don’t have RTTI you can use the clumsy FLTK mechanism, by having type() use a unique
value. These unique values must be greater than the symbol FL RESERVED TYPE (which is 100) and
less than FL WINDOW (unless you make a subclass of Fl Window). Look through the header files for
FL RESERVED TYPE to find an unused number. If you make a subclass of Fl Window you must use
FL WINDOW + n (where n must be in the range 1 to 7).
Events are identified by the integer argument. Other information about the most recent event is stored in
static locations and acquired by calling the Fl::event ∗() methods. This information remains valid until
another event is handled.
Here is a sample handle() method for a widget that acts as a pushbutton and also accepts the
keystroke ’x’ to cause the callback:
int MyClass::handle(int event) {
switch(event) {
case FL PUSH:
highlight = 1;
redraw();
return 1;
case FL DRAG: {
int t = Fl::event inside(this);
if (t != highlight) {
highlight = t;
redraw();
}
}
return 1;
case FL RELEASE:
if (highlight) {
highlight = 0;
9.6. DRAWING THE WIDGET 69
redraw();
do callback();
// never do anything after a callback, as the callback
// may delete the widget!
}
return 1;
case FL SHORTCUT:
if (Fl::event key() == ’x’) {
do callback();
return 1;
}
return 0;
default:
return Fl Widget::handle(event);
}
}
You must return non-zero if your handle() method uses the event. If you return zero, the parent
widget will try sending the event to another widget.
For debugging purposes, event numbers can be printed as their actual event names using the fl -
eventnames[] array, e.g.:
#include <FL/names.h> // defines fl eventnames[]
[..]
int MyClass::handle(int e) {
printf("Event was %s (%d)\n", fl eventnames[e], e); // e.g. "Event was FL PUSH (1)"
[..]
...
};
The constructor has to initialize these instances. They are automatically added to the group, since
the Fl Group constructor does Fl Group::begin(). Don’t forget to call Fl Group::end() or use the Fl End
pseudo-class:
The child widgets need callbacks. These will be called with a pointer to the children, but the widget
itself may be found in the parent() pointer of the child. Usually these callbacks can be static private
methods, with a matching private method:
If you make the handle() method, you can quickly pass all the events to the children using the Fl-
Group::handle() method. You don’t need to override handle() if your composite widget does nothing
other than pass events to the children:
If you override draw() you need to draw all the children. If redraw() or damage() is called on
a child, damage(FL DAMAGE CHILD) is done to the group, so this bit of damage() can be used to
indicate that a child needs to be drawn. It is fastest if you avoid drawing anything else in this case:
int MyClass::draw() {
Fl Widget *const*a = array();
if (damage() == FL DAMAGE CHILD) { // only redraw some children
for (int i = children(); i --; a ++) update child(**a);
} else { // total redraw
... draw background graphics ...
// now draw all the children atop the background:
for (int i = children ; i --; a ++) {
draw child(**a);
draw outside label(**a); // you may not need to do this
}
}
}
• draw child()
• draw children()
• update child()
This will force the child’s damage() bits all to one and call draw() on it, then clear the damage().
You should call this on all children if a total redraw of your widget is requested, or if you draw some-
thing (like a background box) that damages the child. Nothing is done if the child is not visible()
or if it is clipped.
A convenience function that draws all children of the group. This is useful if you derived a widget
from Fl Group and want to draw a special border or background. You can call draw children()
from the derived draw() method after drawing the box, border, or background.
Draw the labels that are not drawn by draw label(). If you want more control over the label positions
you might want to call child->draw label(x,y,w,h,a).
Draws the child only if its damage() is non-zero. You should call this on all the children if your own
damage is equal to FL DAMAGE CHILD. Nothing is done if the child is not visible() or if it is
clipped.
• Fl::paste()
• Fl::selection()
• Fl::selection owner()
It may be possible to cut/paste non-text data by using Fl::add handler(). Note that handling events beyond
those provided by FLTK may be operating system specific. See Operating System Issues for more details.
• FL DND ENTER
• FL DND DRAG
• FL DND LEAVE
• FL DND RELEASE
• FL PASTE
72 CHAPTER 9. ADDING AND EXTENDING WIDGETS
1. Fl Window is a subclass of Fl Group so make sure your constructor calls end() unless you actually
want children added to your window.
2. When handling events and drawing, the upper-left corner is at 0,0, not x(),y() as in other Fl -
Widget’s. For instance, to draw a box around the widget, call draw box(0,0,w(),h()), rather
than draw box(x(),y(),w(),h()).
You may also want to subclass Fl Window in order to get access to different visuals or to change other
attributes of the windows. See the Operating System Issues chapter for more information.
Chapter 10
Using OpenGL
• A class definition.
• A draw() method.
If your subclass provides static controls in the window, they must be redrawn whenever the FL DAMA-
GE ALL bit is set in the value returned by damage(). For double-buffered windows you will need to
surround the drawing code with the following code to make sure that both buffers are redrawn:
#ifndef MESA
glDrawBuffer(GL FRONT AND BACK);
#endif // !MESA
... draw stuff here ...
#ifndef MESA
glDrawBuffer(GL BACK);
#endif // !MESA
Note:
If you are using the Mesa graphics library, the call to glDrawBuffer() is not required and will
slow down drawing considerably. The preprocessor instructions shown above will optimize your code
based upon the graphics library used.
73
74 CHAPTER 10. USING OPENGL
public:
MyWindow(int X, int Y, int W, int H, const char *L)
: Fl Gl Window(X, Y, W, H, L) {}
};
The draw() and handle() methods are described below. Like any widget, you can include addi-
tional private and public data in your class (such as scene graph information, etc.)
When handle() is called, the OpenGL context is not set up! If your display changes, you should
call redraw() and let draw() do the work. Don’t call any OpenGL drawing functions from inside
handle()!
You can call some OpenGL stuff like hit detection and texture loading functions by doing:
case FL PUSH:
make current(); // make OpenGL context current
if (!valid()) {
10.3. USING OPENGL IN NORMAL FLTK WINDOWS 75
Your main program can now create one of your windows by doing new MyWindow(...).
You can also use your new window class in FLUID by:
3. In the widget panel fill in the ”class” field with MyWindow. This will make FLUID produce con-
structors for your new class.
4. In the ”Extra Code” field put #include "MyWindow.H", so that the FLUID output file will
compile.
You must put glwindow->show() in your main code after calling show() on the window con-
taining the OpenGL window.
You can then put OpenGL drawing code anywhere you can draw normally by surrounding it with gl-
start() and gl finish() to set up, and later release, an OpenGL context with an orthographic projection so
that 0,0 is the lower-left corner of the window and each pixel is one unit. The current clipping is reproduced
with OpenGL glScissor() commands. These functions also synchronize the OpenGL graphics stream
with the drawing done by other X, WIN32, or FLTK functions.
gl start();
... put your OpenGL code here ...
gl finish();
The same context is reused each time. If your code changes the projection transformation or anything
else you should use glPushMatrix() and glPopMatrix() functions to put the state back before
calling gl finish().
You may want to use Fl Window::current()->h() to get the drawable height so that you can
flip the Y coordinates.
Unfortunately, there are a bunch of limitations you must adhere to for maximum portability:
Sets the current OpenGL color to a FLTK color. For color-index modes it will use fl xpixel(c),
which is only right if this window uses the default colormap!
Outlines or fills a rectangle with the current color. If Fl Gl Window::ortho() has been called, then the
rectangle will exactly fill the pixel rectangle passed.
Sets the current OpenGL font to the same font you get by calling fl font().
int gl height()
int gl descent()
float gl width(const char ∗s)
float gl width(const char ∗s, int n)
float gl width(uchar c)
Draws a nul-terminated string or an array of n characters in the current OpenGL font at the current
raster position.
Draws a nul-terminated string or an array of n characters in the current OpenGL font at the given
position.
Draws a string formatted into a box, with newlines and tabs expanded, other control characters changed
to ∧ X, and aligned with the edges or center. Exactly the same output as fl draw().
10.5. SPEEDING UP OPENGL 77
• All other values for GL SWAP TYPE, and not setting the variable, cause FLTK to assume that the
back buffer must be completely redrawn after a swap.
This is easily tested by running the gl overlay demo program and seeing if the display is correct when you
drag another window over it or if you drag the window off the screen and back on. You have to exit and
run the program again for it to see any changes to the environment variable.
To use OpenGL Optimizer with FLTK you’ll need to create a subclass of Fl Gl Widget that in-
cludes several state variables:
class OptimizerWindow : public Fl Gl Window {
csContext *context ; // Initialized to 0 and set by draw()...
csDrawAction *draw action ; // Draw action...
csGroup *scene ; // Scene to draw...
csCamara *camera ; // Viewport for scene...
void draw();
public:
OptimizerWindow(int X, int Y, int W, int H, const char *L)
: Fl Gl Window(X, Y, W, H, L) {
context = (csContext *)0;
draw action = (csDrawAction *)0;
scene = (csGroup *)0;
camera = (csCamera *)0;
}
The camera() method sets the camera (projection and viewpoint) to use when drawing the scene.
The scene is redrawn after this call.
The draw() Method
The draw() method performs the needed initialization and does the actual drawing:
void OptimizerWindow::draw() {
if (!context ) {
// This is the first time we’ve been asked to draw; create the
// Optimizer context for the scene...
#ifdef WIN32
context = new csContext((HDC)fl getHDC());
context ->ref();
context ->makeCurrent((HDC)fl getHDC());
#else
context = new csContext(fl display, fl visual);
context ->ref();
context ->makeCurrent(fl display, fl window);
#endif // WIN32
if (!valid()) {
// Update the viewport for this context...
context ->setViewport(0, 0, w(), h());
}
The scene() method sets the scene to be drawn. The scene is a collection of 3D objects in a cs-
Group. The scene is redrawn after this call.
Chapter 11
This chapter shows how to use the Fast Light User-Interface Designer (”FLUID”) to create your GUIs.
Subchapters:
• What is FLUID?
• A Short Tutorial
• FLUID Reference
• Known limitations
79
80 CHAPTER 11. PROGRAMMING WITH FLUID
Normally the FLUID file defines one or more functions or classes which output C++ code. Each
function defines one or more FLTK windows, and all the widgets that go inside those windows.
Widgets created by FLUID are either ”named”, ”complex named” or ”unnamed”. A named widget has
a legal C++ variable identifier as its name (i.e. only alphanumeric and underscore). In this case FLUID
defines a global variable or class member that will point at the widget after the function defining it is called.
A complex named object has punctuation such as ’.’ or ’->’ or any other symbols in its name. In this
case FLUID assigns a pointer to the widget to the name, but does not attempt to declare it. This can be
used to get the widgets into structures. An unnamed widget has a blank name and no pointer is stored.
Widgets may either call a named callback function that you write in another source file, or you can
supply a small piece of C++ source and FLUID will write a private callback function into the .cxx file.
to edit the .fl file filename.fl. If the file does not exist you will get an error pop-up, but if you
dismiss it you will be editing a blank file of that name. You can run FLUID without any name, in which
case you will be editing an unnamed blank setup (but you can use save-as to write it to a file).
You can provide any of the standard FLTK switches before the filename:
-display host:n.n
-geometry WxH+X+Y
-title windowtitle
-name classname
-iconic
-fg color
-bg color
-bg2 color
-scheme schemename
Changing the colors may be useful to see what your interface will look at if the user calls it with the
same switches. Similarly, using ”-scheme plastic” will show how the interface will look using the ”plastic”
scheme.
In the current version, if you don’t put FLUID into the background with ’&’ then you will be able to
abort FLUID by typing CTRL-C on the terminal. It will exit immediately, losing any changes.
fluid -c filename.fl
This will read the filename.fl file and write filename.cxx and filename.h. Any leading
directory on filename.fl will be stripped, so they are always written to the current directory. If there
are any errors reading or writing the files, FLUID will print the error and exit with a non-zero code. You
can use the following lines in a makefile to automate the creation of the source and header files:
Most versions of make support rules that cause .fl files to be compiled:
The window is of class CubeViewUI, and is completely generated by FLUID, including class member
functions. The central display of the cube is a separate subclass of Fl Gl Window called CubeView. Cube-
ViewUI manages CubeView using callbacks from the various sliders and rollers to manipulate the viewing
angle and zoom of CubeView.
At the completion of this tutorial you will (hopefully) understand how to:
1. Use FLUID to create a complete user interface class, including constructor and any member functions
necessary.
Here is the CubeView class definition, as given by its header file ”test/CubeView.h”:
class CubeView : public Fl Gl Window {
public:
CubeView(int x,int y,int w,int h,const char *l=0);
// this value determines the scaling factor used to draw the cube.
double size;
/* Set the rotation about the vertical (y ) axis.
private:
/* Draw the cube boundaries
* Draw the faces of the cube using the boxv[] vertices, using
* GL LINE LOOP for the faces. The color is #defined by
11.5. A SHORT TUTORIAL 83
* CUBECOLOR.
*/
void drawCube();
Here is the CubeView implementation. It is very similar to the ”cube” demo included with FLTK.
#include "CubeView.h"
#include <math.h>
void CubeView::drawCube() {
/* Draw a colored cube */
#define ALPHA 0.5
glShadeModel(GL FLAT);
glBegin(GL QUADS);
glColor4f(0.0, 0.0, 1.0, ALPHA);
glVertex3fv(boxv0);
glVertex3fv(boxv1);
glVertex3fv(boxv2);
glVertex3fv(boxv3);
glVertex3fv(boxv1);
glVertex3fv(boxv2);
glVertex3fv(boxv2);
glVertex3fv(boxv3);
glVertex3fv(boxv3);
glVertex3fv(boxv0);
glVertex3fv(boxv4);
glVertex3fv(boxv5);
glVertex3fv(boxv5);
glVertex3fv(boxv6);
glVertex3fv(boxv6);
glVertex3fv(boxv7);
glVertex3fv(boxv7);
glVertex3fv(boxv4);
glVertex3fv(boxv0);
glVertex3fv(boxv4);
glVertex3fv(boxv1);
glVertex3fv(boxv5);
glVertex3fv(boxv2);
glVertex3fv(boxv6);
glVertex3fv(boxv3);
glVertex3fv(boxv7);
glEnd();
};//drawCube
void CubeView::draw() {
if (!valid()) {
glLoadIdentity(); glViewport(0,0,w(),h());
glOrtho(-10,10,-10,10,-20000,10000); glEnable(GL BLEND);
glBlendFunc(GL SRC ALPHA, GL ONE MINUS SRC ALPHA);
}
We will completely construct a window to display and control the CubeView defined in the previous section
using FLUID.
Once you have started FLUID, the first step in defining a class is to create a new class within FLUID using
the New->Code->Class menu item. Name the class ”CubeViewUI” and leave the subclass blank. We do
not need any inheritance for this window. You should see the new class declaration in the FLUID browser
window.
11.5. A SHORT TUTORIAL 85
Click on the CubeViewUI class in the FLUID window and add a new method by selecting New->Code-
>Function/Method. The name of the function will also be CubeViewUI. FLUID will understand that this
will be the constructor for the class and will generate the appropriate code. Make sure you declare the
constructor public.
Then add a window to the CubeViewUI class. Highlight the name of the constructor in the FLUID
browser window and click on New->Group->Window. In a similar manner add the following to the
CubeViewUI constructor:
None of these additions need be public. And they shouldn’t be unless you plan to expose them as part of
the interface for CubeViewUI.
When you are finished you should have something like this:
86 CHAPTER 11. PROGRAMMING WITH FLUID
What we have is nice, but does little to show our cube. We have already defined the CubeView class and
we would like to show it within the CubeViewUI.
The CubeView class inherits the Fl Gl Window class, which is created in the same way as a Fl Box
widget. Use New->Other->Box to add a square box to the main window. This will be no ordinary box,
however.
The Box properties window will appear. The key to letting CubeViewUI display CubeView is to enter
CubeView in the Class: text entry box. This tells FLUID that it is not an Fl Box, but a similar widget with
the same constructor.
Each of the widgets we defined before adding CubeView can have callbacks that call CubeView methods.
You can call an external function or put in a short amount of code in the Callback field of the widget panel.
For example, the callback for the ypan slider is:
We call cube->redraw() after changing the value to update the CubeView window. CubeView
could easily be modified to do this, but it is nice to keep this exposed. In the case where you may want to
do more than one view change only redrawing once saves a lot of time.
There is no reason to wait until after you have added CubeView to enter these callbacks. FLUID
assumes you are smart enough not to refer to members or functions that don’t exist.
You can add class methods within FLUID that have nothing to do with the GUI. As an example add a show
function so that CubeViewUI can actually appear on the screen.
Make sure the top level CubeViewUI is selected and select New->Code->Function/Method. Just use
the name show(). We don’t need a return value here, and since we will not be adding any widgets to this
method FLUID will assign it a return type of void.
88 CHAPTER 11. PROGRAMMING WITH FLUID
Once the new method has been added, highlight its name and select New->Code->Code. Enter the
method’s code in the code window.
Below that are either widgets (subclasses of Fl Widget) or groups of widgets (including other groups).
Plain groups are for layout, navigation, and resize purposes. Tab groups provide the well-known file-card
tab interface.
Widgets are shown in the browser by either their name (such as ”main panel” in the example), or by
their type and label (such as ”Button ”the green””).
You select widgets by clicking on their names, which highlights them (you can also select widgets
from any displayed window). You can select many widgets by dragging the mouse across them, or by
using Shift+Click to toggle them on and off. To select no widgets, click in the blank area under the last
widget. Note that hidden children may be selected even when there is no visual indication of this.
You open widgets by double-clicking on them, or (to open several widgets you have picked) by typing
the F1 key. A control panel will appear so you can change the widget(s).
Discards the current editing session and reads in a different .fl file. You are asked for confirmation
if you have changed the current file.
FLUID can also read .fd files produced by the Forms and XForms ”fdesign” programs. It is best to
File/Merge them instead of opening them. FLUID does not understand everything in a .fd file, and
will print a warning message on the controlling terminal for all data it does not understand. You will
probably need to edit the resulting setup to fix these errors. Be careful not to save the file without
changing the name, as FLUID will write over the .fd file with its own format, which fdesign cannot
read!
File/Insert... (Ctrl+i)
Inserts the contents of another .fl file, without changing the name of the current .fl file. All the
functions (even if they have the same names as the current ones) are added, and you will have to use
cut/paste to put the widgets where you want.
File/Save (Ctrl+s)
Writes the current data to the .fl file. If the file is unnamed then FLUID will ask for a filename.
File/Save As... (Ctrl+Shift+S)
”Compiles” the data into a .cxx and .h file. These are exactly the same as the files you get when you
run FLUID with the -c switch.
90 CHAPTER 11. PROGRAMMING WITH FLUID
The output file names are the same as the .fl file, with the leading directory and trailing ”.fl” stripped,
and ”.h” or ”.cxx” appended.
File/Write Strings (Ctrl+Shift+W)
Writes a message file for all of the text labels defined in the current file.
The output file name is the same as the .fl file, with the leading directory and trailing ”.fl” stripped,
and ”.txt”, ”.po”, or ”.msg” appended depending on the Internationalization Mode.
File/Quit (Ctrl+q)
Exits FLUID. You are asked for confirmation if you have changed the current file.
Edit/Undo (Ctrl+z)
This isn’t implemented yet. You should do save often so you can recover from any mistakes you make.
Edit/Cut (Ctrl+x)
Deletes the selected widgets and all of their children. These are saved to a ”clipboard” file and can be
pasted back into any FLUID window.
Edit/Copy (Ctrl+c)
Copies the selected widgets and all of their children to the ”clipboard” file.
Edit/Paste (Ctrl+c)
If the widget is a window, it is added to whatever function is selected, or contained in the current
selection.
If the widget is a normal widget, it is added to whatever window or group is selected. If none is, it is
added to the window or group that is the parent of the current selection.
To avoid confusion, it is best to select exactly one widget before doing a paste.
If they are all selected already then this selects all widgets in that group’s parent. Repeatedly typing
Ctrl+a will select larger and larger groups of widgets until everything is selected.
Edit/Open... (F1 or double click)
Displays the current widget in the attributes panel. If the widget is a window and it is not visible then
the window is shown instead.
Edit/Sort
Sorts the selected widgets into left to right, top to bottom order. You need to do this to make navigation
keys in FLTK work correctly. You may then fine-tune the sorting with ”Earlier” and ”Later”. This does
not affect the positions of windows or functions.
Edit/Earlier (F2)
Moves all of the selected widgets one earlier in order among the children of their parent (if possible).
This will affect navigation order, and if the widgets overlap it will affect how they draw, as the later
widget is drawn on top of the earlier one. You can also use this to reorder functions, classes, and
windows within functions.
Edit/Later (F3)
Moves all of the selected widgets one later in order among the children of their parent (if possible).
Edit/Group (F7)
Creates a new Fl Group and make all the currently selected widgets children of it.
Edit/Ungroup (F8)
Deletes the parent group if all the children of a group are selected.
Edit/Overlays on/off (Ctrl+Shift+O)
Toggles the display of the red overlays off, without changing the selection. This makes it easier to see
box borders and how the layout looks. The overlays will be forced back on if you change the selection.
92 CHAPTER 11. PROGRAMMING WITH FLUID
Displays the project settings panel. The output filenames control the extensions or names of the files
that are generated by FLUID. If you check the ”Include Header from Code” button the code file will
include the header file automatically.
Displays the project settings (”Preferences”) panel. This panel is used to control the user interface
settings.
New/Code/Function
Creates a new C function. You will be asked for a name for the function. This name should be a legal
C++ function template, without the return type. You can pass arguments which can be referred to by
code you type into the individual widgets.
If the function contains any unnamed windows, it will be declared as returning a Fl Window pointer.
The unnamed window will be returned from it (more than one unnamed window is useless). If the
function contains only named windows, it will be declared as returning nothing (void ).
11.6. FLUID REFERENCE 93
It is possible to make the .cxx output be a self-contained program that can be compiled and executed.
This is done by deleting the function name so main(argc,argv) is used. The function will call
show() on all the windows it creates and then call Fl::run(). This can also be used to test resize
behavior or other parts of the user interface.
Creates a new Fl Window widget. The window is added to the currently selected function, or to the
function containing the currently selected item. The window will appear, sized to 100x100. You can
resize it to whatever size you require.
The widget panel will also appear and is described later in this chapter.
New/...
All other items on the New menu are subclasses of Fl Widget. Creating them will add them to the
currently selected group or window, or the group or window containing the currently selected widget.
The initial dimensions and position are chosen by copying the current widget, if possible.
When you create the widget you will get the widget’s control panel, which is described later in this
chapter.
Layout/Align/...
Space all selected widgets evenly inside the selected space. Widgets will be sorted from first to last.
Layout/Make Same Size/...
Make all selected widgets the same size as the first selected widget.
Layout/Center in Group/...
Displays the grid settings panel. This panel controls the grid that all widgets snap to when you move
and resize them, and for the ”snap” which is how far a widget has to be dragged from its original
position to actually change.
Displays the shell command panel. The shell command is commonly used to run a ’make’ script to
compile the FLTK output.
Help/About FLUID
Help/On FLUID
Help/Manual
String to print next to or inside the button. You can put newlines into the string to make multiple lines.
The easiest way is by typing Ctrl+j.
How to draw the label. Normal, shadowed, engraved, and embossed change the appearance of the text.
Image
The active image for the widget. Click on the Browse... button to pick an image file using the file
chooser.
Inactive
96 CHAPTER 11. PROGRAMMING WITH FLUID
The inactive image for the widget. Click on the Browse... button to pick an image file using the file
chooser.
Alignment (buttons)
Where to draw the label. The arrows put it on that side of the widget, you can combine them to put it
in the corner. The ”box” button puts the label inside the widget, rather than outside.
The clip button clips the label to the widget box, the wrap button wraps any text in the label, and the
text image button puts the text over the image instead of under the image.
Position (text fields)
The position fields show the current position and size of the widget box. Enter new values to move
and/or resize a widget.
Values (text fields)
The values and limits of the current widget. Depending on the type of widget, some or all of these
fields may be inactive.
Shortcut
The shortcut key to activate the widget. Click on the shortcut button and press any key sequence to set
the shortcut.
Attributes (buttons)
The Visible button controls whether the widget is visible (on) or hidden (off) initially. Don’t change
this for windows or for the immediate children of a Tabs group.
The Active button controls whether the widget is activated (on) or deactivated (off) initially. Most
widgets appear greyed out when deactivated.
The Resizable button controls whether the window is resizeable. In addition all the size changes of
a window or group will go ”into” the resizable child. If you have a large data display surrounded by
buttons, you probably want that data area to be resizable. You can get more complex behavior by
making invisible boxes the resizable widget, or by using hierarchies of groups. Unfortunately the only
way to test it is to compile the program. Resizing the FLUID window is not the same as what will
happen in the user program.
The Hotspot button causes the parent window to be positioned with that widget centered on the mouse.
This position is determined when the FLUID function is called, so you should call it immediately
before showing the window. If you want the window to hide and then reappear at a new position, you
should have your program set the hotspot itself just before show().
11.7. GUI ATTRIBUTES 97
The Border button turns the window manager border on or off. On most window managers you will
have to close the window and reopen it to see the effect.
The string typed into here is passed to the X window manager as the class. This can change the icon or
window decorations. On most (all?) window managers you will have to close the window and reopen
it to see the effect.
Font to draw the label in. Ignored by symbols, bitmaps, and pixmaps. Your program can change the
actual font used by these ”slots” in case you want some font other than the 16 provided.
Pixel size (height) for the font to draw the label in. Ignored by symbols, bitmaps, and pixmaps. To see
the result without dismissing the panel, type the new number and then Tab.
98 CHAPTER 11. PROGRAMMING WITH FLUID
Color to draw the label. Ignored by pixmaps (bitmaps, however, do use this color as the foreground
color).
Many widgets will work, and draw faster, with a ”frame” instead of a ”box”. A frame does not draw
the colored interior, leaving whatever was already there visible. Be careful, as FLUID may draw this
ok but the real program may leave unwanted stuff inside the widget.
If a window is filled with child widgets, you can speed up redrawing by changing the window’s box
type to ”NO BOX”. FLUID will display a checkerboard for any areas that are not colored in by boxes.
Note that this checkerboard is not drawn by the resulting program. Instead random garbage will be
displayed.
The boxtype to draw when a button is pressed or for some parts of other widgets like scrollbars and
valuators.
Color (button)
Some widgets will use this color for certain parts. FLUID does not always show the result of this: this
is the color buttons draw in when pushed down, and the color of input fields when they have the focus.
Some widgets display text, such as input fields, pull-down menus, and browsers.
11.7. GUI ATTRIBUTES 99
This is how you use your own subclasses of Fl Widget. Whatever identifier you type in here will be
the class that is instantiated.
In addition, no #include header file is put in the .h file. You must provide a #include line as the
first line of the ”Extra Code” which declares your subclass.
The class must be similar to the class you are spoofing. It does not have to be a subclass. It is sometimes
useful to change this to another FLTK class. Currently the only way to get a double-buffered window
is to change this field for the window to ”Fl Double Window” and to add
#include <FL/Fl Double Window.h>
Some classes have subtypes that modify their appearance or behavior. You pick the subtype off of this
menu.
Name (text field)
100 CHAPTER 11. PROGRAMMING WITH FLUID
Name of a variable to declare, and to store a pointer to this widget into. This variable will be of type
”<class>∗”. If the name is blank then no variable is created.
You can name several widgets with ”name[0]”, ”name[1]”, ”name[2]”, etc. This will cause FLUID to
declare an array of pointers. The array is big enough that the highest number found can be stored. All
widgets in the array must be the same type.
Public (button)
Controls whether the widget is publicly accessible. When embedding widgets in a C++ class, this
controls whether the widget is public or private in the class. Otherwise it controls whether the
widget is declared static or global (extern ).
Extra Code (text fields)
These four fields let you type in literal lines of code to dump into the .h or .cxx files.
If the text starts with a # or the word extern then FLUID thinks this is an ”include” line, and it is
written to the .h file. If the same include line occurs several times then only one copy is written.
All other lines are ”code” lines. The current widget is pointed to by the local variable o. The window
being constructed is pointed to by the local variable w. You can also access any arguments passed to
the function here, and any named widgets that are before this one.
FLUID will check for matching parenthesis, braces, and quotes, but does not do much other error
checking. Be careful here, as it may be hard to figure out what widget is producing an error in the
compiler. If you need more than four lines you probably should call a function in your own .cxx
code.
Callback (text field)
This can either be the name of a function, or a small snippet of code. If you enter anything other than
letters, numbers, and the underscore then FLUID treats it as code.
A name refers to a function in your own code. It must be declared as void name(<class>∗,void∗).
A code snippet is inserted into a static function in the .cxx output file. The function prototype is
void name(class ∗o, void ∗v) so that you can refer to the widget as o and the user -
data() as v. FLUID will check for matching parenthesis, braces, and quotes, but does not do much
other error checking. Be careful here, as it may be hard to figure out what widget is producing an error
in the compiler.
This is a value for the user data() of the widget. If blank the default value of zero is used. This
can be any piece of C code that can be cast to a void pointer.
Type (text field)
The void∗ in the callback function prototypes is replaced with this. You may want to use long for
old XForms code. Be warned that anything other than void∗ is not guaranteed to work! However on
most architectures other pointer types are ok, and long is usually ok, too.
When (pulldown menu)
When to do the callback. This can be Never, Changed, Release, or Enter Key. The value of Enter
Key is only useful for text input fields.
There are other rare but useful values for the when() field that are not in the menu. You should use
the extra code fields to put these values in.
No Change (button)
The No Change button means the callback is done on the matching event even if the data is not
changed.
(it does this using illegal X methods, so it is possible it will barf with some window managers!). Notice
that the actual window in your program may not be resizable, and if it is, the effect on child widgets may
be different.
The panel for the window (which you get by double-clicking it) is almost identical to the panel for any
other Fl Widget. There are three extra items:
FLUID runs using the default visual of your X server. This may be 8 bits, which will give you dithered
images. You may get better results in your actual program by adding the code ”Fl::visual(FL RGB)”
to your code right before the first window is displayed.
All widgets with the same image on them share the same code and source X pixmap. Thus once you
have put an image on a widget, it is nearly free to put the same image on many other widgets.
If you edit an image at the same time you are using it in FLUID, the only way to convince FLUID to
read the image file again is to remove the image from all widgets that are using it or re-load the .fl
file.
Don’t rely on how FLTK crops images that are outside the widget, as this may change in future
versions! The cropping of inside labels will probably be unchanged.
To more accurately place images, make a new ”box” widget and put the image in that as the label.
FLUID reads X bitmap files which use C source code to define a bitmap. Sometimes they are stored
with the ”.h” or ”.bm” extension rather than the standard ”.xbm” extension.
FLUID writes code to construct an Fl Bitmap image and use it to label the widget. The ’1’ bits in the
bitmap are drawn using the label color of the widget. You can change this color in the FLUID widget
attributes panel. The ’0’ bits are transparent.
The program ”bitmap” on the X distribution does an adequate job of editing bitmaps.
FLUID reads X pixmap files as used by the libxpm library. These files use C source code to define a
pixmap. The filenames usually have the ”.xpm” extension.
FLUID writes code to construct an Fl Pixmap image and use it to label the widget. The label color of
the widget is ignored, even for 2-color images that could be a bitmap. XPM files can mark a single
color as being transparent, and FLTK uses this information to generate a transparency mask for the
image.
We have not found any good editors for small iconic pictures. For pixmaps we have used XPaint and
the KDE icon editor.
BMP Files
FLUID reads Windows BMP image files which are often used in WIN32 applications for icons. F-
LUID converts BMP files into (modified) XPM format and uses a Fl BMP Image image to label the
widget. Transparency is handled the same as for XPM files. All image data is uncompressed when
written to the source file, so the code may be much bigger than the .bmp file.
GIF Files
FLUID reads GIF image files which are often used in HTML documents to make icons. FLUID
converts GIF files into (modified) XPM format and uses a Fl GIF Image image to label the widget.
Transparency is handled the same as for XPM files. All image data is uncompressed when written to
the source file, so the code may be much bigger than the .gif file. Only the first image of an animated
GIF file is used.
JPEG Files
If FLTK is compiled with JPEG support, FLUID can read JPEG image files which are often used for
digital photos. FLUID uses a Fl JPEG Image image to label the widget, and writes uncompressed
RGB or grayscale data to the source file.
If FLTK is compiled with PNG support, FLUID can read PNG image files which are often used in
HTML documents. FLUID uses a Fl PNG Image image to label the widget, and writes uncompressed
RGB or grayscale data to the source file. PNG images can provide a full alpha channel for partial
transparency, and FLTK supports this as best as possible on each platform.
The #include field controls the header file to include for I18N; by default this is <libintl.h>, the
standard I18N file for GNU gettext.
The Function: field controls the function (or macro) that will retrieve the localized message; by default
the gettext function will be called.
To use POSIX catgets for I18N, open the preferences window and choose ”POSIX catgets” from the
Use: chooser. Three new input fields will then appear to control the include file, catalog file, and set
number for retrieving the localized label strings.
The #include field controls the header file to include for I18N; by default this is <nl types.h>, the
standard I18N file for POSIX catgets.
The File: field controls the name of the catalog file variable to use when retrieving localized messages;
by default the file field is empty which forces a local (static) catalog file to be used for all of the windows
defined in your .fl file.
The Set: field controls the set number in the catalog file. The default set is 1 and rarely needs to be
changed.
Advanced FLTK
This chapter explains advanced programming and design topics that will help you to get the most out of
FLTK.
12.1 Multithreading
FLTK supports multithreaded applications using a locking mechanism based on ”pthreads”. We do not
provide a threading interface as part of the library. However a simple example how threads can be imple-
mented for all supported platforms can be found in test/threads.h and test/threads.cxx.
To use the locking mechanism, FLTK must be compiled with --enable-threads set during the
configure process. IDE-based versions of FLTK are automatically compiled with locking enabled if
possible.
In main(), call Fl::lock() before Fl::run() or Fl::wait() to start the runtime multithreading support for
your program. All callbacks and derived functions like handle() and draw() will now be properly
locked:
int main() {
Fl::lock();
/* run thread */
while (Fl::wait() > 0) {
if (Fl::thread message()) {
/* process your data */
}
}
}
You can now start as many threads as you like. From within a thread (other than the main thread) FLTK
calls must be wrapped with calls to Fl::lock() and Fl::unlock():
Fl::lock(); // avoid conflicting calls
... // your code here
Fl::unlock(); // allow other threads to access FLTK again
You can send messages from child threads to the main thread using Fl::awake(void∗ message):
void *msg; // "msg" is a pointer to your message
Fl::awake(msg); // send "msg" to main thread
A message can be anything you like. The main thread can retrieve the message by calling Fl::thread -
message(). See example above.
You can also tell the main thread to call a function for you as soon as possible by using Fl::awake(Fl -
Awake Handler cb, void∗ userdata):
void do something(void *userdata) {
// running with the main thread
}
107
108 CHAPTER 12. ADVANCED FLTK
FLTK supports multiple platforms, some of which allow only the main thread to handle system events
and open or close windows. The safe thing to do is to adhere to the following rules for threads on all
operating systems:
• Don’t show() or hide() anything that contains widgets derived from Fl Window, including di-
alogs, file choosers, subwindows or those using Fl Gl Window.
• Don’t call Fl::run(), Fl::wait(), Fl::flush() or any related methods that will handle system messages
• The make current() method may or may not work well for regular windows, but should always
work for a Fl Gl Window to allow for high speed rendering on graphics cards with multiple pipelines
This chapter explains how FLTK handles international text via Unicode and UTF-8.
Unicode support was only recently added to FLTK and is still incomplete. This chapter is Work in
Progress, reflecting the current state of Unicode support.
The Unicode Standard was originally developed by a consortium of mainly US computer manufacturers
and developers of multi-lingual software. It has now become a defacto standard for character encoding,
and is supported by most of the major computing companies in the world.
Before Unicode, many different systems, on different platforms, had been developed for encoding
characters for different languages, but no single encoding could satisfy all languages. Unicode provides
access to over 100,000 characters used in all the major languages written today, and is independent of
platform and language.
Unicode also provides higher-level concepts needed for text processing and typographic publishing
systems, such as algorithms for sorting and comparing text, composite character and text rendering, right-
to-left and bi-directional text handling.
There are currently no plans to add this extra functionality to FLTK.
ISO 10646
The International Organisation for Standardization (ISO) had also been trying to develop a single unified
character set. Although both ISO and the Unicode Consortium continue to publish their own standards,
they have agreed to coordinate their work so that specific versions of the Unicode and ISO 10646 standards
are compatible with each other.
109
110 CHAPTER 13. UNICODE AND UTF-8 SUPPORT
The international standard ISO 10646 defines the Universal Character Set (UCS) which contains the
characters required for almost all known languages. The standard also defines three different implementa-
tion levels specifying how these characters can be combined.
There are currently no plans for handling the different implementation levels or the combining charac-
ters in FLTK.
In UCS, characters have a unique numerical code and an official name, and are usually shown using
’U+’ and the code in hexadecimal, e.g. U+0041 is the ”Latin capital letter A”. The UCS characters U+0000
to U+007F correspond to US-ASCII, and U+0000 to U+00FF correspond to ISO 8859-1 (Latin1).
ISO 10646 was originally designed to handle a 31-bit character set from U+00000000 to U+7FFFFFFF,
but the current idea is that 21-bits will be sufficient for all future needs, giving characters up to U+10FFFF.
The complete character set is sub-divided into planes. Plane 0, also known as the Basic Multilingual
Plane (BMP), ranges from U+0000 to U+FFFD and consists of the most commonly used characters from
previous encoding standards. Other planes contain characters for specialist applications.
Todo Do we need this info about planes?
The UCS also defines various methods of encoding characters as a sequence of bytes. UCS-2 encodes
Unicode characters into two bytes, which is wasteful if you are only dealing with ASCII or Latin1 text, and
insufficient if you need characters above U+00FFFF. UCS-4 uses four bytes, which lets it handle higher
characters, but this is even more wasteful for ASCII or Latin1.
UTF-8
The Unicode standard defines various UCS Transformation Formats. UTF-16 and UTF-32 are based on
units of two and four bytes. UCS characters requiring more than 16 bits are encoded using ”surrogate
pairs” in UTF-16.
UTF-8 encodes all Unicode characters into variable length sequences of bytes. Unicode characters in
the 7-bit ASCII range map to the same value and are represented as a single byte, making the transformation
to Unicode quick and easy.
All UCS characters above U+007F are encoded as a sequence of several bytes. The top bits of the first
byte are set to show the length of the byte sequence, and subseqent bytes are always in the range 0x80 to
0x8F. This combination provides some level of synchronisation and error detection.
Unicode range Byte sequences
U+00000000 - U+0000007F 0xxxxxxx
U+00000080 - U+000007FF 110xxxxx 10xxxxxx
U+00000800 - U+0000FFFF 1110xxxx 10xxxxxx 10xxxxxx
U+00010000 - U+001FFFFF 11110xxx 10xxxxxx 10xxxxxx
10xxxxxx
U+00200000 - U+03FFFFFF 111110xx 10xxxxxx 10xxxxxx
10xxxxxx 10xxxxxx
U+04000000 - U+7FFFFFFF 1111110x 10xxxxxx 10xxxxxx
10xxxxxx 10xxxxxx 10xxxxxx
Moving from ASCII encoding to Unicode will allow all new FLTK applications to be easily interna-
tionalized and used all over the world. By choosing UTF-8 encoding, FLTK remains largely source-code
compatible to previous iterations of the library.
FLTK will be entirely converted to Unicode using UTF-8 encoding. If a different encoding is required
by the underlying operating system, FLTK will convert the string as needed.
It is important to note that the initial implementation of Unicode and UTF-8 in FLTK involves three
important areas:
13.3. ILLEGAL UNICODE AND UTF-8 SEQUENCES 111
The current implementation of Unicode / UTF-8 in FLTK will impose the following limitations:
• An implementation note in the [OksiD] code says that all functions are LIMITED to 24 bit Unicode
values, but also says that only 16 bits are really used under linux and win32. [Can we verify this?]
• The [fltk2] fl utf8encode() and fl utf8decode() functions are designed to handle Unicode characters
in the range U+000000 to U+10FFFF inclusive, which covers all UTF-16 characters, as specified in
RFC 3629. Note that the user must first convert UTF-16 surrogate pairs to UCS.
• FLTK will only handle single characters, so composed characters consisting of a base character and
floating accent characters will be treated as multiple characters;
• FLTK will only compare or sort strings on a byte by byte basis and not on a general Unicode character
basis;
• FLTK will not handle right-to-left or bi-directional text;
Todo Verify 16/24 bit Unicode limit for different character sets? OksiD’s code appears limited to 16-
bit whereas the FLTK2 code appears to handle a wider set. What about illegal characters? See
comments in fl utf8fromwc() and fl utf8toUtf16().
• if ERRORS TO CP1252 is set to 1 (the default), fl utf8decode() will assume that a byte sequence
starting with a byte in the range 0x80 to 0x9f represents a Microsoft CP1252 character, and will
instead return the value of an equivalent UCS character. Otherwise, it will be processed as an illegal
byte value as described below.
• if STRICT RFC3629 is set to 1 (not the default!) then UTF-8 sequences that correspond to illegal U-
CS values are treated as errors. Illegal UCS values include those above U+10FFFF, or corresponding
to UTF-16 surrogate pairs. Illegal byte values are handled as described below.
• if ERRORS TO ISO8859 1 is set to 1 (the default), the illegal byte value is returned unchanged,
otherwise 0xFFFD, the Unicode REPLACEMENT CHARACTER, is returned instead.
fl utf8encode() is less strict, and only generates the UTF-8 sequence for 0xFFFD, the Unicode REPL-
ACEMENT CHARACTER, if it is asked to encode a UCS value above U+10FFFF.
Many of the [fltk2] functions below use fl utf8decode() and fl utf8encode() in their own implementa-
tion, and are therefore somewhat protected from bad UTF-8 sequences.
The [OksiD] fl utf8len() function assumes that the byte it is passed is the first byte in a UTF-8 sequence,
and returns the length of the sequence. Trailing bytes in a UTF-8 sequence will return -1.
• WARNING: fl utf8len() can not distinguish between single bytes representing Microsoft CP1252
characters 0x80-0x9f and those forming part of a valid UTF-8 sequence. You are strongly advised
not to use fl utf8len() in your own code unless you know that the byte sequence contains only valid
UTF-8 sequences.
112 CHAPTER 13. UNICODE AND UTF-8 SUPPORT
• WARNING: Some of the [OksiD] functions below still use fl utf8len() in their implementations.
These may need further validation.
Please see the individual function description for further details about error handling and return values.
fl utf8locale() returns true if the ”locale” seems to indicate that UTF-8 encoding is used.
It is highly recommended that you change your system so this does return true!
fl utf8test() examines the first len bytes of src. It returns 0 if there are any illegal UTF-8
sequences; 1 if src contains plain ASCII or if len is zero; or 2, 3 or 4 to indicate the range of
Unicode characters found.
Returns the number of UTF-8 characters in the first len bytes of buf.
If c is a valid first byte of a UTF-8 encoded character sequence, fl utf8len() will return the number
of bytes in that sequence. It returns -1 if c is not a valid first byte.
const char∗ fl utf8back(const char ∗p, const char ∗start, const char ∗end) FLTK2
const char∗ fl utf8fwd(const char ∗p, const char ∗start, const char ∗end) FLTK2
If p already points to the start of a UTF-8 character sequence, these functions will return p. Otherwise
fl utf8back() searches backwards from p and fl utf8fwd() searches forwards from p, within
the start and end limits, looking for the start of a UTF-8 character.
unsigned int fl utf8decode(const char ∗p, const char ∗end, int ∗len) FLTK2
int fl utf8encode(unsigned ucs, char ∗buf) FLTK2
13.4. FLTK UNICODE AND UTF-8 FUNCTIONS 113
fl utf8decode() attempts to decode the UTF-8 character that starts at p and may not extend past
end. It returns the Unicode value, and the length of the UTF-8 character sequence is returned via
the len argument. fl utf8encode() writes the UTF-8 encoding of ucs into buf and returns the
number of bytes in the sequence. See the main documentation for the treatment of illegal Unicode and
UTF-8 sequences.
unsigned int fl utf8froma(char ∗dst, unsigned dstlen, const char ∗src, unsigned srclen) FLTK2
unsigned int fl utf8toa(const char ∗src, unsigned srclen, char ∗dst, unsigned dstlen) FLTK2
fl utf8froma() converts a character string containing single bytes per character (i.e. ASCII or IS-
O-8859-1) into UTF-8. If the src string contains only ASCII characters, the return value will be the
same as srclen.
fl utf8toa() converts a string containing UTF-8 characters into single byte characters. UTF-8
characters that do not correspond to ASCII or ISO-8859-1 characters below 0xFF are replaced with
’?’.
Both functions return the number of bytes that would be written, not counting the null terminator.
destlen provides a means of limiting the number of bytes written, so setting destlen to zero is a
means of measuring how much storage would be needed before doing the real conversion.
converts a UTF-8 string to a local multi-byte character string. [More info required here!]
unsigned int fl utf8fromwc(char ∗dst, unsigned dstlen, const wchar t ∗src, unsigned srclen) FLTK2
unsigned int fl utf8towc(const char ∗src, unsigned srclen, wchar t ∗dst, unsigned dstlen) FLTK2
unsigned int fl utf8toUtf16(const char ∗src, unsigned srclen, unsigned short ∗dst, unsigned dstlen) FL-
TK2
These routines convert between UTF-8 and wchar t or ”wide character” strings. The difficulty lies
in the fact that sizeof(wchar t) is 2 on Windows and 4 on Linux and most other systems. There-
fore some ”wide characters” on Windows may be represented as ”surrogate pairs” of more than one
wchar t.
fl utf8fromwc() converts from a ”wide character” string to UTF-8. Note that srclen is the
number of wchar t elements in the source string and on Windows this might be larger than the
number of characters. dstlen specifies the maximum number of bytes to copy, including the null
terminator.
fl utf8towc() converts a UTF-8 string into a ”wide character” string. Note that on Windows, some
”wide characters” might result in ”surrogate pairs” and therefore the return value might be more than
the number of characters. dstlen specifies the maximum number of wchar t elements to copy,
including a zero terminating element. [Is this all worded correctly?]
fl utf8toUtf16() converts a UTF-8 string into a ”wide character” string using UTF-16 encoding
to handle the ”surrogate pairs” on Windows. dstlen specifies the maximum number of wchar t
elements to copy, including a zero terminating element. [Is this all worded correctly?]
114 CHAPTER 13. UNICODE AND UTF-8 SUPPORT
These routines all return the number of elements that would be required for a full conversion of the
src string, including the zero terminator. Therefore setting dstlen to zero is a way of measuring
how much storage would be needed before doing the real conversion.
unsigned int fl utf8from mb(char ∗dst, unsigned dstlen, const char ∗src, unsigned srclen) FLTK2
unsigned int fl utf8to mb(const char ∗src, unsigned srclen, char ∗dst, unsigned dstlen) FLTK2
These functions convert between UTF-8 and the locale-specific multi-byte encodings used on some
systems for filenames, etc. If fl utf8locale() returns true, these functions don’t do anything useful. [Is
this all worded correctly?]
fl tolower() and fl toupper() convert a single Unicode character from upper to lower case, and
vice versa. fl utf tolower() and fl utf toupper() convert a string of bytes, some of which
may be multi-byte UTF-8 encodings of Unicode characters, from upper to lower case, and vice versa.
Warning: to be safe, buf length must be at least 3∗len [for 16-bit Unicode]
fl utf strcasecmp() is a UTF-8 aware string comparison function that converts the strings to
lower case Unicode as part of the comparison. flt utf strncasecmp() only compares the first n
characters [bytes?]
FLTK Enumerations
Note
This file is not actively maintained any more, but is left here as a reference, until the doxygen docu-
mentation is completed.
See Also
FL/Enumerations.H.
This appendix lists the enumerations provided in the <FL/Enumerations.H> header file, organized by
section. Constants whose value are zero are marked with ”(0)”, this is often useful to know when program-
ming.
• FL VERSION - A combined floating-point version number for the major, minor, and patch release
numbers, currently 1.0303
14.2 Events
Events are identified by an Fl Event enumeration value. The following events are currently defined:
• FL NO EVENT - No event (or an event fltk does not understand) occurred (0).
117
118 CHAPTER 14. FLTK ENUMERATIONS
• FL SELECTIONCLEAR - The widget should clear any selections made for the clipboard.
• FL DND LEAVE - The mouse pointer left a widget still dragging data.
• FL WHEN CHANGED - Do the callback only when the widget value changes.
• FL WHEN NOT CHANGED - Do the callback whenever the user interacts with the widget.
• FL WHEN RELEASE - Do the callback when the button or key is released and the value changes.
• FL WHEN ENTER KEY - Do the callback when the user presses the ENTER key and the value
changes.
• FL WHEN RELEASE ALWAYS - Do the callback when the button or key is released, even if the
value doesn’t change.
• FL WHEN ENTER KEY ALWAYS - Do the callback when the user presses the ENTER key, even
if the value doesn’t change.
14.4. FL::EVENT BUTTON() VALUES 119
• FL ALIGN TOP LEFT - The label appears at the top of the widget, aligned to the left.
• FL ALIGN TOP RIGHT - The label appears at the top of the widget, aligned to the right.
• FL ALIGN BOTTOM LEFT - The label appears at the bottom of the widget, aligned to the left.
• FL ALIGN BOTTOM RIGHT - The label appears at the bottom of the widget, aligned to the right.
• FL ALIGN LEFT TOP - The label appears to the left of the widget, aligned at the top. Outside
labels only.
• FL ALIGN RIGHT TOP - The label appears to the right of the widget, aligned at the top. Outside
labels only.
• FL ALIGN LEFT BOTTOM - The label appears to the left of the widget, aligned at the bottom.
Outside labels only.
• FL ALIGN RIGHT BOTTOM - The label appears to the right of the widget, aligned at the bottom.
Outside labels only.
• FL ALIGN INSIDE - ’or’ this with other values to put label inside the widget.
• FL ALIGN TEXT OVER IMAGE - Label text will appear above the image.
• FL ALIGN IMAGE OVER TEXT - Label text will be below the image.
• FL ALIGN IMAGE NEXT TO TEXT - The image will appear to the left of the text.
• FL ALIGN TEXT NEXT TO IMAGE - The image will appear to the right of the text.
• FL ALIGN IMAGE BACKDROP - The image will be used as a background for the widget.
14.8 Fonts
The following constants define the standard FLTK fonts:
14.9 Colors
The Fl Color enumeration type holds a FLTK color value. Colors are either 8-bit indexes into a virtual
colormap or 24-bit RGB color values. Color indices occupy the lower 8 bits of the value, while RGB
colors occupy the upper 24 bits, for a byte organization of RGBI.
• FL BACKGROUND2 COLOR - the default background color for text, list, and valuator widgets
• FL FOREGROUND COLOR - the default foreground color (0) used for labels and text
The following color constants can be used to access the colors from the FLTK standard color cube:
• FL BLACK
• FL BLUE
• FL CYAN
• FL DARK BLUE
• FL DARK CYAN
• FL DARK GREEN
• FL DARK MAGENTA
• FL DARK RED
• FL DARK YELLOW
• FL GREEN
• FL MAGENTA
• FL RED
• FL WHITE
14.10. CURSORS 123
• FL YELLOW
• FL GRAY0
• FL DARK3
• FL DARK2
• FL DARK1
• FL LIGHT1
• FL LIGHT2
• FL LIGHT3
The inline methods for getting a grayscale, color cube, or RGB color value are described in the Colors
section of the Drawing Things in FLTK chapter.
14.10 Cursors
The following constants define the mouse cursors that are available in FLTK. The double-headed arrows
are bitmaps provided by FLTK on X, the others are provided by system-defined cursors.
• FL WRITE - Call the callback when data can be written without blocking.
GLUT Compatibility
This appendix describes the GLUT compatibility header file supplied with FLTK.
FLTK’s GLUT compatibility is based on the original GLUT 3.7 and the follow-on FreeGLUT 2.4.0
libraries.
• glutInitDisplayMode(GLUT LUMINANCE)
• glutPushWindow()
125
126 CHAPTER 15. GLUT COMPATIBILITY
• glutVideoResize() missing.
• glutWarpPointer()
• glutWindowStatusFunc()
• Spaceball, buttonbox, dials, and tablet functions
Most of the symbols/enumerations have different values than GLUT uses. This will break code that relies
on the actual values. The only symbols guaranteed to have the same values are true/false pairs like GLUT-
DOWN and GLUT UP, mouse buttons GLUT LEFT BUTTON, GLUT MIDDLE BUTTON, GLUT R-
IGHT BUTTON, and GLUT KEY F1 thru GLUT KEY F12.
The strings passed as menu labels are not copied.
glutPostRedisplay() does not work if called from inside a display function. You must use
glutIdleFunc() if you want your display to update continuously.
glutSwapBuffers() does not work from inside a display function. This is on purpose, because
FLTK swaps the buffers for you.
glutUseLayer() does not work well, and should only be used to initialize transformations inside a
resize callback. You should redraw overlays by using glutOverlayDisplayFunc().
Overlays are cleared before the overlay display function is called. glutLayerGet(GLUT OVERLA-
Y DAMAGED) always returns true for compatibility with some GLUT overlay programs. You must rewrite
your code so that gl color() is used to choose colors in an overlay, or you will get random overlay
colors.
glutSetCursor(GLUT CURSOR FULL CROSSHAIR) just results in a small crosshair.
The fonts used by glutBitmapCharacter() and glutBitmapWidth() may be different.
glutInit(argc,argv) will consume different switches than GLUT does. It accepts the switches
recognized by Fl::args(), and will accept any abbreviation of these switches (such as ”-di” for ”-display”).
15.4.3 Description
Each GLUT window is an instance of this class. You may find it useful to manipulate instances directly
rather than use GLUT window id’s. These may be created without opening the display, and thus can fit
better into FLTK’s method of creating windows.
The current GLUT window is available in the global variable glut window.
new Fl Glut Window(...) is the same as glutCreateWindow() except it does not show()
the window or make the window current.
window->make current() is the same as glutSetWindow(number). If the window has not
had show() called on it yet, some functions that assume an OpenGL context will not work. If you do
show() the window, call make current() again to set the context.
∼Fl Glut Window() is the same as glutDestroyWindow().
15.4.4 Members
The Fl Glut Window class contains several public members that can be altered directly:
member description
display A pointer to the function to call to draw the
normal planes.
entry A pointer to the function to call when the mouse
moves into or out of the window.
keyboard A pointer to the function to call when a regular
key is pressed.
menu[3] The menu to post when one of the mouse buttons
is pressed.
mouse A pointer to the function to call when a button is
pressed or released.
motion A pointer to the function to call when the mouse
is moved with a button down.
overlaydisplay A pointer to the function to call to draw the
overlay planes.
passivemotion A pointer to the function to call when the mouse
is moved with no buttons down.
reshape A pointer to the function to call when the window
is resized.
special A pointer to the function to call when a special
key is pressed.
visibility A pointer to the function to call when the window
is iconified or restored (made visible.)
15.4.5 Methods
Fl Glut Window::Fl Glut Window(int x, int y, int w, int h, const char ∗title = 0)
Fl Glut Window::Fl Glut Window(int w, int h, const char ∗title = 0)
The first constructor takes 4 int arguments to create the window with a preset position and size. The
second constructor with 2 arguments will create the window with a preset size, but the window manager
will choose the position according to its own whims.
Forms Compatibility
Warning: The Forms compatility is deprecated and no longer maintained in FLTK1, and is
likely to be removed completely after the next official release.
129
130 CHAPTER 16. FORMS COMPATIBILITY
Fl Free widgets emulate the old Forms ”free” widget. It may be useful for porting programs that change
the handle() function on widgets, but you will still need to rewrite things.
Fl Timer widgets are provided to emulate the XForms timer. These work, but are quite inefficient and
inaccurate compared to using Fl::add timeout().
All instance variables are hidden. If you directly refer to the x, y, w, h, label, or other fields of your
Forms widgets you will have to add empty parenthesis after each reference. The easiest way to do this is
to globally replace "->x" with "->x()", etc. Replace "boxtype" with "box()".
const char ∗ arguments to most FLTK methods are simply stored, while Forms would strdup()
the passed string. This is most noticeable with the label of widgets. Your program must always pass static
data such as a string constant or malloc’d buffer to label(). If you are using labels to display program
output you may want to try the Fl Output widget.
The default fonts and sizes are matched to the older GL version of Forms, so all labels will draw
somewhat larger than an XForms program does.
fdesign outputs a setting of a ”fdui” instance variable to the main window. I did not emulate this because
I wanted all instance variables to be hidden. You can store the same information in the user data()
field of a window. To do this, search through the fdesign output for all occurrences of "->fdui" and edit
to use "->user data()" instead. This will require casts and is not trivial.
The prototype for the functions passed to fl add timeout() and fl set idle callback()
callback are different.
All the following XForms calls are missing:
• fl ringbell()
• fl gettime()
• FL CANVAS objects
• fl show oneliner()
• command log
• FL DATE INPUT
• xyplot object
The IRISGL library always forked when you created the first window, unless ”foreground()” was called.
FLTK acts like ”foreground()” is called all the time. If you really want the fork behavior do ”if (fork())
exit(0)” right at the start of your program.
If a Forms (not XForms) program if you wanted your own window for displaying things you would create
a IRISGL window and draw in it, periodically calling Forms to check if the user hit buttons on the panels.
If the user did things to the IRISGL window, you would find this out by having the value FL EVENT
returned from the call to Forms.
None of this works with FLTK. Nor will it compile, the necessary calls are not in the interface.
You have to make a subclass of Fl Gl Window and write a draw() method and handle() method.
This may require anywhere from a trivial to a major rewrite.
If you draw into the overlay planes you will have to also write a draw overlay() method and call
redraw overlay() on the OpenGL window.
One easy way to hack your program so it works is to make the draw() and handle() methods
on your window set some static variables, storing what event happened. Then in the main loop of your
program, call Fl::wait() and then check these variables, acting on them as though they are events read from
fl queue.
The file <FL/gl.h> defines replacements for a lot of IRISGL calls, translating them to OpenGL. There are
much better translators available that you might want to investigate.
Programs that call fl make object or directly setting the handle routine will not compile. You have
to rewrite them to use a subclass of Fl Widget. It is important to note that the handle() method is not
exactly the same as the handle() function of Forms. Where a Forms handle() returned non-zero, your
handle() must call do callback(). And your handle() must return non-zero if it ”understood”
the event.
An attempt has been made to emulate the ”free” widget. This appears to work quite well. It may be
quicker to modify your subclass into a ”free” widget, since the ”handle” functions match.
If your subclass draws into the overlay you are in trouble and will have to rewrite things a lot.
If you have written your own ”free” widgets you will probably get a lot of errors about ”getvaluator”. You
should substitute:
Forms FLTK
MOUSE X Fl::event x root()
MOUSE Y Fl::event y root()
LEFTSHIFTKEY,RIGHTSHIFTKEY Fl::event shift()
CAPSLOCKKEY Fl::event capslock()
LEFTCTRLKEY,RIGHTCTRLKEY Fl::event ctrl()
LEFTALTKEY,RIGHTALTKEY Fl::event alt()
MOUSE1,RIGHTMOUSE Fl::event state()
MOUSE2,MIDDLEMOUSE Fl::event state()
MOUSE3,LEFTMOUSE Fl::event state()
The ”style” numbers have been changed because I wanted to insert bold-italic versions of the normal fonts.
If you use Times, Courier, or Bookman to display any text you will get a different font out of FLTK. If you
are really desperate to fix this use the following code:
fl font name(3,"*courier-medium-r-no*");
fl font name(4,"*courier-bold-r-no*");
fl font name(5,"*courier-medium-o-no*");
fl font name(6,"*times-medium-r-no*");
fl font name(7,"*times-bold-r-no*");
fl font name(8,"*times-medium-i-no*");
fl font name(9,"*bookman-light-r-no*");
fl font name(10,"*bookman-demi-r-no*");
fl font name(11,"*bookman-light-i-no*");
134 CHAPTER 16. FORMS COMPATIBILITY
Chapter 17
Despite the name, this header file will define the appropriate interface for your environment. The pages
that follow describe the functionality that is provided for each operating system.
WARNING:
The interfaces provided by this header file may change radically in new FLTK releases. Use them only
when an existing generic FLTK interface is not sufficient.
Installs 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.
FLTK calls this for any X events it does not recognize, or X events with a window ID that FLTK does
not recognize. You can look at the X event in the fl xevent variable.
135
136 CHAPTER 17. OPERATING SYSTEM ISSUES
The argument is the FLTK event type that was not handled, or zero for unrecognized X events. These
handlers are also called for global shortcuts and some other events that the widget they were passed to
did not handle, for example FL SHORTCUT.
This variable contains the time stamp from the most recent X event that reported it; not all events do.
Many X calls like cut and paste need this value.
Returns the Fl Window that corresponds to the given XID, or NULL if not found. This function uses a
cache so it is slightly faster than iterating through the windows yourself.
This call allows you to supply the X events to FLTK, which may allow FLTK to cooperate with another
toolkit or library. The return value is non-zero if FLTK understood the event. If the window does not
belong to FLTK and the add handler() functions all return 0, this function will return false.
Besides feeding events your code should call Fl::flush() periodically so that FLTK redraws its win-
dows.
This function will call the callback functions. It will not return until they complete. In particular, if
a callback pops up a modal window by calling fl ask(), for instance, it will not return until the modal
function returns.
You must use them to produce Xlib calls. Don’t attempt to change them. A typical X drawing call is
written like this:
XDrawSomething(fl display, fl window, fl gc, ...);
Other information such as the position or size of the X window can be found by looking at Fl Window-
::current(), which returns a pointer to the Fl Window being drawn.
unsigned long fl xpixel(Fl Color i)
unsigned long fl xpixel(uchar r, uchar g, uchar b)
17.2. THE UNIX (X11) INTERFACE 137
Returns the X pixel number used to draw the given FLTK color index or RGB color. This is the X
pixel that fl color() would use.
Convert a name into the red, green, and blue values of a color by parsing the X11 color names. On
other systems, fl parse color() can only convert names in hexadecimal encoding, for example
#ff8083.
Points to the font selected by the most recent fl font(). This is not necessarily the current font of fl -
gc, which is not set until fl draw() is called. If FLTK was compiled with Xft support, fl xfont will
usually be 0 and fl xftfont will contain a pointer to the XftFont structure instead.
If FLTK was compiled with Xft support enabled, fl xftfont points to the xft font selected by the
most recent fl font(). Otherwise it will be 0. fl xftfont should be cast to XftFont∗.
Set which X display to use. This actually does putenv("DISPLAY=...") so that child programs
will display on the same screen if called with exec(). This must be done before the display is opened.
This call is provided under MacOS and WIN32 but it has no effect.
The open X display. This is needed as an argument to most Xlib calls. Don’t attempt to change it!
This is NULL before the display is opened.
Opens the display. Does nothing if it is already open. This will make sure fl display is non-zero.
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 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.
138 CHAPTER 17. OPERATING SYSTEM ISSUES
Which screen number to use. This is set by fl open display() to the default screen. You can
change it by setting this to a different value immediately afterwards. It can also be set by changing the
last number in the Fl::display() string to ”host:0.#”.
The visual and colormap that FLTK will use for all windows. These are set by fl open display()
to the default visual and colormap. You can change them before calling show() on the first window.
Typical code for changing the default visual is:
Fl::args(argc, argv); // do this first so $DISPLAY is set
fl open display();
fl visual = find a good visual(fl display, fl screen);
if (!fl visual) Fl::abort("No good visual");
fl colormap = make a colormap(fl display, fl visual->visual, fl visual->depth);
// it is now ok to show() windows:
window->show(argc, argv);
If the window is already shown() this must cause it to be raised, this can usually be done by calling
Fl Window::show(). If not shown() your implementation must call either Fl X::set xid() or Fl X-
::make xid().
An example:
void MyWindow::show() {
if (shown()) {Fl Window::show(); return;} // you must do this!
fl open display(); // necessary if this is first window
// we only calculate the necessary visual colormap once:
static XVisualInfo *visual;
static Colormap colormap;
if (!visual) {
visual = figure out visual();
colormap = XCreateColormap(fl display, RootWindow(fl display,fl screen),
vis->visual, AllocNone);
}
Fl X::make xid(this, visual, colormap);
}
Allocate a hidden class called an Fl X, put the XID into it, and set a pointer to it from the Fl Window.
This causes Fl Window::shown() to return true.
This static method does the most onerous parts of creating an X window, including setting the label,
resize limitations, etc. It then does Fl X::set xid() with this new window and maps the window.
17.2. THE UNIX (X11) INTERFACE 139
This virtual function is called by Fl::flush() to update the window. For FLTK’s own windows it does
this by setting the global variables fl window and fl gc and then calling the draw() method. For
your own windows you might just want to put all the drawing code in here.
The X region that is a combination of all damage() calls done so far is in Fl X::i(this)->region.
If NULL then you should redraw the entire window. The undocumented function fl clip region(-
XRegion) will initialize the FLTK clip stack with a region or NULL for no clipping. You must set
region to NULL afterwards as fl clip region() will own and delete it when done.
If damage() & FL DAMAGE EXPOSE then only X expose events have happened. This may be
useful if you have an undamaged image (such as a backing buffer) around.
Destroy the window server copy of the window. Usually you will destroy contexts, pixmaps, or other
resources used by the window, and then call Fl Window::hide() to get rid of the main window identified
by xid(). If you override this, you must also override the destructor as shown:
void MyWindow::hide() {
if (mypixmap) {
XFreePixmap(fl display,mypixmap);
mypixmap = 0;
}
Fl Window::hide(); // you must call this
}
Because of the way C++ works, if you override hide() you must override the destructor as well
(otherwise only the base class hide() is called):
MyWindow::˜MyWindow() {
hide();
}
Note
Access to the Fl X hidden class requires to #define FL INTERNALS before compilation.
Sets the icon for the window to the passed pointer. You will need to cast the icon Pixmap to a char∗
when calling this method. To set a monochrome icon using a bitmap compiled with your application
use:
140 CHAPTER 17. OPERATING SYSTEM ISSUES
#include "icon.xbm"
window->icon((const void*)p);
To use a multi-colored icon, the XPM format and library should be used as follows:
#include <X11/xpm.h>
#include "icon.xpm"
Pixmap p, mask;
When using the Xpm library, be sure to include it in the list of libraries that are used to link the
application (usually ”-lXpm”).
NOTE:
You must call Fl Window::show(int argc, char∗∗ argv) for the icon to be used. The Fl Window::show()
method does not bind the icon to the window.
17.2.6 X Resources
When the Fl Window::show(int argc, char∗∗ argv) method is called, FLTK looks for the following X
resources:
• dndTextOps - The default setting for drag and drop text operations (boolean).
• visibleFocus - The default setting for visible keyboard focus on non-text widgets (boolean).
Resources associated with the first window’s Fl Window::xclass() string are queried first, or if no class has
been specified then the class ”fltk” is used (e.g. fltk.background). If no match is found, a global
search is done (e.g. ∗background).
This variable contains the most recent message read by GetMessage(), which is called by Fl-
::wait(). This may not be the most recent message sent to an FLTK window, because silly WIN32 calls
the handle procedures directly for some events (sigh).
Installs a function to parse unrecognized messages sent to FLTK windows. If FLTK cannot figure out
what to do with a message, it calls each of these functions (most recent first) until one of them returns
non-zero. The argument passed to the functions is the FLTK event that was not handled or zero for
unknown messages. If all the handlers return zero then FLTK calls DefWindowProc().
Returns the Fl Window that corresponds to the given window handle, or NULL if not found. This
function uses a cache so it is slightly faster than iterating through the windows yourself.
These global variables are set before Fl Widget::draw() is called, or by Fl Window::make current().
You can refer to them when needed to produce GDI calls, but don’t attempt to change them. The functions
return GDI objects for the current color set by fl color() and are created as needed and cached. A typical
GDI drawing call is written like this:
DrawSomething(fl gc, ..., fl brush());
It may also be useful to refer to Fl Window::current() to get the window’s size or position.
Sets the icon for the window to the passed pointer. You will need to cast the HICON handle to a char∗
when calling this method. To set the icon using an icon resource compiled with your application use:
window->icon((const void *)LoadIcon(fl display, MAKEINTRESOURCE(IDI ICON)));
You can also use the LoadImage() and related functions to load specific resolutions or create the
icon from bitmap data.
NOTE:
You must call Fl Window::show(int argc, char∗∗ argv) for the icon to be used. The Fl Window::show()
method does not bind the icon to the window.
• If a program is deactivated, Fl::wait() does not return until it is activated again, even though
many events are delivered to the program. This can cause idle background processes to stop unex-
pectedly. This also happens while the user is dragging or resizing windows or otherwise holding the
mouse down. We were forced to remove most of the efficiency FLTK uses for redrawing in order to
get windows to update while being moved. This is a design error in WIN32 and probably impossible
to get around.
• Fl Gl Window::can do overlay() returns true until the first time it attempts to draw an over-
lay, and then correctly returns whether or not there is overlay hardware.
• SetCapture (used by Fl::grab()) doesn’t work, and the main window title bar turns gray
while menus are popped up.
17.4. THE APPLE OS X INTERFACE 143
• Compilation with gcc 3.4.4 and -Os exposes an optimisation bug in gcc. The symptom is that
when drawing filled circles only the perimeter is drawn. This can for instance be seen in the symbols
demo. Other optimisation options such as -O2 and -O3 seem to work OK. More details can be found
in STR#1656
FLTK maps the Mac ’control’ key to FL CTRL, the ’option’ key to FL ALT and the ’Apple’ key to
FL META. Furthermore, FL COMMAND designates the ’Apple’ key on Mac OS X and the ’control’
key on other platforms. Keyboard events return the key name in Fl::event key() and the keystroke
translation in Fl::event text(). For example, typing Option-Y on a Mac US keyboard will set FL ALT
in Fl::event state(), set Fl::event key() to ’y’ and return the Yen symbol in Fl::event text().
Apple ”Quit” Event
When the user presses Cmd-Q or requests a termination of the application, OS X will send a ”Quit”
Apple Event. FLTK handles this event by sending an FL CLOSE event to all open windows. If all
windows close, the application will terminate.
Apple ”Open” Event
Whenever the user drops a file onto an application icon, OS X generates an Apple Event of the type
”Open”. You can have FLTK notify you of an Open event by calling the fl open callback function.
void fl open display()
Opens the display. Does nothing if it is already open. You should call this if you wish to do Cocoa or
Quartz calls and there is a chance that your code will be called before the first show() of a window.
Window fl xid(const Fl Window ∗)
Returns the window reference for an Fl Window, or NULL if the window has not been shown. This
reference is a pointer to an instance of the subclass FLWindow of Cocoa’s NSWindow class.
Fl Window ∗fl find(Window xid)
Returns the Fl Window that corresponds to the given window reference, or NULL if not found. FLTK
windows that are children of top-level windows share the Window of the top-level window.
void fl mac set about( Fl Callback ∗cb, void ∗user data, int shortcut)
Attaches the callback cb to the ”About myprog” item of the system application menu. cb will be
called with NULL first argument and user data second argument.
Fl Sys Menu Bar class
The Fl Sys Menu Bar class allows to build menu bars that, on Mac OS X, are placed in the system
menu bar (at top-left of display), and, on other platforms, at a user-chosen location of a user-chosen
window.
144 CHAPTER 17. OPERATING SYSTEM ISSUES
<key>CFBundleIconFile</key>
<string>foo.icns</string>
replacing foo by your application name. If you use Xcode, just add your .icns file to your application
target.
17.4.3 Internationalization
All FLTK programs contain an application menu with, e.g., the About xxx, Hide xxx, and Quit xxx items.
This menu can be internationalized/localized by any of two means.
• using the Fl Mac App Menu class.
• using the standard Mac OS X localization procedure. Create a language-specific .lproj directory
(e.g., German.lproj) in the Resources subdirectory of the application bundle. Create therein
a Localizable.strings file that translates all menu items to this language. The German
Localizable.strings file, for example, contains:
Set "Print Front Window" = ""; therein so the application menu doesn’t show a ”Print
Front Window” item. To localize the application name itself, create a file InfoPlist.strings
in each .lproj directory and put CFBundleName = "localized name"; in each such file.
Fl Double Window
OS X double-buffers all windows automatically. On OS X, Fl Window and Fl Double Window are
handled internally in the same way.
FLTK does not access the resource fork of an application. However, a minimal resource fork must be
created for OS X applications. Starting with OS X 10.6, resource forks are no longer needed.
17.4. THE APPLE OS X INTERFACE 145
It is advisable to use the Finder for moving and copying and Mac archiving tools like Sit for distribution
as they will handle the Resource Fork correctly.
Mac File Paths
This appendix describes the differences between the FLTK 1.0.x and FLTK 1.1.x functions and classes.
The following table shows the old and new function names:
147
148 CHAPTER 18. MIGRATING CODE FROM FLTK 1.0 TO 1.1
This appendix describes the differences between the FLTK 1.1.x and FLTK 1.3.x functions and classes.
149
150 CHAPTER 19. MIGRATING CODE FROM FLTK 1.1 TO 1.3
Chapter 20
Developer Information
Example
/** \file
Fl_Clock, Fl_Clock_Output widgets. */
/**
\class Fl_Clock_Output
\brief This widget can be used to display a program-supplied time.
The time shown on the clock is not updated. To display the current time,
use Fl_Clock instead.
/**
Returns the displayed time.
Returns the time in seconds since the UNIX epoch (January 1, 1970).
\see value(ulong)
*/
ulong value() const {return value_;}
/**
Set the displayed time.
Set the time in seconds since the UNIX epoch (January 1, 1970).
\param[in] v seconds since epoch
\see value()
*/
void Fl_Clock_Output::value(ulong v) {
[...]
}
/**
Create an Fl_Clock widget using the given position, size, and label string.
The default boxtype is \c FL_NO_BOX.
\param[in] X, Y, W, H position and size of the widget
\param[in] L widget label, default is no label
*/
Fl_Clock::Fl_Clock(int X, int Y, int W, int H, const char *L)
: Fl_Clock_Output(X, Y, W, H, L) {}
/**
151
152 CHAPTER 20. DEVELOPER INFORMATION
Create an Fl_Clock widget using the given boxtype, position, size, and
label string.
\param[in] t boxtype
\param[in] X, Y, W, H position and size of the widget
\param[in] L widget label, default is no label
*/
Fl_Clock::Fl_Clock(uchar t, int X, int Y, int W, int H, const char *L)
: Fl_Clock_Output(X, Y, W, H, L) {
type(t);
box(t==FL_ROUND_CLOCK ? FL_NO_BOX : FL_UP_BOX);
}
Note
Gizmo.cxx:
/** \relatesalso Gizmo
Pops up a gizmo dialog with a Gizmo in it
*/
int popup_gizmo(...);
Different Headlines
You can use HTML tags <H1> ... <H4> for headlines with different sizes. As of doxygen 1.8.x there
must not be more than three spaces at the beginning of the line for this to work. Currently (doxygen 1.8.6)
there seems to be no difference in the font sizes of <H3> and <H4> in the pdf output, whereas the html
output uses different font sizes.
20.1. NON-ASCII CHARACTERS 153
at its top.
This section is
\section development structure Document Structure
• doxygen \ref links to other doxygen \page, \section, \subsection and \anchor locations
• HTML links without markup - doxygen creates ”http://...” links automatically
• standard, non-Doxygen, HTML links
- see chapter \ref unicode creates a link to the named chapter
unicode that has been created with a \\page statement.
appears as:
• see chapter Unicode and UTF-8 Support creates a link to the named chapter unicode that has been
created with a \page statement.
• For further informations about quoting see http://www.doxygen.org/htmlcmds.html
• see Nedit creates a standard HTML link
This paragraph will have a title, but because there is a blank line
between the \par and the text, it will have the normal layout.
\par
It is also possible to have an indented paragraph without title.
This is how you indent subsequent paragraphs.
This paragraph will have a title, but because there is a blank line between the \par and the text, it will have
the normal layout.
Indented Paragraph with title
This paragraph will also have a title, but because there is no blank line between the \par and the text,
it will be indented.
It is also possible to have an indented paragraph without title. This is how you indent subsequent
paragraphs.
No link to Fl Widget::draw()
Note that the paragraph title is treated as plain text. Doxygen type links will not work. HTML charac-
ters and tags may or may not work.
Use a single line ending with <br> for complicated paragraph titles.
Software License
December 11, 2001
The FLTK library and included programs are provided under the terms of the GNU Library General Public
License (LGPL) with the following exceptions:
1. Modifications to the FLTK configure script, config header file, and makefiles by themselves to sup-
port a specific platform do not constitute a modified or derivative work.
The authors do request that such modifications be contributed to the FLTK project - send all con-
tributions through the ”Software Trouble Report” on the following page: http://www.fltk.-
org/str.php
2. Widgets that are subclassed from FLTK widgets do not constitute a derivative work.
3. Static linking of applications and widgets to the FLTK library does not constitute a derivative work
and does not require the author to provide source code for the application or widget, use the shared
FLTK libraries, or link their applications or widgets against a user-supplied version of FLTK.
If you link the application or widget to a modified version of FLTK, then the changes to FLTK must
be provided under the terms of the LGPL in sections 1, 2, and 4.
4. You do not have to provide a copy of the FLTK license with programs that are linked to the FLTK
library, nor do you have to identify the FLTK license in your program or documentation as required
by section 6 of the LGPL.
However, programs must still identify their use of FLTK. The following example statement can be
included in user documentation to satisfy this requirement:
[program/widget] is based in part on the work of the FLTK project (http://www.fltk.org).
GNU LIBRARY GENERAL PUBLIC LICENSE
157
158 CHAPTER 21. SOFTWARE LICENSE
The licenses for most software are designed to take away your freedom to share and change it. By con-
trast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free
software–to make sure the software is free for all its users.
This license, the Library General Public License, applies to some specially designated Free Software
Foundation software, and to any other libraries whose authors decide to use it. You can use it for your
libraries, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses
are designed to make sure that you have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it if you want it, that you can change the
software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask
you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute
copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis or for a fee, you must give the
recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide complete object files to the recipients so
that they can relink them with the library, after making changes to the library and recompiling it. And you
must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this
license which gives you legal permission to copy, distribute and/or modify the library.
Also, for each distributor’s protection, we want to make certain that everyone understands that there
is no warranty for this free library. If the library is modified by someone else and passed on, we want its
recipients to know that what they have is not the original version, so that any problems introduced by others
will not reflect on the original authors’ reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that
companies distributing free software will individually obtain patent licenses, thus in effect transforming the
program into proprietary software. To prevent this, we have made it clear that any patent must be licensed
for everyone’s free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary GNU General Public License,
which was designed for utility programs. This license, the GNU Library General Public License, applies
to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in
full, and don’t assume that anything in it is the same as in the ordinary license.
The reason we have a separate public license for some libraries is that they blur the distinction we
usually make between modifying or adding to a program and simply using it. Linking a program with a
library, without changing the library, is in some sense simply using the library, and is analogous to running
a utility program or application program. However, in a textual and legal sense, the linked executable is
a combined work, a derivative of the original library, and the ordinary General Public License treats it as
such.
Because of this blurred distinction, using the ordinary General Public License for libraries did not
effectively promote software sharing, because most developers did not use the libraries. We concluded that
weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the users of those programs of all
benefit from the free status of the libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while preserving your freedom as a user of
such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards changes in the actual functions
of the Library.) The hope is that this will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and modification follow. Pay close attention
to the difference between a ”work based on the libary” and a ”work that uses the library”. The former
contains code derived from the library, while the latter only works together with the library.
Note that it is possible for a library to be covered by the ordinary General Public License rather than by
this special one.
159
0. This License Agreement applies to any software library which contains a notice placed by the copyright
holder or other authorized party saying it may be distributed under the terms of this Library General Public
License (also called ”this License”). Each licensee is addressed as ”you”.
A ”library” means a collection of software functions and/or data prepared so as to be conveniently
linked with application programs (which use some of those functions and data) to form executables.
The ”Library”, below, refers to any such software library or work which has been distributed under these
terms. A ”work based on the Library” means either the Library or any derivative work under copyright law:
that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or
translated straightforwardly into another language. (Hereinafter, translation is included without limitation
in the term ”modification”.)
”Source code” for a work means the preferred form of the work for making modifications to it. For
a library, complete source code means all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered by this License; they are
outside its scope. The act of running a program using the Library is not restricted, and output from such a
program is covered only if its contents constitute a work based on the Library (independent of the use of
the Library in a tool for writing it). Whether that is true depends on what the Library does and what the
program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library’s complete source code as you receive
it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the
absence of any warranty; and distribute a copy of this License along with the Library.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer
warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based
on the Library, and copy and distribute such modifications or work under the terms of Section 1 above,
provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that you changed the files and
the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms
of this License.
d) If a facility in the modified Library refers to a function or a table of data to be supplied by an
application program that uses the facility, other than as an argument passed when the facility is invoked,
then you must make a good faith effort to ensure that, in the event an application does not supply such
function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose that is entirely well-defined
independent of the application. Therefore, Subsection 2d requires that any application-supplied function or
table used by this function must be optional: if the application does not supply it, the square root function
must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not
derived from the Library, and can be reasonably considered independent and separate works in themselves,
then this License, and its terms, do not apply to those sections when you distribute them as separate works.
But when you distribute the same sections as part of a whole which is a work based on the Library, the
distribution of the whole must be on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely
by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works
based on the Library.
In addition, mere aggregation of another work not based on the Library with the Library (or with a
work based on the Library) on a volume of a storage or distribution medium does not bring the other work
160 CHAPTER 21. SOFTWARE LICENSE
d) Verify that the user has already received a copy of these materials or that you have already sent this
user a copy.
For an executable, the required form of the ”work that uses the Library” must include any data and
utility programs needed for reproducing the executable from it. However, as a special exception, the source
code distributed need not include anything that is normally distributed (in either source or binary form)
with the major components (compiler, kernel, and so on) of the operating system on which the executable
runs, unless that component itself accompanies the executable.
It may happen that this requirement contradicts the license restrictions of other proprietary libraries that
do not normally accompany the operating system. Such a contradiction means you cannot use both them
and the Library together in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side in a single library
together with other library facilities not covered by this License, and distribute such a combined library,
provided that the separate distribution of the work based on the Library and of the other library facilities is
otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the Library, uncombined
with any other library facilities. This must be distributed under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of it is a work based on the
Library, and explaining where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly
provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute
the Library is void, and will automatically terminate your rights under this License. However, parties who
have received copies, or rights, from you under this License will not have their licenses terminated so long
as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed it. However, nothing else grants
you permission to modify or distribute the Library or its derivative works. These actions are prohibited by
law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work
based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions
for copying, distributing or modifying the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library), the recipient automati-
cally receives a license from the original licensor to copy, distribute, link with or modify the Library subject
to these terms and conditions. You may not impose any further restrictions on the recipients’ exercise of
the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
11. If, as a consequence of a court judgment or allegation of patent infringement or for any other
reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this
License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any
other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if
a patent license would not permit royalty-free redistribution of the Library by all those who receive copies
directly or indirectly through you, then the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the
balance of the section is intended to apply, and the section as a whole is intended to apply in other circum-
stances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims
or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of
the free software distribution system which is implemented by public license practices. Many people have
made generous contributions to the wide range of software distributed through that system in reliance on
consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute
software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of
this License.
12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by
copyrighted interfaces, the original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries, so that distribution is permitted
162 CHAPTER 21. SOFTWARE LICENSE
only in or among countries not thus excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of the Library General
Public License from time to time. Such new versions will be similar in spirit to the present version, but
may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies a version number of
this License which applies to it and ”any later version”, you have the option of following the terms and
conditions either of that version or of any later version published by the Free Software Foundation. If the
Library does not specify a license version number, you may choose any version ever published by the Free
Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs whose distribution con-
ditions are incompatible with these, write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make
exceptions for this. Our decision will be guided by the two goals of preserving the free status of all deriva-
tives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHER-
WISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE
THE LIBRARY ”AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLI-
ED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILIT-
Y AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE,
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITI-
NG WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARIS-
ING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTH-
ER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Chapter 22
The FLTK distribution contains over 60 sample applications written in, or ported to, FLTK.
If the FLTK archive you received does not contain either an ’examples’ or ’test’ directory, you can
download the complete FLTK distribution from http://fltk.org/software.php .
Most of the example programs were created while testing a group of widgets. They are not meant to be
great achievements in clean C++ programming, but merely a test platform to verify the functionality of the
FLTK library.
Note that extra example programs are also available in an additional ’examples’ directory, but these are
NOT built automatically when you build FLTK, unlike those in the ’test’ directory shown below.
22.1.1 adjuster
adjuster shows a nifty little widget for quickly setting values in a great range.
22.1.2 arc
The arc demo explains how to derive your own widget to generate some custom drawings. The
sample drawings use the matrix based arc drawing for some fun effects.
163
164 CHAPTER 22. EXAMPLE SOURCE CODE
22.1.3 ask
ask shows some of FLTK’s standard dialog boxes. Click the correct answers or you may end up in a
loop, or you may end up in a loop, or you... .
22.1.4 bitmap
This simple test shows the use of a single color bitmap as a label for a box widget. Bitmaps are stored
in the X11 ’.bmp’ file format and can be part of the source code.
22.1.5 blocks
A wonderful and addictive game that shows the usage of FLTK timers, graphics, and how to implement
sound on all platforms. blocks is also a good example for the Mac OS X specific bundle format.
22.1.6 boxtype
boxtype gives an overview of readily available boxes and frames in FLTK. More types can be added
by the application programmer. When using themes, FLTK shuffles boxtypes around to give your
program a new look.
22.1.7 browser
browser shows the capabilities of the Fl Browser widget. Important features tested are loading of
files, line formatting, and correct positioning of the browser data window.
22.1.8 button
22.1.9 buttons
22.1.10 checkers
Written by Steve Poulsen in early 1979, checkers shows how to convert a VT100 text-terminal
based program into a neat application with a graphical UI. Check out the code that drags the pieces,
and how the pieces are drawn by layering. Then tell me how to beat the computer at Checkers.
22.1.11 clock
The clock demo shows two analog clocks. The innards of the Fl Clock widget are pretty interesting,
explaining the use of timeouts and matrix based drawing.
22.1. EXAMPLE APPLICATIONS 165
22.1.12 colbrowser
colbrowser runs only on X11 systems. It reads /usr/lib/X11/rgb.txt to show the color representation
of every text entry in the file. This is beautiful, but only moderately useful unless your UI is written in
Motif.
The color chooser gives a short demo of FLTK’s palette based color chooser and of the RGB
based color wheel.
22.1.14 cube
The cube demo shows the speed of OpenGL. It also tests the ability to render two OpenGL buffers
into a single window, and shows OpenGL text.
22.1.15 CubeView
22.1.16 cursor
The cursor demo shows all mouse cursor shapes that come standard with FLTK. The fgcolor and
bgcolor sliders work only on few systems (some version of Irix for example).
22.1.17 curve
curve draws a nice Bezier curve into a custom widget. The points option for splines is not supported
on all platforms.
22.1.18 demo
This tool allows quick access to all programs in the test directory. demo is based on the visuals of
the IrixGL demo program. The menu tree can be changed by editing test/demo.menu.
22.1.19 device
Exercises the Fl Image Surface, Fl Copy Surface, and Fl Printer classes to draw to an Fl Image ob-
ject, copy graphical data to the clipboard, and for print support.
Note
The clipboard.cxx program of the ’examples’ directory is a clipboard watching application that con-
tinuously displays the textual or graphical content of the system clipboard (a.k.a pasteboard on Mac
OS X) exercising Fl::paste().
166 CHAPTER 22. EXAMPLE SOURCE CODE
22.1.20 doublebuffer
The doublebuffer demo shows the difference between a single buffered window, which may
flicker during a slow redraw, and a double buffered window, which never flickers, but uses twice the
amount of RAM. Some modern OS’s double buffer all windows automatically to allow transparency
and shadows on the desktop. FLTK is smart enough to not tripple buffer a window in that case.
22.1.21 editor
FLTK has two very different text input widgets. Fl Input and derived classes are rather light weight,
however Fl Text Editor is a complete port of nedit (with permission). The editor test is almost a
full application, showing custom syntax highlighting and dialog creation.
fast slow shows how an application can use the Fl Widget::when() setting to receive different kinds
of callbacks.
The standard FLTK file chooser is the result of many iterations, trying to find a middle ground
between a complex browser and a fast light implementation.
22.1.24 fonts
fonts shows all available text fonts on the host system. If your machine still has some pixmap based
fonts, the supported sizes will be shown in bold face. Only the first 256 fonts will be listed.
22.1.25 forms
forms is an XForms program with very few changes. Search for ”fltk” to find all changes necessary
to port to fltk. This demo shows the different boxtypes. Note that some boxtypes are not appropriate
for some objects.
22.1.26 fractals
fractals shows how to mix OpenGL, Glut and FLTK code. FLTK supports a rather large subset of
Glut, so that many Glut applications compile just fine.
22.1.27 fullscreen
This demo shows how to do many of the window manipulations that are popular for games. You
can toggle the border on/off, switch between single- and double-buffered rendering, and take over the
entire screen. More information in the source code.
22.1.28 gl overlay
gl overlay shows OpenGL overlay plane rendering. If no hardware overlay plane is available,
FLTK will simulate it for you.
22.1. EXAMPLE APPLICATIONS 167
22.1.29 glpuzzle
The glpuzzle test shows how most Glut source code compiles easily under FLTK.
22.1.30 hello
hello: Hello, World. Need I say more? Well, maybe. This tiny demo shows how little is needed to
get a functioning application running with FLTK. Quite impressive, I’d say.
22.1.31 help
help displays the built-in FLTK help browser. The Fl Help Dialog understands a subset of html and
renders various image formats. This widget makes it easy to provide help pages to the user without
depending on the operating system’s html browser.
22.1.32 iconize
iconize demonstrates the effect of the window functions hide(), iconize(), and show().
22.1.33 image
The image demo shows how an image can be created on the fly. This generated image contains an al-
pha (transparency) channel which lets previous renderings ’shine through’, either via true transparency
or by using screen door transparency (pixelation).
22.1.34 inactive
inactive tests the correct rendering of inactive widgets. To see the inactive version of images, you
can check out the pixmap or image test.
22.1.35 input
This tool shows and tests different types of text input fields based on Fl Input . The input program
also tests various settings of Fl Input::when().
input choice tests the latest addition to FLTK1, a text input field with an attached pulldown menu.
Windows users will recognize similarities to the ’ComboBox’. input choice starts up in ’plastic’
scheme, but the traditional scheme is also supported.
22.1.37 keyboard
FLTK unifies keyboard events for all platforms. The keyboard test can be used to check the return
values of Fl::event key() and Fl::event text(). It is also great to see the modifier buttons and the scroll
wheel at work. Quit this application by closing the window. The ESC key will not work.
168 CHAPTER 22. EXAMPLE SOURCE CODE
22.1.38 label
Every FLTK widget can have a label attached to it. The label demo shows alignment, clipping, and
wrapping of text labels. Labels can contain symbols at the start and end of the text, like @FLTK or
@circle uh-huh @square.
Advanced line drawing can be tested with line style. Not all platforms support all line styles.
This little app finds all available pixel formats for the current X11 screen. But since you are now an
FLTK user, you don’t have to worry about any of this.
22.1.41 mandelbrot
mandelbrot shows two advanced topics in one test. It creates grayscale images on the fly, updating
them via the idle callback system. This is one of the few occasions where the idle callback is very
useful by giving all available processor time to the application without blocking the UI or other apps.
22.1.42 menubar
The menubar tests many aspects of FLTK’s popup menu system. Among the features are radio
buttons, menus taller than the screen, arbitrary sub menu depth, and global shortcuts.
22.1.43 message
22.1.44 minimum
The minimum test program verifies that the update regions are set correctly. In a real life application,
the trail would be avoided by choosing a smaller label or by setting label clipping differently.
22.1.45 navigation
navigation demonstrates how the text cursor moves from text field to text field when using the
arrow keys, tab, and shift-tab.
22.1.46 output
output shows the difference between the single line and multi line mode of the Fl Output widget.
Fonts can be selected from the FLTK standard list of fonts.
22.1. EXAMPLE APPLICATIONS 169
22.1.47 overlay
The overlay test app shows how easy an FLTK window can be layered to display cursor and ma-
nipulator style elements. This example derives a new class from Fl Overlay Window and provides a
new function to draw custom overlays.
22.1.48 pack
The pack test program demonstrates the resizing and repositioning of children of the Fl Pack group.
Putting an Fl Pack into an Fl Scroll is a useful way to create a browser for large sets of data.
pixmap browser tests the shared-image interface. When using the same image multiple times,
Fl Shared Image will keep it only once in memory.
22.1.50 pixmap
This simple test shows the use of a LUT based pixmap as a label for a box widget. Pixmaps are stored
in the X11 ’.xpm’ file format and can be part of the source code. Pixmaps support one transparent
color.
22.1.51 preferences
I do have my preferences in the morning, but sometimes I just can’t remember a thing. This is
where the Fl Preferences come in handy. They remember any kind of data between program launches.
22.1.52 radio
The radio tool was created entirely with fluid. It shows some of the available button types and tests
radio button behavior.
22.1.53 resizebox
22.1.54 resize
The resize demo tests size and position functions with the given window manager.
22.1.55 scroll
scroll shows how to scroll an area of widgets, one of them being a slow custom drawing. Fl Scroll
uses clipping and smart window area copying to improve redraw speed. The buttons at the bottom of
the window control decoration rendering and updates.
170 CHAPTER 22. EXAMPLE SOURCE CODE
22.1.56 shape
shape is a very minimal demo that shows how to create your own OpenGL rendering widget. Now
that you know that, go ahead and write that flight simulator you always dreamt of.
22.1.57 subwindow
The subwindow demo tests messaging and drawing between the main window and ’true’ sub win-
dows. A sub window is different to a group by resetting the FLTK coordinate system to 0, 0 in the top
left corner. On Win32 and X11, subwindows have their own operating system specific handle.
22.1.58 sudoku
Another highly addictive game - don’t play it, I warned you. The implementation shows how to create
application icons, how to deal with OS specifics, and how to generate sound.
22.1.59 symbols
symbols are a speciality of FLTK. These little vector drawings can be integrated into labels. They
scale and rotate, and with a little patience, you can define your own. The rotation number refers to 45
degree rotations if you were looking at a numeric keypad (2 is down, 6 is right, etc.).
22.1.60 tabs
The tabs tool was created with fluid. It tests correct hiding and redisplaying of tabs, navigation across
tabs, resize behavior, and no unneeded redrawing of invisible widgets.
The tabs application shows the Fl Tabs widget on the left and the Fl Wizard widget on the right side
for direct comparison of these two panel management widgets.
22.1.61 threads
FLTK can be used in a multithreading environment. There are some limitations, mostly due to the
underlying operating system. threads shows how to use Fl::lock(), Fl::unlock(), and Fl::awake() in
secondary threads to keep FLTK happy. Although locking works on all platforms, this demo is not
available on every machine.
22.1.62 tile
The tile tool shows a nice way of using Fl Tile. To test correct resizing of subwindows, the widget
for region 1 is created from an Fl Window class.
The tiled image demo uses an image as the background for a window by repeating it over the full
size of the widget. The window is resizable and shows how the image gets repeated.
22.1. EXAMPLE APPLICATIONS 171
22.1.64 unittests
unittests exercises all of FLTK’s drawing features (e.g., text, lines, circles, images), as well as
scrollbars and schemes.
22.1.65 utf8
utf8 shows all fonts available to the platform that runs it, and how each font draws each of the
Unicode code points ranging between U+0020 and U+FFFF.
22.1.66 valuators
22.1.67 fluid
fluid is not only a big test program, but also a very useful visual UI designer. Many parts of fluid
were created using fluid. See the Fluid Tutorial for more details.
172 CHAPTER 22. EXAMPLE SOURCE CODE
Chapter 23
173
174 CHAPTER 23. FAQ (FREQUENTLY ASKED QUESTIONS)
4. You do not have to provide a copy of the FLTK license with programs
that are linked to the FLTK library, nor do you have to identify the
FLTK license in your program or documentation as required by section 6
of the LGPL.
However, programs must still identify their use of FLTK. The following
example statement can be included in user documentation to satisfy
this requirement:
23.4 Hitting the ’Escape’ key closes windows - how do I prevent this?
[From FLTK article #378]
1. FLTK has a ”global event handler” that makes Escape try to close the window, the same as clicking
the close box. To disable this everywhere you can install your own that pretends it wants the escape
key and thus stops the default one from seeing it (this may not be what you want, see below about
the callbacks):
static int my handler(int event) {
if (event == FL SHORTCUT) return 1; // eat all shortcut keys
return 0;
}
...in main():
Fl::add handler(my handler);
...
1. Attempts to close a window (both clicking the close box or typing Escape) call that window’s call-
back. The default version of the callback does hide(). To make the window not close or otherwise
do something different you replace the callback. To make the main window exit the program:
void my callback(Fl Widget*, void*) {
exit(0);
}
...
main window->callback(my callback);
...
If you don’t want Escape to close the main window and exit you can check for and ignore it. This is
better than replacing the global handler because Escape will still close pop-up windows:
void my callback(Fl Widget*, void*) {
if (Fl::event()==FL SHORTCUT && Fl::event key()==
FL Escape)
return; // ignore Escape
exit(0);
}
23.4. HITTING THE ’ESCAPE’ KEY CLOSES WINDOWS - HOW DO I PREVENT THIS? 175
It is very common to ask for confirmation before exiting, this can be done with:
void my callback(Fl Widget*, void*) {
if (fl ask("Are you sure you want to quit?"))
exit(0);
}
176 CHAPTER 23. FAQ (FREQUENTLY ASKED QUESTIONS)
Chapter 24
Todo List
Page Adding and Extending Widgets
Clarify Fl Window::damage(uchar) handling - seems confused/wrong? ORing value doesn’t match set-
ting behaviour in FL Widget.H!
Clarify Fl Widget::test shortcut() explanations. Fl Widget.h says Internal Use only, but subclassing
chapter gives details!
Group Box Types
Description of boxtypes is incomplete. See below for the defined enum Fl Boxtype.
See Also
src/Fl get system colors.cxx
Page Drawing Things in FLTK
add an Fl Draw Area Cb typedef to allow fl scroll(...) to be doxygenated?
Member Fl Browser ::scrollbar width (int width)
This method should eventually be removed in 1.4+
Member Fl Browser ::scrollbar width () const
This method should eventually be removed in 1.4+
Member Fl Browser ::sort (int flags=0)
Add a flag to ignore case
Class Fl Button
Refactor the doxygen comments for Fl Button type() documentation.
Refactor the doxygen comments for Fl Button when() documentation.
Class Fl Chart
Refactor Fl Chart::type() information.
Class Fl Choice
Refactor the doxygen comments for Fl Choice changed() documentation.
Class Fl Counter
Refactor the doxygen comments for Fl Counter type() documentation.
Member Fl Cursor
enum Fl Cursor needs maybe an image.
Member Fl File Input::errorcolor () const
Better docs for Fl File Input::errorcolor() - is it even used?
177
178 CHAPTER 24. TODO LIST
Member Fl Group::sizes ()
Should the internal representation of the sizes() array be documented?
Member fl height (int font, int size)
In the future, when the XFT issues are resolved, this function should simply return the ’size’ value.
Member Fl Input ::handle mouse (int, int, int, int, int keepmark=0)
Add comment and parameters
Member Fl Input ::handletext (int e, int, int, int, int)
Add comment and parameters
Member fl intptr t
typedef’s fl intptr t and fl uintptr t should be documented.
Class Fl Label
For FLTK 1.3, the Fl Label type will become a widget by itself. That way we will be avoiding a lot of
code duplication by handling labels in a similar fashion to widgets containing text. We also provide an
easy interface for very complex labels, containing html or vector graphics.
Member Fl Labeltype
The doxygen comments are incomplete, and some labeltypes are starting with an underscore. Also,
there are three external functions undocumented (yet):
Member Fl When
doxygen comments for values are incomplete and maybe wrong or unclear
Member Fl Widget::argument (long v)
The user data value must be implemented using intptr t or similar to avoid 64-bit machine incompati-
bilities.
Member Fl Widget::type () const
Explain ”simulate RTTI” (currently only used to decide if a widget is a window, i.e. type()>=FL WI-
NDOW ?). Is type() really used in a way that ensures ”Forms compatibility” ?
Member Fl Window::show (int argc, char ∗∗argv)
explain which system parameters are set up.
Page Handling Events
Add details on how to detect repeating keys, since on some X servers a repeating key will generate both
FL KEYUP and FL KEYDOWN, such that to tell if a key is held, you need Fl::event key(int) to detect
if the key is being held down during FL KEYUP or not.
Group Mouse and Keyboard Events
FL Button and FL key... constants could be structured better (use an enum or some doxygen grouping
?)
Page Unicode and UTF-8 Support
Do we need this info about planes?
Work through the code and this documentation to harmonize the [OksiD] and [fltk2] functions.
Verify 16/24 bit Unicode limit for different character sets? OksiD’s code appears limited to 16-bit
whereas the FLTK2 code appears to handle a wider set. What about illegal characters? See comments
in fl utf8fromwc() and fl utf8toUtf16().
Chapter 25
Deprecated List
Member Fl::release ()
Use Fl::grab(0) instead.
See Also
grab(Fl Window∗)
Member Fl::set idle (Fl Old Idle Handler cb)
This method is obsolete - use the add idle() method instead.
Member fl clip
fl clip(int, int, int, int) is deprecated and will be removed from future releases. Please use fl push -
clip(int x, int y, int w, int h) instead.
Member Fl Group::focus (Fl Widget ∗W)
This is for backwards compatibility only. You should use W->take focus() instead.
See Also
Fl Widget::take focus();
Member Fl Menu Item::check ()
.
Member Fl Menu Item::checked () const
.
Member Fl Menu Item::uncheck ()
.
Member Fl Spinner::maxinum () const
181
182 CHAPTER 25. DEPRECATED LIST
Module Index
26.1 Modules
Here is a list of all modules:
Callback function typedefs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Windows handling functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Events handling functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Selection & Clipboard functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Screen functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Color & Font functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Drawing functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Multithreading support functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Safe widget deletion support functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Cairo support functions and classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Unicode and UTF-8 functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Mac OS X-specific symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Common Dialogs classes and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
File names and URI utility functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
183
184 CHAPTER 26. MODULE INDEX
Chapter 27
Hierarchical Index
185
186 CHAPTER 27. HIERARCHICAL INDEX
Fl FormsBitmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Fl FormsPixmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Fl FormsText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
Fl Free . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
Fl Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Fl Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Fl Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
Fl File Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Fl Hold Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
Fl Multi Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
Fl Select Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
Fl Check Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
Fl Color Chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Fl Help View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Fl Input Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
Fl Pack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
Fl Scroll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628
Fl Spinner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
Fl Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661
Fl Table Row . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677
Fl Tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680
Fl Text Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
Fl Text Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
Fl Tile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741
Fl Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 752
Fl Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858
Fl Double Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
Fl Cairo Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Fl Overlay Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
Fl Gl Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Fl Glut Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Fl Single Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
Fl Menu Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
Fl Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874
Fl Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
Fl Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
Fl File Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
Fl Float Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Fl Int Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
Fl Multiline Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Fl Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555
Fl Multiline Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
Fl Secret Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
Fl Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516
Fl Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
Fl Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
Fl Sys Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
Fl Menu Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Fl Positioner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
Fl Progress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609
Fl Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745
Fl Valuator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 810
188 CHAPTER 27. HIERARCHICAL INDEX
Fl Adjuster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
Fl Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
Fl Simple Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642
Fl Dial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
Fl Fill Dial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
Fl Line Dial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
Fl Roller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624
Fl Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
Fl Fill Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
Fl Hor Fill Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
Fl Hor Nice Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Fl Hor Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Fl Nice Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
Fl Scrollbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
Fl Value Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 821
Fl Hor Value Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
Fl Value Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 814
Fl Value Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818
Fl Widget Tracker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 857
Fl XColor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876
Fl Text Editor::Key Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 881
Fl Graphics Driver::matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 881
Fl Preferences::Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 882
Fl Preferences::Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883
Fl Paged Device::page format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883
Fl Preferences::RootNode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
Fl Window::shape data type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
Fl Text Display::Style Table Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
Chapter 28
Class Index
189
190 CHAPTER 28. CLASS INDEX
Fl Clock Output
This widget can be used to display a program-supplied time . . . . . . . . . . . . 374
Fl Color Chooser
Standard RGB color chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Fl Copy Surface
Supports copying of graphical data to the clipboard . . . . . . . . . . . . . . . . . 381
Fl Counter
Controls a single floating point value with button (or keyboard) arrows . . . . . . 382
Fl Device
All graphical output devices and all graphics systems . . . . . . . . . . . . . . . . 385
Fl Device Plugin
This plugin socket allows the integration of new device drivers for special window
or screen types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
Fl Dial
Circular dial to control a single floating point value . . . . . . . . . . . . . . . . . 388
Fl Display Device
A display to which the computer can draw . . . . . . . . . . . . . . . . . . . . . 390
Fl Double Window
The Fl Double Window provides a double-buffered window . . . . . . . . . . . . 391
Fl End
This is a dummy class that allows you to end a Fl Group in a constructor list of a
class: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Fl File Browser
Displays a list of filenames, optionally with file-specific icons . . . . . . . . . . . 393
Fl File Chooser
Displays a standard file selection dialog that supports various selection modes . . . 395
Fl File Icon
Manages icon images that can be used as labels in other widgets and as icons in the
FileBrowser widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Fl File Input
This widget displays a pathname in a text input field . . . . . . . . . . . . . . . . 408
Fl Fill Dial
Draws a dial with a filled arc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
Fl Fill Slider
Widget that draws a filled horizontal slider, useful as a progress or value meter . . 411
Fl Float Input
Subclass of Fl Input that only allows the user to type floating point numbers (sign,
digits, decimal point, more digits, ’E’ or ’e’, sign, digits) . . . . . . . . . . . . . . . . 412
Fl FLTK File Chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Fl Font Descriptor
This a structure for an actual system font, with junk to help choose it and info on
character sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Fl Fontdesc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Fl FormsBitmap
Forms compatibility Bitmap Image Widget . . . . . . . . . . . . . . . . . . . . . 414
Fl FormsPixmap
Forms pixmap drawing routines . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Fl FormsText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
Fl Free
Emulation of the Forms ”free” widget . . . . . . . . . . . . . . . . . . . . . . . . 419
Fl GDI Graphics Driver
The MSWindows-specific graphics class . . . . . . . . . . . . . . . . . . . . . . 421
Fl GDI Printer Graphics Driver
The graphics driver used when printing on MSWindows . . . . . . . . . . . . . . 425
28.1. CLASS LIST 191
Fl GIF Image
Supports loading, caching, and drawing of Compuserve GIFSM images . . . . . . 426
Fl Gl Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Fl Gl Window
Sets things up so OpenGL works . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Fl Glut Bitmap Font
Fltk glut font/size attributes used in the glutXXX functions . . . . . . . . . . . . . 433
Fl Glut StrokeChar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Fl Glut StrokeFont . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Fl Glut StrokeStrip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Fl Glut StrokeVertex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Fl Glut Window
GLUT is emulated using this window class and these static variables (plus several
more static variables hidden in glut compatability.cxx): . . . . . . . . . . . . . . . . 434
Fl Graphics Driver
A virtual class subclassed for each graphics driver FLTK uses . . . . . . . . . . . 436
Fl Group
FLTK container widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Fl GTK File Chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Fl Help Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
Fl Help Dialog
Displays a standard help dialog window using the Fl Help View widget . . . . . . 468
Fl Help Font Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
Fl Help Font Style
Fl Help View font stack element definition . . . . . . . . . . . . . . . . . . . . . 472
Fl Help Link
Definition of a link for the html viewer . . . . . . . . . . . . . . . . . . . . . . . 472
Fl Help Target
Fl Help Target structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Fl Help View
Displays HTML text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Fl Hold Browser
The Fl Hold Browser is a subclass of Fl Browser which lets the user select a single
item, or no items by clicking on the empty space . . . . . . . . . . . . . . . . . . . . 479
Fl Hor Fill Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
Fl Hor Nice Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Fl Hor Slider
Horizontal Slider class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Fl Hor Value Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
Fl Image
Fl Image is the base class used for caching and drawing all kinds of images in FLTK 483
Fl Image Surface
Directs all graphics requests to an Fl Image . . . . . . . . . . . . . . . . . . . . . 486
Fl Input
This is the FLTK text input widget . . . . . . . . . . . . . . . . . . . . . . . . . . 488
Fl Input
This class provides a low-overhead text input field . . . . . . . . . . . . . . . . . 490
Fl Input Choice
A combination of the input widget and a menu button . . . . . . . . . . . . . . . 505
Fl Int Input
Subclass of Fl Input that only allows the user to type decimal digits (or hex numbers
of the form 0xaef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
192 CHAPTER 28. CLASS INDEX
Fl JPEG Image
Supports loading, caching, and drawing of Joint Photographic Experts Group (JPE-
G) File Interchange Format (JFIF) images . . . . . . . . . . . . . . . . . . . . . . . . 510
Fl Label
This struct stores all information for a text or mixed graphics label . . . . . . . . . 511
Fl Light Button
This subclass displays the ”on” state by turning on a light, rather than drawing
pushed in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
Fl Line Dial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
Fl Mac App Menu
Mac OS-specific class allowing to localize the application menu . . . . . . . . . . 515
Fl Menu
Base class of all widgets that have a menu in FLTK . . . . . . . . . . . . . . . . . 516
Fl Menu Bar
This widget provides a standard menubar interface . . . . . . . . . . . . . . . . . 528
Fl Menu Button
This is a button that when pushed pops up a menu (or hierarchy of menus) defined
by an array of Fl Menu Item objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Fl Menu Item
The Fl Menu Item structure defines a single menu item that is used by the Fl Menu-
class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Fl Menu Window
Window type used for menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
Fl Multi Browser
Subclass of Fl Browser which lets the user select any set of the lines . . . . . . . . 546
Fl Multi Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Fl Multiline Input
This input field displays ’\n’ characters as new lines rather than ∧ J, and accepts the
Return, Tab, and up and down arrow keys . . . . . . . . . . . . . . . . . . . . . . . . 547
Fl Multiline Output
This widget is a subclass of Fl Output that displays multiple lines of text . . . . . 548
Fl Native File Chooser
This class lets an FLTK application easily and consistently access the operating
system’s native file chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549
Fl Nice Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
Fl Output
This widget displays a piece of text . . . . . . . . . . . . . . . . . . . . . . . . . 555
Fl Overlay Window
This window provides double buffering and also the ability to draw the ”overlay”
which is another picture placed on top of the main image . . . . . . . . . . . . . . . . 556
Fl Pack
This widget was designed to add the functionality of compressing and aligning wid-
gets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
Fl Paged Device
Represents page-structured drawing surfaces . . . . . . . . . . . . . . . . . . . . 560
Fl Pixmap
Supports caching and drawing of colormap (pixmap) images, including transparency
566
Fl Plugin
Fl Plugin allows link-time and run-time integration of binary modules . . . . . . . 569
Fl Plugin Manager
Fl Plugin Manager manages link-time and run-time plugin binaries . . . . . . . . 570
28.1. CLASS LIST 193
Fl PNG Image
Supports loading, caching, and drawing of Portable Network Graphics (PNG) image
files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
Fl PNM Image
Supports loading, caching, and drawing of Portable Anymap (PNM, PBM, PGM,
PPM) image files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Fl Positioner
This class is provided for Forms compatibility . . . . . . . . . . . . . . . . . . . 573
Fl PostScript File Device
To send graphical output to a PostScript file . . . . . . . . . . . . . . . . . . . . . 576
Fl PostScript Graphics Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Fl PostScript Printer
Print support under Unix/Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . 590
Fl Preferences
Fl Preferences provides methods to store user settings between application starts . 591
Fl Printer
OS-independent print support . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
Fl Progress
Displays a progress bar for the user . . . . . . . . . . . . . . . . . . . . . . . . . 609
Fl Quartz Graphics Driver
The Mac OS X-specific graphics class . . . . . . . . . . . . . . . . . . . . . . . . 611
Fl Radio Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614
Fl Radio Light Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615
Fl Radio Round Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615
Fl Scroll::ScrollInfo::Fl Region LRTB
A local struct to manage a region defined by left/right/top/bottom . . . . . . . . . 616
Fl Scroll::ScrollInfo::Fl Region XYWH
A local struct to manage a region defined by xywh . . . . . . . . . . . . . . . . . 617
Fl Repeat Button
The Fl Repeat Button is a subclass of Fl Button that generates a callback when it
is pressed and then repeatedly generates callbacks as long as it is held down . . . . . . 617
Fl Return Button
The Fl Return Button is a subclass of Fl Button that generates a callback when it is
pressed or when the user presses the Enter key . . . . . . . . . . . . . . . . . . . . . 618
Fl RGB Image
Supports caching and drawing of full-color images with 1 to 4 channels of color
information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620
Fl Roller
”dolly” control commonly used to move 3D objects . . . . . . . . . . . . . . . . . 624
Fl Round Button
Buttons generate callbacks when they are clicked by the user . . . . . . . . . . . . 626
Fl Round Clock
A clock widget of type FL ROUND CLOCK . . . . . . . . . . . . . . . . . . . . 627
Fl Scroll
This container widget lets you maneuver around a set of widgets much larger than
your window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628
Fl Scrollbar
Displays a slider with arrow buttons at the ends of the scrollbar . . . . . . . . . . 632
Fl Scroll::ScrollInfo::Fl Scrollbar Data
A local struct to manage a scrollbar’s xywh region and tab values . . . . . . . . . 635
Fl Secret Input
Subclass of Fl Input that displays its input as a string of placeholders . . . . . . . 636
194 CHAPTER 28. CLASS INDEX
Fl Select Browser
The class is a subclass of Fl Browser which lets the user select a single item, or no
items by clicking on the empty space . . . . . . . . . . . . . . . . . . . . . . . . . . 637
Fl Shared Image
This class supports caching, loading, and drawing of image files . . . . . . . . . . 638
Fl Simple Counter
This widget creates a counter with only 2 arrow buttons . . . . . . . . . . . . . . 642
Fl Single Window
This is the same as Fl Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
Fl Slider
Sliding knob inside a box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
Fl Spinner
This widget is a combination of the input widget and repeat buttons . . . . . . . . 647
Fl Surface Device
A surface that’s susceptible to receive graphical output . . . . . . . . . . . . . . . 652
Fl Sys Menu Bar
A class to create, modify and delete menus that appear on Mac OS X in the menu
bar at the top of the screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
Fl System Printer
Print support under MSWindows and Mac OS . . . . . . . . . . . . . . . . . . . . 657
Fl Table
A table of widgets or other content . . . . . . . . . . . . . . . . . . . . . . . . . . 661
Fl Table Row
A table with row selection capabilities . . . . . . . . . . . . . . . . . . . . . . . . 677
Fl Tabs
”file card tabs” interface that allows you to put lots and lots of buttons and switches
in a panel, as popularized by many toolkits . . . . . . . . . . . . . . . . . . . . . . . 680
Fl Text Buffer
This class manages unicode displayed in one or more Fl Text Display widgets . . 686
Fl Text Display
Rich text display widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
Fl Text Editor
This is the FLTK text editor widget . . . . . . . . . . . . . . . . . . . . . . . . . 733
Fl Text Selection
This is an internal class for Fl Text Buffer to manage text selections . . . . . . . . 738
Fl Tile
Lets you resize its children by dragging the border between them . . . . . . . . . 741
Fl Tiled Image
This class supports tiling of images over a specified area . . . . . . . . . . . . . . 743
Fl Timer
This is provided only to emulate the Forms Timer widget . . . . . . . . . . . . . . 745
Fl Toggle Button
The toggle button is a push button that needs to be clicked once to toggle on, and
one more time to toggle off . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747
Fl Tooltip
Tooltip support for all FLTK widgets . . . . . . . . . . . . . . . . . . . . . . . . 748
Fl Tree
Tree widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 752
Fl Tree Item
Tree widget item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787
Fl Tree Item Array
Manages an array of Fl Tree Item pointers . . . . . . . . . . . . . . . . . . . . . 803
Fl Tree Prefs
Tree widget’s preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 806
28.1. CLASS LIST 195
Fl Valuator
Controls a single floating-point value and provides a consistent interface to set the
value, range, and step, and insures that callbacks are done the same for every object . . 810
Fl Value Input
Displays a numeric value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 814
Fl Value Output
Displays a floating point value . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818
Fl Value Slider
Fl Slider widget with a box displaying the current value . . . . . . . . . . . . . . 821
Fl Widget
Fl Widget is the base class for all widgets in FLTK . . . . . . . . . . . . . . . . . 823
Fl Widget Tracker
This class should be used to control safe widget deletion . . . . . . . . . . . . . . 857
Fl Window
This widget produces an actual window . . . . . . . . . . . . . . . . . . . . . . . 858
Fl Wizard
This widget is based off the Fl Tabs widget, but instead of displaying tabs it only
changes ”tabs” under program control . . . . . . . . . . . . . . . . . . . . . . . . . . 874
Fl XBM Image
Supports loading, caching, and drawing of X Bitmap (XBM) bitmap files . . . . . 876
Fl XColor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876
Fl Xlib Graphics Driver
The Xlib-specific graphics class . . . . . . . . . . . . . . . . . . . . . . . . . . . 877
Fl XPM Image
Supports loading, caching, and drawing of X Pixmap (XPM) images, including
transparency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 880
Fl Text Editor::Key Binding
Simple linked list associating a key/state to a function . . . . . . . . . . . . . . . 881
Fl Graphics Driver::matrix
A 2D coordinate transformation matrix . . . . . . . . . . . . . . . . . . . . . . . 881
Fl Preferences::Name
’Name’ provides a simple method to create numerical or more complex procedural
names for entries and groups on the fly . . . . . . . . . . . . . . . . . . . . . . . . . 882
Fl Preferences::Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883
Fl Paged Device::page format
Width, height and name of a page format . . . . . . . . . . . . . . . . . . . . . . 883
Fl Preferences::RootNode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
Fl Window::shape data type
Data supporting a non-rectangular window shape . . . . . . . . . . . . . . . . . . 884
Fl Text Display::Style Table Entry
This structure associates the color, font, andsize of a string to draw with an attribute
mask matching attr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
196 CHAPTER 28. CLASS INDEX
Chapter 29
File Index
197
198 CHAPTER 29. FILE INDEX
Fl Browser .H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Cairo.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Cairo Window.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Chart.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Check Browser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Check Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Choice.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Clock.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl cmap.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl color.cxx
Color handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 916
Fl Color Chooser.H
Fl Color Chooser widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917
Fl compose.cxx
Utility functions to support text input . . . . . . . . . . . . . . . . . . . . . . . . 918
Fl Copy Surface.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Counter.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl curve.cxx
Utility for drawing Bezier curves, adding the points to the current fl begin/fl -
vertex/fl end path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 918
Fl Device.H
Declaration of classes Fl Device, Fl Graphics Driver, Fl Surface Device, Fl Display-
Device, Fl Device Plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 918
Fl Dial.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Double Window.cxx
Fl Double Window implementation . . . . . . . . . . . . . . . . . . . . . . . . . 920
Fl Double Window.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl draw.H
Utility header to pull drawing functions together . . . . . . . . . . . . . . . . . . 920
Fl Export.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl File Browser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl File Chooser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl File Icon.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl File Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Fill Dial.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Fill Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Float Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Font.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl FormsBitmap.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl FormsPixmap.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Free.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl GIF Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Gl Choice.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Gl Window.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Group.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Help Dialog.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Help View.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Hold Browser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Hor Fill Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Hor Nice Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Hor Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Hor Value Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
29.1. FILE LIST 199
Fl Image.H
Fl Image, Fl RGB Image classes . . . . . . . . . . . . . . . . . . . . . . . . . . 926
Fl Image Surface.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Input .H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Input Choice.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Int Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl JPEG Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Light Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Line Dial.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl line style.cxx
Line style drawing utility hiding different platforms . . . . . . . . . . . . . . . . . 927
Fl Menu.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Menu .H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Menu Bar.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Menu Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Menu Item.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Menu Window.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl message.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Multi Browser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Multi Label.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Multiline Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Multiline Output.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Native File Chooser.H
Fl Native File Chooser widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . 927
Fl Nice Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Object.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Output.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Overlay Window.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Pack.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Paged Device.cxx
Implementation of class Fl Paged Device . . . . . . . . . . . . . . . . . . . . . . 927
Fl Paged Device.H
Declaration of class Fl Paged Device . . . . . . . . . . . . . . . . . . . . . . . . 928
Fl Pixmap.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Plugin.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl PNG Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl PNM Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Positioner.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl PostScript.H
Declaration of classes Fl PostScript Graphics Driver, Fl PostScript File Device . 928
Fl Preferences.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Printer.H
Declaration of classes Fl Printer, Fl System Printer and Fl PostScript Printer . . . 930
Fl Progress.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Radio Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Radio Light Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Radio Round Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl rect.cxx
Drawing and clipping routines for rectangles . . . . . . . . . . . . . . . . . . . . 931
Fl Repeat Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Return Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl RGB Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Roller.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
200 CHAPTER 29. FILE INDEX
Fl Round Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Round Clock.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Scroll.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Scrollbar.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Secret Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Select Browser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Shared Image.H
Fl Shared Image class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 931
fl show colormap.H
The fl show colormap() function hides the implementation classes used to provide
the popup window and color selection mechanism . . . . . . . . . . . . . . . . . . . 932
fl show input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Simple Counter.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Single Window.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Spinner.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Sys Menu Bar.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Table.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Table Row.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Tabs.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Text Buffer.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Text Display.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Text Editor.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Tile.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Tiled Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Timer.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Toggle Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Toggle Light Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Toggle Round Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Tooltip.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Tree.H
This file contains the definitions of the Fl Tree class . . . . . . . . . . . . . . . . 932
Fl Tree Item.H
This file contains the definitions for Fl Tree Item . . . . . . . . . . . . . . . . . . 933
Fl Tree Item Array.H
This file defines a class that manages an array of Fl Tree Item pointers . . . . . . 933
Fl Tree Prefs.H
This file contains the definitions for Fl Tree’s preferences . . . . . . . . . . . . . 934
fl types.h
This file contains simple ”C”-style type definitions . . . . . . . . . . . . . . . . . 935
fl utf8.h
Header for Unicode and UTF8 chracter handling . . . . . . . . . . . . . . . . . . 936
Fl Valuator.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Value Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Value Output.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Value Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl vertex.cxx
Portable drawing code for drawing arbitrary shapes with simple 2D transformations 938
Fl Widget.H
Fl Widget, Fl Label classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 938
Fl Window.H
Fl Window widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 939
Fl Wizard.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl XBM Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
29.1. FILE LIST 201
Fl XColor.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl XPM Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
flstring.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
forms.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
freeglut teapot data.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
gb2312.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
georgian academy.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
georgian ps.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
gl.h
This file defines wrapper functions for OpenGL in FLTK . . . . . . . . . . . . . . 939
gl2opengl.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
gl draw.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
glu.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
glut.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 1.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 10.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 11.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 13.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 14.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 15.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 16.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 2.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 3.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 4.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 5.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 6.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 7.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 8.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 9.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 9e.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
jisx0201.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
jisx0208.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
jisx0212.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
koi8 c.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
koi8 r.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
koi8 u.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
ksc5601.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
mac.H
Mac OS X-specific symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 942
math.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
mediumarrow.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
mulelao.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
names.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
print panel.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
slowarrow.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
spacing.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
symbol .h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
tatar cyr.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
tcvn.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
tis620.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
ucs2be.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
utf8.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
viscii.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
win32.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
202 CHAPTER 29. FILE INDEX
x.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Ximint.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Xlibint.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Xutf8.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Chapter 30
Module Documentation
Typedefs
• typedef void(∗ Fl Abort Handler )(const char ∗format,...)
Signature of set abort functions passed as parameters.
• typedef int(∗ Fl Args Handler )(int argc, char ∗∗argv, int &i)
Signature of args functions passed as parameters.
• typedef void(∗ Fl Atclose Handler )(Fl Window ∗window, void ∗data)
Signature of set atclose functions passed as parameters.
• typedef void(∗ Fl Awake Handler )(void ∗data)
Signature of some wakeup callback functions passed as parameters.
• typedef void( Fl Box Draw F )(int x, int y, int w, int h, Fl Color color)
Signature of some box drawing functions passed as parameters.
• typedef void(∗ Fl Clipboard Notify Handler )(int source, void ∗data)
Signature of add clipboard notify functions passed as parameters.
• typedef int(∗ Fl Event Dispatch )(int event, Fl Window ∗w)
Signature of event dispatch functions passed as parameters.
• typedef int(∗ Fl Event Handler )(int event)
Signature of add handler functions passed as parameters.
• typedef void(∗ Fl FD Handler )(FL SOCKET fd, void ∗data)
Signature of add fd functions passed as parameters.
• typedef void(∗ Fl Idle Handler )(void ∗data)
Signature of add idle callback functions passed as parameters.
• typedef void( Fl Label Draw F )(const Fl Label ∗label, int x, int y, int w, int h, Fl Align align)
Signature of some label drawing functions passed as parameters.
• typedef void( Fl Label Measure F )(const Fl Label ∗label, int &width, int &height)
Signature of some label measurement functions passed as parameters.
• typedef void(∗ Fl Old Idle Handler )()
Signature of set idle callback functions passed as parameters.
• typedef int(∗ Fl System Handler )(void ∗event, void ∗data)
Signature of add system handler functions passed as parameters.
• typedef void(∗ Fl Timeout Handler )(void ∗data)
Signature of some timeout callback functions passed as parameters.
203
204 CHAPTER 30. MODULE DOCUMENTATION
Functions
• static void Fl::default atclose (Fl Window ∗, void ∗)
Default callback for window widgets.
• static Fl Window ∗ Fl::first window ()
Returns the first top-level window in the list of shown() windows.
• static void Fl::first window (Fl Window ∗)
Sets the window that is returned by first window().
• static Fl Window ∗ Fl::grab ()
Returns the window that currently receives all events.
• static void Fl::grab (Fl Window ∗)
Selects the window to grab.
• static Fl Window ∗ Fl::modal ()
Returns the top-most modal() window currently shown.
• static Fl Window ∗ Fl::next window (const Fl Window ∗)
Returns the next top-level window in the list of shown() windows.
• static void Fl::set abort (Fl Abort Handler f)
For back compatibility, sets the void Fl::fatal handler callback.
• static void Fl::set atclose (Fl Atclose Handler f)
For back compatibility, sets the Fl::atclose handler callback.
Variables
• static void(∗ Fl::atclose )(Fl Window ∗, void ∗)
Back compatibility: default window callback handler.
Functions
• static void Fl::add handler (Fl Event Handler h)
Install a function to parse unrecognized events.
• static void Fl::add system handler (Fl System Handler h, void ∗data)
Install a function to intercept system events.
• static Fl Widget ∗ Fl::belowmouse ()
Gets the widget that is below the mouse.
• static void Fl::belowmouse (Fl Widget ∗)
Sets the widget that is below the mouse.
• static int Fl::compose (int &del)
Any text editing widget should call this for each FL KEYBOARD event.
• static void Fl::compose reset ()
If the user moves the cursor, be sure to call Fl::compose reset().
• static void Fl::disable im ()
Disables the system input methods facilities.
• static void Fl::enable im ()
Enables the system input methods facilities.
• static int Fl::event ()
Returns the last event that was processed.
• static int Fl::event alt ()
Returns non-zero if the Alt key is pressed.
• static int Fl::event button ()
Gets which particular mouse button caused the current event.
• static int Fl::event button1 ()
Returns non-zero if mouse button 1 is currently held down.
• static int Fl::event button2 ()
Returns non-zero if button 2 is currently held down.
• static int Fl::event button3 ()
Returns non-zero if button 3 is currently held down.
• static int Fl::event buttons ()
Returns the mouse buttons state bits; if non-zero, then at least one button is pressed now.
• static int Fl::event clicks ()
Returns non zero if we had a double click event.
• static void Fl::event clicks (int i)
Manually sets the number returned by Fl::event clicks().
• static void ∗ Fl::event clipboard ()
During an FL PASTE event of non-textual data, returns a pointer to the pasted data.
• static const char ∗ Fl::event clipboard type ()
Returns the type of the pasted data during an FL PASTE event.
• static int Fl::event command ()
Returns non-zero if the FL COMMAND key is pressed, either FL CTRL or on OSX FL META.
• static int Fl::event ctrl ()
208 CHAPTER 30. MODULE DOCUMENTATION
Variables
• const char ∗const fl eventnames [ ]
This is an array of event names you can use to convert event numbers into names.
• const char ∗const fl fontnames [ ]
This is an array of font names you can use to convert font numbers into names.
• FL SHORTCUT events that are not recognized by any widget. This lets you provide global shortcut
keys.
• FL SCREEN CONFIGURATION CHANGED events. Under X11, this event requires the libXrandr.-
so shared library to be loadable at run-time and the X server to implement the RandR extension.
• FL FULLSCREEN events sent to a window that enters of leaves fullscreen mode.
• System events that FLTK does not recognize. See fl xevent.
• Some other events when the widget FLTK selected returns zero from its handle() method. Exactly
which ones may change in future versions, however.
210 CHAPTER 30. MODULE DOCUMENTATION
See Also
Fl::remove handler(Fl Event Handler)
Fl::event dispatch(Fl Event Dispatch d)
Fl::handle(int, Fl Window∗)
void Fl::add system handler ( Fl System Handler ha, void ∗ data ) [static]
Install a function to intercept system events.
FLTK calls each of these functions as soon as a new system event is received. The processing will stop
at the first function to return non-zero. If all functions return zero then the event is passed on for normal
handling by FLTK.
Each function will be called with a pointer to the system event as the first argument and data as
the second argument. The system event pointer will always be void ∗, but will point to different objects
depending on the platform:
• X11: XEvent
• Windows: MSG
• OS X: NSEvent
Parameters
ha The event handler function to register
data User data to include on each call
See Also
Fl::remove system handler(Fl System Handler)
If false is returned, the keys should be treated as function keys, and del is set to zero. You could insert
the text anyways, if you don’t know what else to do.
On the Mac OS platform, text input can involve marked text, that is, temporary text replaced by other
text during the input process. This occurs, e.g., when using dead keys or when entering CJK charac-
ters. Text editing widgets should preferentially signal marked text, usually underlining it. Widgets can
use int Fl::compose state after having called Fl::compose(int&) to obtain the length in bytes of
marked text that always finishes at the current insertion point. It’s the widget’s task to underline marked
text. Widgets should also call void Fl::reset marked text() when processing FL UNFOCUS
events. Optionally, widgets can also call void Fl::insertion point location(int x, int
y, int height) to indicate the window coordinates of the bottom of the current insertion point and
the line height. This way, auxiliary windows that help choosing among alternative characters appear just
below the insertion point. If widgets don’t do that, auxiliary windows appear at the widget’s bottom. The
Fl Input and Fl Text Editor widgets underline marked text. If none of this is done by a user-defined text
editing widget, text input will work, but will not signal to the user what text is marked. Finally, text editing
widgets should call set flag(MAC USE ACCENTS MENU); in their constructor if they want to use the
feature introduced with Mac OS 10.7 ”Lion” where pressing and holding a key on the keyboard opens an
accented-character menu window.
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 characters to be selected.
Return values
FL LEFT MOUSE
FL MIDDLE MOUSE
FL RIGHT MOUSE.
See Also
Fl::event buttons()
See Also
int event clicks()
main() {
Fl::event dispatch(myHandler);
...
Fl::run();
}
Parameters
d new dispatch function, or NULL
See Also
Fl::add handler(Fl Event Handler)
Fl::handle(int, Fl Window∗)
Fl::handle (int, Fl Window∗)
214 CHAPTER 30. MODULE DOCUMENTATION
int Fl::event inside ( int xx, int yy, int ww, int hh ) [static]
Returns whether or not the mouse event is inside the given rectangle.
Returns non-zero if the current Fl::event x() and Fl::event y() put it inside the given arbitrary bounding
box.
You should always call this rather than doing your own comparison so you are consistent about edge
effects.
To find out, whether the event is inside a child widget of the current window, you can use Fl::event -
inside(const Fl Widget ∗).
Parameters
in xx,yy,ww,hh bounding box
Returns
non-zero, if mouse event is inside
Note
The mentioned restrictions are necessary, because this method does not transform coordinates of child
widgets, and thus the given widget o must be within the same window that is handling the current
event. Otherwise the results are undefined.
You should always call this rather than doing your own comparison so you are consistent about edge effects.
See Also
Fl::event inside(int, int, int, int)
Parameters
in o child widget to be tested
Returns
non-zero, if mouse event is inside the widget
30.3. EVENTS HANDLING FUNCTIONS 215
See Also
int event key(int), event text(), compose(int&).
• All keys on the main keyboard producing a printable ASCII character use the value of that ASCII
character (as though shift, ctrl, and caps lock were not on). The space bar is 32.
• All keys on the numeric keypad producing a printable ASCII character use the value of that ASCII
character plus FL KP. The highest possible value is FL KP Last so you can range-check to see if
something is on the keypad.
• All numbered function keys use the number on the function key plus FL F. The highest possible
number is FL F Last, so you can range-check a value.
• Buttons on the mouse are considered keys, and use the button number (where the left button is 1)
plus FL Button.
• All other keys on the keypad have a symbol: FL Escape, FL BackSpace, FL Tab, FL Enter, FL -
Print, FL Scroll Lock, FL Pause, FL Insert, FL Home, FL Page Up, FL Delete, FL End, FL Page-
Down, FL Left, FL Up, FL Right, FL Down, FL Iso Key, FL Shift L, FL Shift R, FL Control L,
FL Control R, FL Caps Lock, FL Alt L, FL Alt R, FL Meta L, FL Meta R, FL Menu, FL Num -
Lock, FL KP Enter. Be careful not to confuse these with the very similar, but all-caps, symbols used
by Fl::event state().
Parameters
e the event type (Fl::event number() is not yet set)
window the window that caused this event
Returns
0 if the event was not handled
See Also
Fl::add handler(Fl Event Handler)
Fl::event dispatch(Fl Event Dispatch)
Returns
0 if the event was not handled
See Also
Fl::event dispatch(Fl Event Dispatch)
Parameters
ha The event handler function to remove
See Also
Fl::add system handler(Fl System Handler)
Tests the current event, which must be an FL KEYBOARD or FL SHORTCUT, against a shortcut value
(described in Fl Button).
Not to be confused with Fl Widget::test shortcut().
Returns
non-zero if there is a match.
Initial value:
=
{
"FL NO EVENT",
"FL PUSH",
"FL RELEASE",
"FL ENTER",
"FL LEAVE",
"FL DRAG",
"FL FOCUS",
"FL UNFOCUS",
"FL KEYDOWN",
"FL KEYUP",
"FL CLOSE",
"FL MOVE",
"FL SHORTCUT",
"FL DEACTIVATE",
"FL ACTIVATE",
"FL HIDE",
"FL SHOW",
"FL PASTE",
"FL SELECTIONCLEAR",
"FL MOUSEWHEEL",
"FL DND ENTER",
"FL DND DRAG",
"FL DND LEAVE",
"FL DND RELEASE",
"FL SCREEN CONFIGURATION CHANGED",
"FL FULLSCREEN"
}
This is an array of event names you can use to convert event numbers into names.
The array gets defined inline wherever your ’#include <FL/names.h>’ appears.
Example:
This is an array of font names you can use to convert font numbers into names.
The array gets defined inline wherever your ’#include <FL/names.h>’ appears.
Example:
#include <FL/names.h> // array will be defined here
int MyClass::my callback(Fl Widget *w, void*) {
int fnum = w->labelfont();
// Resulting output might be e.g. "Label’s font is FL HELVETICA (0)"
printf("Label’s font is %s (%d)\n", fl fontnames[fnum], fnum);
// ..resulting output might be e.g. "Label’s font is FL HELVETICA (0)"..
[..]
}
30.4. SELECTION & CLIPBOARD FUNCTIONS 221
Functions
• static void Fl::add clipboard notify (Fl Clipboard Notify Handler h, void ∗data=0)
FLTK will call the registered callback whenever there is a change to the selection buffer or the clipboard.
• static int Fl::clipboard contains (const char ∗type)
Returns non 0 if the clipboard contains data matching type.
• static void Fl::copy (const char ∗stuff, int len, int destination=0, const char ∗type=Fl::clipboard -
plain text)
Copies the data pointed to by stuff to the selection buffer (destination is 0) or the clipboard
(destination is 1).
• static int Fl::dnd ()
Initiate a Drag And Drop operation.
• static void Fl::paste (Fl Widget &receiver, int source, const char ∗type=Fl::clipboard plain text)
Pastes the data from the selection buffer (source is 0) or the clipboard (source is 1) into receiver.
• static void Fl::paste (Fl Widget &receiver)
Backward compatibility only.
• static void Fl::remove clipboard notify (Fl Clipboard Notify Handler h)
Stop calling the specified callback when there are changes to the selection buffer or the clipboard.
• static void Fl::selection (Fl Widget &owner, const char ∗, int len)
Changes the current selection.
• static Fl Widget ∗ Fl::selection owner ()
back-compatibility only: Gets the widget owning the current selection
• static void Fl::selection owner (Fl Widget ∗)
Back-compatibility only: The single-argument call can be used to move the selection to another widget or
to set the owner to NULL, without changing the actual text of the selection.
Variables
• static char const ∗const Fl::clipboard image = ”image”
Denotes image data.
• static char const ∗const Fl::clipboard plain text = ”text/plain”
Denotes plain textual data.
Note
Some systems require polling to monitor the clipboard and may therefore have some delay in detect-
ing changes.
static void Fl::copy ( const char ∗ stuff, int len, int destination = 0, const char ∗ type =
Fl::clipboard plain text ) [static]
Copies the data pointed to by stuff to the selection buffer (destination is 0) or the clipboard
(destination is 1).
len is the number of relevant bytes in stuff. type is always Fl::clipboard plain text. The selec-
tion buffer is used for middle-mouse pastes and for drag-and-drop selections. The clipboard is used for
traditional copy/cut/paste operations.
Note
This function is, at present, intended only to copy UTF-8 encoded textual data. To copy graphical
data, use the Fl Copy Surface class. The type argument may allow in the future to copy other kinds
of data.
static void Fl::paste ( Fl Widget & receiver, int source, const char ∗ type = Fl::clipboard plain text
) [static]
Pastes the data from the selection buffer (source is 0) or the clipboard (source is 1) into receiver.
If source is 1, the optional type argument indicates what type of data is requested from the clipboard
(at present, Fl::clipboard plain text - requesting text data - and Fl::clipboard image - requesting image data
- are possible). Set things up so the handle function of the receiver widget will be called with an F-
L PASTE event some time in the future if the clipboard does contain data of the requested type. During
processing of this event, and if type is Fl::clipboard plain text, the text data from the specified source
are in Fl::event text() with UTF-8 encoding, and the number of characters in Fl::event length(); if type
is Fl::clipboard image, Fl::event clipboard() returns a pointer to the image data, as an Fl Image ∗. The
receiver 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 in FLTK.
The selection buffer is used for middle-mouse pastes and for drag-and-drop selections. The clipboard
is used for traditional copy/cut/paste operations.
30.4. SELECTION & CLIPBOARD FUNCTIONS 223
• Unix/Linux platform: Image data in PNG or BMP formats are recognized. Requires linking with
the fltk images library.
• MSWindows platform: Both bitmap and vectorial (Enhanced metafile) data from clipboard can
be pasted as image data.
• Mac OS X platform: Both bitmap (TIFF) and vectorial (PDF) data from clipboard can be pasted
as image data.
void Fl::selection ( Fl Widget & owner, const char ∗ text, int len ) [static]
Changes the current selection.
The block of text is copied to an internal buffer by FLTK (be careful if doing this in response to an
FL PASTE as this may be the same buffer returned by event text()). The selection owner() widget is set to
the passed owner.
Functions
• static int Fl::h ()
Returns the height in pixels of the main screen work area.
• static int Fl::screen count ()
Gets the number of available screens.
• static void Fl::screen dpi (float &h, float &v, int n=0)
Gets the screen resolution in dots-per-inch for the given screen.
• static int Fl::screen num (int x, int y)
Gets the screen number of a screen that contains the specified screen position x, y.
• static int Fl::screen num (int x, int y, int w, int h)
Gets the screen number for the screen which intersects the most with the rectangle defined by x, y, w, h.
• static void Fl::screen work area (int &X, int &Y, int &W, int &H, int mx, int my)
Gets the bounding box of the work area of a screen that contains the specified screen position mx, my.
• static void Fl::screen work area (int &X, int &Y, int &W, int &H, int n)
Gets the bounding box of the work area of the given screen.
• static void Fl::screen work area (int &X, int &Y, int &W, int &H)
Gets the bounding box of the work area of the screen that contains the mouse pointer.
• static void Fl::screen xywh (int &X, int &Y, int &W, int &H)
Gets the bounding box of a screen that contains the mouse pointer.
• static void Fl::screen xywh (int &X, int &Y, int &W, int &H, int mx, int my)
Gets the bounding box of a screen that contains the specified screen position mx, my.
• static void Fl::screen xywh (int &X, int &Y, int &W, int &H, int n)
Gets the screen bounding rect for the given screen.
• static void Fl::screen xywh (int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh)
Gets the screen bounding rect for the screen which intersects the most with the rectangle defined by mx, my,
mw, mh.
• static int Fl::w ()
Returns the width in pixels of the main screen work area.
• static int Fl::x ()
Returns the leftmost x coordinate of the main screen work area.
• static int Fl::y ()
Returns the topmost y coordinate of the main screen work area.
Parameters
out h,v horizontal and vertical resolution
in n the screen number (0 to Fl::screen count() - 1)
See Also
void screen xywh(int &x, int &y, int &w, int &h, int mx, int my)
void Fl::screen work area ( int & X, int & Y, int & W, int & H, int mx, int my ) [static]
Gets the bounding box of the work area of a screen that contains the specified screen position mx, my.
Parameters
out X,Y,W,H the work area bounding box
in mx,my the absolute screen position
void Fl::screen work area ( int & X, int & Y, int & W, int & H, int n ) [static]
Gets the bounding box of the work area of the given screen.
Parameters
out X,Y,W,H the work area bounding box
in n the screen number (0 to Fl::screen count() - 1)
See Also
void screen xywh(int &x, int &y, int &w, int &h, int mx, int my)
static void Fl::screen work area ( int & X, int & Y, int & W, int & H ) [inline], [static]
Gets the bounding box of the work area of the screen that contains the mouse pointer.
Parameters
out X,Y,W,H the work area bounding box
See Also
void screen work area(int &x, int &y, int &w, int &h, int mx, int my)
226 CHAPTER 30. MODULE DOCUMENTATION
static void Fl::screen xywh ( int & X, int & Y, int & W, int & H ) [inline], [static]
Gets the bounding box of a screen that contains the mouse pointer.
30.5. SCREEN FUNCTIONS 227
Parameters
out X,Y,W,H the corresponding screen bounding box
See Also
void screen xywh(int &x, int &y, int &w, int &h, int mx, int my)
void Fl::screen xywh ( int & X, int & Y, int & W, int & H, int mx, int my ) [static]
Gets the bounding box of a screen that contains the specified screen position mx, my.
Parameters
out X,Y,W,H the corresponding screen bounding box
in mx,my the absolute screen position
void Fl::screen xywh ( int & X, int & Y, int & W, int & H, int n ) [static]
Gets the screen bounding rect for the given screen.
Under MSWindows, Mac OS X, and the Gnome desktop, screen #0 contains the menubar/taskbar
Parameters
out X,Y,W,H the corresponding screen bounding box
in n the screen number (0 to Fl::screen count() - 1)
See Also
void screen xywh(int &x, int &y, int &w, int &h, int mx, int my)
void Fl::screen xywh ( int & X, int & Y, int & W, int & H, int mx, int my, int mw, int mh )
[static]
Gets the screen bounding rect for the screen which intersects the most with the rectangle defined by mx,
my, mw, mh.
Parameters
out X,Y,W,H the corresponding screen bounding box
in mx,my,mw,mh the rectangle to search for intersection with
See Also
void screen xywh(int &X, int &Y, int &W, int &H, int n)
Functions
• void fl color (Fl Color c)
Sets the color for all subsequent drawing operations.
• void fl color (int c)
for back compatibility - use fl color(Fl Color c) instead
• void fl color (uchar r, uchar g, uchar b)
Sets the color for all subsequent drawing operations.
• Fl Color fl color ()
Returns the last fl color() that was set.
• Fl Color fl color average (Fl Color color1, Fl Color color2, float weight)
Returns the weighted average color between the two given colors.
• Fl Color fl contrast (Fl Color fg, Fl Color bg)
Returns a color that contrasts with the background color.
• int fl descent ()
Returns the recommended distance above the bottom of a fl height() tall box to draw the text at so it looks
centered vertically in that box.
• void fl font (Fl Font face, Fl Fontsize fsize)
Sets the current font, which is then used in various drawing routines.
• Fl Font fl font ()
Returns the face set by the most recent call to fl font().
• int fl height ()
Returns the recommended minimum line spacing for the current font.
• FL EXPORT int fl height (int font, int size)
This function returns the actual height of the specified font and size.
• Fl Color fl inactive (Fl Color c)
Returns the inactive, dimmed version of the given color.
• FL EXPORT const char ∗ fl latin1 to local (const char ∗t, int n=-1)
Converts text from Windows/X11 latin1 character set to local encoding.
• FL EXPORT const char ∗ fl local to latin1 (const char ∗t, int n=-1)
Converts text from local encoding to Windowx/X11 latin1 character set.
• FL EXPORT const char ∗ fl local to mac roman (const char ∗t, int n=-1)
Converts text from local encoding to Mac Roman character set.
• FL EXPORT const char ∗ fl mac roman to local (const char ∗t, int n=-1)
Converts text from Mac Roman character set to local encoding.
• FL EXPORT Fl Color fl show colormap (Fl Color oldcol)
Pops up a window to let the user pick a colormap entry.
• Fl Fontsize fl size ()
Returns the size set by the most recent call to fl font().
• FL EXPORT void fl text extents (const char ∗, int &dx, int &dy, int &w, int &h)
Determines the minimum pixel dimensions of a nul-terminated string.
• void fl text extents (const char ∗t, int n, int &dx, int &dy, int &w, int &h)
Determines the minimum pixel dimensions of a sequence of n characters.
• FL EXPORT double fl width (const char ∗txt)
30.6. COLOR & FONT FUNCTIONS 229
Returns the typographical width of a nul-terminated string using the current font face and size.
• double fl width (const char ∗txt, int n)
Returns the typographical width of a sequence of n characters using the current font face and size.
• double fl width (unsigned int c)
Returns the typographical width of a single character using the current font face and size.
• ulong fl xpixel (uchar r, uchar g, uchar b)
Returns the X pixel number used to draw the given rgb color.
• ulong fl xpixel (Fl Color i)
Returns the X pixel number used to draw the given FLTK color index.
• static void Fl::free color (Fl Color i, int overlay=0)
Frees the specified color from the colormap, if applicable.
• static unsigned Fl::get color (Fl Color i)
Returns the RGB value(s) for the given FLTK color index.
• static void Fl::get color (Fl Color i, uchar &red, uchar &green, uchar &blue)
Returns the RGB value(s) for the given FLTK color index.
• static const char ∗ Fl::get font (Fl Font)
Gets the string for this face.
• static const char ∗ Fl::get font name (Fl Font, int ∗attributes=0)
Get a human-readable string describing the family of this face.
• static int Fl::get font sizes (Fl Font, int ∗&sizep)
Return an array of sizes in sizep.
• static void Fl::set color (Fl Color, uchar, uchar, uchar)
Sets an entry in the fl color index table.
• static void Fl::set color (Fl Color i, unsigned c)
Sets an entry in the fl color index table.
• static void Fl::set font (Fl Font, const char ∗)
Changes a face.
• static void Fl::set font (Fl Font, Fl Font)
Copies one face to another.
• static Fl Font Fl::set fonts (const char ∗=0)
FLTK will open the display, and add every fonts on the server to the face table.
Parameters
in c color
Thus, a weight value of 1.0 will return the first color, while a value of 0.0 will return the second color.
Parameters
in color1,color2 boundary colors
in weight weighting factor
Returns
contrasting color
Todo In the future, when the XFT issues are resolved, this function should simply return the ’size’ value.
Returns
pointer to internal buffer containing converted characters
Returns
pointer to internal buffer containing converted characters
Parameters
in t character string (local encoding)
in n optional number of characters to convert (default is all)
Returns
pointer to internal buffer containing converted characters
Returns
pointer to internal buffer containing converted characters
Parameters
in oldcol color to be highlighted when grid is shown.
Return values
Fl Color value of the chosen colormap entry.
See Also
Fl Color Chooser
FL EXPORT void fl text extents ( const char ∗ , int & dx, int & dy, int & w, int & h )
Determines the minimum pixel dimensions of a nul-terminated string.
Usage: given a string ”txt” drawn using fl draw(txt, x, y) you would determine its pixel extents on the
display using fl text extents(txt, dx, dy, wo, ho) such that a bounding box that exactly fits around the text
could be drawn with fl rect(x+dx, y+dy, wo, ho). Note the dx, dy values hold the offset of the first ”colored
in” pixel of the string, from the draw origin.
No FLTK symbol expansion will be performed.
void fl text extents ( const char ∗ t, int n, int & dx, int & dy, int & w, int & h ) [inline]
Determines the minimum pixel dimensions of a sequence of n characters.
See Also
fl text extents(const char∗, int& dx, int& dy, int& w, int& h)
Parameters
in r,g,b color components
Returns
X pixel number
Returns
X pixel number
void Fl::get color ( Fl Color i, uchar & red, uchar & green, uchar & blue ) [static]
Returns the RGB value(s) for the given FLTK color index.
This form returns the red, green, and blue values separately in referenced variables.
See also unsigned get color(Fl Color c)
const char ∗ Fl::get font name ( Fl Font fnum, int ∗ attributes = 0 ) [static]
Get a human-readable string describing the family of this face.
This is useful if you are presenting a choice to the user. There is no guarantee that each face has a
different name. The return value points to a static buffer that is overwritten each call.
The integer pointed to by attributes (if the pointer is not zero) is set to zero, FL BOLD or FL I-
TALIC or FL BOLD | FL ITALIC. To locate a ”family” of fonts, search forward and back for a set with
non-zero attributes, these faces along with the face with a zero attribute before them constitute a family.
30.6. COLOR & FONT FUNCTIONS 235
int Fl::get font sizes ( Fl Font fnum, int ∗& sizep ) [static]
Return an array of sizes in sizep.
The return value is the length of this array. The sizes are sorted from smallest to largest and indicate
what sizes can be given to fl font() that will be matched exactly (fl font() will pick the closest size for other
sizes). A zero in the first location of the array indicates a scalable font, where any size works, although the
array may list sizes that work ”better” than others. Warning: the returned array points at a static buffer that
is overwritten each call. Under X this will open the display.
void Fl::set color ( Fl Color i, uchar red, uchar green, uchar blue ) [static]
Sets an entry in the fl color index table.
You can set it to any 8-bit RGB color. The color is not allocated until fl color(i) is used.
Macros
• #define fl clip fl push clip
Intersects the current clip region with a rectangle and pushes this new region onto the stack (deprecated).
Enumerations
• enum {
FL SOLID = 0, FL DASH = 1, FL DOT = 2, FL DASHDOT = 3,
FL DASHDOTDOT = 4, FL CAP FLAT = 0x100, FL CAP ROUND = 0x200, FL CAP SQUARE
= 0x300,
FL JOIN MITER = 0x1000, FL JOIN ROUND = 0x2000, FL JOIN BEVEL = 0x3000 }
Functions
• void Fl Quartz Graphics Driver::copy offscreen (int x, int y, int w, int h, Fl Offscreen pixmap,
int srcx, int srcy)
• FL EXPORT int fl add symbol (const char ∗name, void(∗drawit)(Fl Color), int scalable)
Adds a symbol to the system.
• void fl arc (int x, int y, int w, int h, double a1, double a2)
Draw ellipse sections using integer coordinates.
• void fl arc (double x, double y, double r, double start, double end)
Adds a series of points to the current path on the arc of a circle.
• void fl begin complex polygon ()
Starts drawing a complex filled polygon.
• void fl begin line ()
Starts drawing a list of lines.
• void fl begin loop ()
Starts drawing a closed sequence of lines.
• void fl begin offscreen (Fl Offscreen ctx)
Send all subsequent drawing commands to this offscreen buffer.
• void fl begin points ()
Starts drawing a list of points.
• void fl begin polygon ()
Starts drawing a convex filled polygon.
• FL EXPORT char fl can do alpha blending ()
Checks whether platform supports true alpha blending for RGBA images.
• FL EXPORT void fl chord (int x, int y, int w, int h, double a1, double a2)
fl chord declaration is a place holder - the function does not yet exist
• void fl circle (double x, double y, double r)
fl circle() is equivalent to fl arc(x,y,r,0,360), but may be faster.
• int fl clip box (int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
Intersects the rectangle with the current clip region and returns the bounding box of the result.
• void fl clip region (Fl Region r)
Replaces the top of the clipping stack with a clipping region of any shape.
30.7. DRAWING FUNCTIONS 237
• void fl pie (int x, int y, int w, int h, double a1, double a2)
Draw filled ellipse sections using integer coordinates.
• void fl point (int x, int y)
Draws a single pixel at the given coordinates.
• void fl polygon (int x, int y, int x1, int y1, int x2, int y2)
Fills a 3-sided polygon.
• void fl polygon (int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)
Fills a 4-sided polygon.
• void fl pop clip ()
Restores the previous clip region.
• void fl pop matrix ()
Restores the current transformation matrix from the stack.
• void fl push clip (int x, int y, int w, int h)
Intersects the current clip region with a rectangle and pushes this new region onto the stack.
• void fl push matrix ()
Saves the current transformation matrix on the stack.
• void fl push no clip ()
Pushes an empty clip region onto the stack so nothing will be clipped.
• FL EXPORT uchar ∗ fl read image (uchar ∗p, int X, int Y, int W, int H, int alpha=0)
Reads an RGB(A) image from the current window or off-screen buffer.
• void fl rect (int x, int y, int w, int h)
Draws a 1-pixel border inside the given bounding box.
• void fl rect (int x, int y, int w, int h, Fl Color c)
Draws with passed color a 1-pixel border inside the given bounding box.
• void fl rectf (int x, int y, int w, int h)
Colors with current color a rectangle that exactly fills the given bounding box.
• void fl rectf (int x, int y, int w, int h, Fl Color c)
Colors with passed color a rectangle that exactly fills the given bounding box.
• FL EXPORT void fl rectf (int x, int y, int w, int h, uchar r, uchar g, uchar b)
Colors a rectangle with ”exactly” the passed r,g,b color.
• FL EXPORT void fl reset spot (void)
• void fl restore clip ()
Undoes any clobbering of clip done by your program.
• void fl rotate (double d)
Concatenates rotation transformation onto the current one.
• void fl rtl draw (const char ∗str, int n, int x, int y)
Draws a UTF-8 string of length n bytes right to left starting at the given x, y location.
• void fl scale (double x, double y)
Concatenates scaling transformation onto the current one.
• void fl scale (double x)
Concatenates scaling transformation onto the current one.
• FL EXPORT void fl scroll (int X, int Y, int W, int H, int dx, int dy, void(∗draw area)(void ∗, int, int,
int, int), void ∗data)
Scroll a rectangle and draw the newly exposed portions.
• FL EXPORT void fl set spot (int font, int size, int X, int Y, int W, int H, Fl Window ∗win=0)
• FL EXPORT void fl set status (int X, int Y, int W, int H)
• FL EXPORT const char ∗ fl shortcut label (unsigned int shortcut)
240 CHAPTER 30. MODULE DOCUMENTATION
Variables
• const int stack max = 16
Parameters
in x,y,w,h position and size
Deprecated fl clip(int, int, int, int) is deprecated and will be removed from future releases. Please use
fl push clip(int x, int y, int w, int h) instead.
Returns
1 on success, 0 on failure
void fl arc ( int x, int y, int w, int h, double a1, double a2 ) [inline]
Draw ellipse sections using integer coordinates.
These functions match the rather limited circle drawing code provided by X and WIN32. The advantage
over using fl arc with floating point coordinates is that they are faster because they often use the hardware,
and they draw much nicer small circles, since the small sizes are often hard-coded bitmaps.
If a complete circle is drawn it will fit inside the passed bounding box. The two angles are measured
in degrees counter-clockwise from 3 o’clock and are the starting and ending angle of the arc, a2 must be
greater or equal to a1.
fl arc() draws a series of lines to approximate the arc. Notice that the integer version of fl arc() has
a different number of arguments than the double version fl arc(double x, double y, double r, double start,
double end)
242 CHAPTER 30. MODULE DOCUMENTATION
Parameters
in x,y,w,h bounding box of complete circle
in a1,a2 start and end angles of arc measured in degrees counter-clockwise from
3 o’clock. a2 must be greater than or equal to a1.
void fl arc ( double x, double y, double r, double start, double end ) [inline]
Adds a series of points to the current path on the arc of a circle.
You can get elliptical paths by using scale and rotate before calling fl arc().
Parameters
in x,y,r center and radius of circular arc
in start,end angles of start and end of arc measured in degrees counter-clockwise
from 3 o’clock. If end is less than start then it draws the arc in a
clockwise direction.
Examples:
// Draw an arc of points
fl begin points();
fl arc(100.0, 100.0, 50.0, 0.0, 180.0);
fl end points();
Note
For portability, you should only draw polygons that appear the same whether ”even/odd” or ”non-
zero” winding rules are used to fill them. Holes should be drawn in the opposite direction to the
outside loop.
int fl clip box ( int x, int y, int w, int h, int & X, int & Y, int & W, int & H ) [inline]
Intersects the rectangle with the current clip region and returns the bounding box of the result.
Returns non-zero if the resulting rectangle is different to the original. This can be used to limit the
necessary drawing to a rectangle. W and H are set to zero if the rectangle is completely outside the region.
Parameters
in x,y,w,h position and size of rectangle
out X,Y,W,H position and size of resulting bounding box.
Returns
Non-zero if the resulting rectangle is different to the original.
void fl copy offscreen ( int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy )
Copy a rectangular area of the given offscreen buffer into the current drawing destination.
Parameters
x,y position where to draw the copied rectangle
w,h size of the copied rectangle
pixmap offscreen buffer containing the rectangle to copy
srcx,srcy origin in offscreen buffer of rectangle to copy
Parameters
w,h width and height in pixels of the buffer.
Returns
the created graphics buffer.
void fl curve ( double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3,
double Y3 ) [inline]
Adds a series of points on a Bezier curve to the path.
The curve ends (and two of the points) are at X0,Y0 and X3,Y3.
Parameters
in X0,Y0 curve start point
in X1,Y1 curve control point
in X2,Y2 curve control point
in X3,Y3 curve end point
FL EXPORT void fl draw ( int angle, const char ∗ str, int x, int y )
Draws a nul-terminated UTF-8 string starting at the given x, y location and rotating angle degrees
counter-clockwise.
This version of fl draw provides direct access to the text drawing function of the underlying OS and is
supported by Xft, Win32 and MacOS fltk subsets.
FL EXPORT void fl draw ( const char ∗ str, int x, int y, int w, int h, Fl Align align, Fl Image ∗
img, int draw symbols )
Fancy string drawing function which is used to draw all the labels.
The string is formatted and aligned inside the passed box. Handles ’\t’ and ’\n’, expands all other
control characters to ’∧ X’, and aligns inside or against the edges of the box. See Fl Widget::align() for
values of align. The value FL ALIGN INSIDE is ignored, as this function always prints inside the box.
30.7. DRAWING FUNCTIONS 245
If img is provided and is not NULL, the image is drawn above or below the text as specified by the align
value. The draw symbols argument specifies whether or not to look for symbol names starting with the
’@’ character’
FL EXPORT void fl draw box ( Fl Boxtype t, int x, int y, int w, int h, Fl Color c )
Draws a box using given type, position, size and color.
Parameters
in t box type
in x,y,w,h position and size
in c color
void fl draw image ( const uchar ∗ buf, int X, int Y, int W, int H, int D = 3, int L = 0 )
[inline]
Draws an 8-bit per color RGB or luminance image.
Parameters
in buf points at the ”r” data of the top-left pixel. Color data must be in r,g,b
order. Luminance data is only one gray byte.
in X,Y position where to put top-left corner of image
in W,H size of the image
in D delta to add to the pointer between pixels. It may be any value greater
than or equal to 1, or it can be negative to flip the image horizontally
in L delta to add to the pointer between lines (if 0 is passed it uses W ∗ D),
and may be larger than W ∗ D to crop data, or negative to flip the image
vertically
It is highly recommended that you put the following code before the first show() of any window in your
program to get rid of the dithering if possible:
Fl::visual(FL RGB);
Gray scale (1-channel) images may be drawn. This is done if abs(D) is less than 3, or by calling fl -
draw image mono(). Only one 8-bit sample is used for each pixel, and on screens with different numbers
of bits for red, green, and blue only gray colors are used. Setting D greater than 1 will let you display one
channel of a color image.
Note:
The X version does not support all possible visuals. If FLTK cannot draw the image in the current
visual it will abort. FLTK supports any visual of 8 bits or less, and all common TrueColor visuals up
to 32 bits.
void fl draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int Y, int W, int H, int D = 3 )
[inline]
Draws an image using a callback function to generate image data.
You can generate the image as it is being drawn, or do arbitrary decompression of stored data, provided
it can be decompressed to individual scan lines easily.
246 CHAPTER 30. MODULE DOCUMENTATION
Parameters
in cb callback function to generate scan line data
in data user data passed to callback function
in X,Y screen position of top left pixel
in W,H image width and height
in D data size in bytes (must be greater than 0)
See Also
fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L)
The callback function cb is called with the void∗ data user data pointer to allow access to a structure
of information about the image, and the x, y, and w of the scan line desired from the image. 0,0 is the
upper-left corner of the image, not x, y. A pointer to a buffer to put the data into is passed. You must copy
w pixels from scanline y, starting at pixel x, to this buffer.
Due to cropping, less than the whole image may be requested. So x may be greater than zero, the first
y may be greater than zero, and w may be less than W. The buffer is long enough to store the entire W ∗ D
pixels, this is for convenience with some decompression schemes where you must decompress the entire
line at once: decompress it into the buffer, and then if x is not zero, copy the data over so the x’th pixel
is at the start of the buffer.
You can assume the y’s will be consecutive, except the first one may be greater than zero.
If D is 4 or more, you must fill in the unused bytes with zero.
void fl draw image mono ( const uchar ∗ buf, int X, int Y, int W, int H, int D = 1, int L = 0 )
[inline]
Draws a gray-scale (1 channel) image.
See Also
fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L)
void fl draw image mono ( Fl Draw Image Cb cb, void ∗ data, int X, int Y, int W, int H, int D =
1 ) [inline]
Draws a gray-scale image using a callback function to generate image data.
See Also
fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D)
FL EXPORT int fl draw pixmap ( char ∗const ∗ data, int x, int y, Fl Color bg )
Draw XPM image data, with the top-left corner at the given position.
The image is dithered on 8-bit displays so you won’t lose color space for programs displaying both
images and pixmaps.
Parameters
in data pointer to XPM image data
in x,y position of top-left corner
30.7. DRAWING FUNCTIONS 247
in bg background color
Returns
0 if there was any error decoding the XPM data.
FL EXPORT int fl draw pixmap ( const char ∗const ∗ cdata, int x, int y, Fl Color bg )
Draw XPM image data, with the top-left corner at the given position.
See Also
fl draw pixmap(char∗ const∗ data, int x, int y, Fl Color bg)
FL EXPORT int fl draw symbol ( const char ∗ label, int x, int y, int w, int h, Fl Color col )
Draw the named symbol in the given rectangle using the given color.
Parameters
in label name of symbol
in x,y position of symbol
in w,h size of symbol
in col color of symbox
Returns
1 on success, 0 on failure
FL EXPORT const char∗ fl expand text ( const char ∗ from, char ∗ buf, int maxbuf, double maxw,
int & n, double & width, int wrap, int draw symbols )
Copy from to buf, replacing control characters with ∧ X.
Stop at a newline or if maxbuf characters written to buffer. Also word-wrap if width exceeds maxw.
Returns a pointer to the start of the next line of characters. Sets n to the number of characters put into the
buffer. Sets width to the width of the string in the current font.
Parameters
in s sets of 4 grayscale values in bottom, right, top, left order
in x,y,w,h position and size
void fl line style ( int style, int width = 0, char ∗ dashes = 0 ) [inline]
Sets how to draw lines (the ”pen”).
If you change this it is your responsibility to set it back to the default using fl line style(0).
Parameters
in style A bitmask which is a bitwise-OR of a line style, a cap style, and a join
style. If you don’t specify a dash type you will get a solid line. If you
don’t specify a cap or join type you will get a system-defined default of
whatever value is fastest.
in width The thickness of the lines in pixels. Zero results in the system defined
default, which on both X and Windows is somewhat different and nicer
than 1.
in dashes A pointer to an array of dash lengths, measured in pixels. The first lo-
cation 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.
Note
Because of how line styles are implemented on Win32 systems, you must set the line style after
setting the drawing color. If you set the color after the line style you will lose the line style settings.
The dashes array does not work under Windows 95, 98 or Me, since those operating systems do
not support complex line styles.
FL EXPORT void fl measure ( const char ∗ str, int & w, int & h, int draw symbols )
Measure how wide and tall the string will be when printed by the fl draw() function with align parameter.
If the incoming w is non-zero it will wrap to that width.
The ’current font’ is used to do the width/height calculations, so unless its value is known at the time
fl measure() is called, it is advised to first set the current font with fl font().
Note: In the general use case, it’s a common error to forget to set w to 0 before calling fl measure()
when wrap behavior isn’t needed.
Parameters
in str nul-terminated string
out w,h width and height of string in current font
30.7. DRAWING FUNCTIONS 249
FL EXPORT int fl measure pixmap ( char ∗const ∗ data, int & w, int & h )
Get the dimensions of a pixmap.
An XPM image contains the dimensions in its data. This function returns the width and height.
Parameters
in data pointer to XPM image data.
out w,h width and height of image
Returns
non-zero if the dimensions were parsed OK
0 if there were any problems
FL EXPORT int fl measure pixmap ( const char ∗const ∗ cdata, int & w, int & h )
Get the dimensions of a pixmap.
See Also
fl measure pixmap(char∗ const∗ data, int &w, int &h)
void fl mult matrix ( double a, double b, double c, double d, double x, double y ) [inline]
Concatenates another transformation onto the current one.
Parameters
in a,b,c,d,x,y transformation matrix elements such that X’ = aX + cY + x and
Y’ = bX +dY + y
Returns
non-zero if any of the rectangle intersects the current clip region. If this returns 0 you don’t have to
draw the object.
Note
Under X this returns 2 if the rectangle is partially clipped, and 1 if it is entirely inside the clip region.
250 CHAPTER 30. MODULE DOCUMENTATION
These special characters can be combined to form chords of modifier keys. (See ’Remarks’ below)
After the optional modifier key prefixes listed above, one can either specify a single keyboard character
to use as the shortcut, or a numeric sequence in hex, decimal or octal.
Examples:
"c" -- Uses ’c’ as the shortcut
"#ˆc" -- Same as FL_ALT|FL_CTRL|’c’
"#ˆ!c" -- Same as FL_ALT|FL_CTRL|FL_META|’c’
"@c" -- Same as FL_COMMAND|’c’ (see FL_COMMAND for platform specific behavior)
"0x63" -- Same as "c" (hex 63==’c’)
"99" -- Same as "c" (dec 99==’c’)
"0143" -- Same as "c" (octal 0143==’c’)
"ˆ0x63" -- Same as (FL_CTRL|’c’), or (FL_CTRL|0x63)
"ˆ99" -- Same as (FL_CTRL|’c’), or (FL_CTRL|99)
"ˆ0143" -- Same as (FL_CTRL|’c’), or (FL_CTRL|0143)
Remarks
Due to XForms legacy, there are some odd things to consider when using the modifier characters.
(1) You can use the special modifier keys for chords only if the modifiers are provided in this order:
#, +, ∧ , !, @. Other ordering can yield undefined results.
So for instance, Ctrl-Alt-c must be specified as ”#∧ c” (and not ”∧ #c”), due to the above ordering rule.
(2) If you want to make a shortcut that uses one of the special modifier characters (as the character
being modified), then to avoid confusion, specify the numeric equivalent, e.g.
If you want.. Then use..
----------------------------- ------------------------------
’#’ as the shortcut.. "0x23" (instead of just "#").
’+’ as the shortcut.. "0x2b" (instead of just "+").
’ˆ’ as the shortcut.. "0x5e" (instead of just "ˆ").
Alt-+ as the shortcut.. "#0x2b" (instead of "#+").
Alt-ˆ as the shortcut.. "#0x5e" (instead of "#ˆ").
..etc..
As a general rule that’s easy to remember, unless the shortcut key to be modified is a single alpha-
numeric character [A-Z,a-z,0-9), it’s probably best to use the numeric equivalents.
Todo Fix these silly legacy issues in a future release to support more predictable behavior for the modifier
keys.
void fl pie ( int x, int y, int w, int h, double a1, double a2 ) [inline]
Draw filled ellipse sections using integer coordinates.
Like fl arc(), but fl pie() draws a filled-in pie slice. This slice may extend outside the line drawn by
fl arc(); to avoid this use w - 1 and h - 1.
30.7. DRAWING FUNCTIONS 251
Parameters
in x,y,w,h bounding box of complete circle
in a1,a2 start and end angles of arc measured in degrees counter-clockwise from
3 o’clock. a2 must be greater than or equal to a1.
void fl polygon ( int x, int y, int x1, int y1, int x2, int y2 ) [inline]
Fills a 3-sided polygon.
The polygon must be convex.
void fl polygon ( int x, int y, int x1, int y1, int x2, int y2, int x3, int y3 ) [inline]
Fills a 4-sided polygon.
The polygon must be convex.
FL EXPORT uchar∗ fl read image ( uchar ∗ p, int X, int Y, int W, int H, int alpha = 0 )
Reads an RGB(A) image from the current window or off-screen buffer.
Parameters
in p pixel buffer, or NULL to allocate one
in X,Y position of top-left of image to read
in W,H width and height of image to read
in alpha alpha value for image (0 for none)
Returns
pointer to pixel buffer, or NULL if allocation failed.
The p argument points to a buffer that can hold the image and must be at least W∗H∗3 bytes when reading
RGB images, or W∗H∗4 bytes when reading RGBA images. If NULL, fl read image() will create an array
of the proper size which can be freed using delete[].
The alpha parameter controls whether an alpha channel is created and the value that is placed in the
alpha channel. If 0, no alpha channel is generated.
252 CHAPTER 30. MODULE DOCUMENTATION
FL EXPORT void fl rectf ( int x, int y, int w, int h, uchar r, uchar g, uchar b )
FL EXPORT void fl scroll ( int X, int Y, int W, int H, int dx, int dy, void(∗)(void ∗, int, int, int,
int) draw area, void ∗ data )
FL EXPORT void fl set spot ( int font, int size, int X, int Y, int W, int H, Fl Window ∗ win = 0 )
Todo provide user documentation for fl set spot function
Returns
a pointer to a static buffer containing human readable text for the shortcut
FL EXPORT const char∗ fl shortcut label ( unsigned int shortcut, const char ∗∗ eom )
Get a human-readable string from a shortcut value.
Parameters
in shortcut the integer value containing the ascii character or extended keystroke
plus modifiers
in eom if this pointer is set, it will receive a pointer to the end of the modifier
text
Returns
a pointer to a static buffer containing human readable text for the shortcut
See Also
fl shortcut label(unsigned int shortcut)
Parameters
in x,y coordinate
Functions
• static void Fl::awake (void ∗message=0)
Sends a message pointer to the main thread, causing any pending Fl::wait() call to terminate so that the
main thread can retrieve the message and any pending redraws can be processed.
• static int Fl::awake (Fl Awake Handler cb, void ∗message=0)
See void awake(void∗ message=0).
• static int Fl::lock ()
The lock() method blocks the current thread until it can safely access FLTK widgets and data.
• static void ∗ Fl::thread message ()
The thread message() method returns the last message that was sent from a child by the awake() method.
• static void Fl::unlock ()
The unlock() method releases the lock that was set using the lock() method.
Sends a message pointer to the main thread, causing any pending Fl::wait() call to terminate so that the
main thread can retrieve the message and any pending redraws can be processed.
Multiple calls to Fl::awake() will queue multiple pointers for the main thread to process, up to a system-
defined (typically several thousand) depth. The default message handler saves the last message which can
be accessed using the Fl::thread message() function.
In the context of a threaded application, a call to Fl::awake() with no argument will trigger event loop
handling in the main thread. Since it is not possible to call Fl::flush() from a subsidiary thread, Fl::awake()
is the best (and only, really) substitute.
See also: Multithreading
See Also
Fl::awake(void∗ message=0)
256 CHAPTER 30. MODULE DOCUMENTATION
Functions
• static void Fl::clear widget pointer (Fl Widget const ∗w)
Clears a widget pointer in the watch list.
• static void Fl::delete widget (Fl Widget ∗w)
Schedules a widget for deletion at the next call to the event loop.
• static void Fl::do widget deletion ()
Deletes widgets previously scheduled for deletion.
• static void Fl::release widget pointer (Fl Widget ∗&w)
Releases a widget pointer from the watch list.
• static void Fl::watch widget pointer (Fl Widget ∗&w)
Adds a widget pointer to the widget watch list.
Note
Internal use only !
This method searches the widget watch list for pointers to the widget and clears each pointer that points to
it. Widget pointers can be added to the widget watch list by calling Fl::watch widget pointer() or by using
the helper class Fl Widget Tracker (recommended).
See Also
Fl::watch widget pointer()
class Fl Widget Tracker
Since
FLTK 1.3 it is not necessary to remove widgets from their parent groups or windows before calling
this, because it will be done in the widget’s destructor, but it is not a failure to do this nevertheless.
Note
In FLTK 1.1 you must remove widgets from their parent group (or window) before deleting them.
See Also
Fl Widget::∼Fl Widget()
See Also
Fl::delete widget(Fl Widget ∗wi)
30.9. SAFE WIDGET DELETION SUPPORT FUNCTIONS 259
See Also
Fl::watch widget pointer()
This can be used, if it is possible that a widget might be deleted during a callback or similar function. The
widget pointer must be added to the watch list before calling the callback. After the callback the widget
pointer can be queried, if it is NULL. If it is NULL, then the widget has been deleted during the callback
and must not be accessed anymore. If the widget pointer is not NULL, then the widget has not been deleted
and can be accessed safely.
After accessing the widget, the widget pointer must be released from the watch list by calling Fl-
::release widget pointer().
Example for a button that is clicked (from its handle() method):
Fl Widget *wp = this; // save ’this’ in a pointer variable
Fl::watch widget pointer(wp); // add the pointer to the watch list
set changed(); // set the changed flag
do callback(); // call the callback
if (!wp) { // the widget has been deleted
Fl::release widget pointer(wp); // remove the pointer from the watch list
This works, because all widgets call Fl::clear widget pointer() in their destructors.
See Also
Fl::release widget pointer()
Fl::clear widget pointer()
An easier and more convenient method to control widget deletion during callbacks is to use the class Fl -
Widget Tracker with a local (automatic) variable.
See Also
class Fl Widget Tracker
260 CHAPTER 30. MODULE DOCUMENTATION
Functions
• static void Fl::cairo autolink context (bool alink)
when FLTK HAVE CAIRO is defined and cairo autolink context() is true, any current window dc is linked
to a current context.
• static bool Fl::cairo autolink context ()
Gets the current autolink mode for cairo support.
• static cairo t ∗ Fl::cairo cc ()
Gets the current cairo context linked with a fltk window.
• static void Fl::cairo cc (cairo t ∗c, bool own=false)
Sets the current cairo context to c.
• static cairo t ∗ Fl::cairo make current (Fl Window ∗w)
Provides a corresponding cairo context for window wi.
See Also
void cairo autolink context(bool alink)
30.10. CAIRO SUPPORT FUNCTIONS AND CLASSES 261
Note
Only available when configure has the –enable-cairo option
Returns
the valid cairo t∗ cairo context associated to this window.
262 CHAPTER 30. MODULE DOCUMENTATION
Macros
• #define ERRORS TO CP1252 1
• #define ERRORS TO ISO8859 1 1
• #define NBC 0xFFFF + 1
• #define STRICT RFC3629 0
Functions
• FL EXPORT int fl access (const char ∗f, int mode)
• FL EXPORT int fl chmod (const char ∗f, int mode)
• FL EXPORT int fl execvp (const char ∗file, char ∗const ∗argv)
• FL EXPORT FILE ∗ fl fopen (const char ∗f, const char ∗mode)
Cross-platform function to open files with a UTF-8 encoded name.
• FL EXPORT char ∗ fl getcwd (char ∗buf, int maxlen)
• FL EXPORT char ∗ fl getenv (const char ∗name)
• FL EXPORT char fl make path (const char ∗path)
• FL EXPORT void fl make path for file (const char ∗path)
• FL EXPORT int fl mkdir (const char ∗f, int mode)
• FL EXPORT unsigned int fl nonspacing (unsigned int ucs)
returns true if the character is non-spacing.
• FL EXPORT int fl open (const char ∗f, int oflags,...)
Cross-platform function to open files with a UTF-8 encoded name.
• FL EXPORT int fl rename (const char ∗f, const char ∗t)
• FL EXPORT int fl rmdir (const char ∗f)
• FL EXPORT int fl stat (const char ∗path, struct stat ∗buffer)
• FL EXPORT int fl system (const char ∗f)
• FL EXPORT int fl tolower (unsigned int ucs)
return the Unicode lower case value of ucs
• FL EXPORT int fl toupper (unsigned int ucs)
return the Unicode upper case value of ucs
• FL EXPORT unsigned fl ucs to Utf16 (const unsigned ucs, unsigned short ∗dst, const unsigned
dstlen)
• FL EXPORT int fl unlink (const char ∗f)
• FL EXPORT char ∗ fl utf2mbcs (const char ∗s)
converts UTF8 to a local multi-byte character string.
• FL EXPORT const char ∗ fl utf8back (const char ∗p, const char ∗start, const char ∗end)
• FL EXPORT int fl utf8bytes (unsigned ucs)
Return the number of bytes needed to encode the given UCS4 character in UTF8.
• FL EXPORT unsigned fl utf8decode (const char ∗p, const char ∗end, int ∗len)
• FL EXPORT int fl utf8encode (unsigned ucs, char ∗buf)
• FL EXPORT unsigned fl utf8from mb (char ∗dst, unsigned dstlen, const char ∗src, unsigned srclen)
• FL EXPORT unsigned fl utf8froma (char ∗dst, unsigned dstlen, const char ∗src, unsigned srclen)
• FL EXPORT unsigned fl utf8fromwc (char ∗dst, unsigned dstlen, const wchar t ∗src, unsigned sr-
clen)
• FL EXPORT const char ∗ fl utf8fwd (const char ∗p, const char ∗start, const char ∗end)
30.11. UNICODE AND UTF-8 FUNCTIONS 263
Returns
a FILE pointer upon successful completion, or NULL in case of error.
See Also
fl open().
Returns
a file descriptor upon successful completion, or -1 in case of error.
See Also
fl fopen().
unsigned fl ucs to Utf16 ( const unsigned ucs, unsigned short ∗ dst, const unsigned dstlen )
Convert a single 32-bit Unicode codepoint into an array of 16-bit characters. These are used by some
system calls, especially on Windows.
ucs is the value to convert.
dst points at an array to write, and dstlen is the number of locations in this array. At most dstlen
words will be written, and a 0 terminating word will be added if dstlen is large enough. Thus this
function will never overwrite the buffer and will attempt return a zero-terminated string if space permits. If
dstlen is zero then dst can be set to NULL and no data is written, but the length is returned.
The return value is the number of 16-bit words that would be written to dst if it is large enough, not
counting any terminating zero.
30.11. UNICODE AND UTF-8 FUNCTIONS 265
If the return value is greater than dstlen it indicates truncation, you should then allocate a new array
of size return+1 and call this again.
Unicode characters in the range 0x10000 to 0x10ffff are converted to ”surrogate pairs” which take two
words each (in UTF-16 encoding). Typically, setting dstlen to 2 will ensure that any valid Unicode value
can be converted, and setting dstlen to 3 or more will allow a NULL terminated sequence to be returned.
const char ∗ fl utf8back ( const char ∗ p, const char ∗ start, const char ∗ end )
Move p backward until it points to the start of a UTF-8 character. If it already points at the start of one then
it is returned unchanged. Any UTF-8 errors are treated as though each byte of the error is an individual
character.
start is the start of the string and is used to limit the backwards search for the start of a UTF-8 character.
end is the end of the string and is assumed to be a break between characters. It is assumed to be greater
than p.
If you wish to decrement a UTF-8 pointer, pass p-1 to this.
Returns
number of bytes required
Returns number of bytes that utf8encode() will use to encode the character ucs.
Direct testing for the 1-byte case (as shown above) will also speed up the scanning of strings where the
majority of characters are ASCII.
If ucs is greater than 0x10ffff this is an illegal character according to RFC 3629. These are converted
as though they are 0xFFFD (REPLACEMENT CHARACTER).
RFC 3629 also says many other values for ucs are illegal (in the range 0xd800 to 0xdfff, or ending
with 0xfffe or 0xffff). However I encode these as though they are legal, so that utf8encode/fl utf8decode
will be the identity for all codes between 0 and 0x10ffff.
unsigned fl utf8from mb ( char ∗ dst, unsigned dstlen, const char ∗ src, unsigned srclen )
Convert a filename from the locale-specific multibyte encoding used by Windows to UTF-8 as used by
FLTK.
Up to dstlen bytes are written to dst, including a null terminator. The return value is the number
of bytes that would be written, not counting the null terminator. If greater or equal to dstlen then if you
malloc a new array of size n+1 you will have the space needed for the entire string. If dstlen is zero then
nothing is written and this call just measures the storage space needed.
On Unix or on Windows when a UTF-8 locale is in effect, this does not change the data. You may also
want to check if fl utf8test() returns non-zero, so that the filesystem can store filenames in UTF-8 encoding
regardless of the locale.
unsigned fl utf8froma ( char ∗ dst, unsigned dstlen, const char ∗ src, unsigned srclen )
Convert an ISO-8859-1 (ie normal c-string) byte stream to UTF-8.
It is possible this should convert Microsoft’s CP1252 to UTF-8 instead. This would translate the codes
in the range 0x80-0x9f to different characters. Currently it does not do this.
Up to dstlen bytes are written to dst, including a null terminator. The return value is the number
of bytes that would be written, not counting the null terminator. If greater or equal to dstlen then if you
malloc a new array of size n+1 you will have the space needed for the entire string. If dstlen is zero then
nothing is written and this call just measures the storage space needed.
srclen is the number of bytes in src to convert.
If the return value equals srclen then this indicates that no conversion is necessary, as only ASCII
characters are in the string.
unsigned fl utf8fromwc ( char ∗ dst, unsigned dstlen, const wchar t ∗ src, unsigned srclen )
Turn ”wide characters” as returned by some system calls (especially on Windows) into UTF-8.
Up to dstlen bytes are written to dst, including a null terminator. The return value is the number
of bytes that would be written, not counting the null terminator. If greater or equal to dstlen then if you
malloc a new array of size n+1 you will have the space needed for the entire string. If dstlen is zero then
nothing is written and this call just measures the storage space needed.
srclen is the number of words in src to convert. On Windows this is not necessarily the number of
characters, due to there possibly being ”surrogate pairs” in the UTF-16 encoding used. On Unix wchar t is
32 bits and each location is a character.
On Unix if a src word is greater than 0x10ffff then this is an illegal character according to RFC 3629.
These are converted as though they are 0xFFFD (REPLACEMENT CHARACTER). Characters in the
range 0xd800 to 0xdfff, or ending with 0xfffe or 0xffff are also illegal according to RFC 3629. However I
encode these as though they are legal, so that fl utf8towc will return the original data.
On Windows ”surrogate pairs” are converted to a single character and UTF-8 encoded (as 4 bytes).
Mismatched halves of surrogate pairs are converted as though they are individual characters.
const char ∗ fl utf8fwd ( const char ∗ p, const char ∗ start, const char ∗ end )
Move p forward until it points to the start of a UTF-8 character. If it already points at the start of one then
it is returned unchanged. Any UTF-8 errors are treated as though each byte of the error is an individual
character.
start is the start of the string and is used to limit the backwards search for the start of a utf8 character.
30.11. UNICODE AND UTF-8 FUNCTIONS 267
end is the end of the string and is assumed to be a break between characters. It is assumed to be greater
than p.
This function is for moving a pointer that was jumped to the middle of a string, such as when doing a
binary search for a position. You should use either this or fl utf8back() depending on which direction your
algorithim can handle the pointer moving. Do not use this to scan strings, use fl utf8decode() instead.
See Also
fl utf8len1
See Also
fl utf8len
• Returns 0 if there is any illegal UTF-8 sequences, using the same rules as fl utf8decode(). Note that
some UCS values considered illegal by RFC 3629, such as 0xffff, are considered legal by this.
• Returns 1 if there are only single-byte characters (ie no bytes have the high bit set). This is legal
UTF-8, but also indicates plain ASCII. It also returns 1 if srclen is zero.
Because there are many illegal sequences in UTF-8, it is almost impossible for a string in another
encoding to be confused with UTF-8. This is very useful for transitioning Unix to UTF-8 filenames, you
can simply test each filename with this to decide if it is UTF-8 or in the locale encoding. My hope is that
if this is done we will be able to cleanly transition to a locale-less encoding.
268 CHAPTER 30. MODULE DOCUMENTATION
unsigned fl utf8to mb ( const char ∗ src, unsigned srclen, char ∗ dst, unsigned dstlen )
Convert the UTF-8 used by FLTK to the locale-specific encoding used for filenames (and sometimes used
for data in files). Unfortunately due to stupid design you will have to do this as needed for filenames. This
is a bug on both Unix and Windows.
Up to dstlen bytes are written to dst, including a null terminator. The return value is the number
of bytes that would be written, not counting the null terminator. If greater or equal to dstlen then if you
malloc a new array of size n+1 you will have the space needed for the entire string. If dstlen is zero then
nothing is written and this call just measures the storage space needed.
If fl utf8locale() returns true then this does not change the data.
unsigned fl utf8toa ( const char ∗ src, unsigned srclen, char ∗ dst, unsigned dstlen )
Convert a UTF-8 sequence into an array of 1-byte characters.
If the UTF-8 decodes to a character greater than 0xff then it is replaced with ’?’.
Errors in the UTF-8 are converted as individual bytes, same as fl utf8decode() does. This allows ISO-
8859-1 text mistakenly identified as UTF-8 to be printed correctly (and possibly CP1512 on Windows).
src points at the UTF-8, and srclen is the number of bytes to convert.
Up to dstlen bytes are written to dst, including a null terminator. The return value is the number
of bytes that would be written, not counting the null terminator. If greater or equal to dstlen then if you
malloc a new array of size n+1 you will have the space needed for the entire string. If dstlen is zero then
nothing is written and this call just measures the storage space needed.
unsigned fl utf8toUtf16 ( const char ∗ src, unsigned srclen, unsigned short ∗ dst, unsigned dstlen )
Convert a UTF-8 sequence into an array of 16-bit characters. These are used by some system calls, espe-
cially on Windows.
src points at the UTF-8, and srclen is the number of bytes to convert.
dst points at an array to write, and dstlen is the number of locations in this array. At most
dstlen-1 words will be written there, plus a 0 terminating word. Thus this function will never over-
write the buffer and will always return a zero-terminated string. If dstlen is zero then dst can be null
and no data is written, but the length is returned.
The return value is the number of 16-bit words that would be written to dst if it were long enough, not
counting the terminating zero. If the return value is greater or equal to dstlen it indicates truncation, you
can then allocate a new array of size return+1 and call this again.
Errors in the UTF-8 are converted as though each byte in the erroneous string is in the Microsoft C-
P1252 encoding. This allows ISO-8859-1 text mistakenly identified as UTF-8 to be printed correctly.
Unicode characters in the range 0x10000 to 0x10ffff are converted to ”surrogate pairs” which take two
words each (this is called UTF-16 encoding).
unsigned fl utf8towc ( const char ∗ src, unsigned srclen, wchar t ∗ dst, unsigned dstlen )
Converts a UTF-8 string into a wide character string.
This function generates 32-bit wchar t (e.g. ”ucs4” as it were) except on Windows where it is equivalent
to fl utf8toUtf16 and returns UTF-16.
src points at the UTF-8, and srclen is the number of bytes to convert.
dst points at an array to write, and dstlen is the number of locations in this array. At most
dstlen-1 wchar t will be written there, plus a 0 terminating wchar t.
The return value is the number of wchar t that would be written to dst if it were long enough, not
counting the terminating zero. If the return value is greater or equal to dstlen it indicates truncation, you
can then allocate a new array of size return+1 and call this again.
Notice that sizeof(wchar t) is 2 on Windows and is 4 on Linux and most other systems. Where wchar t
is 16 bits, Unicode characters in the range 0x10000 to 0x10ffff are converted to ”surrogate pairs” which
take two words each (this is called UTF-16 encoding). If wchar t is 32 bits this rather nasty problem is
avoided.
30.11. UNICODE AND UTF-8 FUNCTIONS 269
Note that Windows includes Cygwin, i.e. compiled with Cygwin’s POSIX layer (cygwin1.dll, –enable-
cygwin), either native (GDI) or X11.
int fl utf strncasecmp ( const char ∗ s1, const char ∗ s2, int n )
UTF-8 aware strncasecmp - converts to lower case Unicode and tests.
Parameters
s1,s2 the utf8 strings to compare
n the maximum number of utf8 characters to compare
Returns
0 if the strings are equal
>0 if s1 is greater than s2
<0 if s1 is less than s2
int fl utf tolower ( const unsigned char ∗ str, int len, char ∗ buf )
converts the str string to the lower case equivalent into buf.
Warning: to be safe buf length must be at least 3 ∗ len [for 16-bit Unicode]
int fl utf toupper ( const unsigned char ∗ str, int len, char ∗ buf )
converts the str string to the upper case equivalent into buf.
Warning: to be safe buf length must be at least 3 ∗ len [for 16-bit Unicode]
Returns
width of character in columns
Depending on build options, this function may map C1 control characters (0x80 to 0x9f) to CP1252, and
return the width of that character instead. This is not the same behaviour as fl wcwidth (unsigned int ucs) .
Note that other control characters and DEL will still return -1, so if you want different behaviour, you
need to test for those characters before calling fl wcwidth(), and handle them separately.
Parameters
in ucs Unicode character value
Returns
width of character in columns
Classes
• class Fl Mac App Menu
Mac OS-specific class allowing to localize the application menu.
Functions
• void fl mac set about (Fl Callback ∗cb, void ∗user data, int shortcut=0)
Attaches a callback to the ”About myprog” item of the system application menu.
• void fl open callback (void(∗cb)(const char ∗))
Register a function called for each file dropped onto an application icon.
• int gl texture pile height (void)
Returns the current height of the pile of pre-computed string textures.
• void gl texture pile height (int max)
Changes the height of the pile of pre-computed string textures.
Variables
• int fl mac os version
The version number of the running Mac OS X (e.g., 100604 for 10.6.4)
• class Fl Sys Menu Bar ∗ fl sys menu bar
The system menu bar.
See Also
The Apple OS X Interface
Functions
• void fl alert (const char ∗fmt,...)
Shows an alert message dialog box.
• int fl ask (const char ∗fmt,...)
Shows a dialog displaying the fmt message, this dialog features 2 yes/no buttons.
• void fl beep (int type)
Emits a system beep message.
• int fl choice (const char ∗fmt, const char ∗b0, const char ∗b1, const char ∗b2,...)
Shows a dialog displaying the fmt message, this dialog features up to 3 customizable choice buttons.
• int fl color chooser (const char ∗name, double &r, double &g, double &b, int cmode)
Pops up a window to let the user pick an arbitrary RGB color.
• int fl color chooser (const char ∗name, uchar &r, uchar &g, uchar &b, int cmode)
Pops up a window to let the user pick an arbitrary RGB color.
• char ∗ fl dir chooser (const char ∗message, const char ∗fname, int relative)
Shows a file chooser dialog and gets a directory.
• char ∗ fl file chooser (const char ∗message, const char ∗pat, const char ∗fname, int relative)
Shows a file chooser dialog and gets a filename.
• void fl file chooser callback (void(∗cb)(const char ∗))
Set the file chooser callback.
• void fl file chooser ok label (const char ∗l)
Set the ”OK” button label.
• const char ∗ fl input (const char ∗fmt, const char ∗defstr,...)
Shows an input dialog displaying the fmt message.
• void fl message (const char ∗fmt,...)
Shows an information message dialog box.
• void fl message hotspot (int enable)
Sets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
• int fl message hotspot (void)
Gets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
• Fl Widget ∗ fl message icon ()
Gets the Fl Box icon container of the current default dialog used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password()
• void fl message title (const char ∗title)
Sets the title of the dialog window used in many common dialogs.
• void fl message title default (const char ∗title)
Sets the default title of the dialog window used in many common dialogs.
• const char ∗ fl password (const char ∗fmt, const char ∗defstr,...)
Shows an input dialog displaying the fmt message.
274 CHAPTER 30. MODULE DOCUMENTATION
Variables
• static void(∗ Fl::error )(const char ∗,...) = ::error
FLTK calls Fl::error() to output a normal error message.
• static void(∗ Fl::fatal )(const char ∗,...) = ::fatal
FLTK calls Fl::fatal() to output a fatal error message.
• const char ∗ fl cancel = ”Cancel”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl close = ”Close”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl no = ”No”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl ok = ”OK”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl yes = ”Yes”
string pointer used in common dialogs, you can change it to another language
• static void(∗ Fl::warning )(const char ∗,...) = ::warning
FLTK calls Fl::warning() to output a warning message.
Return values
0 if the no button is selected or another dialog box is still open
1 if yes is selected
Note
#include <FL/fl ask.H>
int fl choice ( const char ∗ fmt, const char ∗ b0, const char ∗ b1, const char ∗ b2, ... )
Shows a dialog displaying the fmt message, this dialog features up to 3 customizable choice buttons.
Note
Common dialog boxes are application modal. No more than one common dialog box can be open at
any time. Requests for additional dialog boxes are ignored.
#include <FL/fl ask.H>
Parameters
in fmt can be used as an sprintf-like format and variables for the message text
in b0 text label of button 0
in b1 text label of button 1
in b2 text label of button 2
Return values
0 if the first button with b0 text is selected or another dialog box is still open
1 if the second button with b1 text is selected
2 if the third button with b2 text is selected
int fl color chooser ( const char ∗ name, double & r, double & g, double & b, int cmode )
[related]
Note
#include <FL/Fl Color Chooser.H>
Parameters
in name Title label for the window
in,out r,g,b Color components in the range 0.0 to 1.0.
in cmode Optional mode for color chooser. See mode(int). Default -1 if none (rgb
mode).
Return values
1 if user confirms the selection
0 if user cancels the dialog
int fl color chooser ( const char ∗ name, uchar & r, uchar & g, uchar & b, int cmode )
[related]
Note
#include <FL/Fl Color Chooser.H>
Parameters
in name Title label for the window
in,out r,g,b Color components in the range 0 to 255.
in cmode Optional mode for color chooser. See mode(int). Default -1 if none (rgb
mode).
Return values
1 if user confirms the selection
0 if user cancels the dialog
char ∗ fl dir chooser ( const char ∗ message, const char ∗ fname, int relative ) [related]
Note
#include <FL/Fl File Chooser.H>
Parameters
in message title bar text
in fname initial/default directory name
in relative 0 for absolute path return, relative otherwise
Returns
the directory path string chosen by the user or NULL if user cancels
278 CHAPTER 30. MODULE DOCUMENTATION
char ∗ fl file chooser ( const char ∗ message, const char ∗ pat, const char ∗ fname, int relative )
[related]
Shows a file chooser dialog and gets a filename.
Note
#include <FL/Fl File Chooser.H>
Parameters
in message text in title bar
in pat filename pattern filter
in fname initial/default filename selection
in relative 0 for absolute path name, relative path name otherwise
Returns
the user selected filename, in absolute or relative format or NULL if user cancels
const char∗ fl input ( const char ∗ fmt, const char ∗ defstr, ... )
Shows an input dialog displaying the fmt message.
Note
Common dialog boxes are application modal. No more than one common dialog box can be open at
any time. Requests for additional dialog boxes are ignored.
#include <FL/fl ask.H>
Parameters
in fmt can be used as an sprintf-like format and variables for the message text
in defstr defines the default returned string if no text is entered
Returns
the user string input if OK was pushed, NULL if Cancel was pushed or another dialog box was still
open
Returns
0 if disable, non-zero otherwise
See Also
fl message hotspot(int)
Note
#include <FL/fl ask.H>
Parameters
in title default window label, string copied internally
const char∗ fl password ( const char ∗ fmt, const char ∗ defstr, ... )
Shows an input dialog displaying the fmt message.
Like fl input() except the input text is not shown, ’∗’ characters are displayed instead.
Note
Common dialog boxes are application modal. No more than one common dialog box can be open at
any time. Requests for additional dialog boxes are ignored.
#include <FL/fl ask.H>
Parameters
in fmt can be used as an sprintf-like format and variables for the message text
in defstr defines the default returned string if no text is entered
Returns
the user string input if OK was pushed, NULL if Cancel was pushed or aother dialog box was still
open
Note
#include <FL/Fl.H>
Note
#include <FL/Fl.H>
282 CHAPTER 30. MODULE DOCUMENTATION
Macros
• #define fl dirent h cyclic include
• #define FL PATH MAX 2048
all path buffers should use this length
Typedefs
• typedef int( Fl File Sort F )(struct dirent ∗∗, struct dirent ∗∗)
File sorting function.
Functions
• FL EXPORT void fl decode uri (char ∗uri)
Decodes a URL-encoded string.
• FL EXPORT int fl filename absolute (char ∗to, int tolen, const char ∗from)
Makes a filename absolute from a relative filename.
• FL EXPORT int fl filename expand (char ∗to, int tolen, const char ∗from)
Expands a filename containing shell variables and tilde (∼).
• FL EXPORT const char ∗ fl filename ext (const char ∗buf)
Gets the extensions of a filename.
• FL EXPORT void fl filename free list (struct dirent ∗∗∗l, int n)
Free the list of filenames that is generated by fl filename list().
• FL EXPORT int fl filename isdir (const char ∗name)
Determines if a file exists and is a directory from its filename.
• FL EXPORT int fl filename list (const char ∗d, struct dirent ∗∗∗l, Fl File Sort F ∗s=fl numericsort)
Portable and const-correct wrapper for the scandir() function.
• FL EXPORT int fl filename match (const char ∗name, const char ∗pattern)
Checks if a string s matches a pattern p.
• FL EXPORT const char ∗ fl filename name (const char ∗filename)
Gets the file name from a path.
• FL EXPORT int fl filename relative (char ∗to, int tolen, const char ∗from)
Makes a filename relative to the current working directory.
• FL EXPORT char ∗ fl filename setext (char ∗to, int tolen, const char ∗ext)
Replaces the extension in buf of max.
• FL EXPORT int fl open uri (const char ∗uri, char ∗msg, int msglen)
Opens the specified Uniform Resource Identifier (URI).
FL EXPORT int fl filename absolute ( char ∗ to, int tolen, const char ∗ from )
Makes a filename absolute from a relative filename.
#include <FL/filename.H>
[..]
chdir("/var/tmp");
fl filename absolute(out, sizeof(out), "foo.txt"); // out="/var/tmp/foo.txt"
fl filename absolute(out, sizeof(out), "./foo.txt"); // out="/var/tmp/foo.txt"
fl filename absolute(out, sizeof(out), "../log/messages"); // out="/var/log/messages"
Parameters
out to resulting absolute filename
in tolen size of the absolute filename buffer
in from relative filename
Returns
0 if no change, non zero otherwise
FL EXPORT int fl filename expand ( char ∗ to, int tolen, const char ∗ from )
Expands a filename containing shell variables and tilde (∼).
Currently handles these variants:
"˜username" // if ’username’ does not exist, result will be unchanged
"˜/file"
"$VARNAME" // does NOT handle ${VARNAME}
Examples:
#include <FL/filename.H>
[..]
putenv("TMPDIR=/var/tmp");
fl filename expand(out, sizeof(out), "˜fred/.cshrc"); // out="/usr/fred/.cshrc"
fl filename expand(out, sizeof(out), "˜/.cshrc"); // out="/usr/<yourname>/.cshrc"
fl filename expand(out, sizeof(out), "$TMPDIR/foo.txt"); // out="/var/tmp/foo.txt"
30.14. FILE NAMES AND URI UTILITY FUNCTIONS 285
Parameters
out to resulting expanded filename
in tolen size of the expanded filename buffer
in from filename containing shell variables
Returns
0 if no change, non zero otherwise
#include <FL/filename.H>
[..]
const char *out;
out = fl filename ext("/some/path/foo.txt"); // result: ".txt"
out = fl filename ext("/some/path/foo"); // result: NULL
Parameters
in buf the filename to be parsed
Returns
a pointer to the extension (including ’.’) if any or NULL otherwise
FL EXPORT void fl filename free list ( struct dirent ∗∗∗ list, int n )
#include <FL/filename.H>
[..]
fl filename isdir("/etc"); // returns non-zero
fl filename isdir("/etc/hosts"); // returns 0
Parameters
in n the filename to parse
Returns
non zero if file exists and is a directory, zero otherwise
286 CHAPTER 30. MODULE DOCUMENTATION
FL EXPORT int fl filename list ( const char ∗ d, dirent ∗∗∗ list, Fl File Sort F ∗ sort )
Portable and const-correct wrapper for the scandir() function.
For each file in that directory a ”dirent” structure is created. The only portable thing about a dirent
is that dirent.d name is the nul-terminated file name. An pointers array to these dirent’s is created and a
pointer to the array is returned in ∗list. The number of entries is given as a return value. If there is an error
reading the directory a number less than zero is returned, and errno has the reason; errno does not work
under WIN32.
Include:
#include <FL/filename.H>
Parameters
in d the name of the directory to list. It does not matter if it has a trailing
slash.
out list table containing the resulting directory listing
in sort sorting functor:
• fl alphasort: The files are sorted in ascending alphabetical order;
upper and lowercase letters are compared according to their ASCII
ordering uppercase before lowercase.
Returns
the number of entries if no error, a negative value otherwise.
• [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.
Parameters
in s the string to check for a match
in p the string pattern
Returns
non zero if the string matches the pattern
Returns
a pointer to the char after the last slash, or to filename if there is none.
FL EXPORT int fl filename relative ( char ∗ to, int tolen, const char ∗ from )
Makes a filename relative to the current working directory.
#include <FL/filename.H>
[..]
chdir("/var/tmp/somedir"); // set cwd to /var/tmp/somedir
[..]
char out[FL PATH MAX];
fl filename relative(out, sizeof(out), "/var/tmp/somedir/foo.txt"); // out="foo.txt",
return=1
fl filename relative(out, sizeof(out), "/var/tmp/foo.txt"); //
out="../foo.txt", return=1
fl filename relative(out, sizeof(out), "foo.txt"); // out="foo.txt",
return=0 (no change)
fl filename relative(out, sizeof(out), "./foo.txt"); //
out="./foo.txt", return=0 (no change)
fl filename relative(out, sizeof(out), "../foo.txt"); //
out="../foo.txt", return=0 (no change)
Parameters
out to resulting relative filename
in tolen size of the relative filename buffer
in from absolute filename
Returns
0 if no change, non zero otherwise
288 CHAPTER 30. MODULE DOCUMENTATION
FL EXPORT char∗ fl filename setext ( char ∗ buf, int buflen, const char ∗ ext )
Replaces the extension in buf of max.
size buflen with the extension in ext.
If there’s no ’.’ in buf, ext is appended.
If ext is NULL, behaves as if it were an empty string (””).
Example
#include <FL/filename.H>
[..]
char buf[FL PATH MAX] = "/path/myfile.cxx";
fl filename setext(buf, sizeof(buf), ".txt"); // buf[] becomes "/path/myfile.txt"
Returns
buf itself for calling convenience.
int fl open uri ( const char ∗ uri, char ∗ msg, int msglen )
Opens the specified Uniform Resource Identifier (URI).
Uses an operating-system dependent program or interface. For URIs using the ”ftp”, ”http”, or ”https”
schemes, the system default web browser is used to open the URI, while ”mailto” and ”news” URIs are
typically opened using the system default mail reader and ”file” URIs are opened using the file system
navigator.
On success, the (optional) msg buffer is filled with the command that was run to open the URI; on
Windows, this will always be ”open uri”.
On failure, the msg buffer is filled with an English error message.
Note
Platform Specific Issues: Windows
With ”file:” based URIs on Windows, you may encounter issues with anchors being ignored. Example-
: ”file:///c:/some/index.html#anchor” may open in the browser without the ”#anchor” suffix. The be-
havior seems to vary across different Windows versions. Workaround: open a link to a separate html
file that redirects to the desired ”file:” URI.
Example
#include <FL/filename.H>
[..]
char errmsg[512];
if ( !fl open uri("http://google.com/", errmsg, sizeof(errmsg)) ) {
char warnmsg[768];
sprintf(warnmsg, "Error: %s", errmsg);
fl alert(warnmsg);
}
Parameters
uri The URI to open
msg Optional buffer which contains the command or error message
msglen Length of optional buffer
Returns
1 on success, 0 on failure
Chapter 31
Class Documentation
The documentation for this struct was generated from the following file:
• Fl Preferences.H
Public Types
• enum Fl Option {
OPTION ARROW FOCUS = 0, OPTION VISIBLE FOCUS, OPTION DND TEXT, OPTION S-
HOW TOOLTIPS,
OPTION FNFC USES GTK, OPTION LAST }
Enumerator for global FLTK options.
289
290 CHAPTER 31. CLASS DOCUMENTATION
This is a bitfield of what shift states were on and what mouse buttons were held down during the most recent
event.
• static int event state (int i)
See int event state()
• static const char ∗ event text ()
Returns the text associated with the current event, including FL PASTE or FL DND RELEASE events.
• static int event x ()
Returns the mouse position of the event relative to the Fl Window it was passed to.
• static int event x root ()
Returns the mouse position on the screen of the event.
• static int event y ()
Returns the mouse position of the event relative to the Fl Window it was passed to.
• static int event y root ()
Returns the mouse position on the screen of the event.
• static Fl Window ∗ first window ()
Returns the first top-level window in the list of shown() windows.
• static void first window (Fl Window ∗)
Sets the window that is returned by first window().
• static void flush ()
Causes all the windows that need it to be redrawn and graphics forced out through the pipes.
• static Fl Widget ∗ focus ()
Gets the current Fl::focus() widget.
• static void focus (Fl Widget ∗)
Sets the widget that will receive FL KEYBOARD events.
• static void foreground (uchar, uchar, uchar)
Changes fl color(FL FOREGROUND COLOR).
• static void free color (Fl Color i, int overlay=0)
Frees the specified color from the colormap, if applicable.
• static int get awake handler (Fl Awake Handler &, void ∗&)
Gets the last stored awake handler for use in awake().
• static Fl Box Draw F ∗ get boxtype (Fl Boxtype)
Gets the current box drawing function for the specified box type.
• static unsigned get color (Fl Color i)
Returns the RGB value(s) for the given FLTK color index.
• static void get color (Fl Color i, uchar &red, uchar &green, uchar &blue)
Returns the RGB value(s) for the given FLTK color index.
• static const char ∗ get font (Fl Font)
Gets the string for this face.
• static const char ∗ get font name (Fl Font, int ∗attributes=0)
Get a human-readable string describing the family of this face.
• static int get font sizes (Fl Font, int ∗&sizep)
Return an array of sizes in sizep.
• static int get key (int key)
Returns true if the given key is held down now.
• static void get mouse (int &, int &)
Return where the mouse is on the screen by doing a round-trip query to the server.
• static void get system colors ()
294 CHAPTER 31. CLASS DOCUMENTATION
Read the user preference colors from the system and use them to call Fl::foreground(), Fl::background(),
and Fl::background2().
• static int gl visual (int, int ∗alist=0)
This does the same thing as Fl::visual(int) but also requires OpenGL drawing to work.
• static Fl Window ∗ grab ()
Returns the window that currently receives all events.
• static void grab (Fl Window ∗)
Selects the window to grab.
• static void grab (Fl Window &win)
See grab(Fl Window∗)
• static int h ()
Returns the height in pixels of the main screen work area.
• static int handle (int, Fl Window ∗)
Handle events from the window system.
• static int handle (int, Fl Window ∗)
Handle events from the window system.
• static int has check (Fl Timeout Handler, void ∗=0)
Returns 1 if the check exists and has not been called yet, 0 otherwise.
• static int has idle (Fl Idle Handler cb, void ∗data=0)
Returns true if the specified idle callback is currently installed.
• static int has timeout (Fl Timeout Handler, void ∗=0)
Returns true if the timeout exists and has not been called yet.
• static int is scheme (const char ∗name)
Returns whether the current scheme is the given name.
• static int lock ()
The lock() method blocks the current thread until it can safely access FLTK widgets and data.
• static Fl Window ∗ modal ()
Returns the top-most modal() window currently shown.
• static Fl Window ∗ next window (const Fl Window ∗)
Returns the next top-level window in the list of shown() windows.
• static bool option (Fl Option opt)
FLTK library options management.
• static void option (Fl Option opt, bool val)
Override an option while the application is running.
• static void own colormap ()
Makes FLTK use its own colormap.
• static void paste (Fl Widget &receiver, int source, const char ∗type=Fl::clipboard plain text)
Pastes the data from the selection buffer (source is 0) or the clipboard (source is 1) into receiver.
• static void paste (Fl Widget &receiver)
Backward compatibility only.
• static Fl Widget ∗ pushed ()
Gets the widget that is being pushed.
• static void pushed (Fl Widget ∗)
Sets the widget that is being pushed.
• static Fl Widget ∗ readqueue ()
All Fl Widgets that don’t have a callback defined use a default callback that puts a pointer to the widget in
this queue, and this method reads the oldest widget out of this queue.
31.2. FL CLASS REFERENCE 295
• static void screen work area (int &X, int &Y, int &W, int &H)
Gets the bounding box of the work area of the screen that contains the mouse pointer.
• static void screen xywh (int &X, int &Y, int &W, int &H)
Gets the bounding box of a screen that contains the mouse pointer.
• static void screen xywh (int &X, int &Y, int &W, int &H, int mx, int my)
Gets the bounding box of a screen that contains the specified screen position mx, my.
• static void screen xywh (int &X, int &Y, int &W, int &H, int n)
Gets the screen bounding rect for the given screen.
• static void screen xywh (int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh)
Gets the screen bounding rect for the screen which intersects the most with the rectangle defined by mx, my,
mw, mh.
• static int scrollbar size ()
Gets the default scrollbar size used by Fl Browser , Fl Help View, Fl Scroll, and Fl Text Display widgets.
• static void scrollbar size (int W)
Sets the default scrollbar size that is used by the Fl Browser , Fl Help View, Fl Scroll, and Fl Text Display
widgets.
• static void selection (Fl Widget &owner, const char ∗, int len)
Changes the current selection.
• static Fl Widget ∗ selection owner ()
back-compatibility only: Gets the widget owning the current selection
• static void selection owner (Fl Widget ∗)
Back-compatibility only: The single-argument call can be used to move the selection to another widget or
to set the owner to NULL, without changing the actual text of the selection.
• static void set abort (Fl Abort Handler f)
For back compatibility, sets the void Fl::fatal handler callback.
• static void set atclose (Fl Atclose Handler f)
For back compatibility, sets the Fl::atclose handler callback.
• static void set boxtype (Fl Boxtype, Fl Box Draw F ∗, uchar, uchar, uchar, uchar)
Sets the function to call to draw a specific boxtype.
• static void set boxtype (Fl Boxtype, Fl Boxtype from)
Copies the from boxtype.
• static void set color (Fl Color, uchar, uchar, uchar)
Sets an entry in the fl color index table.
• static void set color (Fl Color i, unsigned c)
Sets an entry in the fl color index table.
• static void set font (Fl Font, const char ∗)
Changes a face.
• static void set font (Fl Font, Fl Font)
Copies one face to another.
• static Fl Font set fonts (const char ∗=0)
FLTK will open the display, and add every fonts on the server to the face table.
• static void set idle (Fl Old Idle Handler cb)
Sets an idle callback.
• static void set labeltype (Fl Labeltype, Fl Label Draw F ∗, Fl Label Measure F ∗)
Sets the functions to call to draw and measure a specific labeltype.
• static void set labeltype (Fl Labeltype, Fl Labeltype from)
Sets the functions to call to draw and measure a specific labeltype.
31.2. FL CLASS REFERENCE 297
See Also
Fl::option(Fl Option, bool)
Fl::option(Fl Option)
Enumerator
OPTION ARROW FOCUS When switched on, moving the text cursor beyond the start or end of a
text in a text widget will change focus to the next text widget. (This is considered ’old’ behavior)
When switched off (default), the cursor will stop at the end of the text. Pressing Tab or Ctrl-Tab
will advance the keyboard focus.
See also: Fl Input ::tab nav()
OPTION VISIBLE FOCUS If visible focus is switched on (default), FLTK will draw a dotted rect-
angle inside the widget that will receive the next keystroke. If switched off, no such indicator
will be drawn and keyboard navigation is disabled.
OPTION DND TEXT If text drag-and-drop is enabled (default), the user can select and drag text
from any text widget. If disabled, no dragging is possible, however dropping text from other
applications still works.
OPTION SHOW TOOLTIPS If tooltips are enabled (default), hovering the mouse over a widget
with a tooltip text will open a little tooltip window until the mouse leaves the widget. If disabled,
no tooltip is shown.
OPTION FNFC USES GTK When switched on (default), Fl Native File Chooser runs GTK file
dialogs if the GTK library is available on the platform (linux/unix only). When switched off,
GTK file dialogs aren’t used even if the GTK library is available.
OPTION LAST For internal use only.
bool state changed; // anything that changes the display turns this on
void callback(void*) {
if (!state changed) return;
state changed = false;
do expensive calculation();
widget->redraw();
}
main() {
Fl::add check(callback);
return Fl::run();
}
static void Fl::add fd ( int fd, int when, Fl FD Handler cb, void ∗ = 0 ) [static]
Adds a callback function that is called every time by Fl::wait() and also makes it act as though the timeout
is zero (this makes Fl::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. To remove an idle callback use Fl::remove idle().
Fl::wait() and Fl::check() call idle callbacks, but Fl::ready() does not.
The idle callback can call any FLTK functions, including Fl::wait(), Fl::check(), and Fl::ready().
FLTK will not recursively call the idle callback.
void Fl::add timeout ( double t, Fl Timeout Handler cb, void ∗ argp = 0 ) [static]
void callback(void*) {
puts("TICK");
Fl::repeat timeout(1.0, callback);
}
int main() {
Fl::add timeout(1.0, callback);
return Fl::run();
}
300 CHAPTER 31. CLASS DOCUMENTATION
• -display host:n.n
Sets the X display to use; this option is silently ignored under WIN32 and MacOS.
• -geometry WxH+X+Y
Sets the initial window position and size according to the standard X geometry string.
• -iconic
Iconifies the window using Fl Window::iconize().
• -name string
Sets the window class using Fl Window::xclass().
• -scheme string
Sets the widget scheme using Fl::scheme().
• -title string
Sets the window title using Fl Window::label().
If your program requires other switches in addition to the standard FLTK options, you will need to pass
your own argument handler to Fl::args(int,char∗∗,int&,Fl Args Handler) explicitly.
31.2. FL CLASS REFERENCE 301
int Fl::args ( int argc, char ∗∗ argv, int & i, Fl Args Handler cb = 0 ) [static]
Parse command line switches using the cb argument handler.
Returns 0 on error, or the number of words processed.
FLTK provides this as an entirely optional command line switch parser. You don’t have to call it if you
don’t want to. Everything it can do can be done with other calls to FLTK.
To use the switch parser, call Fl::args(...) 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.
Providing an argument handler callback cb lets you define your own switches. It is called with the same
argc and argv, and with i set to the index of the switch to be processed. The cb handler should return
zero if the switch is unrecognized, and not change i. It should return non-zero to indicate the number of
words processed if the switch is recognized, i.e. 1 for just the switch, and more than 1 for the switch plus
associated parameters. i should be incremented by the same amount.
The cb handler is called before any other tests, so you can also override any standard FLTK switch
(this is why FLTK can use very short switches instead of the long ones all other toolkits force you to use).
See Fl::arg() for descriptions of the standard switches.
On return i is set to the index of the first non-switch. This is either:
• 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.
A usage string is displayed if Fl::args() detects an invalid argument on the command-line. You can
change the message by setting the Fl::help pointer.
A very simple command line parser can be found in examples/howto-parse-args.cxx
The simpler Fl::args(int argc, char ∗∗argv) form is useful if your program does not have command line
switches of its own.
See Also
box dy().
See Also
box dy().
See Also
box dy()
These functions are mainly useful in the draw() code for deriving custom widgets, where one wants to
avoid drawing over the widget’s own border box().
This returns non-zero if any windows are displayed, and 0 if no windows are displayed (this is likely to
change in future versions of FLTK).
Gets or sets whether drag and drop text operations are supported.
This specifically affects whether selected text can be dragged from text fields or dragged within a text
field as a cut/paste shortcut.
Gets or sets whether drag and drop text operations are supported.
This specifically affects whether selected text can be dragged from text fields or dragged within a text
field as a cut/paste shortcut.
Causes all the windows that need it to be redrawn and graphics forced out through the pipes.
This is what wait() does before looking for events.
Note: in multi-threaded applications you should only call Fl::flush() from the main thread. If a child
thread needs to trigger a redraw event, it should instead call Fl::awake() to get the main thread to process
the event queue.
int Fl::get awake handler ( Fl Awake Handler & func, void ∗& data ) [static]
Gets the current box drawing function for the specified box type.
Read the user preference colors from the system and use them to call Fl::foreground(), Fl::background(),
and Fl::background2().
This is done by Fl Window::show(argc,argv) before applying the -fg and -bg switches.
On X this reads some common values from the Xdefaults database. KDE users can set these values
by running the ”krdb” program, and newer versions of KDE set this automatically if you check the ”apply
style to other X programs” switch in their control panel.
304 CHAPTER 31. CLASS DOCUMENTATION
Example:
if (Fl::is scheme("gtk+")) { your code here(); }
Parameters
in name lowercase string of requested scheme name.
Returns
1 if the given scheme is active, 0 otherwise.
See Also
Fl::scheme(const char ∗name)
Note
As of FLTK 1.3.0, options can be managed within fluid, using the menu Edit/Global FLTK Settings.
31.2. FL CLASS REFERENCE 305
Parameters
opt which option
Returns
true or false
See Also
enum Fl::Fl Option
Fl::option(Fl Option, bool)
Since
FLTK 1.3.0
Parameters
opt which option
val set to true or false
See Also
enum Fl::Fl Option
bool Fl::option(Fl Option)
See Also
grab(Fl Window∗)
Note
This version removes all matching timeouts, not just the first one. This may change in the future.
void Fl::repeat timeout ( double t, Fl Timeout Handler cb, void ∗ argp = 0 ) [static]
Repeats a timeout callback from the expiration of the previous timeout, allowing for more accurate timing.
You may only call this method inside a timeout callback.
The following code will print ”TICK” each second on stdout with a fair degree of accuracy:
void callback(void*) {
puts("TICK");
Fl::repeat timeout(1.0, callback);
}
int main() {
Fl::add timeout(1.0, callback);
return Fl::run();
}
Uppercase scheme names are equivalent, but the stored scheme name will always be lowercase and
Fl::scheme() will return this lowercase name.
If the resulting scheme name is not defined, the default scheme will be used and Fl::scheme() will return
NULL.
void Fl::set boxtype ( Fl Boxtype t, Fl Box Draw F ∗ f, uchar a, uchar b, uchar c, uchar d )
[static]
Sets the function to call to draw a specific boxtype.
Deprecated This method is obsolete - use the add idle() method instead.
Gets or sets the visible keyboard focus on buttons and other non-text widgets.
The default mode is to enable keyboard focus for all widgets.
Gets or sets the visible keyboard focus on buttons and other non-text widgets.
The default mode is to enable keyboard focus for all widgets.
• Fl::visual(FL RGB)
Full/true color (if there are several depths FLTK chooses the largest). Do this if you use fl draw -
image for much better (non-dithered) output.
• Fl::visual(FL RGB8)
Full color with at least 24 bits of color. FL RGB will always pick this if available, but if not it will
happily return a less-than-24 bit deep visual. This call fails if 24 bits are not available.
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).
31.2. FL CLASS REFERENCE 309
The documentation for this class was generated from the following files:
• Fl.H
• Fl.cxx
• Fl abort.cxx
• Fl add idle.cxx
• Fl arg.cxx
• fl boxtype.cxx
• fl color.cxx
• fl color mac.cxx
• fl color win32.cxx
• Fl compose.cxx
• Fl display.cxx
• fl dnd win32.cxx
• fl dnd x.cxx
• Fl get key.cxx
• Fl get key mac.cxx
• Fl get key win32.cxx
• Fl get system colors.cxx
• Fl grab.cxx
• fl labeltype.cxx
• Fl lock.cxx
• Fl own colormap.cxx
310 CHAPTER 31. CLASS DOCUMENTATION
• fl set font.cxx
• fl set fonts mac.cxx
• fl set fonts win32.cxx
• fl set fonts x.cxx
• fl set fonts xft.cxx
• fl shortcut.cxx
• Fl visual.cxx
• Fl Widget.cxx
• Fl Window.cxx
• gl start.cxx
• screen xywh.cxx
• Fl Cairo.cxx
Fl_Widget
Fl_Valuator
Fl_Adjuster
When you press a button and drag to the right the value increases. When you drag to the left it decreases.
The largest button adjusts by 100 ∗ step(), the next by 10 ∗ step() and that smallest button by step(). Clicking
on the buttons increments by 10 times the amount dragging by a pixel does. Shift + click decrements by 10
times the amount.
Implements Fl Widget.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
31.4. FL BITMAP CLASS REFERENCE 313
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
Fl_Image
Fl_Bitmap
Fl_XBM_Image
The constructors create a new bitmap from the specified bitmap data.
• Fl Bitmap (const char ∗bits, int W, int H)
The constructors create a new bitmap from the specified bitmap data.
• virtual void label (Fl Widget ∗w)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void label (Fl Menu Item ∗m)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void uncache ()
If the image has been cached for display, delete the cache data.
• virtual ∼Fl Bitmap ()
The destructor free all memory and server resources that are used by the bitmap.
Public Attributes
• int alloc array
Non-zero if array points to bitmap data allocated internally.
• const uchar ∗ array
pointer to raw bitmap data
Friends
• class Fl GDI Graphics Driver
• class Fl GDI Printer Graphics Driver
• class Fl Quartz Graphics Driver
• class Fl Xlib Graphics Driver
Fl_Image
Fl_RGB_Image
Fl_BMP_Image
Fl_Widget
Fl_Box
Implements Fl Widget.
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
• Fl Box.H
• Fl Box.cxx
Fl_Widget
Fl_Group
Fl_Browser_
Fl_Browser
Public Types
• enum Fl Line Position { TOP, BOTTOM, MIDDLE }
For internal use only?
Scrolls the browser so the top item in the browser is showing the specified line.
• int value () const
Returns the line number of the currently selected line, or 0 if none.
• void value (int line)
Sets the browser’s value(), which selects the specified line.
• int visible (int line) const
Returns non-zero if the specified line is visible, 0 if hidden.
• ∼Fl Browser ()
The destructor deletes all list items and destroys the browser.
Note: If you are subclassing Fl Browser, it’s more efficient to use the protected methods item first()
and item next(), since Fl Browser internally uses linked lists to manage the browser’s items. For more info,
see find item(int).
Returns
Pointer to browser item that was removed (and is no longer valid).
See Also
add(), insert(), remove(), swap(int,int), clear()
322 CHAPTER 31. CLASS DOCUMENTATION
See Also
add(), insert(), remove(), swap(int,int), clear()
Scrolls the browser so the bottom item in the browser is showing the specified line.
Parameters
in line The line to be displayed at the bottom.
See Also
topline(), middleline(), bottomline(), displayed(), lineposition()
void Fl Browser::clear ( )
See Also
add(), insert(), remove(), swap(int,int), clear()
See Also
column char(), column widths()
See Also
column char(), column widths()
31.7. FL BROWSER CLASS REFERENCE 323
See Also
column char(), column widths()
See Also
column char(), column widths()
Returns
The user data pointer (can be NULL)
Returns
1 if visible, 0 if not visible.
See Also
topline(), middleline(), bottomline(), displayed(), lineposition()
See Also
item at(), find line(), lineno()
• ’@.’ Print rest of line, don’t look for more ’@’ signs
• ’@@’ Print rest of line starting with ’@’
31.7. FL BROWSER CLASS REFERENCE 325
See Also
item height(), item width(),
incr height(), full height()
Reimplemented from Fl Browser .
Parameters
in line The line to be hidden. (1 based)
See Also
show(int), hide(int), display(), visible(), make visible()
Returns
The icon defined, or NULL if none.
See Also
item height(), item width(),
incr height(), full height()
Parameters
in line The new line will be inserted above this line (1 based).
in item The item to be added.
Returns
The item, or NULL if line out of range.
See Also
item at(), find line(), lineno()
void Fl Browser::item draw ( void ∗ item, int X, int Y, int W, int H ) const [protected],
[virtual]
Draws item at the position specified by X Y W H.
The W and H values are used for clipping. Should only be called within the context of an FLTK draw().
Parameters
in item The item to be drawn
in X,Y,W,H position and size.
Implements Fl Browser .
Returns
The first item, or NULL if list is empty.
See Also
item first(), item last(), item next(), item prev()
Implements Fl Browser .
Returns
The height of the item in pixels.
See Also
item height(), item width(),
incr height(), full height()
Implements Fl Browser .
Returns
The last item, or NULL if list is empty.
See Also
item first(), item last(), item next(), item prev()
Reimplemented from Fl Browser .
Returns
The next item after item, or NULL if there are none after this one.
See Also
item first(), item last(), item next(), item prev()
Implements Fl Browser .
31.7. FL BROWSER CLASS REFERENCE 329
Parameters
in item The ’current’ item
Returns
The previous item before item, or NULL if there none before this one.
See Also
item first(), item last(), item next(), item prev()
Implements Fl Browser .
See Also
select(), selected(), value(), item select(), item selected()
Reimplemented from Fl Browser .
Returns
1 if selected, 0 if not.
See Also
select(), selected(), value(), item select(), item selected()
Reimplemented from Fl Browser .
See Also
swap(int,int), item swap()
Reimplemented from Fl Browser .
Parameters
in item The item whose label text is returned.
Returns
The item’s text string. (Can be NULL)
Returns
The width of the item in pixels.
See Also
item height(), item width(),
incr height(), full height()
Implements Fl Browser .
Returns
The line number of the item, or 0 if not found.
See Also
item at(), find line(), lineno()
See Also
topline(), middleline(), bottomline()
332 CHAPTER 31. CLASS DOCUMENTATION
Parameters
in filename The filename to load
Returns
1 if OK, 0 on error (errno has reason)
See Also
add()
See Also
show(int), hide(int), display(), visible(), make visible()
See Also
topline(), middleline(), bottomline(), displayed(), lineposition()
Parameters
in line Line to be removed. (1 based)
If line is out of range, no action is taken.
See Also
add(), insert(), remove(), swap(int,int), clear()
Returns
1 if the state changed, 0 if not.
See Also
select(), selected(), value(), item select(), item selected()
Returns
1 if item selected, 0 if not.
See Also
select(), selected(), value(), item select(), item selected()
Parameters
in line The line to be shown. (1 based)
See Also
show(int), hide(int), display(), visible(), make visible()
See Also
swap(int,int), item swap()
See Also
swap(int,int), item swap()
Returns
The text string (can be NULL)
336 CHAPTER 31. CLASS DOCUMENTATION
See Also
topline(), middleline(), bottomline(), displayed(), lineposition()
See Also
select(), selected(), value(), item select(), item selected()
Parameters
in line The line in the browser to be tested. (1 based)
See Also
show(int), hide(int), display(), visible(), make visible()
The documentation for this class was generated from the following files:
• Fl Browser.H
• Fl Browser.cxx
• Fl Browser load.cxx
Fl_Widget
Fl_Group
Fl_Browser_
Fl_Browser Fl_Check_Browser
Public Types
• enum {
HORIZONTAL = 1, VERTICAL = 2, BOTH = 3, ALWAYS ON = 4,
HORIZONTAL ALWAYS = 5, VERTICAL ALWAYS = 6, BOTH ALWAYS = 7 }
Values for has scrollbar().
Public Attributes
• Fl Scrollbar hscrollbar
Horizontal scrollbar.
• Fl Scrollbar scrollbar
Vertical scrollbar.
31.8. FL BROWSER CLASS REFERENCE 339
This optional method returns a string (label) that may be used for sorting.
• virtual int item width (void ∗item) const =0
This method must be provided by the subclass to return the width of the item in pixels.
• int leftedge () const
This method returns the X position of the left edge of the list area after adjusting for the scrollbar and border,
if any.
• void new list ()
This method should be called when the list data is completely replaced or cleared.
• void redraw line (void ∗item)
This method should be called when the contents of item has changed, but not its height.
• void redraw lines ()
This method will cause the entire list to be redrawn.
• void replacing (void ∗a, void ∗b)
This method should be used when item a is being replaced by item b.
• void ∗ selection () const
Returns the item currently selected, or NULL if there is no selection.
• void swapping (void ∗a, void ∗b)
This method should be used when two items a and b are being swapped.
• void ∗ top () const
Returns the item that appears at the top of the list.
The keyboard navigation of browser items is only possible if visible focus() is enabled. If disabled, the
widget rejects keyboard focus; Tab and Shift-Tab focus navigation will skip the widget.
In ’Select’ and ’Normal’ mode, the widget rejects keyboard focus; no navigation keys are supported
(other than scrollbar positioning).
In ’Hold’ mode, the widget accepts keyboard focus, and Up/Down arrow keys can navigate the selected
item.
In ’Multi’ mode, the widget accepts keyboard focus, and Up/Down arrow keys navigate the focus box;
Space toggles the current item’s selection, Enter selects only the current item (deselects all others). If Shift
(or Ctrl) is combined with Up/Down arrow keys, the current item’s selection state is extended to the next
item. In this way one can extend a selection or de-selection.
31.8. FL BROWSER CLASS REFERENCE 341
• bit 1: vertical
• bit 2: ’always’ (to be combined with bits 0 and 1)
• bit 3-31: reserved for future use
Enumerator
HORIZONTAL Only show horizontal scrollbar.
VERTICAL Only show vertical scrollbar.
BOTH Show both scrollbars. (default)
ALWAYS ON Specified scrollbar(s) should ’always’ be shown (to be used with HORIZONTAL/V-
ERTICAL)
HORIZONTAL ALWAYS Horizontal scrollbar always on.
VERTICAL ALWAYS Vertical scrollbar always on.
BOTH ALWAYS Both scrollbars always on.
Parameters
in item The item being deleted.
See Also
display(), displayed()
Returns
1 if visible, 0 if not visible.
See Also
display(), displayed()
Returns
The item, or NULL if not found
31.8. FL BROWSER CLASS REFERENCE 343
Returns
The height of the entire list, in pixels.
Reimplemented in Fl Browser.
Returns
The maximum width of all the items, in pixels.
Returns
1 if event was processed, 0 if not.
• 0 - No scrollbars.
• Fl Browser ::HORIZONTAL ALWAYS - Horizontal scrollbar always on, vertical always off.
• Fl Browser ::VERTICAL ALWAYS - Vertical scrollbar always on, horizontal always off.
See Also
position(), hposition()
Reimplemented in Fl Browser.
virtual void∗ Fl Browser ::item at ( int index ) const [inline], [protected], [virtual]
This method must be provided by the subclass to return the item for the specified index.
Parameters
in index The index of the item to be returned
Returns
The item at the specified index.
Reimplemented in Fl Browser.
31.8. FL BROWSER CLASS REFERENCE 345
virtual int Fl Browser ::item height ( void ∗ item ) const [protected], [pure virtual]
This method must be provided by the subclass to return the height of item in pixels.
Allow for two additional pixels for the list selection box.
Parameters
in item The item whose height is returned.
Returns
The height of the specified item in pixels.
See Also
item height(), item width(), item quick height()
Implemented in Fl Browser.
virtual void∗ Fl Browser ::item next ( void ∗ item ) const [protected], [pure virtual]
This method must be provided by the subclass to return the item in the list after item.
See Also
item first(), item next(), item last(), item prev()
Implemented in Fl Browser.
virtual void∗ Fl Browser ::item prev ( void ∗ item ) const [protected], [pure virtual]
This method must be provided by the subclass to return the item in the list before item.
See Also
item first(), item next(), item last(), item prev()
Implemented in Fl Browser.
int Fl Browser ::item quick height ( void ∗ item ) const [protected], [virtual]
This method may be provided by the subclass to return the height of the item, in pixels.
Allow for two additional pixels for the list selection box. This method differs from item height in that
it is only called for selection and scrolling operations. The default implementation calls item height.
346 CHAPTER 31. CLASS DOCUMENTATION
Parameters
in item The item whose height to return.
Returns
The height, in pixels.
void Fl Browser ::item select ( void ∗ item, int val = 1 ) [protected], [virtual]
This method must be implemented by the subclass if it supports multiple selections; sets the selection state
to val for the item.
Sets the selection state for item, where optional val is 1 (select, the default) or 0 (de-select).
Parameters
in item The item to be selected
in val The optional selection state; 1=select, 0=de-select.
The default is to select the item (1).
Reimplemented in Fl Browser.
virtual const char∗ Fl Browser ::item text ( void ∗ item ) const [inline], [protected],
[virtual]
This optional method returns a string (label) that may be used for sorting.
Parameters
in item The item whose label text is returned.
Returns
The item’s text label. (Can be NULL if blank)
Reimplemented in Fl Browser.
virtual int Fl Browser ::item width ( void ∗ item ) const [protected], [pure virtual]
This method must be provided by the subclass to return the width of the item in pixels.
Allow for two additional pixels for the list selection box.
31.8. FL BROWSER CLASS REFERENCE 347
Parameters
in item The item whose width is returned.
Returns
The width of the item in pixels.
Implemented in Fl Browser.
See Also
Fl Browser ::bbox()
See Also
position(), hposition()
Parameters
in item The item that needs to be redrawn.
See Also
redraw lines(), redraw line()
See Also
Fl::scrollbar size(int)
31.8. FL BROWSER CLASS REFERENCE 349
See Also
Fl::scrollbar size()
Returns
1 if state was changed, 0 if not.
Parameters
in item The item to select.
in docallbacks If 1, invokes widget callback if item changed.
If 0, doesn’t do callback (default).
• Fl Browser .H
• Fl Browser .cxx
Fl_Widget
Fl_Button
Fl_Radio_Round_Button
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label
Implements Fl Widget.
Reimplemented in Fl Light Button, and Fl Return Button.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
in v button value.
See Also
set(), clear()
The documentation for this class was generated from the following files:
• Fl Button.H
• Fl Button.cxx
Note
Only available when configure has the –enable-cairo option
The documentation for this class was generated from the following files:
• Fl Cairo.H
• Fl Cairo.cxx
356 CHAPTER 31. CLASS DOCUMENTATION
Fl_Widget
Fl_Group
Fl_Window
Fl_Double_Window
Fl_Cairo_Window
Public Types
• typedef void(∗ cairo draw cb )(Fl Cairo Window ∗self, cairo t ∗def)
This defines the cairo draw callback prototype that you must further.
Note
You can alternatively define your custom cairo fltk window, and thus at least override the draw()
method to provide custom cairo support. In this case you will probably use Fl::cairo make current(-
Fl Window∗) to attach a context to your window. You should do it only when your window is the
current window.
See Also
Fl Window::current()
31.12. FL CHART CLASS REFERENCE 357
Fl_Widget
Fl_Chart
• FL SPECIALPIE CHART: Like FL PIE CHART, but the first slice is separated from the pie.
• FL SPIKE CHART: Each sample value is drawn as a vertical line.
Parameters
in a,b are used to set lower, upper
Implements Fl Widget.
void Fl Chart::insert ( int ind, double val, const char ∗ str = 0, unsigned col = 0 )
Inserts a data value val at the given position ind.
Position 1 is the first data value.
Parameters
in ind insertion position
in val data value
in str optional data label
in col optional data color
void Fl Chart::replace ( int ind, double val, const char ∗ str = 0, unsigned col = 0 )
Replace a data value val at the given position ind.
Position 1 is the first data value.
Parameters
in ind insertion position
in val data value
in str optional data label
in col optional data color
• Fl Chart.H
• Fl Chart.cxx
Public Attributes
• unsigned col
For internal use only.
• char str [FL CHART LABEL MAX+1]
For internal use only.
• float val
For internal use only.
• Fl Chart.H
Fl_Widget
Fl_Group
Fl_Browser_
Fl_Check_Browser
Parameters
in event The event to process.
Returns
1 if event was processed, 0 if not.
• Fl Check Browser.H
• Fl Check Browser.cxx
Fl_Widget
Fl_Button
Fl_Light_Button
Fl_Check_Button
366 CHAPTER 31. CLASS DOCUMENTATION
Buttons generate callbacks when they are clicked by the user. You control exactly when and how by
changing the values for type() and when().
The Fl Check Button subclass displays its ”ON” state by showing a ”checkmark” rather than drawing
itself pushed in.
• Fl Check Button.H
• Fl Check Button.cxx
Fl_Widget
Fl_Menu_
Fl_Choice
31.16. FL CHOICE CLASS REFERENCE 367
• int Fl Widget::changed() const This value is true the user picks a different value. It is
turned off by value() and just before doing a callback (the callback can turn it back on if desired).
• void Fl Widget::set changed() This method sets the changed() flag.
Implements Fl Widget.
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
Sets the currently selected value using the index into the menu item array.
Changing the selected value causes a redraw().
Parameters
in v index of value in the menu item array.
Returns
non-zero if the new value is different to the old one.
Returns
non-zero if the new value is different to the old one.
The documentation for this class was generated from the following files:
• Fl Choice.H
• Fl Choice.cxx
Fl_Widget
Fl_Clock_Output
Fl_Clock
Fl_Round_Clock
Create an Fl Clock widget using the given position, size, and label string.
Create an Fl Clock widget using the given boxtype, position, size, and label string.
• ∼Fl Clock ()
See Also
Fl Event
Reimplemented from Fl Widget.
The documentation for this class was generated from the following files:
• Fl Clock.H
• Fl Clock.cxx
Fl_Widget
Fl_Clock_Output
Fl_Clock
Fl_Round_Clock
Parameters
in X,Y,W,H position and size
See Also
value(), minute(), second()
See Also
value(), hour(), second()
See Also
value(), hour(), minute()
See Also
value()
See Also
hour(), minute(), second()
31.19. FL COLOR CHOOSER CLASS REFERENCE 375
Fl_Widget
Fl_Group
Fl_Color_Chooser
Related Functions
(Note that these are not member functions.)
• int fl color chooser (const char ∗name, double &r, double &g, double &b, int cmode)
Pops up a window to let the user pick an arbitrary RGB color.
• int fl color chooser (const char ∗name, uchar &r, uchar &g, uchar &b, int cmode)
Pops up a window to let the user pick an arbitrary RGB color.
You can place any number of the widgets into a panel of your own design. The diagram shows the
widget as part of a color chooser dialog created by the fl color chooser() function. The Fl Color Chooser
widget contains the hue box, value slider, and rgb input fields from the above diagram (it does not have the
color chips or the Cancel or OK buttons). The callback is done every time the user changes the rgb value. It
is not done if they move the hue control in a way that produces the same rgb value, such as when saturation
or value is zero.
The fl color chooser() function 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 brightness using the vertical slider. Or they can type the 8-bit numbers into the RGB Fl Value Input
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).
fl color chooser() 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.
If you use the color chooser on an 8-bit screen, it will allocate all the available colors, leaving you no
space to exactly represent the color the user picks! You can however use fl rectf() to fill a region with a
simulated color using dithering.
31.19. FL COLOR CHOOSER CLASS REFERENCE 377
Returns
1 if a new hsv value was set, 0 if the hsv value was the previous one.
void Fl Color Chooser::hsv2rgb ( double H, double S, double V, double & R, double & G, double
& B ) [static]
This static method converts HSV colors to RGB colorspace.
Parameters
in H,S,V color components
out R,G,B color components
Returns
color modes are rgb(0), byte(1), hex(2), or hsv(3)
Returns
1 if a new rgb value was set, 0 if the rgb value was the previous one.
void Fl Color Chooser::rgb2hsv ( double R, double G, double B, double & H, double & S, double
& V ) [static]
• Fl Color Chooser.H
• Fl Color Chooser.cxx
31.20. FL COPY SURFACE CLASS REFERENCE 379
Fl_Device
Fl_Surface_Device
Fl_Copy_Surface
Platform details:
380 CHAPTER 31. CLASS DOCUMENTATION
• MSWindows: Transparent RGB images copy without transparency. The graphical data is copied to
the clipboard as an ’enhanced metafile’.
• Mac OS: The graphical data is copied to the clipboard (a.k.a. pasteboard) in 2 ’flavors’: 1) in vectorial
form as PDF data; 2) in bitmap form as a TIFF image (or PICT for Mac OS 10.3). Applications to
which the clipboard content is pasted can use the flavor that suits them best.
• X11: the graphical data is copied to the clipboard as an image in BMP format.
• Fl Copy Surface.H
• Fl Copy Surface.cxx
Fl_Widget
Fl_Valuator
Fl_Counter
Fl_Simple_Counter
See Also
Fl Spinner for value input with vertical step arrows.
Creates a new Fl Counter widget using the given position, size, and label string.
The default type is FL NORMAL COUNTER.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label
Implements Fl Widget.
31.22. FL DEVICE CLASS REFERENCE 383
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
• Fl Counter.H
• Fl Counter.cxx
Fl_Device
Fl_Graphics_Driver Fl_Surface_Device
Fl_GDI_Graphics_Driver Fl_Copy_Surface
Fl_PostScript_Graphics_Driver Fl_Display_Device
Fl_Quartz_Graphics_Driver Fl_Image_Surface
Fl_Xlib_Graphics_Driver Fl_Paged_Device
Virtual destructor.
The destructor of Fl Device must be virtual to make the destructors of derived classes being called
correctly on destruction.
Reimplemented in Fl Display Device, Fl Surface Device, Fl Xlib Graphics Driver, Fl GDI Printer -
Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, Fl Graphics Driver, Fl PostScript-
File Device, Fl Printer, Fl Paged Device, Fl PostScript Printer, Fl Copy Surface, Fl System Printer, Fl-
Image Surface, and Fl PostScript Graphics Driver.
31.23. FL DEVICE PLUGIN CLASS REFERENCE 385
Fl_Plugin
Fl_Device_Plugin
• Fl Device.H
Fl_Widget
Fl_Valuator
Fl_Dial
Fl_Fill_Dial Fl_Line_Dial
• Fl Dial.H
• Fl Dial.cxx
388 CHAPTER 31. CLASS DOCUMENTATION
Fl_Device
Fl_Surface_Device
Fl_Display_Device
Fl_Widget
Fl_Group
Fl_Window
Fl_Double_Window
Fl_Cairo_Window Fl_Overlay_Window
Protected Attributes
• char force doublebuffering
Force double buffering, even if the OS already buffers windows (overlays need that on MacOS and Win-
dows2000)
390 CHAPTER 31. CLASS DOCUMENTATION
This makes sure you can use Xdbe on servers where double buffering does not exist for every visual.
See Also
Fl Window::show(int argc, char ∗∗argv)
• Fl Double Window.H
• Fl Double Window.cxx
The documentation for this class was generated from the following file:
• Fl Group.H
Fl_Widget
Fl_Group
Fl_Browser_
Fl_Browser
Fl_File_Browser
Public Types
• enum { FILES, DIRECTORIES }
int Fl File Browser::load ( const char ∗ directory, Fl File Sort F ∗ sort = fl numericsort )
• Fl File Browser.H
• Fl File Browser.cxx
Public Types
• enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 }
394 CHAPTER 31. CLASS DOCUMENTATION
Rescan the current directory without clearing the filename, then select the file if it is in the list.
• void show ()
Shows the Fl File Chooser window.
• int shown ()
Returns non-zero if the file chooser main window show() has been called (but not hide() see Fl Window-
::shown()
• void textcolor (Fl Color c)
Sets the current Fl File Browser text color.
• Fl Color textcolor ()
Gets the current Fl File Browser text color.
• void textfont (Fl Font f)
Sets the current Fl File Browser text font.
• Fl Font textfont ()
Gets the current Fl File Browser text font.
• void textsize (Fl Fontsize s)
Sets the current Fl File Browser text size.
• Fl Fontsize textsize ()
Gets the current Fl File Browser text size.
• void type (int t)
Sets the current type of Fl File Chooser.
• int type ()
Gets the current type of Fl File Chooser.
• void ∗ user data () const
Gets the file chooser user data.
• void user data (void ∗d)
Sets the file chooser user data d.
• const char ∗ value (int f=1)
Gets the current value of the selected file(s).
• void value (const char ∗filename)
Sets the current value of the selected file.
• int visible ()
Returns 1 if the Fl File Chooser window is visible.
• ∼Fl File Chooser ()
Destroys the widget and frees all memory used by it.
Public Attributes
• Fl Button ∗ newButton
The ”new directory” button is exported so that application developers can control the appearance and use.
• Fl Check Button ∗ previewButton
The ”preview” button is exported so that application developers can control the appearance and use.
• Fl Check Button ∗ showHiddenButton
When checked, hidden files (i.e., filename begins with dot) are displayed.
396 CHAPTER 31. CLASS DOCUMENTATION
Related Functions
(Note that these are not member functions.)
• char ∗ fl dir chooser (const char ∗message, const char ∗fname, int relative)
Shows a file chooser dialog and gets a directory.
• char ∗ fl file chooser (const char ∗message, const char ∗pat, const char ∗fname, int relative)
Shows a file chooser dialog and gets a filename.
• void fl file chooser callback (void(∗cb)(const char ∗))
Set the file chooser callback.
• void fl file chooser ok label (const char ∗l)
Set the ”OK” button label.
31.29. FL FILE CHOOSER CLASS REFERENCE 397
The Fl File Chooser widget transmits UTF-8 encoded filenames to its user. It is recommended to open
files that may have non-ASCII names with the fl fopen() or fl open() utility functions that handle these
names in a cross-platform way (whereas the standard fopen()/open() functions fail on the MSWindows
platform to open files with a non-ASCII name).
The Fl File Chooser class also exports several static values that may be used to localize or customize
the appearance of all file chooser dialogs:
The Fl File Chooser::sort member specifies the sort function that is used when loading the contents of
a directory and can be customized at run-time.
The Fl File Chooser class also exports the Fl File Chooser::newButton and Fl File Chooser::preview-
Button widgets so that application developers can control their appearance and use. For more complex
customization, consider copying the FLTK file chooser code and changing it accordingly.
The file chooser will automatically add the ”All Files (∗)” pattern to the end of the string you pass if
you do not provide one. The first filter in the string is the default filter.
See the FLTK documentation on fl filename match() for the kinds of pattern strings that are supported.
The type argument can be one of the following:
• CREATE - allows the user to select a single, existing file or specify a new filename.
The title argument is used to set the title bar text for the Fl File Chooser window.
Note
Fl File Chooser does not delete extra widget in destructor! To prevent memory leakage, don’t forget
to delete unused extra widgets
31.29. FL FILE CHOOSER CLASS REFERENCE 399
• Fl File Chooser.H
• Fl File Chooser.cxx
• Fl File Chooser2.cxx
• fl file dir.cxx
Public Types
• enum {
ANY, PLAIN, FIFO, DEVICE,
LINK, DIRECTORY }
• enum {
END, COLOR, LINE, CLOSEDLINE,
POLYGON, OUTLINEPOLYGON, VERTEX }
Parameters
in p filename pattern
in t file type
in nd number of data values
in d data values
void Fl File Icon::draw ( int x, int y, int w, int h, Fl Color ic, int active = 1 )
Draws an icon in the indicated area.
Parameters
404 CHAPTER 31. CLASS DOCUMENTATION
Fl File Icon ∗ Fl File Icon::find ( const char ∗ filename, int filetype = ANY ) [static]
Finds an icon that matches the given filename and file type.
Parameters
in filename name of file
in filetype enumerated file type
Returns
matching file icon or NULL
void Fl File Icon::labeltype ( const Fl Label ∗ o, int x, int y, int w, int h, Fl Align a ) [static]
Draw the icon label.
Parameters
in o label data
in x,y,w,h position and size of label
in a label alignment [not used]
Returns
0 on success, non-zero on error
Returns
0 on success, non-zero on error
• Fl File Icon.H
• Fl File Icon.cxx
• Fl File Icon2.cxx
Fl_Widget
Fl_Input_
Fl_Input
Fl_File_Input
Note
As all Fl Input derived objects, Fl File Input may call its callback when losing focus (see FL UN-
FOCUS) to update its state like its cursor shape. One resulting side effect is that you should call
clear changed() early in your callback to avoid reentrant calls if you plan to show another window or
dialog box in the callback.
Sets the value of the widget given a new string value and its length.
Returns non 0 on success.
Parameters
in str new string value
in len lengh of value
The documentation for this class was generated from the following files:
• Fl File Input.H
• Fl File Input.cxx
Fl_Widget
Fl_Valuator
Fl_Dial
Fl_Fill_Dial
• Fl Fill Dial.H
• Fl Dial.cxx
Fl_Widget
Fl_Valuator
Fl_Slider
Fl_Fill_Slider
• Fl Fill Slider.H
• Fl Slider.cxx
410 CHAPTER 31. CLASS DOCUMENTATION
Fl_Widget
Fl_Input_
Fl_Input
Fl_Float_Input
• Fl Float Input.H
• Fl Input.cxx
Fl_FLTK_File_Chooser
Fl_GTK_File_Chooser
31.35. FL FLTK FILE CHOOSER CLASS REFERENCE 411
Protected Attributes
• int btype
• char ∗ directory
• char ∗ errmsg
• Fl File Chooser ∗ file chooser
• char ∗ filter
• int filtvalue
• int nfilters
• int options
• char ∗ parsedfilt
• char ∗ preset file
• char ∗ prevvalue
Friends
• class Fl Native File Chooser
The documentation for this class was generated from the following files:
Public Attributes
• Fl Font Descriptor ∗ next
linked list for this Fl Fontdesc
• Fl Fontsize size
font size
• Fl Font.H
The documentation for this struct was generated from the following file:
• Fl Font.H
Fl_Widget
Fl_FormsBitmap
31.39. FL FORMSPIXMAP CLASS REFERENCE 413
• Fl FormsBitmap.H
• forms bitmap.cxx
Fl_Widget
Fl_FormsPixmap
Implements Fl Widget.
31.39. FL FORMSPIXMAP CLASS REFERENCE 415
Parameters
in B existing pixmap
• Fl FormsPixmap.H
• forms pixmap.cxx
Fl_Widget
Fl_FormsText
Implements Fl Widget.
The documentation for this class was generated from the following file:
• forms.H
Fl_Widget
Fl_Free
Parameters
in t type
in X,Y,W,H position and size
in L widget label
in hdl handler function
The constructor takes both the type and the handle function. The handle function should be declared as
follows:
int handle function(Fl Widget *w,
int event,
float event x,
float event y,
char key)
This function is called from the handle() method in response to most events, and is called by the draw()
method.
The event argument contains the event type:
// old event names for compatibility:
#define FL MOUSE FL DRAG
#define FL DRAW 0
#define FL STEP 9
#define FL FREEMEM 12
#define FL FREEZE FL UNMAP
#define FL THAW FL MAP
Implements Fl Widget.
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
• Fl Free.H
• forms free.cxx
Fl_Device
Fl_Graphics_Driver
Fl_GDI_Graphics_Driver
Fl_GDI_Printer_Graphics_Driver
• void draw (Fl RGB Image ∗img, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl RGB Image object to the device.
• void draw image (const uchar ∗buf, int X, int Y, int W, int H, int D=3, int L=0)
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• void draw image (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=3)
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• void draw image mono (const uchar ∗buf, int X, int Y, int W, int H, int D=1, int L=0)
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• void draw image mono (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=1)
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• void font (Fl Font face, Fl Fontsize size)
see fl font(Fl Font face, Fl Fontsize size).
• int height ()
see fl height().
• void rtl draw (const char ∗str, int n, int x, int y)
see fl rtl draw(const char ∗str, int n, int x, int y).
• void text extents (const char ∗, int n, int &dx, int &dy, int &w, int &h)
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
• double width (const char ∗str, int n)
see fl width(const char ∗str, int n).
• double width (unsigned int c)
see fl width(unsigned int n).
see fl descent().
Reimplemented from Fl Graphics Driver.
void Fl GDI Graphics Driver::draw ( const char ∗ str, int n, int x, int y ) [virtual]
void Fl GDI Graphics Driver::draw ( int angle, const char ∗ str, int n, int x, int y ) [virtual]
see fl draw(int angle, const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
void Fl GDI Graphics Driver::draw ( Fl Pixmap ∗ pxm, int XP, int YP, int WP, int HP, int cx, int
cy ) [virtual]
void Fl GDI Graphics Driver::draw ( Fl Bitmap ∗ bm, int XP, int YP, int WP, int HP, int cx, int
cy ) [virtual]
void Fl GDI Graphics Driver::draw ( Fl RGB Image ∗ rgb, int XP, int YP, int WP, int HP, int cx,
int cy ) [virtual]
void Fl GDI Graphics Driver::draw image ( const uchar ∗ buf, int X, int Y, int W, int H, int D =
3, int L = 0 ) [virtual]
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.
422 CHAPTER 31. CLASS DOCUMENTATION
void Fl GDI Graphics Driver::draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int Y, int
W, int H, int D = 3 ) [virtual]
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.
void Fl GDI Graphics Driver::draw image mono ( const uchar ∗ buf, int X, int Y, int W, int H,
int D = 1, int L = 0 ) [virtual]
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.
void Fl GDI Graphics Driver::draw image mono ( Fl Draw Image Cb cb, void ∗ data, int X, int
Y, int W, int H, int D = 1 ) [virtual]
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.
void Fl GDI Graphics Driver::rtl draw ( const char ∗ str, int n, int x, int y ) [virtual]
see fl rtl draw(const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
void Fl GDI Graphics Driver::text extents ( const char ∗ t, int n, int & dx, int & dy, int & w, int
& h ) [virtual]
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
Reimplemented from Fl Graphics Driver.
• Fl Device.H
• fl color win32.cxx
• Fl Device.cxx
• fl draw image win32.cxx
31.43. FL GDI PRINTER GRAPHICS DRIVER CLASS REFERENCE 423
Fl_Device
Fl_Graphics_Driver
Fl_GDI_Graphics_Driver
Fl_GDI_Printer_Graphics_Driver
void Fl GDI Printer Graphics Driver::draw ( Fl Pixmap ∗ pxm, int XP, int YP, int WP, int HP,
int cx, int cy ) [virtual]
Draws an Fl Pixmap object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl GDI Graphics Driver.
void Fl GDI Printer Graphics Driver::draw ( Fl Bitmap ∗ bm, int XP, int YP, int WP, int HP, int
cx, int cy ) [virtual]
Draws an Fl Bitmap object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl GDI Graphics Driver.
The documentation for this class was generated from the following files:
• Fl Device.H
• Fl Device.cxx
Fl_Image
Fl_Pixmap
Fl_GIF_Image
• Fl GIF Image.H
• Fl GIF Image.cxx
Public Attributes
• Colormap colormap
• XVisualInfo ∗ vis
The documentation for this class was generated from the following files:
• Fl Gl Choice.H
• Fl Gl Choice.cxx
Fl_Widget
Fl_Group
Fl_Window
Fl_Gl_Window
Fl_Glut_Window
Friends
• class Fl Gl Overlay
Return values
NULL if this widget is not derived from Fl Gl Window.
Note
This method is provided to avoid dynamic cast.
See Also
Fl Widget::as group(), Fl Widget::as window()
If double-buffering is enabled in the window, the back and front buffers are swapped after this function
is completed.
Reimplemented from Fl Window.
Reimplemented in Fl Glut Window.
void Fl Gl Window::ortho ( )
Sets the projection so 0,0 is in the lower left of the window and each pixel is 1 unit wide/tall.
If you are drawing 2D images, your draw() method may want to call this if valid() is false.
See Also
Fl Window::show(int argc, char ∗∗argv)
You can turn valid() on by calling valid(1). You should only do this after fixing the transformation
inside a draw() or after make current(). This is done automatically after draw() returns.
The documentation for this class was generated from the following files:
• Fl Gl Window.H
• Fl Gl Overlay.cxx
• Fl Gl Window.cxx
Public Attributes
• Fl Font font
• Fl Fontsize size
• glut.H
The documentation for this struct was generated from the following file:
• glut.H
The documentation for this struct was generated from the following file:
• glut.H
432 CHAPTER 31. CLASS DOCUMENTATION
The documentation for this struct was generated from the following file:
• glut.H
The documentation for this struct was generated from the following file:
• glut.H
Fl_Widget
Fl_Group
Fl_Window
Fl_Gl_Window
Fl_Glut_Window
Public Attributes
• void(∗ display )()
• void(∗ entry )(int)
• void(∗ keyboard )(uchar, int x, int y)
• int menu [3]
• void(∗ motion )(int x, int y)
• void(∗ mouse )(int b, int state, int x, int y)
• int number
• void(∗ overlaydisplay )()
• void(∗ passivemotion )(int x, int y)
• void(∗ reshape )(int w, int h)
• void(∗ special )(int, int x, int y)
• void(∗ visibility )(int)
Fl Glut Window::Fl Glut Window ( int X, int Y, int W, int H, const char ∗ t )
Creates a glut window, registers to the glut windows list.
If double-buffering is enabled in the window, the back and front buffers are swapped after this function
is completed.
Reimplemented from Fl Gl Window.
• glut.H
• glut compatability.cxx
Fl_Device
Fl_Graphics_Driver
Fl_GDI_Printer_Graphics_Driver
Classes
• struct matrix
A 2D coordinate transformation matrix.
see fl font(void).
• Fl Font Descriptor ∗ font descriptor ()
Returns a pointer to the current Fl Font Descriptor for the graphics driver.
• void font descriptor (Fl Font Descriptor ∗d)
Sets the current Fl Font Descriptor for the graphics driver.
• virtual int height ()
see fl height().
• Fl Fontsize size ()
see fl size().
• virtual void text extents (const char ∗, int n, int &dx, int &dy, int &w, int &h)
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
• virtual double width (const char ∗str, int n)
see fl width(const char ∗str, int n).
• virtual double width (unsigned int c)
see fl width(unsigned int n).
• virtual ∼Fl Graphics Driver ()
The destructor.
• virtual void loop (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
• void mult matrix (double a, double b, double c, double d, double x, double y)
see fl mult matrix(double a, double b, double c, double d, double x, double y).
• virtual int not clipped (int x, int y, int w, int h)
see fl not clipped(int x, int y, int w, int h).
• virtual void pie (int x, int y, int w, int h, double a1, double a2)
see fl pie(int x, int y, int w, int h, double a1, double a2).
• virtual void point (int x, int y)
see fl point(int x, int y).
• virtual void polygon (int x0, int y0, int x1, int y1, int x2, int y2)
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2).
• virtual void polygon (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
• virtual void pop clip ()
see fl pop clip().
• void pop matrix ()
see fl pop matrix().
• virtual void push clip (int x, int y, int w, int h)
see fl push clip(int x, int y, int w, int h).
• void push matrix ()
see fl push matrix().
• virtual void push no clip ()
see fl push no clip().
• virtual void rect (int x, int y, int w, int h)
see fl rect(int x, int y, int w, int h).
• virtual void rectf (int x, int y, int w, int h)
see fl rectf(int x, int y, int w, int h).
• void restore clip ()
see fl restore clip().
• void rotate (double d)
see fl rotate(double d).
• virtual void rtl draw (const char ∗str, int n, int x, int y)
see fl rtl draw(const char ∗str, int n, int x, int y).
• void scale (double x, double y)
see fl scale(double x, double y).
• void scale (double x)
see fl scale(double x).
• double transform dx (double x, double y)
see fl transform dx(double x, double y).
• double transform dy (double x, double y)
see fl transform dy(double x, double y).
• double transform x (double x, double y)
see fl transform x(double x, double y).
• double transform y (double x, double y)
see fl transform y(double x, double y).
438 CHAPTER 31. CLASS DOCUMENTATION
Protected Attributes
• matrix ∗ fl matrix
Points to the current coordinate transformation matrix.
Friends
• void fl arc (double x, double y, double r, double start, double end)
Adds a series of points to the current path on the arc of a circle.
• void fl arc (int x, int y, int w, int h, double a1, double a2)
Draw ellipse sections using integer coordinates.
• void fl begin complex polygon ()
Starts drawing a complex filled polygon.
• void fl begin line ()
Starts drawing a list of lines.
• void fl begin loop ()
Starts drawing a closed sequence of lines.
• void fl begin points ()
Starts drawing a list of points.
• void fl begin polygon ()
Starts drawing a convex filled polygon.
• class Fl Bitmap
• void fl circle (double x, double y, double r)
fl circle() is equivalent to fl arc(x,y,r,0,360), but may be faster.
• int fl clip box (int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
Intersects the rectangle with the current clip region and returns the bounding box of the result.
• Fl Region fl clip region ()
Returns the current clipping region.
• void fl clip region (Fl Region r)
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 439
Replaces the top of the clipping stack with a clipping region of any shape.
• void fl color (Fl Color c)
Sets the color for all subsequent drawing operations.
• void fl color (uchar r, uchar g, uchar b)
Sets the color for all subsequent drawing operations.
• void fl copy offscreen (int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy)
Copy a rectangular area of the given offscreen buffer into the current drawing destination.
• void fl curve (double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3,
double Y3)
Adds a series of points on a Bezier curve to the path.
• void fl draw (const char ∗str, int n, int x, int y)
Draws starting at the given x, y location a UTF-8 string of length n bytes.
• void fl draw (int angle, const char ∗str, int n, int x, int y)
Draws at the given x, y location a UTF-8 string of length n bytes rotating angle degrees counter-
clockwise.
• void fl draw image (const uchar ∗buf, int X, int Y, int W, int H, int D, int L)
Draws an 8-bit per color RGB or luminance image.
• void fl draw image (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D)
Draws an image using a callback function to generate image data.
• void fl draw image mono (const uchar ∗buf, int X, int Y, int W, int H, int D, int L)
Draws a gray-scale (1 channel) image.
• FL EXPORT void fl draw image mono (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int
H, int D)
Draws a gray-scale image using a callback function to generate image data.
• void fl end complex polygon ()
Ends complex filled polygon, and draws.
• void fl end line ()
Ends list of lines, and draws.
• void fl end loop ()
Ends closed sequence of lines, and draws.
• void fl end points ()
Ends list of points, and draws.
• void fl end polygon ()
Ends convex filled polygon, and draws.
• void fl font (Fl Font face, Fl Fontsize size)
Sets the current font, which is then used in various drawing routines.
• void fl gap ()
Call fl gap() to separate loops of the path.
• void fl line (int x, int y, int x1, int y1)
Draws a line from (x,y) to (x1,y1)
• void fl line (int x, int y, int x1, int y1, int x2, int y2)
Draws a line from (x,y) to (x1,y1) and another from (x1,y1) to (x2,y2)
• void fl line style (int style, int width, char ∗dashes)
Sets how to draw lines (the ”pen”).
• void fl loop (int x0, int y0, int x1, int y1, int x2, int y2)
Outlines a 3-sided polygon with lines.
• void fl loop (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
440 CHAPTER 31. CLASS DOCUMENTATION
void Fl Graphics Driver::arc ( int x, int y, int w, int h, double a1, double a2 ) [protected],
[virtual]
see fl arc(int x, int y, int w, int h, double a1, double a2).
Reimplemented in Fl PostScript Graphics Driver.
442 CHAPTER 31. CLASS DOCUMENTATION
int Fl Graphics Driver::clip box ( int x, int y, int w, int h, int & X, int & Y, int & W, int & H )
[protected], [virtual]
see fl clip box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H).
Reimplemented in Fl PostScript Graphics Driver.
see fl color(void).
void Fl Graphics Driver::curve ( double X0, double Y0, double X1, double Y1, double X2, double
Y2, double X3, double Y3 ) [protected], [virtual]
see fl curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3).
Reimplemented in Fl PostScript Graphics Driver.
see fl descent().
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.
virtual void Fl Graphics Driver::draw ( const char ∗ str, int n, int x, int y ) [inline],
[protected], [virtual]
virtual void Fl Graphics Driver::draw ( int angle, const char ∗ str, int n, int x, int y )
[inline], [protected], [virtual]
see fl draw(int angle, const char ∗str, int n, int x, int y).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.
virtual void Fl Graphics Driver::draw ( Fl RGB Image ∗ rgb, int XP, int YP, int WP, int HP, int
cx, int cy ) [inline], [protected], [virtual]
virtual void Fl Graphics Driver::draw ( Fl Pixmap ∗ pxm, int XP, int YP, int WP, int HP, int cx,
int cy ) [inline], [protected], [virtual]
Draws an Fl Pixmap object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Printer Graphics Driver, Fl GDI Graphics Driver,
Fl Quartz Graphics Driver, and Fl PostScript Graphics Driver.
virtual void Fl Graphics Driver::draw ( Fl Bitmap ∗ bm, int XP, int YP, int WP, int HP, int cx,
int cy ) [inline], [protected], [virtual]
Draws an Fl Bitmap object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Printer Graphics Driver, Fl GDI Graphics Driver,
Fl Quartz Graphics Driver, and Fl PostScript Graphics Driver.
virtual void Fl Graphics Driver::draw image ( const uchar ∗ buf, int X, int Y, int W, int H, int D
= 3, int L = 0 ) [inline], [protected], [virtual]
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.
virtual void Fl Graphics Driver::draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int Y,
int W, int H, int D = 3 ) [inline], [protected], [virtual]
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.
virtual void Fl Graphics Driver::draw image mono ( const uchar ∗ buf, int X, int Y, int W, int H,
int D = 1, int L = 0 ) [inline], [protected], [virtual]
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.
virtual void Fl Graphics Driver::draw image mono ( Fl Draw Image Cb cb, void ∗ data, int X,
int Y, int W, int H, int D = 1 ) [inline], [protected], [virtual]
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.
virtual void Fl Graphics Driver::font ( Fl Font face, Fl Fontsize fsize ) [inline], [virtual]
see fl font(void).
see fl gap().
Reimplemented in Fl PostScript Graphics Driver.
see fl height().
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.
void Fl Graphics Driver::line ( int x, int y, int x1, int y1 ) [protected], [virtual]
void Fl Graphics Driver::line ( int x, int y, int x1, int y1, int x2, int y2 ) [protected],
[virtual]
see fl line(int x, int y, int x1, int y1, int x2, int y2).
Reimplemented in Fl PostScript Graphics Driver.
void Fl Graphics Driver::line style ( int style, int width = 0, char ∗ dashes = 0 ) [protected],
[virtual]
void Fl Graphics Driver::loop ( int x0, int y0, int x1, int y1, int x2, int y2 ) [protected],
[virtual]
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2).
Reimplemented in Fl PostScript Graphics Driver.
void Fl Graphics Driver::loop ( int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3 )
[protected], [virtual]
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
Reimplemented in Fl PostScript Graphics Driver.
void Fl Graphics Driver::mult matrix ( double a, double b, double c, double d, double x, double
y ) [protected]
see fl mult matrix(double a, double b, double c, double d, double x, double y).
int Fl Graphics Driver::not clipped ( int x, int y, int w, int h ) [protected], [virtual]
see fl not clipped(int x, int y, int w, int h).
Reimplemented in Fl PostScript Graphics Driver.
void Fl Graphics Driver::pie ( int x, int y, int w, int h, double a1, double a2 ) [protected],
[virtual]
see fl pie(int x, int y, int w, int h, double a1, double a2).
Reimplemented in Fl PostScript Graphics Driver.
void Fl Graphics Driver::polygon ( int x0, int y0, int x1, int y1, int x2, int y2 ) [protected],
[virtual]
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2).
Reimplemented in Fl PostScript Graphics Driver.
void Fl Graphics Driver::polygon ( int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3 )
[protected], [virtual]
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
Reimplemented in Fl PostScript Graphics Driver.
void Fl Graphics Driver::push clip ( int x, int y, int w, int h ) [protected], [virtual]
see fl push clip(int x, int y, int w, int h).
Reimplemented in Fl PostScript Graphics Driver.
virtual void Fl Graphics Driver::rtl draw ( const char ∗ str, int n, int x, int y ) [inline],
[protected], [virtual]
see fl rtl draw(const char ∗str, int n, int x, int y).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.
void Fl Graphics Driver::text extents ( const char ∗ t, int n, int & dx, int & dy, int & w, int & h )
[virtual]
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.
448 CHAPTER 31. CLASS DOCUMENTATION
virtual double Fl Graphics Driver::width ( const char ∗ str, int n ) [inline], [virtual]
see fl width(const char ∗str, int n).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.
void Fl Graphics Driver::xyline ( int x, int y, int x1, int y2 ) [protected], [virtual]
see fl xyline(int x, int y, int x1, int y2).
Reimplemented in Fl PostScript Graphics Driver.
void Fl Graphics Driver::xyline ( int x, int y, int x1, int y2, int x3 ) [protected], [virtual]
see fl xyline(int x, int y, int x1, int y2, int x3).
Reimplemented in Fl PostScript Graphics Driver.
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 449
void Fl Graphics Driver::yxline ( int x, int y, int y1, int x2 ) [protected], [virtual]
see fl yxline(int x, int y, int y1, int x2).
Reimplemented in Fl PostScript Graphics Driver.
void Fl Graphics Driver::yxline ( int x, int y, int y1, int x2, int y3 ) [protected], [virtual]
see fl yxline(int x, int y, int y1, int x2, int y3).
Reimplemented in Fl PostScript Graphics Driver.
void fl arc ( int x, int y, int w, int h, double a1, double a2 ) [friend]
Draw ellipse sections using integer coordinates.
These functions match the rather limited circle drawing code provided by X and WIN32. The advantage
over using fl arc with floating point coordinates is that they are faster because they often use the hardware,
and they draw much nicer small circles, since the small sizes are often hard-coded bitmaps.
If a complete circle is drawn it will fit inside the passed bounding box. The two angles are measured
in degrees counter-clockwise from 3 o’clock and are the starting and ending angle of the arc, a2 must be
greater or equal to a1.
fl arc() draws a series of lines to approximate the arc. Notice that the integer version of fl arc() has
a different number of arguments than the double version fl arc(double x, double y, double r, double start,
double end)
450 CHAPTER 31. CLASS DOCUMENTATION
Parameters
in x,y,w,h bounding box of complete circle
in a1,a2 start and end angles of arc measured in degrees counter-clockwise from
3 o’clock. a2 must be greater than or equal to a1.
int fl clip box ( int x, int y, int w, int h, int & X, int & Y, int & W, int & H ) [friend]
Intersects the rectangle with the current clip region and returns the bounding box of the result.
Returns non-zero if the resulting rectangle is different to the original. This can be used to limit the
necessary drawing to a rectangle. W and H are set to zero if the rectangle is completely outside the region.
Parameters
in x,y,w,h position and size of rectangle
out X,Y,W,H position and size of resulting bounding box.
Returns
Non-zero if the resulting rectangle is different to the original.
Parameters
in r clipping region
void fl copy offscreen ( int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy )
[friend]
Copy a rectangular area of the given offscreen buffer into the current drawing destination.
Parameters
x,y position where to draw the copied rectangle
w,h size of the copied rectangle
pixmap offscreen buffer containing the rectangle to copy
srcx,srcy origin in offscreen buffer of rectangle to copy
void fl curve ( double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3,
double Y3 ) [friend]
Adds a series of points on a Bezier curve to the path.
The curve ends (and two of the points) are at X0,Y0 and X3,Y3.
Parameters
in X0,Y0 curve start point
in X1,Y1 curve control point
in X2,Y2 curve control point
in X3,Y3 curve end point
void fl draw image ( const uchar ∗ buf, int X, int Y, int W, int H, int D = 3, int L = 0 )
[friend]
Draws an 8-bit per color RGB or luminance image.
452 CHAPTER 31. CLASS DOCUMENTATION
Parameters
in buf points at the ”r” data of the top-left pixel. Color data must be in r,g,b
order. Luminance data is only one gray byte.
in X,Y position where to put top-left corner of image
in W,H size of the image
in D delta to add to the pointer between pixels. It may be any value greater
than or equal to 1, or it can be negative to flip the image horizontally
in L delta to add to the pointer between lines (if 0 is passed it uses W ∗ D),
and may be larger than W ∗ D to crop data, or negative to flip the image
vertically
It is highly recommended that you put the following code before the first show() of any window in your
program to get rid of the dithering if possible:
Fl::visual(FL RGB);
Gray scale (1-channel) images may be drawn. This is done if abs(D) is less than 3, or by calling fl -
draw image mono(). Only one 8-bit sample is used for each pixel, and on screens with different numbers
of bits for red, green, and blue only gray colors are used. Setting D greater than 1 will let you display one
channel of a color image.
Note:
The X version does not support all possible visuals. If FLTK cannot draw the image in the current
visual it will abort. FLTK supports any visual of 8 bits or less, and all common TrueColor visuals up
to 32 bits.
void fl draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int Y, int W, int H, int D = 3 )
[friend]
Draws an image using a callback function to generate image data.
You can generate the image as it is being drawn, or do arbitrary decompression of stored data, provided
it can be decompressed to individual scan lines easily.
Parameters
in cb callback function to generate scan line data
in data user data passed to callback function
in X,Y screen position of top left pixel
in W,H image width and height
in D data size in bytes (must be greater than 0)
See Also
fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L)
The callback function cb is called with the void∗ data user data pointer to allow access to a structure
of information about the image, and the x, y, and w of the scan line desired from the image. 0,0 is the
upper-left corner of the image, not x, y. A pointer to a buffer to put the data into is passed. You must copy
w pixels from scanline y, starting at pixel x, to this buffer.
Due to cropping, less than the whole image may be requested. So x may be greater than zero, the first
y may be greater than zero, and w may be less than W. The buffer is long enough to store the entire W ∗ D
pixels, this is for convenience with some decompression schemes where you must decompress the entire
line at once: decompress it into the buffer, and then if x is not zero, copy the data over so the x’th pixel
is at the start of the buffer.
You can assume the y’s will be consecutive, except the first one may be greater than zero.
If D is 4 or more, you must fill in the unused bytes with zero.
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 453
void fl draw image mono ( const uchar ∗ buf, int X, int Y, int W, int H, int D = 1, int L = 0 )
[friend]
Draws a gray-scale (1 channel) image.
See Also
fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L)
FL EXPORT void fl draw image mono ( Fl Draw Image Cb cb, void ∗ data, int X, int Y, int W,
int H, int D = 1 ) [friend]
Draws a gray-scale image using a callback function to generate image data.
See Also
fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D)
void fl line style ( int style, int width = 0, char ∗ dashes = 0 ) [friend]
Sets how to draw lines (the ”pen”).
If you change this it is your responsibility to set it back to the default using fl line style(0).
Parameters
in style A bitmask which is a bitwise-OR of a line style, a cap style, and a join
style. If you don’t specify a dash type you will get a solid line. If you
don’t specify a cap or join type you will get a system-defined default of
whatever value is fastest.
in width The thickness of the lines in pixels. Zero results in the system defined
default, which on both X and Windows is somewhat different and nicer
than 1.
in dashes A pointer to an array of dash lengths, measured in pixels. The first lo-
cation 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.
Note
Because of how line styles are implemented on Win32 systems, you must set the line style after
setting the drawing color. If you set the color after the line style you will lose the line style settings.
The dashes array does not work under Windows 95, 98 or Me, since those operating systems do
not support complex line styles.
454 CHAPTER 31. CLASS DOCUMENTATION
void fl mult matrix ( double a, double b, double c, double d, double x, double y ) [friend]
Concatenates another transformation onto the current one.
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 455
Parameters
in a,b,c,d,x,y transformation matrix elements such that X’ = aX + cY + x and
Y’ = bX +dY + y
Returns
non-zero if any of the rectangle intersects the current clip region. If this returns 0 you don’t have to
draw the object.
Note
Under X this returns 2 if the rectangle is partially clipped, and 1 if it is entirely inside the clip region.
void fl pie ( int x, int y, int w, int h, double a1, double a2 ) [friend]
Draw filled ellipse sections using integer coordinates.
Like fl arc(), but fl pie() draws a filled-in pie slice. This slice may extend outside the line drawn by
fl arc(); to avoid this use w - 1 and h - 1.
Parameters
in x,y,w,h bounding box of complete circle
in a1,a2 start and end angles of arc measured in degrees counter-clockwise from
3 o’clock. a2 must be greater than or equal to a1.
void fl polygon ( int x0, int y0, int x1, int y1, int x2, int y2 ) [friend]
Fills a 3-sided polygon.
The polygon must be convex.
void fl polygon ( int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3 ) [friend]
Fills a 4-sided polygon.
The polygon must be convex.
Parameters
in x,y,w,h position and size
Parameters
in x,y coordinate
• Fl Device.H
• fl arc.cxx
• fl arci.cxx
• fl curve.cxx
• Fl Device.cxx
• Fl Double Window.cxx
• fl line style.cxx
• fl rect.cxx
• fl vertex.cxx
Fl_Widget
Fl_Group
Fl_Browser_
Fl_Color_Chooser
Fl_Help_View
Fl_Input_Choice
Fl_Pack
Fl_Scroll
Fl_Spinner
Fl_Table
Fl_Tabs
Fl_Text_Display
Fl_Tile
Fl_Tree
Fl_Window
Fl_Wizard
• void clear ()
Deletes all child widgets from memory recursively.
• void clip children (int c)
Controls whether the group widget clips the drawing of child widgets to its bounding box.
• unsigned int clip children ()
Returns the current clipping mode.
• void end ()
Exactly the same as current(this->parent()).
• int find (const Fl Widget ∗) const
Searches the child array for the widget and returns the index.
• int find (const Fl Widget &o) const
See int Fl Group::find(const Fl Widget ∗w) const.
• Fl Group (int, int, int, int, const char ∗=0)
Creates a new Fl Group widget using the given position, size, and label string.
• void focus (Fl Widget ∗W)
• void forms end ()
This is for forms compatibility only.
• int handle (int)
Handles the specified event.
• void init sizes ()
Resets the internal array of widget sizes and positions.
• void insert (Fl Widget &, int i)
The widget is removed from its current group (if any) and then inserted into this group.
• void insert (Fl Widget &o, Fl Widget ∗before)
This does insert(w, find(before)).
• void remove (int index)
Removes the widget at index from the group but does not delete it.
• void remove (Fl Widget &)
Removes a widget from the group but does not delete it.
• void remove (Fl Widget ∗o)
Removes the widget o from the group.
• void resizable (Fl Widget &o)
See void Fl Group::resizable(Fl Widget ∗box)
• void resizable (Fl Widget ∗o)
The resizable widget defines the resizing box for the group.
• Fl Widget ∗ resizable () const
See void Fl Group::resizable(Fl Widget ∗box)
• void resize (int, int, int, int)
Resizes the Fl Group widget and all of its children.
• virtual ∼Fl Group ()
The destructor also deletes all the children.
Return values
NULL if this widget is not derived from Fl Group.
Note
This method is provided to avoid dynamic cast.
See Also
Fl Widget::as window(), Fl Widget::as gl window()
void Fl Group::begin ( )
Sets the current group so you can build the widget tree by just constructing the widgets.
begin() is automatically called by the constructor for Fl Group (and thus for Fl Window as well). be-
gin() is exactly the same as current(this). Don’t forget to end() the group or window!
void Fl Group::clear ( )
Deletes all child widgets from memory recursively.
This method differs from the remove() method in that it affects all child widgets and deletes them from
memory.
See Also
void Fl Group::clip children(int c)
See Also
Fl Group::current()
Implements Fl Widget.
Reimplemented in Fl Table, Fl Tree, Fl Text Display, Fl Tabs, Fl Window, Fl Scroll, Fl Pack, and
Fl Glut Window.
void Fl Group::draw outside label ( const Fl Widget & widget ) const [protected]
Parents normally call this to draw outside labels of child widgets.
void Fl Group::end ( )
Exactly the same as current(this->parent()).
Any new widgets added to the widget tree will be added to the parent of the group.
31.54. FL GROUP CLASS REFERENCE 463
See Also
Fl Widget::take focus();
See Also
Fl Event
Note
The internal array of widget sizes and positions will be allocated and filled when the next resize()
occurs.
See Also
sizes()
464 CHAPTER 31. CLASS DOCUMENTATION
The widget is removed from its current group (if any) and then inserted into this group.
It is put at index n - or at the end, if n >= children(). This can also be used to rearrange the widgets
inside a group.
Removes the widget at index from the group but does not delete it.
This method does nothing if index is out of bounds.
This method differs from the clear() method in that it only affects a single widget and does not delete it
from memory.
Since
FLTK 1.3.0
Removes a widget from the group but does not delete it.
This method does nothing if the widget is not a child of the group.
This method differs from the clear() method in that it only affects a single widget and does not delete it
from memory.
Note
If you have the child’s index anyway, use remove(int index) instead, because this doesn’t need a child
lookup in the group’s table of children. This can be much faster, if there are lots of children.
See Also
void remove(Fl Widget&)
The resizable widget defines the resizing box for the group.
When the group is resized it calculates a new size and position for all of its children. Widgets that are
horizontally or vertically inside the dimensions of the box are scaled to the new size. Widgets outside the
box are moved.
In these examples the gray area is the resizable:
31.54. FL GROUP CLASS REFERENCE 465
The resizable may be set to the group itself, in which case all the contents are resized. This is the
default value for Fl Group, although NULL is the default for Fl Window and Fl Pack.
If the resizable is NULL then all widgets remain a fixed size and distance from the top-left corner.
It is possible to achieve any type of resize behavior by using an invisible Fl Box as the resizable and/or
by using a hierarchy of child Fl Group’s.
See Also
Fl Group::resizable(Fl Widget∗)
Fl Group::resizable()
Fl Widget::resize(int,int,int,int)
If the sizes() array does not exist, it will be allocated and filled with the current widget sizes and
positions.
Note
You should never need to use this method directly, unless you have special needs to rearrange the
children of a Fl Group. Fl Tile uses this to rearrange its widget positions.
See Also
init sizes()
See Also
Fl Group::draw child(Fl Widget& widget) const
The documentation for this class was generated from the following files:
• Fl Group.H
• Fl Group.cxx
• forms compatability.cxx
Fl_FLTK_File_Chooser
Fl_GTK_File_Chooser
Friends
• class Fl Native File Chooser
The documentation for this struct was generated from the following file:
• Fl Help View.H
The first form sets the current buffer to the string provided and reformats the text.
• const char ∗ value () const
The first form sets the current buffer to the string provided and reformats the text.
• int visible ()
Returns 1 if the Fl Help Dialog window is visible.
• int w ()
Returns the position and size of the help dialog.
• int x ()
Returns the position and size of the help dialog.
• int y ()
Returns the position and size of the help dialog.
• ∼Fl Help Dialog ()
The destructor destroys the widget and frees all memory that has been allocated for the current file.
Loads the specified HTML file into the Fl Help View widget.
The filename can also contain a target name (”filename.html#target”).
void Fl Help Dialog::resize ( int xx, int yy, int ww, int hh )
Sets or gets the default text size for the help view.
Sets the internal Fl Help View instance text size.
Delegates call to encapsulated view void Fl Help View::textsize(Fl Fontsize s) instance method
Sets or gets the default text size for the help view.
The first form sets the current buffer to the string provided and reformats the text.
It also clears the history of the ”back” and ”forward” buttons. The second form returns the current
buffer contents.
The first form sets the current buffer to the string provided and reformats the text.
It also clears the history of the ”back” and ”forward” buttons. The second form returns the current
buffer contents.
• Fl Help Dialog.H
• Fl Help Dialog.cxx
• Fl Help Dialog Dox.cxx
Protected Attributes
• Fl Help Font Style elts [100]
font elements
• size t nfonts
current number of fonts in stack
void Fl Help Font Stack::top ( Fl Font & f, Fl Fontsize & s, Fl Color & c ) [inline]
Gets the top (current) element on the stack.
The documentation for this struct was generated from the following file:
• Fl Help View.H
31.59. FL HELP FONT STYLE STRUCT REFERENCE 471
Public Attributes
• Fl Color c
Font Color.
• Fl Font f
Font.
• Fl Fontsize s
Font Size.
• Fl Help View.H
Public Attributes
• char filename [192]
Reference filename.
• int h
Height of link text.
• char name [32]
Link target (blank if none)
• int w
Width of link text.
• int x
X offset of link text.
• int y
Y offset of link text.
472 CHAPTER 31. CLASS DOCUMENTATION
Public Attributes
• char name [32]
Target name.
• int y
Y offset of target.
Fl_Widget
Fl_Group
Fl_Help_View
The constructor creates the Fl Help View widget at the specified position and size.
• void leftline (int)
Scrolls the text to the indicated position, given a pixel column.
• int leftline () const
Gets the left position in pixels.
• void link (Fl Help Func ∗fn)
This method assigns a callback function to use when a link is followed or a file is loaded (via Fl Help View-
::load()) that requires a different file or path.
• int load (const char ∗f)
Loads the specified file.
• void resize (int, int, int, int)
Resizes the help widget.
• int scrollbar size () const
Gets the current size of the scrollbars’ troughs, in pixels.
• void scrollbar size (int newSize)
Sets the pixel size of the scrollbars’ troughs to newSize, in pixels.
• void select all ()
Selects all the text in the view.
• int size () const
Gets the size of the help view.
• void size (int W, int H)
• void textcolor (Fl Color c)
Sets the default text color.
• Fl Color textcolor () const
Returns the current default text color.
• void textfont (Fl Font f)
Sets the default text font.
• Fl Font textfont () const
Returns the current default text font.
• void textsize (Fl Fontsize s)
Sets the default text size.
• Fl Fontsize textsize () const
Gets the default text size.
• const char ∗ title ()
Returns the current document title, or NULL if there is no title.
• void topline (const char ∗n)
Scrolls the text to the indicated position, given a named destination.
• void topline (int)
Scrolls the text to the indicated position, given a pixel line.
• int topline () const
Returns the current top line in pixels.
• void value (const char ∗val)
Sets the current help text buffer to the string provided and reformats the text.
• const char ∗ value () const
Returns the current buffer contents.
• ∼Fl Help View ()
Destroys the Fl Help View widget.
474 CHAPTER 31. CLASS DOCUMENTATION
• A: HREF/NAME
• B
• BODY: BGCOLOR/TEXT/LINK
• BR
• CENTER
• CODE
• DD
• DL
• DT
• EM
• FONT: COLOR/SIZE/FACE=(helvetica/arial/sans/times/serif/symbol/courier)
• H1/H2/H3/H4/H5/H6
• HEAD
• HR
• I
• IMG: SRC/WIDTH/HEIGHT/ALT
• KBD
• LI
• OL
• P
• PRE
• STRONG
• TABLE: TH/TD/TR/BORDER/BGCOLOR/COLSPAN/ALIGN=CENTER|RIGHT|LEFT
• TITLE
• TT
• U
• UL
• VAR
31.62. FL HELP VIEW CLASS REFERENCE 475
Returns
the matching position or -1 if not found
The link function can be used to retrieve remote or virtual documents, returning a temporary file that
contains the actual data. If the link function returns NULL, the value of the Fl Help View widget will
remain unchanged.
If the link callback cannot handle the URI scheme, it should return the uri value unchanged or set the
value() of the widget before returning NULL.
void Fl Help View::resize ( int xx, int yy, int ww, int hh ) [virtual]
Resizes the help widget.
Reimplemented from Fl Group.
31.62. FL HELP VIEW CLASS REFERENCE 477
Returns
Scrollbar size in pixels, or 0 if the global Fl::scrollbar size() is being used.
See Also
Fl::scrollbar size(int)
See Also
Fl::scrollbar size()
• Fl Help View.H
• Fl Help View.cxx
Fl_Widget
Fl_Group
Fl_Browser_
Fl_Browser
Fl_Hold_Browser
Creates a new Fl Hold Browser widget using the given position, size, and label string.
Creates a new Fl Hold Browser widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX. The constructor specializes Fl Browser() by setting the type
to FL HOLD BROWSER. The destructor destroys the widget and frees all memory that has been allocated.
The documentation for this class was generated from the following files:
• Fl Hold Browser.H
• Fl Browser.cxx
Fl_Widget
Fl_Valuator
Fl_Slider
Fl_Hor_Fill_Slider
Fl_Widget
Fl_Valuator
Fl_Slider
Fl_Hor_Nice_Slider
Fl_Widget
Fl_Valuator
Fl_Slider
Fl_Hor_Slider
The documentation for this class was generated from the following files:
• Fl Hor Slider.H
• Fl Slider.cxx
Fl_Widget
Fl_Valuator
Fl_Slider
Fl_Value_Slider
Fl_Hor_Value_Slider
Fl_Image
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• int ld () const
Returns the current line data size in bytes.
• virtual void uncache ()
If the image has been cached for display, delete the cache data.
• int w () const
Returns the current image width in pixels.
• virtual ∼Fl Image ()
The destructor is a virtual method that frees all memory used by the image.
• Fl Image.H
• Fl Image.cxx
Fl_Device
Fl_Surface_Device
Fl_Image_Surface
Parameters
w and
h give the size in pixels of the resulting image.
Fl_Widget
Fl_Input_
Fl_Input
Fl_Multiline_Output
488 CHAPTER 31. CLASS DOCUMENTATION
Creates a new Fl Input widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.
31.71. FL INPUT CLASS REFERENCE 489
Implements Fl Widget.
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
• Fl Input.H
• Fl Input.cxx
Fl_Widget
Fl_Input_
Fl_Input
Fl_Multiline_Output
All variables that represent an index into a text buffer are byte-oriented, not character oriented, counting
from 0 (at or before the first character) to size() (at the end of the buffer, after the last byte). Since UTF-8
characters can be up to six bytes long, simply incrementing such an index will not reliably advance to the
next character in the text buffer.
Indices and pointers into the text buffer should always point at a 7 bit ASCII character or the beginning
of a UTF-8 character sequence. Behavior for false UTF-8 sequences and pointers into the middle of a
sequence are undefined.
See Also
Fl Text Display, Fl Text Editor for more powerful text handling widgets
Returns
0 if no text is selected, 1 if the selection was copied
See Also
Fl::copy(const char ∗, int, int)
Returns
0 if the operation did not change the clipboard
See Also
copy(int), cut()
Returns
0 if no data was copied
Parameters
a,b range of bytes rounded to full characters and clamped to the buffer
Returns
0 if no data was copied
void Fl Input ::handle mouse ( int X, int Y, int , int , int drag = 0 ) [protected]
Handles mouse clicks and mouse moves.
int Fl Input ::handletext ( int event, int X, int Y, int W, int H ) [protected]
Handles all kinds of text field related events.
This is called by derived classes.
Todo Add comment and parameters
Returns
the character at index i
Parameters
in t new input type
Returns
0 if no text was inserted
Returns
end of the line
Returns
start of the line
Parameters
m new index of the mark
Returns
0 if the mark did not change
See Also
position(), position(int, int)
See Also
position(int, int)
Returns
0 if no positions changed
See Also
position(int), position(), mark(int)
Returns
0 if no positions changed
See Also
position(int, int), position(), mark(int)
Returns
non-zero if this widget is read-only
int Fl Input ::replace ( int b, int e, const char ∗ text, int ilen = 0 )
Deletes text from b to e and inserts the new string text.
All changes to the text buffer go through this function. It deletes the region between b and e (either
one may be less or equal to the other), and then inserts the string text at that point and moves the mark()
and position() to the end of the insertion. Does the callback if when() & FL WHEN CHANGED and there
is a change.
Set b and e equal to not delete anything. Set text to NULL to not insert anything.
ilen can be zero or strlen(text), which saves a tiny bit of time if you happen to already know
the length of the insertion, or can be used to insert a portion of a string. If ilen is zero, strlen(text)
is used instead.
31.71. FL INPUT CLASS REFERENCE 499
b and e are clamped to the 0..size() range, so it is safe to pass any values. b, e, and ilen are
used as numbers of bytes (not characters), where b and e count from 0 to size() (end of buffer).
If b and/or e don’t point to a valid UTF-8 character boundary, they are adjusted to the previous (b) or
the next (e) valid UTF-8 character boundary, resp..
If the current number of characters in the buffer minus deleted characters plus inserted characters in
text would overflow the number of allowed characters (maximum size()), then only the first characters
of the string are inserted, so that maximum size() is not exceeded.
cut() and insert() are just inline functions that call replace().
Parameters
in b beginning index of text to be deleted
in e ending index of text to be deleted and insertion position
in text string that will be inserted
in ilen length of text or 0 for nul terminated strings
Returns
0 if nothing changed
Note
If text does not point to a valid UTF-8 character or includes invalid UTF-8 sequences, the text is
inserted nevertheless (counting invalid UTF-8 bytes as one character each).
See Also
Fl Widget::resize(int, int, int, int)
See Also
Fl Button::shortcut()
Parameters
in s new shortcut keystroke
See Also
Fl Button::shortcut()
See Also
Fl Widget::size(int, int)
Returns
non-zero if the new value is different than the current one
Parameters
in str the new text
in len the length of the new text
Returns
non-zero if the new value is different than the current one
See Also
tab nav(), Fl::OPTION ARROW FOCUS.
See Also
tab nav(int), Fl::OPTION ARROW FOCUS.
See Also
textcolor(Fl Color)
Parameters
in n new text color
See Also
textcolor()
Parameters
in i index into the beginning of a line of text
in keepmark if set, move only the cursor, but not the mark
Returns
index to new cursor position
Returns
non-zero if the new value is different than the current one
See Also
Fl Input ::value(const char∗ str, int len), Fl Input ::value()
Returns
non-zero if the new value is different than the current one
See Also
Fl Input ::value(const char∗ str), Fl Input ::value()
See Also
Fl Input ::value(const char∗)
504 CHAPTER 31. CLASS DOCUMENTATION
Returns
end of the word
Returns
start of the word, or previous word
• Fl Input .H
• Fl Input .cxx
Fl_Widget
Fl_Group
Fl_Input_Choice
The user can either type into the input area, or use the menu button chooser on the right to choose an
item which loads the input area with the selected text.
The application can directly access both the internal Fl Input and Fl Menu Button widgets respectively
using the input() and menubutton() accessor methods.
See Also
Fl Group::resizable(Fl Widget∗)
Fl Group::resizable()
Fl Widget::resize(int,int,int,int)
Chooses item# val in the menu, and sets the Fl Input text field to that value.
Any previous text is cleared.
The documentation for this class was generated from the following files:
• Fl Input Choice.H
• Fl Group.cxx
Fl_Widget
Fl_Input_
Fl_Input
Fl_Int_Input
Creates a new Fl Int Input widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.
Inherited destructor destroys the widget and any value associated with it.
The documentation for this class was generated from the following files:
• Fl Int Input.H
• Fl Input.cxx
31.74. FL JPEG IMAGE CLASS REFERENCE 509
Fl_Image
Fl_RGB_Image
Fl_JPEG_Image
Fl JPEG Image::Fl JPEG Image ( const char ∗ name, const unsigned char ∗ data )
The constructor loads the JPEG image from memory.
Construct an image from a block of memory inside the application. Fluid offers ”binary Data” chunks
as a great way to add image data into the C++ source code. name png can be NULL. If a name is given,
the image is added to the list of shared images (see: Fl Shared Image) and will be available by that name.
The inherited destructor frees all memory and server resources that are used by the image.
There is no error function in this class. If the image has loaded correctly, w(), h(), and d() should return
values greater zero.
510 CHAPTER 31. CLASS DOCUMENTATION
Parameters
name A unique name or NULL
data A pointer to the memory location of the JPEG image
The documentation for this class was generated from the following files:
• Fl JPEG Image.H
• Fl JPEG Image.cxx
Public Attributes
• Fl Align align
alignment of label
• Fl Color color
text color
• Fl Image ∗ deimage
optional image for a deactivated label
• Fl Font font
label font used in text
• Fl Image ∗ image
optional image for an active label
• Fl Fontsize size
size of label font
• uchar type
type of label.
• const char ∗ value
label text
Todo For FLTK 1.3, the Fl Label type will become a widget by itself. That way we will be avoiding a
lot of code duplication by handling labels in a similar fashion to widgets containing text. We also
provide an easy interface for very complex labels, containing html or vector graphics.
31.75. FL LABEL STRUCT REFERENCE 511
Parameters
in,out W,H : this is the requested size for the label text plus image; on return, this
will contain the size needed to fit the label
type of label.
See Also
Fl Labeltype
The documentation for this struct was generated from the following files:
• Fl Widget.H
• fl labeltype.cxx
Fl_Widget
Fl_Button
Fl_Light_Button
Fl_Radio_Round_Button
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
• Fl Light Button.H
• Fl Light Button.cxx
Fl_Widget
Fl_Valuator
Fl_Dial
Fl_Line_Dial
• Fl Line Dial.H
• Fl Dial.cxx
• mac.H
• Fl.cxx
Fl_Widget
Fl_Menu_
Fl_Sys_Menu_Bar
Protected Attributes
• uchar alloc
• uchar down box
• Fl Color textcolor
• Fl Font textfont
• Fl Fontsize textsize
518 CHAPTER 31. CLASS DOCUMENTATION
Returns
The index into the menu() array, where the entry was added.
Description
If the menu array was directly set with menu(x), then copy() is done to make a private array.
Since this method can change the internal menu array, any menu item pointers or indecies the applica-
tion may have cached can become stale, and should be recalculated/refreshed.
A menu item’s callback must not add() items to its parent menu during the callback.
The characters ”&”, ”/”, ”\”, and ” ” are treated as special characters in the label string. The ”&”
character specifies that the following character is an accelerator and will be underlined. The ”\”
character is used to escape the next character in the string. Labels starting with the ” ” character cause
a divider to be placed after that menu item.
31.79. FL MENU CLASS REFERENCE 519
A label of the form ”File/Quit” will create the submenu ”File” with a menu item called ”Quit”. The
”/” character is ignored if it appears as the first character of the label string, e.g. ”/File/Quit”.
The label string is copied to new memory and can be freed. The other arguments (including the
shortcut) are copied into the menu item unchanged.
If an item exists already with that name then it is replaced with this new one. Otherwise this new one
is added to the end of the correct menu or submenu. The return value is the offset into the array that
the new entry was placed at.
shortcut
The keyboard shortcut for this menu item.
The shortcut can either be a raw integer value (eg. FL CTRL+’A’) or a string (eg. ”∧ c” or ”∧ 97”).
Raw integer shortcuts can be a combination of keyboard chars (eg. ’A’) and optional keyboard mod-
ifiers (see Fl::event state(), e.g. FL SHIFT, etc). In addition, FL COMMAND can be used to denote
FL META under Mac OS X and FL CTRL under other platforms.
..where <ascii value> is a decimal value representing an ascii character (eg. 97 is the ascii code for
’a’), and the optional prefixes enhance the value that follows. Multiple prefixes must appear in the
order below.
# - Alt
+ - Shift
ˆ - Control
Internally, the text shortcuts are converted to integer values using fl old shortcut(const char∗).
callback
The callback to invoke when this menu item is selected.
These are bit flags to define what kind of menu item this is.
520 CHAPTER 31. CLASS DOCUMENTATION
Returns
the index into the menu() array, where the entry was added
Since this method can change the internal menu array, any menu item pointers or indecies the appli-
cation may have cached can become stale, and should be recalculated/refreshed.
Example:
int index = menubar->find index("File/Recent"); // get index of "File/Recent" submenu
if ( index != -1 ) menubar->clear submenu(index); // clear the submenu
menubar->add("File/Recent/Aaa");
menubar->add("File/Recent/Bbb");
[..]
31.79. FL MENU CLASS REFERENCE 521
Parameters
index The index of the submenu to be cleared
Returns
0 on success, -1 if the index is out of range or not a submenu
See Also
remove(int)
Returns
The index of the matching item, or -1 if not found.
See Also
item pathname()
// Convert an item-to-index
int index = mymenu->find index(item);
if ( index == -1 ) { ..error.. }
522 CHAPTER 31. CLASS DOCUMENTATION
Parameters
item The ∗item to be found
Returns
The index of the item, or -1 if not found.
See Also
menu()
Returns
The index of the item with the specific callback, or -1 if not found
See Also
find index(const char∗)
Parameters
pathname The path and name of the menu item
Returns
The item found, or NULL if not found
See Also
find index(const char∗), find item(Fl Callback∗), item pathname()
31.79. FL MENU CLASS REFERENCE 523
Returns
The item found, or NULL if not found
See Also
find item(const char∗)
int Fl Menu ::insert ( int index, const char ∗ label, int shortcut, Fl Callback ∗ callback, void ∗
userdata = 0, int flags = 0 )
Inserts a new menu item at the specified index position.
If index is -1, the menu item is appended; same behavior as add().
To properly insert a menu item, label must be the name of the item (eg. ”Quit”), and not a ’menu
pathname’ (eg. ”File/Quit”). If a menu pathname is specified, the value of index is ignored, the new
item’s position defined by the pathname.
For more details, see add(). Except for the index parameter, add() has more detailed information on
parameters and behavior, and is functionally equivalent.
Parameters
in index The menu array’s index position where the new item is inserted. If -1,
behavior is the same as add().
in label The text label for the menu item. If the label is a menu pathname, index
is ignored, and the pathname indicates the position of the new item.
in shortcut Optional keyboard shortcut. Can be an int (FL CTRL+’a’) or a string
(”∧ a”). Default is 0.
in callback Optional callback invoked when user clicks the item. Default 0 if none.
in userdata Optional user data passed as an argument to the callback. Default 0 if
none.
in flags Optional flags that control the type of menu item; see add() for more
info. Default is 0 for none.
Returns
The index into the menu() array, where the entry was added.
See Also
add()
524 CHAPTER 31. CLASS DOCUMENTATION
int Fl Menu ::item pathname ( char ∗ name, int namelen, const Fl Menu Item ∗ finditem = 0 )
const
Get the menu ’pathname’ for the specified menuitem.
If finditem==NULL, mvalue() is used (the most recently picked menuitem).
Example:
Returns
• 0 : OK (name has menuitem’s pathname)
• -1 : item not found (name=””)
• -2 : ’name’ not large enough (name=””)
See Also
find item()
See Also
size() – returns the size of the Fl Menu Item array.
Returns
matched Fl Menu Item or NULL.
Fl_Widget
Fl_Menu_
Fl_Menu_Bar
Fl_Sys_Menu_Bar
If there is an item in the top menu that is not a title of a submenu, then it acts like a ”button” in the
menubar. Clicking on it will pick it.
When the user picks an item off the menu, the item’s callback is done with the menubar as the Fl -
Widget∗ argument. If the item does not have a callback the menubar’s callback is done instead.
528 CHAPTER 31. CLASS DOCUMENTATION
Submenus will also pop up in response to shortcuts indicated by putting a ’&’ character in the name
field of the menu item. If you put a ’&’ character in a top-level ”button” then the shortcut picks it. The ’&’
character in submenus is ignored until the menu is popped up.
Typing the shortcut() of any of the menu items will cause callbacks exactly the same as when you pick
the item with the mouse.
Implements Fl Widget.
Reimplemented in Fl Sys Menu Bar.
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
31.81. FL MENU BUTTON CLASS REFERENCE 529
See Also
Fl Event
• Fl Menu Bar.H
• Fl Menu Bar.cxx
Fl_Widget
Fl_Menu_
Fl_Menu_Button
Public Types
• enum popup buttons {
POPUP1 = 1, POPUP2, POPUP12, POPUP3,
POPUP13, POPUP23, POPUP123 }
indicate what mouse buttons pop up the menu.
Normally any mouse button will pop up a menu and it is lined up below the button as shown in the
picture. However an Fl Menu Button may also control a pop-up menu. This is done by setting the type().
If type() is zero a normal menu button is produced. If it is nonzero then this is a pop-up menu. The bits in
type() indicate what mouse buttons pop up the menu (see Fl Menu Button::popup buttons).
The menu will also pop up in response to shortcuts indicated by putting a ’&’ character in the label().
Typing the shortcut() of any of the menu items will cause callbacks exactly the same as when you pick
the item with the mouse. The ’&’ character in menu item names are only looked at when the menu is
popped up, however.
When the user picks an item off the menu, the item’s callback is done with the menu button as the
Fl Widget∗ argument. If the item does not have a callback the menu button’s callback is done instead.
Implements Fl Widget.
See Also
Fl Event
Reimplemented from Fl Widget.
Draws the menu item in bounding box x,y,w,h, optionally selects the item.
• const Fl Menu Item ∗ find shortcut (int ∗ip=0, const bool require alt=false) const
Search only the top level menu for a shortcut.
• const Fl Menu Item ∗ first () const
Returns the first menu item, same as next(0).
• Fl Menu Item ∗ first ()
Returns the first menu item, same as next(0).
• void hide ()
Hides an item in the menu.
• void image (Fl Image ∗a)
compatibility api for FLUID, same as a->label(this)
• void image (Fl Image &a)
compatibility api for FLUID, same as a.label(this)
• int insert (int, const char ∗, int, Fl Callback ∗, void ∗=0, int=0)
Inserts an item at position index.
• const char ∗ label () const
Returns the title of the item.
• void label (const char ∗a)
See const char∗ Fl Menu Item::label() const.
• void label (Fl Labeltype a, const char ∗b)
See const char∗ Fl Menu Item::label() const.
• Fl Color labelcolor () const
Gets the menu item’s label color.
• void labelcolor (Fl Color a)
Sets the menu item’s label color.
• Fl Font labelfont () const
Gets the menu item’s label font.
• void labelfont (Fl Font a)
Sets the menu item’s label font.
• Fl Fontsize labelsize () const
Gets the label font pixel size/height.
• void labelsize (Fl Fontsize a)
Sets the label font pixel size/height.
• Fl Labeltype labeltype () const
Returns the menu item’s labeltype.
• void labeltype (Fl Labeltype a)
Sets the menu item’s labeltype.
• int measure (int ∗h, const Fl Menu ∗) const
Measures width of label, including effect of & characters.
• const Fl Menu Item ∗ next (int=1) const
Advance a pointer by n items through a menu array, skipping the contents of submenus and invisible items.
• Fl Menu Item ∗ next (int i=1)
Advances a pointer by n items through a menu array, skipping the contents of submenus and invisible items.
• const Fl Menu Item ∗ popup (int X, int Y, const char ∗title=0, const Fl Menu Item ∗picked=0, const
Fl Menu ∗=0) const
This method is called by widgets that want to display menus.
534 CHAPTER 31. CLASS DOCUMENTATION
• const Fl Menu Item ∗ pulldown (int X, int Y, int W, int H, const Fl Menu Item ∗picked=0, const
Fl Menu ∗=0, const Fl Menu Item ∗title=0, int menubar=0) const
Pulldown() is similar to popup(), but a rectangle is provided to position the menu.
• int radio () const
Returns true if this item is a radio item.
• void set ()
Turns the check or radio item ”on” for the menu item.
• void setonly ()
Turns the radio item ”on” for the menu item and turns off adjacent radio items set.
• int shortcut () const
Gets what key combination shortcut will trigger the menu item.
• void shortcut (int s)
Sets exactly what key combination will trigger the menu item.
• void show ()
Makes an item visible in the menu.
• int size () const
Size of the menu starting from this menu item.
• int submenu () const
Returns true if either FL SUBMENU or FL SUBMENU POINTER is on in the flags.
• const Fl Menu Item ∗ test shortcut () const
This is designed to be called by a widgets handle() method in response to a FL SHORTCUT event.
• void uncheck ()
back compatibility only
• void ∗ user data () const
Gets the user data() argument that is sent to the callback function.
• void user data (void ∗v)
Sets the user data() argument that is sent to the callback function.
• int value () const
Returns the current value of the check or radio item.
• int visible () const
Gets the visibility of an item.
Public Attributes
• Fl Callback ∗ callback
menu item callback
• int flags
menu item flags like FL MENU TOGGLE, FL MENU RADIO
• Fl Color labelcolor
menu item text color
• Fl Font labelfont
which font for this menu item text
• Fl Fontsize labelsize
size of menu item text
• uchar labeltype
how the menu item text looks like
• int shortcut
31.82. FL MENU ITEM STRUCT REFERENCE 535
The Fl Menu Item structure defines a single menu item that is used by the Fl Menu class.
produces:
536 CHAPTER 31. CLASS DOCUMENTATION
A submenu title is identified by the bit FL SUBMENU in the flags field, and ends with a label() that is
NULL. You can nest menus to any depth. A pointer to the first item in the submenu can be treated as an
Fl Menu array itself. It is also possible to make separate submenu arrays with FL SUBMENU POINTER
flags.
You should use the method functions to access structure members and not access them directly to avoid
compatibility problems with future releases of FLTK.
int Fl Menu Item::add ( const char ∗ mytext, int sc, Fl Callback ∗ cb, void ∗ data = 0, int myflags
=0 )
Adds an item.
The text is split at ’/’ characters to automatically produce submenus (actually a totally unnecessary
feature as you can now add submenu titles directly by setting SUBMENU in the flags):
See Also
Fl Callback p Fl MenuItem::callback() const
See Also
Fl Callback p Fl MenuItem::callback() const
See Also
Fl Callback p Fl MenuItem::callback() const
538 CHAPTER 31. CLASS DOCUMENTATION
See Also
Fl Callback p Fl MenuItem::callback() const
Deprecated .
Deprecated .
void Fl Menu Item::draw ( int x, int y, int w, int h, const Fl Menu ∗ m, int selected = 0 ) const
Draws the menu item in bounding box x,y,w,h, optionally selects the item.
const Fl Menu Item ∗ Fl Menu Item::find shortcut ( int ∗ ip = 0, const bool require alt = false )
const
Search only the top level menu for a shortcut.
Either &x in the label or the shortcut fields are used.
This tests the current event, which must be an FL KEYBOARD or FL SHORTCUT, against a shortcut
value.
Parameters
ip returns the index of the item, if ip is not NULL.
require alt if true: match only if Alt key is pressed.
Returns
found Fl Menu Item or NULL
int Fl Menu Item::insert ( int index, const char ∗ mytext, int sc, Fl Callback ∗ cb, void ∗ data = 0,
int myflags = 0 )
Inserts an item at position index.
If index is -1, the item is added the same way as Fl Menu Item::add().
If ’mytext’ contains any un-escaped front slashes (/), it’s assumed a menu pathname is being specified,
and the value of index will be ignored.
In all other aspects, the behavior of insert() is the same as add().
Parameters
index insert new items here
mytext new label string, details see above
sc keyboard shortcut for new item
cb callback function for new item
data user data for new item
myflags menu flags as described in FL Menu Item
Returns
the index into the menu() array, where the entry was added
540 CHAPTER 31. CLASS DOCUMENTATION
const Fl Menu Item ∗ Fl Menu Item::popup ( int X, int Y, const char ∗ title = 0, const
Fl Menu Item ∗ picked = 0, const Fl Menu ∗ button = 0 ) const
This method is called by widgets that want to display menus.
The menu stays up until the user picks an item or dismisses it. The selected item (or NULL if none) is
returned. This does not do the callbacks or change the state of check or radio items.
X,Y is the position of the mouse cursor, relative to the window that got the most recent event (usually
you can pass Fl::event x() and Fl::event y() unchanged here).
title is a character string title for the menu. If non-zero a small box appears above the menu with
the title in it.
The menu is positioned so the cursor is centered over the item picked. This will work even if picked
is in a submenu. If picked is zero or not in the menu item table the menu is positioned with the cursor in
the top-left corner.
button is a pointer to an Fl Menu from which the color and boxtypes for the menu are pulled. If
NULL then defaults are used.
const Fl Menu Item ∗ Fl Menu Item::pulldown ( int X, int Y, int W, int H, const Fl Menu Item ∗
initial item = 0, const Fl Menu ∗ pbutton = 0, const Fl Menu Item ∗ t = 0, int menubar = 0 ) const
Pulldown() is similar to popup(), but a rectangle is provided to position the menu.
The menu is made at least W wide, and the picked item is centered over the rectangle (like Fl Choice
uses). If picked is zero or not found, the menu is aligned just below the rectangle (like a pulldown menu).
The title and menubar arguments are used internally by the Fl Menu Bar widget.
Gets what key combination shortcut will trigger the menu item.
Sets exactly what key combination will trigger the menu item.
The value is a logical ’or’ of a key and a set of shift flags, for instance FL ALT+’a’ or FL ALT+FL -
F+10 or just ’a’. A value of zero disables the shortcut.
The key can be any value returned by Fl::event key(), but will usually be an ASCII letter. Use a lower-
case letter unless you require the shift key to be held down.
The shift flags can be any set of values accepted by Fl::event state(). If the bit is on that shift key must
be pushed. Meta, Alt, Ctrl, and Shift must be off if they are not in the shift flags (zero for the other bits
indicates a ”don’t care” setting).
Deprecated .
Note
The returned value for a checked menu item as of FLTK 1.3.2 is FL MENU VALUE (4), but may
be 1 in a future version.
31.83. FL MENU WINDOW CLASS REFERENCE 543
Fl_Widget
Fl_Group
Fl_Window
Fl_Single_Window
Fl_Menu_Window
Fl Menu Window::Fl Menu Window ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Menu Window widget using the given position, size, and label string.
See Also
Fl Window::show(int argc, char ∗∗argv)
• Fl Menu Window.H
• Fl Menu Window.cxx
Fl_Widget
Fl_Group
Fl_Browser_
Fl_Browser
Fl_Multi_Browser
• Fl Multi Browser.H
• Fl Browser.cxx
Public Attributes
• const char ∗ labela
• const char ∗ labelb
• uchar typea
• uchar typeb
The documentation for this struct was generated from the following files:
• Fl Multi Label.H
• Fl Multi Label.cxx
Fl_Widget
Fl_Input_
Fl_Input
Fl_Multiline_Input
This is far from the nirvana of text editors, and is probably only good for small bits of text, 10 lines at
most. Note that this widget does not support scrollbars or per-character color control.
If you are presenting large amounts of text and need scrollbars or full color control of characters, you
probably want Fl Text Editor instead.
In FLTK 1.3.x, the default behavior of the ’Tab’ key was changed to support consistent focus naviga-
tion. To get the older FLTK 1.1.x behavior, set Fl Input ::tab nav() to 0. Newer programs should consider
using Fl Text Editor.
• Fl Multiline Input.H
• Fl Input.cxx
Fl_Widget
Fl_Input_
Fl_Input
Fl_Output
Fl_Multiline_Output
• Fl Multiline Output.H
• Fl Input.cxx
Public Types
• enum Option {
NO OPTIONS = 0x0000, SAVEAS CONFIRM = 0x0001, NEW FOLDER = 0x0002, PREVIEW
= 0x0004,
USE FILTER EXT = 0x0008 }
• enum Type {
BROWSE FILE = 0, BROWSE DIRECTORY, BROWSE MULTI FILE, BROWSE MULTI DI-
RECTORY,
BROWSE SAVE FILE, BROWSE SAVE DIRECTORY }
Gets how many filters were available, not including ”All Files”.
• Fl Native File Chooser (int val=BROWSE FILE)
The constructor.
• void options (int o)
Sets the platform specific chooser options to val.
• int options () const
Gets the platform specific Fl Native File Chooser::Option flags.
• void preset file (const char ∗f)
Sets the default filename for the chooser.
• const char ∗ preset file () const
Get the preset filename.
• int show ()
Post the chooser’s dialog.
• void title (const char ∗t)
Set the title of the file chooser’s dialog window.
• const char ∗ title () const
Get the title of the file chooser’s dialog window.
• void type (int t)
Sets the current Fl Native File Chooser::Type of browser.
• int type () const
Gets the current Fl Native File Chooser::Type of browser.
• ∼Fl Native File Chooser ()
Destructor.
The Fl Native File Chooser widget transmits UTF-8 encoded filenames to its user. It is recommended
to open files that may have non-ASCII names with the fl fopen() or fl open() utility functions that han-
dle these names in a cross-platform way (whereas the standard fopen()/open() functions fail on the MS-
Windows platform to open files with a non-ASCII name).
Platform Specific Caveats
• Under X windows, and if Fl::OPTION FNFC USES GTK has not been switched off, the widget
attempts to use standard GTK file chooser dialogs if they are available at run-time on the platform,
and falls back to use FLTK’s Fl File Chooser if they are not. In the latter case, it’s best if you
call Fl File Icon::load system icons() at the start of main(), to enable the nicer looking file browser
widgets. Use the static public attributes of class Fl File Chooser to localize the browser.
• Some operating systems support certain OS specific options; see Fl Native File Chooser::options()
for a list.
if ( fnfc->show() == 0 ) {
// Print all filenames user selected
for (int n=0; n<fnfc->count(); n++ ) {
printf("%d) ’%s’\n", n, fnfc->filename(n));
}
}
if ( fnfc->show() == 0 ) {
// Print all filenames user selected
for (int n=0; n<fnfc->count(); n++ ) {
printf("%d) ’%s’\n", n, fnfc->filename(n));
}
}
The format of each filter is a wildcard, or an optional user description followed by ’\t’ and the wildcard.
On most platforms, each filter is available to the user via a pulldown menu in the file chooser. The ’All
Files’ option is always available to the user.
Returns
• 0 – user picked a file
• 1 – user cancelled
• -1 – failed; errmsg() has reason
Fl_Widget
Fl_Valuator
Fl_Slider
Fl_Nice_Slider
• Fl Nice Slider.H
• Fl Slider.cxx
Fl_Widget
Fl_Input_
Fl_Input
Fl_Output
Fl_Multiline_Output
When you set the value() , Fl Output does a strcpy() to its own storage, which is useful for program-
generated values. The user may select portions of the text using the mouse and paste the contents into other
fields or programs.
There is a single subclass, Fl Multiline Output, which allows you to display multiple lines of text.
Fl Multiline Output does not provide scroll bars. If a more complete text editing widget is needed, use
Fl Text Display instead.
The text may contain any characters except \0, and will correctly display anything, using ∧ X notation
for unprintable control characters and \nnn notation for unprintable characters with the high bit set. It
assumes the font can draw any characters in the ISO-Latin1 character set.
Creates a new Fl Output widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.
Inherited destructor destroys the widget and any value associated with it.
The documentation for this class was generated from the following files:
• Fl Output.H
• Fl Input.cxx
Fl_Widget
Fl_Group
Fl_Window
Fl_Double_Window
Fl_Overlay_Window
Creates a new Fl Overlay Window widget using the given position, size, and label (title) string.
If the positions (x,y) are not given, then the window manager will choose them.
Call this to indicate that the overlay data has changed and needs to be redrawn.
The overlay will be clear until the first time this is called, so if you want an initial display you must call
this after calling show().
See Also
Fl Window::show(int argc, char ∗∗argv)
• Fl Overlay Window.H
• Fl Double Window.cxx
• Fl Overlay Window.cxx
Fl_Widget
Fl_Group
Fl_Pack
Public Types
• enum { VERTICAL = 0, HORIZONTAL = 1 }
resized to the width and are stacked below each other. Then the Fl Pack resizes itself to surround the child
widgets.
This widget is needed for the Fl Tabs. In addition you may want to put the Fl Pack inside an Fl Scroll.
The resizable for Fl Pack is set to NULL by default.
See also: Fl Group::resizable()
Fl_Device
Fl_Surface_Device
Fl_Paged_Device
Fl_PostScript_Printer
560 CHAPTER 31. CLASS DOCUMENTATION
Classes
• struct page format
width, height and name of a page format
Public Types
• enum Page Format {
A0 = 0, A1, A2, A3,
A4, A5, A6, A7,
A8, A9, B0, B1,
B2, B3, B4, B5,
B6, B7, B8, B9,
B10, C5E, DLE, EXECUTIVE,
FOLIO, LEDGER, LEGAL, LETTER,
TABLOID, ENVELOPE, MEDIA = 0x1000 }
Possible page formats.
• enum Page Layout { PORTRAIT = 0, LANDSCAPE = 0x100, REVERSED = 0x200, ORIENTAT-
ION = 0x300 }
Possible page layouts.
Protected Attributes
• int x offset
horizontal offset to the origin of graphics coordinates
• int y offset
vertical offset to the origin of graphics coordinates
Enumerator
A0 A0 format.
A4 A4 format.
LETTER Letter format.
562 CHAPTER 31. CLASS DOCUMENTATION
void Fl Paged Device::margins ( int ∗ left, int ∗ top, int ∗ right, int ∗ bottom ) [virtual]
Computes the dimensions of margins that lie between the printable page area and the full page.
Values are in the same unit as that used by FLTK drawing functions. They are changed by scale() calls.
Parameters
out left If non-null, ∗left is set to the left margin size.
out top If non-null, ∗top is set to the top margin size.
out right If non-null, ∗right is set to the right margin size.
out bottom If non-null, ∗bottom is set to the bottom margin size.
Reimplemented in Fl PostScript File Device, Fl Printer, and Fl System Printer.
Parameters
in x Horizontal position in page coordinates of the desired origin of graphics
functions.
in y Same as above, vertically.
Reimplemented in Fl PostScript File Device, Fl Printer, and Fl System Printer.
void Fl Paged Device::print widget ( Fl Widget ∗ widget, int delta x = 0, int delta y = 0 )
[virtual]
Draws the widget on the printed page.
The widget’s position on the printed page is determined by the last call to origin() and by the optional
delta x and delta y arguments. Its dimensions are in points unless there was a previous call to scale().
Parameters
in widget Any FLTK widget (e.g., standard, custom, window).
in delta x Optional horizontal offset for positioning the widget relatively to the cur-
rent origin of graphics functions.
in delta y Same as above, vertically.
Reimplemented in Fl Printer.
void Fl Paged Device::print window ( Fl Window ∗ win, int x offset = 0, int y offset = 0 )
Prints a window with its title bar and frame if any.
x offset and y offset are optional coordinates of where to position the window top left. Equiv-
alent to print widget() if win is a subwindow or has no border. Use Fl Window::decorated w() and Fl -
Window::decorated h() to get the size of the printed window.
void Fl Paged Device::print window part ( Fl Window ∗ win, int x, int y, int w, int h, int delta x
= 0, int delta y = 0 ) [virtual]
Prints a rectangular part of an on-screen window.
Parameters
win The window from where to capture.
x The rectangle left
y The rectangle top
w The rectangle width
h The rectangle height
delta x Optional horizontal offset from current graphics origin where to print the captured
rectangle.
564 CHAPTER 31. CLASS DOCUMENTATION
Computes the width and height of the printable area of the page.
Values are in the same unit as that used by FLTK drawing functions, are unchanged by calls to origin(),
but are changed by scale() calls. Values account for the user-selected paper type and print orientation.
Returns
0 if OK, non-zero if any error
int Fl Paged Device::start job ( int pagecount, int ∗ frompage = NULL, int ∗ topage = NULL )
[virtual]
Returns
0 if OK, non-zero if any error
Reimplemented in Fl PostScript File Device, Fl Printer, Fl PostScript Printer, and Fl System Printer.
31.94. FL PIXMAP CLASS REFERENCE 565
Returns
0 if OK, non-zero if any error
• Fl Paged Device.H
• Fl Paged Device.cxx
Fl_Image
Fl_Pixmap
Fl_GIF_Image Fl_XPM_Image
The constructors create a new pixmap from the specified XPM data.
• Fl Pixmap (const char ∗const ∗D)
The constructors create a new pixmap from the specified XPM data.
• Fl Pixmap (const uchar ∗const ∗D)
The constructors create a new pixmap from the specified XPM data.
• virtual void label (Fl Widget ∗w)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void label (Fl Menu Item ∗m)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void uncache ()
If the image has been cached for display, delete the cache data.
• virtual ∼Fl Pixmap ()
The destructor free all memory and server resources that are used by the pixmap.
Public Attributes
• int alloc data
Friends
• class Fl GDI Graphics Driver
• class Fl GDI Printer Graphics Driver
• class Fl Quartz Graphics Driver
• class Fl Xlib Graphics Driver
• Fl Pixmap.H
• Fl Pixmap.cxx
568 CHAPTER 31. CLASS DOCUMENTATION
Fl_Plugin
Fl_Device_Plugin
Plugins can be put into modules and either linked before distribution, or loaded from dynamically
linkable files. An Fl Plugin Manager is used to list and access all currently loaded plugins.
Fl Plugin Manager mgr("effects");
int i, n = mgr.plugins();
for (i=0; i<n; i++) {
My Plugin *pin = (My Plugin*)mgr.plugin(i);
pin->do something();
}
Fl_Preferences
Fl_Plugin_Manager
Fl_Image
Fl_RGB_Image
Fl_PNG_Image
Fl PNG Image::Fl PNG Image ( const char ∗ name png, const unsigned char ∗ buffer, int maxsize
)
Constructor that reads a PNG image from memory.
Construct an image from a block of memory inside the application. Fluid offers ”binary Data” chunks
as a great way to add image data into the C++ source code. name png can be NULL. If a name is given,
the image is added to the list of shared images (see: Fl Shared Image) and will be available by that name.
Parameters
name png A name given to this image or NULL
buffer Pointer to the start of the PNG image in memory
maxsize Size in bytes of the memory buffer containing the PNG image
The documentation for this class was generated from the following files:
• Fl PNG Image.H
• Fl PNG Image.cxx
Fl_Image
Fl_RGB_Image
Fl_PNM_Image
Fl_Widget
Fl_Positioner
Implements Fl Widget.
See Also
Fl Event
• Fl Positioner.H
• Fl Positioner.cxx
Fl_Device
Fl_Surface_Device
Fl_Paged_Device
Fl_PostScript_File_Device
Fl_PostScript_Printer
void Fl PostScript File Device::margins ( int ∗ left, int ∗ top, int ∗ right, int ∗ bottom )
[virtual]
Computes the dimensions of margins that lie between the printable page area and the full page.
Values are in the same unit as that used by FLTK drawing functions. They are changed by scale() calls.
Parameters
out left If non-null, ∗left is set to the left margin size.
out top If non-null, ∗top is set to the top margin size.
out right If non-null, ∗right is set to the right margin size.
out bottom If non-null, ∗bottom is set to the bottom margin size.
Reimplemented from Fl Paged Device.
Parameters
in x Horizontal position in page coordinates of the desired origin of graphics
functions.
in y Same as above, vertically.
Reimplemented from Fl Paged Device.
int Fl PostScript File Device::start job ( int pagecount, int ∗ from, int ∗ to ) [virtual]
Don’t use with this class.
Reimplemented from Fl Paged Device.
Reimplemented in Fl PostScript Printer.
int Fl PostScript File Device::start job ( int pagecount, enum Fl Paged Device::Page Format
format = Fl Paged Device::A4, enum Fl Paged Device::Page Layout layout =
Fl Paged Device::PORTRAIT )
Begins the session where all graphics requests will go to a local PostScript file.
Opens a file dialog entitled with Fl PostScript File Device::file chooser title to select an output Post-
Script file.
31.100. FL POSTSCRIPT FILE DEVICE CLASS REFERENCE 579
Parameters
pagecount The total number of pages to be created. Use 0 if this number is unknown when this
function is called.
format Desired page format.
layout Desired page layout.
Returns
0 if OK, 1 if user cancelled the file dialog, 2 if fopen failed on user-selected output file.
int Fl PostScript File Device::start job ( FILE ∗ ps output, int pagecount, enum Fl Paged Device-
::Page Format format = Fl Paged Device::A4, enum Fl Paged Device::Page Layout layout =
Fl Paged Device::PORTRAIT )
Begins the session where all graphics requests will go to FILE pointer.
Parameters
ps output A writable FILE pointer that will receive PostScript output and that should not be
closed until after end job() has been called.
pagecount The total number of pages to be created. Use 0 if this number is unknown when this
function is called.
format Desired page format.
layout Desired page layout.
Returns
always 0.
Returns
0 if OK, non-zero if any error
Translates the current graphics origin accounting for the current rotation.
This function is only useful after a rotate() call. Each translate() call must be matched by an untrans-
late() call. Successive translate() calls add up their effects.
Reimplemented from Fl Paged Device.
The documentation for this class was generated from the following files:
• Fl PostScript.H
• Fl PostScript.cxx
580 CHAPTER 31. CLASS DOCUMENTATION
Fl_Device
Fl_Graphics_Driver
Fl_PostScript_Graphics_Driver
see fl draw(int angle, const char ∗str, int n, int x, int y).
• void draw (Fl Pixmap ∗pxm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Pixmap object to the device.
• void draw (Fl Bitmap ∗bitmap, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Bitmap object to the device.
• void draw (Fl RGB Image ∗rgb, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl RGB Image object to the device.
• void draw image (const uchar ∗d, int x, int y, int w, int h, int delta=3, int ldelta=0)
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• void draw image (Fl Draw Image Cb call, void ∗data, int x, int y, int w, int h, int delta=3)
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• void draw image mono (const uchar ∗d, int x, int y, int w, int h, int delta=1, int ld=0)
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• void draw image mono (Fl Draw Image Cb call, void ∗data, int x, int y, int w, int h, int delta=1)
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• void end complex polygon ()
see fl end complex polygon().
• void end line ()
see fl end line().
• void end loop ()
see fl end loop().
• void end points ()
see fl end points().
• void end polygon ()
see fl end polygon().
• Fl PostScript Graphics Driver ()
The constructor.
• void font (int face, int size)
see fl font(Fl Font face, Fl Fontsize size).
• void gap ()
see fl gap().
• int height ()
see fl height().
• void line (int x1, int y1, int x2, int y2)
see fl line(int x, int y, int x1, int y1).
• void line (int x1, int y1, int x2, int y2, int x3, int y3)
see fl line(int x, int y, int x1, int y1, int x2, int y2).
• void line style (int style, int width=0, char ∗dashes=0)
see fl line style(int style, int width, char∗ dashes).
• void loop (int x0, int y0, int x1, int y1, int x2, int y2)
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2).
• void loop (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
• int not clipped (int x, int y, int w, int h)
see fl not clipped(int x, int y, int w, int h).
• void pie (int x, int y, int w, int h, double a1, double a2)
582 CHAPTER 31. CLASS DOCUMENTATION
The destructor.
void Fl PostScript Graphics Driver::arc ( int x, int y, int w, int h, double a1, double a2 )
[virtual]
int Fl PostScript Graphics Driver::clip box ( int x, int y, int w, int h, int & X, int & Y, int & W,
int & H ) [virtual]
see fl clip box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H).
Reimplemented from Fl Graphics Driver.
Returns
value returned by vfprintf() call
void Fl PostScript Graphics Driver::curve ( double X0, double Y0, double X1, double Y1, double
X2, double Y2, double X3, double Y3 ) [virtual]
see fl curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::draw ( const char ∗ str, int n, int x, int y ) [inline],
[virtual]
see fl draw(const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
31.101. FL POSTSCRIPT GRAPHICS DRIVER CLASS REFERENCE 585
void Fl PostScript Graphics Driver::draw ( int angle, const char ∗ str, int n, int x, int y )
[virtual]
see fl draw(int angle, const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::draw ( Fl Pixmap ∗ pxm, int XP, int YP, int WP, int HP, int
cx, int cy ) [virtual]
Draws an Fl Pixmap object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::draw ( Fl Bitmap ∗ bm, int XP, int YP, int WP, int HP, int
cx, int cy ) [virtual]
Draws an Fl Bitmap object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::draw ( Fl RGB Image ∗ rgb, int XP, int YP, int WP, int HP,
int cx, int cy ) [virtual]
Draws an Fl RGB Image object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::draw image ( const uchar ∗ buf, int X, int Y, int W, int H,
int D = 3, int L = 0 ) [virtual]
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int
Y, int W, int H, int D = 3 ) [virtual]
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::draw image mono ( const uchar ∗ buf, int X, int Y, int W, int
H, int D = 1, int L = 0 ) [virtual]
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::draw image mono ( Fl Draw Image Cb cb, void ∗ data, int
X, int Y, int W, int H, int D = 1 ) [virtual]
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.
586 CHAPTER 31. CLASS DOCUMENTATION
void Fl PostScript Graphics Driver::line ( int x, int y, int x1, int y1 ) [virtual]
see fl line(int x, int y, int x1, int y1).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::line ( int x, int y, int x1, int y1, int x2, int y2 ) [virtual]
see fl line(int x, int y, int x1, int y1, int x2, int y2).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::line style ( int style, int width = 0, char ∗ dashes = 0 )
[virtual]
see fl line style(int style, int width, char∗ dashes).
Reimplemented from Fl Graphics Driver.
31.101. FL POSTSCRIPT GRAPHICS DRIVER CLASS REFERENCE 587
void Fl PostScript Graphics Driver::loop ( int x0, int y0, int x1, int y1, int x2, int y2 )
[virtual]
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::loop ( int x0, int y0, int x1, int y1, int x2, int y2, int x3, int
y3 ) [virtual]
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
Reimplemented from Fl Graphics Driver.
int Fl PostScript Graphics Driver::not clipped ( int x, int y, int w, int h ) [virtual]
see fl not clipped(int x, int y, int w, int h).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::pie ( int x, int y, int w, int h, double a1, double a2 )
[virtual]
see fl pie(int x, int y, int w, int h, double a1, double a2).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::polygon ( int x0, int y0, int x1, int y1, int x2, int y2 )
[virtual]
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::polygon ( int x0, int y0, int x1, int y1, int x2, int y2, int x3,
int y3 ) [virtual]
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::push clip ( int x, int y, int w, int h ) [virtual]
see fl push clip(int x, int y, int w, int h).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::rtl draw ( const char ∗ str, int n, int x, int y ) [virtual]
see fl rtl draw(const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::text extents ( const char ∗ t, int n, int & dx, int & dy, int &
w, int & h ) [virtual]
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::xyline ( int x, int y, int x1, int y2 ) [virtual]
see fl xyline(int x, int y, int x1, int y2).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::xyline ( int x, int y, int x1, int y2, int x3 ) [virtual]
see fl xyline(int x, int y, int x1, int y2, int x3).
Reimplemented from Fl Graphics Driver.
31.102. FL POSTSCRIPT PRINTER CLASS REFERENCE 589
void Fl PostScript Graphics Driver::yxline ( int x, int y, int y1, int x2 ) [virtual]
see fl yxline(int x, int y, int y1, int x2).
Reimplemented from Fl Graphics Driver.
void Fl PostScript Graphics Driver::yxline ( int x, int y, int y1, int x2, int y3 ) [virtual]
see fl yxline(int x, int y, int y1, int x2, int y3).
Reimplemented from Fl Graphics Driver.
The documentation for this class was generated from the following files:
• Fl PostScript.H
• Fl PostScript.cxx
Fl_Device
Fl_Surface_Device
Fl_Paged_Device
Fl_PostScript_File_Device
Fl_PostScript_Printer
Friends
• class Fl Printer
int Fl PostScript Printer::start job ( int pagecount, int ∗ from = NULL, int ∗ to = NULL )
[virtual]
Don’t use with this class.
Reimplemented from Fl PostScript File Device.
The documentation for this class was generated from the following files:
• Fl Printer.H
• Fl Printer.cxx
Fl_Preferences
Fl_Plugin_Manager
Classes
• struct Entry
• class Name
’Name’ provides a simple method to create numerical or more complex procedural names for entries and
groups on the fly.
• class Node
• class RootNode
31.103. FL PREFERENCES CLASS REFERENCE 591
Public Types
• typedef void ∗ ID
Every Fl Preferences-Group has a uniqe ID.
• enum Root { SYSTEM =0, USER }
Define the scope of the preferences.
• char get (const char ∗entry, char ∗&value, const char ∗defaultValue)
Reads an entry from the group.
• char get (const char ∗entry, char ∗value, const char ∗defaultValue, int maxSize)
Reads an entry from the group.
• char get (const char ∗entry, void ∗&value, const void ∗defaultValue, int defaultSize)
Reads an entry from the group.
• char get (const char ∗entry, void ∗value, const void ∗defaultValue, int defaultSize, int maxSize)
Reads an entry from the group.
• char getUserdataPath (char ∗path, int pathlen)
Creates a path that is related to the preferences file and that is usable for additional application data.
• const char ∗ group (int num group)
Returns the name of the Nth (num group) group.
• char groupExists (const char ∗key)
Returns non-zero if a group with this name exists.
• int groups ()
Returns the number of groups that are contained within a group.
• ID id ()
Return an ID that can later be reused to open more references to this dataset.
• const char ∗ name ()
Return the name of this entry.
• const char ∗ path ()
Return the full path to this entry.
• char set (const char ∗entry, int value)
Sets an entry (name/value pair).
• char set (const char ∗entry, float value)
Sets an entry (name/value pair).
• char set (const char ∗entry, float value, int precision)
Sets an entry (name/value pair).
• char set (const char ∗entry, double value)
Sets an entry (name/value pair).
• char set (const char ∗entry, double value, int precision)
Sets an entry (name/value pair).
• char set (const char ∗entry, const char ∗value)
Sets an entry (name/value pair).
• char set (const char ∗entry, const void ∗value, int size)
Sets an entry (name/value pair).
• int size (const char ∗entry)
Returns the size of the value part of an entry.
• virtual ∼Fl Preferences ()
The destructor removes allocated resources.
Protected Attributes
• Node ∗ node
• RootNode ∗ rootNode
Friends
• class Node
• class RootNode
Note
Starting with FLTK 1.3, preference databases are expected to be in UTF-8 encoding. Previous
databases were stored in the current character set or code page which renders them incompatible
for text entries using international characters.
Enumerator
SYSTEM Preferences are used system-wide.
USER Preferences apply only to the current user.
594 CHAPTER 31. CLASS DOCUMENTATION
Fl Preferences::Fl Preferences ( const char ∗ path, const char ∗ vendor, const char ∗ application )
Use this constructor to create or read a preferences file at an arbitrary position in the file system.
The file name is generated in the form path/application.prefs. If application is NULL,
path must contain the full file name.
Parameters
in path path to the directory that contains the preferences file
in vendor unique text describing the company or author of this file
in application unique text describing the application
See Also
Fl Preferences( Fl Preferences&, const char ∗group )
Returns
0 if deleting the entry failed
Parameters
in group name of the group to delete
Returns
0 if call failed
int Fl Preferences::entries ( )
Returns the number of entries (name/value pairs) in a group.
Returns
number of entries
Returns
pointer to value cstring
Returns
0 if entry was not found
void Fl Preferences::flush ( )
Writes all preferences to disk.
This function works only with the base preferences group. This function is rarely used as deleting the
base preferences flushes automatically.
char Fl Preferences::get ( const char ∗ key, int & value, int defaultValue )
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0).
31.103. FL PREFERENCES CLASS REFERENCE 597
Parameters
in key name of entry
out value returned from preferences or default value if none was set
in defaultValue default value to be used if no preference was set
Returns
0 if the default value was used
char Fl Preferences::get ( const char ∗ key, float & value, float defaultValue )
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0).
Parameters
in key name of entry
out value returned from preferences or default value if none was set
in defaultValue default value to be used if no preference was set
Returns
0 if the default value was used
char Fl Preferences::get ( const char ∗ key, double & value, double defaultValue )
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0).
Parameters
in key name of entry
out value returned from preferences or default value if none was set
in defaultValue default value to be used if no preference was set
Returns
0 if the default value was used
char Fl Preferences::get ( const char ∗ key, char ∗& text, const char ∗ defaultValue )
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0). get() allocates memory of sufficient size to hold the value. The buffer must be
free’d by the developer using ’free(value)’.
Parameters
in key name of entry
out text returned from preferences or default value if none was set
598 CHAPTER 31. CLASS DOCUMENTATION
Returns
0 if the default value was used
char Fl Preferences::get ( const char ∗ key, char ∗ text, const char ∗ defaultValue, int maxSize )
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0). ’maxSize’ is the maximum length of text that will be read. The text buffer must
allow for one additional byte for a trailing zero.
Parameters
in key name of entry
out text returned from preferences or default value if none was set
in defaultValue default value to be used if no preference was set
in maxSize maximum length of value plus one byte for a trailing zero
Returns
0 if the default value was used
char Fl Preferences::get ( const char ∗ key, void ∗& data, const void ∗ defaultValue, int defaultSize
)
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0). get() allocates memory of sufficient size to hold the value. The buffer must be
free’d by the developer using ’free(value)’.
Parameters
in key name of entry
out data returned from preferences or default value if none was set
in defaultValue default value to be used if no preference was set
in defaultSize size of default value array
Returns
0 if the default value was used
char Fl Preferences::get ( const char ∗ key, void ∗ data, const void ∗ defaultValue, int defaultSize,
int maxSize )
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0). ’maxSize’ is the maximum length of text that will be read.
Parameters
31.103. FL PREFERENCES CLASS REFERENCE 599
Returns
0 if the default value was used
Todo maxSize should receive the number of bytes that were read.
Parameters
out path buffer for user data path
in pathlen size of path buffer (should be at least FL PATH MAX)
Returns
0 if path was not created or pathname can’t fit into buffer
Returns
’C’ string pointer to the group name
Parameters
in key name of group that is searched for
Returns
0 if no group by that name was found
int Fl Preferences::groups ( )
Returns the number of groups that are contained within a group.
Returns
0 for no groups at all
Returns
0 if setting the value failed
Returns
0 if setting the value failed
Returns
0 if setting the value failed
Returns
0 if setting the value failed
Returns
0 if setting the value failed
Parameters
in key name of entry
in text set this entry to value
Returns
0 if setting the value failed
char Fl Preferences::set ( const char ∗ key, const void ∗ data, int dsize )
Sets an entry (name/value pair).
The return value indicates if there was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences file.
Parameters
in key name of entry
in data set this entry to value
in dsize size of data array
Returns
0 if setting the value failed
Returns
size of value
The documentation for this class was generated from the following files:
• Fl Preferences.H
• Fl Preferences.cxx
Fl_Device
Fl_Surface_Device
Fl_Paged_Device
Fl_Printer
31.104. FL PRINTER CLASS REFERENCE 603
• Unix/Linux platforms: Class Fl RGB Image prints but loses its transparency if it has one. See class
Fl PostScript Graphics Driver for a description of how UTF-8 strings appear in print. Use the static
public attributes of this class to set the print dialog to other languages than English. For example, the
”Printer:” dialog item Fl Printer::dialog printer can be set to French with:
before creation of the Fl Printer object. Use Fl PostScript File Device::file chooser title to cus-
tomize the title of the file chooser dialog that opens when using the ”Print To File” option of the print
dialog.
• MSWindows platform: Transparent Fl RGB Image ’s don’t print with exact transparency on most
printers. Fl RGB Image ’s don’t rotate() well. A workaround is to use the print window part() call.
• Mac OS X platform: all graphics requests print as on display.
void Fl Printer::margins ( int ∗ left, int ∗ top, int ∗ right, int ∗ bottom ) [virtual]
Computes the dimensions of margins that lie between the printable page area and the full page.
Values are in the same unit as that used by FLTK drawing functions. They are changed by scale() calls.
Parameters
out left If non-null, ∗left is set to the left margin size.
out top If non-null, ∗top is set to the top margin size.
out right If non-null, ∗right is set to the right margin size.
out bottom If non-null, ∗bottom is set to the bottom margin size.
Reimplemented from Fl Paged Device.
Parameters
out x If non-null, ∗x is set to the horizontal page offset of graphics origin.
out y Same as above, vertically.
Reimplemented from Fl Paged Device.
void Fl Printer::print widget ( Fl Widget ∗ widget, int delta x = 0, int delta y = 0 ) [virtual]
Draws the widget on the printed page.
The widget’s position on the printed page is determined by the last call to origin() and by the optional
delta x and delta y arguments. Its dimensions are in points unless there was a previous call to scale().
Parameters
in widget Any FLTK widget (e.g., standard, custom, window).
in delta x Optional horizontal offset for positioning the widget relatively to the cur-
rent origin of graphics functions.
in delta y Same as above, vertically.
Reimplemented from Fl Paged Device.
void Fl Printer::print window part ( Fl Window ∗ win, int x, int y, int w, int h, int delta x = 0,
int delta y = 0 ) [virtual]
Prints a rectangular part of an on-screen window.
Parameters
win The window from where to capture.
x The rectangle left
y The rectangle top
w The rectangle width
h The rectangle height
delta x Optional horizontal offset from current graphics origin where to print the captured
rectangle.
delta y As above, vertically.
Reimplemented from Fl Paged Device.
Returns
0 if OK, non-zero if any error
int Fl Printer::start job ( int pagecount, int ∗ frompage = NULL, int ∗ topage = NULL )
[virtual]
Starts a print job.
Parameters
in pagecount the total number of pages of the job
out frompage if non-null, ∗frompage is set to the first page the user wants printed
out topage if non-null, ∗topage is set to the last page the user wants printed
Returns
0 if OK, non-zero if any error
Returns
0 if OK, non-zero if any error
• Fl Printer.H
• Fl Printer.cxx
Fl_Widget
Fl_Progress
The constructor creates the progress bar using the position, size, and label.
You can set the background color with color() and the progress bar color with selection color(), or you
can set both colors together with color(unsigned bg, unsigned sel).
The default colors are FL BACKGROUND2 COLOR and FL YELLOW, resp.
• Fl Progress.H
• Fl Progress.cxx
610 CHAPTER 31. CLASS DOCUMENTATION
Fl_Device
Fl_Graphics_Driver
Fl_Quartz_Graphics_Driver
void Fl Quartz Graphics Driver::draw ( const char ∗ str, int n, int x, int y ) [virtual]
see fl draw(const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
void Fl Quartz Graphics Driver::draw ( int angle, const char ∗ str, int n, int x, int y )
[virtual]
see fl draw(int angle, const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
612 CHAPTER 31. CLASS DOCUMENTATION
void Fl Quartz Graphics Driver::draw ( Fl Pixmap ∗ pxm, int XP, int YP, int WP, int HP, int cx,
int cy ) [virtual]
void Fl Quartz Graphics Driver::draw ( Fl Bitmap ∗ bm, int XP, int YP, int WP, int HP, int cx,
int cy ) [virtual]
void Fl Quartz Graphics Driver::draw ( Fl RGB Image ∗ rgb, int XP, int YP, int WP, int HP, int
cx, int cy ) [virtual]
void Fl Quartz Graphics Driver::draw image ( const uchar ∗ buf, int X, int Y, int W, int H, int D
= 3, int L = 0 ) [virtual]
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.
void Fl Quartz Graphics Driver::draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int Y,
int W, int H, int D = 3 ) [virtual]
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.
void Fl Quartz Graphics Driver::draw image mono ( const uchar ∗ buf, int X, int Y, int W, int H,
int D = 1, int L = 0 ) [virtual]
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.
void Fl Quartz Graphics Driver::draw image mono ( Fl Draw Image Cb cb, void ∗ data, int X,
int Y, int W, int H, int D = 1 ) [virtual]
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.
see fl height().
Reimplemented from Fl Graphics Driver.
void Fl Quartz Graphics Driver::rtl draw ( const char ∗ str, int n, int x, int y ) [virtual]
void Fl Quartz Graphics Driver::text extents ( const char ∗ t, int n, int & dx, int & dy, int & w,
int & h ) [virtual]
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
Reimplemented from Fl Graphics Driver.
• Fl Device.H
• fl color mac.cxx
• Fl Device.cxx
• Fl Double Window.cxx
• fl draw image mac.cxx
Fl_Widget
Fl_Button
Fl_Radio_Button
The constructor creates the button using the given position, size, and label.
The Button type() is set to FL RADIO BUTTON.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label
The documentation for this class was generated from the following files:
• Fl Radio Button.H
• Fl Button.cxx
Fl_Widget
Fl_Button
Fl_Light_Button
Fl_Radio_Light_Button
Fl_Widget
Fl_Button
Fl_Light_Button
Fl_Round_Button
Fl_Radio_Round_Button
Public Attributes
• int b
(b)ottom ”y” position, aka y2
• int l
(l)eft ”x” position, aka x1
• int r
(r)ight ”x” position, aka x2
• int t
(t)op ”y” position, aka y1
616 CHAPTER 31. CLASS DOCUMENTATION
• Fl Scroll.H
Public Attributes
• int h
• int w
• int x
• int y
• Fl Scroll.H
Fl_Widget
Fl_Button
Fl_Repeat_Button
Creates a new Fl Repeat Button widget using the given position, size, and label string.
The default boxtype is FL UP BOX. Deletes the button.
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
• Fl Repeat Button.H
• Fl Repeat Button.cxx
Fl_Widget
Fl_Button
Fl_Return_Button
See Also
Fl Event
• Fl Return Button.H
• Fl Return Button.cxx
Fl_Image
Fl_RGB_Image
• Fl Image ∗ copy ()
• virtual void desaturate ()
The desaturate() method converts an image to grayscale.
• virtual void draw (int X, int Y, int W, int H, int cx=0, int cy=0)
Draws the image with a bounding box.
• void draw (int X, int Y)
• Fl RGB Image (const uchar ∗bits, int W, int H, int D=3, int LD=0)
The constructor creates a new image from the specified data.
• Fl RGB Image (const Fl Pixmap ∗pxm, Fl Color bg=FL GRAY)
The constructor creates a new RGBA image from the specified Fl Pixmap.
• virtual void label (Fl Widget ∗w)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void label (Fl Menu Item ∗m)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void uncache ()
If the image has been cached for display, delete the cache data.
• virtual ∼Fl RGB Image ()
The destructor frees all memory and server resources that are used by the image.
Public Attributes
• int alloc array
• const uchar ∗ array
Friends
• class Fl GDI Graphics Driver
• class Fl Quartz Graphics Driver
• class Fl Xlib Graphics Driver
Parameters
in bits The image data array.
in W The width of the image in pixels
in H The height of the image in pixels
in D The image depth, or ’number of channels’. Default=3
If D=1, each uchar in bits[] is a grayscale pixel value.
If D=2, each uchar pair in bits[] is a grayscale + alpha pixel value.
If D=3, each uchar triplet in bits[] is an R/G/B pixel value
If D=4, each uchar quad in bits[] is an R/G/B/A pixel value.
in LD Line data size (default=0).
Line data is extra data that is included after each line of color image data
and is normally not present.
See Also
Fl Image::data(), Fl Image::w(), Fl Image::h(), Fl Image::d(), Fl Image::ld()
void Fl RGB Image::draw ( int X, int Y, int W, int H, int cx = 0, int cy = 0 ) [virtual]
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
Use the image() or deimage() methods of the Fl Widget and Fl Menu Item classes instead.
Reimplemented from Fl Image.
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
Use the image() or deimage() methods of the Fl Widget and Fl Menu Item classes instead.
Reimplemented from Fl Image.
Sets the maximum allowed image size in bytes when creating an Fl RGB Image object.
The image size in bytes of an Fl RGB Image object is the value of the product w() ∗ h() ∗ d(). If
this product exceeds size, the created object of a derived class of Fl RGB Image won’t be loaded with the
image data. This does not apply to direct RGB image creation with Fl RGB Image::Fl RGB Image(const
uchar ∗bits, int W, int H, int D, int LD). The default max size() value is essentially infinite.
Returns the maximum allowed image size in bytes when creating an Fl RGB Image object.
See Also
void Fl RGB Image::max size(size t)
If the image has been cached for display, delete the cache data.
This allows you to change the data used for the image and then redraw it without recreating an image
object.
Reimplemented from Fl Image.
The documentation for this class was generated from the following files:
• Fl Image.H
• Fl Image.cxx
Fl_Widget
Fl_Valuator
Fl_Roller
Implements Fl Widget.
See Also
Fl Event
• Fl Roller.H
• Fl Roller.cxx
Fl_Widget
Fl_Button
Fl_Light_Button
Fl_Round_Button
Fl_Radio_Round_Button
626 CHAPTER 31. CLASS DOCUMENTATION
The Fl Round Button subclass display the ”on” state by turning on a light, rather than drawing pushed
in. The shape of the ”light” is initially set to FL ROUND DOWN BOX. The color of the light when on is
controlled with selection color(), which defaults to FL FOREGROUND COLOR.
The Fl Round Button subclass displays the ”ON” state by turning on a light, rather than drawing pushed
in.
The default box type is FL NO BOX, which draws the label w/o a box right of the checkmark.
The shape of the ”light” is set with down box() and its default value is FL ROUND DOWN BOX.
The color of the light when on is controlled with selection color(), which defaults to FL FOREGRO-
UND COLOR (usually black).
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label
The documentation for this class was generated from the following files:
• Fl Round Button.H
• Fl Round Button.cxx
Fl_Widget
Fl_Clock_Output
Fl_Clock
Fl_Round_Clock
• Fl Round Clock.H
• Fl Clock.cxx
Fl_Widget
Fl_Group
Fl_Scroll
Public Types
• enum {
HORIZONTAL = 1, VERTICAL = 2, BOTH = 3, ALWAYS ON = 4,
HORIZONTAL ALWAYS = 5, VERTICAL ALWAYS = 6, BOTH ALWAYS = 7 }
628 CHAPTER 31. CLASS DOCUMENTATION
Public Attributes
• Fl Scrollbar hscrollbar
• Fl Scrollbar scrollbar
If all of the child widgets are packed together into a solid rectangle then you want to set box() to FL -
NO BOX or one of the FRAME types. This will result in the best output. However, if the child widgets
are a sparse arrangement you must set box() to a real BOX type. This can result in some blinking during
redrawing, but that can be solved by using a Fl Double Window.
By default you can scroll in both directions, and the scrollbars disappear if the data will fit in the area
of the scroll.
Use Fl Scroll::type() to change this as follows :
• 0 - No scrollbars
Use scrollbar.align(int) ( see void Fl Widget::align(Fl Align) ) : to change what side the scrollbars
are drawn on.
If the FL ALIGN LEFT bit is on, the vertical scrollbar is on the left. If the FL ALIGN TOP bit is on,
the horizontal scrollbar is on the top. Note that only the alignment flags in scrollbar are considered. The
flags in hscrollbar however are ignored.
This widget can also be used to pan around a single child widget ”canvas”. This child widget should be
of your own class, with a draw() method that draws the contents. The scrolling is done by changing the x()
and y() of the widget, so this child must use the x() and y() to position its drawing. To speed up drawing it
should test fl push clip().
Another very useful child is a single Fl Pack, which is itself a group that packs its children together and
changes size to surround them. Filling the Fl Pack with Fl Tabs groups (and then putting normal widgets
inside those) gives you a very powerful scrolling list of individually-openable panels.
Fluid lets you create these, but you can only lay out objects that fit inside the Fl Scroll without scrolling.
Be sure to leave space for the scrollbars, as Fluid won’t show these either.
You cannot use Fl Window as a child of this since the clipping is not conveyed to it when drawn, and it
will draw over the scrollbars and neighboring objects.
Todo The visibility of the scrollbars ought to be checked/calculated outside of the draw() method (STR
#1895).
void Fl Scroll::clear ( )
Clear all but the scrollbars...
See Also
Fl Event
Returns
Scrollbar size in pixels, or 0 if the global Fl::scrollsize() is being used.
See Also
Fl::scrollbar size(int)
See Also
Fl::scrollbar size()
• Fl Scroll.H
• Fl Scroll.cxx
Fl_Widget
Fl_Valuator
Fl_Slider
Fl_Scrollbar
Fl Scrollbar::∼Fl Scrollbar ( )
Destroys the Scrollbar.
Implements Fl Widget.
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
int Fl Scrollbar::value ( int pos, int windowSize, int first, int total ) [inline]
Sets the position, size and range of the slider in the scrollbar.
Parameters
in pos position, first line displayed
in windowSize number of lines displayed
in first number of first line
in total total number of lines
You should call this every time your window changes size, your data changes size, or your scroll position
changes (even if in response to a callback from this scrollbar). All necessary calls to redraw() are done.
Calls Fl Slider::scrollvalue(int pos, int size, int first, int total).
The documentation for this class was generated from the following files:
• Fl Scrollbar.H
• Fl Scrollbar.cxx
Public Attributes
• int first
scrollbar tab’s ”number of first line”
• int h
• int pos
scrollbar tab’s ”position of first line displayed”
• int size
scrollbar tab’s ”size of window in lines”
• int total
scrollbar tab’s ”total number of lines”
• int w
• int x
• int y
• Fl Scroll.H
Fl_Widget
Fl_Input_
Fl_Input
Fl_Secret_Input
Creates a new Fl Secret Input widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.
Inherited destructor destroys the widget and any value associated with it.
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
• Fl Secret Input.H
• Fl Input.cxx
Fl_Widget
Fl_Group
Fl_Browser_
Fl_Browser
Fl_Select_Browser
• Fl Select Browser.H
• Fl Browser.cxx
Fl_Image
Fl_Shared_Image
638 CHAPTER 31. CLASS DOCUMENTATION
Protected Attributes
• int alloc image
• Fl Image ∗ image
• const char ∗ name
• int original
• int refcount
Friends
• class Fl JPEG Image
• class Fl PNG Image
void Fl Shared Image::draw ( int X, int Y, int W, int H, int cx, int cy ) [virtual]
Draws the image with a bounding box.
This form specifies a bounding box for the image, with the origin (upper-lefthand corner) of the image
offset by the cx and cy arguments.
Reimplemented from Fl Image.
See Also
Fl Shared Image::find(const char ∗n, int W, int H)
Fl Shared Image::release()
Fl JPEG Image::Fl JPEG Image(const char ∗name, const unsigned char ∗data)
Fl PNG Image::Fl PNG Image (const char ∗name png, const unsigned char ∗buffer, int maxsize)
If the image has been cached for display, delete the cache data.
This allows you to change the data used for the image and then redraw it without recreating an image
object.
Reimplemented from Fl Image.
The documentation for this class was generated from the following files:
• Fl Shared Image.H
• Fl Shared Image.cxx
Fl_Widget
Fl_Valuator
Fl_Counter
Fl_Simple_Counter
The documentation for this class was generated from the following files:
• Fl Simple Counter.H
• Fl Counter.cxx
Fl_Widget
Fl_Group
Fl_Window
Fl_Single_Window
Fl_Menu_Window
However, it is possible that some implementations will provide double-buffered windows by default.
This subcan be used to force single-buffering. This may be useful for modifying existing programs that use
incremental update, or for some types of image data, such as a movie flipbook.
See Also
Fl Window::show(int argc, char ∗∗argv)
• Fl Single Window.H
• Fl Single Window.cxx
Fl_Widget
Fl_Valuator
Fl_Slider
Fl_Hor_Value_Slider
• FL VERT FILL SLIDER - Draws a filled vertical slider, useful as a progress or value meter.
• FL HOR FILL SLIDER - Draws a filled horizontal slider, useful as a progress or value meter.
• FL VERT NICE SLIDER - Draws a vertical slider with a nice looking control knob.
• FL HOR NICE SLIDER - Draws a horizontal slider with a nice looking control knob.
Implements Fl Widget.
Reimplemented in Fl Value Slider.
See Also
Fl Event
int Fl Slider::scrollvalue ( int pos, int size, int first, int total )
Sets the size and position of the sliding knob in the box.
646 CHAPTER 31. CLASS DOCUMENTATION
Parameters
in pos position of first line displayed
in size size of window in lines
in first number of first line
in total total number of lines Returns Fl Valuator::value(p)
• Fl Slider.H
• Fl Slider.cxx
Fl_Widget
Fl_Group
Fl_Spinner
See Also
Fl Event
Deprecated
Deprecated
See Also
Fl Group::resizable(Fl Widget∗)
Fl Group::resizable()
Fl Widget::resize(int,int,int,int)
Fl_Device
Fl_Surface_Device
Fl_PostScript_Printer
• Fl Device.H
• Fl Device.cxx
Fl_Widget
Fl_Menu_
Fl_Menu_Bar
Fl_Sys_Menu_Bar
31.129. FL SYS MENU BAR CLASS REFERENCE 653
• no symbolic labels
• no embossed labels
• no font sizes
You can configure a callback for the ’About’ menu item to invoke your own code with fl mac set about().
See Also
Fl Menu ::add(const char∗ label, int shortcut, Fl Callback ∗cb, void ∗user data, int flags)
int Fl Sys Menu Bar::add ( const char ∗ label, const char ∗ shortcut, Fl Callback ∗ cb, void ∗
user data = 0, int flags = 0 ) [inline]
Adds a new menu item.
See Also
Fl Menu ::add(const char∗ label, int shortcut, Fl Callback∗, void ∗user data=0, int flags=0)
See Also
Fl Menu ::add(const char∗ str)
31.129. FL SYS MENU BAR CLASS REFERENCE 655
int Fl Sys Menu Bar::insert ( int index, const char ∗ label, int shortcut, Fl Callback ∗ cb, void ∗
user data = 0, int flags = 0 )
insert in the system menu bar a new menu item
insert in the system menu bar a new menu item, with a title string, shortcut int, callback, argument to
the callback, and flags.
See Also
Fl Menu ::insert(int index, const char∗ label, int shortcut, Fl Callback ∗cb, void ∗user data, int flags)
int Fl Sys Menu Bar::insert ( int index, const char ∗ label, const char ∗ shortcut, Fl Callback ∗ cb,
void ∗ user data = 0, int flags = 0 ) [inline]
Insert a new menu item.
See Also
Fl Menu ::insert(int index, const char∗ label, const char∗ shortcut, Fl Callback ∗cb, void ∗user -
data=0, int flags=0)
Parameters
m list of Fl Menu Item
Fl_Device
Fl_Surface_Device
Fl_Paged_Device
Fl_System_Printer
Friends
• class Fl Printer
void Fl System Printer::margins ( int ∗ left, int ∗ top, int ∗ right, int ∗ bottom ) [virtual]
Computes the dimensions of margins that lie between the printable page area and the full page.
Values are in the same unit as that used by FLTK drawing functions. They are changed by scale() calls.
Parameters
out left If non-null, ∗left is set to the left margin size.
out top If non-null, ∗top is set to the top margin size.
out right If non-null, ∗right is set to the right margin size.
out bottom If non-null, ∗bottom is set to the bottom margin size.
Reimplemented from Fl Paged Device.
Computes the width and height of the printable area of the page.
Values are in the same unit as that used by FLTK drawing functions, are unchanged by calls to origin(),
but are changed by scale() calls. Values account for the user-selected paper type and print orientation.
Returns
0 if OK, non-zero if any error
int Fl System Printer::start job ( int pagecount, int ∗ frompage = NULL, int ∗ topage = NULL )
[virtual]
Returns
0 if OK, non-zero if any error
Returns
0 if OK, non-zero if any error
• Fl Printer.H
• Fl Printer.cxx
Fl_Widget
Fl_Group
Fl_Table
Fl_Table_Row
Public Types
• enum TableContext {
CONTEXT NONE = 0, CONTEXT STARTPAGE = 0x01, CONTEXT ENDPAGE = 0x02, CON-
TEXT ROW HEADER = 0x04,
CONTEXT COL HEADER = 0x08, CONTEXT CELL = 0x10, CONTEXT TABLE = 0x20, CO-
NTEXT RC RESIZE = 0x40 }
The context bit flags for Fl Table related callbacks (eg.
• void begin ()
• void callback (Fl Widget ∗, void ∗)
Callbacks will be called depending on the setting of Fl Widget::when().
• int callback col ()
Returns the current column the event occurred on.
• TableContext callback context ()
Returns the current ’table context’.
• int callback row ()
Returns the current row the event occurred on.
• Fl Widget ∗ child (int n) const
Returns the child widget by an index.
• int children () const
Returns the number of children in the table.
• virtual void clear ()
Clears the table to zero rows (rows(0)), zero columns (cols(0)), and clears any widgets (table->clear()) that
were added with begin()/end() or add()/insert()/etc.
• int col header ()
Returns if column headers are enabled or not.
• void col header (int flag)
Enable or disable column headers.
• void col header color (Fl Color val)
Sets the color for column headers and redraws the table.
• Fl Color col header color ()
Gets the color for column headers.
• void col header height (int height)
Sets the height in pixels for column headers and redraws the table.
• int col header height ()
Gets the column header height.
• void col position (int col)
Sets the column scroll position to column ’col’, and causes the screen to redraw.
• int col position ()
Returns the current column scroll position as a column number.
• int col resize ()
Returns the current value of this flag.
• void col resize (int flag)
Allows/disallows column resizing by the user.
• int col resize min ()
Sets the current column minimum resize value.
• void col resize min (int val)
Returns the current column minimum resize value.
• void col width (int col, int width)
Sets the width of the specified column in pixels, and the table is redrawn.
• int col width (int col)
Returns the current width of the specified column in pixels.
• void col width all (int width)
Convenience method to set the width of all columns to the same value, in pixels.
• virtual void cols (int val)
662 CHAPTER 31. CLASS DOCUMENTATION
Protected Types
• enum ResizeFlag {
RESIZE NONE = 0, RESIZE COL LEFT = 1, RESIZE COL RIGHT = 2, RESIZE ROW A-
BOVE = 3,
RESIZE ROW BELOW = 4 }
Protected Attributes
• int botrow
• int current col
• int current row
• Fl Scrollbar ∗ hscrollbar
• int leftcol
• int leftcol scrollpos
• int rightcol
• int select col
• int select row
• Fl Scroll ∗ table
• int table h
• int table w
• int tih
• int tiw
• int tix
• int tiy
• int toh
• int toprow
• int toprow scrollpos
• int tow
• int tox
• int toy
• Fl Scrollbar ∗ vscrollbar
• int wih
• int wiw
• int wix
• int wiy
• As a custom widget; see examples/table-simple.cxx and test/table.cxx. Very optimal for even ex-
tremely large tables.
• As a table made up of a single FLTK widget instanced all over the table, simulating a numeric spread-
sheet. See examples/table-spreadsheet.cxx and examples/table-spreadsheet-with-keyboard-nav.cxx.
Optimal for large tables.
• As a regular container of FLTK widgets, one widget per cell. See examples/table-as-container.cxx.
Not recommended for large tables.
When acting as part of a custom widget, events on the cells and/or headings generate callbacks when
they are clicked by the user. You control when events are generated based on the setting for Fl Table-
::when().
When acting as a container for FLTK widgets, the FLTK widgets maintain themselves. Although
the draw cell() method must be overridden, its contents can be very simple. See the draw cell() code in
examples/table-simple.cxx.
The following variables are available to classes deriving from Fl Table:
666 CHAPTER 31. CLASS DOCUMENTATION
• Greg Ercolano : 12/16/2002 - initial implementation 12/16/02. Fl Table, Fl Table Row, docs.
• Jean-Marc Lienher : 02/22/2004 - added keyboard nav + mouse selection, and ported Fl Table into
fltk-utf8-1.1.4
OTHER CONTRIBUTORS
• Inspired by the Feb 2000 version of FLVW’s Flvw Table widget. Mucho thanks to those folks.
• Mister Satan : 04/07/2003 - MinGW porting mods, and singleinput.cxx; a cool Fl Input oriented
spreadsheet example
• Marek Paliwoda : 01/08/2003 - Porting mods for Borland
31.131. FL TABLE CLASS REFERENCE 667
LICENSE
Greg added the following license to the original distribution of Fl Table. He kindly gave his permission
to integrate Fl Table and Fl Table Row into FLTK, allowing FLTK license to apply while his widgets are
part of the library.
If used on its own, this is the license that applies:
Fl_Table License
December 16, 2002
The Fl_Table library and included programs are provided under the terms
of the GNU Library General Public License (LGPL) with the following
exceptions:
Fl Table::∼Fl Table ( )
The destructor for the Fl Table.
Destroys the table and its associated widgets.
R, C, (int)context, (int)Fl::event());
}
public:
// Constructor
MyTable() {
[..]
table.callback(&event callback, (void*)this); // setup callback
table.when(FL WHEN CHANGED|FL WHEN RELEASE); // when to call it
}
};
See Also
child(int)
670 CHAPTER 31. CLASS DOCUMENTATION
Clears the table to zero rows (rows(0)), zero columns (cols(0)), and clears any widgets (table->clear()) that
were added with begin()/end() or add()/insert()/etc.
See Also
rows(int), cols(int)
Sets the width of the specified column in pixels, and the table is redrawn.
callback() will be invoked with CONTEXT RC RESIZE if the column’s width was actually changed,
and when() is FL WHEN CHANGED.
Convenience method to set the width of all columns to the same value, in pixels.
The screen is redrawn.
virtual void Fl Table::draw cell ( TableContext context, int R = 0, int C = 0, int X = 0, int Y = 0,
int W = 0, int H = 0 ) [inline], [protected], [virtual]
Subclass should override this method to handle drawing the cells.
This method will be called whenever the table is redrawn, once per cell.
Only cells that are completely (or partially) visible will be told to draw.
context will be one of the following:
672 CHAPTER 31. CLASS DOCUMENTATION
headers
case CONTEXT COL HEADER:
fl push clip(X, Y, W, H);
{
fl draw box(FL THIN UP BOX, X, Y, W, H,
color());
fl color(FL BLACK);
fl draw(s, X, Y, W, H, FL ALIGN CENTER);
}
fl pop clip();
return;
// TEXT
fl color(FL BLACK);
fl draw(s, X, Y, W, H, FL ALIGN CENTER);
// BORDER
fl color(FL LIGHT2);
fl rect(X, Y, W, H);
}
fl pop clip();
return;
default:
return;
}
//NOTREACHED
}
void Fl Table::get selection ( int & row top, int & col left, int & row bot, int & col right )
Gets the region of cells selected (highlighted).
Parameters
in row top Returns the top row of selection area
in col left Returns the left column of selection area
in row bot Returns the bottom row of selection area
in col right Returns the right column of selection area
See Also
Fl Event
void Fl Table::set selection ( int row top, int col left, int row bot, int col right )
Sets the region of cells to be selected (highlighted).
So for instance, set selection(0,0,0,0) selects the top/left cell in the table. And set selection(0,0,1,1)
selects the four cells in rows 0 and 1, column 0 and 1.
31.131. FL TABLE CLASS REFERENCE 675
Parameters
in row top Top row of selection area
in col left Left column of selection area
in row bot Bottom row of selection area
in col right Right column of selection area
Sets the kind of box drawn around the data table, the default being FL NO BOX.
Changing this value will cause the table to redraw.
Sets which row should be at the top of the table, scrolling as necessary, and the table is redrawn.
If the table cannot be scrolled that far, it is scrolled as far as possible.
void Fl Table::visible cells ( int & r1, int & r2, int & c1, int & c2 ) [inline]
Returns the range of row and column numbers for all visible and partially visible cells in the table.
These values can be used e.g. by your draw cell() routine during CONTEXT STARTPAGE to figure
out what cells are about to be redrawn for the purposes of locking the data from a database before it’s
drawn.
leftcol rightcol
: :
toprow .. .-------------------.
| |
| V I S I B L E |
| |
| T A B L E |
| |
botrow .. ’-------------------‘
e.g. in a table where the visible rows are 5-20, and the visible columns are 100-120, then those variables
would be:
• toprow = 5
• botrow = 20
• leftcol = 100
• rightcol = 120
The Fl Widget::when() function is used to set a group of flags, determining when the widget callback is
called:
676 CHAPTER 31. CLASS DOCUMENTATION
• Fl Table.H
• Fl Table.cxx
Fl_Widget
Fl_Group
Fl_Table
Fl_Table_Row
Public Types
• enum TableRowSelectMode { SELECT NONE, SELECT SINGLE, SELECT MULTI }
See Also
rows(int), cols(int)
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
This convenience function changes the selection state for all rows based on ’flag’.
0=deselect, 1=select, 2=toggle existing state.
Changes the selection state for ’row’, depending on the value of ’flag’.
0=deselected, 1=select, 2=toggle existing state.
The documentation for this class was generated from the following files:
• Fl Table Row.H
• Fl Table Row.cxx
31.133. FL TABS CLASS REFERENCE 679
Fl_Widget
Fl_Group
Fl_Tabs
Clicking the tab makes a child visible() by calling show() on it, and all other children are made in-
visible by calling hide() on them. Usually the children are Fl Group widgets containing several widgets
themselves.
Each child makes a card, and its label() is printed on the card tab, including the label font and style. The
selection color of that child is used to color the tab, while the color of the child determines the background
color of the pane.
The size of the tabs is controlled by the bounding box of the children (there should be some space
between the children and the edge of the Fl Tabs), and the tabs may be placed ”inverted” on the bottom
- this is determined by which gap is larger. It is easiest to lay this out in fluid, using the fluid browser to
select each child group and resize them until the tabs look the way you want them to.
The background area behind and to the right of the tabs is ”transparent”, exposing the background
detail of the parent. The value of Fl Tabs::box() does not affect this area. So if Fl Tabs is resized by itself
without the parent, force the appropriate parent (visible behind the tabs) to redraw() to prevent artifacts.
See ”Resizing Caveats” below on how to keep tab heights constant. See ”Callback’s Use Of when()”
on how to control the details of how clicks invoke the callback().
A typical use of the Fl Tabs widget:
Default Appearance
The appearance of each ”tab” is taken from the label() and color() of the child group corresponding to
that ”tab” and panel. Where the ”tabs” appear depends on the position and size of the child groups that
make up the panels within the Fl Tab, i.e. whether there is more space above or below them. The height of
the ”tabs” depends on how much free space is available.
31.133. FL TABS CLASS REFERENCE 681
..
tabs = new Fl Tabs(..);
tabs->selection color(FL DARK3);
..
..
return Fl::run();
}
Resizing Caveats
When Fl Tabs is resized vertically, the default behavior scales the tab’s height as well as its children.
To keep the tab height constant during resizing, set the tab widget’s resizable() to one of the tab’s child
groups, i.e.
Since
FLTK 1.3.0
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
See Also
push(Fl Widget∗).
See Also
push().
Fl Widget ∗ Fl Tabs::value ( )
Gets the currently visible widget/tab.
The value() is the first visible child (or the last child if none are visible) and this also hides any other
children. This allows the tabs to be deleted, moved to other groups, and show()/hide() called without it
screwing up.
31.134. FL TEXT BUFFER CLASS REFERENCE 685
Returns
1 if there was a change (new value different from previous),
0 if there was no change (new value already set)
Returns
The child widget of the tab the user clicked on, or
0 if there are no children or if the event is outside of the tabs area.
The documentation for this class was generated from the following files:
• Fl Tabs.H
• Fl Tabs.cxx
Public Attributes
• int input file was transcoded
true iff the loaded file has been transcoded to UTF-8
• void(∗ transcoding warning action )(Fl Text Buffer ∗)
Pointer to a function called after reading a non UTF-8 encoded file.
31.134. FL TEXT BUFFER CLASS REFERENCE 689
Protected Attributes
• char ∗ mBuf
allocated memory where the text is stored
• char mCanUndo
if this buffer is used for attributes, it must not do any undo calls
• void ∗∗ mCbArgs
caller arguments for modifyProcs above
• int mCursorPosHint
hint for reasonable cursor position after a buffer modification operation
• int mGapEnd
points to the first char after the gap
• int mGapStart
points to the first character of the gap
• Fl Text Selection mHighlight
690 CHAPTER 31. CLASS DOCUMENTATION
highlighted areas
• int mLength
length of the text in the buffer (the length of the buffer itself must be calculated: gapEnd - gapStart + length)
• Fl Text Modify Cb ∗ mModifyProcs
procedures to call when buffer is modified to redisplay contents
• int mNModifyProcs
number of modify-redisplay procs attached
• int mNPredeleteProcs
number of pre-delete procs attached
• void ∗∗ mPredeleteCbArgs
caller argument for pre-delete proc above
• Fl Text Predelete Cb ∗ mPredeleteProcs
procedure to call before text is deleted from the buffer; at most one is supported.
• int mPreferredGapSize
the default allocation for the text gap is 1024 bytes and should only be increased if frequent and large
changes in buffer size are expected
• Fl Text Selection mPrimary
highlighted areas
• Fl Text Selection mSecondary
highlighted areas
• int mTabDist
equiv.
Parameters
pos byte offset into buffer
Returns
byte offset converted to a memory address
Returns
byte offset converted to a memory address
int Fl Text Buffer::appendfile ( const char ∗ file, int buflen = 128∗1024 ) [inline]
Appends the named file to the end of the buffer.
See also insertfile().
Returns
unencoded raw byte
Returns
Unicode UCS-4 encoded character
void Fl Text Buffer::copy ( Fl Text Buffer ∗ fromBuf, int fromStart, int fromEnd, int toPos )
Copies text from one buffer to this one.
31.134. FL TEXT BUFFER CLASS REFERENCE 693
Parameters
fromBuf source text buffer may be the same as this
fromStart byte offset into buffer
fromEnd byte offset into buffer
toPos destination byte offset into buffer
int Fl Text Buffer::count displayed characters ( int lineStartPos, int targetPos ) const
Count the number of displayed characters between buffer position lineStartPos and targetPos.
(displayed characters are the characters shown on the screen to represent characters in the buffer, where
tabs and control characters are expanded)
int Fl Text Buffer::findchar backward ( int startPos, unsigned int searchChar, int ∗ foundPos )
const
Search backwards in buffer buf for character searchChar, starting with the character BEFORE start-
Pos, returning the result in foundPos returns 1 if found, 0 if not.
(The difference between this and BufSearchBackward is that it’s optimized for single characters. The
overall performance of the text widget is dependent on its ability to count lines quickly, hence searching
for a single character: newline)
Parameters
startPos byte offset to start position
searchChar UCS-4 character that we want to find
foundPos byte offset where the character was found
Returns
1 if found, 0 if not
int Fl Text Buffer::findchar forward ( int startPos, unsigned searchChar, int ∗ foundPos ) const
Finds the next occurrence of the specified character.
Search forwards in buffer for character searchChar, starting with the character startPos, and
returning the result in foundPos returns 1 if found, 0 if not. (The difference between this and BufSearch-
Forward is that it’s optimized for single characters. The overall performance of the text widget is dependent
on its ability to count lines quickly, hence searching for a single character: newline)
Parameters
startPos byte offset to start position
searchChar UCS-4 character that we want to find
foundPos byte offset where the character was found
Returns
1 if found, 0 if not
694 CHAPTER 31. CLASS DOCUMENTATION
int Fl Text Buffer::insertfile ( const char ∗ file, int pos, int buflen = 128∗1024 )
Inserts a file at the specified position.
Returns 0 on success, non-zero on error (strerror() contains reason). 1 indicates open for read failed (no
data loaded). 2 indicates error occurred while reading data (data was partially loaded). File can be UTF-8
or CP1252-encoded. If the input file is not UTF-8-encoded, the Fl Text Buffer widget will contain UTF-
8-transcoded data. By default, the message Fl Text Buffer::file encoding warning message will warn the
user about this.
See Also
input file was transcoded and transcoding warning action.
Parameters
pos byte index into buffer
Returns
byte offset to line end
Returns
byte offset to line start
Returns
copy of utf8 text, must be free’d
int Fl Text Buffer::loadfile ( const char ∗ file, int buflen = 128∗1024 ) [inline]
Loads a text file into the buffer.
See also insertfile().
int Fl Text Buffer::outputfile ( const char ∗ file, int start, int end, int buflen = 128∗1024 )
Writes the specified portions of the file to a file.
Returns 0 on success, non-zero on error (strerror() contains reason). 1 indicates open for write failed
(no data saved). 2 indicates error occurred while writing data (data was partially saved).
Parameters
ix index to the current char
void Fl Text Buffer::replace ( int start, int end, const char ∗ text )
Deletes the characters between start and end, and inserts the null-terminated string text in their place
in the buffer.
Parameters
start byte offset to first character to be removed and new insert position
end byte offset to charcatre after last character to be removed
text utf-8 encoded and nul terminated text
int Fl Text Buffer::search backward ( int startPos, const char ∗ searchString, int ∗ foundPos, int
matchCase = 0 ) const
Search backwards in buffer for string searchCharssearchString, starting with the character BEFORE start-
Pos, returning the result in foundPos returns 1 if found, 0 if not.
Parameters
startPos byte offset to start position
searchString utf8 string that we want to find
foundPos byte offset where the string was found
matchCase if set, match character case
Returns
1 if found, 0 if not
int Fl Text Buffer::search forward ( int startPos, const char ∗ searchString, int ∗ foundPos, int
matchCase = 0 ) const
Search forwards in buffer for string searchString, starting with the character startPos, and return-
ing the result in foundPos returns 1 if found, 0 if not.
31.134. FL TEXT BUFFER CLASS REFERENCE 697
Parameters
startPos byte offset to start position
searchString utf8 string that we want to find
foundPos byte offset where the string was found
matchCase if set, match character case
Returns
1 if found, 0 if not
Returns
byte offset in input after all output bytes are sent
Parameters
start byte offset to first character
end byte offset after last character in range
Returns
newly allocated text buffer - must be free’d, text is utf8
Returns
byte offset to word end
Returns
byte offset to word start
Initial value:
=
"Displayed text contains the UTF-8 transcoding\n"
"of the input file which was not UTF-8 encoded.\n"
"Some changes may have occurred."
This message may be displayed using the fl alert() function when a file which was not UTF-8 encoded
is input.
procedure to call before text is deleted from the buffer; at most one is supported.
equiv.
number of characters in a tab
31.135. FL TEXT DISPLAY CLASS REFERENCE 699
• Fl Text Buffer.H
• Fl Text Buffer.cxx
Fl_Widget
Fl_Group
Fl_Text_Display
Fl_Text_Editor
Classes
• struct Style Table Entry
This structure associates the color, font, andsize of a string to draw with an attribute mask matching attr.
Public Types
• enum {
NORMAL CURSOR, CARET CURSOR, DIM CURSOR, BLOCK CURSOR,
HEAVY CURSOR, SIMPLE CURSOR }
text display cursor shapes enumeration
• enum { CURSOR POS, CHARACTER POS }
the character position is the left edge of a character, whereas the cursor is thought to be between the centers
of two consecutive characters.
• enum {
DRAG NONE = -2, DRAG START DND = -1, DRAG CHAR = 0, DRAG WORD = 1,
DRAG LINE = 2 }
drag types - they match Fl::event clicks() so that single clicking to start a collection selects by character,
double clicking selects by word and triple clicking selects by line.
• enum { WRAP NONE, WRAP AT COLUMN, WRAP AT PIXEL, WRAP AT BOUNDS }
wrap types - used in wrap mode()
• typedef void(∗ Unfinished Style Cb )(int, void ∗)
700 CHAPTER 31. CLASS DOCUMENTATION
Protected Types
• enum { DRAW LINE, FIND INDEX, FIND INDEX FROM ZERO, GET WIDTH }
31.135. FL TEXT DISPLAY CLASS REFERENCE 703
Protected Attributes
• int damage range1 end
• int damage range1 start
• int damage range2 end
• int damage range2 start
• int display insert position hint
• int dragging
• int dragPos
• int dragType
• int mAbsTopLineNum
• Fl Text Buffer ∗ mBuffer
• double mColumnScale
• int mContinuousWrap
• Fl Color mCursor color
• int mCursorOldY
• int mCursorOn
• int mCursorPos
• int mCursorPreferredXPos
• int mCursorStyle
• int mCursorToHint
• int mFirstChar
• void ∗ mHighlightCBArg
• int mHorizOffset
• int mHorizOffsetHint
• Fl Scrollbar ∗ mHScrollBar
• int mLastChar
• int mLineNumLeft
• int mLineNumWidth
• int ∗ mLineStarts
• int mMaxsize
• int mModifyingTabDistance
• int mNBufferLines
• int mNeedAbsTopLineNum
• int mNLinesDeleted
• int mNStyles
• int mNVisibleLines
• Fl Text Buffer ∗ mStyleBuffer
• const Style Table Entry ∗ mStyleTable
• int mSuppressResync
• int mTopLineNum
• int mTopLineNumHint
• Unfinished Style Cb mUnfinishedHighlightCB
• char mUnfinishedStyle
• Fl Scrollbar ∗ mVScrollBar
706 CHAPTER 31. CLASS DOCUMENTATION
• int mWrapMarginPix
• Fl Align scrollbar align
• int scrollbar width
• int shortcut
• Fl Color textcolor
Fl Font textfont
Fl Fontsize textsize
Friends
• void fl text drag me (int pos, Fl Text Display ∗d)
Example Use
#include <FL/FL Text Display.H>
..
int main() {
..
Fl Text Buffer *buff = new Fl Text Buffer();
Fl Text Display *disp = new Fl Text Display(10, 10, 640, 480);
disp->buffer(buff); // attach text buffer to display widget
buff->text("line one\nline two"); // add some text to buffer
..
}
Features
• Word wrap: wrap mode(), wrapped column(), wrapped row()
• Font control: textfont(), textsize(), textcolor()
• Font styling: highlight data()
• Cursor: cursor style(), show cursor(), hide cursor(), cursor color()
• Line numbers: linenumber width(), linenumber font(), linenumber size(), linenumber fgcolor(), linenumber-
bgcolor(), linenumber align(), linenumber format()
Note that other features may be available via Fl Text Editor and Fl Text Buffer classes.
Note
Line numbers were added in 1.3.3. To avoid breaking ABI, many of its options are read only. To
adjust these features in 1.3.x, you must build FLTK with FLTK ABI VERSION set to 10303 or
higher.
anonymous enum
wrap types - used in wrap mode()
Enumerator
WRAP NONE don’t wrap text at all
WRAP AT COLUMN wrap text at the given text column
WRAP AT PIXEL wrap text at a pixel position
WRAP AT BOUNDS wrap text so that it fits into the widget width
Parameters
X,Y,W,H position and size of widget
l label text, defaults to none
Attach a text buffer to display, replacing the current buffer (if any)
Parameters
buf attach this text buffer
Sets the current text buffer associated with the text widget.
Multiple text widgets can be associated with the same text buffer.
Parameters
buf new text buffer
Gets the current text buffer associated with the text widget.
Multiple text widgets can be associated with the same text buffer.
Returns
current text buffer
void Fl Text Display::buffer modified cb ( int pos, int nInserted, int nDeleted, int nRestyled, const
char ∗ deletedText, void ∗ cbArg ) [static], [protected]
Parameters
pos starting index of modification
nInserted number of bytes we inserted (must be UTF-8 aligned!)
nDeleted number of bytes deleted (must be UTF-8 aligned!)
nRestyled ??
deletedText this is what was removed, must not be NULL if nDeleted is set
cbArg ”this” pointer for static callback function
void Fl Text Display::buffer predelete cb ( int pos, int nDeleted, void ∗ cbArg ) [static],
[protected]
void Fl Text Display::calc line starts ( int startLine, int endLine ) [protected]
void Fl Text Display::clear rect ( int style, int X, int Y, int width, int height ) const
[protected]
Parameters
col an approximate column number based on the main font
Returns
number of pixels from the left margin to the left of an average sized character
int Fl Text Display::count lines ( int startPos, int endPos, bool startPosIsLineStart ) const
Count the number of lines between two positions.
Same as BufCountLines, but takes into account wrapping if wrapping is turned on. If the caller knows
that startPos is at a line start, it can pass startPosIsLineStart as True to make the call more
efficient by avoiding the additional step of scanning back to the last newline.
Parameters
startPos index to first character
endPos index after last character
startPosIsLine- avoid scanning back to the line start
Start
Returns
number of lines
This call also switches the cursor on and may trigger a redraw.
712 CHAPTER 31. CLASS DOCUMENTATION
Parameters
style new cursor style
Todo Unicode?
void Fl Text Display::draw string ( int style, int X, int Y, int toX, const char ∗ string, int nChars )
const [protected]
Draw a text segment in a single style.
Draw a string or blank area according to parameter style, using the appropriate colors and drawing
method for that style, with top left corner at X, Y. If style says to draw text, use string as source of
31.135. FL TEXT DISPLAY CLASS REFERENCE 713
characters, and draw nChars, if style is FILL, erase rectangle where text would have drawn from X to
toX and from Y to the maximum y extent of the current font(s).
714 CHAPTER 31. CLASS DOCUMENTATION
Parameters
style index into style lookup table
X,Y drawing origin
toX rightmost position if this is a fill operation
string text if this is a drawing operation
nChars number of characters to draw
void Fl Text Display::draw text ( int left, int top, int width, int height ) [protected]
Refresh a rectangle of the text display.
Parameters
left,top are in coordinates of the text drawing window.
width,height size in pixels
void Fl Text Display::draw vline ( int visLineNum, int leftClip, int rightClip, int leftCharIndex,
int rightCharIndex ) [protected]
Draw a single line of text.
Draw the text on a single line represented by visLineNum (the number of lines down from the top
of the display), limited by leftClip and rightClip window coordinates and leftCharIndex and
rightCharIndex character positions (not including the character at position rightCharIndex).
Parameters
visLineNum index of line in the visible line number lookup
leftClip,right- pixel position of clipped area
Clip
leftChar- index into line of segment that we want to draw
Index,right-
CharIndex
Returns
1 if there are empty lines
void Fl Text Display::extend range for styles ( int ∗ startpos, int ∗ endpos ) [protected]
I don’t know what this does!
Extend the range of a redraw request (from ∗start to ∗end) with additional redraw requests resulting
from changes to the attached style buffer (which contains auxiliary information for coloring or styling
text).
Parameters
startpos ??
endpos ??
Todo Unicode?
31.135. FL TEXT DISPLAY CLASS REFERENCE 715
void Fl Text Display::find line end ( int startPos, bool startPosIsLineStart, int ∗ lineEnd, int ∗
nextLineStart ) const [protected]
Finds both the end of the current line and the start of the next line.
Why? In continuous wrap mode, if you need to know both, figuring out one from the other can be
expensive or error prone. The problem comes when there’s a trailing space or tab just before the end of
the buffer. To translate an end of line value to or from the next lines start value, you need to know whether
the trailing space or tab is being used as a line break or just a normal character, and to find that out would
otherwise require counting all the way back to the beginning of the line.
Parameters
startPos
startPosIsLine-
Start
out lineEnd
out nextLineStart
void Fl Text Display::find wrap range ( const char ∗ deletedText, int pos, int nInserted, int
nDeleted, int ∗ modRangeStart, int ∗ modRangeEnd, int ∗ linesInserted, int ∗ linesDeleted )
[protected]
Wrapping calculations.
When continuous wrap is on, and the user inserts or deletes characters, wrapping can happen before
and beyond the changed position. This routine finds the extent of the changes, and counts the deleted
and inserted lines over that range. It also attempts to minimize the size of the range to what has to be
counted and re-displayed, so the results can be useful both for delimiting where the line starts need to be
recalculated, and for deciding what part of the text to redisplay.
Parameters
deletedText
pos
nInserted
nDeleted
modRangeStart
modRangeEnd
linesInserted
linesDeleted
int Fl Text Display::find x ( const char ∗ s, int len, int style, int x ) const [protected]
Find the index of the character that lies at the given x position.
Parameters
s UTF-8 text string
len length of string
style index into style lookup table
x position in pixels
Returns
index into buffer
716 CHAPTER 31. CLASS DOCUMENTATION
int Fl Text Display::handle vline ( int mode, int lineStartPos, int lineLen, int leftChar, int
rightChar, int Y, int bottomClip, int leftClip, int rightClip ) const [protected]
Universal pixel machine.
We use a single function that handles all line layout, measuring, and drawing
• draw a text range
void Fl Text Display::highlight data ( Fl Text Buffer ∗ styleBuffer, const Style Table Entry ∗
styleTable, int nStyles, char unfinishedStyle, Unfinished Style Cb unfinishedHighlightCB, void ∗
cbArg )
Attach (or remove) highlight information in text display and redisplay.
Highlighting information consists of a style buffer which parallels the normal text buffer, but codes font
and color information for the display; a style table which translates style buffer codes (indexed by buffer
character - ’A’) into fonts and colors; and a callback mechanism for as-needed highlighting, triggered by a
style buffer entry of ”unfinishedStyle”. Style buffer can trigger additional redisplay during a normal buffer
modification if the buffer contains a primary Fl Text Selection (see extendRangeForStyleMods for more
information on this protocol).
Style buffers, tables and their associated memory are managed by the caller.
Styles are ranged from 65 (’A’) to 126.
31.135. FL TEXT DISPLAY CLASS REFERENCE 717
Parameters
styleBuffer this buffer works in parallel to the text buffer. For every character in the text buffer,
the stye buffer has a byte at the same offset that contains an index into an array of
possible styles.
styleTable a list of styles indexed by the style buffer
nStyles number of styles in the style table
unfinishedStyle if this style is found, the callback below is called
unfinished- if a character with an unfinished style is found, this callback will be called
HighlightCB
cbArg and optional argument for the callback above, usually a pointer to the Text Display.
Returns
1 if position (X, Y) is inside of the primary Fl Text Selection
Note that the definition of the end of a line is less clear when continuous wrap is on. With continuous
wrap off, it’s just a pointer to the newline that ends the line. When it’s on, it’s the character beyond the last
displayable character on the line, where a whitespace character which has been ”converted” to a newline
for wrapping is not considered displayable. Also note that a line can be wrapped at a non-whitespace
character if the line had no whitespace. In this case, this routine returns a pointer to the start of the next
line. This is also consistent with the model used by visLineLength.
Parameters
startPos index to starting character
startPosIsLine- avoid scanning back to the line start
Start
Returns
new position as index
Returns
new position as index
Version
1.3.3 ABI feature (ignored in 1.3.x unless FLTK ABI VERSION is 10303 or higher)
Version
1.3.3 ABI feature (ignored in 1.3.x unless FLTK ABI VERSION is 10303 or higher)
Version
1.3.3 ABI feature (ignored in 1.3.x unless FLTK ABI VERSION is 10303 or higher)
31.135. FL TEXT DISPLAY CLASS REFERENCE 719
Version
1.3.3 ABI feature (ignored in 1.3.x unless FLTK ABI VERSION is 10303 or higher)
void Fl Text Display::maintain absolute top line number ( int state ) [protected]
Line numbering stuff, currently unused.
In continuous wrap mode, internal line numbers are calculated after wrapping. A separate non-wrapped
line count is maintained when line numbering is turned on. There is some performance cost to maintaining
this line count, so normally absolute line numbers are not tracked if line numbering is off. This routine
allows callers to specify that they still want this line count maintained (for use via TextDPosToLineAnd-
Col). More specifically, this allows the line number reported in the statistics line to be calibrated in absolute
lines, rather than post-wrapped lines.
720 CHAPTER 31. CLASS DOCUMENTATION
void Fl Text Display::measure deleted lines ( int pos, int nDeleted ) [protected]
Wrapping calculations.
This is a stripped-down version of the findWrapRange() function above, intended to be used to calculate
the number of ”deleted” lines during a buffer modification. It is called before the modification takes place.
This function should only be called in continuous wrap mode with a non-fixed font width. In that
case, it is impossible to calculate the number of deleted lines, because the necessary style information is
no longer available after the modification. In other cases, we can still perform the calculation afterwards
(possibly even more efficiently).
Parameters
pos
nDeleted
double Fl Text Display::measure proportional character ( const char ∗ s, int xPix, int pos ) const
[protected]
Wrapping calculations.
Measure the width in pixels of the first character of string ”s” at a particular column ”colNum” and
buffer position ”pos”. This is for measuring characters in proportional or mixed-width highlighting fonts.
A note about proportional and mixed-width fonts: the mixed width and proportional font code in nedit
does not get much use in general editing, because nedit doesn’t allow per-language-mode fonts, and editing
programs in a proportional font is usually a bad idea, so very few users would choose a proportional font as a
default. There are still probably mixed- width syntax highlighting cases where things don’t redraw properly
for insertion/deletion, though static display and wrapping and resizing should now be solid because they
are now used for online help display.
Parameters
s text string
xPix x pixel position needed for calculating tab widths
pos offset within string
Returns
width of character in pixels
Returns
width of line in pixels
31.135. FL TEXT DISPLAY CLASS REFERENCE 721
Returns
1 if the cursor moved, 0 if the beginning of the text was reached
Returns
1 if the cursor moved, 0 if the beginning of the text was reached
Returns
1 if the cursor moved, 0 if the end of the text was reached
Returns
1 if the cursor moved, 0 if the beginning of the text was reached
int Fl Text Display::position style ( int lineStartPos, int lineLen, int lineIndex ) const
Find the correct style for a character.
Determine the drawing method to use to draw a specific character from ”buf”. lineStartPos gives
the character index where the line begins, lineIndex, the number of characters past the beginning of
the line, and lineIndex the number of displayed characters past the beginning of the line. Passing
lineStartPos of -1 returns the drawing style for ”no text”.
Why not just: position style(pos)? Because style applies to blank areas of the window beyond the
text boundaries, and because this routine must also decide whether a position is inside of a rectangular
Fl Text Selection, and do so efficiently, without re-counting character positions from the start of the line.
Note that style is a somewhat incorrect name, drawing method would be more appropriate.
Parameters
lineStartPos beginning of this line
lineLen number of bytes in line
lineIndex position of character within line
Returns
style for the given character
int Fl Text Display::position to line ( int pos, int ∗ lineNum ) const [protected]
Convert a position index into a line number offset.
Find the line number of position pos relative to the first line of displayed text. Returns 0 if the line is
not displayed.
Parameters
pos ??
out lineNum ??
Returns
??
Todo What does this do?
int Fl Text Display::position to linecol ( int pos, int ∗ lineNum, int ∗ column ) const
[protected]
Find the line and column number of position pos.
This only works for displayed lines. If the line is not displayed, the function returns 0 (without the
mLineStarts array it could turn in to very long calculation involving scanning large amounts of text in the
buffer). If continuous wrap mode is on, returns the absolute line number (as opposed to the wrapped line
number which is used for scrolling).
Parameters
pos character index
out lineNum absolute (unwrapped) line number
out column character offset to the beginning of the line
Returns
0 if pos is off screen, line number otherwise
Todo a column number makes little sense in the UTF-8/variable font width environment. We will have
to further define what exactly we want to return. Please check the functions that call this particular
function.
31.135. FL TEXT DISPLAY CLASS REFERENCE 723
Returns
0 if character vertically out of view, X & Y positions otherwise
Returns
new position as index
Parameters
topLineNum top line number
horizOffset column number
Returns
0 if nothing changed, 1 if we scrolled
Returns
scrollbar alignment
int Fl Text Display::skip lines ( int startPos, int nLines, bool startPosIsLineStart )
Skip a number of lines forward.
Same as BufCountForwardNLines, but takes into account line breaks when wrapping is turned on. If
the caller knows that startPos is at a line start, it can pass ”startPosIsLineStart” as True to make the call
more efficient by avoiding the additional step of scanning back to the last newline.
Parameters
startPos index to starting character
nLines number of lines to skip ahead
startPosIsLine- avoid scanning back to the line start
Start
Returns
new position as index
double Fl Text Display::string width ( const char ∗ string, int length, int style ) const
[protected]
Find the width of a string in the font of a particular style.
726 CHAPTER 31. CLASS DOCUMENTATION
Parameters
string the text
length number of bytes in string
style index into style table
Returns
width of text segment in pixels
Parameters
s new text size
void Fl Text Display::update line starts ( int pos, int charsInserted, int charsDeleted, int
linesInserted, int linesDeleted, int ∗ scrolled ) [protected]
Update line start arrays and variables.
Update the line starts array, mTopLineNum, mFirstChar and lastChar for this text display after a modi-
fication to the text buffer, given by the position pos where the change began, and the numbers of characters
and lines inserted and deleted.
Parameters
pos index into buffer of recent changes
charsInserted number of bytes(!) inserted
charsDeleted number of bytes(!) deleted
linesInserted number of lines
linesDeleted number of lines
out scrolled set to 1 if the text display needs to be scrolled
Returns
number of bytes in this line
Returns
index of first character after the end of the word
728 CHAPTER 31. CLASS DOCUMENTATION
Parameters
pos start calculation at this index
Returns
beginning of the words
Todo we need new wrap modes to wrap at the window edge and based on pixel width or average character
width.
Returns
1 if a \n character causes the line wrap
Parameters
row
column
Returns
something unknown
Todo What does this do and how is it useful? Column numbers mean little in this context. Which functions
depend on this one?
Todo Unicode?
void Fl Text Display::wrapped line counter ( Fl Text Buffer ∗ buf, int startPos, int maxPos, int
maxLines, bool startPosIsLineStart, int styleBufOffset, int ∗ retPos, int ∗ retLines, int ∗ retLineStart,
int ∗ retLineEnd, bool countLastLineMissingNewLine = true ) const [protected]
Wrapping calculations.
Count forward from startPos to either maxPos or maxLines (whichever is reached first), and return all
relevant positions and line count. The provided textBuffer may differ from the actual text buffer of the
widget. In that case it must be a (partial) copy of the actual text buffer and the styleBufOffset argument
must indicate the starting position of the copy, to take into account the correct style information.
Parameters
in buf The text buffer to operate on
in startPos Starting index position into the buffer
in maxPos Maximum index position into the buffer we’ll reach
in maxLines Maximum number of lines we’ll reach
in startPosIsLine- Flag indicating if startPos is start of line. (If set, prevents our having to
Start find the line start)
in styleBufOffset Offset index position into style buffer.
out retPos Position where counting ended. When counting lines, the position re-
turned is the start of the line ”maxLines” lines beyond ”startPos”.
out retLines Number of line breaks counted
out retLineStart Start of the line where counting ended
out retLineEnd End position of the last line traversed
out countLastLine-
MissingNew-
Line
row
Returns
something unknown
Todo What does this do and how is it useful? Column numbers mean little in this context. Which functions
depend on this one?
Returns
an approximate column number based on the main font
int Fl Text Display::xy to position ( int X, int Y, int posType = CHARACTER POS ) const
[protected]
Translate a pixel position into a character index.
Translate window coordinates to the nearest (insert cursor or character cell) text position. The parameter
posType specifies how to interpret the position: CURSOR POS means translate the coordinates to the
nearest cursor position, and CHARACTER POS means return the position of the character closest to (X,
Y).
Parameters
X,Y pixel position
posType CURSOR POS or CHARACTER POS
Returns
index into text buffer
void Fl Text Display::xy to rowcol ( int X, int Y, int ∗ row, int ∗ column, int posType =
CHARACTER POS ) const [protected]
Translate pixel coordinates into row and column.
Translate window coordinates to the nearest row and column number for positioning the cursor. This, of
course, makes no sense when the font is proportional, since there are no absolute columns. The parameter
posType specifies how to interpret the position: CURSOR POS means translate the coordinates to the
nearest position between characters, and CHARACTER POS means translate the position to the nearest
character cell.
Parameters
X,Y pixel coordinates
732 CHAPTER 31. CLASS DOCUMENTATION
Fl_Widget
Fl_Group
Fl_Text_Display
Fl_Text_Editor
Classes
• struct Key Binding
Simple linked list associating a key/state to a function.
Public Types
• typedef int(∗ Key Func )(int key, Fl Text Editor ∗editor)
Key function binding callback type.
Fl Text Editor::Key Func Fl Text Editor::bound key function ( int key, int state, Key Binding ∗
list )
Returns the function associated with a key binding.
31.136. FL TEXT EDITOR CLASS REFERENCE 735
Key Func Fl Text Editor::bound key function ( int key, int state ) [inline]
Returns the function associated with a key binding.
void Fl Text Editor::remove key binding ( int key, int state ) [inline]
Removes the key binding associated with the key ”key” of state ”state”.
The documentation for this class was generated from the following files:
• Fl Text Editor.H
• Fl Text Editor.cxx
31.137. FL TEXT SELECTION CLASS REFERENCE 737
Protected Attributes
• int mEnd
byte offset to the character after the last selected character
• bool mSelected
this flag is set if any text is selected
• int mStart
byte offset to the first selected character
Friends
• class Fl Text Buffer
Parameters
start retrun byte offset to first selected character
end retrun byte offset pointing after last selected character
Returns
true if selected
Returns
a non-zero number if any text has been selected, or 0 if no text is selected.
Returns
byte offset
• Fl Text Buffer.H
• Fl Text Buffer.cxx
740 CHAPTER 31. CLASS DOCUMENTATION
Fl_Widget
Fl_Group
Fl_Tile
For the tiling to work correctly, the children of an Fl Tile must cover the entire area of the widget, but
not overlap. This means that all children must touch each other at their edges, and no gaps can be left inside
the Fl Tile.
Fl Tile does not normally draw any graphics of its own. The ”borders” which can be seen in the
snapshot above are actually part of the children. Their boxtypes have been set to FL DOWN BOX creating
31.138. FL TILE CLASS REFERENCE 741
the impression of ”ridges” where the boxes touch. What you see are actually two adjacent FL DOWN B-
OX’s drawn next to each other. All neighboring widgets share the same edge - the widget’s thick borders
make it appear as though the widgets aren’t actually touching, but they are. If the edges of adjacent widgets
do not touch, then it will be impossible to drag the corresponding edges.
Fl Tile allows objects to be resized to zero dimensions. To prevent this you can use the resizable() to
limit where corners can be dragged to. For more information see note below.
Even though objects can be resized to zero sizes, they must initially have non-zero sizes so the Fl Tile
can figure out their layout. If desired, call position() after creating the children but before displaying the
window to set the borders where you want.
Note on resizable(Fl Widget &w): The ”resizable” child widget (which should be invisible) limits
where the borders can be dragged to. All dragging will be limited inside the resizable widget’s borders.
If you don’t set it, it will be possible to drag the borders right to the edges of the Fl Tile widget, and thus
resize objects on the edges to zero width or height. When the entire Fl Tile widget is resized, the resizable()
widget will keep its border distance to all borders the same (this is normal resize behavior), so that you can
effectively set a border width that will never change.
Note: You can still resize widgets inside the resizable() to zero width and/or height, i.e. box 2b above
to zero width and box 3a to zero height.
See Also
void Fl Group::resizable(Fl Widget &w)
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
void Fl Tile::position ( int oldx, int oldy, int newx, int newy )
Drags the intersection at (oldx,oldy) to (newx,newy).
This redraws all the necessary children.
Pass zero as oldx or oldy to disable drag in that direction.
Fl_Image
Fl_Tiled_Image
Protected Attributes
• int alloc image
• Fl Image ∗ image
void Fl Tiled Image::draw ( int X, int Y, int W, int H, int cx, int cy ) [virtual]
Draws the image with a bounding box.
This form specifies a bounding box for the image, with the origin (upper-lefthand corner) of the image
offset by the cx and cy arguments.
Reimplemented from Fl Image.
The documentation for this class was generated from the following files:
• Fl Tiled Image.H
• Fl Tiled Image.cxx
Fl_Widget
Fl_Timer
• FL NORMAL TIMER - The timer just does the callback and displays the string ”Timer” in the
widget.
• FL VALUE TIMER - The timer does the callback and displays the current timer value in the widget.
• FL HIDDEN TIMER - The timer just does the callback and does not display anything.
Implements Fl Widget.
746 CHAPTER 31. CLASS DOCUMENTATION
See Also
Fl Event
Fl_Widget
Fl_Button
Fl_Toggle_Button
• static void enter area (Fl Widget ∗w, int X, int Y, int W, int H, const char ∗tip)
You may be able to use this to provide tooltips for internal pieces of your widget.
• static Fl Font font ()
Gets the typeface for the tooltip text.
• static void font (Fl Font i)
Sets the typeface for the tooltip text.
• static float hoverdelay ()
Gets the tooltip hover delay, the delay between tooltips.
• static void hoverdelay (float f)
Sets the tooltip hover delay, the delay between tooltips.
• static int margin height ()
• static int margin width ()
• static Fl Fontsize size ()
Gets the size of the tooltip text.
• static void size (Fl Fontsize s)
Sets the size of the tooltip text.
• static Fl Color textcolor ()
Gets the color of the text in the tooltip.
• static void textcolor (Fl Color c)
Sets the color of the text in the tooltip.
• static int wrap width ()
Friends
• void Fl Widget::copy tooltip (const char ∗)
• void Fl Widget::tooltip (const char ∗)
void Fl Tooltip::enter area ( Fl Widget ∗ wid, int x, int y, int w, int h, const char ∗ t )
[static]
You may be able to use this to provide tooltips for internal pieces of your widget.
Call this after setting Fl::belowmouse() to your widget (because that calls the above enter() method).
Then figure out what thing the mouse is pointing at, and call this with the widget (this pointer is used to
remove the tooltip if the widget is deleted or hidden, and to locate the tooltip), the rectangle surrounding
the area, relative to the top-left corner of the widget (used to calculate where to put the tooltip), and the text
of the tooltip (which must be a pointer to static data as it is not copied).
• Fl Tooltip.H
• Fl.cxx
• Fl Tooltip.cxx
Fl_Widget
Fl_Group
Fl_Tree
31.143. FL TREE CLASS REFERENCE 751
Protected Attributes
• Fl Scrollbar ∗ vscroll
Vertical scrollbar.
Friends
• class Fl Tree Item
31.143. FL TREE CLASS REFERENCE 757
The tree items may also contain other FLTK widgets, like buttons, input fields,
or even "custom" widgets.
FEATURES
Items can be added with add(),
removed with remove(),
completely cleared with clear(),
inserted with insert() and insert above(),
selected/deselected with select() and deselect(),
open/closed with open() and close(),
758 CHAPTER 31. CLASS DOCUMENTATION
positioned on the screen with show item top(), show item middle() and show item bottom(),
item children can be swapped around with Fl Tree Item::swap children(),
sorting can be controlled when items are add()ed via sortorder().
You can walk the entire tree with first() and next().
You can walk visible items with first visible item() and next visible item().
You can walk selected items with first selected item() and next selected item().
Items can be found by their pathname using find item(const char∗), and an item’s pathname can be
found with item pathname().
The selected items’ colors are controlled by selection color() (inherited from Fl Widget).
A hook is provided to allow you to redefine how item’s labels are drawn via Fl Tree::item draw -
callback().
SELECTION OF ITEMS
The tree can have different selection behaviors controlled by selectmode(). The background color
used for selected items is the Fl Tree::selection color(). The foreground color for selected items is
controlled internally with fl contrast().
CHILD WIDGETS
FLTK widgets (including custom widgets) can be assigned to tree items via Fl Tree Item::widget().
When an Fl Tree Item::widget() is defined, the default behavior is for the widget() to be shown in
place of the item’s label (if it has one). Only the widget()’s width will be used; the widget()’s x() and
y() position will be managed by the tree, and the h() will track the item’s height. This default behavior
can be altered (ABI 1.3.1): Setting Fl Tree::item draw mode()’s FL TREE ITEM DRAW LABEL-
AND WIDGET flag causes the label + widget to be displayed together in that order, and adding
the FL TREE ITEM HEIGHT FROM WIDGET flag causes widget’s height to define the widget()’s
height.
ICONS
The tree’s open/close icons can be redefined with Fl Tree::openicon(), Fl Tree::closeicon(). User icons
can either be changed globally with Fl Tree::usericon(), or on a per-item basis with Fl Tree Item-
::usericon().
Various default preferences can be globally manipulated via Fl Tree Prefs, including colors, margins,
icons, connection lines, etc.
FONTS AND COLORS
When adding new items to the tree, the new items get the defaults for fonts and colors from:
Each item (Fl Tree Item) inherits a copy of these font/color attributes when created, and each item
has its own methods to let the app change these values on a per-item basis using methods of the same
name:
SIMPLE EXAMPLES
To find all the selected items:
for ( Fl Tree Item *i=first selected item(); i; i=
next selected item(i) )
printf("Item %s is selected\n", i->label());
To recursively walk all the children of a particular item, define a function that uses recursion:
// Find all of the item’s children and print an indented report of their labels
void my print all children(Fl Tree Item *item, int indent=0) {
for ( int t=0; t<item->children(); t++ ) {
printf("%*s Item: %s\n", indent, "", item->child(t)->label());
my print all children(item->child(t), indent+4); // recurse
}
}
To change the default label font and color when creating new items:
tree = new Fl Tree(..);
tree->item labelfont(FL COURIER); // Use Courier font for all new items
tree->item labelfgcolor(FL RED); // Use red color for labels of all new items
[..]
// Now create the items in the tree using the above defaults.
tree->add("Aaa");
tree->add("Bbb");
[..]
760 CHAPTER 31. CLASS DOCUMENTATION
To change the font and color of all existing items in the tree:
// Change the font and color of all items currently in the tree
for ( Fl Tree Item *item = tree->first(); item; item = tree->
next(item) ) {
item->labelfont(FL COURIER);
item->labelcolor(FL RED);
}
DISPLAY DESCRIPTION
The following image shows the tree’s various visual elements and the methods that control them:
The following shows the protected ’tree inner’ (tix..) and ’tree outer’ (tox..) dimension variables:
KEYBOARD BINDINGS
The following table lists keyboard bindings for navigating the tree:
Parameters
in path The path to the item to be created, e.g. ”Flintsone/Fred”.
Returns
The new item added, or 0 on error.
See Also
add(const char∗,Fl Tree Item∗)
Version
1.3.0 release
Parameters
in path The path to the item, e.g. ”Flintsone/Fred”.
in item The new item to be added. If NULL, a new item is created with a name
that is the last element in ’path’.
Returns
The new item added, or 0 on error.
Version
1.3.3
Fl Tree Item ∗ Fl Tree::add ( Fl Tree Item ∗ parent item, const char ∗ name )
Add a new child item labeled ’name’ to the specified ’parent item’.
Parameters
in parent item The parent item the new child item will be added to. Must not be NULL.
in name The label for the new item
Returns
The new item added.
Version
1.3.0 release
762 CHAPTER 31. CLASS DOCUMENTATION
See Also
item reselect mode() – enables FL TREE REASON RESELECTED events
void Fl Tree::clear ( )
Clear the entire tree’s children, including the root.
The tree will be left completely empty.
Parameters
in item – the item to be closed. Must not be NULL.
in docallback – A flag that determines if the callback() is invoked or not:
Returns
• 1 – item was closed
• 0 – item was already closed, no change
See Also
open(), close(), is open(), is close(), callback item(), callback reason()
Returns
• 1 – OK: item closed
• 0 – OK: item was already closed, no change
• -1 – ERROR: item was not found
See Also
open(), close(), is open(), is close(), callback item(), callback reason()
Parameters
in val – The new image, or zero to use the default [-] icon.
Returns
• 0 - item was already deselected, no change was made
• 1 - item’s state was changed
Returns
• 1 - OK: item’s state was changed
• 0 - OK: item was already deselected, no change was made
• -1 - ERROR: item was not found
31.143. FL TREE CLASS REFERENCE 765
Returns
Count of how many items were actually changed to the deselected state.
Returns
1 if displayed, 0 if scrolled off screen or no items are in tree.
Version
1.3.0
766 CHAPTER 31. CLASS DOCUMENTATION
int Fl Tree::extend selection dir ( Fl Tree Item ∗ from, Fl Tree Item ∗ to, int dir, int val, bool
visible )
Extend the selection between and including ’from’ and ’to’ depending on direction ’dir’, ’val’,
and ’visible’.
Efficient: does not walk entire tree; starts with ’from’ and stops at ’to’ while moving in direction
’dir’. Dir must be specified though. Handles calling redraw() if anything changed.
Parameters
in from Starting item
in to Ending item
in dir Direction to extend selection (FL Up or FL Down)
in val 0=deselect, 1=select, 2=toggle
in visible true=affect only open(), visible items,
false=affect open or closed items (default)
Returns
The number of items whose selection states were changed, if any.
Version
1.3.3
Parameters
in path – the tree item’s pathname to be found (e.g. ”Flintstones/Fred”)
Returns
The item, or NULL if not found.
See Also
item pathname()
Returns
First item in tree, or 0 if none (tree empty).
See Also
first(), next(), last(), prev()
Returns
The first selected item, or 0 if none.
See Also
first selected item(), last selected item(), next selected item()
See Also
first visible item(), last visible item(), next visible item()
Version
1.3.3
Note
Must be using FLTK ABI 1.3.3 or higher for this to be effective.
Note
Must be using FLTK ABI 1.3.3 or higher for this to be effective.
Fl Tree Item ∗ Fl Tree::insert ( Fl Tree Item ∗ item, const char ∗ name, int pos )
Insert a new item ’name’ into ’item’s children at position ’pos’.
Example:
tree->add("Aaa/000"); // "000" is index 0 in Aaa’s children
tree->add("Aaa/111"); // "111" is index 1 in Aaa’s children
tree->add("Aaa/222"); // "222" is index 2 in Aaa’s children
..
// How to use insert() to insert a new item between Aaa/111 + Aaa/222
Fl Tree Item *item = tree->find item("Aaa"); // get parent item Aaa
if (item) tree->insert(item, "New item", 2); // insert as a child of Aaa at index #2
31.143. FL TREE CLASS REFERENCE 769
Parameters
in item The existing item to insert new child into. Must not be NULL.
in name The label for the new item
in pos The position of the new item in the child list
Returns
The new item added.
See Also
insert above()
Fl Tree Item ∗ Fl Tree::insert above ( Fl Tree Item ∗ above, const char ∗ name )
Inserts a new item ’name’ above the specified Fl Tree Item ’above’.
Example:
tree->add("Aaa/000"); // "000" is index 0 in Aaa’s children
tree->add("Aaa/111"); // "111" is index 1 in Aaa’s children
tree->add("Aaa/222"); // "222" is index 2 in Aaa’s children
..
// How to use insert above() to insert a new item above Aaa/222
Fl Tree Item *item = tree->find item("Aaa/222"); // get item Aaa/222
if (item) tree->insert above(item, "New item"); // insert new item above it
Parameters
in above – the item above which to insert the new item. Must not be NULL.
in name – the name of the new item
Returns
The new item added, or 0 if ’above’ could not be found.
See Also
insert()
Returns
• 1 : item is open
• 0 : item is closed
Parameters
in path – the tree item’s pathname (e.g. ”Flintstones/Fred”)
Returns
• 1 - OK: item is closed
• 0 - OK: item is open
• -1 - ERROR: item was not found
Note
Must be using FLTK ABI 1.3.3 or higher for this to be effective.
Returns
• 1 : item is open
• 0 : item is closed
Returns
• 1 - OK: item is open
• 0 - OK: item is closed
• -1 - ERROR: item was not found
See Also
Fl Tree Item::visible r()
31.143. FL TREE CLASS REFERENCE 771
Parameters
in w Widget to test
Returns
1 if w is a scrollbar, 0 if not.
Returns
• 1 : item selected
• 0 : item deselected
Returns
• 1 : item selected
• 0 : item deselected
• -1 : item was not found
Returns
1 if scrollbar visible, 0 if not.
772 CHAPTER 31. CLASS DOCUMENTATION
int Fl Tree::item pathname ( char ∗ pathname, int pathnamelen, const Fl Tree Item ∗ item ) const
Return ’pathname’ of size ’pathnamelen’ for the specified ’item’.
If ’item’ is NULL, root() is used.
The tree’s root will be included in the pathname of showroot() is on.
Menu items or submenus that contain slashes (’/’ or ’\’) in their names will be escaped with a backslash.
This is symmetrical with the add() function which uses the same escape pattern to set names.
31.143. FL TREE CLASS REFERENCE 773
Parameters
out pathname The string to use to return the pathname
in pathnamelen The maximum length of the string (including NULL). Must not be zero.
in item The item whose pathname is to be returned.
Returns
• 0 : OK (pathname returns the item’s pathname)
• -1 : item not found (pathname=””)
• -2 : pathname not large enough (pathname=””)
See Also
find item()
Returns
Last item in the tree, or 0 if none (tree empty).
See Also
first(), next(), last(), prev()
Returns
The last selected item, or 0 if none.
See Also
first selected item(), last selected item(), next selected item()
Version
1.3.3
774 CHAPTER 31. CLASS DOCUMENTATION
Returns
Last visible item in the tree, or 0 if none.
See Also
first visible item(), last visible item(), next visible item()
Version
1.3.3
Parameters
in item The item to use to find the next item. If NULL, returns 0.
Returns
Next item in tree, or 0 if at last item.
See Also
first(), next(), last(), prev()
31.143. FL TREE CLASS REFERENCE 775
Fl Tree Item ∗ Fl Tree::next item ( Fl Tree Item ∗ item, int dir = FL Down, bool visible = false )
Returns next item after ’item’ in direction ’dir’ depending on ’visible’.
Next item will be above (if dir==FL Up) or below (if dir==FL Down). If ’visible’ is true, only
items whose parents are open() will be returned. If ’visible’ is false, even items whose parents are
close()ed will be returned.
If item is 0, the return value will be the result of this truth table:
visible=true visible=false
------------------- -------------
dir=Fl Up: last visible item() last()
dir=Fl Down: first visible item() first()
Example use:
Parameters
in item The item to use to find the next item. If NULL, returns 0.
in dir Can be FL Up or FL Down (default=FL Down or ’next’)
in visible true=return only open(), visible items,
false=return open or closed items (default)
Returns
Next item in tree in the direction and visibility specified, or 0 if no more items of specified visibility
in that direction.
See Also
first(), last(), next(),
first visible item(), last visible item(), next visible item(),
first selected item(), last selected item(), next selected item()
Version
1.3.3
Parameters
in item The item to use to find the next selected item. If NULL, first() is used.
Returns
The next selected item, or 0 if there are no more selected items.
See Also
first selected item(), last selected item(), next selected item()
Fl Tree Item ∗ Fl Tree::next selected item ( Fl Tree Item ∗ item, int dir )
Returns the next selected item above or below ’item’, depending on ’dir’.
If ’item’ is 0, search starts at either first() or last(), depending on ’dir’: first() if ’dir’ is FL -
Down (default), last() if ’dir’ is FL Up.
Use this to walk the tree looking for all the selected items, e.g.
// Walk down the tree (forwards)
for ( Fl Tree Item *i=tree->first selected item(); i; i=tree->
next selected item(i, FL Down) )
printf("Item: %s\n", i->label());
Parameters
in item The item above or below which we’ll find the next selected item. If
NULL, first() is used if FL Down, last() if FL Up. (default=NULL)
in dir The direction to go. FL Up for moving up the tree, FL Down for down
the tree (default)
Returns
The next selected item, or 0 if there are no more selected items.
See Also
first selected item(), last selected item(), next selected item()
Version
1.3.3
Fl Tree Item ∗ Fl Tree::next visible item ( Fl Tree Item ∗ item, int dir ) [protected]
Returns next open(), visible item above (dir==FL Up) or below (dir==FL Down) the specified ’item’,
or 0 if no more items.
If ’item’ is 0, returns first() if ’dir’ is FL Up, or last() if dir is FL Down.
// Walk down the tree (forwards)
for ( Fl Tree Item *i=tree->first visible item(); i; i=tree->
next visible item(i, FL Down) )
printf("Item: %s\n", i->label());
Parameters
in item The item above/below which we’ll find the next visible item
in dir The direction to search. Can be FL Up or FL Down.
Returns
The item found, or 0 if there’s no visible items above/below the specified item.
Version
1.3.3
Returns
• 1 – item was opened
• 0 – item was already open, no change
See Also
open(), close(), is open(), is close(), callback item(), callback reason()
Parameters
in path – the tree item’s pathname (e.g. ”Flintstones/Fred”)
in docallback – A flag that determines if the callback() is invoked or not:
Returns
• 1 – OK: item opened
• 0 – OK: item was already open, no change
• -1 – ERROR: item was not found
See Also
open(), close(), is open(), is close(), callback item(), callback reason()
See Also
open(), close(), is open(), is close(), callback item(), callback reason()
Parameters
in val – The new image, or zero to use the default [+] icon.
Parameters
in item The item to use to find the previous item. If NULL, returns 0.
Returns
Previous item in tree, or 0 if at first item.
See Also
first(), next(), last(), prev()
See Also
Fl Group::resizable(Fl Widget∗)
Fl Group::resizable()
Fl Widget::resize(int,int,int,int)
See Also
Fl::scrollbar size(int)
See Also
Fl::scrollbar size()
Parameters
in item – the item to be selected. Must not be NULL.
in docallback – A flag that determines if the callback() is invoked or not:
Returns
• 1 - item’s state was changed
• 0 - item was already selected, no change was made
Returns
• 1 : OK: item’s state was changed
• 0 : OK: item was already selected, no change was made
• -1 : ERROR: item was not found
in item The item that will be selected (along with all its children). If NULL,
first() is used.
in docallback – A flag that determines if the callback() is invoked or not:
Returns
Count of how many items were actually changed to the selected state.
Returns
The number of items whose selection states were changed, if any.
See Also
show item top(), show item middle(), show item bottom()
See Also
show item top(), show item middle(), show item bottom()
Parameters
in item The item to be shown. If NULL, first() is used.
Version
1.3.0
See Also
vposition(), hposition()
• Fl Tree.H
• Fl Tree.cxx
Add a new child to this item with the name ’new label’ and defaults from ’prefs’.
• Fl Tree Item ∗ add (const Fl Tree Prefs &prefs, char ∗∗arr, Fl Tree Item ∗newitem)
Descend into path specified by ’arr’ and add ’newitem’ there.
• Fl Tree Item ∗ add (const Fl Tree Prefs &prefs, char ∗∗arr)
Descend into the path specified by ’arr’, and add a new child there.
• Fl Tree Item ∗ child (int index)
Return the child item for the given ’index’.
• const Fl Tree Item ∗ child (int t) const
Return the const child item for the given ’index’.
• int children () const
Return the number of children this item has.
• void clear children ()
Clear all the children for this item.
• void close ()
Close this item and all its children.
• void deactivate ()
Deactivate the item; the callback() won’t be invoked when clicked.
• Fl Tree Item ∗ deparent (int index)
Deparent child at index position ’pos’.
• int depth () const
Returns how many levels deep this item is in the hierarchy.
• void deselect ()
Disable the item’s selection state.
• int deselect all ()
Deselect item and all its children.
• void draw (int X, int &Y, int W, Fl Widget ∗tree, Fl Tree Item ∗itemfocus, const Fl Tree Prefs
&prefs, int lastchild=1)
Draw this item and its children.
• int event on collapse icon (const Fl Tree Prefs &prefs) const
Was the event on the ’collapse’ button of this item?
• int event on label (const Fl Tree Prefs &prefs) const
Was event on the label() of this item?
• int find child (const char ∗name)
Return the index of the immediate child of this item that has the label ’name’.
• int find child (Fl Tree Item ∗item)
Find the index number for the specified ’item’ in the current item’s list of children.
• const Fl Tree Item ∗ find child item (const char ∗name) const
Return the /immediate/ child of current item that has the label ’name’.
• Fl Tree Item ∗ find child item (const char ∗name)
Non-const version of Fl Tree Item::find child item(const char ∗name) const.
• const Fl Tree Item ∗ find child item (char ∗∗arr) const
Find child item by descending array ’arr’ of names.
• Fl Tree Item ∗ find child item (char ∗∗arr)
Non-const version of Fl Tree Item::find child item(char ∗∗arr) const.
• const Fl Tree Item ∗ find clicked (const Fl Tree Prefs &prefs) const
Find the item that the last event was over.
• Fl Tree Item ∗ find clicked (const Fl Tree Prefs &prefs)
31.144. FL TREE ITEM CLASS REFERENCE 787
Fl Tree Item ∗ Fl Tree Item::add ( const Fl Tree Prefs & prefs, const char ∗ new label,
Fl Tree Item ∗ item )
Add ’item’ as immediate child with ’new label’ and defaults from ’prefs’.
If ’item’ is NULL, a new item is created. An internally managed copy is made of the label string.
Adds the item based on the value of prefs.sortorder().
Returns
the item added
Version
1.3.3
Fl Tree Item ∗ Fl Tree Item::add ( const Fl Tree Prefs & prefs, const char ∗ new label )
Add a new child to this item with the name ’new label’ and defaults from ’prefs’.
An internally managed copy is made of the label string. Adds the item based on the value of prefs.-
sortorder().
Returns
the item added
Version
1.3.0 release
Fl Tree Item ∗ Fl Tree Item::add ( const Fl Tree Prefs & prefs, char ∗∗ arr, Fl Tree Item ∗
newitem )
Returns
the item added.
Version
1.3.3 ABI feature
792 CHAPTER 31. CLASS DOCUMENTATION
Fl Tree Item ∗ Fl Tree Item::add ( const Fl Tree Prefs & prefs, char ∗∗ arr )
Descend into the path specified by ’arr’, and add a new child there.
Should be used only by Fl Tree’s internals. Adds the item based on the value of prefs.sortorder().
Returns
the item added.
Version
1.3.0 release
int Fl Tree Item::calc item height ( const Fl Tree Prefs & prefs ) const [protected]
Return the item’s ’visible’ height.
Takes into account the item’s:
• visibility (if !is visible(), returns 0)
• labelfont() height: if label() != NULL
• widget() height: if widget() != NULL
• openicon() height (if not NULL)
• usericon() height (if not NULL) Does NOT include Fl Tree::linespacing();
Returns
maximum pixel height
void Fl Tree Item::draw ( int X, int & Y, int W, Fl Widget ∗ tree, Fl Tree Item ∗ itemfocus, const
Fl Tree Prefs & prefs, int lastchild = 1 )
Draw this item and its children.
Parameters
in X Horizontal position for item being drawn
in,out Y Vertical position for item being drawn, returns new position for next item
in W Recommended width of item
in tree The parent tree
in itemfocus The tree’s current focus item (if any)
in prefs The tree’s preferences
in lastchild Is this item the last child in a subtree?
Version
1.3.0 release, removed 1.3.3 ABI
void Fl Tree Item::draw horizontal connector ( int x1, int x2, int y, const Fl Tree Prefs & prefs )
[protected]
Internal: Horizontal connector line based on preference settings.
Parameters
in x1 The left hand X position of the horizontal connector
in x2 The right hand X position of the horizontal connector
in y The vertical position of the horizontal connector
in prefs The Fl Tree prefs
void Fl Tree Item::draw vertical connector ( int x, int y1, int y2, const Fl Tree Prefs & prefs )
[protected]
Internal: Vertical connector line based on preference settings.
Parameters
in x The x position of the vertical connector
in y1 The top of the vertical connector
in y2 The bottom of the vertical connector
in prefs The Fl Tree prefs
Version
1.3.0 release
794 CHAPTER 31. CLASS DOCUMENTATION
const Fl Tree Item ∗ Fl Tree Item::find child item ( const char ∗ name ) const
Return the /immediate/ child of current item that has the label ’name’.
Returns
const found item, or 0 if not found.
Version
1.3.3
const Fl Tree Item ∗ Fl Tree Item::find child item ( char ∗∗ arr ) const
Find child item by descending array ’arr’ of names.
Does not include self in search. Only Fl Tree should need this method.
Returns
item, or 0 if not found
Version
1.3.0 release
const Fl Tree Item ∗ Fl Tree Item::find clicked ( const Fl Tree Prefs & prefs ) const
Find the item that the last event was over.
Parameters
in prefs The parent tree’s Fl Tree Prefs
Returns
pointer to clicked item, or NULL if none found
Version
1.3.0
Fl Tree Item ∗ Fl Tree Item::insert ( const Fl Tree Prefs & prefs, const char ∗ new label, int pos =
0 )
Insert a new item named ’new label’ into current item’s children at a specified position ’pos’.
Returns
the new item inserted.
Fl Tree Item ∗ Fl Tree Item::insert above ( const Fl Tree Prefs & prefs, const char ∗ new label )
Insert a new item named ’new label’ above this item.
Returns
the new item inserted, or 0 if an error occurred.
Returns
• 0: Success
• -1: range error (e.g. if ’to’ or ’from’ out of range).
• (Other return values reserved for future use)
Returns
0 on success. a negative number on error:
• -1: one of the items has no parent
• -2: item’s index could not be determined
• -3: bad ’op’
• -4: index range error
• -5: could not deparent
• -6: could not reparent at ’pos’
• (Other return values reserved for future use.)
Returns
0 on success.
On error returns a negative value; see move(Fl Tree Item∗,int,int) for possible error codes.
31.144. FL TREE ITEM CLASS REFERENCE 797
Version
1.3.3
798 CHAPTER 31. CLASS DOCUMENTATION
Returns
the previous item in the tree, or 0 if there’s no item above this one (hit the root).
Returns
This item’s previous sibling, or 0 if none.
Returns
the previous open() visible() item above us, or 0 if there’s no more items.
Version
1.3.3 ABI
31.144. FL TREE ITEM CLASS REFERENCE 799
Returns
0 if removed, -1 if not found.
Version
1.3.3
Returns
• 0: on success
• -1: on error (e.g. if ’pos’ out of range)
Parameters
in ax,bx the index of the items to swap
Returns
• 0 : OK
• -1 : failed: item ’a’ or ’b’ is not our child.
Returns
1 – item and its parents are open() and visible() 0 – item (or one of its parents) are invisible or
close()ed.
• Fl Tree Item.H
• Fl Tree Item.cxx
void Fl Tree Item Array::insert ( int pos, Fl Tree Item ∗ new item )
Insert an item at index position pos.
Handles enlarging array if needed, total increased by 1. If pos == total(), an empty item is appended
to the array.
• When ’from’ moved lower in tree, appears BELOW item that was at ’to’.
• When ’from’ moved higher in tree, appears ABOVE item that was at ’to’.
Returns
0 on success, -1 on range error (e.g. if ’to’ or ’from’ out of range)
int Fl Tree Item Array::reparent ( Fl Tree Item ∗ item, Fl Tree Item ∗ newparent, int pos )
Reparent specified item as a child of ourself.
Typically ’newchild’ was recently orphaned with deparent().
\returns 0 on success, -1 on error (e.g. if \p ’pos’ out of range)
Parameters
in val – The new image, or zero to use the default [-] icon.
Sets the default icon to be used as the ’open’ icon when items are add()ed to the tree.
This overrides the built in default ’[+]’ icon.
Parameters
in val – The new image, or zero to use the default [+] icon.
• Fl Tree Prefs.H
• Fl Tree Prefs.cxx
808 CHAPTER 31. CLASS DOCUMENTATION
Fl_Widget
Fl_Valuator
Fl_Line_Dial Fl_Hor_Fill_Slider
Fl_Hor_Nice_Slider
Fl_Hor_Slider
Fl_Nice_Slider
Fl_Scrollbar
Fl_Value_Slider
In the above diagram each box surrounds an actual subclass. These are further differentiated by setting
the type() of the widget t o the symbolic value labeling the widget. The ones labelled ”0” are the default
versions with a type(0). For consistency the symbol FL VERTICAL is defined as zero.
This method is used by the Fl Value ... group of widgets to format the current value into a text string.
The return value is the length of the formatted text. The formatted value is written into in buffer. buffer
should have space for at least 128 bytes.
You may override this function to create your own text formatting.
• Fl Valuator.H
• Fl Valuator.cxx
Fl_Widget
Fl_Valuator
Fl_Value_Input
Public Attributes
• Fl Input input
If step() is non-zero and integral, then the range of numbers are limited to integers instead of floating
point values.
Implements Fl Widget.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
See Also
position(int,int), size(int,int)
See Also
Fl Value Input::shortcut(int)
If ”soft” is turned on, the user is allowed to drag the value outside the range.
If they drag the value to one of the ends, let go, then grab again and continue to drag, they can get to
any value. The default is true.
• Fl Value Input.H
• Fl Value Input.cxx
Fl_Widget
Fl_Valuator
Fl_Value_Output
31.149. FL VALUE OUTPUT CLASS REFERENCE 817
Implements Fl Widget.
See Also
Fl Event
• Fl Value Output.H
• Fl Value Output.cxx
Fl_Widget
Fl_Valuator
Fl_Slider
Fl_Value_Slider
Fl_Hor_Value_Slider
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
• Fl Value Slider.H
• Fl Value Slider.cxx
Fl_Widget
Fl_Box
Fl_Button
Fl_Chart
Fl_Clock_Output
Fl_FormsBitmap
Fl_FormsPixmap
Fl_FormsText
Fl_Free
Fl_Group
Fl_Input_
Fl_Menu_
Fl_Positioner
Fl_Progress
Fl_Timer
Fl_Valuator
• int x () const
Gets the widget position in its window.
• int y () const
Gets the widget position in its window.
• virtual ∼Fl Widget ()
Destroys the widget.
Protected Types
• enum {
INACTIVE = 1<<0, INVISIBLE = 1<<1, OUTPUT = 1<<2, NOBORDER = 1<<3,
FORCE POSITION = 1<<4, NON MODAL = 1<<5, SHORTCUT LABEL = 1<<6, CHANGE-
D = 1<<7,
OVERRIDE = 1<<8, VISIBLE FOCUS = 1<<9, COPIED LABEL = 1<<10, CLIP CHILDREN
= 1<<11,
MENU WINDOW = 1<<12, TOOLTIP WINDOW = 1<<13, MODAL = 1<<14, NO OVERL-
AY = 1<<15,
GROUP RELATIVE = 1<<16, COPIED TOOLTIP = 1<<17, FULLSCREEN = 1<<18, MAC -
USE ACCENTS MENU = 1<<19,
USERFLAG3 = 1<<29, USERFLAG2 = 1<<30, USERFLAG1 = 1<<31 }
flags possible values enumeration.
Friends
• class Fl Group
CLIP CHILDREN all drawing within this widget will be clipped (Fl Group)
MENU WINDOW a temporary popup window, dismissed by clicking outside (Fl Window)
TOOLTIP WINDOW a temporary popup, transparent to events, and dismissed easily (Fl Window)
MODAL a window blocking input to all other winows (Fl Window)
NO OVERLAY window not using a hardware overlay plane (Fl Menu Window)
GROUP RELATIVE position this widget relative to the parent group, not to the window
COPIED TOOLTIP the widget tooltip is internally copied, its destruction is handled by the widget
FULLSCREEN a fullscreen window (Fl Window)
MAC USE ACCENTS MENU On the Mac OS platform, pressing and holding a key on the keyboard
opens an accented-character menu window (Fl Input , Fl Text Editor)
USERFLAG3 reserved for 3rd party extensions
USERFLAG2 reserved for 3rd party extensions
USERFLAG1 reserved for 3rd party extensions
Destruction removes the widget from any parent group! And groups when destroyed destroy all their
children. This is convenient and fast.
Return values
0 if the widget is inactive
See Also
active r(), activate(), deactivate()
See Also
active(), activate(), deactivate()
See Also
label(), align(Fl Align), Fl Align
See Also
align(), Fl Align
Todo The user data value must be implemented using intptr t or similar to avoid 64-bit machine incom-
patibilities.
Return values
NULL if this widget is not derived from Fl Gl Window.
Note
This method is provided to avoid dynamic cast.
See Also
Fl Widget::as group(), Fl Widget::as window()
Reimplemented in Fl Gl Window.
Return values
NULL if this widget is not derived from Fl Group.
Note
This method is provided to avoid dynamic cast.
See Also
Fl Widget::as window(), Fl Widget::as gl window()
Reimplemented in Fl Group.
Note
This method is provided to avoid dynamic cast.
See Also
Fl Widget::as group(), Fl Widget::as gl window()
Reimplemented in Fl Window.
31.151. FL WIDGET CLASS REFERENCE 833
See Also
box(Fl Boxtype), Fl Boxtype
See Also
box(), Fl Boxtype
Parameters
in cb new callback
See Also
set changed(), clear changed()
Parameters
in c new bitmask of damage flags (default: 0)
See Also
damage(uchar), damage()
See Also
color(Fl Color), color(Fl Color, Fl Color)
Parameters
in bg background color
See Also
color(), color(Fl Color, Fl Color), selection color(Fl Color)
See Also
color(unsigned), selection color(unsigned)
Returns
Returns 1 if w is a child of this widget, or is equal to this widget. Returns 0 if w is NULL.
Parameters
in new label the new label text
See Also
label()
See Also
tooltip(const char∗), tooltip()
See Also
damage(uchar), clear damage(uchar)
See Also
damage(), clear damage(uchar)
Parameters
in c bitmask of flags to set
in x,y,w,h size of damaged area
See Also
damage(), clear damage(uchar)
void Fl Widget::deactivate ( )
Deactivates the widget.
Inactive widgets will be drawn ”grayed out”, e.g. with less contrast than the active widget. Inactive
widgets will not receive any keyboard or mouse button events. Other events (including FL ENTER, FL -
MOVE, FL LEAVE, FL SHORTCUT, and others) will still be sent. A widget is only active if active() is
true on it and all of its parents.
Changing this value will send FL DEACTIVATE to the widget if active r() is true.
Currently you cannot deactivate Fl Window widgets.
See Also
activate(), active(), active r()
See Also
callback(), do callback(), Fl::readqueue()
Parameters
in img the new image for the deactivated widget
See Also
callback()
See Also
callback()
void Fl Widget::draw box ( Fl Boxtype t, int X, int Y, int W, int H, Fl Color c ) const
[protected]
Draws a box of type t, of color c at the position X,Y and size W,H.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
Reimplemented in Fl Tree, Fl Table, Fl Input, Fl Window, Fl Browser , Fl Tabs, Fl Text Display, Fl-
Scroll, Fl Spinner, Fl Table Row, Fl Clock, Fl Check Browser, Fl Button, Fl Gl Window, Fl Choice, Fl-
Slider, Fl Menu Button, Fl Group, Fl Value Input, Fl Counter, Fl File Input, Fl Free, Fl Dial, Fl Menu-
Bar, Fl Scrollbar, Fl Text Editor, Fl Positioner, Fl Box, Fl Value Output, Fl Timer, Fl Glut Window,
Fl Adjuster, Fl Secret Input, Fl Light Button, Fl Value Slider, Fl Roller, Fl Return Button, Fl Repeat -
Button, and Fl Tile.
Parameters
in img the new image for the label
See Also
contains()
See Also
label(const char ∗), copy label(const char ∗)
See Also
copy label()
Parameters
t text or label to search for ’&x’ shortcut.
Returns
Unicode (UCS-4) value of shortcut in t or 0.
Note
Internal use only.
See Also
Fl Font
See Also
Fl Font
Returns
the current font size
See Also
Fl Fontsize labelsize()
Returns
the current label type.
See Also
Fl Labeltype
See Also
Fl Labeltype
31.151. FL WIDGET CLASS REFERENCE 845
void Fl Widget::measure label ( int & ww, int & hh ) const [inline]
Sets width ww and height hh accordingly with the label size.
Labels with images will return w() and h() of the image.
This calls fl measure() internally. For more information about the arguments ww and hh and word
wrapping
See Also
fl measure(const char∗, int&, int&, int)
See Also
set output(), clear output()
See Also
Fl Group::add(Fl Widget∗)
See Also
resize(int,int,int,int), size(int,int)
846 CHAPTER 31. CLASS DOCUMENTATION
void Fl Widget::redraw ( )
Schedules the drawing of the widget.
Marks the widget as needing its draw() routine called.
See Also
position(int,int), size(int,int)
Reimplemented in Fl Table, Fl Tree, Fl Help View, Fl Text Display, Fl Window, Fl Browser , Fl-
Input , Fl Input Choice, Fl Spinner, Fl Scroll, Fl Group, Fl Gl Window, Fl Value Input, Fl Overlay -
Window, Fl Double Window, and Fl Tile.
See Also
selection color(Fl Color), color(Fl Color, Fl Color)
Parameters
in a the new selection color
See Also
selection color(), color(Fl Color, Fl Color)
See Also
activate()
See Also
changed(), clear changed()
See Also
output(), clear output()
See Also
visible focus(), clear visible focus(), visible focus(int)
848 CHAPTER 31. CLASS DOCUMENTATION
See Also
position(int,int), resize(int,int,int,int)
Returns
true, if the entered text matches the widget’s’&x’ shortcut, false (0) otherwise.
Note
Internal use only.
int Fl Widget::test shortcut ( const char ∗ t, const bool require alt = false ) [static]
Returns true if the given text t contains the entered ’&x’ shortcut.
This method must only be called in handle() methods or callbacks after a keypress event (usually FL -
KEYDOWN or FL SHORTCUT). The given text t (usually a widget’s label or menu text) is searched for
a ’&x’ shortcut, and if found, this is compared with the entered key value.
Fl::event text() is used to get the entered key value. Fl::event state() is used to get the Alt modifier, if
require alt is true.
Parameters
t text or label to search for ’&x’ shortcut.
require alt if true: match only if Alt key is pressed.
Returns
true, if the entered text matches the ’&x’ shortcut in t false (0) otherwise.
Note
Internal use only.
See Also
tooltip(const char∗), copy tooltip(const char∗)
Parameters
in text New tooltip text (no copy is made)
See Also
copy tooltip(const char∗), tooltip()
See Also
window()
Fl Window ∗ Fl Widget::top window offset ( int & xoff, int & yoff ) const
Finds the x/y offset of the current widget relative to the top-level window.
Parameters
out xoff,yoff Returns the x/y offset
Returns
the top-level window (or NULL for a widget that’s not in any window)
Parameters
in v new user data
See Also
show(), hide(), visible r()
See Also
set visible focus(), clear visible focus(), visible focus()
See Also
visible focus(int), set visible focus(), clear visible focus()
See Also
show(), hide(), visible()
See Also
when(uchar)
Return values
NULL if no window is associated with this widget.
Note
for an Fl Window widget, this returns its parent window (if any), not this window.
See Also
top window()
Returns
the x position relative to the window
Returns
the y position relative to the window
The documentation for this class was generated from the following files:
• Fl Widget.H
• Fl.cxx
• fl boxtype.cxx
• fl labeltype.cxx
• fl shortcut.cxx
• Fl Tooltip.cxx
• Fl Widget.cxx
• Fl Window.cxx
if (...) {
Fl Widget Tracker wp(this); // watch myself
do callback(); // call the callback
// Now we are sure that the widget has not been deleted.
// It is safe to access the widget
• Fl.H
• Fl.cxx
Fl_Widget
Fl_Group
Fl_Window
Classes
• struct shape data type
Data supporting a non-rectangular window shape.
• void size range (int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0)
Sets the allowable range the user can resize this window to.
• unsigned int tooltip window () const
Returns true if this window is a tooltip window.
• void wait for expose ()
Waits for the window to be fully displayed after calling show().
• int x root () const
Gets the x position of the window on the screen.
• const char ∗ xclass () const
Returns the xclass for this window, or a default.
• void xclass (const char ∗c)
Sets the xclass for this window.
• int y root () const
Gets the y position of the window on the screen.
• virtual ∼Fl Window ()
The destructor also deletes all the children.
Protected Attributes
• shape data type ∗ shape data
non-null means the window has a non-rectangular shape
31.153. FL WINDOW CLASS REFERENCE 859
Friends
• class Fl X
See Also
Fl Window(int x, int y, int w, int h, const char∗ title)
See Also
Fl Window(int w, int h, const char ∗title)
860 CHAPTER 31. CLASS DOCUMENTATION
Note
This method is provided to avoid dynamic cast.
See Also
Fl Widget::as group(), Fl Widget::as gl window()
Note
Under some window managers, the sequence of hiding the window and changing its modality will
often cause it to be re-displayed at a different position when it is subsequently shown. This is an
irritating feature but appears to be unavoidable at present. As a result we would advise to use this
method only when absolutely necessary.
See Also
void set modal(), void set non modal()
See Also
cursor(const Fl RGB Image∗, int, int), default cursor()
void Fl Window::cursor ( const Fl RGB Image ∗ image, int hotx, int hoty )
Changes the cursor for this window.
This always calls the system, if you are changing the cursor a lot you may want to keep track of how
you set it in a static variable and call this only if the new cursor is different.
The default cursor will be used if the provided image cannot be used as a cursor.
See Also
cursor(Fl Cursor), default cursor()
int Fl Window::decorated h ( )
Returns the window height including any window title bar and any frame added by the window manager.
Same as h() if applied to a subwindow.
int Fl Window::decorated w ( )
Returns the window width including any frame added by the window manager.
Same as w() if applied to a subwindow.
862 CHAPTER 31. CLASS DOCUMENTATION
See Also
Fl Window::default icons(const Fl RGB Image ∗[ ], int)
Fl Window::icon(const Fl RGB Image ∗)
Fl Window::icons(const Fl RGB Image ∗[ ], int)
void Fl Window::default icons ( const Fl RGB Image ∗ icons[ ], int count ) [static]
Sets the default window icons.
The default icons are used for all windows that don’t have their own icons set before show() is called.
You can change the default icons whenever you want, but this only affects windows that are created (and
shown) after this call.
The given images in icons are copied. You can use a local variable or free the images immediately
after this call.
Parameters
in icons default icons for all windows subsequently created
in count number of images in icons. set to 0 to remove the current default icons
See Also
Fl Window::default icon(const Fl RGB Image ∗)
Fl Window::icon(const Fl RGB Image ∗)
Fl Window::icons(const Fl RGB Image ∗[ ], int)
Parameters
in xc default xclass for all windows subsequently created
See Also
Fl Window::xclass(const char ∗)
0 otherwise
See Also
force position(int)
void Fl Window::fullscreen ( )
Makes the window completely fill one or more screens, without any window manager border visible.
You must use fullscreen off() to undo this.
Note
On some platforms, this can result in the keyboard being grabbed. The window may also be recreated,
meaning hide() and show() will be called.
See Also
void Fl Window::fullscreen screens()
void Fl Window::fullscreen screens ( int top, int bottom, int left, int right )
Sets which screens should be used when this window is in fullscreen mode.
The window will be resized to the top of the screen with index top, the bottom of the screen with index
bottom, etc.
If this method is never called, or if any argument is < 0, then the window will be resized to fill the
screen it is currently on.
See Also
void Fl Window::fullscreen()
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
See Also
Fl Event
Reimplemented from Fl Group.
Reimplemented in Fl Gl Window, and Fl Glut Window.
See Also
Fl Window::default icon(const Fl RGB Image ∗)
Fl Window::default icons(const Fl RGB Image ∗[ ], int)
Fl Window::icons(const Fl RGB Image ∗[ ], int)
void Fl Window::iconize ( )
Iconifies the window.
If you call this when shown() is false it will show() it as an icon. If the window is already iconified this
does nothing.
Call show() to restore the window.
When a window is iconified/restored (either by these calls or by the user) the handle() method is called
with FL HIDE and FL SHOW events and visible() is turned on and off.
There is no way to control what is drawn in the icon except with the string passed to Fl Window-
::xclass(). You should not rely on window managers displaying the icons.
See Also
Fl Window::default icon(const Fl RGB Image ∗)
Fl Window::default icons(const Fl RGB Image ∗[ ], int)
Fl Window::icon(const Fl RGB Image ∗)
Note
Since Fl Tooltip Window is derived from Fl Menu Window, this also clears the menu window()
state.
• With Fl Bitmap or Fl Pixmap, the shaped window covers the image part where bitmap bits equal
one, or where the pixmap is not fully transparent.
• With an Fl RGB Image with an alpha channel (depths 2 or 4), the shaped window covers the image
part that is not fully transparent.
• With an Fl RGB Image of depth 1 (gray-scale) or 3 (RGB), the shaped window covers the non-black
image part.
Platform details:
• On the unix/linux platform, the SHAPE extension of the X server is required. This function does
control the shape of Fl Gl Window instances.
• On the MSWindows platform, this function does nothing with class Fl Gl Window.
• On the Mac platform, OS version 10.4 or above is required. An 8-bit shape-mask is used when img
is an Fl RGB Image: with depths 2 or 4, the image alpha channel becomes the shape mask such that
areas with alpha = 0 are out of the shaped window; with depths 1 or 3, white and black are in and out
of the shaped window, respectively, and other colors give intermediate masking scores. This function
does nothing with class Fl Gl Window.
The window borders and caption created by the window system are turned off by default. They can be
re-enabled by calling Fl Window::border(1).
A usage example is found at example/shapedwindow.cxx.
Version
1.3.3 (and requires compilation with -DFLTK ABI VERSION = 10303)
See Also
void shape(const Fl Image∗ img)
31.153. FL WINDOW CLASS REFERENCE 869
Parameters
argc command-line argument count, usually from main()
argv command-line argument vector, usually from main()
See Also
virtual void Fl Window::show()
void Fl Window::size range ( int minw, int minh, int maxw = 0, int maxh = 0, int dw = 0, int dh =
0, int aspect = 0 ) [inline]
Sets the allowable range the user can resize this window to.
This only works for top-level windows.
• minw and minh are the smallest the window can be. Either value must be greater than 0.
• maxw and maxh are the largest the window can be. If either is equal to the minimum then you
cannot resize in that direction. If either is zero then FLTK picks a maximum size in that direction
such that the window will fill the screen.
• dw and dh are size increments. The window will be constrained to widths of minw + N ∗ dw, where
N is any non-negative integer. If these are less or equal to 1 they are ignored (this is ignored on
WIN32).
870 CHAPTER 31. CLASS DOCUMENTATION
• aspect is a flag that indicates that the window should preserve its aspect ratio. This only works
if both the maximum and minimum have the same aspect ratio (ignored on WIN32 and by many X
window managers).
If this function is not called, FLTK tries to figure out the range from the setting of resizable():
• If resizable() is NULL (this is the default) then the window cannot be resized and the resize border
and max-size control will not be displayed for the window.
• If either dimension of resizable() is less than 100, then that is considered the minimum size. Other-
wise the resizable() has a minimum size of 100.
• If either dimension of resizable() is zero, then that is also the maximum size (so the window cannot
resize in that direction).
It is undefined what happens if the current size does not fit in the constraints passed to size range().
Note that the window will not be responsive until the event loop is started with Fl::run().
If the default xclass has not yet been set, this also sets the default xclass for all windows created subse-
quently.
See Also
Fl Window::default xclass(const char ∗)
Fl_Widget
Fl_Group
Fl_Wizard
872 CHAPTER 31. CLASS DOCUMENTATION
void Fl Wizard::prev ( )
Shows the previous child.
Fl Widget ∗ Fl Wizard::value ( )
Gets the current visible child widget.
• Fl Wizard.H
• Fl Wizard.cxx
31.155. FL XBM IMAGE CLASS REFERENCE 873
Fl_Image
Fl_Bitmap
Fl_XBM_Image
The constructor loads the named XBM file from the given name filename.
The destructor free all memory and server resources that are used by the image.
The documentation for this class was generated from the following files:
• Fl XBM Image.H
• Fl XBM Image.cxx
The documentation for this struct was generated from the following file:
• Fl XColor.H
874 CHAPTER 31. CLASS DOCUMENTATION
Fl_Device
Fl_Graphics_Driver
Fl_Xlib_Graphics_Driver
void Fl Xlib Graphics Driver::draw ( const char ∗ str, int n, int x, int y ) [virtual]
see fl draw(const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
void Fl Xlib Graphics Driver::draw ( int angle, const char ∗ str, int n, int x, int y ) [virtual]
see fl draw(int angle, const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
876 CHAPTER 31. CLASS DOCUMENTATION
void Fl Xlib Graphics Driver::draw ( Fl Pixmap ∗ pxm, int XP, int YP, int WP, int HP, int cx, int
cy ) [virtual]
void Fl Xlib Graphics Driver::draw ( Fl Bitmap ∗ bm, int XP, int YP, int WP, int HP, int cx, int
cy ) [virtual]
void Fl Xlib Graphics Driver::draw ( Fl RGB Image ∗ rgb, int XP, int YP, int WP, int HP, int cx,
int cy ) [virtual]
void Fl Xlib Graphics Driver::draw image ( const uchar ∗ buf, int X, int Y, int W, int H, int D =
3, int L = 0 ) [virtual]
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.
void Fl Xlib Graphics Driver::draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int Y, int
W, int H, int D = 3 ) [virtual]
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.
void Fl Xlib Graphics Driver::draw image mono ( const uchar ∗ buf, int X, int Y, int W, int H,
int D = 1, int L = 0 ) [virtual]
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.
void Fl Xlib Graphics Driver::draw image mono ( Fl Draw Image Cb cb, void ∗ data, int X, int
Y, int W, int H, int D = 1 ) [virtual]
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.
void Fl Xlib Graphics Driver::rtl draw ( const char ∗ str, int n, int x, int y ) [virtual]
see fl rtl draw(const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
void Fl Xlib Graphics Driver::text extents ( const char ∗ t, int n, int & dx, int & dy, int & w, int
& h ) [virtual]
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
Reimplemented from Fl Graphics Driver.
Fl_Image
Fl_Pixmap
Fl_XPM_Image
Public Attributes
• Key Func function
associated function
• int key
the key pressed
• Key Binding ∗ next
next key binding in the list
• int state
the state of key modifiers
Public Attributes
• double a
• double b
• double c
• double d
• double x
• double y
31.161. FL PREFERENCES::NAME CLASS REFERENCE 879
The documentation for this class was generated from the following files:
• Fl Preferences.H
• Fl Preferences.cxx
880 CHAPTER 31. CLASS DOCUMENTATION
Public Attributes
• int height
height in points
• const char ∗ name
format name
• int width
width in points
31.164. FL PREFERENCES::ROOTNODE CLASS REFERENCE 881
• Fl Paged Device.H
The documentation for this class was generated from the following files:
• Fl Preferences.H
• Fl Preferences.cxx
Public Attributes
• int lh
height of shape image
• int lw
width of shape image
• Fl Image ∗ shape
shape image
• Fl Bitmap ∗ todelete
auxiliary bitmap image
• Fl Window.H
Public Attributes
• unsigned attr
• Fl Color color
• Fl Font font
• Fl Fontsize size
• Fl Text Display.H
31.166. FL TEXT DISPLAY::STYLE TABLE ENTRY STRUCT REFERENCE 883
∧
A Command-A Selects all text in the widget.
∧
C Command-C Copy the current selection to
the clipboard.
∧ ∧
I I Insert a tab.
∧ ∧
J J Insert a Line Feed.
(Similar to literal ’Enter’
character)
∧ ∧
L L Insert a Form Feed.
∧ ∧
M M Insert a Carriage Return.
∧
V, Command-V Paste the clipboard.
Shift-Insert (Macs keyboards don’t have
”Insert” keys, but if they did,
Shift-Insert would work)
∧
X, Command-X, Cut.
Shift-Delete Shift-Delete Copy the selection to the
clipboard and delete it. (If
there’s no selection,
Shift-Delete acts like Delete)
∧
Z Command-Z Undo.
This is a single-level undo
mechanism, but all adjacent
deletions and insertions are
concatenated into a single
”undo”. Often this will undo a
lot more than you expected.
File Documentation
Macros
• #define FL IMAGE WITH ALPHA 0x40000000
Version Numbers
FLTK defines some constants to help the programmer to find out, for which FLTK version a program is
compiled.
The following constants are defined:
• #define FL MAJOR VERSION 1
The major release version of this FLTK library.
• #define FL MINOR VERSION 3
The minor release version for this library.
• #define FL PATCH VERSION 3
The patch version for this library.
• #define FL VERSION
The FLTK version number as a double.
This and the following constants define the non-ASCII keys on the
keyboard for FL_KEYBOARD and FL_SHORTCUT events.
Todo FL Button and FL key... constants could be structured better (use an enum or some doxygen
grouping ?)
\sa Fl::event_key() and Fl::get_key(int) (use ascii letters for all other keys):
885
886 CHAPTER 32. FILE DOCUMENTATION
Mouse Buttons
These constants define the button numbers for FL_PUSH and FL_RELEASE events.
See Also
Fl::event button()
Event States
Typedefs
• typedef int Fl Fontsize
Size of a font in pixels.
Enumerations
• enum { FL READ = 1, FL WRITE = 4, FL EXCEPT = 8 }
FD ”when” conditions.
• enum Fl Damage {
FL DAMAGE CHILD = 0x01, FL DAMAGE EXPOSE = 0x02, FL DAMAGE SCROLL = 0x04,
FL DAMAGE OVERLAY = 0x08,
FL DAMAGE USER1 = 0x10, FL DAMAGE USER2 = 0x20, FL DAMAGE ALL = 0x80 }
Damage masks.
32.1. ENUMERATIONS.H FILE REFERENCE 889
• enum Fl Event {
FL NO EVENT = 0, FL PUSH = 1, FL RELEASE = 2, FL ENTER = 3,
FL LEAVE = 4, FL DRAG = 5, FL FOCUS = 6, FL UNFOCUS = 7,
FL KEYDOWN = 8, FL KEYBOARD = 8, FL KEYUP = 9, FL CLOSE = 10,
FL MOVE = 11, FL SHORTCUT = 12, FL DEACTIVATE = 13, FL ACTIVATE = 14,
FL HIDE = 15, FL SHOW = 16, FL PASTE = 17, FL SELECTIONCLEAR = 18,
FL MOUSEWHEEL = 19, FL DND ENTER = 20, FL DND DRAG = 21, FL DND LEAVE = 22,
FL DND RELEASE = 23, FL SCREEN CONFIGURATION CHANGED = 24, FL FULLSCRE-
EN = 25 }
Every time a user moves the mouse pointer, clicks a button, or presses a key, an event is generated and sent
to your application.
• enum Fl Labeltype {
FL NORMAL LABEL = 0, FL NO LABEL, FL SHADOW LABEL, FL ENGRAVED LABEL,
FL EMBOSSED LABEL, FL MULTI LABEL, FL ICON LABEL, FL IMAGE LABEL,
FL FREE LABELTYPE }
The labeltype() method sets the type of the label.
• enum Fl Mode {
FL RGB = 0, FL INDEX = 1, FL SINGLE = 0, FL DOUBLE = 2,
FL ACCUM = 4, FL ALPHA = 8, FL DEPTH = 16, FL STENCIL = 32,
FL RGB8 = 64, FL MULTISAMPLE = 128, FL STEREO = 256, FL FAKE SINGLE = 512 }
visual types and Fl Gl Window::mode() (values match Glut)
When Conditions
• enum Fl When {
FL WHEN NEVER = 0, FL WHEN CHANGED = 1, FL WHEN NOT CHANGED = 2, FL -
WHEN RELEASE = 4,
FL WHEN RELEASE ALWAYS = 6, FL WHEN ENTER KEY = 8, FL WHEN ENTER KE-
Y ALWAYS =10, FL WHEN ENTER KEY CHANGED =11 }
These constants determine when a callback is performed.
Cursors
• enum Fl Cursor {
FL CURSOR DEFAULT = 0, FL CURSOR ARROW = 35, FL CURSOR CROSS = 66, FL C-
URSOR WAIT = 76,
FL CURSOR INSERT = 77, FL CURSOR HAND = 31, FL CURSOR HELP = 47, FL CURS-
OR MOVE = 27,
FL CURSOR NS = 78, FL CURSOR WE = 79, FL CURSOR NWSE = 80, FL CURSOR NE-
SW = 81,
FL CURSOR N = 70, FL CURSOR NE = 69, FL CURSOR E = 49, FL CURSOR SE = 8,
FL CURSOR S = 9, FL CURSOR SW = 7, FL CURSOR W = 36, FL CURSOR NW = 68,
FL CURSOR NONE =255 }
The following constants define the mouse cursors that are available in FLTK.
Variables
• FL EXPORT Fl Fontsize FL NORMAL SIZE
normal font size
890 CHAPTER 32. FILE DOCUMENTATION
Box Types
FLTK standard box types
This enum defines the standard box types included with FLTK.
FL NO BOX means nothing is drawn at all, so whatever is already on the screen remains. The FL ... -
FRAME types only draw their edges, leaving the interior unchanged. The blue color in Figure 1 is the area
that is not drawn by the frame types.
Todo Description of boxtypes is incomplete. See below for the defined enum Fl Boxtype.
See Also
src/Fl get system colors.cxx
Alignment Flags
Flags to control the label alignment.
This controls how the label is displayed next to or inside the widget. The default value is FL ALIGN -
CENTER for most widgets, which centers the label inside the widget.
Flags can be or’d to achieve a combination of alignments.
Outside alignments:
TOP LEFT TOP TOP RIGHT
LEFT TOP+---------------------------------+RIGHT TOP
| |
LEFT| |RIGHT
| |
LEFT BOTTOM+---------------------------------+RIGHT BOTTOM
BOTTOM RIGHT BOTTOM BOTTOM LEFT
Inside alignments:
+---------------------------------+
|TOP LEFT TOP TOP RIGHT|
| |
|LEFT RIGHT|
| |
|BOTTOM RIGHT BOTTOM BOTTOM LEFT|
+---------------------------------+
See Also
FL ALIGN CENTER, etc.
Font Numbers
The following constants define the standard FLTK fonts:
Colors
The Fl Color type holds an FLTK color value.
Colors are either 8-bit indexes into a virtual colormap or 24-bit RGB color values. (See Colors for the
default FLTK colormap)
Color indices occupy the lower 8 bits of the value, while RGB colors occupy the upper 24 bits, for a
byte organization of RGBI.
Fl Color => 0xrrggbbii
| | | |
| | | +--- index between 0 and 255
| | +----- blue color component (8 bit)
| +------- green component (8 bit)
+--------- red component (8 bit)
32.1. ENUMERATIONS.H FILE REFERENCE 895
A color can have either an index or an rgb value. Colors with rgb set and an index >0 are reserved for
special use.
Returns the weighted average color between the two given colors.
• Fl Color fl lighter (Fl Color c)
Returns a lighter version of the specified color.
• Fl Color fl darker (Fl Color c)
Returns a darker version of the specified color.
• Fl Color fl rgb color (uchar r, uchar g, uchar b)
Returns the 24-bit color value closest to r, g, b.
• Fl Color fl rgb color (uchar g)
Returns the 24-bit color value closest to g (grayscale).
• Fl Color fl gray ramp (int i)
Returns a gray color value from black (i == 0) to white (i == FL NUM GRAY - 1).
• Fl Color fl color cube (int r, int g, int b)
Returns a color out of the color cube.
See Also
FL VERSION
#define FL VERSION
Value:
enum Fl Boxtype
Enumerator
FL NO BOX nothing is drawn at all, this box is invisible
FL FLAT BOX a flat box
FL UP BOX see figure 1
FL DOWN BOX see figure 1
FL UP FRAME see figure 1
FL DOWN FRAME see figure 1
FL THIN UP BOX see figure 1
FL THIN DOWN BOX see figure 1
FL THIN UP FRAME see figure 1
FL THIN DOWN FRAME see figure 1
FL ENGRAVED BOX see figure 1
FL EMBOSSED BOX see figure 1
FL ENGRAVED FRAME see figure 1
FL EMBOSSED FRAME see figure 1
FL BORDER BOX see figure 1
FL SHADOW BOX see figure 1
FL BORDER FRAME see figure 1
FL SHADOW FRAME see figure 1
FL ROUNDED BOX see figure 1
FL RSHADOW BOX see figure 1
FL ROUNDED FRAME see figure 1
FL RFLAT BOX see figure 1
898 CHAPTER 32. FILE DOCUMENTATION
enum Fl Cursor
The following constants define the mouse cursors that are available in FLTK.
Cursors are provided by the system when available, or bitmaps built into FLTK as a fallback.
Enumerator
FL CURSOR DEFAULT the default cursor, usually an arrow.
FL CURSOR ARROW an arrow pointer.
FL CURSOR CROSS crosshair.
FL CURSOR WAIT busy indicator (e.g. hourglass).
FL CURSOR INSERT I-beam.
FL CURSOR HAND pointing hand.
FL CURSOR HELP question mark pointer.
FL CURSOR MOVE 4-pointed arrow or hand.
FL CURSOR NS up/down resize.
FL CURSOR WE left/right resize.
FL CURSOR NWSE diagonal resize.
FL CURSOR NESW diagonal resize.
FL CURSOR N upwards resize.
FL CURSOR NE upwards, right resize.
FL CURSOR E rightwards resize.
FL CURSOR SE downwards, right resize.
FL CURSOR S downwards resize.
FL CURSOR SW downwards, left resize.
FL CURSOR W leftwards resize.
FL CURSOR NW upwards, left resize.
FL CURSOR NONE invisible.
enum Fl Damage
Damage masks.
Enumerator
FL DAMAGE CHILD A child needs to be redrawn.
FL DAMAGE EXPOSE The window was exposed.
FL DAMAGE SCROLL The Fl Scroll widget was scrolled.
FL DAMAGE OVERLAY The overlay planes need to be redrawn.
FL DAMAGE USER1 First user-defined damage bit.
FL DAMAGE USER2 Second user-defined damage bit.
FL DAMAGE ALL Everything needs to be redrawn.
900 CHAPTER 32. FILE DOCUMENTATION
enum Fl Event
Every time a user moves the mouse pointer, clicks a button, or presses a key, an event is generated and sent
to your application.
Events can also come from other programs like the window manager.
Events are identified by the integer argument passed to the Fl Widget::handle() virtual method. Other
information about the most recent event is stored in static locations and acquired by calling the Fl::event ∗()
methods. This static information remains valid until the next event is read from the window system, so it
is ok to look at it outside of the handle() method.
See Also
Fl::event text(), Fl::event key(), class Fl::
Enumerator
FL NO EVENT No event.
FL PUSH A mouse button has gone down with the mouse pointing at this widget. You can find out
what button by calling Fl::event button(). You find out the mouse position by calling Fl::event x()
and Fl::event y().
A widget indicates that it ”wants” the mouse click by returning non-zero from its Fl Widget-
::handle() method. It will then become the Fl::pushed() widget and will get FL DRAG and the
matching FL RELEASE events. If Fl Widget::handle() returns zero then FLTK will try sending
the FL PUSH to another widget.
FL RELEASE A mouse button has been released. You can find out what button by calling Fl::event-
button().
In order to receive the FL RELEASE event, the widget must return non-zero when handling
FL PUSH.
FL ENTER The mouse has been moved to point at this widget. This can be used for highlighting
feedback. If a widget wants to highlight or otherwise track the mouse, it indicates this by return-
ing non-zero from its handle() method. It then becomes the Fl::belowmouse() widget and will
receive FL MOVE and FL LEAVE events.
FL LEAVE The mouse has moved out of the widget. In order to receive the FL LEAVE event, the
widget must return non-zero when handling FL ENTER.
FL DRAG The mouse has moved with a button held down. The current button state is in Fl::event -
state(). The mouse position is in Fl::event x() and Fl::event y().
In order to receive FL DRAG events, the widget must return non-zero when handling FL PUSH.
FL FOCUS This indicates an attempt to give a widget the keyboard focus. If a widget wants the
focus, it should change itself to display the fact that it has the focus, and return non-zero from its
handle() method. It then becomes the Fl::focus() widget and gets FL KEYDOWN, FL KEYUP,
and FL UNFOCUS events.
The focus will change either because the window manager changed which window gets the focus,
or because the user tried to navigate using tab, arrows, or other keys. You can check Fl::event-
key() to figure out why it moved. For navigation it will be the key pressed and for interaction
with the window manager it will be zero.
FL UNFOCUS This event is sent to the previous Fl::focus() widget when another widget gets the
focus or the window loses focus.
FL KEYDOWN A key was pressed (FL KEYDOWN) or released (FL KEYUP). Fl KEYBOARD
is a synonym for FL KEYDOWN. The key can be found in Fl::event key(). The text that the key
should insert can be found with Fl::event text() and its length is in Fl::event length(). If you use
the key handle() should return 1. If you return zero then FLTK assumes you ignored the key and
32.1. ENUMERATIONS.H FILE REFERENCE 901
will then attempt to send it to a parent widget. If none of them want it, it will change the event
into a FL SHORTCUT event.
To receive FL KEYBOARD events you must also respond to the FL FOCUS and FL UNFOCUS
events.
If you are writing a text-editing widget you may also want to call the Fl::compose() function to
translate individual keystrokes into non-ASCII characters.
FL KEYUP events are sent to the widget that currently has focus. This is not necessarily the same
widget that received the corresponding FL KEYDOWN event because focus may have changed
between events.
FL KEYBOARD Equivalent to FL KEYDOWN.
See Also
FL KEYDOWN
FL KEYUP Key release event.
See Also
FL KEYDOWN
FL CLOSE The user clicked the close button of a window. This event is used internally only to trig-
ger the callback of Fl Window derived classed. The default callback closes the window calling
Fl Window::hide().
FL MOVE The mouse has moved without any mouse buttons held down. This event is sent to the
Fl::belowmouse() widget.
In order to receive FL MOVE events, the widget must return non-zero when handling FL ENT-
ER.
FL SHORTCUT If the Fl::focus() widget is zero or ignores an FL KEYBOARD event then FLTK
tries sending this event to every widget it can, until one of them returns non-zero. FL SHORT-
CUT is first sent to the Fl::belowmouse() widget, then its parents and siblings, and eventually to
every widget in the window, trying to find an object that returns non-zero. FLTK tries really hard
to not to ignore any keystrokes!
You can also make ”global” shortcuts by using Fl::add handler(). A global shortcut will work no
matter what windows are displayed or which one has the focus.
FL DEACTIVATE This widget is no longer active, due to Fl Widget::deactivate() being called on it
or one of its parents. Fl Widget::active() may still be true after this, the widget is only active if
Fl Widget::active() is true on it and all its parents (use Fl Widget::active r() to check this).
FL ACTIVATE This widget is now active, due to Fl Widget::activate() being called on it or one of
its parents.
FL HIDE This widget is no longer visible, due to Fl Widget::hide() being called on it or one of its
parents, or due to a parent window being minimized. Fl Widget::visible() may still be true after
this, but the widget is visible only if visible() is true for it and all its parents (use Fl Widget-
::visible r() to check this).
FL SHOW This widget is visible again, due to Fl Widget::show() being called on it or one of its
parents, or due to a parent window being restored. Child Fl Windows respond to this by actually
creating the window if not done already, so if you subclass a window, be sure to pass FL SHOW
to the base class Fl Widget::handle() method!
FL PASTE You should get this event some time after you call Fl::paste(). The contents of Fl::event-
text() is the text to insert and the number of characters is in Fl::event length().
FL SELECTIONCLEAR The Fl::selection owner() will get this event before the selection is moved
to another widget. This indicates that some other widget or program has claimed the selection.
Motif programs used this to clear the selection indication. Most modern programs ignore this.
902 CHAPTER 32. FILE DOCUMENTATION
FL MOUSEWHEEL The user has moved the mouse wheel. The Fl::event dx() and Fl::event dy()
methods can be used to find the amount to scroll horizontally and vertically.
FL DND ENTER The mouse has been moved to point at this widget. A widget that is interested
in receiving drag’n’drop data must return 1 to receive FL DND DRAG, FL DND LEAVE and
FL DND RELEASE events.
FL DND DRAG The mouse has been moved inside a widget while dragging data. A widget that is
interested in receiving drag’n’drop data should indicate the possible drop position.
FL DND LEAVE The mouse has moved out of the widget.
FL DND RELEASE The user has released the mouse button dropping data into the widget. If the
widget returns 1, it will receive the data in the immediately following FL PASTE event.
FL SCREEN CONFIGURATION CHANGED The screen configuration (number, positions) was
changed. Use Fl::add handler() to be notified of this event.
FL FULLSCREEN The fullscreen state of the window has changed.
enum Fl Labeltype
The labeltype() method sets the type of the label.
The following standard label types are included:
Todo The doxygen comments are incomplete, and some labeltypes are starting with an underscore. Also,
there are three external functions undocumented (yet):
• fl define FL SHADOW LABEL()
• fl define FL ENGRAVED LABEL()
• fl define FL EMBOSSED LABEL()
Enumerator
FL NORMAL LABEL draws the text (0)
FL NO LABEL does nothing
FL SHADOW LABEL draws a drop shadow under the text
FL ENGRAVED LABEL draws edges as though the text is engraved
FL EMBOSSED LABEL draws edges as though the text is raised
FL MULTI LABEL ?
FL ICON LABEL draws the icon associated with the text
FL IMAGE LABEL ?
FL FREE LABELTYPE first free labeltype to use for creating own labeltypes
enum Fl When
These constants determine when a callback is performed.
See Also
Fl Widget::when();
Todo doxygen comments for values are incomplete and maybe wrong or unclear
Enumerator
FL WHEN NEVER Never call the callback.
32.1. ENUMERATIONS.H FILE REFERENCE 903
FL WHEN CHANGED Do the callback only when the widget value changes.
FL WHEN NOT CHANGED Do the callback whenever the user interacts with the widget.
FL WHEN RELEASE Do the callback when the button or key is released and the value changes.
FL WHEN RELEASE ALWAYS Do the callback when the button or key is released, even if the
value doesn’t change.
FL WHEN ENTER KEY Do the callback when the user presses the ENTER key and the value
changes.
FL WHEN ENTER KEY ALWAYS Do the callback when the user presses the ENTER key, even if
the value doesn’t change.
FL WHEN ENTER KEY CHANGED ?
Macros
• #define fl dirent h cyclic include
• #define FL FILENAME H
• #define FL PATH MAX 2048
all path buffers should use this length
Typedefs
• typedef int( Fl File Sort F )(struct dirent ∗∗, struct dirent ∗∗)
File sorting function.
Functions
• FL EXPORT void fl decode uri (char ∗uri)
Decodes a URL-encoded string.
• FL EXPORT int fl filename absolute (char ∗to, int tolen, const char ∗from)
Makes a filename absolute from a relative filename.
• FL EXPORT int fl filename expand (char ∗to, int tolen, const char ∗from)
Expands a filename containing shell variables and tilde (∼).
• FL EXPORT const char ∗ fl filename ext (const char ∗buf)
Gets the extensions of a filename.
• FL EXPORT void fl filename free list (struct dirent ∗∗∗l, int n)
Free the list of filenames that is generated by fl filename list().
• FL EXPORT int fl filename isdir (const char ∗name)
Determines if a file exists and is a directory from its filename.
906 CHAPTER 32. FILE DOCUMENTATION
• FL EXPORT int fl filename list (const char ∗d, struct dirent ∗∗∗l, Fl File Sort F ∗s=fl numericsort)
Portable and const-correct wrapper for the scandir() function.
• FL EXPORT int fl filename match (const char ∗name, const char ∗pattern)
Checks if a string s matches a pattern p.
• FL EXPORT const char ∗ fl filename name (const char ∗filename)
Gets the file name from a path.
• FL EXPORT int fl filename relative (char ∗to, int tolen, const char ∗from)
Makes a filename relative to the current working directory.
• FL EXPORT char ∗ fl filename setext (char ∗to, int tolen, const char ∗ext)
Replaces the extension in buf of max.
• FL EXPORT int fl open uri (const char ∗uri, char ∗msg, int msglen)
Opens the specified Uniform Resource Identifier (URI).
Classes
• class Fl
The Fl is the FLTK global (static) class containing state information and global methods for the current
application.
• class Fl Widget Tracker
This class should be used to control safe widget deletion.
Macros
• #define Fl Object Fl Widget
for back compatibility - use Fl Widget!
• #define FL SOCKET int
Typedefs
• typedef void(∗ Fl Abort Handler )(const char ∗format,...)
Signature of set abort functions passed as parameters.
• typedef int(∗ Fl Args Handler )(int argc, char ∗∗argv, int &i)
Signature of args functions passed as parameters.
• typedef void(∗ Fl Atclose Handler )(Fl Window ∗window, void ∗data)
Signature of set atclose functions passed as parameters.
• typedef void(∗ Fl Awake Handler )(void ∗data)
Signature of some wakeup callback functions passed as parameters.
32.4. FL ARC.CXX FILE REFERENCE 907
• typedef void( Fl Box Draw F )(int x, int y, int w, int h, Fl Color color)
Signature of some box drawing functions passed as parameters.
• typedef void(∗ Fl Clipboard Notify Handler )(int source, void ∗data)
Signature of add clipboard notify functions passed as parameters.
• typedef int(∗ Fl Event Dispatch )(int event, Fl Window ∗w)
Signature of event dispatch functions passed as parameters.
• typedef int(∗ Fl Event Handler )(int event)
Signature of add handler functions passed as parameters.
• typedef void(∗ Fl FD Handler )(FL SOCKET fd, void ∗data)
Signature of add fd functions passed as parameters.
• typedef void(∗ Fl Idle Handler )(void ∗data)
Signature of add idle callback functions passed as parameters.
• typedef void( Fl Label Draw F )(const Fl Label ∗label, int x, int y, int w, int h, Fl Align align)
Signature of some label drawing functions passed as parameters.
• typedef void( Fl Label Measure F )(const Fl Label ∗label, int &width, int &height)
Signature of some label measurement functions passed as parameters.
• typedef void(∗ Fl Old Idle Handler )()
Signature of set idle callback functions passed as parameters.
• typedef int(∗ Fl System Handler )(void ∗event, void ∗data)
Signature of add system handler functions passed as parameters.
• typedef void(∗ Fl Timeout Handler )(void ∗data)
Signature of some timeout callback functions passed as parameters.
Functions
• void fl alert (const char ∗fmt,...)
Shows an alert message dialog box.
• int fl ask (const char ∗fmt,...)
Shows a dialog displaying the fmt message, this dialog features 2 yes/no buttons.
• void fl beep (int type)
Emits a system beep message.
• int fl choice (const char ∗fmt, const char ∗b0, const char ∗b1, const char ∗b2,...)
Shows a dialog displaying the fmt message, this dialog features up to 3 customizable choice buttons.
• const char ∗ fl input (const char ∗fmt, const char ∗defstr,...)
Shows an input dialog displaying the fmt message.
• void fl message (const char ∗fmt,...)
Shows an information message dialog box.
• void fl message hotspot (int enable)
Sets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
• int fl message hotspot (void)
Gets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
• Fl Widget ∗ fl message icon ()
Gets the Fl Box icon container of the current default dialog used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password()
• void fl message title (const char ∗title)
Sets the title of the dialog window used in many common dialogs.
• void fl message title default (const char ∗title)
Sets the default title of the dialog window used in many common dialogs.
• const char ∗ fl password (const char ∗fmt, const char ∗defstr,...)
Shows an input dialog displaying the fmt message.
32.7. FL ASK.H FILE REFERENCE 909
Variables
• const char ∗ fl cancel = ”Cancel”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl close = ”Close”
string pointer used in common dialogs, you can change it to another language
• Fl Font fl message font = FL HELVETICA
• Fl Fontsize fl message size = -1
• const char ∗ fl no = ”No”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl ok = ”OK”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl yes = ”Yes”
string pointer used in common dialogs, you can change it to another language
Macros
• #define fl attr(x)
Enumerations
• enum Fl Beep {
FL BEEP DEFAULT = 0, FL BEEP MESSAGE, FL BEEP ERROR, FL BEEP QUESTION,
FL BEEP PASSWORD, FL BEEP NOTIFICATION }
Different system beeps available.
Functions
• FL EXPORT void FL EXPORT void fl alert (const char ∗,...) fl attr(( format ( printf
• FL EXPORT void FL EXPORT void
FL EXPORT int fl ask (const char ∗,...) fl attr(( format ( printf
• FL EXPORT void fl beep (int type=FL BEEP DEFAULT)
Emits a system beep message.
• FL EXPORT int fl choice (const char ∗q, const char ∗b0, const char ∗b1, const char ∗b2,...) fl -
attr(( format ( printf
• FL EXPORT int FL EXPORT const
char ∗ fl input (const char ∗label, const char ∗deflt=0,...) fl attr(( format ( printf
• FL EXPORT void fl message (const char ∗,...) fl attr(( format ( printf
• void fl message font (Fl Font f, Fl Fontsize s)
• FL EXPORT void fl message hotspot (int enable)
910 CHAPTER 32. FILE DOCUMENTATION
Sets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
• FL EXPORT int fl message hotspot (void)
Gets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
• FL EXPORT int FL EXPORT const
char FL EXPORT const char
FL EXPORT Fl Widget ∗ fl message icon ()
Gets the Fl Box icon container of the current default dialog used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password()
• FL EXPORT void fl message title (const char ∗title)
Sets the title of the dialog window used in many common dialogs.
• FL EXPORT void fl message title default (const char ∗title)
Sets the default title of the dialog window used in many common dialogs.
• FL EXPORT int FL EXPORT const
char FL EXPORT const char ∗ fl password (const char ∗label, const char ∗deflt=0,...) fl attr(( -
format ( printf
Variables
• FL EXPORT void FL EXPORT void
FL EXPORT int deprecated
• FL EXPORT const char ∗ fl cancel
string pointer used in common dialogs, you can change it to another language
• FL EXPORT const char ∗ fl close
string pointer used in common dialogs, you can change it to another language
• FL EXPORT Fl Font fl message font
• FL EXPORT Fl Fontsize fl message size
• FL EXPORT const char ∗ fl no
string pointer used in common dialogs, you can change it to another language
• FL EXPORT const char ∗ fl ok
string pointer used in common dialogs, you can change it to another language
• FL EXPORT const char ∗ fl yes
string pointer used in common dialogs, you can change it to another language
See Also
fl beep(int)
Enumerator
FL BEEP DEFAULT Default beep.
FL BEEP MESSAGE Message beep.
FL BEEP ERROR Error beep.
FL BEEP QUESTION Question beep.
FL BEEP PASSWORD Password beep.
FL BEEP NOTIFICATION Notification beep.
Macros
• #define D1 BORDER WIDTH
• #define D2 (BORDER WIDTH+BORDER WIDTH)
• #define fl border box fl rectbound
allow consistent naming
Functions
• void fl border frame (int x, int y, int w, int h, Fl Color c)
Draws a frame of type FL BORDER FRAME.
• void fl down box (int x, int y, int w, int h, Fl Color c)
Draws a box of type FL DOWN BOX.
• void fl down frame (int x, int y, int w, int h, Fl Color)
Draws a frame of type FL DOWN FRAME.
• void fl draw box (Fl Boxtype t, int x, int y, int w, int h, Fl Color c)
Draws a box using given type, position, size and color.
• void fl embossed box (int x, int y, int w, int h, Fl Color c)
Draws a box of type FL EMBOSSED BOX.
• void fl embossed frame (int x, int y, int w, int h, Fl Color)
Draws a frame of type FL EMBOSSED FRAME.
• void fl engraved box (int x, int y, int w, int h, Fl Color c)
Draws a box of type FL ENGRAVED BOX.
• void fl engraved frame (int x, int y, int w, int h, Fl Color)
Draws a frame of type FL ENGRAVED FRAME.
• void fl frame (const char ∗s, int x, int y, int w, int h)
Draws a series of line segments around the given box.
• void fl frame2 (const char ∗s, int x, int y, int w, int h)
912 CHAPTER 32. FILE DOCUMENTATION
Macros
• #define fl overlay 0
HAVE OVERLAY determines whether fl overlay is variable or defined as 0.
Functions
• Fl Color fl color average (Fl Color color1, Fl Color color2, float weight)
Returns the weighted average color between the two given colors.
• Fl Color fl contrast (Fl Color fg, Fl Color bg)
Returns a color that contrasts with the background color.
• Fl Color fl inactive (Fl Color c)
Returns the inactive, dimmed version of the given color.
• ulong fl xpixel (uchar r, uchar g, uchar b)
Returns the X pixel number used to draw the given rgb color.
• ulong fl xpixel (Fl Color i)
Returns the X pixel number used to draw the given FLTK color index.
Variables
• uchar fl bluemask
color mask used in current color map handling
• int fl blueshift
color shift used in current color map handling
• int fl extrashift
color shift used in current color map handling
• uchar fl greenmask
color mask used in current color map handling
• int fl greenshift
color shift used in current color map handling
• uchar fl redmask
color mask used in current color map handling
• int fl redshift
color shift used in current color map handling
• Fl XColor fl xmap [1][256]
HAVE OVERLAY determines whether fl xmap is one or two planes.
Classes
• class Fl Color Chooser
The Fl Color Chooser widget provides a standard RGB color chooser.
Variables
• XIC fl xim ic
Classes
• class Fl Device
All graphical output devices and all graphics systems.
• class Fl Device Plugin
This plugin socket allows the integration of new device drivers for special window or screen types.
• class Fl Display Device
A display to which the computer can draw.
• class Fl GDI Graphics Driver
The MSWindows-specific graphics class.
• class Fl GDI Printer Graphics Driver
The graphics driver used when printing on MSWindows.
• class Fl Graphics Driver
A virtual class subclassed for each graphics driver FLTK uses.
• class Fl Quartz Graphics Driver
The Mac OS X-specific graphics class.
• class Fl Surface Device
A surface that’s susceptible to receive graphical output.
• class Fl Xlib Graphics Driver
The Xlib-specific graphics class.
• struct Fl Graphics Driver::matrix
A 2D coordinate transformation matrix.
Macros
• #define FL MATRIX STACK SIZE 32
• #define FL REGION STACK SIZE 10
• #define XPOINT XPoint
Typedefs
• typedef short COORD T
• typedef void(∗ Fl Draw Image Cb )(void ∗data, int x, int y, int w, uchar ∗buf)
signature of image generation callback function.
Variables
• FL EXPORT Fl Graphics Driver ∗ fl graphics driver
Points to the driver that currently receives all graphics requests.
Parameters
in data user data passed to function
in x,y,w position and width of scan line in image
out buf buffer for generated image data. You must copy w pixels from scanline
y, starting at pixel x to this buffer.
Functions
• void fl begin offscreen (Fl Offscreen ctx)
Send all subsequent drawing commands to this offscreen buffer.
• char fl can do alpha blending ()
Checks whether platform supports true alpha blending for RGBA images.
• void fl copy offscreen (int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy)
Copy a rectangular area of the given offscreen buffer into the current drawing destination.
• Fl Offscreen fl create offscreen (int w, int h)
Creation of an offscreen graphics buffer.
• void fl delete offscreen (Fl Offscreen ctx)
Deletion of an offscreen graphics buffer.
• void fl end offscreen ()
Quit sending drawing commands to the current offscreen buffer.
Variables
• const int stack max = 16
Macros
• #define fl clip fl push clip
Intersects the current clip region with a rectangle and pushes this new region onto the stack (deprecated).
Enumerations
• enum {
FL SOLID = 0, FL DASH = 1, FL DOT = 2, FL DASHDOT = 3,
FL DASHDOTDOT = 4, FL CAP FLAT = 0x100, FL CAP ROUND = 0x200, FL CAP SQUARE
= 0x300,
FL JOIN MITER = 0x1000, FL JOIN ROUND = 0x2000, FL JOIN BEVEL = 0x3000 }
Functions
• FL EXPORT int fl add symbol (const char ∗name, void(∗drawit)(Fl Color), int scalable)
Adds a symbol to the system.
• void fl arc (int x, int y, int w, int h, double a1, double a2)
Draw ellipse sections using integer coordinates.
• void fl arc (double x, double y, double r, double start, double end)
Adds a series of points to the current path on the arc of a circle.
• void fl begin complex polygon ()
Starts drawing a complex filled polygon.
• void fl begin line ()
Starts drawing a list of lines.
• void fl begin loop ()
Starts drawing a closed sequence of lines.
• void fl begin points ()
Starts drawing a list of points.
• void fl begin polygon ()
Starts drawing a convex filled polygon.
• FL EXPORT char fl can do alpha blending ()
Checks whether platform supports true alpha blending for RGBA images.
• FL EXPORT void fl chord (int x, int y, int w, int h, double a1, double a2)
fl chord declaration is a place holder - the function does not yet exist
• void fl circle (double x, double y, double r)
fl circle() is equivalent to fl arc(x,y,r,0,360), but may be faster.
• int fl clip box (int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
Intersects the rectangle with the current clip region and returns the bounding box of the result.
• void fl clip region (Fl Region r)
Replaces the top of the clipping stack with a clipping region of any shape.
• Fl Region fl clip region ()
Returns the current clipping region.
• void fl color (Fl Color c)
Sets the color for all subsequent drawing operations.
• void fl color (int c)
for back compatibility - use fl color(Fl Color c) instead
• void fl color (uchar r, uchar g, uchar b)
Sets the color for all subsequent drawing operations.
918 CHAPTER 32. FILE DOCUMENTATION
• Fl Color fl color ()
Returns the last fl color() that was set.
• FL EXPORT void fl cursor (Fl Cursor)
Sets the cursor for the current window to the specified shape and colors.
• FL EXPORT void fl cursor (Fl Cursor, Fl Color fg, Fl Color bg=FL WHITE)
• void fl curve (double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3,
double Y3)
Adds a series of points on a Bezier curve to the path.
• int fl descent ()
Returns the recommended distance above the bottom of a fl height() tall box to draw the text at so it looks
centered vertically in that box.
• FL EXPORT void fl draw (const char ∗str, int x, int y)
Draws a nul-terminated UTF-8 string starting at the given x, y location.
• FL EXPORT void fl draw (int angle, const char ∗str, int x, int y)
Draws a nul-terminated UTF-8 string starting at the given x, y location and rotating angle degrees
counter-clockwise.
• void fl draw (const char ∗str, int n, int x, int y)
Draws starting at the given x, y location a UTF-8 string of length n bytes.
• void fl draw (int angle, const char ∗str, int n, int x, int y)
Draws at the given x, y location a UTF-8 string of length n bytes rotating angle degrees counter-
clockwise.
• FL EXPORT void fl draw (const char ∗str, int x, int y, int w, int h, Fl Align align, Fl Image ∗img=0,
int draw symbols=1)
Fancy string drawing function which is used to draw all the labels.
• FL EXPORT void fl draw (const char ∗str, int x, int y, int w, int h, Fl Align align, void(∗callthis)(const
char ∗, int, int, int), Fl Image ∗img=0, int draw symbols=1)
The same as fl draw(const char∗,int,int,int,int,Fl Align,Fl Image∗,int) with the addition of the callthis
parameter, which is a pointer to a text drawing function such as fl draw(const char∗, int, int, int) to do the
real work.
• FL EXPORT void fl draw box (Fl Boxtype, int x, int y, int w, int h, Fl Color)
Draws a box using given type, position, size and color.
• void fl draw image (const uchar ∗buf, int X, int Y, int W, int H, int D=3, int L=0)
Draws an 8-bit per color RGB or luminance image.
• void fl draw image (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=3)
Draws an image using a callback function to generate image data.
• void fl draw image mono (const uchar ∗buf, int X, int Y, int W, int H, int D=1, int L=0)
Draws a gray-scale (1 channel) image.
• void fl draw image mono (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=1)
Draws a gray-scale image using a callback function to generate image data.
• FL EXPORT int fl draw pixmap (char ∗const ∗data, int x, int y, Fl Color=FL GRAY)
Draw XPM image data, with the top-left corner at the given position.
• FL EXPORT int fl draw pixmap (const char ∗const ∗cdata, int x, int y, Fl Color=FL GRAY)
Draw XPM image data, with the top-left corner at the given position.
• FL EXPORT int fl draw symbol (const char ∗label, int x, int y, int w, int h, Fl Color)
Draw the named symbol in the given rectangle using the given color.
• void fl end complex polygon ()
Ends complex filled polygon, and draws.
• void fl end line ()
32.15. FL DRAW.H FILE REFERENCE 919
Draws a UTF-8 string of length n bytes right to left starting at the given x, y location.
• void fl scale (double x, double y)
Concatenates scaling transformation onto the current one.
• void fl scale (double x)
Concatenates scaling transformation onto the current one.
• FL EXPORT void fl scroll (int X, int Y, int W, int H, int dx, int dy, void(∗draw area)(void ∗, int, int,
int, int), void ∗data)
Scroll a rectangle and draw the newly exposed portions.
• FL EXPORT void fl set spot (int font, int size, int X, int Y, int W, int H, Fl Window ∗win=0)
• FL EXPORT void fl set status (int X, int Y, int W, int H)
• FL EXPORT const char ∗ fl shortcut label (unsigned int shortcut)
Get a human-readable string from a shortcut value.
• FL EXPORT const char ∗ fl shortcut label (unsigned int shortcut, const char ∗∗eom)
Get a human-readable string from a shortcut value.
• Fl Fontsize fl size ()
Returns the size set by the most recent call to fl font().
• FL EXPORT void fl text extents (const char ∗, int &dx, int &dy, int &w, int &h)
Determines the minimum pixel dimensions of a nul-terminated string.
• void fl text extents (const char ∗t, int n, int &dx, int &dy, int &w, int &h)
Determines the minimum pixel dimensions of a sequence of n characters.
• double fl transform dx (double x, double y)
Transforms distance using current transformation matrix.
• double fl transform dy (double x, double y)
Transforms distance using current transformation matrix.
• double fl transform x (double x, double y)
Transforms coordinate using the current transformation matrix.
• double fl transform y (double x, double y)
Transforms coordinate using the current transformation matrix.
• void fl transformed vertex (double xf, double yf)
Adds coordinate pair to the vertex list without further transformations.
• void fl translate (double x, double y)
Concatenates translation transformation onto the current one.
• void fl vertex (double x, double y)
Adds a single vertex to the current path.
• FL EXPORT double fl width (const char ∗txt)
Returns the typographical width of a nul-terminated string using the current font face and size.
• double fl width (const char ∗txt, int n)
Returns the typographical width of a sequence of n characters using the current font face and size.
• double fl width (unsigned int c)
Returns the typographical width of a single character using the current font face and size.
• void fl xyline (int x, int y, int x1)
Draws a horizontal line from (x,y) to (x1,y)
• void fl xyline (int x, int y, int x1, int y2)
Draws a horizontal line from (x,y) to (x1,y), then vertical from (x1,y) to (x1,y2)
• void fl xyline (int x, int y, int x1, int y2, int x3)
Draws a horizontal line from (x,y) to (x1,y), then a vertical from (x1,y) to (x1,y2) and then another horizontal
from (x1,y2) to (x3,y2)
922 CHAPTER 32. FILE DOCUMENTATION
Variables
• FL EXPORT char fl draw shortcut
Classes
• class Fl Image
Fl Image is the base class used for caching and drawing all kinds of images in FLTK.
• class Fl RGB Image
The Fl RGB Image class supports caching and drawing of full-color images with 1 to 4 channels of color
information.
Enumerations
• enum Fl RGB Scaling { FL RGB SCALING NEAREST = 0, FL RGB SCALING BILINEAR }
The scaling algorithm to use for RGB images.
Enumerator
FL RGB SCALING NEAREST default RGB image scaling algorithm
FL RGB SCALING BILINEAR more accurate, but slower RGB image scaling algorithm
32.17. FL LINE STYLE.CXX FILE REFERENCE 923
Variables
• int fl line width = 0
Classes
• class Fl FLTK File Chooser
• class Fl GTK File Chooser
• class Fl Native File Chooser
This class lets an FLTK application easily and consistently access the operating system’s native file chooser.
Classes
• class Fl Paged Device
Represents page-structured drawing surfaces.
• struct Fl Paged Device::page format
width, height and name of a page format
Macros
• #define NO PAGE FORMATS 30 /∗ MSVC6 compilation fix ∗/
Number of elements in enum Page Format.
Classes
• class Fl PostScript File Device
To send graphical output to a PostScript file.
• class Fl PostScript Graphics Driver
Typedefs
• typedef int( Fl PostScript Close Command )(FILE ∗)
PostScript graphical backend.
Classes
• class Fl PostScript Printer
Print support under Unix/Linux.
• class Fl Printer
32.23. FL RECT.CXX FILE REFERENCE 927
Functions
• Fl Region XRectangleRegion (int x, int y, int w, int h)
Variables
• int fl line width
Classes
• class Fl Shared Image
This class supports caching, loading, and drawing of image files.
Typedefs
• typedef Fl Image ∗(∗ Fl Shared Handler )(const char ∗name, uchar ∗header, int headerlen)
Functions
• FL EXPORT void fl register images ()
Register the image formats.
928 CHAPTER 32. FILE DOCUMENTATION
Functions
• FL EXPORT Fl Color fl show colormap (Fl Color oldcol)
Pops up a window to let the user pick a colormap entry.
Classes
• class Fl Tree
Tree widget.
Enumerations
• enum Fl Tree Reason {
FL TREE REASON NONE =0, FL TREE REASON SELECTED, FL TREE REASON DESEL-
ECTED, FL TREE REASON OPENED,
FL TREE REASON CLOSED, FL TREE REASON DRAGGED }
The reason the callback was invoked.
32.27. FL TREE ITEM.H FILE REFERENCE 929
Classes
• class Fl Tree Item
Tree widget item.
Classes
• class Fl Tree Item Array
Manages an array of Fl Tree Item pointers.
930 CHAPTER 32. FILE DOCUMENTATION
Variables
• class FL EXPORT Fl Tree Item
Classes
• class Fl Tree Prefs
Tree widget’s preferences.
Enumerations
• enum Fl Tree Connector { FL TREE CONNECTOR NONE =0, FL TREE CONNECTOR DOT-
TED =1, FL TREE CONNECTOR SOLID =2 }
Defines the style of connection lines between items.
• enum Fl Tree Select { FL TREE SELECT NONE =0, FL TREE SELECT SINGLE =1, FL TRE-
E SELECT MULTI =2, FL TREE SELECT SINGLE DRAGGABLE =3 }
Tree selection style.
• enum Fl Tree Sort { FL TREE SORT NONE =0, FL TREE SORT ASCENDING =1, FL TREE -
SORT DESCENDING =2 }
Sort order options for items added to the tree.
Enumerator
FL TREE CONNECTOR NONE Use no lines connecting items.
FL TREE CONNECTOR DOTTED Use dotted lines connecting items (default)
FL TREE CONNECTOR SOLID Use solid lines connecting items.
32.30. FL TYPES.H FILE REFERENCE 931
Typedefs
Miscellaneous
• typedef unsigned char uchar
unsigned char
• typedef unsigned long ulong
unsigned long
• typedef char ∗ Fl String
Flexible length utf8 Unicode text.
• typedef const char ∗ Fl CString
Flexible length utf8 Unicode read-only string.
• typedef unsigned int Fl Shortcut
24-bit Unicode character + 8-bit indicator for keyboard flags
• typedef unsigned int Fl Char
24-bit Unicode character - upper 8-bits are unused
Todo FIXME: temporary (?) typedef to mark UTF8 and Unicode conversions
Macros
• #define xchar unsigned short
Functions
• FL EXPORT int fl access (const char ∗f, int mode)
• FL EXPORT int fl chmod (const char ∗f, int mode)
• FL EXPORT int fl execvp (const char ∗file, char ∗const ∗argv)
• FL EXPORT FILE ∗ fl fopen (const char ∗f, const char ∗mode)
Cross-platform function to open files with a UTF-8 encoded name.
• FL EXPORT char ∗ fl getcwd (char ∗buf, int maxlen)
• FL EXPORT char ∗ fl getenv (const char ∗name)
• FL EXPORT char fl make path (const char ∗path)
• FL EXPORT void fl make path for file (const char ∗path)
• FL EXPORT int fl mkdir (const char ∗f, int mode)
• FL EXPORT unsigned int fl nonspacing (unsigned int ucs)
returns true if the character is non-spacing.
• FL EXPORT int fl open (const char ∗f, int oflags,...)
Cross-platform function to open files with a UTF-8 encoded name.
• FL EXPORT int fl rename (const char ∗f, const char ∗t)
• FL EXPORT int fl rmdir (const char ∗f)
• FL EXPORT int fl stat (const char ∗path, struct stat ∗buffer)
• FL EXPORT int fl system (const char ∗f)
• FL EXPORT int fl tolower (unsigned int ucs)
return the Unicode lower case value of ucs
• FL EXPORT int fl toupper (unsigned int ucs)
return the Unicode upper case value of ucs
• FL EXPORT unsigned fl ucs to Utf16 (const unsigned ucs, unsigned short ∗dst, const unsigned
dstlen)
32.31. FL UTF8.H FILE REFERENCE 933
Classes
• struct Fl Label
This struct stores all information for a text or mixed graphics label.
• class Fl Widget
Fl Widget is the base class for all widgets in FLTK.
Macros
• #define FL RESERVED TYPE 100
Reserved type numbers (necessary for my cheapo RTTI) start here.
Typedefs
• typedef void( Fl Callback )(Fl Widget ∗, void ∗)
Default callback type definition for all fltk widgets (by far the most used)
• typedef void( Fl Callback0 )(Fl Widget ∗)
One parameter callback type definition passing only the widget.
• typedef void( Fl Callback1 )(Fl Widget ∗, long)
Callback type definition passing the widget and a long data value.
• typedef Fl Callback ∗ Fl Callback p
Default callback type pointer definition for all fltk widgets.
• typedef long fl intptr t
• typedef unsigned long fl uintptr t
Classes
• class Fl Window
This widget produces an actual window.
• struct Fl Window::shape data type
Data supporting a non-rectangular window shape.
Macros
• #define FL DOUBLE WINDOW 0xF1
double window type id
• #define FL WINDOW 0xF0
window type id all subclasses have type() >= this
Functions
• FL EXPORT void gl color (Fl Color i)
Sets the curent OpenGL color to an FLTK color.
• void gl color (int c)
back compatibility
936 CHAPTER 32. FILE DOCUMENTATION
See Also
On the Mac OS X platform, see gl texture pile height(int)
See Also
On the Mac OS X platform, see gl texture pile height(int)
See Also
On the Mac OS X platform, see gl texture pile height(int)
See Also
On the Mac OS X platform, see gl texture pile height(int)
See Also
On the Mac OS X platform, see gl texture pile height(int)
See Also
On the Mac OS X platform, see gl texture pile height(int)
938 CHAPTER 32. FILE DOCUMENTATION
FL EXPORT void gl draw ( const char ∗ str, int x, int y, int w, int h, Fl Align align )
Draws a string formatted into a box, with newlines and tabs expanded, other control characters changed to
∧
X.
and aligned with the edges or center. Exactly the same output as fl draw().
Classes
• class Fl Mac App Menu
Mac OS-specific class allowing to localize the application menu.
Functions
• void fl mac set about (Fl Callback ∗cb, void ∗user data, int shortcut=0)
Attaches a callback to the ”About myprog” item of the system application menu.
• void fl open callback (void(∗cb)(const char ∗))
Register a function called for each file dropped onto an application icon.
Variables
• int fl mac os version
The version number of the running Mac OS X (e.g., 100604 for 10.6.4)
• class Fl Sys Menu Bar ∗ fl sys menu bar
The system menu bar.
939
940 INDEX
FL CURSOR W FL EXCEPT
Enumerations.H, 903 Enumerations.H, 901
FL CURSOR WAIT FL FLAT BOX
Enumerations.H, 903 Enumerations.H, 901
FL CURSOR WE FL FOCUS
Enumerations.H, 903 Enumerations.H, 904
FL DAMAGE ALL FL FREE BOXTYPE
Enumerations.H, 903 Enumerations.H, 902
FL DAMAGE CHILD FL FREE LABELTYPE
Enumerations.H, 903 Enumerations.H, 906
FL DAMAGE EXPOSE FL FULLSCREEN
Enumerations.H, 903 Enumerations.H, 906
FL DAMAGE OVERLAY FL HIDE
Enumerations.H, 903 Enumerations.H, 905
FL DAMAGE SCROLL FL JOIN BEVEL
Enumerations.H, 903 Drawing functions, 241
FL DAMAGE USER1 FL JOIN MITER
Enumerations.H, 903 Drawing functions, 241
FL DAMAGE USER2 FL JOIN ROUND
Enumerations.H, 903 Drawing functions, 241
FL DASH FL KEYBOARD
Drawing functions, 241 Enumerations.H, 905
FL DASHDOT FL KEYDOWN
Drawing functions, 241 Enumerations.H, 904
FL DASHDOTDOT FL KEYUP
Drawing functions, 241 Enumerations.H, 905
FL DEACTIVATE FL LEAVE
Enumerations.H, 905 Enumerations.H, 904
FL DND DRAG FL MOUSEWHEEL
Enumerations.H, 906 Enumerations.H, 905
FL DND ENTER FL MOVE
Enumerations.H, 906 Enumerations.H, 905
FL DND LEAVE FL NO BOX
Enumerations.H, 906 Enumerations.H, 901
FL DND RELEASE FL NO EVENT
Enumerations.H, 906 Enumerations.H, 904
FL DOT FL NO LABEL
Drawing functions, 241 Enumerations.H, 906
FL DOWN BOX FL NORMAL LABEL
Enumerations.H, 901 Enumerations.H, 906
FL DOWN FRAME FL PASTE
Enumerations.H, 901 Enumerations.H, 905
FL DRAG FL PUSH
Enumerations.H, 904 Enumerations.H, 904
FL EMBOSSED BOX FL READ
Enumerations.H, 901 Enumerations.H, 901
FL EMBOSSED FRAME FL RELEASE
Enumerations.H, 901 Enumerations.H, 904
FL ENGRAVED BOX FL RGB SCALING BILINEAR
Enumerations.H, 901 Fl Image.H, 926
FL ENGRAVED FRAME FL RGB SCALING NEAREST
Enumerations.H, 901 Fl Image.H, 926
FL ENTER FL SCREEN CONFIGURATION CHANGED
Enumerations.H, 904 Enumerations.H, 906
952 INDEX
x
Fl Help Dialog, 470
Fl Widget, 856
Screen functions, 226
x to col
Fl Text Display, 732
xbounds
Fl Positioner, 575
xclass
Fl Window, 873
xposition
Fl Scroll, 632
xstep
Fl Positioner, 575
xvalue
Fl Positioner, 575
xy to position
Fl Text Display, 732
xy to rowcol
Fl Text Display, 732
xyline
Fl Graphics Driver, 450
Fl PostScript Graphics Driver, 589
y
Fl Help Dialog, 470
Fl Widget, 856
Screen functions, 227
ybounds
Fl Positioner, 575