Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Lua FLTK tips, general help, Things the documentation doesn't say< Next Oldest | Next Newest >
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: July 16 2006,05:08 QUOTE

I've been playing with Lua FLTK for quite a while, and I continue to find it very frustrating that the available documentation is as vague as it can possibly be without being completely useless.
So I'm making this thread to post anything that I might learn from trial-and-error or sources other than printed docs.  I hope that if other people have some pearls that cannot be found without experimentation that they will also post.

Fonts

To start things off, there is a nice little thing about fonts that I just discovered today, by chance more than anything else.
The documentation includes the following about setting fonts:
Quote
Font:set_font(Font f): integer
Set the font string of a Font.

Anyone understand the syntax used here?  No, of course not, because not only is it vague, but it is also inaccurate.  I've tried many times over the last several months to do something with this bit of code, and get nothing but errors or segfaults.  It was only after i tried to use it "in a way that i would have done it if i had written lua fltk"....like this:
Font:set_font(Font.helvetica,"-artwiz-anorexia-medium-r-normal--11-*-*-*-*-*-iso8859-1'')
or
Font:set_font(0,"anorexia")

Now it would have been much easier to understand if they had mentioned the fact that "Font f" represents two parameters, separated by a comma, and that ": integer" is not a part of the function but instead is apparently the return value of the function.

Anyway....now I can finally set whatever font i want simply, without the need to load the entire pile of system fonts into the font table, and without wondering whether or not flua is going to choke on one or more of them.

This is also useful for changing the font in the built-in dialog boxes (file browser, for example). Since most visual properties of these dialogs are static, you can't tell it what font to use...it always uses Font.helvetica.  However, you can tell flua what Font.helvetica is before the dialog is opened, so it will use your custom font for the dialog.

======

The "Font:set_fonts()" function can be unpredictable, and so far I have not used it without running into a situation where certain (broken?) fonts will screw up indexing of the fonts table.  I haven't found a solution beyond using specific strings to load only certain font sets.

======

Apparently Lua FLTK does not handle font aliases well, if at all.  When using custom fonts it is best to use the full font name (-*-whatever-blah-blah-*-whatever-*), or at least provide a useable font size, to prevent the font from looking crunchy.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: July 16 2006,15:43 QUOTE

Browsers

When loading a text file into a browser, there seems to always be a blank line at the end.  This is not inherently a problem, but with a Select_Browser or Hold_Browser you might occasionally run into a situation where hitting an empty line could case a segmentation fault.  I've gotten crashes even when first checking for a blank line.
One way to avoid this is to delete the trailing line when the file is loaded:
Code Sample
if browser_name:text(browser_name.size) == "" then
browser_name:remove(browser_name.size)
end

There might be a simpler, less redundant piece of code for this, but this works.

======

All mouse button actions done within a browser window are registered as clicks.  With a Select_Browser use the mousewheel to scroll only when the cursor is placed over the scrollbar.  PageUp and PageDown keys are more useful than clicking the tiny scroll buttons, particularly in a large browser.  I hope one day this behavior will improve, or that I find a way to work around it.

======

Multi_Browser doesn't work.  If you select multiple lines in a Multi_Browser and then attempt to do some action on everything selected, it will ignore the first item that was selected.  Basically this means that Multi_Browser is next to useless, since it's purpose is to select multiple items on which to do an action.  I know, this is just a complaint rather than a tip, but i'm hoping I or someone else will come up with a way to deal with it and i want to make sure it's documented somewhere =o)


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: July 17 2006,04:48 QUOTE

Tabs

The Lua FLTK documentation says very little about tabs, although the examples included with the Lua FLTK distribution help.  The most troubling part about the doc on this subject is that it suggests using the fluid UI designer to lay them out, which is fairly useless information if you are coding in a text editor and do not have a full FLTK distribution.

So here is what I've been able to come up with from the tabs example and from experimentation....

1) A set of tabs should be a "Tabs" widget whose dimensions include the height of the tabs and the contents of the tabbed areas. This I'll call the "outer group".
2) Each tab contained in this group should be its own group (the "inner groups") whose dimensions include only the tabbed area.  The height of the tab itself is determined by the space available between the outer group and the inner group.  The position of the tab (top or bottom) is determined by whichever side has the largest space between the inner group and outer group.
3) As with any other group, any contents of a tab which are placed beyond the boundaries of the tab group will be visible but will not be able to receive input.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
2 replies since July 16 2006,05:08 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: Lua FLTK tips, general help

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code