tags:

views:

514

answers:

7

So I've been learning C# for like a year now (I'm 20 years old) and I'm getting pretty confident with it. I've also been meddling with C++ every now and again. For example just recently I've been following the Nehe OpenGL tutorials for C++ and I find it a fun way of learning.

I want to start looking at creating cross platform GUI software after I stumbled across this library called FLTK (fluid something rather). After finally and painfully getting it to work I found it refreshing to know that there are solutions for GUI creation in C++, however I think FLTK looked pretty old.

So I googled around for some newer GUI frameworks and decided to start playing with wxWidgets (decided against Qt because of licensing). I downloaded it, compiled it, and looked to see if there were any IDE plug-ins for RAD development, as you can imagine going from drag and drop a component onto a form in C# I was hoping for something similar.

I learned that code::blocks has something of the sort so I tried that out. It was alright but the thing that turned me off was the horrible code completion; it would only show members and methods in the current object and nothing for the #included header files. I understand that code completion/IntelliSense isn't easy for C++ but Visual Studio 2008 handles it pretty good. I did find some other RAD tools like wxFormBuilder but it costs money, not something I want to do for simply learning.

So my TLDR question is if anyone has had experience with wxWidgets? Do you just develop in whatever IDE you're comfortable with and just code the GUI? Meaning no visual helpers? Perhaps you could give me a nudge in what direction I should be going :)

Thanks, this is also my first post on this site albeit I have read many threads before that have helped me solve copious problems. Cheers!

A: 

There is wxGlade and wxFormBuilder.

I don't know if there is another one, but the wxFormBuilder I know is free and open source.

You will find links to other tools on the homepage of wxGlade (http:// wxglade.sourceforge.net/).

Most of these programs are able to output xrc files, which are are an XML representation of your GUI. It address the issue of complexity of the generated code but is not as powerful.

Yet personally I don't use any of these tools, except sometimes to see what it's going to look like before I do it but never to actually generate code.

f4
+4  A: 

My suggestion is to learn how to do GUI layout with wxWidgets in code, then when you get good at it learn how to use the GUI tools.

Doing this kind of work manually for a while gives you the understanding about what you need ("Ok, I need a wxSizer, vertical, to put these two horizontal wxSizers into, where I put my a wxStaticText and a wxTextCtl for each line ...")... where as I think if you started out with the GUI tools you'd just tend to get annoyed because (last time I looked) none of them were Drag And Drop editors like you get with .NET.

RyanWilcox
Ok thanks, i'll start off with that
Daniel
+1 for this good advice. Starting this way is a good idea!
George Edison
+1 for visualizing it in your head. I believe that if you can't imagine how to do manually, then you won't be able to get it correct it in a drag-and-drop editor anyways.
Dashogun
I started this way too and it made a huge difference to how much I understood the code that was generated by the various UI design tools.
Fraser Graham
A: 

I use wxWidgets without using a drag and drop designer. There are obviously drawbacks to that approach but an advantage is that you don't have any horrible automatically generated code to deal with. In the past I've found having such code in the middle of my project has caused various types of grief - especially if you decide it needs some serious changes it is often necessary to start from scratch because form designers are so much better at "writing" as opposed to "editing".

For simple applications you can assemble a UI using a mixture of customized and standard widgets without too much difficulty. Check out the wxWidgets samples and demos, which use that approach. My chess app (see my website) uses this approach too.

A more elaborate UI could possibly be implemented by writing something special at a higher level of abstraction. The kind of thing I am thinking of would be a subsystem that accepts high level flexible requests to provide different types of user interface functionality, and then sorts out the details of the controls to create and the positioning etc. of those controls itself. That is kind of a technical fantasy of mine but I haven't ever really attempted to do it. Actually, a fairly primitive facility of this type is already available and used by the demos I mentioned; It is called a "Sizer" (class wxSizer) and is basically a control container.

Finally I would point out that problems with the Qt licence have basically gone away since Nokia bought Trolltech and made it "more" free (LGPL licence). Many people think Qt is the way to go these days. I am pretty happy with wxWidgets but will definitely evaluate Qyt seriously one day. Good luck with your projects.

Bill Forster
True, in c# it usually decides to randomly turn things invisible and it's very annoying, these Sizer things sort of sound a bit like inverse docking. Cool thanks for your input
Daniel
Sizers are a wonderful tool in the hands of someone who knows what they're doing.
George Edison
+1  A: 

Definitely give Code::Blocks another try. It is a WONDERFUL environment to work with wxWidgets in. It comes with a form designer and templates for wxWidgets projects, so I can't imagine working without it.

Also, for a good beginner's introduction to wxWidgets, try this page. It helped me alot when I started with it.

George Edison
The tutorial you link to looks good - wish I'd known about it earlier. It's interesting though, all of my experiences with MFC have been diabolical - every problem I've had has required searching for a weird incantation provided by an expert somewhere on the net. Almost every problem I've had with wxWidgets I've been able to solve by myself with normal programmer's logic. Simple example problem; Change color of static text. MFC solution; Intercept a whole bunch of windows messages etc. wxWidgets solution; Call .color() method on control. My conclusion; MFC is only superficially similar to wx.
Bill Forster
MFC is AWFUL! I would never use it. And even if I had to, I would hate it.
George Edison
Yeah I totally agree. So it's surprising how often the mantra that wxWidgets is merely some kind of portable MFC framework comes up. My experience is that although there is superficial similarity, MFC is a problem, whilst wxWidgets is a solution.(In case it's confusing why I am blathering about this, the otherwise nice tutorial you linked to in your answer spends a lot of space on the similarity between MFC and wxWidgets).
Bill Forster
I just ignored that. The rest is good.
George Edison
A: 

