I - Tests and Demo Source Code

March 19, 2005

The FLTK distribution contains over 60 sample applications written in, or ported to, FLTK. If the FLTK archive you received does not contain a '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.

Example Applications
adjuster arc ask bitmap blocks boxtype
browser button buttons checkers clock colbrowser
color_chooser cube CubeView cursor curve demo
doublebuffer editor fast_slow file_chooser fluid fonts
forms fractals fullscreen gl_overlay glpuzzle hello
help iconize image inactive input input_choice
keyboard label line_style list_visuals mandelbrot menubar
message minimum navigation output overlay pack
pixmap_browser pixmap preferences radio resizebox resize
scroll shape subwindow sudoku symbols tabs
threads tile tiled_image valuators

adjuster

adjuster shows a nifty little widget for quickly setting values in a great range.

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.

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... .

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.

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.

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.

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.

button

The button test is a simple demo of push-buttons and callbacks.

buttons

buttons shows a sample of FLTK button types.

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.

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.

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 moderatly useful unless your UI is written in Motif.

color_chooser

The color_chooser gives a short demo of FLTK's palette based color chooser and of the RGB based color wheel.

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.

CubeView

CubeView shows how to create a UI containing OpenGL with Fluid.

cursor

The cursor demo show 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).

curve

curve draws a nice Bezier curve into a custom widget. The points option for splines is not supported on all platforms.

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.

doublebuffer

The doublebuffer demo show 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.

editor

FLTK has two very different text input widgets. Fl_Input and derived classes are rather leight 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

fast_slow shows how an application can use then when() setting to receive different kinds of callbacks.

file_chooser

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.

fonts

fonts show 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.

forms

forms is an XForms program with very few changes. Search for "fltk" to find all changes necessary to port to fltk. This demo show the different boxtypes. Note that some boxtypes are not appropriate for some objects.

fractals

fractals shows how to mix OpenGL, Glut and FLTK code. FLTK supports a rather large subset of Glut, so that many Glut application compile just fine.

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.

gl_overlay

gl_overlay shows OpenGL overlay plane rendering. If no hardware overlay plane is available, FLTK will simulate it for you.

glpuzzle

The glpuzzle test shows how most Glut source code compiles easily under FLTK.

hello

hello: Hello, World. Need I say maore? Well, maybe. This tiny demo shows how little is needed to get a functioning application running with FLTK. Quite impressive, I'd say.

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.

iconize

iconize demonstrates the effect of the window functions hide(), iconize(), and show().

image

The image demo shows how an image can be created on the fly. This generated image contains an alpha (transparency) channel which lets previous renderings 'shine through', either via true transparency or by using screen door transparency (pixelation).

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.

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

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.

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.

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.

line_style

Advanced line drawing can be tested with line_style. Not all platforms support all line styles.

list_visuals

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.

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.

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.

message

message pops up a few of FLTK's standars message boxes.

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.

navigation

navigation demonstrates how the text cursor moves from text field to text field when using the arrow keys, tab, and shift-tab.

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.

overlay

The overlay test app show how easy an FLTK window can be layered to display cursor and manipulator style elemnts. This example derives a new class from Fl_Overly_WIndow and provides a new function to draw custom overlays.

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

pixmap_browser tests the shared-image interface. When using the same image multiple times, Fl_Shared_Image will keep it only once in memory.

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.

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.

radio

The radio tool was created entirely with fluid. It shows some of the available button types and tests radio button behavior.

resizebox

resizebox shows some possible ways of FLTK's automatic resize bahavior..

resize

The resize demo tests size and position functions with the given window manager.

scroll

scroll shows how to scroll an area of widgets, one of them beeing 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.

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.

subwindow

The subwindow demo tests messaging and drawing between the main window and 'true' sub windows. A sub window is different to a group by resetting the FLTK coordinate stystem to 0, 0 in the top left corner. On Win32 and X11, subwindows have their own operating system specific handle.

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.

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.).

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.

threads

FLTK can be used in a multithreading environment. There are some limitations, mostly due to the underlying operating system. threads show 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.

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.

tiled_image

The tiled_image demo uses an image as the background for a window by repeating it over the full size of the widget. Thw window is resizable and shows how the image gets repeated.

valuators

valuators shows all of FLTK's nifty widgets to change numeric values.

fluid

fuid is not only a big test program, but also a very useful visual UI designer. Many parts of fluid were created using fluid.