Marc Balmer

lua-users home
wiki

Au clair de la lune... mailto:marc@msys.ch

My company micro systems, http://www.msys.ch/, uses Lua as scripting language for the http://www.arcapos.com/ POS systems.

LuaMotif a Lua and Motif integration. See also http://www.vnode.ch/lua_gui

Hello world, Motif style, in Lua:

require "motif"

button = PushButton {
	labelString = "Push here to say hello",
	activateCallback = function ()
		print("Hello yourself!")
	end
}

SetLanguageProc(nil, nil, nil)
toplevel, app = Initialize("XLua")

Realize(toplevel, button)
MainLoop(app)

And a fancier example:

require "motif"

gui = Form {
	fractionBase = 3,
	Frame {
		topAttachment = ATTACH_FORM,
		rightAttachment = ATTACH_FORM,
		bottomAttachment = ATTACH_POSITION,
		leftAttachment = ATTACH_FORM,

		bottomPosition = 1,

		LabelGadget {
			labelString = "Motif Buttons in Lua",
			childType = FRAME_TITLE_CHILD
		},
		RowColumn {
			PushButton {
				labelString = "Button one",
				activateCallback = function()
					print("Button one was pressed")
				end
			},
			PushButton {
				labelString = "Button two",
				activateCallback = function()
					print("Button two was pressed")
				end
			},
		}
	},
	Frame {
		topAttachment = ATTACH_POSITION,
		rightAttachment = ATTACH_POSITION,
		bottomAttachment = ATTACH_POSITION,
		leftAttachment = ATTACH_POSITION,

		topPosition = 1,
		bottomPosition = 2,
		rightPosition = 2,
		leftPosition = 1,

		LabelGadget {
			labelString = "frame fame",
			childType = FRAME_TITLE_CHILD
		},
		Form {
			PushButton {
				labelString = "pushme"
			}
		}
	},
	TabStack {
		topAttachment = ATTACH_POSITION,
		rightAttachment = ATTACH_FORM,
		bottomAttachment = ATTACH_FORM,
		leftAttachment = ATTACH_FORM,

		topPosition = 2,

		tabSide = TABS_ON_BOTTOM,
		tabStyle = TABS_ROUNDED,

		tabCornerPercent = 100,
		tabMarginHeight = 64,
		tabMarginWidth = 64,

		products = LabelGadget {
				labelString = "frame title",
				childVerticalAlignment = ALIGNMENT_CENTER,
		},
		groups = Frame {
			LabelGadget {
				labelString = "frame title",
				childType = FRAME_TITLE_CHILD,
				childVerticalAlignment = ALIGNMENT_CENTER,
			},
			rc = RowColumn {
				PushButton {
					labelString = "pushme",
					activateCallback = function (w)
						print(tf:GetString())
						tfield = w:Parent().t
						print(tfield:GetString())
					end
				},
				t = TextField {
					activateCallback = function (w)
						print(w:GetString())
					end,
					valueChangedCallback = function (w)
						print(w:GetString())
					end,
					focusCallback = function (w)
						print("Button down " ..
						    w:GetString())
					end
				}
			}
		},
		accounts = Label {
			labelString = "Buchhaltung"
		},
		ECRs = Label {
			labelString = "Kassen"
		}
	}

}

tf = gui[3].groups.rc.t

SetLanguageProc(nil, nil, nil)
toplevel, app = Initialize("XPoS")

Realize(toplevel, gui)

MainLoop(app)

RecentChanges · preferences
edit · history
Last edited April 6, 2012 9:18 am GMT (diff)