Documentation

GUI.Forms

GUI.Forms is a C++20 toolkit for macOS, Windows and Linux.

  • macOS 14 or later, Apple silicon
  • Windows 10 or later, x64
  • Linux on x64 and arm64, under X11 or XWayland

It includes a superset of Windows Forms' model of controls, properties and events, draws on the CPU, and opens to C, C# and Python through a C ABI. Version 1.0, MIT licensed.

Built with GUI.Forms

Plan Paint's Home ribbon above a painted landscape: a cottage with a smoking chimney, pine trees and a lake in a meadow, with snow-capped mountains, clouds and the sun behind

Plan Paint

An amalgam of the image editors from the 90s and your youth, universally present and fully demonstrating our take on the Ribbon class.

PlaySuite on macOS: a wooden shelf of boxed games such as FreeCell, Hearts, Koi-Koi, Solitaire and Spider, with Spider selected and described at the bottom

PlaySuite

Games in one application, each game a folder. Anyone can add one by pull request.

Pocket Reference on the gui_forms::Button page, with the contents tree on the left and the page's description, parameters and properties on the right

Pocket Reference

The GUI.Forms reference, written as a GUI.Forms program: every control and topic, searchable, laid out on change and never per frame. MIT-licensed, and the place to start reading how a retained-mode program is put together.

Screenshot to come from the 1.0 build

Chat stress

A billion messages of every length in one GUI.Forms list. Jump anywhere, scroll, resize the window: it answers as quickly as it would with ten. The list does its work on the rows you can see, from memory fixed at the start, so what it costs depends on the window, never on how much it holds.

GUI.Forms in one display

Every code file, sized by its length. Hover or tap a file to see what it includes.

The map needs JavaScript. The code statistics give the same counts.

Consistent by design

Every GUI.Forms window is one retained tree painted consistently across all hosts by our own rasterizing and rendering engines. There is little if any platform variation.

Conversely, Qt and GTK hand text to each platform's font system, and Qt Quick, GTK 4 and Avalonia draw through the graphics driver, so a dialog can wrap differently on a customer's screen and a fault can belong to one driver alone.

What you lay out and test on one machine is what every user sees, and a screenshot from any of your users with a GUI.Forms window is a faithful bug report.

Gracefully stateless fault control

An expected failure returns as a value and leaves the program as it was. A defect stops the process where it began, and its report carries the frames that led there. Nothing carries on half changed.

An exception is allowed to unfold across languages. One raised in native code and reaching a C# caller arrives as a NativeException whose stack trace holds the native frames it came through. Elsewhere an exception that meets a native boundary is undefined behaviour: Qt says so of its slots, .NET turns one into a crash or a bare SEHException, and a C library has no way to pass one on at all.

Your program is either right or stopped, its reports name where the fault began on both sides of the boundary, and an event handler can clear a list, detach its control or close the window without regard for what the control was doing.

Speed

Most code is slow because it keeps asking questions it already knows the answers to. Ours stopped asking. Every tight loop and core mechanism was stripped until nothing inside it decides anything; it only computes. Then the next wave stripped it again. Not one result changed along the way.

STXlib's FFT was built the same way. Where size matters, it beats FFTW.

You will never wait on GUI.Forms. You will forget it is there.

Trustworthy by design

GUI.Forms is written in one house style: an orthodox, explicitly spelled subset of C++20 in which types, ownership, mutation and execution order are visible where they are used. Code written that way can be checked, and it is. Clang-based tools read it with full type information, applying the style semantically and carrying the whole codebase onto STXlib's own vocabulary types; further checks hold lifetimes, state machines and storage boundaries to the same rules.

The work continues toward formal verification. Every stateful part declares its contract once, and its entry checks, its fuzzing and its proof obligations are generated from that declaration, with a deducer discharging what it can. The allocator's page protocol is proved for any number of threads, and STXlib's core routines carry machine-checked proofs. A program built in the high-integrity configuration holds only what it uses, and a reviewer can show that from the symbols in the finished binary.

Other toolkits ask to be trusted. GUI.Forms is built so that its trustworthiness can be checked.

Model Context Protocol from the first version

In recent years, since general machine intelligence proliferated, operating system and application providers have begun to proliferate MCP servers; control toolkits, however, mainly predated AI. In GUI.Forms it is part of the toolkit, so every program built on it speaks MCP from its first build, and needs no code of its own to achieve the minimum in instrumentation, accelerating development and use.

Often, in other approaches, a model reaches a desktop program in one of two ways: someone writes and maintains an MCP server for that one program, or the model reads screenshots and accessibility trees and guesses where to click. Both have issues with brittle representation and a fragmented approach.

A GUI.Forms program arrives with a coherent MCP stack. The model has first-order access to the controls, commands and states the program uses, so automation, testing and assistance come with every program and keep working as it changes.

Easy to theme

Unlike Visual Studio's form editor contracts, GUI.Forms form specifications are easy to work with and straightforward, using XML with inline control trees and bindings, with an accompanying theme language that uses a subset of CSS level 3. Designers can restyle a program without touching its code, on the fly, and GUI.Forms comes with a handful of classic themes that are familiar to most users.

<form xmlns="urn:gui-forms:form:1" id="greeter.window"
      text="GUI.Forms - first window" client-size="480 140">
  <panel id="greeter.root">
    <label id="greeter.status" text="Ready."
           bounds="24 24 432 32" classes="status"/>
    <button id="greeter.run" text="Run" bounds="24 72 120 36">
      <bind property="command" to="run"/>
    </button>
  </panel>
