Cross platform GUI Programming with D - user-interface

I want to start programming with D. I have a simple application in mind that needs a GUI but I want to make sure it's portable to Linux/Windows/Mac equally well and with minimal (no) change for each platform.
wxD is looking like the contender of choice because I know the wx toolkit already.
I see fltk4d as a contender and a (unfinished) wrapper around Qt.
Are there any other truly cross platform GUI toolkits for D that will go where I want with little effort and what would the the toolkit of choice for people here?

GtkD should be a very good option for you as a stable Windows/Linux/Mac GUI toolkit.
DWT was once considered the standard, it has its own newsgroup on the Digital Mars server and I think Walter Bright may have called it the standard too. I don't think it's completely working on Mac but this should change in the future.
Here is a nice list of some other options but most have less active development and/or are not yet ready for production.

I have not used any of D's GUI libraries, but I would go with wxD if I wanted to use one now. I would pick it because I think wxD would have the most native looking controls and is cross-platform. Especially since you already know wx, it looks like a good choice.
I'm actually writing a cross-platform GUI library, Dynamin, but I have not released it yet. It is not a port; ported libraries tend to not have as nice of APIs or take advantage of as many language features. But it is not far enough along to do more than simple programs. I also don't have a Mac backend or GTK theme yet.

Related

Differences that matter between GTK+ and QT?

What are the finer differences between QT and GTK+?
Specifically I need to know the finer differences.
Language neutral, Windows/Linux neutral. Just the finer points please...
How native are the widgets / controls to the window manger, from its standpoint? Example: If it were a text control, would it process: a WM_COMMAND or EM_SETSEL message sent to it? If not, how do third-party applications / screen readers interact with the control / widget?
Advanced widgets available in one toolkit and not available in the other? Add-Ons are fine to describe.
What is the quality of theming from a multimedia / special effects standpoint? like powerpoint style special effects such as fade-ins of widgets/docks. What's the ease of coding for these scenarios?
Note: I'm probably biased towards Qt as I never used GTK seriously.
Qt's graphics view and scene system is awesome, GTK only has low level Cairo.
Writing custom widgets seems easier with Qt, probably because of the OO design. I don't know which API has more "advanced" widgets, but the basic ones are probably enough for most applications with a little bit of customization.
If you want a completely custom display for your app with special effects and all, you can easily write one based on graphics view/scene. Qt 4.7 also adds Qt Quick to design fancy interfaces, I didn't have the opportunity to test it yet but it looks pretty cool.
Overall I think both are great frameworks and offer enough for any application, but with Qt you get everything in a nice package, when you have to use 3rd party additions or reinvent the wheel to get the same job done with GTK.
Although you didn't ask this, it's worth pointing out the different philosophies between Qt and Gtk+ (or Gtkmm, the C++ version of Gtk+).
Qt is a full application development toolkit. It includes XML parsers, concurrency framework and so on. Gtkmm is not. From the gtkmm documentation:
gtkmm is a GUI toolkit and nothing
more, and it strives to be the best
C++ GUI toolkit. That mandate does not
cover generic C++ data structures, an
XML parser, or database access.
The probably more fair comparison is between Qt and Gtkmm + a set of GNOME libraries.
For advanced widgets the GNOME libraries are really nice - take libgoffice, for example. But it doesn't have a beginner friendly documentation and you will end up having to ask questions in the mailing lists or the IRC channels. Qt is also very nice and have a much friendly documentation. The quality and availability are equivalent, in my opinion, but Qt usually have more documentation or, at least, is documented in a way more friendly to "outsiders".
Both have high quality presentation and effects. No meaningful difference. I like the Gtk+ appearance more than Qt, but it just a matter of personal taste.
Not a complete answer, but:
I find it really difficult to
customize widgets in Gtk+, e.g. I
want the behavior of widget X, but
need to tweak the look beyond the
usual style settings.
OTOH I don't like Qt's moc, but that's more of a
personal thing.
I'd also strongly
recommend Gtkmm (the C++ wrapper)
over plain Gtk+.
Sorry if this bias to qt and shallow
Qt has many eyecandy effect ( dont know about gtkmm).
Qt has Qtconcurrent, higher level api for multithreading. probably more readable
than Qthread Qmutex blablabla...
Based from your question I think you want to integrate desktop app to www,
so just compare for yourself between qtwebkit , gtkhtml and gtkwebkit which one is likely to fit you better.
I've narrowed it down to XULRunner or GTK+.
Here's why:
I need to quickly become familiar with the internals. QT makes this difficult for me with so much on their ease-of-use solutions.
QT is HUGE! I stopped a custom compile after it had been running for over 4hrs on my 3Ghz P4! to be fair, QT provides many precompiled binaries
Out of the box themes for QT are rather too 'professional' looking. I need something cool, GTK+ has some neat themes which I can modify.
I don't need / want to use the framework for networking, file management, multimedia, webkit, or anything besides a GUI frontend to other apps.
Note that the license in Qt is LGPL which is not good enough for many commercial projects. Same for GTK+, but at least you can pay for legally using Qt in commercial projects.

