2012-01-03 01:42:53 +01:00
|
|
|
rootWidget = g_ui.getRootWidget()
|
2011-08-26 17:06:52 +02:00
|
|
|
|
2012-01-03 01:42:53 +01:00
|
|
|
function importStyle(otui)
|
2012-01-05 02:28:29 +01:00
|
|
|
g_ui.importStyle(resolvepath(otui, 2))
|
|
|
|
end
|
|
|
|
|
|
|
|
function importFont(otfont)
|
|
|
|
g_fonts.importFont(resolvepath(otfont, 2))
|
|
|
|
end
|
|
|
|
|
|
|
|
function setDefaultFont(font)
|
|
|
|
g_fonts.setDefaultFont(font)
|
2012-01-03 01:42:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function displayUI(arg1, options)
|
2011-11-17 21:40:31 +01:00
|
|
|
local widget
|
|
|
|
local parent
|
|
|
|
if options then parent = options.parent end
|
2012-01-03 01:42:53 +01:00
|
|
|
parent = parent or rootWidget
|
2011-08-26 17:06:52 +02:00
|
|
|
|
2011-11-17 21:40:31 +01:00
|
|
|
-- display otui files
|
|
|
|
if type(arg1) == 'string' then
|
2012-01-05 02:28:29 +01:00
|
|
|
local otuiFilePath = resolvepath(arg1, 2)
|
2012-01-03 01:42:53 +01:00
|
|
|
widget = g_ui.loadUI(otuiFilePath, parent)
|
2011-11-17 21:40:31 +01:00
|
|
|
-- display already loaded widgets
|
|
|
|
else
|
|
|
|
widget = arg1
|
|
|
|
if parent:hasChild(widget) then
|
|
|
|
widget:focus()
|
|
|
|
widget:show()
|
|
|
|
else
|
|
|
|
parent:addChild(widget)
|
|
|
|
widget:show()
|
|
|
|
end
|
|
|
|
end
|
2011-08-26 17:06:52 +02:00
|
|
|
|
2011-11-17 21:40:31 +01:00
|
|
|
-- apply display options
|
|
|
|
if widget and options then
|
|
|
|
for option,value in pairs(options) do
|
|
|
|
if option == 'locked' and value then
|
|
|
|
widget:lock()
|
|
|
|
elseif option == 'visible' then
|
|
|
|
widget:setVisible(value)
|
2012-01-02 21:46:40 +01:00
|
|
|
elseif option == 'x' then
|
|
|
|
widget:setX(value)
|
|
|
|
elseif option == 'y' then
|
|
|
|
widget:setY(value)
|
2011-11-17 21:40:31 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return widget
|
2011-08-26 17:06:52 +02:00
|
|
|
end
|
2012-01-03 01:42:53 +01:00
|
|
|
|
|
|
|
function createWidget(style, parent)
|
|
|
|
local className = g_ui.getStyleClass(style)
|
2012-01-04 12:24:29 +01:00
|
|
|
if className == "" then
|
|
|
|
error('could not find style ' .. style)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-01-03 01:42:53 +01:00
|
|
|
local class = _G[className]
|
2012-01-04 12:24:29 +01:00
|
|
|
if not class then
|
|
|
|
error('could not find widget class ' .. class)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-01-03 01:42:53 +01:00
|
|
|
local widget = class.create()
|
|
|
|
if parent then
|
2012-01-10 23:13:40 +01:00
|
|
|
if type(parent) == 'string' then
|
|
|
|
parent = rootWidget:recursiveGetChildById(parent)
|
|
|
|
end
|
2012-01-03 01:42:53 +01:00
|
|
|
parent:addChild(widget)
|
|
|
|
end
|
|
|
|
widget:setStyle(style)
|
|
|
|
return widget
|
|
|
|
end
|