Skip to main content

Crate nappgui

Crate nappgui 

Source
Expand description

§nappgui-rs

Rust bindings to NAppGUI

NAppGUI is a professional SDK to build cross-platform desktop applications using The C Programming Language (ANSI C90). NAppGUI has built as a lightweight layer on top of the operating system native APIs, that allows create portable programs extremelly fast and small without any external dependency.

See frang75/nappgui_src and its home page for more information.

This crate is under development and is not ready for production use.

§Requirements

  • Git: for some patches on Windows build
  • CMake: for building the NAppGui static library
  • Windows SDK: only needed when using MSVC

§Example

use nappgui::osapp::*;
use nappgui::prelude::*;

struct App {
    _window: Window,
}

impl AppHandler for App {
    fn create() -> Self {
        let clicks = std::rc::Rc::new(std::cell::RefCell::new(0));

        let panel = Panel::new();
        let layout = Layout::new(1, 3);
        let label = Label::new("Hello, I'm a label");
        let button = PushButton::new("Click Me!");
        let text = TextView::new();

        layout.set(0, 0, &label);
        layout.set(0, 1, &button);
        layout.set(0, 2, &text);
        layout.hsize(0, 250.0);
        layout.vsize(2, 100.0);
        layout.margin(5.0);
        layout.vmargin(0, 5.0);
        layout.vmargin(1, 5.0);

        button.on_click(move |_params| {
            text.writef(&format!("Button click {}\n", clicks.borrow()));
            *clicks.borrow_mut() += 1;
        });

        panel.layout(&layout);

        let window = Window::new(WindowFlags::default());
        window.panel(&panel);
        window.title("Hello, World!");
        window.origin(500.0, 200.0);
        window.on_close(|_| finish());

        window.show();

        Self { _window: window }
    }
}

fn main() {
    osmain::<App>();
}

Modules§

core
Just as a building needs a strong foundation, any software project must be supported by robust and efficient pillars. For this purpose, the core library has been developed, which provides commonly used non-graphical utilities.
draw_2d
The Draw2D library integrates all the functionality necessary to create two dimensions vector graphics. It depends directly on Geom2D and, as we will see later, drawing does not imply having a graphical user interface in the program.
error
Nappgui Error types
gui
The Gui library allows you to create graphical user interfaces in a simple and intuitive way. Only available for desktop applications for obvious reasons, unlike the rest of libraries that can also be used in command line applications.
osapp
The OSApp library starts and manages the message cycle of a desktop application.
prelude
Enums and types
types
Wrapper inner types

Macros§

cell_dbind
Associates a cell with the field of a struct.
dbind
Adds a field from a structure to its internal table within DBind.
dbind_enum
Registers a value of type enum.
dbind_increment
Sets the increment of a numeric value, for example, when clicking an UpDown control.
dbind_range
Sets the maximum and minimum value in numeric fields.
include_resource
Embed resources
layout_dbind
Associates a cell with the field of a struct.
layout_dbind_obj
Associate an object with a layout to view and edit it.