Is there any cross-platform GUI Toolkit which does not follow the one source to rule them all concept?

After a long evaluation period of mainstream toolkits Qt, WxWidget, GTK i came to the conclusion that it does not make sense to religiously equalize the different platform. Now more then ever before.
In the days before Java portability meant, that platform dependent code was located in known places and should be small but not none. No write once, run everywhere marketing.
Is there any GUI tookit - experimental or commerical (even outdated or dead projects) - that is going this way. It would need to give me native widgets of course. I would like to have a look at them before i start my own toolkit
If you think this is a stupid idea tell me why (cause everybody else is doing it differently there may be a reason i don't see)
As someone who zealously believes that GUIs should be drawn with native widgets, I must say I've been very impressed with wxWidgets, although you mention that at the beginning.
As far as I know, wxWidgets uses native widgets whenever possible, and indeed it does also include platform-specific features that are neither possible nor relevant on other platforms. A good example of this is how you can use the native Mac OS X menu, while on other systems it won't do squat. There are other and better examples.
I must mention wxPython in particular, in case you either don't want to or just don't have the time to write a C++ program. wxPython astonished me when I tried it out first, and I even managed to make a stand-alone .exe file from it that worked on a fresh install of Windows 2000 without any updates or particular runtime environments.
If wxWidgets doesn't suit your needs, I wonder what would. :) Hurray for wxWidgets!
AFAIK, wxWidgets uses the platform's native widgets whenever possible.
Have a look at SWT, it tries to use the widgets of the underlying platform as much as possible.

How to decide GUI Framework for desktop application project

I am working on a new small utility desktop application but I am not really able to choose the GUI framework to use. I have worked on both JAVA,C# and C++, so language is not really a constraint. My criteria are:-
A very well designed architecture, something like QT. It's better if it follows typical C++ design methodologies.
Layout management should be easy, intuitive and not really cumbersome. I hate adjusting pixels on screen.
Its license should be open.
It should look good :)
Mentioned QT seems to comply to all your requirements. QT has "deploy everywhere" attribute, whilst Java needs no deploying at all (it depends on what is use of your utility).
Ad. 2 QT has really convenient GUI designer.
Ad. 3 LGPL. Usually it is enough.
Ad. 4 It is always matter of taste. IMO QT4 looks awesome under linux, but it's windows look'n'feel is correct at best. It's strong point is, that without additional tweaks it almost everywhere looks native.
I've been using Swing, and it works fine. NetBeans (a decent IDE by itself) even supports graphical GUI building.
It's well designed (basically
everything is done with listeners,
functions that are registered for a
certain event). It has bindings, so
you don't have to write code to set
up a value in a text field or read
it out
Layout is not perfect, but
acceptable within NetBeans. It's
WYSIWYG (almost). Look-and-feel can
be changed on the fly.
License is free. Source-code is not
available, I think.
Looks fine on Windows and Linux,
less so on OSX.
You could always try SWT. The advantages of Java with the standard L&F of supported operating systems.
Well designed. Lots of
documentation, and very easy to
develop with. (If you know Swing,
you can pick up SWT in no time.)
I believe layout managers do exist
that support SWT. I'm not positive
about this though, as I typically
don't use layout managers too much.
Uses the Eclipse Public
License. Should meet most of
your requirements.
From Wikipedia on SWT:
SWT is written in Java. To display GUI elements, the SWT implementation accesses the native GUI libraries of the operating system using JNI (Java Native Interface) in a manner that is similar to those programs written using operating system-specific APIs. Programs that call SWT are portable, but the implementation of the toolkit, despite the fact that it is written in Java, is unique for each platform.
Hope that helps you.
I'd suggest wxWidgets if you want to program in C++ or wxPython (the python language binding of wxWidgets if you know or don't mind learning Python.
Architecture is similar to QT I think.
Layout using sizers. Quite easy once you get the hang of it.
Liberal open source license.
Widgets are native on all platforms (Windows, Mac OS X, Linux).

