The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Simple and easy GUI for C++

I have been looking for a good GUI for C++.  I would like it to be quite simple and very easy to use.  I would like to be able to simply and convieniently change the colors of the pixels on the screen, and retrieve keybourd (and maybe mouse) movements.  I was wondering if anyone had some good recomendations.
Steven Gary Noyce Send private email
Wednesday, August 09, 2006
 
 
What platform ?
What kind of app - Doc/View or simple dialog ?

MFC is the venerable but still most popular route on windows, wxWindows and QT are cross platform and have a more pure C++ nature (especially QT)
Winforms - the new toolkit for .Net is cleaner than MFC but is easier to use from c# than c++.

GUI programming requires a jump in understanding, your programs don't start at line 1 and run to the end, you respond to events, you have to update other controls depending on events, you have to synchronise your model of the data witht he view of the data.
These things are usually a bigger step to understanding guis than which toolkit.

In addition most toolkits have a number of macros and none standard c++ features to handle the plumbing of events which can be a bit confusing, especially when these are dropped in by the dialog editor.
Martin Send private email
Wednesday, August 09, 2006
 
 
You didn't specify which platform, or how much experience you've got working without any framework, so I can only take a random guess.

For something that's literally just turning pixels on and off in a window, you might just as well be off using the raw API. For Windows, this means creating a window, hooking a windows procedure to it, responding to messages, and getting hold of a device context to turn the pixels on and off. If you're a novice to this area, try Charles Petzold's "Programming Windows" book (http://www.charlespetzold.com/pw5/).

Once you've got that under your belt, you can look at another framework. For lightweight GUIs under Windows, I've heard WTL (http://wtl.sourceforge.net/) is good, but I haven't played with it much myself.

However, if you're looking for something like the best widget set for X programming, ignore all of the above.
Ritchie Swann Send private email
Wednesday, August 09, 2006
 
 
Ok, thanks for the answers.  I am using windows, so things for only windows are ok, but idealy I would like to learn how to do things more generically.  My main programming history is with a toy language call Blitz3D.  It had a function called WritePixel (x,y,r,g,b).  It aslo had a function KeyDown (scan code) that returned either true or false depending on if the key was being pressed or not.  To make a window, it had a function Graphics (width, height, depth, mode).  To get mouse movements, it had functions MouseX (), MouseY (), and MoveMouse (x,y).  I now have most C++ programming under my belt, except all of it has been in a console so far.  I know graphics programming in C++ will be a lot different than in my toy language, but idealy I would like it as close as possible.
Steven Gary Noyce Send private email
Wednesday, August 09, 2006
 
 
I'd suggest you bite the bullet. Fundamentally, Windows works on an event-driven basis. You can't poll for the keyboard (which is a bad thing to try and do anyway, see blogs.msdn.com/oldnewthing/archive/2006/01/24/516808.aspx), you have to respond to a keyboard event instead.

There's a SetPixel function in Windows that does pretty much what you want, but it works on device contexts, so you'll need to understand about how and when you get hold of one of those.

And also you'll need to understand that it's your responsibility to handle the redrawing of your application's visual state if, for example, you minimize and maximize the application (fortunately most frameworks take care of this to some degree).

Good luck!
Ritchie Swann Send private email
Wednesday, August 09, 2006
 
 
I have been using WTL for a personal project and find it meets my needs. Microsoft dropped it on the open source community a while back and it is being maintained on SourceForge. The biggest problem with WTL is the almost complete lack of documentation. Someone ran Doxygen over it, but with no explaination the results are useless. If you think it might meet your needs check out Michael Dunn's "WTL for MFC Programmers" series on The Code Project.

I also suggest finding a book about the Win32 API if you are going to do anything on Windows.

WTL on SourceForge -- http://sourceforge.net/projects/wtl/
Michael Dunn's "WTL for MFC Programmers" series -- http://codeproject.com/wtl/wtl4mfc1.asp
Mike Send private email
Wednesday, August 09, 2006
 
 
So, is it better to use the windows API, or a multiplatform library?  I don't know, but it seems like a waste to program with the windows API because then you basically can't ever port it to another platform, right?
Steven Gary Noyce Send private email
Wednesday, August 09, 2006
 
 
Blitz3D is based on DirectX. BlitzMax on OpenGL.
If you try to do something like you do with Blitz, you need to use either OpenGL or DirectX. With straight WinAPI calls you'll never get the performance you need.

My advice would be to get Lamothe's "Tricks of the 3D Game Programming Gurus", in which he builds a 3d engine from scratch, based on a simple Direct Draw buffer. The book also includes an engine that has all the function calls you need (PlotPixel, DrawLine, etc.).

Be ready for a steep learning curve!

Another option would be to use www.libsdl.org, which does something similar, but is based on OpenGL.
Fritz Send private email
Thursday, August 10, 2006
 
 
You could always have a look at using the VCL :

http://www.turboexplorer.com/cpphome.htm

Effectively you are getting an IDE that is practically Delphi except for the fact that you are working with C++ instead of Object Pascal...Easy as pie, cheap as chips, highly recommended :-)
Lurkio
Thursday, August 10, 2006
 
 
>So, is it better to use the windows API, or a
>multiplatform library? 

It depends on the library - for own use / learnign experience I would go multiplatform. If this is an app for a customer that they need to support for 10years pick something well known.

wxWidgets is my favorite even for purely windows projects, it is very much like MFC but seems cleaner than MFC which has had a lot of bolt-on improvements over the years.

WinForms seems to be aimed at fairly simple fill-in-form types apps rather than providing the framework to write complex desktop apps. You can talk to it from python now so I might give it a try.
Also winforms might not have a future between continued support for MFC and the new markup based guis (WPF/Avalon)

No experience of QT - it used to be expensive on windows, I think it is cheaper now.

Entirely possible that GUI toolkits may dissapear in favour of local web apps where the screen is defined in html/markup langauge and talks to a local app with Ajax etc.
Martin Send private email
Thursday, August 10, 2006
 
 
> local web apps where the screen is defined in html/markup langauge and talks to a local app with Ajax etc.

Ajax sends HTTP requests, doesn't it: does that imply that the "local app" would be a web server?
Christopher Wells Send private email
Thursday, August 10, 2006
 
 
Yes - or you could use XMLRPC or a whole range of other methods. It's trivial to implement a local http server in eg Python.

For apps where the gui feedback isn't too hard - typical fill in forms business apps  not 3D CAD, it makes sense.

Very good separation of the display from logic.
Easy to test
Easy to adapt / customise the gui.
You get the benefit of all the web frameworks to handle the database back end stuff.
It's easy to convert into a web app, or workgroup app if needed.
Easy to pull in remote resources from web/intranet.

You can either use the local browser or create a simple wrapper app that uses IE/Mozilla etc to render the HTML.
Martin Send private email
Thursday, August 10, 2006
 
 
> I would like to be able to simply and convieniently change the colors of the pixels on the screen, and retrieve keybourd (and maybe mouse) movements.

I have a reccomendation: learn the difference between "GUI framework" and "graphics library".  ;)

For the former, wxWidgets is popular and strongly encourages a native-look application. For the latter, SDL is a popular cross-platform option, but there's many others in both categories.

Sunday, August 13, 2006
 
 
So, I think "graphics library" is the more correct term for what I am looking for.  What would you recommend?  I was thinking about learning to use opengl.  Which do you think is the best, OpenGl, DirectX, or something else?
Steven Gary Noyce Send private email
Tuesday, August 15, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz