Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => Casio PRIZM => Topic started by: flyingfisch on January 05, 2012, 10:16:28 am

Title: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 10:16:28 am
NOTE: I am posting this in PRIZM projects, but since there is no LuaFX for PRIZM yet, it would be nice to have a LuaFX/AFX projects section ;)

I have been meaning to make a GUI library for a while and have only now found the time, so here it is in alpha-of-an-alpha :D

Available functions:

* Lua Classes (thanks to adriweb for code)
* Input text (missing in the originl luaFX)

Planned functions to be included:

* Buttons
* Window Manager
* EZ Menus
* Dialog boxes
* Radio Buttons
* Check Boxes
* More :D

Since this project is free and open source, and you are free to fork it if you want, here is the code: ;)

EDIT: Added a GitHub repo (https://github.com/flyingfisch/CalGUI)

Code: [Select]
-- locals
local line = graydraw.line
local wait = misc.wait
local setcolor = graydraw.setcolor
local text = graydraw.text
local exitprog = misc.exit
local print = nbdraw.print
local find = string.find
local setCursor = nbdraw.setcursor
local strsub = string.sub
local strlen = string.len

--[[--
CalGUI (Pronounced Cal-gew-ey), a GUI library for LuaFX
By flyingfisch
Last Updated 1/05/2012
This project is free and open source.
--]]--

--[[--
Class definition system
Borrowed from LuaNspire
Thanks to adriweb for code
--]]--
class = function(prototype)
    local derived = {}
    local derivedMT = {
        __index = prototype,
        __call  = function(proto, ...)
            local instance = {}
            local instanceMT = {
                __index = derived,
                __call = function()
                    return nil, "ERROR: Attempt to invoke an instance of a class"
                end,
            }
            setmetatable(instance, instanceMT)
            if instance.init then
                instance:init(...)
            end
            return instance
        end,
    }
    setmetatable(derived, derivedMT)
    return derived
end

--[[--
Input text system
--]]--
function input()
setcolor(false) --set 5-color mode "false"
i = 1
parse = ""
print(parse .. "_")
--keystrokes
while not key(5) do
repeat
--non-alpha:
if alpha == 0 then
if key(1) then parse = parse .. "0" end
if key(2) then parse = parse .. "." end
if key(4) then parse = parse .. "-" end
if key(6) then parse = parse .. "1" end
if key(7) then parse = parse .. "2" end
if key(8) then parse = parse .. "3" end
if key(9) then parse = parse .. "+" end
if key(10) then parse = parse .. "-" end
if key(11) then parse = parse .. "4" end
if key(12) then parse = parse .. "5" end
if key(13) then parse = parse .. "6" end
if key(14) then parse = parse .. "*" end
if key(15) then parse = parse .. "/" end
if key(16) then parse = parse .. "7" end
if key(17) then parse = parse .. "8" end
if key(18) then parse = parse .. "9" end
if key(19) then parse = strsub(parse,1,#parse-1) end
if key(33) then alpha = 1 end
--alpha:
else
if key(1) then parse = parse .. "z" end
if key(2) then parse = parse .. " " end
if key(3) then parse = parse .. [["]] end
if key(6) then parse = parse .. "u" end
if key(7) then parse = parse .. "v" end
if key(8) then parse = parse .. "w" end
if key(9) then parse = parse .. "x" end
if key(10) then parse = parse .. "y" end
if key(11) then parse = parse .. "p" end
if key(12) then parse = parse .. "q" end
if key(13) then parse = parse .. "r" end
if key(14) then parse = parse .. "s" end
if key(15) then parse = parse .. "t" end
if key(16) then parse = parse .. "m" end
if key(17) then parse = parse .. "n" end
if key(18) then parse = parse .. "o" end
if key(19) then parse = strsub(parse,1,#parse-1) end
if key(21) then parse = parse .. "g" end
if key(22) then parse = parse .. "h" end
if key(23) then parse = parse .. "i" end
if key(24) then parse = parse .. "j" end
if key(25) then parse = parse .. "k" end
if key(26) then parse = parse .. "l" end
if key(27) then parse = parse .. "a" end
if key(28) then parse = parse .. "b" end
if key(29) then parse = parse .. "c" end
if key(30) then parse = parse .. "d" end
if key(31) then parse = parse .. "e" end
if key(32) then parse = parse .. "f" end
if key(34) then parse = parse .. "r" end
if key(33) then alpha = 0 end
end
wait(2) --interrupt
until key(0)

clear nil
setCursor(1,1)
print(parse .. "_")

refresh

if key(5) then break end --check for EXE
wait(3)
end
end
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Nick on January 05, 2012, 11:10:17 am
does it work with the classes now? sounds great, now you're sort of the inventor of classes for casio lol

looks good, and it might be alpha-of-alpha, but you have to start somewhere.. i wish you good luck with it (not sarcastic or ironically meant xp )
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 11:14:29 am
does it work with the classes now? sounds great, now you're sort of the inventor of classes for casio lol

looks good, and it might be alpha-of-alpha, but you have to start somewhere.. i wish you good luck with it (not sarcastic or ironically meant xp )

I understand how its meant :)

Yep, It does work with classes.

I added a repo on GitHub for this project: https://github.com/flyingfisch/CalGUI
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Nick on January 05, 2012, 11:22:44 am
ooh, i just took a look at it, and can't you remake that
Code: [Select]
if key(1) then parse = parse .. "0" end
if key(2) then parse = parse .. "." end
if key(4) then parse = parse .. "-" end
etc etc
to a table like this:
Code: [Select]
parsetable = {
["1"]="0",
["2"]=".",
etc..
}

or isn't that possible in luaFX? it would be a lot smaller than now, so you don't need all those statements, just
Code: [Select]
parse..parsetable[tostring(key)]
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Eiyeron on January 05, 2012, 11:26:58 am
does it work with the classes now? sounds great, now you're sort of the inventor of classes for casio lol

Just for LuaFX! :p

OW, 208 posts already?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 11:29:22 am
ooh, i just took a look at it, and can't you remake that
Code: [Select]
if key(1) then parse = parse .. "0" end
if key(2) then parse = parse .. "." end
if key(4) then parse = parse .. "-" end
etc etc
to a table like this:
Code: [Select]
parsetable = {
["1"]="0",
["2"]=".",
etc..
}

or isn't that possible in luaFX? it would be a lot smaller than now, so you don't need all those statements, just
Code: [Select]
parse..parsetable[tostring(key)]

Ok, so this is using classes?

does it work with the classes now? sounds great, now you're sort of the inventor of classes for casio lol

Just for LuaFX! :p

OW, 208 posts already?
What do you mean by "Just for LuaFX"?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Nick on January 05, 2012, 11:31:22 am
no flyingfisch, that's not classes, that's just a table and the reference to it..

i only don't know if that ["0"]= is possible in lua, it would make the work much easier
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Eiyeron on January 05, 2012, 11:35:38 am
does it work with the classes now? sounds great, now you're sort of the inventor of classes for casio lol

Just for LuaFX! :p

OW, 208 posts already?
What do you mean by "Just for LuaFX"?

C/C++ and classes could be already compiled with GCC or Casio's SDK (if the first option is better than second). But Very good job for making classes :)

and just {"0","1","2"...} is enough, nah?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 11:36:41 am
key(0) returns true if one or more keys are pressed.
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Eiyeron on January 05, 2012, 11:38:52 am
I know that! I'm the guy who forc'd Veb to make that! :p
and with table = {"a" = 5}, we can make table.a = 5, I saw that with trying to make a tilemapper engine...
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 11:55:58 am
you should go look at my lib i have made for the nspire. it offers all of those things you mentioned plus more. its bieng updated and their are pictures on this site in another topic it might give you some ideas...:
http://ourl.ca/14633/276223;topicseen#new (http://ourl.ca/14633/276223;topicseen#new)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Eiyeron on January 05, 2012, 11:56:53 am
What does mean "EZ menus"?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Nick on January 05, 2012, 11:57:30 am
is there a big difference between luaFX and Nspire lua? otherwise this gui from jwalker could be really useful
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Eiyeron on January 05, 2012, 12:02:06 pm
Not many graphics functions!
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 12:05:01 pm
what functions are there?
basicly if it supports lines, arcs, text, and the abiliy to fill polygons like rectangles, thats prety much all you need
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Eiyeron on January 05, 2012, 12:09:51 pm
NOt arcs, only full circles.
I know that MonochromeLib support (for black and white) almost all of this (without arcs), but I dunno if Veb have implemented all of this
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Adriweb on January 05, 2012, 12:10:13 pm
By the way, the class() code should work, but I didn't test it ... Did you ? :D
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Eiyeron on January 05, 2012, 12:12:07 pm
NOt now, I'm "working"... :-°
But alway here for LFX! :p
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 01:03:02 pm
I know that! I'm the guy who forc'd Veb to make that! :p
and with table = {"a" = 5}, we can make table.a = 5, I saw that with trying to make a tilemapper engine...

I was responding to nick... sorry for the miscommunication :P

What does mean "EZ menus"?
Easy menus. Kind of like CASIO-BASIC menus.

is there a big difference between luaFX and Nspire lua? otherwise this gui from jwalker could be really useful

I dont think there is a very big difference, and I am looking at jwalkers code right now :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: helder7 on January 05, 2012, 01:23:16 pm
very good project

good luck
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 01:34:29 pm
you guys have a circle command  O.O
i mentioned arcs because thats how we have to draw circles
@ flyingfisch: did you download it off of ticalc, because the new version is wayyyyy better, i mean its like comparing Windows 3.1 to Windows7
anyway im probably going to upload a prerelease version for poeple to test out and comment on very soon here, like maybe tonight.
anyway have fun this is a fun type of project :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: DJ Omnimaga on January 05, 2012, 01:35:24 pm
NOTE: I am posting this in PRIZM projects, but since there is no LuaFX for PRIZM yet, it would be nice to have a LuaFX/AFX projects section ;)

You could maybe ask admins, but the issue is that the AFX is discontinued so such section would be unpopular. It might be best to wait until LuaFX for the FX-9860G or the Prizm is complete.
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Nick on January 05, 2012, 01:40:26 pm
@ flyingfisch: did you download it off of ticalc, because the new version is wayyyyy better, i mean its like comparing Windows 3.1 to Windows7

lol, is it really that bad your first version?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 01:46:17 pm
you guys have a circle command  O.O
i mentioned arcs because thats how we have to draw circles
@ flyingfisch: did you download it off of ticalc, because the new version is wayyyyy better, i mean its like comparing Windows 3.1 to Windows7
anyway im probably going to upload a prerelease version for poeple to test out and comment on very soon here, like maybe tonight.
anyway have fun this is a fun type of project :)

New version???

Youll have to tell me where it is :P
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 01:56:58 pm
it isnt out yet but i think  i posted a link on the first page of the topic and it goes to my topic + some pics
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 01:59:06 pm
Could I have a link to the topic?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 02:10:34 pm
sure:
http://ourl.ca/14633/276223;topicseen#new (http://ourl.ca/14633/276223;topicseen#new)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 02:23:40 pm
Thanks!

BTW:
Userbar!

(http://userbars.removedfromgame.com/ub/flyingfisch388.png)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 05:26:56 pm
@ flyingfisch: did you download it off of ticalc, because the new version is wayyyyy better, i mean its like comparing Windows 3.1 to Windows7

lol, is it really that bad your first version?
lol bad explanation on my part.
it wasnt bad it just was severly limited, and i changed the design of the dialog boxes and added a forms control
dialogs used to only support 1 line of text on the very top portion of the body of the dialog, no controls
below is two images comparing them, the second one is the new look:
(http://www.ticalc.org/cgi-bin/zipview?nspire/lua/libs/wzguilib.zip;12-04-2011%20Image001.jpg)
(http://www.omnimaga.org/index.php?action=dlattach;topic=12036.0;attach=11045;image)
also the context menus are completely random you could change any of the text you wanted to :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 05:28:30 pm
Could someone tell me the basics of building a window manager?

Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 05:40:03 pm
thats a tough one.... on the TI-Nspire we have on. events
the window manager handles these events
i made a window class to handle that sort of thing
in Work Zone GUI Lib, WZGUILIB is just short for it, parent windows have a controls table and a dialogs table
some functions you would see would be--
window:drawControls(gc)
window:udateControls(control)
window:getFocus()
and a seperate function to find a specific window that is focused: curwin()
it also handlse the basic on. events like: charIn(char), mouseDown(x, y), mouseMove(x, y), backspaceKey(), paint(gc)
scince i dont know what is on prizm, i couldnt tell you what your functions are but if it is event based it would easily be similar
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 05:41:05 pm
Is there lua code for on. events that i could port to luaFX?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 05:45:58 pm
i dont know what the code is behind the events, it would be operating systems stuff i suppose
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 05:46:54 pm
i dont know what the code is behind the events, it would be operating systems stuff i suppose

Really? I cant do it like i did lua classes?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 05:49:24 pm
you might be able to... but i dont think so because the events would have to be raised by the operating system, of course your not as limited as we are so you could prbably figured out a way link the events in lua to say a keypress on the calc
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 05:51:15 pm
how do on events work? maybe i can emulate them :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 05:55:34 pm
i think a message is sent to the LUA interpreter on the TI-Nspire so thats the only way to recieve input that i can think of right now
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 05:56:24 pm
I mean, how is an on event used? What do they do in a program?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 05:58:55 pm
o, what they dow is if there is an event, you write code to handle it
like this:
function on.mouseDown(x, y)
  sdia.isdrawn = true
  sdia.text = "mouse was pressed"
end
just a nod to my GUI library :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 06:00:41 pm
do you have to define the event on.mouseDown, or is it in lua nspire by default?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 06:01:32 pm
its in lua nspire by default
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 06:03:35 pm
ok so i could probably make my own on events using functions? also, casio calcs do not have a cursor default, so im going to try to implement that too. ;)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 06:05:15 pm
you might be able to make them with functions and a cursor couldnt be that hard, could it?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 05, 2012, 06:12:43 pm
you might be able to make them with functions and a cursor couldnt be that hard, could it?

I could probably do the cursor with classes...
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 05, 2012, 06:14:18 pm
i would do cursors with classes, it would make it so much eiser, all you need is to make an image, and have a place to store x, y
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Nick on January 06, 2012, 04:21:02 am
just do
Code: [Select]
cursortypes = {
*cursor image data here*
}
cursor:init(x,y,type)
 self.x = x
 self.y = y
 self.type = cursortypes[type]
end
Cursor = cursor(50,50,*number here*)
this way you can add different cursor like we have in nspire, which you can find here (https://sites.google.com/site/stonesetproductions/sources/cursors.zip?attredirects=0&d=1)
it contains a zip with all the cursors in a different image

and then assign a function to it to change the cursor
Code: [Select]
function cursor:set(type)
Cursor.type = cursortypes[type]
end


cursor:set(*number here*)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 09:11:58 am
Thanks nick for your code :)

and for your cursor images (i was having trouble making one that didnt look silly. lol)

@jwalker: Is there a sample program that uses your library that I look at? I want to see how the library is used in a program. Also, which post in your thread has the latest code?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 06, 2012, 09:14:20 am
im actualy about to upload a prerelease version right now, check in a few miniutes, im using an old crappy school computer so it might take some time :P
EDIT: uploaded!
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 09:16:31 am
im actualy about to upload a prerelease version right now, check in a few miniutes, im using an old crappy school computer so it might take some time :P
OK. :D

just do
Code: [Select]
cursortypes = {
*cursor image data here*
}
cursor:init(x,y,type)
 self.x = x
 self.y = y
 self.type = cursortypes[type]
end
Cursor = cursor(50,50,*number here*)
this way you can add different cursor like we have in nspire, which you can find here (https://sites.google.com/site/stonesetproductions/sources/cursors.zip?attredirects=0&d=1)
it contains a zip with all the cursors in a different image
...

OK, does that code use classes or what? (This is my first major program with lua so please bear with me :) )

Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 06, 2012, 09:17:35 am
this code does use classes, the one he gave you and mine also
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 09:19:32 am
I'm gonna have to take another look at jimbauwens explanation of classes :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 06, 2012, 09:23:37 am
thats a good idea too, my code only uses one instance of inheritance though, in the form class, do to the fact that the lib is quit large and poeple should be able to choose what code they need and take the other stuff out.
this way if they take out some class and some other class had to inherit from it there would be errors.
also i might add a control class for the controls to inherit from, but i may not do to the fact im trying to make it smaller and more optimized :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 09:26:40 am
thats a good idea too, my code only uses one instance of inheritance though, in the form class, do to the fact that the lib is quit large and poeple should be able to choose what code they need and take the other stuff out.
this way if they take out some class and some other class had to inherit from it there would be errors.
also i might add a control class for the controls to inherit from, but i may not do to the fact im trying to make it smaller and more optimized :)

OK.

Is there a list of on events and their usage?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 06, 2012, 09:46:40 am
no i didnt list them but they are descriptive...
for example:
function on.mouseDown(x, y) means the mouse was clicked and returns to us x and y
function on.charIn(char) means that a key other than an arrow key was pressed and returns char to us
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Nick on January 06, 2012, 09:52:16 am
i thought he meant functions from your gui jwalker.. here are all the functions standard in nspire lua

Function name        Arguments                                                  Called when
on.paint(gc)        GC is the graphical context (explained later)       platform.window:invalidate() is called
on.arrowKey(arrow)   Arrow returns ‘left’,’right’,’up’ or ‘down’           An arrow key had been pressed
on.arrowLeft()        -                                                                   The left arrow key has been pressed
on.arrowRight()        -                                                                   The right arrow key has been pressed
on.arrowUp()        -                                                                   The up arrow key has been pressed
on.arrowDown()   -   The down arrow key has been pressed
on.enterKey()   -   The enter key has been pressed
on.escapeKey()   -   The escape key has been pressed
on.tabKey()   -   The tab key has been pressed
on.charIn(char)   Char can return any char, e.g. char = ‘+’   Any character key has been pressed
on.mouseMove(x,y)   x and y return the position of the mouse   The mouse moves
on.mouseDown(x,y)   x and y return the position of the mouse   The mouse has been pressed
on.mouseUp(x,y)   x and y return the position of the mouse   The mouse has been released
on.create()   -   The file gets opened (made)
on.destroy()   -   The file gets closed (destroyed)
on.resize()   -   The screen is resized (when in the pc software)
on.timer()   -   The timer is called
on.deleteKey()   -   The delete key has been pressed
on.backspaceKey()   -   The backspace key has been pressed
on.returnKey()   -   The return key has been  pressed
on.contextMenu()   -   The [ctrl][menu] key has been pressed
on.help()   -   The [ctrl][trig] has been pressed
on.clearKey()   -   The clear key has been pressed
on.activate()   -   The tab/page gets activated
on.deactivate()   -   The tab/page gets inactivated
on.blink()   -   The focus gets lost on the page

or just go here (http://wiki.inspired-lua.org/Overview_of_the_API)
it's the events part
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 06, 2012, 10:03:51 am
in my GUI on. events are ususaly sent to the window that was retrieved from the curwin() function, except mouse down will check all windows because then a user can give them focus and effectively redraw them overtop of the other windows
some on. events i dont implement, because i dont use them, like on.blink
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 10:11:43 am
i thought he meant functions from your gui jwalker.. here are all the functions standard in nspire lua

Function name        Arguments                                                  Called when
on.paint(gc)        GC is the graphical context (explained later)       platform.window:invalidate() is called
on.arrowKey(arrow)   Arrow returns ‘left’,’right’,’up’ or ‘down’           An arrow key had been pressed
on.arrowLeft()        -                                                                   The left arrow key has been pressed
on.arrowRight()        -                                                                   The right arrow key has been pressed
on.arrowUp()        -                                                                   The up arrow key has been pressed
on.arrowDown()   -   The down arrow key has been pressed
on.enterKey()   -   The enter key has been pressed
on.escapeKey()   -   The escape key has been pressed
on.tabKey()   -   The tab key has been pressed
on.charIn(char)   Char can return any char, e.g. char = ‘+’   Any character key has been pressed
on.mouseMove(x,y)   x and y return the position of the mouse   The mouse moves
on.mouseDown(x,y)   x and y return the position of the mouse   The mouse has been pressed
on.mouseUp(x,y)   x and y return the position of the mouse   The mouse has been released
on.create()   -   The file gets opened (made)
on.destroy()   -   The file gets closed (destroyed)
on.resize()   -   The screen is resized (when in the pc software)
on.timer()   -   The timer is called
on.deleteKey()   -   The delete key has been pressed
on.backspaceKey()   -   The backspace key has been pressed
on.returnKey()   -   The return key has been  pressed
on.contextMenu()   -   The [ctrl][menu] key has been pressed
on.help()   -   The [ctrl][trig] has been pressed
on.clearKey()   -   The clear key has been pressed
on.activate()   -   The tab/page gets activated
on.deactivate()   -   The tab/page gets inactivated
on.blink()   -   The focus gets lost on the page

or just go here (http://wiki.inspired-lua.org/Overview_of_the_API)
it's the events part


So yeah, this should be pretty easy to do with classes, right?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Nick on January 06, 2012, 10:13:15 am
certainly, you will only have to use loops to determine if a function needs to be called or not..
luaFX is in loops, isn't it?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 10:14:10 am
certainly, you will only have to use loops to determine if a function needs to be called or not..
luaFX is in loops, isn't it?

As in, it supports loops?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Nick on January 06, 2012, 10:15:44 am
no, i mean, is it event-based? or just like basic programs that you have to create a loop that gets repeated constantly and from which you call certain functions if a statement is true
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 10:33:16 am
LuaFX is almost exactly the same as lua 5.1. I guess you could make it event based somehow...But yeah, I think you have to do loops

Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 11:05:07 am
Bug report!

After procrastinating for a day, i decided to test the lua classes code with this program:

Code: [Select]
local print = graydraw.print

class = function(prototype)
    local derived = {}
    local derivedMT = {
        __index = prototype,
        __call  = function(proto, ...)
            local instance = {}
            local instanceMT = {
                __index = derived,
                __call = function()
                    return nil, "ERROR: Attempt to invoke an instance of a class"
                end,
            }
            setmetatable(instance, instanceMT)
            if instance.init then
                instance:init(...)
            end
            return instance
        end,
    }
    setmetatable(derived, derivedMT)
    return derived
end

car = class()

function car: init(power, type, lights, etc)
    self.power = power
    self.type = type
    self.lights = lights*2
    self.options = etc
end

jeep = car(60, "4x4", 12, {air-conditioning = False, trailer-hook = True})

if jeep.options.trailer-hook then
   print("The jeep can have a trailer")
else
   print("No trailer for you :(")
end

And....I get an error:

Code: [Select]
[string 'experiment.lua']:35: '}' expected near '='

So is there a problem with my code, luaFX, or the lua class code?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Nick on January 06, 2012, 11:06:34 am
try to remove the spaces, and if that does not work, place quotation mark around the air-conditioning and if that doe not work place [" "] around ari conditioning and if that does not work you're lost xp
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 11:16:45 am
Well, apparently it did not like the dashes. But now I get another error with this code D:

Code: [Select]
local print = graydraw.print

class = function(prototype)
    local derived = {}
    local derivedMT = {
        __index = prototype,
        __call  = function(proto, ...)
            local instance = {}
            local instanceMT = {
                __index = derived,
                __call = function()
                    return nil, "ERROR: Attempt to invoke an instance of a class"
                end,
            }
            setmetatable(instance, instanceMT)
            if instance.init then
                instance:init(...)
            end
            return instance
        end,
    }
    setmetatable(derived, derivedMT)
    return derived
end

car = class()

function car: init(power, type, lights, etc)
    self.power = power
    self.type = type
    self.lights = lights*2
    self.options = etc
end

jeep = car(60, "4x4", 12, {airconditioning = false,trailerhook = true})
if jeep.trailerhook then
   print("The jeep can have a trailer")
else
   print("No trailer for you :(")
end

Error message:

Code: [Select]
[string 'experiment.lua']:22: Attempt to call global 'setmetatable', a nil value
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 06, 2012, 11:23:03 am
maybe its something with LuaFX...
the way you used setmetatable works on oclua...
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 11:26:25 am
oclua?
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Adriweb on January 06, 2012, 11:37:20 am
o_O

setmetatable() is a native lua function ....
:o

( http://lua-users.org/wiki/MetamethodsTutorial (http://lua-users.org/wiki/MetamethodsTutorial) )

What version of Lua are you using ?
That may be the problem...

Also, I know there are some encoding problem with Omnimaga codes in posts.

Here's the class function, that you can again copy/paste, maybe it will work this time ?
http://pastebin.com/9gTmaKKK (http://pastebin.com/9gTmaKKK)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 11:42:27 am
I guess this is why luaFX is called beta right now. :P

I'll have to ask eiyeron to talk to veb about it for me. :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 06, 2012, 11:59:22 am
oclua is the nspire on-calc lua programming stuff
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 12:01:08 pm
Oh, ok. So On-Calc lua. ok :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Nick on January 06, 2012, 12:09:03 pm
well, flyingfisch, don't feel like making one too? could be very useful..
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 12:29:54 pm
well, flyingfisch, don't feel like making one too? could be very useful..

On-calc lua editor? Yeah, I think I'll try that when I learn C/C++. Which I should probably do pretty soon. :P

Which language do you think I should learn? C or C++? They both make addins.
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: Nick on January 06, 2012, 12:31:25 pm
i asked myself that question too, most people say C++, dunno why, but it's true..

btw: i don't know the difference..
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 12:35:46 pm
i asked myself that question too, most people say C++, dunno why, but it's true..

btw: i don't know the difference..

neither do I :D

I think I'll just stick with lua and make the on-calc editor in lua when we get the ability to write programs from a lua file. ;)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 06, 2012, 01:07:08 pm
I am doing both :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 01:14:54 pm
I am doing both :)
Doing both? ???
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 06, 2012, 01:20:20 pm
Yea it's taking a long time. :p
I'm learning c for OS development and c++ for
Everything else I can think of :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 06, 2012, 01:23:12 pm
Yea it's taking a long time. :p
I'm learning c for OS development and c++ for
Everything else I can think of :)
lol. Yeah, I should learn... but... I'm lazy/busy :D :P
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 06, 2012, 01:26:22 pm
Yea that's why it's taking so long
It seems like I get it down and het caught up in something else
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 08, 2012, 05:43:06 pm
When I asked on planet-casio why it didnt work, Veb (the main LFX developer) responded that:

Quote from: Veb
I believed these functions will never be used, that's why I didn't include them.

If you believe it is necessary, I will include them.

So we should be able to start this project up again pretty soon :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 08, 2012, 06:41:00 pm
thats great! oh and  i updated the lua script to handle windows better if you want to look at it...
http://ourl.ca/14633/277096;topicseen#new (http://ourl.ca/14633/277096;topicseen#new)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 08, 2012, 08:07:32 pm
cool!
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 08, 2012, 08:15:38 pm
yea im prety much on the last thing, improuving the textboxes... after that its documentation time :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: flyingfisch on January 09, 2012, 09:58:57 am
yea im prety much on the last thing, improuving the textboxes... after that its documentation time :)

Nice. :)
Title: Re: CalGUI -- A GUI library by flyingfisch
Post by: jwalker on January 09, 2012, 10:08:55 am
i figure i will be done within this week :)