BaH modules...

BlitzMax Forums/BlitzMax Programming/BaH modules...

Brucey(Posted 2006) [#1]
I've recently uploaded the latest versions of my modules :

cairo
fontconfig
libxml
gtkmaxgui (linux gui fltk replacement)
realtimebattle (linux only)

You can download these via syncmods...
syncmods -u your_name -p your_pass bah.MODULENAME

or from the website :
http://brucey.net/programming/blitz

* Cairo uses the latest 1.2.2 of the cairo lib. (requires fontconfig module!)

* Fontconfig has been split from the cairo distro as it is now useful in its own right. It comes with a new Font Loader, that enables you to load any system fonts with LoadImageFont - Max2D - without requiring the full path.

* Libxml now has much more of the API exposed.

* GTKMaxGUI is a replacement for the default Linux MaxGUI module (fltk), which is based on GTK+. Gadgets perform as expected (rather than the hit-or-miss affair with the fltk module), and provide a much more "standard" look and feel on the Linux platform. It also fully supports GTK themes, and will update on-the-fly.

* RealTimeBattle is a Max module for building robots to compete in a virtual arena. More info here.


The libxslt module is done, but I'm just tidying up the documentation before I release it.

As usual, all modules come complete with source and documentation, and are cross-platform unless otherwise stated...

If you have an suggestions / ideas, they are always most welcome.

Enjoy :o)


