fltk.window

FLTK Window Class

This module provides the Window class that wraps FLTK's Fl_Window. Windows are top-level containers that can be displayed on screen.

The Window class provides:

  • RAII-based resource management
  • Size and position control
  • Title management
  • Resizable window support
  • Child widget management (via Group base)

    Authors

    Dejan Lekić

    License

    BSD-3-Clause

Types 4

classWindow : Widget

Top-level window widget.

Windows are containers that can be displayed on the screen. They can contain child widgets and handle user input.

Example:

auto window = new Window(640, 480, "My Application");
window.sizeRange(320, 240);  // Set minimum size
window.show();
run();

Fields
WindowPtr _windowHandleThe underlying window handle (more specific than Widget's handle)
string _titleStored title for reference
Methods
WindowPtr windowHandle() @safe nothrow @nogcReturns the underlying window handle.
string title() const @safe nothrow @nogcGets the window title.
void title(string newTitle)Sets the window title.
bool shown() const nothrow @nogcChecks if the window is currently shown on screen.
void show() nothrow @nogcShows the window on screen.
void hide() nothrow @nogcHides the window.
void sizeRange(int minWidth, int minHeight, int maxWidth = 0, int maxHeight = 0) nothrow @nogcSets the window's size range (minimum and maximum size).
void makeResizable() nothrow @nogcMakes the window resizable.
void resizable(Widget resizeWidget) nothrow @nogcMakes the window resizable using a specific widget as the resize box.
GroupPtr asGroup() nothrow @nogcReturns the window as a Group handle for child widget operations.
void begin() nothrow @nogcBegins adding children to this window.
void end() nothrow @nogcEnds adding children to this window.
int childCount() nothrow @nogcGets the number of child widgets.
Constructors
this(int width, int height, string title = null)Creates a new window with the specified size.
this(int x, int y, int width, int height, string title = null)Creates a new window with position and size.
Destructors
~thisDestroys the window and releases resources.

Double-buffered window widget.

DoubleWindow provides flicker-free rendering by using double buffering. All drawing is done to an off-screen buffer, then copied to the screen in a single operation. This eliminates flicker during complex redraws.

Use DoubleWindow instead of Window when:

  • The window contains animations
  • Widgets are frequently updated
  • You need smooth, flicker-free rendering

Example:

auto window = new DoubleWindow(640, 480, "Smooth Animation");
// Add widgets...
window.show();
run();

Fields
DoubleWindowPtr _doubleWindowHandleThe underlying double window handle
string _titleStored title for reference
Methods
DoubleWindowPtr doubleWindowHandle() @safe nothrow @nogcReturns the underlying double window handle.
WindowPtr windowHandle() nothrow @nogcReturns the window handle (for Window-compatible operations).
string title() const @safe nothrow @nogcGets the window title.
void title(string newTitle)Sets the window title.
void show() nothrow @nogcShows the window on screen.
void hide() nothrow @nogcHides the window.
bool shown() nothrow @nogcReturns whether the window is currently shown.
GroupPtr asGroup() nothrow @nogcReturns the window as a Group handle for child widget operations.
void begin() nothrow @nogcBegins adding children to this window.
void end() nothrow @nogcEnds adding children to this window.
int childCount() nothrow @nogcGets the number of child widgets.
Constructors
this(int width, int height, string title = null)Creates a new double-buffered window with the specified size.
Destructors
~thisDestroys the window and releases resources.

Single-buffered window widget.

SingleWindow forces single buffering even on systems that default to double buffering. This can be useful for:

  • Programs that use incremental update
  • Displaying certain types of image data like movie flipbooks
  • Legacy programs that expect single-buffered behavior

Example:

auto window = new SingleWindow(640, 480, "Single Buffered");
// Add widgets...
window.show();
run();

Fields
SingleWindowPtr _singleWindowHandleThe underlying single window handle
string _titleStored title for reference
Methods
SingleWindowPtr singleWindowHandle() @safe nothrow @nogcReturns the underlying single window handle.
WindowPtr windowHandle() nothrow @nogcReturns the window handle (for Window-compatible operations).
string title() const @safe nothrow @nogcGets the window title.
void title(string newTitle)Sets the window title.
void show() nothrow @nogcShows the window on screen.
void hide() nothrow @nogcHides the window.
bool shown() nothrow @nogcReturns whether the window is currently shown.
GroupPtr asGroup() nothrow @nogcReturns the window as a Group handle for child widget operations.
void begin() nothrow @nogcBegins adding children to this window.
void end() nothrow @nogcEnds adding children to this window.
int childCount() nothrow @nogcGets the number of child widgets.
Constructors
this(int width, int height, string title = null)Creates a new single-buffered window with the specified size.
this(int x, int y, int width, int height, string title = null)Creates a new single-buffered window with position and size.
Destructors
~thisDestroys the window and releases resources.

Menu window widget.

MenuWindow is a window type specifically designed for popup menus. It uses hardware overlay planes if available for flicker-free display. When overlay planes are not available, it falls back to normal drawing.

Example:

auto menu = new MenuWindow(150, 200);
menu.setOverlay();  // Use hardware overlay if available
// Add menu items...
menu.show();

Fields
MenuWindowPtr _menuWindowHandleThe underlying menu window handle
string _titleStored title for reference
Methods
MenuWindowPtr menuWindowHandle() @safe nothrow @nogcReturns the underlying menu window handle.
WindowPtr windowHandle() nothrow @nogcReturns the window handle (for Window-compatible operations).
string title() const @safe nothrow @nogcGets the window title.
void title(string newTitle)Sets the window title.
void show() nothrow @nogcShows the window on screen.
void hide() nothrow @nogcHides the window.
bool shown() nothrow @nogcReturns whether the window is currently shown.
bool overlay() nothrow @nogcReturns whether hardware overlay mode is enabled.
void setOverlay() nothrow @nogcEnables hardware overlay mode if available.
void clearOverlay() nothrow @nogcDisables hardware overlay mode (use normal drawing planes).
GroupPtr asGroup() nothrow @nogcReturns the window as a Group handle for child widget operations.
void begin() nothrow @nogcBegins adding children to this window.
void end() nothrow @nogcEnds adding children to this window.
int childCount() nothrow @nogcGets the number of child widgets.
Constructors
this(int width, int height, string title = null)Creates a new menu window with the specified size.
this(int x, int y, int width, int height, string title = null)Creates a new menu window with position and size.
Destructors
~thisDestroys the window and releases resources.