wxFormBuilder but it costs money

wxFormBuilder is Free and Open source

Also Visual Studio is best for C++ coding in wxWidgets, but you will run into lots of issues on Linux due to the way Visual Studio handles a lot of things, like file names you have to take extra care for case sensitivity.

Also regarding the GUI, add the wxFormBuilder to the Visual Studio solution, add the file type handler to Visual Studio. Now just double click on it and add your dialogs, like you do it in C#. Just add the generated code files to the Visual Studio project once and you are done.

It's very easy to use Visual Studio with GUI programming in wxWidgets.

Also don't forget to watch the CodeLite editor if you want to port on Linux. It is very much compatible with the Visual Studio projects and shortcut keys.

Priyank Bolia
Ah! wxWidgets in VC++ - a recipe for trouble. See http://stackoverflow.com/questions/1916782/static-library-links-in-wxwidgets-statically-but-apps-using-my-lib-still-require and http://stackoverflow.com/questions/134029/wxwidgets-setup-h-no-such-file
George Edison
Strongly, disagree, you need some experience to start, but once you are booted, its very fast to program using VS. And I can say this because I wrote a wxVS2008Integration integration tool long back (no more available), and its very easy to use VS in compare to any other IDE.
Priyank Bolia
Having used both VC++ AND CodeBlocks, I can honestly say CodeBlocks is better. It's not perfect, but still better.
George Edison
Priyank Bolia
I've used VC++ 2008 Express with wxWidgets (with wxVC and wxFormBuilder [installed [wxPack]]) and they worked together pretty well (tried CodeBlocks before that but - for me - the debugger integration was pretty shabby).Also used CodeBlocks with wxWidgets (with wxFormBuilder) on Linux (but on a smaller project so I've managed to get by the debugging issues).http://wxpack.sourceforge.net/
Eugen Constantin Dinca
A: 

I have developed a number of application GUIs using wxWidgets - you can see screenshots at http://ravenspoint.com/

IMHO, you should distinguish between designing a GUI and implementing it. Expecting to use the same program to design your GUI and to automatically emit all the code to implement the design is expecting too much.

A design program should be fast and simple. I recommend http://www.balsamiq.com/

Once you have settled on the design, then you can turn to the coding. Personally, I find that placing widgets on a panel using the wxPosition and wxSize parameters of the wxWidget constructors to be trivial - easier than trying to nudge widgets into their exact positions using the mouse.

The trouble with using some kind of form builder to emit all the code for a significant GUI is that you end up with a morass of automatically generated code that is hard to find your way around in. If the code has been handwritten, then you already know where everything is located.

ravenspoint
I know this is no solution but what I do is use a RAD to design the form, then copy-and-paste the code into an editor and 'fix it up.' Then I integrate it into the app's source code.
George Edison
George - it is a solution if it works for you. However, the 'fix it up' step sounds tedious to me. I wonder if it would ever produce easily maintained code with, for example, meaningful variable names and code order?The problem with both your and my approach is, of course, design iteration. At least the GUI mock-ups from balsamiq do not pretend to emit code, and I am not faced with editing a mixture of machine and human generated code - it is all my own work, for good or bad. After a while you learn to write GUI code that is easy to adjust when clients ask for changes.
ravenspoint
A: 

I just finished doing a hello world program in both wx and fltk using the netbeans IDE. Microsoft Visual Studio WinForms or MFC was much easier than either. I needed cross platform capability so I could not use it for this application. I finished fltk in much less time than wx. The program was simpler, smaller, faster, and easier to write. Wx had pretty disjointed documentation and organization. Fltk was designed back in the "old days" when small fast and efficient was valued. That's probably why it seems "old" to you. I'm an old guy so it worked for me. YMMV

Jay