IUP GUI lib (Win/Lin) getting started

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

IUP GUI lib (Win/Lin) getting started

Post by MrSwiss »

Hi all,

recent discussions about GUI lib's led me to investgate them.
The knock out criteria set by myself are the following:
  • cross OS compatible (no OS dependency)
  • straight C interface (no wrappers for C++ needed)
  • available as precompiled binaries (not just source)
  • FB headers already existing (.bi files) even if not necessarily up-to-date
  • simple installation (preferably with static linking)
Additionally some nice to have's:
  • simple syntax (easy to get aquainted with)
  • DPI awareness (Win only, I think)
  • simple examples (in doc or elsewhere) for easy translation to FB
  • possibilty to handle plots (for scientific/technical use)
And the winner is: IUP,
which seems to be the only one, that covers all the preset knock out criteria above.
Plus, just about all my nice to have's, as well.
Just so much about why IUP (you might have other criteria to lead you elsewhere).

Getting started (Win installation/Lin is different):
  • 1) getting the binaries (which isn't that clearly described)
    link: at sourceforge choose: iup-3.28_Win64_mingw6_lib.zip -- or -- iup-3.28_Win32_mingw6_lib.zip
    2) unzip the files to a freshly created directory/folder
    3) optional: (I don't like empty dir's on my storage) delete empty dir's
    4) copy all .a files to your FBC installation: <FBC>/lib
    5) all done ... time for first tests
Some of the examples (from IUP's doc to FB):
IUP_ex1mod.bas -- a bit modified by myself:

Code: Select all

' IUP_ex1mod.bas -- (c) 2020-05-04, MrSwiss
'
' compile: -s gui
'
#Include "IUP/iup.bi"                   ' static lib's ver. 3.28 (.bi is for 3.15)
                                        ' it is still working "as expected" _
                                        ' maybe without the latest additions

Dim As UByte    bits = SizeOf(Any Ptr) * 8  ' get FBC's bitness w/o preprocessor
Dim As String   msg1 = "Hello FreeBASIC programmers from IUP 3.28" + Chr(10) + _
                       "FB-IUP bindings 3.15 and FBC" + Str(bits) + " ver. " + _
                       __FB_VERSION__, _
                title1 = "FBC + IUP -- Example 1 (modified)"

IupOpen(0, 0)                           ' required
IupMessage(title1, msg1)                ' waits for 'OK' button click
IupClose()                              ' required
' ----- EOF -----
IUP_ex2.bas:

Code: Select all

' IUP_ex2.bas -- (c) 2020-05-06, MrSwiss
'
' compile: -s gui
'
#Include "IUP/iup.bi"   ' LINUX only: insists on propper case


' ===== Main =====
Dim As Ihandle Ptr  dlg, label

IupOpen(0, 0)

label = IupLabel("Hello world from IUP.")
dlg = IupDialog(IupVbox(label, 0))

IupSetAttribute(dlg, "TITLE", "Hello World 2")
IupShowXY(dlg, IUP_CENTER, IUP_CENTER)

IupMainLoop()

IupClose()
' ===== End Main =====  ' ----- EOF -----
IUP_ex5.bas

Code: Select all

' IUP_ex5.bas -- (c) 2020-05-06, MrSwiss
'
' compile: -s gui
'
#Include "IUP/iup.bi"      ' LINUX only: insists on propper case


Function btn_exit_cb() As Long
    Return IUP_CLOSE
End Function

' ===== Main =====
Dim As Ihandle Ptr  dlg, button, label, vbox

IupOpen(0, 0)

label = IupLabel("Hello world from IUP.")

button = IupButton("OK", 0)
vbox = IupVbox(label, button, 0)
IupSetAttribute(vbox, "ALIGNMENT", "ACENTER")
IupSetAttribute(vbox, "GAP", "10")
IupSetAttribute(vbox, "MARGIN", "10x10")

dlg = IupDialog(vbox)
IupSetAttribute(dlg, "TITLE", "Hello World 5")

IupSetCallback(button, "ACTION", Cast(Icallback, @btn_exit_cb))
IupShowXY(dlg, IUP_CENTER, IUP_CENTER)

IupMainLoop()

IupClose()
' ===== End Main =====  ' ----- EOF -----
Don't expect more of those translations from my side (it's DIY time).
There only purpose is: to test whether the install was successfull.

[Edit] 2020-05-06 CEST 23.23.23 (updated code) removed typo[/Edit]
Last edited by MrSwiss on May 06, 2020 21:24, edited 1 time in total.
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: IUP GUI lib (Win/Lin) getting started

Post by badidea »

MrSwiss wrote:And the winner is: IUP
Just curious, on which criteria did FLTK fail the test for you?
(FLTK is the only GUI I have really used so far)
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: IUP GUI lib (Win/Lin) getting started

Post by MrSwiss »

badidea wrote:Just curious, on which criteria did FLTK fail the test for you?
I'm certain that you know, that curiosty killed the cat, in the end. ;-)

How about: straight C interface (no wrappers for C++ needed)
angros47
Posts: 2324
Joined: Jun 21, 2005 19:04

Re: IUP GUI lib (Win/Lin) getting started

Post by angros47 »

Freebasic can use some C++ features directly, with no wrapper.

Also, for pure C interface there is xforms
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: IUP GUI lib (Win/Lin) getting started

Post by MrSwiss »

Please, switch on your 'grey cells' before posting pointless suggestions.

- xforms has no prebuilt headers (in FBC distribution)
- some C++ (is simply not good enough)
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: IUP GUI lib (Win/Lin) getting started

Post by Imortis »

MrSwiss wrote:...
- xforms has no prebuilt headers (in FBC distribution)
...
Prebuild header for xforms

There is a header, and the library has not been updated since 2014, so the header is still good.

I don't know how it stacks up to your other criteria, but thought I would point this out.
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: IUP GUI lib (Win/Lin) getting started

Post by badidea »

MrSwiss wrote:I'm certain that you know, that curiosty killed the cat, in the end. ;-)
I am not much of a cat-person, but more on-topic...

Have you tried the linux version? I am having some difficulties here on Ubuntu 18.04 (kernel version 4.15.0-96-generic).
First easy issue: #Include "iup/iup.bi" needs to be #Include "IUP/iup.bi"
Next I downloaded iup-3.28_Linux415_64_lib.tar.gz from https://sourceforge.net/projects/iup/fi ... Libraries/
Extracted the file and ran the installer: "sudo ./install"
Then the linker could not find libpangox-1.0
I created a symbolic link: sudo ln -s libpangox-1.0.so.0 libpangox-1.0.so
Now it compiles, but a get a GTK error (on your first example):
(test:5164): Gtk-ERROR **: 21:36:07.763: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
Trace/breakpoint trap (core dumped)

Edit, reported before here as well: viewtopic.php?t=14230&start=45#p258803, downloading iup-3.28_Linux35_64_lib.tar.gz for the GTK 2 version...
That fixed it:
Image
BTW, there is a typo "FreeBASCIC"
Last edited by badidea on May 06, 2020 19:57, edited 1 time in total.
systemctl
Posts: 182
Joined: Mar 27, 2020 5:15

Re: IUP GUI lib (Win/Lin) getting started

Post by systemctl »

badidea wrote:
MrSwiss wrote:And the winner is: IUP
Just curious, on which criteria did FLTK fail the test for you?
(FLTK is the only GUI I have really used so far)
Don't hate me please but FLTK apps are ugly and not fit with the environment around them. IUP, being GTK+ based, fit nicely. FLTK also has too much widgets and they look weirded and alien. e.g: I know our dear and very familar normal Button, but I have no idea what is a Return Button and what is the reason I have to use it over the normal button other than it also has a return symbol icon?
systemctl
Posts: 182
Joined: Mar 27, 2020 5:15

Re: IUP GUI lib (Win/Lin) getting started

Post by systemctl »

angros47 wrote:Also, for pure C interface there is xforms
XForms is even uglier than FLTK and is abandon ware. It's even not have font antialiasing so the texts look broken and of course ugly. FLTK is more updated and at least has Xft support to have a smooth font rendering.
systemctl
Posts: 182
Joined: Mar 27, 2020 5:15

Re: IUP GUI lib (Win/Lin) getting started

Post by systemctl »

badidea wrote:
MrSwiss wrote:I'm certain that you know, that curiosty killed the cat, in the end. ;-)
I am not much of a cat-person, but more on-topic...

Have you tried the linux version? I am having some difficulties here on Ubuntu 18.04 (kernel version 4.15.0-96-generic).
First easy issue: #Include "iup/iup.bi" needs to be #Include "IUP/iup.bi"
Next I downloaded iup-3.28_Linux415_64_lib.tar.gz from https://sourceforge.net/projects/iup/fi ... Libraries/
Extracted the file and ran the installer: "sudo ./install"
Then the linker could not find libpangox-1.0
I created a symbolic link: sudo ln -s libpangox-1.0.so.0 libpangox-1.0.so
Now it compiles, but a get a GTK error (on your first example):
(test:5164): Gtk-ERROR **: 21:36:07.763: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
Trace/breakpoint trap (core dumped)

Edit, reported before here as well: viewtopic.php?t=14230&start=45#p258803, downloading iup-3.28_Linux35_64_lib.tar.gz for the GTK 2 version...
That fixed it:
Image
Nope. Both the GTK+2 and GTK+3 version work well. IUP uses GTK+ underlying. So you have to install GTK+ development package. For GTK+2: libgtk2.0-dev. For GTK+3: libgtk-3-dev.

Also, the installer of IUP install to /usr/lib64 by default on my system. So you have to create this file: /etc/ld.so.conf.d/IUP.conf with this content:

Code: Select all

/usr/lib64
(Adapt it the fit what is on your system)

Save it then run ldconfig.

All of the steps above are run with sudo.
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: IUP GUI lib (Win/Lin) getting started

Post by badidea »

systemctl wrote:Don't hate me please but FLTK apps are ugly and not fit with the environment around them. IUP, being GTK+ based, fit nicely. FLTK also has too much widgets and they look weirded and alien. e.g: I know our dear and very familar normal Button, but I have no idea what is a Return Button and what is the reason I have to use it over the normal button other than it also has a return symbol icon?
You could have a point, this FLTK one is still pretty OK:
Image
But now, with a dark theme:
Image
Not so nice.
angros47
Posts: 2324
Joined: Jun 21, 2005 19:04

Re: IUP GUI lib (Win/Lin) getting started

Post by angros47 »

@MrSwiss

Please read before saying that there is no header: https://freebasic.net/forum/viewtopic.php?f=7&t=22671
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: IUP GUI lib (Win/Lin) getting started

Post by MrSwiss »

@angros47,

please read, then understand and only then, post:
I've clearly stated that: - xforms has no prebuilt headers (in FBC distribution)
I'm not going to search the galaxy (aka: Forum/Internet/other places) for headers.
(It's either on my storage, or not. Period.)

Btw.: Updated code for LINUX and corrected typo (in the first post).
systemctl
Posts: 182
Joined: Mar 27, 2020 5:15

Re: IUP GUI lib (Win/Lin) getting started

Post by systemctl »

badidea wrote:
systemctl wrote:Don't hate me please but FLTK apps are ugly and not fit with the environment around them. IUP, being GTK+ based, fit nicely. FLTK also has too much widgets and they look weirded and alien. e.g: I know our dear and very familar normal Button, but I have no idea what is a Return Button and what is the reason I have to use it over the normal button other than it also has a return symbol icon?
You could have a point, this FLTK one is still pretty OK:
Image
But now, with a dark theme:
Image
Not so nice.
If you are an Engineer, so yes, this is perfectly fine. But if you are a normal user, familar with Android and Windows, you definitely see there must be something wrong with this GUI. Your dialog also too simple. The more widgets you use, the more you find it's not fit with the environment outside.
Post Reply