annotate Modules/Frames.lua @ 144:03e108d12ef1

Ticket 45 - Added the ability suppress COD warnings when mailing to characters on other accounts in Altoholic/DataStore. Instead of sending COD, ItemAuditor will send tracking info in the message. Thanks to Zerotorescue for giving me the solution to detect whether or not Postal or MailOpener is processing. It was the last step holding this back from being released.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Sat, 09 Oct 2010 00:21:06 -0700
parents f37ab41f1928
children fbfd9dfa6d2b
rev   line source
Asa@63 1 local ItemAuditor = select(2, ...)
Asa@63 2 local Frames = ItemAuditor:NewModule("Frames")
Asa@58 3
Asa@58 4 local AceGUI = LibStub("AceGUI-3.0")
Asa@58 5
Asa@58 6 local tabs = {}
Asa@58 7
Asa@65 8 function Frames.RegisterTab(text, value, callback)
Asa@59 9 tabs[value] = {text=text, callback=callback}
Asa@58 10 end
Asa@58 11
Asa@58 12 local displayFrame = false
Asa@58 13 local currentContent = false
Asa@58 14 local function switchTab(container, event, group)
Asa@58 15 if tabs[group] == nil then
Asa@58 16 error(format("Invaid tab name: %s", tostring(group)))
Asa@58 17 end
Asa@58 18 local cb = tabs[group].callback
Asa@58 19
Asa@58 20 container:ReleaseChildren()
Asa@58 21
Asa@58 22 if currentContent then
Asa@58 23 currentContent:Hide()
Asa@58 24 if displayFrame then
Asa@58 25 displayFrame:SetStatusText('')
Asa@58 26 end
Asa@58 27 end
Asa@59 28
Asa@58 29 currentContent = cb(container)
Asa@58 30 end
Asa@58 31
Asa@65 32 function Frames.CreateFrame(selectedTab)
Asa@59 33
Asa@58 34 if not displayFrame then
Asa@58 35 -- Create the frame container
Asa@58 36 displayFrame = AceGUI:Create("Frame")
Asa@58 37 ItemAuditor:RegisterFrame(displayFrame)
Asa@58 38 local window = displayFrame.frame;
Asa@58 39 -- I have no idea why AceGUI insists on using FULLSCREEN_DIALOG by default.
Asa@58 40 window:SetFrameStrata("MEDIUM")
Asa@58 41 displayFrame:SetTitle("ItemAuditor")
Asa@58 42 displayFrame:SetStatusText("")
Asa@58 43
Asa@58 44 displayFrame:SetLayout("Fill")
Asa@58 45
Asa@58 46 window:SetHeight(500);
Asa@58 47
Asa@58 48 local tabSet = {}
Asa@58 49 for key, data in pairs(tabs) do
Asa@58 50 tinsert(tabSet, {text=data['text'], value=key})
Asa@58 51 -- Default to the first tab.
Asa@58 52 if not selectedTab then
Asa@58 53 selectedTab = key
Asa@58 54 end
Asa@58 55 end
Asa@58 56 -- Each tab can adjust the width as needed.
Asa@58 57 window:SetWidth(300);
Asa@58 58
Asa@58 59 displayFrame.tab = AceGUI:Create("TabGroup")
Asa@58 60 displayFrame.tab:SetLayout("Flow")
Asa@58 61 displayFrame.tab:SetTabs(tabSet)
Asa@58 62 displayFrame.tab:SetCallback("OnGroupSelected", switchTab)
Asa@58 63
Asa@58 64
Asa@58 65 displayFrame:AddChild(displayFrame.tab)
Asa@58 66 end
Asa@130 67
Asa@130 68 displayFrame.frame:Raise()
Asa@58 69
Asa@58 70 if not selectedTab then
Asa@58 71 for key in pairs(tabs) do
Asa@58 72 selectedTab = key
Asa@58 73 break
Asa@58 74 end
Asa@58 75 end
Asa@58 76
Asa@58 77 displayFrame.tab:SelectTab(selectedTab)
Asa@58 78 displayFrame:Show()
Asa@58 79 end
Asa@58 80
Asa@65 81 function Frames.UpdateStatusText(message)
Asa@58 82 if displayFrame then
Asa@58 83 displayFrame:SetStatusText(message)
Asa@58 84 end
Asa@65 85 end
Asa@65 86
Asa@65 87 function ItemAuditor:UpdateStatusText(message)
Asa@65 88 return Frames.UpdateStatusText(message)
Asa@65 89 end
Asa@65 90
Asa@65 91 function ItemAuditor:RegisterTab(text, value, callback)
Asa@65 92 return Frames.RegisterTab(text, value, callback)
Asa@65 93 end
Asa@65 94
Asa@65 95 function ItemAuditor:CreateFrame(selectedTab)
Asa@65 96 Frames.CreateFrame(selectedTab)
Asa@65 97 end