Difference(Posted 2006) [#2]
If you have an suggestions / ideas, they are always most welcome.

I suggest we elevate Brucey to Sainthood.

libxslt will be SUPER usefull in my next project.


SebHoll(Posted 2006) [#3]
I suggest we elevate Brucey to Sainthood.

Same here!!!


morszeck(Posted 2006) [#4]
It's very coo! Thx Brucey for upgading cairo! But i can't update with syncmods?! The modserver is www.blitzbasic.com/modserver120 or an other?


Brucey(Posted 2006) [#5]
Sorry morszeck, my mac is sick at the moment, so I am unable to upload syncmods for mac versions.

You'll have to get it from the website for now, I'm afraid. :-(


morszeck(Posted 2006) [#6]
No,no. I can compiled the modules from you, but i can't update automatically the modules width syncmod.


taxlerendiosk(Posted 2006) [#7]
Fantastic Brucey, I'm glad you're still interested in all these. Can you load zlib-compressed SVG from incbin yet? Or, load XML from memory at all, I guess, I could probably work out the rest. I'm not at home at the moment so I can't sync-a-mods yet to check it out myself.


Brucey(Posted 2006) [#8]
@denzil
XML thru incbin is working now. If you need it from a Bank or such, I could probably build that in too...
Haven't looked at the same for SVG yet tho.

@morszeck
If you are on Mac, syncmods won't work for my modules yet. The way it works is, one must upload each platform module *from* the platform itself, and since my Mac is currently sick, I am unable to upload for Mac, and hence there won't be syncmods for Mac til I can.


morszeck(Posted 2006) [#9]
Hi Brucey, i have same problem in cairo-module with RGBA_8888, the colors and the alpha-canal.

See here: http://www.blitzbasic.com/Community/posts.php?topic=59324


Ninjacrat(Posted 2006) [#10]
Building gradient
Compiling:gradient.bmx
flat assembler version 1.64
3 passes, 6478 bytes.
Linking:gradient.debug.exe
C:/Program Files/BlitzMax/mod/bah.mod/fontconfig.mod/fontconfig.debug.win32.x86.a(fcfreetype.c.debug.win32.x86.o)(.text+0x1768):fcfreetype.c: undefined reference to `FT_Get_BDF_Property'
C:/Program Files/BlitzMax/mod/bah.mod/fontconfig.mod/fontconfig.debug.win32.x86.a(fcfreetype.c.debug.win32.x86.o)(.text+0x2362):fcfreetype.c: undefined reference to `FT_Get_BDF_Property'
C:/Program Files/BlitzMax/mod/bah.mod/fontconfig.mod/fontconfig.debug.win32.x86.a(fcfreetype.c.debug.win32.x86.o)(.text+0x2379):fcfreetype.c: undefined reference to `FT_Get_BDF_Property'
C:/Program Files/BlitzMax/mod/bah.mod/fontconfig.mod/fontconfig.debug.win32.x86.a(fcfreetype.c.debug.win32.x86.o)(.text+0x23b1):fcfreetype.c: undefined reference to `FT_Get_BDF_Property'
C:/Program Files/BlitzMax/mod/bah.mod/fontconfig.mod/fontconfig.debug.win32.x86.a(fcfreetype.c.debug.win32.x86.o)(.text+0x2516):fcfreetype.c: undefined reference to `FT_Get_BDF_Property'
C:/Program Files/BlitzMax/mod/bah.mod/fontconfig.mod/fontconfig.debug.win32.x86.a(fcfreetype.c.debug.win32.x86.o)(.text+0x257d):fcfreetype.c: more undefined references to `FT_Get_BDF_Property' follow
Build Error: Failed to link C:/Program Files/BlitzMax/mod/bah.mod/cairo.mod/examples/gradient.debug.exe
Process complete


Um, help!


Brucey(Posted 2006) [#11]
@ Ninjacrat
That's interesting... it almost looks like you have an old verion of the Freetype module installed (there was a file missing from the compile in a previous version, which BRL have now included). I suggest ensuring you have run syncmods.
With the latest modules that example runs fine on both win32 and linux for me.

@morszeck
I may have messed up the Mac PPC cairo... If you are feeling adventurous, you might like to try changing a line in src/config.h
Since my Mac is offline, I had to guess what the PPC define should be... so it currently looks like :
#If defined(__APPLE__) & defined(PPC)

Try changing it to simply
#If defined(__APPLE__)

...if anyone knows what the "proper" definition for a PPC compile is, I'd be grateful to know...


Oh, and btw, libxslt is now available :-)
You can either syncmods for it:
syncmods -u your_name -p your_password bah.libxslt

or get it off the website...
As usual, full source, documentation and short tutorial included ;-)

:o)


bradford6(Posted 2006) [#12]
Brucey,
I just want to reiterate what an excellent job you have done with the LibXML mod. Thanks for your hard work on that.


Brucey(Posted 2006) [#13]
Thanks :-)
As with all the mods, I try to make them as easy (in a Max way) to use as possible, and try to have them reasonably well documented with (I hope) useful examples.


Just updated lots of mods today (including libxml). Here's the list of changes :

BaH.libxml
* Exposed some XPathContext properties. 
* Fixed TxmlBuffer getContent not returning anything. 
* API change - Renamed TxmlURI URIEscapeStr() to URIEscapeString(). 
* Docs tidy up. 
* Many more examples.


BaH.cairo
* Added CreateFromImage function to TCairoImageSurface. 
* Proper SetDash implementation. (API change!) 
* Added group methods - PushGroup(), PushGroupWithContent(), PopGroup(), PopGroupToSource() and GetGroupTarget(). 
* Added CAIRO_EXTEND_PAD const. 
* Added pattern GetType() and pattern type consts. 
* Added NewSubPath(), SetScaledFont(). 
* Added font type consts. 
* Added scaled font methods - TextExtents(), GetFontFace(), GetFontOptions(), GetFontMatrix(), GetCTM() and GetType(). 
* Added font face GetType(). 
* Added surface methods - GetContent(), GetDeviceOffset(), SetFallbackResolution(), GetType(), and surface type consts. 
* Added image surface methods - GetData(), GetFormat() and GetStride(). 
* Added PDF and PS surface SetSize() methods. 
* Improved API documentation.
* Linux now requires libcairo (1.2.0+) installed.

Note for Linux build - BaH.cairo on Linux now uses libcairo on the system rather than using the included library source. You will need to have at least libcairo 1.2.0 installed.

BaH.libsvg
* Updates to cvs versions of libsvg and libsvg-cairo (1 Dec 2006)


BaH.GTKMaxGUI
* New popupmenu functionality. 
* Added EVENT_MOUSEWHEEL events for canvas and active panels. 
* Added EVENT_KEYDOWN and EVENT_KEYUP events for active panels. 
* Added EVENT_KEYCHAR events for canvas and active panels. 
* Added EVENT_KEYREPEAT for Canvas and active panels. 
* Fixed canvas mouse up not reporting button data. 
* Fixed canvas generating double ACTIVATE_REDRAWs. 
* Fixed some key mappings. 
* Fixed PANELPIXMAP_TILE not resetting to 0,0. 
* Fixed panel redraw event handling.



RepeatUntil(Posted 2006) [#14]
Excellent job!! I am using libxml and this is just great!


Brucey(Posted 2007) [#15]
Hallo folks, and welcome to 2007.

Only a couple of updates this time.
Mostly it's all about UTF-8 support (you know, those non-ASCII characters some people like).

BaH.Libxml (1.09)
* Added automatic libxml UTF-to-Max and Max-To-UTF String conversion. Fixes non-ascii string issues.
* Added getLineNumber method to TxmlBase.


BaH.GTKMaxGUI (1.14)
* Fixed non-resizable window resizing problem with menus and statusbar changes.
* Fixed ComboBox not clearing items.
* Rewrite of UTF-8 handling... *sigh*
* Fixed UTF-8 issues with Notify, Confirm, Proceed, RequestFile and RequestDir.


I've also updated (on my website - see link in sig) BaH.Volumes, which now includes Mac OS X support, and therefore completes the set by supporting all three platforms. (Volumes gives you volume/drive information for your PC)

I've been thoroughly testing UTF-8 support in both libxml and GTK, and all seems to be going well. Hopefully I'll be releasing another module in the not too distant future which supports localization in applications. It comes with a GUI utility app which makes keeping track of everything much easier, and also removes the need for editing of localized text-files. As usual, it'll be free, flexible, and reasonably well documented. ;-)


degac(Posted 2007) [#16]
Well done, thank you very much for your efforts!


bradford6(Posted 2007) [#17]
Thanks Brucey!

Happy new year.


Difference(Posted 2007) [#18]
Thanks!

Does the "Added automatic libxml UTF-to-Max and Max-To-UTF String conversion" has anything to say when I'm using the xmlReaderForFile functions and then ugly stuff like:

ElementName= UTF82LAT1(String.FromCString(xmlTextReaderConstName(reader))) ?
Function UTF82LAT1$(in$)
	
	Local inlen,outlen

	inlen = Len(in)

	Local outbank:TBank = CreateBank(Len(in))
		
	outlen = BankSize(outbank)
		
	If UTF8Toisolat1 (BankBuf(outbank) ,outlen ,in.ToCString(),inlen )>=0
		
		Local as:String			
			
		as = string.FromBytes(BankBuf(outbank),BankSize(outbank))
										
		Return Left$(as  ,outlen )
	Else
		Return in$
		
	EndIf
	
End Function	



Brucey(Posted 2007) [#19]
Well, unless I've missed one, all exposed API calls that return Strings are first converted into "Max"-type Strings, rather than what was previously going on - which was that I simply did a String.fromCString(byte ptr) call - fine if the text is ASCII only.
In my current tests, the Max libxml mod is now happily converting text of 170+ languages and displaying them correctly in a ListBox. (on both Mac and Linux, with, I assume Win32 also, once I get my App working correctly there). ... and before anyone asks, you need to have all the correct fonts installed for most of these to work. For example, on Windows, I had to install a 7+meg chinese font to get that text displaying properly. (it seems to be pre-installed on my Mac and FC5 installations)

Also, any exposed API that takes a String as a parameter should now be converted from Max String to UTF-8 String - which is what libxml appears to expect.
I've successfully opened, edited, and saved XML in Max that contains all kinds of native language script.

Btw, if you find any missing API that you think important.. please let me know.
I was surprised I'd missed xmlGetLineNo()... ;-)


Difference(Posted 2007) [#20]
Sounds great. I'll give it a good testing and report back.


klepto2(Posted 2007) [#21]
hi Brucey:
First awesome work espacially the port of the fontconfig module was very usefull for me. (I'm working on a new Textarea Gadget and a new IDE).

But here is a small screen what I will offer to you as soon I have everything debugged :



Yes, it is your GTK Module on win32, and till now it works really nice with some restrictions (no htmlview atm and some
problems with canvases when using imagefonts)

so, if you're interrested I will send the linux\win32 version to you. (the win32 package need the GTK+ Runtimepackage for win32)


Brucey(Posted 2007) [#22]
Hey Klepto, that's really nice.
Does the IDE work as well as it does on Linux? Certainly looks the same.


Brucey(Posted 2007) [#23]
Well, it's the end of the first week of 2007 (for those that follow the Gregorian calendar...)

I've got some more updates to announce.

BaH.GTKMaxGUI (1.15)
* UTF-8 fix for RequestFile filters and RequestDir path.
* Added text attribute with GetText and SetText methods to TreeNode.

see sebtest_9.bmx in the tests folder for the TreeNode fix.
I think now that I've covered all the UTF-8 holes in my GTK implementation, but you never knows...

BaH.Volumes (1.03)
* Added new functions : GetUserHomeDir, GetUserDesktopDir, GetUserAppDir, GetUserDocumentsDir.

and 1.02 previously added Mac support.

For anyone that's interested, the Volumes module gives you cross-platform support to what drives are available and what space/size they have.
The new functions provide things like the directory for the users Home, Documents, Desktop and Application Data (on Mac it is Application Support).
It uses the various platform APIs to get this information, so it should be fairly rigid...


Last but not least, I'm releasing yet *another* new module. This one is called BaH.Locale and provides a nice Localization implementation.
If you need flexible multi-language support in your Max applications, this might be worth a look.
It uses the Libxml mod to drive the file-format, and also makes everything nice and UTF-8 friendly by default.

It comes with support for 190+ languages, using the official ISO standards for language codes, plus, for most languages it includes the native version of the language name, which is handy for language selection menus etc.

I've also thrown in a small GUI app called BLFBuilder which I use for creating and maintaining the localization files. The app itself uses the Locale module, and as such demonstrates one implementation of the module.


As usual, you can get these either from my website, or via syncmods...

Enjoy!

:o)


SebHoll(Posted 2007) [#24]
How can you get Brucey's GTK module to work with Windows? I was wondering if this was possible...


klepto2(Posted 2007) [#25]
Ok I have uploaded the win32 version:
(seems there are a lot of bugs in the win version)

Download link for the Module:

http://klepto2.kl.funpic.de/include.php?path=content/download.php&contentid=15&download=go

The archiv contains a second archiv called lib.rar which contains the needed .a lib files for the win port and have to be extracted and copied to the BMax lib folder.
The module is already precompiled.

As a second download you have to download the needed dlls (only if you haven't installed gimp for windows) .

Get them from : ftp://ftp.gtk.org/pub/gtk/v2.10/win32/gtk+-2.10.6.zip

Have fun.

Currently you can't use the HTMLView Gadget because gtk makes a lot of problems if you will use the gtkhtml view.
Maybe someone else could solve this.


SebHoll(Posted 2007) [#26]
Thanks for the info - I tried it with Max'd GUI today and it's really broken. Menu's won't show at all, and the UI is really unresponsive. I thought it might help with cross platform development but it looks like I'll have to do that while booted in Linux instead.


morszeck(Posted 2007) [#27]
Hi Brucey. Cairo has it new release 1.4.0. can you take up this in your module?


Brucey(Posted 2007) [#28]
I'll take a look, morszeck :-)


siread(Posted 2007) [#29]
Hi Brucey. Can I just say that I love you?

I just found your Locale module and it's superb. Exactly what I was intending to write myself, and you've gone and saved me the trouble! Thanks.

I have noticed a small glitch with the BLFBuilder. If you have some tags then click Add. Give the new tag a name, then click on a previous tag (before giving the new tag some text) and you end up with duplicate tags. Then you have to delete them otherwise editing the text of either messes them both up. (This was the Windows build btw.)

Nothing major, and I will take a look at the code myself later, but just thought I'd mention it. Thanks again. :)


Brucey(Posted 2007) [#30]
Heh... thanks si ;-)

...you end up with duplicate tags

Cool... will take a gander at it.
You always think you've thought of every combination of doing something, and then someone else tests it and you find you hadn't :-)


siread(Posted 2007) [#31]
I've added a couple of features to the BLFBuilder. I hope you don't mind...

- Export CSV file
- Import CSV file

This means you can save your locale file as a csv, then open it in your favourite spreadsheet program. The advantage to this is that you can have a master file that you can share with your translators. If you have several people doing the translations it's very hard to simply share the .blf file as each person would have to wait their turn, but with a csv you can load it up in Excel and copy and paste contributions from the translators. It also makes it easier to add tags or text in bulk.

Then you just import it, save it as a blf and use it in your program. :)

The csv files don't support values at the moment (as I'm not using keyboard shortcuts) but it would be simple enough to add. Also, commas are converted to semi-colons in the csv file (so as not to mess the csv up) and converted back when imported. This means if you can't use a semi-colons in your text as it will be changed into a comma if you import.

http://download.newstargames.com/misc/BLF_CSV.zip


Brucey(Posted 2007) [#32]
That's excellent, si,

Tho I have a tweak for non-ascii characters, which won't save properly using the standard WriteFile.

Instead of
Local csvfile:TStream=WriteFile(filename)

use
Local csvfile:TStream=WriteStream("utf8::" + filename)

as this will write the data out in something you should be able to read (given any decent editor).

For example, exporting the example_01.blf gives the following :
Tag,af,de,en,es,it,ru,
eight,agt,acht,eight,ocho,otto,2>A5<L,


Note that the Cyrillic (Russian) text has been translated into something like a mess, basically.

In UTF8, the file looks like
Tag,af,de,en,es,it,ru,
eight,agt,acht,eight,ocho,otto,&#1074;&#1086;&#1089;&#1077;&#1084;&#1100;,

(Note: that this Forum converts the text to Unicode values - the file itself stores the characters properly :-p )

The Import should also probably load as UTF-8. (haven't tried that yet).

I'll be adding your revised BLFBuilder to the release.

Thanks for the work, and glad someone finds it useful.

:o)


siread(Posted 2007) [#33]
Ah, of course. I forgot to test those funny alphabets. :)


Brucey(Posted 2007) [#34]
The bug you mentioned is only on win32... seems to be fine on Linux (GTK / Qt) and Mac...
...There's always one...


Brucey(Posted 2007) [#35]
OK... sorted. New version of the module uploaded (1.01).

Turned out there's a bug with Event Hooks on win32, which is why it wasn't working quite right. Anyways, I changed the logic to work-around the bug. (that's Mac and Win there are Event Hook problems... geepers)

I also tweaked the CSV stuff a wee bit more.
The comma/semi-colon stuff wasn't working quite right, and I added support for newlines in text (you can have ~n for a newline in the csv text now).
And I used slices in place of the "retro" stuff.

I wonder if we shouldn't have some kind of "ini" import/export too, since you mentioned the idea of making it easy for people to add a new translation.
Perhaps something along the lines of:
[lang:en]
one=one
two=two
...

[lang:de]
one=ein
two=zwei
...

..where you would supply them with the default ini, and a blank ini in their specialized locale:
[lang:fr]
one=
two=


Just an idea...


siread(Posted 2007) [#36]
Ooh, slices. Something for me to learn about. And yes, newlines are quite important too. :)

I think ini files would be a great addition. Makes it easy to for anyone to read in a simple text editor.


SebHoll(Posted 2007) [#37]
Just seen your worklog and I'm looking forward to your Console GUI module... ;-)


Brucey(Posted 2007) [#38]
Just a couple of things today....

Some new cross-platform modules :

BaH.Random - A drop in replacement for BRL.Random (ie. you import BaH instead of BRL) which uses the same Function set, but utilizes the latest SFMT (SIMD-oriented Fast Mersenne Twister) code. Also adds a new Rand64() function which generates random Longs.

BaH.ClearSilver - A C-library templating engine, used by people like Google Groups. Comes with a basic CGI kit if you want to build CGI apps. As well as web-page generation, it's also good for generating code and the likes (well, anything that you can create from templates really).

BaH.Portmidi - I was asked to help with this recently. So here we are. Uses hooks/callbacks which is about as threaded as we get at the moment in BlitzMax. Hasn't been tested too much, but it does build on all platforms (which is something) ;-p


Also some updates (to the website) for Cairo and Libxml modules. I haven't had a chance to put them on Syncmods yet.. but for those that are desperate for them, head to the website.
Note about Cairo. On PPC Mac, you will need also a customized BRL.Pixmap module (which is also on the site). This makes it possible for me to not have to re-write the Cairo internals (like I used to do) to make it work with the different byte-order BlitzMax uses...

Enjoy :-)


GfK(Posted 2007) [#39]
Nice - just installed the Random mod.

It did catch me out, though - at first I didn't realise I had to call SeedRnd() before anything else worked.

No big deal, but couldn't it default to "1" or something?


Brucey(Posted 2007) [#40]
No big deal, but couldn't it default to "1" or something?


It could indeed :-)


Brucey(Posted 2007) [#41]
BaH.Random (1.01) now automatically seeds to 0 if not done so before a call to one of the functions.

Thanks GfK ;-)


GfK(Posted 2007) [#42]
Thx!

*nudge* The dates on your website are wrong. portmidi and random mods show 2006 - should be 2007! ;)


Brucey(Posted 2007) [#43]
Thanks... I've been writing 2006 all year :-/


siread(Posted 2007) [#44]
Hi Brucey. I just found a small bug in Bah.locale.

Line 722: If comma Then

Should be: If comma > -1 Then

The find function returns -1 if a string isn't found. This was causing a problem if there wasn't a comma at the end of every csv line. :)