You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.5 KiB
74 lines
1.5 KiB
13 years ago
|
rootWidget = g_ui.getRootWidget()
|
||
13 years ago
|
|
||
13 years ago
|
function importStyle(otui)
|
||
13 years ago
|
g_ui.importStyle(resolvepath(otui, 2))
|
||
|
end
|
||
|
|
||
|
function importFont(otfont)
|
||
|
g_fonts.importFont(resolvepath(otfont, 2))
|
||
|
end
|
||
|
|
||
|
function setDefaultFont(font)
|
||
|
g_fonts.setDefaultFont(font)
|
||
13 years ago
|
end
|
||
|
|
||
|
function displayUI(arg1, options)
|
||
13 years ago
|
local widget
|
||
|
local parent
|
||
|
if options then parent = options.parent end
|
||
13 years ago
|
parent = parent or rootWidget
|
||
13 years ago
|
|
||
13 years ago
|
-- display otui files
|
||
|
if type(arg1) == 'string' then
|
||
13 years ago
|
local otuiFilePath = resolvepath(arg1, 2)
|
||
13 years ago
|
widget = g_ui.loadUI(otuiFilePath, parent)
|
||
13 years ago
|
-- display already loaded widgets
|
||
|
else
|
||
|
widget = arg1
|
||
|
if parent:hasChild(widget) then
|
||
|
widget:focus()
|
||
|
widget:show()
|
||
|
else
|
||
|
parent:addChild(widget)
|
||
|
widget:show()
|
||
|
end
|
||
|
end
|
||
13 years ago
|
|
||
13 years ago
|
-- 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)
|
||
13 years ago
|
elseif option == 'x' then
|
||
|
widget:setX(value)
|
||
|
elseif option == 'y' then
|
||
|
widget:setY(value)
|
||
13 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
return widget
|
||
13 years ago
|
end
|
||
13 years ago
|
|
||
|
function createWidget(style, parent)
|
||
|
local className = g_ui.getStyleClass(style)
|
||
13 years ago
|
if className == "" then
|
||
|
error('could not find style ' .. style)
|
||
|
return
|
||
|
end
|
||
|
|
||
13 years ago
|
local class = _G[className]
|
||
13 years ago
|
if not class then
|
||
|
error('could not find widget class ' .. class)
|
||
|
return
|
||
|
end
|
||
|
|
||
13 years ago
|
local widget = class.create()
|
||
|
if parent then
|
||
|
parent:addChild(widget)
|
||
|
end
|
||
|
widget:setStyle(style)
|
||
|
return widget
|
||
|
end
|