News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
Enumerations
Author Message
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
Enumerations

Something that I keep forgetting to put in use....

The FLTK constants listed in enumerations.html file (and those that aren't listed) can be called with a number rather than a name.
This makes it more difficult to read a script, but makes it slightly smaller in size, maybe slightly less ram use but i couldn't say for sure.

For example, "widget:box(fltk.FL_UP_BOX)" could be written "widget:box(2)"

I believe this can be done for all FLTK constants.

I suppose this is why they're called "enumerations"?

06-07-2007 03:56 AM
Find all posts by this user Quote this message in a reply
iGame3D
Moderator
***


Posts: 231
Group: Moderators
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #2
RE: Enumerations

I was looking at a similiar procedure today for lua in Bang3D, and we do the same thing in iGame3D's core.lua.

Although I've never been confident enough myself to use numbers instead of names, i'd need to program a program just to help me use the numbers.

Perhaps use the enumerations in a new version of the cxx convertor?

cxxToEnumeratedLua?

06-07-2007 06:12 AM
Visit this user's website Find all posts by this user Quote this message in a reply
widged
Junior Member
**


Posts: 35
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #3
RE: Enumerations

iGame3D Wrote:
Perhaps use the enumerations in a new version of the cxx convertor?


In fact, it is useful to check out the list of numbers as not all flags seem to be understood in murgalua. For instance, FL_WHEN_CHANGED wasn't recognized and I had to use 1 as argument instead

Full list of constants

06-07-2007 07:11 AM
Visit this user's website Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #4
RE: Enumerations

Quote:
FL_WHEN_CHANGED wasn't recognized

This might be a stupid question, but did you try "fltk.FL_WHEN_CHANGED"?
I think murgaLua needs to be told explicitly to access FLTK constants and functions using "fltk.*"

Instead of telling me I'm an idiot, please just ignore this if I'm being obvious =o)

06-07-2007 08:16 AM
Find all posts by this user Quote this message in a reply
widged
Junior Member
**


Posts: 35
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #5
RE: Enumerations

mikshaw Wrote:

Quote:
FL_WHEN_CHANGED wasn't recognized

This might be a stupid question, but did you try "fltk.FL_WHEN_CHANGED"?


That's an excellent point...sorry for the confusion I introduced when using shorthand rather than full syntax. Rapid way to check out:

Code:
frame2:box(fltk.FL_SHADOW_BOX)  

--> doesn't show any box (defaults to NO_BOX?)

Code:
frame2:box(23)

--> shows the expected box (FL_SHADOW_BOX {23;})

In other words, when the code doesn't do what you expect, it's worth to try and use the numeric value for the constant instead of the string variant.

This post was last modified: 06-07-2007 08:50 AM by widged.

06-07-2007 08:23 AM
Visit this user's website Find all posts by this user Quote this message in a reply
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #6
RE: Enumerations

I just tried widget:box(23) and got the results I'd expect from widget:box(3), which looks like it must be FL_DOWN_BOX. One of the first tests I did with murgaLua was displaying all of the available FLTK boxes, and FL_SHADOW_BOX was one that didn't work, although it wasn't listed in unimplementedFltk.txt

I wonder if there are many features that work differently depending on your platform. FLTK and Lua are apparently supposed to work the same cross-platform, but I guess that can change when you build a whole new framework from them.
My puter: Slackware Linux x86, murgaLua 0.4.1

06-07-2007 09:07 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: