Jump to content

Draft:NAppGUI

From Wikipedia, the free encyclopedia

NAppGUI
Original author(s)Francisco García Collado
Initial release31 December 2019; 4 years ago (2019-12-31)
Stable release
v1.4.3.5531 / October 12, 2024; 40 days ago (2024-10-12)
Repositorygithub.com/frang75/nappgui_src
Written inC
Operating systemWindows, MacOS, Linux
LicenseMIT License
Websitenappgui.com

NAppGUI is an open-source SDK for building cross-platform desktop applications using the C Programming Language (ANSI C90). NAppGUI operates as a lightweight layer on top of the operating system's native APIs, which allows creating portable programs very fast and small without external dependencies.

Architecture

[edit]

The NAppGUI SDK goes beyond a pure GUI widget library and provides the below cross-platform core components..[1]

  • Sewer: Basic types, assertions, Unicode, standard C library, math functions.
  • Osbs: Operating system services. Portable API on files, directories, processes, threads, memory, etc.
  • Core: Commonly used non-graphical utilities. Memory auditor, data structures, I/O channels, lexical analysis, etc.
  • Geom2D: 2D geometry. Transformations, vectors, polygons, collisions, etc.
  • Draw2D: Vector drawing API, images and fonts.
  • Gui: High-level user interface composer.
  • OSApp: Desktop applications. Message loops.
  • INet: Internet protocols and services, such as HTTP.

Supported Platforms

[edit]

NAppGUI currently supports the following platforms:[2]

Portability and Deployment

[edit]

NAppGUI aims to compile and debug a program on any of the above platforms without touching a single line of code. It leverages CMake for creating or updating a build project from the source code and uses Visual Studio, Xcode or GCC depending on the active platform.[3]

Since the very beginning of the project, the main objective of NAppGUI has been to simplify as much as possible the arduous task of creating applications with a graphical interface in C. The philosophy on which the project is based and some of its characteristics are:

  • Rapid prototyping, evolution and maintenance in real applications, apart from the simple examples we find in the literature and the Internet.
  • The user interface is described using ANSI-C functions, completely eliminating visual design. This fact facilitates the creation of dynamic interfaces, guarantees portability and enables access to the API from any programming language.
  • Windows are automatically laid out and sized, without the programmer having to explicitly specify the coordinates and size of the controls.
  • It is possible to have a complete application in a single .c file, by removing the usual resource files (*.rc, *.xvid , etc) and their associated controllers. The programmer has complete freedom when defining his own file structure.
  • Automatic synchronization of internal data structures with the interface or with I/O channels. “Data binding".
  • Unified management of resources which facilitates internationalization. “Resources”
  • Translations between languages at runtime without the need to restart the application. “Runtime translation”.
  • The compiled version of NAppGUI occupies less than 1Mb, and is distributed in several static libraries that generate very small executables. This is a great advantage over other solutions that require the distribution of heavy .DLLs, sometimes larger than the application itself.
  • Native Appearance: The applications will be integrated into each system respecting their original aesthetic.
  • Backends. The NAppGUI core provides structures and objects for creating highly efficient command-line applications on Windows or Linux servers.

Documentation

[edit]

Documentation for NAppGUI is available in the form of an introductory Quick Start Guide, User Guide[4] with build instructions and creating a new application, API reference[5] as well as a free ebook[6]

A set of sample applications demonstrates NAppGUI functionality and facilitates creating own applications.[7]

There exist a NAppGUI Programming Tutorial on YouTube (Spanish language).[8]

Hello World Example

[edit]
NAppGui Hello World Sample on Windows XP.
NAppGui Hello World Sample on Windows XP.
NAppGUI Hello World Sample on MacOS Sonoma.
NAppGUI Hello World Sample on MacOS Sonoma.
NAppGUI Hello World Sample on Ubuntu 18.
NAppGUI Hello World Sample on Ubuntu 18.
NAppGui Hello World Sample on Windows 11
NAppGui Hello World Sample on Windows 11.
NAppGui Hello World Sample on Kali Linux 2023.3.
NAppGui Hello World Sample on Kali Linux 2023.3.
NAppGui Hello World Sample on Mac OSX Snow Leopard.
NAppGui Hello World Sample on Mac OSX Snow Leopard.
NAppGui Hello World Sample on Raspian 8 Jessie.
NAppGui Hello World Sample on Raspian 8 Jessie.

The below code sample creates a window, adds label, button and text control widgets and reacts on a button click. Three screenshots show the program running on the supported platforms.[9]

/* NAppGUI Hello World */

#include <nappgui.h>

typedef struct _app_t App;

struct _app_t
{
    Window *window;
    TextView *text;
    uint32_t clicks;
};

/*---------------------------------------------------------------------------*/

static void i_OnButton(App *app, Event *e)
{
    String *msg = str_printf("Button click (%d)\n", app->clicks);
    textview_writef(app->text, tc(msg));
    str_destroy(&msg);
    app->clicks += 1;
    unref(e);
}

/*---------------------------------------------------------------------------*/

static Panel *i_panel(App *app)
{
    Panel *panel = panel_create();
    Layout *layout = layout_create(1, 3);
    Label *label = label_create();
    Button *button = button_push();
    TextView *text = textview_create();
    app->text = text;
    label_text(label, "Hello!, I'm a label");
    button_text(button, "Click Me!");
    button_OnClick(button, listener(app, i_OnButton, App));
    layout_label(layout, label, 0, 0);
    layout_button(layout, button, 0, 1);
    layout_textview(layout, text, 0, 2);
    layout_hsize(layout, 0, 250);
    layout_vsize(layout, 2, 100);
    layout_margin(layout, 5);
    layout_vmargin(layout, 0, 5);
    layout_vmargin(layout, 1, 5);
    panel_layout(panel, layout);
    return panel;
}

/*---------------------------------------------------------------------------*/

static void i_OnClose(App *app, Event *e)
{
    osapp_finish();
    unref(app);
    unref(e);
}

/*---------------------------------------------------------------------------*/

static App *i_create(void)
{
    App *app = heap_new0(App);
    Panel *panel = i_panel(app);
    app->window = window_create(ekWINDOW_STD);
    window_panel(app->window, panel);
    window_title(app->window, "Hello, World!");
    window_origin(app->window, v2df(500, 200));
    window_OnClose(app->window, listener(app, i_OnClose, App));
    window_show(app->window);
    return app;
}

/*---------------------------------------------------------------------------*/

static void i_destroy(App **app)
{
    window_destroy(&(*app)->window);
    heap_delete(app, App);
}

/*---------------------------------------------------------------------------*/

#include "osmain.h"
osmain(i_create, i_destroy, "", App)

Other Language Bindings

[edit]

There exist bindings to the below programming languages for NAppGUI.

Reception and Adoption

[edit]

Licensing

[edit]

NAppGUI is an open-source project and is distributed under the MIT license.

References

[edit]
  1. ^ "NAppGUI API - Cross-platform C SDK". nappgui.com. Retrieved 2024-01-12.
  2. ^ "Quick start - Cross-platform C SDK". nappgui.com. Retrieved 2024-01-12.
  3. ^ "Welcome to NAppGUI - Cross-platform C SDK". nappgui.com. Retrieved 2024-01-12.
  4. ^ "Welcome to NAppGUI - Cross-platform C SDK". nappgui.com. Retrieved 2024-01-12.
  5. ^ "NAppGUI API - Cross-platform C SDK". nappgui.com. Retrieved 2024-01-12.
  6. ^ García Collado, Francisco (7 January 2024). "Mastering NAppGUI" (PDF). Cross-Platform C SDK - NAppGUI. Retrieved 9 January 2024.
  7. ^ "Die - Cross-platform C SDK". nappgui.com. Retrieved 2024-01-12.
  8. ^ "Tutorial Programación Multiplataforma en C - YouTube". www.youtube.com. Retrieved 2024-01-12.
  9. ^ "Hello World! - Cross-platform C SDK". nappgui.com. Retrieved 2024-01-12.
  10. ^ Ringey, Brennan (2023-07-07), stoneface86/nappgui-nim, retrieved 2024-01-12
  11. ^ Ogi-kun (2023-05-03), Ogi-kun/nappgui, retrieved 2024-01-12
  12. ^ "nappgui-go command - github.com/parro-it/nappgui-go - Go Packages". pkg.go.dev. Retrieved 2024-01-12.
  13. ^ "Release Cross-platform OS abstraction and GUI library MVP · rochus-keller/Oberon". GitHub. Retrieved 2024-01-12.
  14. ^ "27 Open-source Electron Alternatives For Building Desktop Apps using Web Technologies". MEDevel.com: Open-source for Healthcare, and Education. 2023-07-13. Retrieved 2024-05-27.
  15. ^ "raygui vs nappgui - compare differences and reviews? | LibHunt". www.libhunt.com. Retrieved 2024-05-27.