fltk.app

FLTK Application and Event Loop Helpers

This module provides functions for running the FLTK event loop and managing timeouts and idle callbacks.

The event loop is the core of any FLTK application. It processes user input, window events, and triggers callbacks.

Example:

import fltk;

void main() {
   auto window = new Window(300, 200, "My App");
   window.show();
   run();  // Blocks until all windows are closed
}

Authors

Dejan Lekić

License

BSD-3-Clause

Types 9

aliasTimeoutCallback = void delegate()

Callback type for timeouts and idle handlers.

enumScheme

Available UI schemes.

noneDefault FLTK look
gtkGTK+ inspired look
gleamGleam scheme (modern look)
plasticPlastic scheme (shiny buttons)
oxyOxygen scheme

Clipboard destination/source.

selection = 0X11 selection buffer (middle-click paste)
clipboard = 1System clipboard (Ctrl+V paste)

File descriptor event types.

read = 1Data available to read
write = 4Ready for writing
except = 8Exception/error condition
aliasFdHandler = void delegate(int fd) nothrow @nogc

File descriptor callback delegate type.

Screen/monitor information.

Fields
int x
int y
int width
int height
structScreenDpi

Screen DPI information.

Fields
float horizontal
float vertical

Visual mode flags for requesting specific display capabilities.

RGB = 0RGB color (default)
INDEX = 1Indexed color
DOUBLE = 2Double buffering
ACCUM = 4Accumulation buffer
ALPHA = 8Alpha blending
DEPTH = 16Depth buffer
STENCIL = 32Stencil buffer
RGB8 = 648-bit RGB
MULTISAMPLE = 128Anti-aliasing
STEREO = 256Stereo display
FAKE_SINGLE = 512Fake single buffering
enumOption

FLTK option indices.

ARROW_FOCUS = 0Arrow keys move focus between widgets
VISIBLE_FOCUS = 1Show visible focus rectangle
DND_TEXT = 2Enable drag-and-drop for text
SHOW_TOOLTIPS = 3Show tooltips
FNFC_USES_GTK = 4Native file chooser uses GTK
PRINTER_USES_GTK = 5Printer dialog uses GTK
SHOW_SCALING = 6Show scaling factor in title

Functions 47

fnint run() nothrow @nogcRuns the FLTK event loop until all windows are closed.
fnint wait(double seconds = - 1.0) nothrow @nogcWaits for events with an optional timeout.
fnint check() nothrow @nogcChecks for and processes pending events without blocking.
fnint ready() nothrow @nogcChecks if events are ready without processing them.
fnvoid addTimeout(double seconds, TimeoutCallback callback)Adds a one-shot timeout callback.
fnbool hasTimeout(TimeoutCallback callback)Checks if a timeout callback is registered.
fnvoid removeTimeout(TimeoutCallback callback)Removes a timeout callback.
fnvoid addIdle(TimeoutCallback callback)Adds an idle callback.
fnbool hasIdle(TimeoutCallback callback)Checks if an idle callback is registered.
fnvoid removeIdle(TimeoutCallback callback)Removes an idle callback.
fnint flush() nothrow @nogcProcesses all pending events and returns immediately.
fnstring scheme()Gets the current UI scheme.
fnbool setScheme(string name)Sets the UI scheme.
fnbool setScheme(Scheme s)Sets the UI scheme using enum.
fnvoid copy(string text, ClipboardType destination = ClipboardType.clipboard)Copies text to the clipboard.
fnbool dnd() nothrow @nogcInitiates a drag and drop operation.
fnstring eventText()Gets the text from a drag and drop or paste event.
fnint eventLength() nothrow @nogcGets the length of the current event text.
fnvoid lock() nothrow @nogcAcquires the FLTK lock for thread-safe operations.
fnvoid unlock() nothrow @nogcReleases the FLTK lock.
fnvoid awake() nothrow @nogcWakes up the main thread from another thread.
private fnvoid _fdCallbackDispatcher(int fd, void *) nothrow @nogc
private fnvoid _addFdHandler(int fd, FdHandler handler) nothrow @nogc
private fnvoid _removeFdHandler(int fd) nothrow @nogc
fnvoid addFd(int fd, FdEvent events, FdHandler handler) nothrow @nogcAdds a file descriptor callback.
fnvoid addFd(int fd, FdHandler handler) nothrow @nogcAdds a file descriptor callback for read events.
fnvoid removeFd(int fd, FdEvent events = cast(FdEvent) 0)nothrow nothrow @nogcRemoves a file descriptor callback.
fnint screenCount() nothrow @nogcGets the number of screens/monitors.
fnScreenInfo screenBounds(int screen = 0) nothrow @nogcGets the bounding rectangle of a screen.
fnScreenInfo screenWorkArea(int screen = 0) nothrow @nogcGets the work area of a screen (excluding taskbars, docks, etc.).
fnScreenDpi screenDpi(int screen = 0) nothrow @nogcGets the DPI (dots per inch) of a screen.
fndouble fltkVersion() nothrow @nogc @trustedGets the FLTK library version.
fnint fltkApiVersion() nothrow @nogc @trustedGets the FLTK API version.
fnint fltkAbiVersion() nothrow @nogc @trustedGets the FLTK ABI version.
fnvoid setDisplay(string display) @trustedSets the X display to use for subsequent windows.
fnbool requestVisual(int mode) nothrow @nogc @trustedRequests a visual type for windows.
fnvoid ownColormap() nothrow @nogc @trustedRequests FLTK to use its own colormap.
fnvoid getSystemColors() nothrow @nogc @trustedLoads system colors into FLTK's color palette.
fnvoid setForeground(ubyte r, ubyte g, ubyte b) nothrow @nogc @trustedSets the default foreground (label) color.
fnvoid setBackground(ubyte r, ubyte g, ubyte b) nothrow @nogc @trustedSets the default background color for widgets.
fnvoid setBackground2(ubyte r, ubyte g, ubyte b) nothrow @nogc @trustedSets the default background color for text input widgets.
fnint scrollbarSize() nothrow @nogc @trustedGets the default scrollbar width in pixels.
fnvoid setScrollbarSize(int width) nothrow @nogc @trustedSets the default scrollbar width in pixels.
fnbool getOption(Option opt) nothrow @nogc @trustedGets an FLTK option value.
fnvoid setOption(Option opt, bool val) nothrow @nogc @trustedSets an FLTK option value.
fnint getDamage() nothrow @nogc @trustedGets the global damage flag.
fnvoid redrawAll() nothrow @nogc @trustedMarks all widgets for redraw.

Variables 6

private varTimeoutCallback[] _timeoutCallbacks
private varTimeoutCallback[] _idleCallbacks
private enumvarMAX_FD_HANDLERS = 64
private varFdHandler[MAX_FD_HANDLERS] _fdHandlers
private varint[MAX_FD_HANDLERS] _fdKeys
private varint _fdCount = 0