Favorite graphical subsystem to program in

Ok, this is an interesting question to ask because everyone has a say in it.
What is your favorite library to program in for GUI's and the language that you program it in. Give a short reason why. (ex. Gtk, Qt, Windows, etc..) Just an FYI, this includes any scripting language that you program a GUI in Python, Perl etc...
Frankly I've always done Gtk in C, but I'm starting to warm up to Qt in C++ with the new KDE. I've never been a big fan of Windows programming.
ChrisW. stated that I did not give a reason for Gtk/Qt so here goes. I started with Gtk because when I started programming GUI's I was working in Linux and there was more Gtk information available. Started utilizing Qt when I started working more in KDE but really the move to Qt was based on trying to move to C++ and learn more languages. I've never been a fan of basic Windows programming, but I do enjoy a little DirectX now and then :P
Recently I had the opportunity to work with both wxWindows and QT, while some time ago I wrote some small programs using FLTK and Gtk. My conclusion is that widget libraries tend to be very similar; each one has its strenghts and its quirks.
Instead of advocating a specific library, then, I would like to advocate the use of high level languages in GUI programming: the development cycle is way faster and GUI programs are rarely CPU bound, so the performance hit is rarely a problem.
If a GUI program has to perform some intense computations, just develop a core library in C or C++, but keep the interface in Python or whatever other interpreted language.
People like to bash Swing for being old, slow and ugly, but it's just not true. Swing is mature, is faster than ever on Java SE 6/10, looks decent enough, and is tolerable to program. Above all, I've found Java + Swing to be the most trouble-free cross-platform combination. It also works remarkably seamlessly with Jython (Python on JVM).
SWT could also be an option, but so far I've been happy with Swing.
I realise you're focusing on application GUIs but if you want a quick, powerful and fun way to visualize anything on your computer, you can't go past Processing
From the site:
Processing is an open source
programming language and environment
for people who want to program images,
animation, and interactions. It is
used by students, artists, designers,
researchers, and hobbyists for
learning, prototyping, and production.
It is created to teach fundamentals of
computer programming within a visual
context and to serve as a software
sketchbook and professional production
tool. Processing is an alternative to
proprietary software tools in the same
domain.
WPF in particular, and XAML in all its reincarnations (WPF, Silverlight, Moonlight).
C# on top of .Net 3.5/Mono: $0
Visual Studio Express/MonoDevelop: $0
Being able to tell the designer "make my program pretty" and continue coding features: priceless.
I liked writing to video memory under DOS: for an animated game (i.e. an Asteroids clone), that was as fast (performant) as I knew how to do it (certainly faster that using the BIOS API).
This is really a somewhat subjective question, so there is no best or correct answer to it. The following is based on my (limited) experience:
I personally like wxWidgets with PLT Scheme for writing simple but flexible GUIs. There are much more advanced toolkits, but I usually do not need their features. wxWidgets is flexible and the Scheme interface follows Scheme traditions of being powerful with a relatively simple structure. I like the fact that wxWidgets is portable, and yet tries not to actually draw its own widgets, but can use native or common toolkits of the environment it is used under. It is written in C++ but I never used its C++ interface.
That is not to say that in my opinion Scheme will generally be the optimal language to write your application in. In fact there are many kinds of applications I would not write in Scheme, even though I like the language. But regarding the GUI programming part, that is my favourite because of its straight-forwardness, and the way that a functional language like Scheme goes well with declarative-style GUI programming.
Of course you will not have the same level of control when using that as when having your program involved in every stage of the window construction and input reaction, by using an event loop (such as with Win32API or Xt/Intrinsics). But that is not always convenient and often unnecessary, and seems to become decreasingly common.
Note: The wxWindows toolkit was renamed wxWidgets, but my installation of a rather recent version of PLT Scheme still comes with the older wxWindows. I am not sure whether there is an updated package of wxWidgets available or if it is going to be included in a future version of PLT Scheme.
Qt4 without question for me. Now that it has an LGPL license it makes sense for all kinds of applications that previously weren't possible. Additionally, it changes C++ in ways that dramatically improve the experience of using the language. (Things like a foreach and forever loop, atomic operations on integers, and memory management)
Gtk and is the primary window-drawing graphical subsystem I have experience working with (and is therefore my favorite XD).
As far as general graphics subsystems go, however, OpenGL (typically in combination with GLUT) has been an easy and productive ride for me. Regrettably I have little DirectX experience to compare to, though :S
For writing souped-up versions of standard Windows components, I loved Borland's VCL, and am very pleased with .NET.

osx & windows development -- for newbies

my background: i've been developing web applications using php and javascript for the past ten years. before that, i've developed applications using turbo pascal for DOS. in my opinion application and web application development are two different kinds of development (at least it's what i think when i remember back the old days of DOS application development).
now i am in the need to go back to "normal" application development for various reasons. the application i want to build needs a GUI and it has to run on osx and windows. as mac os user it would be very nice for me to get an application as result, that really feels like an osx application. i don't need any special UI components: an explorer/finder like tree, a datagrid and some form-elements would be enough for my needs.
now the problem is, that i don't know where to start: i would classify me as newbie, because it's that long time since i last developed anything other than a web application. are there any recommendations of programming languages and gui toolkits with a not to steep learning curve? or can you recommend any book i should read for getting into cross-plattform osx/windows app development?
many thanks!
thanks everyone! i think i'll have a look at realbasic!
Edit Nov 2011 - a retraction
Most of what I say below is still true however I have now got serious reservations about recommending REALbasic for anyone trying to release commercial-quality applications. To save me remembering to edit this post later, see if RealSoftware have managed to release a robust version of their IDE using the Cocoa version of their frameworks. If not, be very cautious.
It's with a heavy heart that I write this because I still really like the language and think the framework and IDE are well-done. The problem is apparently one of under-capitalization and possibly a software development culture inside the company that consistently fails to deal with a bug regression problem. Many bugs are fixed each release but there appears to be a huge tax on the developers in the number of introduced bugs. They have a very small team for the complexity of the product, especially considering the newly released Web Edition which is effectively an entirely new platform.
It's still theoretically a great product but take advantage of the trial period, test it thoroughly on each of the platforms you plan to target and decide if you can live with any bugs you find because they may be there for a while.
REALbasic.
The language is a powerful, modern OO language that won't be hard for you to adapt to from your vaguely remembered Pascal or current JavaScript. It has most of the power of C++ without the dangerous bits that make debugging a nightmare. You will also find the IDE simpler and easier to deal with than say Visual Studio.
The IDE makes it very easy to throw together a GUI and have it just work on multiple platforms. The Pro version has one of the best cross-platform debuggers I've used and it is easy to just work (say) on a Mac and develop for Windows and Linux, compiling and testing with one click.
There is also a thriving community including many people at your level of expertise so you won't be mocked for being a newbie.
I am a professional software developer with over 25 years experience and currently mainly working in REALbasic, C++, C#, Objective-C and a bit of Ruby. For apps such as you mention, REALbasic is my tool of choice.
edit: I can't believe someone downvoted this but didn't have the guts to add a comment explaining why. I'd heard about prejudice against REALbasic but this is the first time I've encountered it. In what way was my answer inappropriate for this question?
Just to add to my cred, I've implemented cross-platform frameworks used by systems deployed to tens of thousands of end users - I have the C++ cross-platform experience to applaud someone else doing a good job and the REALbasic frameworks are very nice.
The best cross-platform tool I've dabbled in with a relatively small learning curve...especially if you're familiar with Visual Basic...is REALbasic. With REALbasic Pro you can compile a program to target Win32, Linux, and OS X from the same codebase, as long as you're not using OS-specific calls and features (which you can do with plugins or direct calls). Their support has been pretty responsive to my questions, the personal edition (which compiles to only the single target platform you'd downloaded the IDE for) is free for Linux and inexpensive for other platforms, but really you might want to download and try it out. One IDE, relatively inexpensive, and can compile native applications on OS X, Windows, and Linux...it's less hassle, and for me that's important when you want to get a job done.
I'd advise against C and Qt and would also recommend REALbasic.
With your background in Pascal and probably JavaScript you'll feel much more comfortable with REALbasic. I've done a lot of coding in Pascal and C/C++ - where Pascal guides you to avoid programming mistakes, C lets you step right in, even invites you, and then you'll have a hard time figuring out why it went wrong. Qt is a very abstract framework and requires you to learn a lot before you can get something working, just like with C. When compared to the easyness we used to have with TP back then.
RB is much more like Pascal in this regard. And its IDE is quite modern in regards to supporting your programming, with an easy-to-use GUI designer, straight-forward editor to fill in the gaps for handling UI events, code completion, etc.
Only when you get into huge program sizes, RB loses some of its appeal because it is missing tools to give you a good overview of complex class interactions etc.
Another thing is that Qt is more likely to cause ugly-looking Mac apps than RB would. RB visually guides you to get it all aligned nicely - in Qt you have to work with numbers, offsets, etc. to position your objects (at least it was that way when I used Qt 2 years ago).
I've written quite a few x-platform apps in RB and am pretty happy with the results.
You won't probably write those super-nice looking apps that compete with the best on the open small business market, but if you just want to get some solid code working, with an easy-to-design UI that's acceptable to the average user, give RB a try.
It's not free, though. But its rather small community is on your side - they're eager to help, instead of bashing everyone who's trying to talk sense :)
I'm new here but picked up on this thread through the REALbasic User Group. I think my position was similar to yours. I did website design for my work, using mostly javascript (with a little php, not much). I had a Pascal and BASIC background. I'd dabbled it C but didn't like the level of detail you needed to monitor it. It reminded me too much of assembly (which I still have nightmares about from my high-school/college days).
I was looking for a cross-platform language, with a familiar feel to it, but initially started with VB because it was free. I prefer programming in MacOS however, so I tried REALbasic. I found that REALbasic's UI builder was much easier to use than VB's. I'd echo other comments that the community is the most responsive of any user groups I've been involved with. I've since used REALbasic and my Mac to make several programs that over 100 users use every day at my work (on PCs, mostly XP and 2000). I've received compliments on the polish and ease of use of these programs. You DO have to remember to adjust the 'little' things to make it look right cross platform (ie: default button placement is opposite on PC vs. Mac, button sizes are different on Linux, etc). Many people have donated custom classes that do this stuff for you though.
People seem to assume that a "BASIC" language cannot be powerful enough for their purposes. While it is BASIC at it's core (with For..Next, Do..While, and If..Then commands), it ain't your daddy's BASIC. It's much more OOP than anything else I've used, based upon an event-driven structure, which for me was easy to pick up. They have a free trial, so grab a demo and run through the tutorial. If you get stuck, ask for questions on the NUG or Forums at the website and you'll likely get an answer quickly.
You may be interested in the following questions and answers:
Cross-platform development - Go with a cross-platform UI toolkit or native on multiple platforms?
Easiest cross platform widget toolkit?
Should I use a cross-platform GUI-toolkit or rely on the native ones?
Using a Mac for cross platform development?
and many others suggested in the Related sidebar of these questions.
Some answers suggest gtk (which is used by cross-platform gimp). Others suggest native approaches. Some suggest that a Mac is a nice platform for developing for Mac OS X, Windows, Unix and Linux.
I wholeheartedly recommend RealBasic too. I have been using RB for about 8 years now and find it to be a perfect tool for my Companies development needs, from small apps, to large multi-user systems.
It is perfect for beginners and those that are getting back into programming, and also for professional developers.
Highly recommended.
As Andy Dent and others here have indicated, for a newbie to create cross-platform applications it is hard to beat REALbasic (now Xojo).
Sure, there are plenty of other cross platform solutions such as QT (C++), Java, .NET (to some extent) and wxWidgets but they are not something a beginner would be able to use effectively.
I have many years of professional development experience in a wide variety of languages and technologies and I prefer to use REALbasic most of the time.
With that said, you might also consider Runtime Revolution or Adobe Air.
Whilst it might seem tempting to use a language thats platform independent and allow you to write the app once and use anywhere, you will undoubtably be sacrificing something on each, particularly in the UI and user experience.
If you can your best creating something using a native API that lets you take full advantage of the features of the OS to make your application shine.
I would definitely go for C++ and Qt, the code you write once will compile and run without problems on Windows, Mac and Linux. The new IDE that comes with Qt - Qt Creator is brilliant, works and looks the same on Windows, Mac and Linux, you don't need to anything else to start writing cross-platform applications.
I tried WxWidgets but didn't find good IDE, the best one was Code Blocks but GUI Designer is not perfect and has different problems on different systems and the IDE itself is still under heavy development.
Other options are Java and C# but those are not cross-platform languages, those are platforms themselves. Although you wouldn't need to compile code for each platform there will a lot of different issues on the way...
If your GUI's simple enough, why not just create a generic GUI layer, then program to that? Compile a version for each OS using native widgets. That's the best way to ensure native L&F on multiple platforms.
Both the Qt and REALbasic suggestions are good, although they tie you to that particular technology (which I can't imagine would be an issue in this particular case).
Personally, I'd go with Java, because it's worked for me before (I had an app that ran on my PDA, my phone and my desktop), but it doesn't use native widgets.
Adding a late comment here:
Take a look at Revolution. It's sort of like a modern Hyper-card on roids. And it's cross platform (Mac, Linux and Windows). This is a serious competitor to RealBasic and is coming on strong. Though I still use RB (and like it) I'm giving Revolution a serious look at.
I would also look into either Realbasic or Revolution. They both create cross platform native apps. Personally I think Realbasic would be a better choice as it is very similar, language wise, to VB. You can learn some valuable skills with RB and it can grow with your experience. I have been using VB and RB for more then 10 years combined and I think you will be happy.
If you need your code to be cross platform, you would have to go with something like QT.
Although, I would recommend using native API for each one (Cocoa for Mac OS X, .NET or the Win32 API for Windows). User experience will be much better. But of course, that will cost you more money in terms of developers hours.

Resources