Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Porting (read: rewriting) a WxWidgets app for Mono/GTK#, Java or ...?

This thread is locked; no one can reply to it. rss feed Print
Porting (read: rewriting) a WxWidgets app for Mono/GTK#, Java or ...?
Mika Halttunen
Member #760
November 2000
avatar

As you might know, my CSSTint (see my sig) uses wxWidgets, and is currently Windows-only. It was a bit of a let down, when I tried to compile it on Linux. It would compile only after several code changes, and even then the main view is broken, since the ListView cannot be customed like in Windows. So the Linux build is quite unusable.

Now, it would be probably fixable, but somehow I've been thinking of rewriting the whole thing for the sake of learning and interesting experience. The current wxWidgets version is IMHO very usable, so I'm targeting only Linux (+ MacOS X maybe) here. Naturally it doesn't hurt if the rewritten thing runs in Windows as well. :)

I've been thinking of three approaches:

  1. Write for Mono/GTK# using MonoDevelop as the IDE (it has an UI designer, which would help - I wrote the wx version without any)

  2. Write for Java using Eclipse (no UI designer, unless there's a plugin..?)

  3. Write for native GTK (could use a lot of my existing non-UI related C++ code)

So, I'd like to hear some opinions and comments. Am I out of my mind (it's quite a big ordeal, rewriting the whole thing, I know)? If you had to rewrite that kind of program, what language/platform would you target for?

Any other tips, e.g. if you'd choose Java for this, what component you'd use for the main color list? In wx I used a ListView in detail mode, where I just painted the color column differently. Now I think the best way would be to use a table, where you can have different cell-renderers, so doing the color column would be a matter of implementing a cell-renderer that renders a rounded box for the background.

{"name":"dbimage.php","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/b\/fbfd0a36f9d03d797ccc62c6a74030ad.jpg","w":615,"h":395,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/b\/fbfd0a36f9d03d797ccc62c6a74030ad"}dbimage.php

Also, if I start doing this, I could write a blog of some kind of the "porting" progress. I think it'd be interesting to read later on, but I don't know if anybody else would want to read it. :) Discuss, please. I appreciate any input on this, I'm not even sure if I want to do it or not. ;)

---------------------------------------------
.:MHGames | @mhgames_ :.

Goalie Ca
Member #2,579
July 2002
avatar

Probably easiest in a high-level language. I would vote for python + gtk or mono + gtk

-------------
Bah weep granah weep nini bong!

Mika Halttunen
Member #760
November 2000
avatar

Quote:

Probably easiest in a high-level language. I would vote for python + gtk or mono + gtk

Yeah, Mono + GTK seems like a good choice to me at this point. I haven't really used Python, C# fits better into my way of programming. :) But then the Java option also interest me, and Eclipse's just great.. Choices, choices.. :P

---------------------------------------------
.:MHGames | @mhgames_ :.

Carrus85
Member #2,633
August 2002
avatar

I'd second python, probably with wxpython for the gui. Python as a language isn't really that hard, and you would be using the same gui toolkit, which is cross platform.

Thomas Fjellstrom
Member #476
June 2000
avatar

I'd go with Qt personally. Its a much better cross platform API than gtk will ever be. (mono and wx are gtk based)

Its good enough that Nokia, a company that was committed to doing their own software and toolkits for devices had a radical switch recently and acquired TrollTech, the creator of Qt, and explicitly asked them to teach Nokia how to make cross platform phone AND computer software. Also, Qt, and not Qtopia (embedded version of Qt) will be the toolkit for a couple of Nokia's higher end platforms soon.

Also note that Qt isn't just a GUI toolkit, its a platform toolkit. You code to Qt, not "windows, unix or osx", so theres rarely and special code for any of the platforms you're targeting. Just pure Qt api calls. Makes things easy to maintain.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Mokkan
Member #4,355
February 2004
avatar

I'd go with either Mono+GTK# or Qt. I thought wxWidgets was supposed to be cross-platform? Seems strange how it won't work right on Linux. Hm :-/.

Thomas Fjellstrom
Member #476
June 2000
avatar

If you choose Qt, go Qt4. Specifically 4.4 if you can.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Mika Halttunen
Member #760
November 2000
avatar

First of all, thanks for your replies everyone! :)

I've done some Python, but it feels a bit awkward for me, you know, the sudden lack of semicolons and curly braces.. ;) I guess I'd probably get used to it pretty soon, though.

