0 Members and 1 Guest are viewing this topic.
----------------------textbox-------------------------------------------textbox = class()function textbox:init(x, y, width, text, textcolor, tbcolor, parent, selected) self.parent = parent self.x = x + parent.x self.y = y + parent.y self.xoff = x self.yoff = y self.width = width if self.width < 10 then self.width = 10 end self.height = 11 self.text = text self.textcolor = textcolor self.tbcolor = tbcolor self.selected = selected self.cury = self.y + 1 self.curx = self.x + 1 self.curh = (self.y + self.height) - 1 self.parent = parent self.type = "txt" self.stwid = 0 self.dIndex = 1 self.initial = true self.bsflag = false table.insert(parent.controls, self)endfunction textbox:paint(gc) self.stwid = gc:getStringWidth(self.text) if self.initial == true then local dtext = self.text while gc:getStringWidth(dtext) >= self.width - 1 do dtext = string.sub(dtext, 2) end self.initial = false self.dIndex = string.find(self.text, dtext) else while gc:getStringWidth(string.sub(self.text, self.dIndex)) >= self.width and self.bsflag == false do self.dIndex = self.dIndex + 1 self.dText = string.sub(self.text, self.dIndex) end if self.bsflag == true then self.text = string.sub(self.text, 1, string.len(self.text) - 1) if string.len(self.text) > string.len(string.sub(self.text, self.dIndex)) then self.dIndex = self.dIndex - 1 while gc:getStringWidth(string.sub(self.text, self.dIndex)) >= self.width do self.dIndex = self.dIndex + 1 self.dText = string.sub(self.text, self.dIndex) end end end end self.bsflag = false gc:setColorRGB(unpack(self.tbcolor)) gc:drawRect( self.x, self.y, self.width + 3, self.height) gc:setColorRGB(unpack(self.textcolor)) gc:setFont("sansserif", "r", 8) self.stwid = gc:drawString( string.sub(self.text, self.dIndex), self.x + 4, self.y + 3, "middle") gc:setColorRGB(unpack(color.black)) self.cury = self.y + 1 self.curx = self.x + gc:getStringWidth(string.sub(self.text, self.dIndex)) + 3 self.curh = (self.y + self.height) - 1 gc:drawLine(self.curx, self.cury, self.curx, self.curh)endfunction textbox:charIn(ch) if self.selected then self.text = self.text..ch end platform.window:invalidate(self.x, self.y, self.width + 2, self.height)endfunction textbox:backspaceKey() self.bsflag = true platform.window:invalidate(self.x, self.y, self.width + 2, self.height)endfunction textbox:click() if self.selected then self.selected = false else for _, tb in pairs(self.parent.controls) do if tb.type == "txt" then tb.selected = false end end self.selected = true endendfunction textbox:checkClick(x, y) if y >= self.y and y <= self.y + self.height and x >= self.x and x <= self.x + self.width then self:click() endend
I thought I would leak the dev version of 3.1, there isnt alot of new stuff, but trust me, there is more coming!!dont worry about all of the stuff in the on.create method, in fact you could uncomment most of the stuff and it would all workalso even though it says wzpack_3d, there isnt much 3d, i ended up doing most of my testing there
Icon1 = image.new("\012\000\000\000\012\000\000\000\000\000\000\000\024\000\000\000\016\000\001\000\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\192\255\228\247\228\247\228\247\228\247\228\247\228\247\228\247\228\247\192\255\014\194\014\194\192\255\213\162\157\130\157\130\157\130\157\130\157\130\157\130\213\162\192\255\014\194\014\194\192\255\192\255\192\255\192\255\213\162\213\162\192\255\192\255\192\255\192\255\014\194\014\194\192\255\192\255\192\255\192\255\213\162\213\162\192\255\192\255\192\255\192\255\014\194\014\194\192\255\192\255\192\255\192\255\213\162\213\162\192\255\192\255\192\255\192\255\014\194\014\194\192\255\192\255\192\255\192\255\213\162\213\162\192\255\192\255\192\255\192\255\014\194\014\194\192\255\192\255\192\255\192\255\213\162\213\162\192\255\192\255\192\255\192\255\014\194\014\194\192\255\192\255\192\255\192\255\213\162\213\162\192\255\192\255\192\255\192\255\014\194\014\194\192\255\213\162\157\130\157\130\157\130\157\130\157\130\157\130\213\162\192\255\014\194\014\194\192\255\228\247\228\247\228\247\228\247\228\247\228\247\228\247\228\247\192\255\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194") Icon2 = image.new("\012\000\000\000\012\000\000\000\000\000\000\000\024\000\000\000\016\000\001\000\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\014\194\014\194\157\130\157\130\157\130\157\130\157\130\000\128\157\130\157\130\157\130\157\130\014\194\014\194\157\130\157\130\157\130\157\130\157\130\000\128\157\130\157\130\157\130\157\130\014\194\014\194\157\130\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\157\130\014\194\014\194\157\130\157\130\157\130\157\130\157\130\000\128\157\130\157\130\157\130\157\130\014\194\014\194\157\130\157\130\157\130\157\130\157\130\000\128\157\130\157\130\157\130\157\130\014\194\014\194\157\130\157\130\157\130\157\130\000\128\000\128\000\128\157\130\157\130\157\130\014\194\014\194\157\130\157\130\157\130\000\128\000\128\000\128\000\128\000\128\157\130\157\130\014\194\014\194\157\130\157\130\000\128\000\128\157\130\000\128\157\130\000\128\000\128\157\130\014\194\014\194\000\128\000\128\000\128\157\130\157\130\000\128\157\130\157\130\000\128\000\128\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194\014\194") Icon3 = image.new("\012\000\000\000\012\000\000\000\000\000\000\000\024\000\000\000\016\000\001\000\016\194\016\194\016\194\016\194\016\194\016\194\016\194\016\194\016\194\016\194\016\194\016\194\016\194}\207}\207}\207}\207\000\128\000\128}\207}\207}\207}\207\016\194\016\194}\207}\207}\207}\207\000\128\000\128}\207}\207}\207}\207\016\194\016\194}\207}\207}\207\000\128`\255`\255\000\128}\207}\207}\207\016\194\016\194}\207}\207\000\128`\255\000\188\000\188`\255\000\128}\207}\207\016\194\016\194}\207}\207\000\128`\255\000\188\000\188`\255\000\128}\207}\207\016\194\016\194}\207}\207\000\128\192\255\000\188\000\188`\255\000\128}\207}\207\016\194\016\194}\207\000\128\000\128\192\255\000\188\000\188`\255\000\128\000\128}\207\016\194\016\194}\207\000\128`\255`\255`\255`\255`\255`\255\000\128}\207\016\194\016\194\000\128`\255`\255`\255\000\188\000\188`\255`\255`\255\000\128\016\194\016\194\000\128`\255`\255`\255\000\188\000\188`\255`\255`\255\000\128\016\194\016\194\016\194\016\194\016\194\016\194\016\194\016\194\016\194\016\194\016\194\016\194\016\194") Tabs = {atab = {text = "Tab1", selected = true, controls = {}, x = 0, y = 0}, btab = {text = "Tab2", selected = false, controls = {}, x = 0, y = 0}, ctab = {text = "Tab3", selected = false, controls = {}, x = 0, y = 0}, dtab = {text = "Tab4", selected = false, controls = {}, x = 0, y = 0}} lableT = {"l1", "l2", "l3"} picT = {Icon1, Icon2, Icon3} --This is the form class: Params x, y, width, height, fullscreen, title, title color, title bar and frame color, is drawn, has context menu, c.m. table, has status bar, has icon, icon img form1 = form(1, 1, 160, 160, true, "Title", color.white, color.brickred, true, false, false, true, true, Icon1) --This is the tabcontrol class: Params x, y, width, height, tab table, parent tabControl1 = tabcontrol(10, 15, 110, 50, Tabs, form1) --This is the textbox class: Params x, y, width, text, text color, textbox color, parent, is selected textbox1 = textbox(10, 70, 100, "Hello World", color.black, color.black, form1, false) --this is the button class: Params text, x, y, action, text color, bg color, parent button1 = button("BTN1", 4, 4, btnClick, color.black, color.Bcontrol, Tabs.atab)--could also be tabControl1.tabcollection.atab --this is the lable class: Params x, y, text, text size, color, parent lable1 = lable(1, 2, "BTN1 not clicked ever!", 7, color.black, Tabs.btab) --this is the radioButton class: Params text, x, y, marked, back color, mark color, text color, parent rdb1 = radioButton("rdb1", 2, 2, true, color.Bcontrol, color.green, color.black, Tabs.ctab) rdb2 = radioButton("rdb2", 2, 14, false, color.Bcontrol, color.green, color.black, Tabs.ctab) --this is the Checkbox class: Params x, y, text, checked, back color, check color, text color, parent checkbox1 = checkbox(2, 2, "Checkbox1", true, color.Bcontrol, color.red, color.black, Tabs.dtab) checkbox2 = checkbox(2, 14,"Checkbox2", true, color.Bcontrol, color.red, color.black, Tabs.dtab) --this is the Picture box class: Params x, y, width, height, label table, picture table, text color, index, lable name, parent, selected picturebox1 = pb(130, 15, 20, 20, lableT, picT, color.red, 1, lblmm, form1, false) --this is the numeric updown class: Params x, y, curent number, line color, maximum number, minimum number, text color, plus minus color, parent, selected numericUPDown1 = NumericUD(10, 130, 10, color.black, 25, -1, color.black, color.black, form1, false) --this is the dialog class: Params x, y, text, title, back color, text color, is drawn, parent, selected dialog1 = dialog(10, 10, "Dialog1 is right here~secondline", "Dialog1", color.brickred, color.black, false, form1, false)
function btnClick() lable1.text = "Button has been clicked!" picturebox1:nextpic() if checkbox1.checked and checkbox2.checked and rdb2.marked then dialog1.isdrawn = true end I()end