Platforms

Platform Implementations

NAppGUI's portable API is backed by three concrete native stacks in this checkout: Cocoa/AppKit on macOS, Win32 on Windows, and GTK3 on Linux. Each backend provides the osapp runloop pieces, the osgui control/window implementation, and the platform drawing backend used by draw2d.

Relevant Source Files

Shared Contract

The high-level application bootstrap is the same across platforms: osmain_imp() starts osgui, starts gui, creates the native GuiCtx with osguictx(), installs it as current, and then hands control to the platform-specific _osapp_run(...) implementation.

From that point on, control creation, window events, focus routing, drawing, and optional web support all flow through the platform backend.

Backend Comparison

Area macOS Windows GTK
Application loop NSApplication delegate plus timers in multiple runloop modes Win32 timer plus standard message loop GtkApplication activation plus g_timeout_add timers
Window base NSPanel HWND GtkApplicationWindow or offscreen GTK window
2D drawing Core Graphics GDI/GDI+ Cairo plus Pango text
Browser widget WKWebView when enabled WebView2 when enabled WebKitGTK when enabled
OpenGL helper NSOpenGLContext wgl EGL on GTK/X11

Platform-Specific Character

  • macOS: uses staged termination, deferred theme refresh, NSPanel-based windows, and AppKit appearance-aware color handling.
  • Windows: uses classic Win32 windows, accelerator tables, tooltip windows, GDI+ graphics, and asynchronous WebView2 creation.
  • GTK: relies on configure-event driven move/resize handling, Cairo/Pango rendering, GTK accelerator groups, and WebKitGTK when available.

Reading Order

Start with the per-platform osapp file to understand lifecycle and runloop behavior, then move to the platform oswindow implementation, then the matching draw2d backend, and finally the platform osweb file if browser integration matters for your application.