Native Windows GUI

Native Windows GUI is no longer maintained. The dev branch is where the lastest features are if you are in dire need of a Windows only GUI library

Native Windows GUI (NWG) is a thin GUI toolkit built over the Microsoft Windows WINAPI for rust. The current version is 0.2.0 BETA 1. The library is close to production ready, but still lacks some important features and some useful controls and resources.

NWG uses retep998/winapi-rs and works on all rust channels and most rust versions. NWG was tested on Windows 8.1 and Windows 10 using the MSVC ABI build, but any version of Microsoft Windows supported by Rust is supposed to be supported by NWG (vista and up).

NWG will not compile on the GNU toolchain. This is because comctl32.lib doesn't include a function required by NWG.

Why NWG?

Is native-windows-gui the gui framework you are looking for? It is ...

And it isn't...

Installation

To use NWG in your project add it to cargo.toml:

toml [dependencies] native-windows-gui = "0.2.1"

And then, in main.rs or lib.rs :

rust extern crate native_windows_gui as nwg;

Documentation

NWG has complete documentation, available here: https://gabdube.github.io/native-windows-gui/

The documentation alone should be enough to introduce to the basics of NWG.

(btw) If English is your first language (it's not mine), it would be super kind to give me feedback about quality of the docs.

Example

Having cargo installed and in your PATH, execute the following code to run the included example:
(scroll further down for a code example)

bash git clone git@github.com:gabdube/native-windows-gui.git cd native-windows-gui cargo run --example showcase cargo run --example canvas cargo run --example templating

A GUI

A GUI

Code example

```rust /** Simple example on how to use the nwg template system. */

//To hide console window

![windows_subsystem = "windows"]

[macrouse] extern crate nativewindows_gui as nwg;

use nwg::{Event, Ui, simplemessage, fatalmessage, dispatch_events};

/// Custom enums are the preferred way to define ui ids. It's clearer and more extensible than any other types (such as &'str).

[derive(Debug, Clone, Hash)]

pub enum AppId { // Controls MainWindow, NameInput, HelloButton, Label(u8), // Ids for static controls that won't be referenced in the Ui logic can be shortened this way.

// Events
SayHello,

// Resources
MainFont,
TextFont

}

use AppId::*; // Shortcut

nwgtemplate!( head: setupui, controls: [ (MainWindow, nwgwindow!( title="Template Example"; size=(280, 105) )), (Label(0), nwglabel!( parent=MainWindow; text="Your Name: "; position=(5,15); size=(80, 25); font=Some(TextFont) )), (NameInput, nwgtextinput!( parent=MainWindow; position=(85,13); size=(185,22); font=Some(TextFont) )), (HelloButton, nwgbutton!( parent=MainWindow; text="Hello World!"; position=(5, 45); size=(270, 50); font=Some(MainFont) )) ]; events: [ (HelloButton, SayHello, Event::Click, |ui,,,| { let yourname = nwgget!(ui; (NameInput, nwg::TextInput)); simplemessage("Hello", &format!("Hello {}!", yourname.gettext()) ); }) ]; resources: [ (MainFont, nwgfont!(family="Arial"; size=27)), (TextFont, nwgfont!(family="Arial"; size=17)) ]; values: [] );

fn main() { let app: Ui;

match Ui::new() {
    Ok(_app) => { app = _app; },
    Err(e) => { fatal_message("Fatal Error", &format!("{:?}", e) ); }
}

if let Err(e) = setup_ui(&app) {
    fatal_message("Fatal Error", &format!("{:?}", e));
}

dispatch_events();

} ```