0 Members and 7 Guests are viewing this topic.
tabcontrol = class()function tabcontrol:init(x, y, width, height, tabcpntr, parent) self.x = x + parent.x self.y = y + parent.y self.xoff = x self.yoff = y self.width = width self.height = height self.parent = parent self.controls = {} self.tabcollection = tabcpntr self.curtab = startingtab self.tabcount = table.maxn(self.tabcollection) table.insert(parent.controls, self)endfunction tabcontrol:paint(gc) stroff = gc:getStringWidth("SOF") - 6 gc:setColorRGB(unpack(color.white)) gc:fillRect(self.x, self.y, self.width, self.height) gc:setColorRGB(unpack(color.black)) gc:drawRect(self.x, self.y, self.width, self.height) gc:drawRect(self.x, self.y - stroff, self.width, stroff) gc:setFont("sansserif", "r", 6) local y = self.y - 8 local x = self.x + 2 for _, bb in pairs(self.tabcollection) do bb.x = x bb.y = y bb.width = gc:getStringWidth(bb.text) bb.height = gc:getStringHeight(bb.text) if bb.selected then gc:setColorRGB(unpack(color.Bdark)) gc:fillRect(bb.x - 2, bb.y - 2, bb.width + 2, bb. height - 4) gc:setColorRGB(unpack(color.black)) end gc:drawRect(bb.x - 2, bb.y - 2, bb.width + 2, bb.height - 4) gc:drawString(bb.text, x, y, "middle") x = x + 5 + bb.width endendfunction tabcontrol:checkClick(x, y)endfunction tabcontrol:clicked(x, y)endfunction tabcontrol:getCurTab() for _, tabs in pairs(self.tabcollection) do if tabs.selected then return tabs end endend
Tabs = {tab4 = {text = "Tab3", selected = false}, tab2 = {text = "Tab1", selected = true}, tab3 = {text = "Tab2", selected = false}, tab1 = {text = "Tab4", selected = false}}
Oh and there's one thing i've seen on some places, what's that "for __," part? i mean, what does that __ sign to?