Mercurial > wow > itemauditor
comparison Libs/AceGUI-3.0/widgets/AceGUIWidget-Window.lua @ 0:169f5211fc7f
First public revision.
At this point ItemAuditor watches mail for auctions sold or purchased, watches for buy/sell (money and 1 item type change) and conversions/tradeskills. Milling isn't working yet because there is too much time between the first event and the last event.
| author | Asa Ayers <Asa.Ayers@Gmail.com> |
|---|---|
| date | Thu, 20 May 2010 19:22:19 -0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:169f5211fc7f |
|---|---|
| 1 local AceGUI = LibStub("AceGUI-3.0") | |
| 2 | |
| 3 -- Lua APIs | |
| 4 local pairs, assert, type = pairs, assert, type | |
| 5 | |
| 6 -- WoW APIs | |
| 7 local CreateFrame, UIParent = CreateFrame, UIParent | |
| 8 | |
| 9 -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded | |
| 10 -- List them here for Mikk's FindGlobals script | |
| 11 -- GLOBALS: GameFontNormal | |
| 12 | |
| 13 ---------------- | |
| 14 -- Main Frame -- | |
| 15 ---------------- | |
| 16 --[[ | |
| 17 Events : | |
| 18 OnClose | |
| 19 | |
| 20 ]] | |
| 21 do | |
| 22 local Type = "Window" | |
| 23 local Version = 2 | |
| 24 | |
| 25 local function frameOnClose(this) | |
| 26 this.obj:Fire("OnClose") | |
| 27 end | |
| 28 | |
| 29 local function closeOnClick(this) | |
| 30 this.obj:Hide() | |
| 31 end | |
| 32 | |
| 33 local function frameOnMouseDown(this) | |
| 34 AceGUI:ClearFocus() | |
| 35 end | |
| 36 | |
| 37 local function titleOnMouseDown(this) | |
| 38 this:GetParent():StartMoving() | |
| 39 AceGUI:ClearFocus() | |
| 40 end | |
| 41 | |
| 42 local function frameOnMouseUp(this) | |
| 43 local frame = this:GetParent() | |
| 44 frame:StopMovingOrSizing() | |
| 45 local self = frame.obj | |
| 46 local status = self.status or self.localstatus | |
| 47 status.width = frame:GetWidth() | |
| 48 status.height = frame:GetHeight() | |
| 49 status.top = frame:GetTop() | |
| 50 status.left = frame:GetLeft() | |
| 51 end | |
| 52 | |
| 53 local function sizerseOnMouseDown(this) | |
| 54 this:GetParent():StartSizing("BOTTOMRIGHT") | |
| 55 AceGUI:ClearFocus() | |
| 56 end | |
| 57 | |
| 58 local function sizersOnMouseDown(this) | |
| 59 this:GetParent():StartSizing("BOTTOM") | |
| 60 AceGUI:ClearFocus() | |
| 61 end | |
| 62 | |
| 63 local function sizereOnMouseDown(this) | |
| 64 this:GetParent():StartSizing("RIGHT") | |
| 65 AceGUI:ClearFocus() | |
| 66 end | |
| 67 | |
| 68 local function sizerOnMouseUp(this) | |
| 69 this:GetParent():StopMovingOrSizing() | |
| 70 end | |
| 71 | |
| 72 local function SetTitle(self,title) | |
| 73 self.titletext:SetText(title) | |
| 74 end | |
| 75 | |
| 76 local function SetStatusText(self,text) | |
| 77 -- self.statustext:SetText(text) | |
| 78 end | |
| 79 | |
| 80 local function Hide(self) | |
| 81 self.frame:Hide() | |
| 82 end | |
| 83 | |
| 84 local function Show(self) | |
| 85 self.frame:Show() | |
| 86 end | |
| 87 | |
| 88 local function OnAcquire(self) | |
| 89 self.frame:SetParent(UIParent) | |
| 90 self.frame:SetFrameStrata("FULLSCREEN_DIALOG") | |
| 91 self:ApplyStatus() | |
| 92 self:EnableResize(true) | |
| 93 end | |
| 94 | |
| 95 local function OnRelease(self) | |
| 96 self.status = nil | |
| 97 for k in pairs(self.localstatus) do | |
| 98 self.localstatus[k] = nil | |
| 99 end | |
| 100 end | |
| 101 | |
| 102 -- called to set an external table to store status in | |
| 103 local function SetStatusTable(self, status) | |
| 104 assert(type(status) == "table") | |
| 105 self.status = status | |
| 106 self:ApplyStatus() | |
| 107 end | |
| 108 | |
| 109 local function ApplyStatus(self) | |
| 110 local status = self.status or self.localstatus | |
| 111 local frame = self.frame | |
| 112 self:SetWidth(status.width or 700) | |
| 113 self:SetHeight(status.height or 500) | |
| 114 if status.top and status.left then | |
| 115 frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top) | |
| 116 frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0) | |
| 117 else | |
| 118 frame:SetPoint("CENTER",UIParent,"CENTER") | |
| 119 end | |
| 120 end | |
| 121 | |
| 122 local function OnWidthSet(self, width) | |
| 123 local content = self.content | |
| 124 local contentwidth = width - 34 | |
| 125 if contentwidth < 0 then | |
| 126 contentwidth = 0 | |
| 127 end | |
| 128 content:SetWidth(contentwidth) | |
| 129 content.width = contentwidth | |
| 130 end | |
| 131 | |
| 132 | |
| 133 local function OnHeightSet(self, height) | |
| 134 local content = self.content | |
| 135 local contentheight = height - 57 | |
| 136 if contentheight < 0 then | |
| 137 contentheight = 0 | |
| 138 end | |
| 139 content:SetHeight(contentheight) | |
| 140 content.height = contentheight | |
| 141 end | |
| 142 | |
| 143 local function EnableResize(self, state) | |
| 144 local func = state and "Show" or "Hide" | |
| 145 self.sizer_se[func](self.sizer_se) | |
| 146 self.sizer_s[func](self.sizer_s) | |
| 147 self.sizer_e[func](self.sizer_e) | |
| 148 end | |
| 149 | |
| 150 local function Constructor() | |
| 151 local frame = CreateFrame("Frame",nil,UIParent) | |
| 152 local self = {} | |
| 153 self.type = "Window" | |
| 154 | |
| 155 self.Hide = Hide | |
| 156 self.Show = Show | |
| 157 self.SetTitle = SetTitle | |
| 158 self.OnRelease = OnRelease | |
| 159 self.OnAcquire = OnAcquire | |
| 160 self.SetStatusText = SetStatusText | |
| 161 self.SetStatusTable = SetStatusTable | |
| 162 self.ApplyStatus = ApplyStatus | |
| 163 self.OnWidthSet = OnWidthSet | |
| 164 self.OnHeightSet = OnHeightSet | |
| 165 self.EnableResize = EnableResize | |
| 166 | |
| 167 self.localstatus = {} | |
| 168 | |
| 169 self.frame = frame | |
| 170 frame.obj = self | |
| 171 frame:SetWidth(700) | |
| 172 frame:SetHeight(500) | |
| 173 frame:SetPoint("CENTER",UIParent,"CENTER",0,0) | |
| 174 frame:EnableMouse() | |
| 175 frame:SetMovable(true) | |
| 176 frame:SetResizable(true) | |
| 177 frame:SetFrameStrata("FULLSCREEN_DIALOG") | |
| 178 frame:SetScript("OnMouseDown", frameOnMouseDown) | |
| 179 | |
| 180 frame:SetScript("OnHide",frameOnClose) | |
| 181 frame:SetMinResize(240,240) | |
| 182 frame:SetToplevel(true) | |
| 183 | |
| 184 local titlebg = frame:CreateTexture(nil, "BACKGROUND") | |
| 185 titlebg:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Title-Background]]) | |
| 186 titlebg:SetPoint("TOPLEFT", 9, -6) | |
| 187 titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24) | |
| 188 | |
| 189 local dialogbg = frame:CreateTexture(nil, "BACKGROUND") | |
| 190 dialogbg:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]]) | |
| 191 dialogbg:SetPoint("TOPLEFT", 8, -24) | |
| 192 dialogbg:SetPoint("BOTTOMRIGHT", -6, 8) | |
| 193 dialogbg:SetVertexColor(0, 0, 0, .75) | |
| 194 | |
| 195 local topleft = frame:CreateTexture(nil, "BORDER") | |
| 196 topleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) | |
| 197 topleft:SetWidth(64) | |
| 198 topleft:SetHeight(64) | |
| 199 topleft:SetPoint("TOPLEFT") | |
| 200 topleft:SetTexCoord(0.501953125, 0.625, 0, 1) | |
| 201 | |
| 202 local topright = frame:CreateTexture(nil, "BORDER") | |
| 203 topright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) | |
| 204 topright:SetWidth(64) | |
| 205 topright:SetHeight(64) | |
| 206 topright:SetPoint("TOPRIGHT") | |
| 207 topright:SetTexCoord(0.625, 0.75, 0, 1) | |
| 208 | |
| 209 local top = frame:CreateTexture(nil, "BORDER") | |
| 210 top:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) | |
| 211 top:SetHeight(64) | |
| 212 top:SetPoint("TOPLEFT", topleft, "TOPRIGHT") | |
| 213 top:SetPoint("TOPRIGHT", topright, "TOPLEFT") | |
| 214 top:SetTexCoord(0.25, 0.369140625, 0, 1) | |
| 215 | |
| 216 local bottomleft = frame:CreateTexture(nil, "BORDER") | |
| 217 bottomleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) | |
| 218 bottomleft:SetWidth(64) | |
| 219 bottomleft:SetHeight(64) | |
| 220 bottomleft:SetPoint("BOTTOMLEFT") | |
| 221 bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1) | |
| 222 | |
| 223 local bottomright = frame:CreateTexture(nil, "BORDER") | |
| 224 bottomright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) | |
| 225 bottomright:SetWidth(64) | |
| 226 bottomright:SetHeight(64) | |
| 227 bottomright:SetPoint("BOTTOMRIGHT") | |
| 228 bottomright:SetTexCoord(0.875, 1, 0, 1) | |
| 229 | |
| 230 local bottom = frame:CreateTexture(nil, "BORDER") | |
| 231 bottom:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) | |
| 232 bottom:SetHeight(64) | |
| 233 bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT") | |
| 234 bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT") | |
| 235 bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1) | |
| 236 | |
| 237 local left = frame:CreateTexture(nil, "BORDER") | |
| 238 left:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) | |
| 239 left:SetWidth(64) | |
| 240 left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT") | |
| 241 left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT") | |
| 242 left:SetTexCoord(0.001953125, 0.125, 0, 1) | |
| 243 | |
| 244 local right = frame:CreateTexture(nil, "BORDER") | |
| 245 right:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]]) | |
| 246 right:SetWidth(64) | |
| 247 right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT") | |
| 248 right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT") | |
| 249 right:SetTexCoord(0.1171875, 0.2421875, 0, 1) | |
| 250 | |
| 251 local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton") | |
| 252 close:SetPoint("TOPRIGHT", 2, 1) | |
| 253 close:SetScript("OnClick", closeOnClick) | |
| 254 self.closebutton = close | |
| 255 close.obj = self | |
| 256 | |
| 257 local titletext = frame:CreateFontString(nil, "ARTWORK") | |
| 258 titletext:SetFontObject(GameFontNormal) | |
| 259 titletext:SetPoint("TOPLEFT", 12, -8) | |
| 260 titletext:SetPoint("TOPRIGHT", -32, -8) | |
| 261 self.titletext = titletext | |
| 262 | |
| 263 local title = CreateFrame("Button", nil, frame) | |
| 264 title:SetPoint("TOPLEFT", titlebg) | |
| 265 title:SetPoint("BOTTOMRIGHT", titlebg) | |
| 266 title:EnableMouse() | |
| 267 title:SetScript("OnMouseDown",titleOnMouseDown) | |
| 268 title:SetScript("OnMouseUp", frameOnMouseUp) | |
| 269 self.title = title | |
| 270 | |
| 271 local sizer_se = CreateFrame("Frame",nil,frame) | |
| 272 sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) | |
| 273 sizer_se:SetWidth(25) | |
| 274 sizer_se:SetHeight(25) | |
| 275 sizer_se:EnableMouse() | |
| 276 sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown) | |
| 277 sizer_se:SetScript("OnMouseUp", sizerOnMouseUp) | |
| 278 self.sizer_se = sizer_se | |
| 279 | |
| 280 local line1 = sizer_se:CreateTexture(nil, "BACKGROUND") | |
| 281 self.line1 = line1 | |
| 282 line1:SetWidth(14) | |
| 283 line1:SetHeight(14) | |
| 284 line1:SetPoint("BOTTOMRIGHT", -8, 8) | |
| 285 line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") | |
| 286 local x = 0.1 * 14/17 | |
| 287 line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) | |
| 288 | |
| 289 local line2 = sizer_se:CreateTexture(nil, "BACKGROUND") | |
| 290 self.line2 = line2 | |
| 291 line2:SetWidth(8) | |
| 292 line2:SetHeight(8) | |
| 293 line2:SetPoint("BOTTOMRIGHT", -8, 8) | |
| 294 line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") | |
| 295 local x = 0.1 * 8/17 | |
| 296 line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) | |
| 297 | |
| 298 local sizer_s = CreateFrame("Frame",nil,frame) | |
| 299 sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0) | |
| 300 sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) | |
| 301 sizer_s:SetHeight(25) | |
| 302 sizer_s:EnableMouse() | |
| 303 sizer_s:SetScript("OnMouseDown",sizersOnMouseDown) | |
| 304 sizer_s:SetScript("OnMouseUp", sizerOnMouseUp) | |
| 305 self.sizer_s = sizer_s | |
| 306 | |
| 307 local sizer_e = CreateFrame("Frame",nil,frame) | |
| 308 sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25) | |
| 309 sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0) | |
| 310 sizer_e:SetWidth(25) | |
| 311 sizer_e:EnableMouse() | |
| 312 sizer_e:SetScript("OnMouseDown",sizereOnMouseDown) | |
| 313 sizer_e:SetScript("OnMouseUp", sizerOnMouseUp) | |
| 314 self.sizer_e = sizer_e | |
| 315 | |
| 316 --Container Support | |
| 317 local content = CreateFrame("Frame",nil,frame) | |
| 318 self.content = content | |
| 319 content.obj = self | |
| 320 content:SetPoint("TOPLEFT",frame,"TOPLEFT",12,-32) | |
| 321 content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-12,13) | |
| 322 | |
| 323 AceGUI:RegisterAsContainer(self) | |
| 324 return self | |
| 325 end | |
| 326 | |
| 327 AceGUI:RegisterWidgetType(Type,Constructor,Version) | |
| 328 end |