</form>
:root { ink-on-paper: #1d3557 on #ffffff; }

.status {
  color: role(ink-on-paper);
  font-family: content;
  font-size: 15px;
  font-weight: 600;
}

The Gallery's Control spectrum page in three of them.

The GUI.Forms Gallery's Control spectrum page in the windows-professional theme: flat grey buttons with a solid blue Accent button, check boxes, radio buttons and typography roles, with the page list on the left
windows-professional
The same Gallery page in the xp-style theme: a beige window, buttons with blue borders, green check marks and radio dots, and the selected page highlighted in blue
xp-style
The same Gallery page in the windows7-style theme: grey gradient buttons, a light blue glossy Accent button and the selected page highlighted in blue
windows7-style

Accessible and translatable

Every stock control publishes its role, name, state and actions by default, through one semantic tree served to NSAccessibility, UI Automation and AT-SPI. A compiler plugin finds every string a program writes to a localizable property, in code as well as in forms, and right-to-left layout mirrors as Windows Forms' does.

A GUI.Forms based program is accessible and ready to translate without extra work; the developer's effort starts only where the defaults are not enough.

WinForms compatible, Windows optional

The vocabulary and design gently deviate from and supersede the familiar, professionally articulated design language that is Windows Forms. It keeps the control families, Dock and Anchor, tab order, mnemonics, validation, accept and cancel buttons, Invoke, BindingSource. Every Forms type is mapped to its counterpart, and where behaviour differs on purpose the guide says so.

Windows Forms developers are at home on the first day, and their programs run on macOS and Linux too.

Compatible, not identical

Some of WinForms' behaviour survives only because programs came to depend on it. GUI.Forms keeps each control's vocabulary and intent, and behaves the way the documentation describes rather than the way the defect does. A converted program keeps its logic and loses the workarounds. Every WinForms program still starts its message loop through Microsoft Office's component manager, carried into the framework decades ago; GUI.Forms opens its first window directly.

Dependency-free and adaptable

STXlib, a standard library extending framework and wrapper, is a code membrane that stands between GUI.Forms and everything outside it: the host's C library, the C++ runtime, threads, files, math and the allocator. It runs beside glibc, musl, FreeBSD's libc and the Windows UCRT and behaves the same over each; it supplies the atomic helpers a compiler would otherwise take from its runtime, and its own math gives the same bits on every processor. Fonts, shaping, hinting, PNG and zlib are first-party.

Programs written on GUI.Forms can make use of it or use their own libraries without friction. The contribution from GUI.Forms, conversely, is guaranteed to run on the machines you intend, and depends only on its own stack, which is formulated from best-practice components like Clang.

Strong ABI support

  • C: function tables negotiated through one exported function, fixed-width types, a status from every call. Within a major version a table only grows at its end, and an audit rejects any break. A conformance kit runs the ABI's checks in your own tests.
  • C++20: the library itself, as static archives through CMake.
  • C#: GuiForms.Interop, and GuiForms.Forms with Windows Forms' protected On* hooks as virtuals.
  • Python: PyGUIForms, pure Python over the C ABI, CPython 3.10 or later.

Compact by design

  • GUI.Forms links statically, from archives built with every function and datum in a section of its own.
  • The linker keeps only what the program reaches, with link-time optimisation and dead stripping on every platform.
  • The C++ runtime is linked in and pinned, so nothing has to be installed beside the program.
  • A feature the program never calls is not in the binary.

Allocators and threading, the GUI.Forms way

We considered the speed and reliability of threading and allocator methods to be the most important part of any framework that purports to offer reliability. We set out to achieve this without leaning on the 21st-century crutch that has become "convert everything to Rust". We followed by adapting best principles and sourcing the best work we could find. We deviated from designs we considered good, but imperfect, to approach perfection and excellence. Our motto is sic semper eximius.

We took inspiration from only the brightest and greatest engineers, and rather than simply copy their work, adapted the lessons from it and put the work into proving our results correct, in everything we did.

Our designs eliminate unrequited ceremony, redundant accounting and epistemically deficient paradigms. At the same time, we unlock performance gains by tight coding, atomic behaviour and principled staging. Our allocator is faster than mimalloc. It is also correct. To the best of our ability, we developed methodologies to prove its threading model and design error-free, directed-graph style. Short of rewriting it in another language, we believe we have a high-integrity allocator. Our atomic threader is fast and tight, and inherits from the best designs in the world.

Your code may have bugs in it, and bugs that will remain hidden for decades. We got tired of the number of bugs hidden in Windows. This is part of our motivation for doing it this way: because computers should be allowed to be correct. By design, your bugs will not become ours.

Wholly MIT by design

GUI.Forms 1.0, STXlib and PyGUIForms are MIT licensed. Parts of the renderer and the glyph hinter extend designs from Skia and FreeType, so their notices stay with that code: Skia's BSD licence and the FreeType licence. The fonts keep their OFL and the C++ library its LLVM Apache licence. All are listed in THIRD_PARTY_NOTICES.md.

Where the designs come from

The programming model is inspired by Windows Forms. The CPU renderer extends Skia's. The font reader is inspired by ttf-parser and Skrifa, and the hinter extends Skrifa's auto-hinter, itself after FreeType's. The allocator is inspired by mimalloc, with TLSF for its free runs. Each has an ancestry in the named libraries but does not resemble them, is faster than the frameworks it derives from, and by design is less likely to facilitate bugs of any kind in use.