Heh, I figured it'd be you recommending Qt, Thomas. :D I'll have to look some info on it. Somehow it didn't occur to me at all, maybe since I'm mostly a Gnome user. I've been a bit spoiled by C# (and Java) garbage collection lately, though, so C++ doesn't sound tempting in that sense. Feels funny saying that, because C++ is what I've used for like 8 years now. :P How usable is Qt with Java, btw?

Quote:

I thought wxWidgets was supposed to be cross-platform? Seems strange how it won't work right on Linux. Hm :-/.

Yes, it is cross-platform, but apparently some things are different between the ports.. Then again, what I'm doing with the ListView on the Windows version is basically a big, ugly hack, so no wonder it doesn't work. Especially the "Edit in place" command is even bigger of a hack, therefore I'm hoping to use a real table where I can just say cell->showEditBox().

Current status: Mono+GTK# seems good, and Qt is something I'll definitely have to check out. Thanks for the comments, guys, keep 'em coming!

---------------------------------------------
.:MHGames | @mhgames_ :.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

:P How usable is Qt with Java, btw?

QtJAmbi

Quote:

I've been a bit spoiled by C# (and Java) garbage collection lately, though, so C++ doesn't sound tempting in that sense.

Qt handles most of the memory management for its own classes. Once you create a QObject based object and add it to a parent QObject, the parent takes charge of the object.

Generally the only memory management I need to do in many Qt projects is the initial:
MyApp *app = new MyApp(...); ... delete app;

Anything more complex can use Qt's container types and fancy Database access classes, and still not require too much memory management.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Mika Halttunen
Member #760
November 2000
avatar

Thanks Thomas; Qt seems sweet, and even the QtJambi demos run beautifully, straight through Java Webstart. :) The memory management looks also quite bearable.. ;)

Ok, I think I've got this narrowed down to Mono/GTK# and Qt. Still have to think about this, and try more Qt stuff.

EDIT: What about Java + SWT instead of Swing? SWT seems nice too.

---------------------------------------------
.:MHGames | @mhgames_ :.

Thomas Harte
Member #33
April 2000
avatar

I'd like to recommend QT over GTK+ for the simple reason that QT uses the native widgets of the platform it's compiled for, whereas GTK+ does all it's drawing for itself, on the CPU. Making it slower on some OSs, and making GTK+ apps always look slightly out of place.

CGamesPlay
Member #2,559
July 2002
avatar

Quote:

(mono and wx are gtk based)

Err, no. Mono is a runtime. Gtk# is Gtk based :P

Qt# exists. Also ActiveQt is done by TrollTech, but it isn't free.

Mika: Have you considered building a web application?

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Johan Henriksson
Member #11
April 2000
avatar

SWT has an awkward programming model. it is really a step backwards. unless you're really begging for a more native-like user interface, it is not worth it (swing looks perfectly native on mac and linux).

you'll find distributing the code easier to achieve with java than with python or C#. the latter have portability problems in practice. then there is always the speed...

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

swing looks perfectly native on mac and linux

If by native, you mean fugly :P I run KDE/Qt, not Gnome/Gtk, so its "native" look will look like gtk, and won't even respect the gtk themes I have set, so its useless.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Mika Halttunen
Member #760
November 2000
avatar

CGamesPlay said:

Mika: Have you considered building a web application?

No no, I don't like web applications.. :)

I've been playing a bit with QT Jambi in Eclipse. Seems to work quite nicely, although I've been doing just Hello Worlds for now.

---------------------------------------------
.:MHGames | @mhgames_ :.

Thomas Harte
Member #33
April 2000
avatar

Quote:

swing looks perfectly native on mac and linux

I don't think it does. Per wiki:

wikipedia said:

Swing widgets provide more sophisticated GUI components than the earlier Abstract Window Toolkit. They are designed to be consistent across all platforms, unlike AWT widgets, which map directly to the current platform's graphics interface without modification. Swing supports a pluggable look and feel by using the current platform's graphics interface to achieve consistency through modifications made by additional API calls.

And here's the first Swing application I could find online, running under OS X:
{"name":"594397","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/b\/0bde61c1d9483ac4fbac2a4780e60286.png","w":652,"h":456,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/b\/0bde61c1d9483ac4fbac2a4780e60286"}594397

It looks nothing like a native OS X application. The fonts are horrid (usually a sure sign of toolkits that don't use native widgets — since they never use the various OS's built-in LCD subpixel rendering system1), the colours are wrong, the widgets are all wrong and the menubar is confusingly in the application.

1 and don't get me started on the kerning.

Go to: