IUP portable user interface

Posted by pulkomandy on Fri Mar 30 22:48:11 2012  •  Comments (5)  • 

Just a quick note to say I started a project with IUP as the framework for user interface. After spending some time with Qt and wxWidgets, I've finally found an UItoolkit that just does what's expected. No need for a precompiler, no replacement of my main function by some wrapper, no rewrite of the C++ STL.

IUP is written in C, but has a nice attribute-based interface that makes it very easy and pleasant to use. I've made good progress on building my windows and the layouting system is nice to work with (still fighting with Qt one...). IUP is cross platform as it uses either comctl32, GTK or Motif. I think I'll write an Haiku/BeAPI backend for it as it's going to be rather useful.

It's quite easy to install in MinGW, just get the prebuilt binaries (either dll or static linked) and includes and drop them at the right place. No need to recompile for hours like wxWidgets.

I still have to see how integration of custom widgets is possible. This gets useful quicker than one may think, as soon as you need an hex-editor, a music-tracker like interface, or something similar. But these seem to be handled by IUP with a generic "grid" control that looks quite flexible. In wxWidgets both of these were a mess, with no easy way to do a custom control like an hex spinbox, and a button grid giving very bad performance. Having to manually call freeze() and thaw() on widgets got boring really quickly. Not to mention the complete lack of threading support...

Let's see how it goes in a few weeks!

IUP with C++

While the documenation suggests a way of using IUP in C++ and encourages it, I was not so happy with using friend functions or static methods. So I came up with my own solution involving a bit of C++11 magic (variadic templates). The result is the IUP++ class that reigsters itself as an IUP callback (with any arguments) and forwards the call to a C++ object and method. It's used this way :

Callback<Gui>::create(menu_open, "ACTION", this, &Gui::doStuff);
Callback<Gui, int, int>::create(toggle, "ACTION", this, &Gui::doMoreStuff);

Where Gui is the class you want to answer to the event, menu_open and toggle are IUP handles to UI objects, "ACTION" is the callback name, this is the object to forward the event to (an instance of Gui), and doStuff and doMoreStuff are methods called. Notice the Callback also needs the parameters to these - that's the second "int" in the second example (the first one being the return type, that defaults to int if missing, but is needed when you add parameters). I'm looking for suggestions on how to make this simpler, as there is still some repetition in it...

gravatar Comment

Posted by adam on Thu Dec 7 19:09:49 2017

I am interested in talking with you directly about helping haiku become ready for more young developers. I read about this alternative to wxWidgets cross platform toolkit (IUP) in C on your website. It looks good, and is well maintained having a new release this year. I am thinking of swapping my development over from Linux to Haiku. This can only happen if I can find the right tool and also the right people to help me get up and going quickly (like within a few days).

Best wishes

gravatar Comment

Posted by johann on Wed Jan 9 01:08:57 2019

Thanks for this great work.
Still, it's not really clear for me how it works... I guess it's to be used outside of the "Handler" class ?
If you have an exemple, it will be great.

gravatar Comment

Posted by PulkoMandy on Wed Jan 9 09:08:49 2019


You can find the complete application at

In particular, gui.cpp is where the user interface is wired to C .

Note that current versions of IUP have their own C API, which I have not played with yet, and may do things in a better way.

gravatar Comment

Posted by johann on Sun Jan 13 21:08:51 2019

Hi. Thanks for the answer.
Something is not really clear here for me. The first argument to Callback::create is supposed to be a Handle element, but in the example on Gui.cpp, it seems you set a simple method as argument (same as the last argument), or maybe i'm missing something ?

I'll also check with the C Api.

gravatar Comment

Posted by PulkoMandy on Sun Jan 13 21:19:28 2019

The first argument is the IUP handle (it is a local variable, if you look at menu_open for example), the last argument is the method (it is prefixed with Gui:: to distinguish it from the handle).

Callbacks for playToggle, blocklist, etc use different names for the IUP handle and the callback method.

Leave a comment

Name: Mail: