--[[********************************************************]]-- --[[ Set up a table to reference the objects in AMS ]]-- --[[********************************************************]]-- tbObjectType = {} tbObjectType[OBJECT_BUTTON] = Button; tbObjectType[OBJECT_LABEL] = Label; tbObjectType[OBJECT_PARAGRAPH] = Paragraph; tbObjectType[OBJECT_IMAGE] = Image; tbObjectType[OBJECT_FLASH] = Flash; tbObjectType[OBJECT_VIDEO] = Video; tbObjectType[OBJECT_WEB] = Web; tbObjectType[OBJECT_INPUT] = Input; tbObjectType[OBJECT_HOTSPOT] = Hotspot; tbObjectType[OBJECT_LISTBOX] = ListBox; tbObjectType[OBJECT_COMBOBOX] = ComboBox; tbObjectType[OBJECT_PROGRESS] = Progress; tbObjectType[OBJECT_TREE] = Tree; tbObjectType[OBJECT_RADIOBUTTON] = RadioButton; tbObjectType[OBJECT_RICHTEXT] = RichText; tbObjectType[OBJECT_CHECKBOX] = CheckBox; tbObjectType[OBJECT_SLIDESHOW] = SlideShow; tbObjectType[OBJECT_GRID] = Grid; tbObjectType[OBJECT_PLUGIN] = Plugin; --[[********************************************************]]-- --[[ Group Actions ]]-- --[[********************************************************]]-- m_tblGroup = {}; GroupEX = {}; --################################################################################################### GroupEX.AddItem = function (sObjectName, sGroupName) local nIndex = Table.Count(m_tblGroup) + 1; Table.Insert(m_tblGroup, nIndex, {}) m_tblGroup[nIndex].Group = sGroupName; m_tblGroup[nIndex].Object = sObjectName; m_tblGroup[nIndex].ObjectType = Page.GetObjectType(sObjectName); end --################################################################################################### GroupEX.RemoveItem = function (sObjectName, sGroupName) for i in m_tblGroup do if m_tblGroup[i].Group == sGroupName and m_tblGroup[i].Object == sObjectName then Table.Remove(m_tblGroup, i); break; end end end --################################################################################################### GroupEX.SetVisible = function (sGroupName, bVisible, bRedraw = false) Application.SetRedraw(bRedraw) for i in m_tblGroup do if m_tblGroup[i].Group == sGroupName then local Object = tbObjectType[m_tblGroup[i].ObjectType]; if Object.SetVisible then local Name = m_tblGroup[i].Object Object.SetVisible(Name, bVisible) end end end Application.SetRedraw(true) end --################################################################################################### GroupEX.SetEnabled = function (sGroupName, bEnable, bRedraw=false) Application.SetRedraw(bRedraw) for i in m_tblGroup do if m_tblGroup[i].Group == sGroupName then local Object = tbObjectType[m_tblGroup[i].ObjectType]; if Object.SetEnabled then local Name = m_tblGroup[i].Object Object.SetEnabled(Name, bEnable) end end end Application.SetRedraw(true) end --################################################################################################### GroupEX.Move = function (sGroupName, xDiff, yDiff, bRedraw) Application.SetRedraw(bRedraw) for i in m_tblGroup do if m_tblGroup[i].Group == sGroupName then local Object = tbObjectType[m_tblGroup[i].ObjectType]; local Name = m_tblGroup[i].Object if Object.SetPos then Object.SetPos(Name, Object.GetPos(Name).X + xDiff, Object.GetPos(Name).Y + yDiff) end end end Application.SetRedraw(true) end --################################################################################################### GroupEX.IsVisible = function (sGroupName) for i in m_tblGroup do if m_tblGroup[i].Group == sGroupName then local Object = tbObjectType[m_tblGroup[i].ObjectType]; if Object.IsVisible then local Name = m_tblGroup[i].Object return Object.IsVisible(Name) end end end end --################################################################################################### GroupEX.IsEnabled = function (sGroupName) for i in m_tblGroup do if m_tblGroup[i].Group == sGroupName then local Object = tbObjectType[m_tblGroup[i].ObjectType]; if Object.IsEnabled then local Name = m_tblGroup[i].Object return Object.IsEnabled(Name) end end end end --################################################################################################### GroupEX.Count = function (sGroupName) local nCount=0 for i in m_tblGroup do if m_tblGroup[i].Group == sGroupName then nCount=nCount+1 end end return nCount end --################################################################################################### GroupEX.CreateObject = function (sObjName,cObjType,tbObjProps,sGroupName) Page.CreateObject(cObjType,sObjName,tbObjProps); local error = Application.GetLastError(); if (error ~= 0) then return error else Group.AddItem(sObjName, sGroupName); return 0 end end --################################################################################################### GroupEX.DeleteObject = function (sObjName,sGroupName) Group.RemoveItem(sObjName, sGroupName); Page.DeleteObject(sObjName); local error = Application.GetLastError(); if (error ~= 0) then return error else return 0 end end --################################################################################################### GroupEX.IsObject = function (sObjName) local strReturn = "" for i, sGroup in m_tblGroup do local strObject = m_tblGroup[i].Object if strObject == sObjName then strReturn = m_tblGroup[i].Group break end end return strReturn end --###################################################################################################