new lua function for creating widgets: createWidget

This commit is contained in:
Eduardo Bart
2012-01-02 22:42:53 -02:00
parent 9fbdf3f5cb
commit 05230f44e4
29 changed files with 137 additions and 120 deletions

View File

@@ -1,17 +1,21 @@
UI = { }
UI.root = getRootWidget()
-- globals
rootWidget = g_ui.getRootWidget()
-- public functions
function UI.display(arg1, options)
function importStyle(otui)
g_ui.importStyle(resolveFileFullPath(otui, 2))
end
function displayUI(arg1, options)
local widget
local parent
if options then parent = options.parent end
parent = parent or UI.root
parent = parent or rootWidget
-- display otui files
if type(arg1) == 'string' then
local otuiFilePath = resolveFileFullPath(arg1, 2)
widget = loadUI(otuiFilePath, parent)
widget = g_ui.loadUI(otuiFilePath, parent)
-- display already loaded widgets
else
widget = arg1
@@ -40,3 +44,14 @@ function UI.display(arg1, options)
end
return widget
end
function createWidget(style, parent)
local className = g_ui.getStyleClass(style)
local class = _G[className]
local widget = class.create()
if parent then
parent:addChild(widget)
end
widget:setStyle(style)
return widget
end