lights FAQ Forum github.com/luapower/winapi

Native OS APIs
winapi
winapi.wglpanel
winapi.cairopanel
objc
xlib

winapi

Win32 windows & controls


Scope

Windows, common controls and dialogs, message loop and system APIs.

Features

  • UTF8 Lua strings everywhere (also works with wide char buffers)
  • bitmap widget for custom painting
  • OpenGL and cairo custom-painting widgets (in separate packages)
  • anchor-based layout model for all controls
  • object system with virtual properties (win.title = 'hello' sets the title)
  • binding helpers for easy binding of new and future APIs
  • all calls are error-checked
  • automatic memory management (ownership; buffers)
  • flags can be passed as 'FLAG1 FLAG2'
  • counting from 1 everywhere.

Status

Current status and issues.

Hello World

local winapi = require'winapi'
require'winapi.windowclass'

local win = winapi.Window{
   w = 500,                --all these are "initial fields"
   h = 300,
   title = 'Lua rulez',
   autoquit = true,        --this is to quit app when the window is closed
   visible = false,        --this field is from BaseWindow
}

function win:on_close()    --this is an event handler
   print'Bye'
end

print(win.title)           --this is how to read the value of a property
win.title = 'Lua rulez!'   --this is how to set the value of a property
win:show()                 --this is a method call

os.exit(winapi.MessageLoop()) --start the message loop

Demos

Check out winapi_demo to see all the controls in action:

screnshot

screnshot

Also, many modules can be run as standalone scripts, which will showcase their functionality, so there's lots of little demos there too.

Documentation

Architecture

Classes

  • Object - objects
    • VObject - objects with virtual properties
      • BaseWindow - base class for top-level windows and controls
        • Window - final class for top level windows
        • Control - base class for controls
          • Panel - custom-painted child windows
          • Label - labels
          • BaseButton - base class for buttons
          • Edit - edit boxes
          • ComboBox - combo boxes and drop-down lists
          • ListBox - list boxes
          • [ListView][winapi.listviewclass] - list views
          • [TabControl][winapi.tabcontrolclass] - tab bars
          • [Toolbar][winapi.toolbarclass] - toolbars
        • [Tooltip][winapi.tooltipclass] - tooltips
      • [Menu][winapi.menuclass] - menus and menu bars
      • [NotifyIcon][winapi.notifyiconclass] - system tray icons

Functions

The "proc" layer is documented in the code, including API quirks and empirical knowledge, so do check out the source code.

Modules


Last updated: 11 months ago | Edit on GitHub

Pkg type:other
Version: r5-3-g401c2da
Last commit:
License: Public Domain
Requires: none
Required by: none

Top