This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Messages - jwalker
Pages: 1 ... 42 43 [44] 45
646
« on: December 31, 2011, 09:53:59 pm »
well i redesigned dialog boxes and added multiline-text support, added a "forms" class that makes up for the features that are lacking in the dialog boxes. now all thats left is working on the screen manager... I will get pics as fast as i can
647
« on: December 31, 2011, 09:51:40 pm »
Happy new year everyone!
648
« on: December 30, 2011, 07:38:42 pm »
you could save the notes page that you made your code in
649
« on: December 30, 2011, 07:36:18 pm »
I cant wait for the next os, but i might not upgrade my CX CAS if if ndless comes out after i fix this i will get rid of all of the other platform.gc's its a good thing there isnt many of them
650
« on: December 30, 2011, 11:12:41 am »
the problem is that with diffrent charachters like a and A it dosen't seem to recognize the diffrence in size: example this code:
textbox = class()
function textbox:init(x, y, text, selected, textcolor, tbcolor) self.x = x self.y = y self.width = 156 self.height = 20 self.text = text self.textcolor = textcolor self.tbcolor = tbcolor self.selected = isselected self.curx = self.x + platform.gc():getStringWidth(self.text) self.cury = y + 1 self.curh = (self.y + self.height) - 1 table.insert(textboxTable, self) end function textbox:paint(gc) gc:setColorRGB(unpack(self.tbcolor)) gc:drawRect( self.x, self.y, self.width, self.height) gc:setColorRGB(unpack(self.textcolor)) gc:setFont("serif", "r", 11) gc:drawString( self.text, self.x + 4, self.y + 8, "middle") gc:setColorRGB(unpack(color.black)) gc:drawLine(self.curx, self.cury, self.curx, self.curh) end function textbox:charIn(ch) if self.selected then if (self.width - 8) < platform.gc():getStringWidth(self.text) then platform.window:invalidate() else self.text = self.text..ch self.curx = self.x + platform.gc():getStringWidth(self.text) + 2 platform.window:invalidate() end end end function textbox:backspace() if self.selected then self.text = string.sub(self.text, 1, string.len(self.text) - 1) self.curx = self.x + platform.gc():getStringWidth(self.text) + 2 platform.window:invalidate() end end
function textbox:click() if self.selected then self.selected = false else for _, tb in pairs(textboxTable) do tb.selected = false end self.selected = true end platform.window:invalidate() end
function 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() end end the code is this: cury = self.x + platform.gc():getStringWidth(self.text) it seems that if you continualy type a lowercase "a" the cursor goes farther ahead and it seems that if you continualy type a capital "A" the cursor will fall behind this is the same for most of the capitol and lowercase letters also this dosent have a drawTB function because im working on a small screen manager
651
« on: December 30, 2011, 10:52:07 am »
well thats good to know that it will be faster and i wasnt that clear either, i should have put in my post the larger they are- the more that everything lags when its redrawing
652
« on: December 30, 2011, 01:15:33 am »
you could make sprites, i would suggest using classes, but you would have to use one of the two methods i talked about above for drawing them
653
« on: December 30, 2011, 12:55:18 am »
to make pictures, you can use all of the drawing commands, or you can convert a pic to a ti.image although this is realy large and re-drawing the screen will slow down to make a menu...if you ever read the tibasicdev article on making custom menus thats basicly what you would have to do it in lua, as there isnt a "Menu(" command Lua is realy easy to learn everything is event/function based Lua example: function on.paint(gc) gc:setColorRGB(0, 0, 0)--set the color to black gc:drawRect(3, 3, 50, 50)--draws a rectangle on the screen with black lines gc:fillRect(100, 0, 50, 50)--makes a rectangle that is filled with the color black end to find some tutorials go to: http://www.inspired-lua.org/to get the official scripting tools go to: http://education.ti.com/educationportal/sites/US/nonProductSingle/nspire-scripting.html
654
« on: December 29, 2011, 06:54:50 pm »
Im trying to make a cursor for the text box but ive encountered a problem... im not quite sure if the "gc:getStringWidth" command works properly does anyone else have problems with it
655
« on: December 28, 2011, 08:50:10 pm »
i program 84 basic on the Nspire emulater, and once when it crashed the cursor was offset like a quarter of an inch into the screen i had to turn it off to fix it. it was a good thing that i had archived my programs.
657
« on: December 28, 2011, 08:41:12 pm »
that is awesome!
658
« on: December 28, 2011, 06:18:49 pm »
i was thinking something like that too. and i might change the circle to a square. the colors can be changed just by creating the dialog box or changing the color after it is created kind of like this: ----colors: color = { black = {0, 0, 0}, lightgreen = {0, 255, 0},} -----------dialog code dialog = class()
function dialog:init( x, y, text, title, isselected, backcolor, textcolor, closecolor, isdrawn)--add buttons and other features self.x = x self.y = y self.text = text self.title = title self.width = 200 self.height = 150 self.cbw = 10 self.cbh = 10 self.cbx = self.x + 175 self.cby = self.y + 7 self.selected = isselected self.backcolor = backcolor self.textcolor = textcolor self.closecolor = closecolor self.isdrawn = isdrawn self.moveable = false table.insert(dialogTable, self) end function dialog:paint(gc) if self.isdrawn then gc:setFont("sansserif", "b", 12) gc:setColorRGB(unpack(self.backcolor)) gc:fillRect( self.x, self.y, self.width, self.height) gc:setColorRGB(unpack(color.white)) gc:fillRect( self.x + 5, self.y + 20, self.width - 10, self.height - 30) gc:setColorRGB(unpack(self.textcolor)) if string.len(self.title) > 10 then self.title = string.sub(self.title, 1, 10).."..." end gc:drawString(self.title, self.x + 10, self.y + 8, "middle") gc:drawString(self.text, self.x + 9, self.y + 25, "middle") gc:setColorRGB(unpack(self.closecolor)) gc:fillArc( self.cbx, self.cby, self.cbw, self.cbh, 0, 360) end end function dialog:checkUnclick() self.moveable = false cursor.set("default") self.selected = false platform.window:invalidate() end function dialog:checkClick(x, y) if self.isdrawn then if (x >= self.cbx and x <= self.cbx + 10) and (y >= self.cby and y <= self.cby + 10) then self:close() elseif self.moveable == false and (x >= self.x and x <= self.x + self.width) and (y >=self.y and y <= self.y + (self.height - 130)) then self:wasclicked(x, y) else self:checkUnclick() end end end function dialog:close() self.selected = false self.isdrawn = false self.moveable = false cursor.set("default") platform.window:invalidate() end function dialog:wasclicked(x, y) self.moveable = true if self.selected ~= self then for _, dlg in pairs(dialogTable) do dlg.selected = false end self.selected = true end self.xvar = x - self.x self.yvar = y - self.y cursor.set("drag grab") platform.window:invalidate() end function dialog:mouseMove(x, y) if self.moveable and self.isdrawn and self.selected then cursor.set("drag grab") self.x = x - self.xvar self.y = y - self.yvar self.cbx = self.x + 175 self.cby = self.y + 7 platform.window:invalidate() end end function drawDialog(gc) for _, SD in pairs(dialogTable) do if SD.isdrawn then SD:paint(gc) end end end ------------ ---------------create the dialog box function on.create() dia1 = dialog(45, 23, "Color change", "Colors", false, color.lightgreen, color.red, color.red, true) end ----------------------------say a function changes the color like this later on if it is called function color_change() dia1.backcolor = color.black -----after that the color of the boarder would be black end in the end its what the programmer decides, but i probably would tone the colors down just because they are hard to see on the calc EDIT: @epic7 it is a small, easy to use gui library that offers quite a few features, im working on making a better use of the OOP that Nspire lua offers
659
« on: December 28, 2011, 06:00:15 pm »
yea, i added some stuff to it and put it on ticalc a few hours ago. some things i have to fix yet is the lack of inheritance and the fact that dialog boxes only support text right now. its a good thing i have the rest of christmas break to work on it meaning i am adding a screen manager and better features for dialog boxes here is some code for numeric up downs that i added: function NumericUD:init(x, y, num, selected, linecolor, maxnum, minnumber, textcolor, pmbcolor) self.x = x self.y = y self.pmbcolor = pmbcolor self.num = num self.text = tostring(num) self.selected = selected self.linecolor = linecolor self.maxnum = maxnum self.minnumber = minnumber self.textcolor = textcolor self.width = 42 self.height = 23 table.insert(NUDTable, self) end
function NumericUD:paint(gc) gc:setPen("thin", "smooth") gc:setColorRGB(unpack(self.pmbcolor)) gc:drawLine(self.x + 35, self.y, self.x + 35, self.y + 23) gc:drawLine(self.x + 35, self.y + 11, self.x + 42, self.y + 11) gc:setFont("serif", "r", 6) gc:drawString("+", self.x + 36, self.y - 2, "top") gc:drawString("-", self.x + 36, self.y + 10, "top") gc:setColorRGB(unpack(self.linecolor)) gc:drawRect(self.x, self.y, self.width, self.height) gc:setColorRGB(unpack(self.textcolor)) gc:setFont("serif", "r", 11) gc:drawString(self.text, self.x + 2, self.y + 2, "top") end function NumericUD:click(x, y) if y >= self.y and y <= self.y + 11 and x >= self.x + 35 and x <= self.x + 40 then self:Up() elseif y >= self.y + 11 and y <= self.y + 23 and x >= self.x + 35 and x <= self.x + 40 then self:Down() end end function NumericUD:Up() if self.num ~= self.maxnum then self.num = self.num + 1 self.text = tostring(self.num) end platform.window:invalidate() end function NumericUD:Down() if self.num ~= self.minnumber then self.num = self.num - 1 self.text = tostring(self.num) end platform.window:invalidate() end function drawNUD(gc) for _, NUD in pairs(NUDTable) do NUD:paint(gc) end end i probably would have worked on it way more, but i found a bug in the picture box function
660
« on: December 27, 2011, 11:23:57 am »
ok good to know. one of the reasons i am updating it is to make a better use of the lua's OOP programming. the screen manager idea is one that i hadnt thought of before that i probably should have. The EEPro stuff looks realy cool too
Pages: 1 ... 42 43 [44] 45
|