1. Widget Toolkits
- Posted by Icy_Viking Feb 26, 2023
- 1299 views
Hi all,
I was recently thinking of widget toolkits recently. I know there is the Win32 API, X11/Wayland, GTK, IUP, FLTK, etc. I was recently thinking of how useful it might be to start one. I was looking at the Win32 API and I think a new Win32lib would come in handy. Wrapping the Windows API would be an enormous task from top to bottom, but it would be pretty handy. With WSL/g, having a cross platform toolkit would benefit. Is there a wrapper for GTK4? Then there are others like IUP or FLTK. Greg's FFI library should help making wrapping one or some of these not as difficult as it would be in the past.
2. Re: Widget Toolkits
- Posted by petelomax Feb 26, 2023
- 1296 views
I'm actually working on xpGUI, a new cross-platform GUI for Phix that uses WinAPI on Windows, GTK on Linux, and document.createElement() under JavaScript.
I plan to keep it as simple as possible, very early days yet, slightly stuck on a simple canvas, though recently rather busy with slightly more important stuff.
You can see the code I've got so far and four short (and incomplete) examples that work on both WinAPI and GTK here. (but no xpGUI.js as yet)
3. Re: Widget Toolkits
- Posted by Icy_Viking Feb 26, 2023
- 1250 views
I'm actually working on xpGUI, a new cross-platform GUI for Phix that uses WinAPI on Windows, GTK on Linux, and document.createElement() under JavaScript.
I plan to keep it as simple as possible, very early days yet, slightly stuck on a simple canvas, though recently rather busy with slightly more important stuff.
You can see the code I've got so far and four short (and incomplete) examples that work on both WinAPI and GTK here. (but no xpGUI.js as yet)
Looks interesting. Yes I can tell it is in very early stages of development. I did briefly start on a wrapper for the Win32 API. Still very early in its development stages, not sure how far I'll get with it, but I work on it when I feel motivated or super bored. The Windows API is vast. Even looking at the X11 and Wayland APIs, they're vast too.
4. Re: Widget Toolkits
- Posted by ChrisB (moderator) Feb 27, 2023
- 1206 views
I'm actually working on xpGUI, a new cross-platform GUI for Phix that uses WinAPI on Windows, GTK on Linux, and document.createElement() under JavaScript.
I plan to keep it as simple as possible, very early days yet, slightly stuck on a simple canvas, though recently rather busy with slightly more important stuff.
You can see the code I've got so far and four short (and incomplete) examples that work on both WinAPI and GTK here. (but no xpGUI.js as yet)
Hi Pete
xp has connotations of Windows xp - not necessarily a bad thing.
Why don't you consider the name MonGoose (like MonGUIse)
(Cat amongst pigeons and not serious) (and not a Kat reference)
Cheers
6. Re: Widget Toolkits
- Posted by ghaberek (admin) Feb 27, 2023
- 1185 views
Hi all,
I was recently thinking of widget toolkits recently. I know there is the Win32 API, X11/Wayland, GTK, IUP, FLTK, etc. I was recently thinking of how useful it might be to start one. I was looking at the Win32 API and I think a new Win32lib would come in handy. Wrapping the Windows API would be an enormous task from top to bottom, but it would be pretty handy. With WSL/g, having a cross platform toolkit would benefit. Is there a wrapper for GTK4? Then there are others like IUP or FLTK. Greg's FFI library should help making wrapping one or some of these not as difficult as it would be in the past.
I've been revisiting IUP lately (basically starting over on my old "iup4eu" wrapper) and I now have a script that can regenerate the entire wrapper automatically in a few seconds. You can see the output of that here: iup.e. That file is only about 10% hand-coded while iup_export.e is about 50% hand-coded (everything except the function defs at the bottom). Using libffi definitely helps with IUP since some of the callbacks pass strings (which I've added better support for using libffi) and floats (which Euphoria does not support in callbacks at all). One neat trick is that I've got Icallback() using a map to avoid recreating callbacks. So helps clean up the code for registering callbacks with parameter types, as demonstrated below. But... (big but here) I'm about halfway done integrating libffi into the Euphoria backend (at least it builds now!) and I'd like to get that done first rather than relying on my very experimental libffi wrapper. And if we are going to write our own GUI toolkit for Euphoria, I'd like to implement classes first. I'm not a huge fan of OOP but everything in the GUI space is already built that way and I think it would make the whole process a lot easier and more manageable. I think IUP will suffice for now and we can package with the release of Euphoria 4.2.
include iup.e -- int function(Ihandle* ih, int button, int pressed, int x, int y, char* status); [in C] function button_cb( atom ih, integer button, integer pressed, integer x, integer y, sequence status ) return IUP_DEFAULT end function -- declare the callback with its name and parameter types, like this: Icallback( "button_cb", {C_POINTER,C_INT,C_INT,C_INT,C_INT,C_STRING} ) -- int function(Ihandle* ih, const char* filename, int num, int x, int y); [in C] function dropfiles_cb( atom ih, sequence filename, integer num, integer x, integer y ) return IUP_DEFAULT end function Icallback( "dropfiles_cb", {C_POINTER,C_STRING,C_INT,C_INT,C_INT} ) -- int function(Ihandle* ih, int op, float posx, float posy); [in C] function scroll_cb( atom ih, integer op, atom posx, atom posy ) return IUP_DEFAULT end function Icallback( "scroll_cb", {C_POINTER,C_INT,C_FLOAT,C_FLOAT} ) procedure main() IupOpen() atom canvas = IupCanvas( NULL ) IupSetAttribute( canvas, "BORDER", "NO" ) IupSetAttribute( canvas, "DROPFILESTARGET", "YES" ) IupSetAttribute( canvas, "SCROLLBAR", "YES" ) -- now Icallback() will find the existing callbacks declared -- above, which already have their parameter types defined: IupSetCallback( canvas, "BUTTON_CB", Icallback("button_cb") ) IupSetCallback( canvas, "DROPFILES_CB", Icallback("dropfiles_cb") ) IupSetCallback( canvas, "SCROLL_CB", Icallback("scroll_cb") ) atom dialog = IupDialog( canvas ) IupSetAttribute( dialog, "RASTERSIZE", "720x480" ) IupSetAttribute( dialog, "TITLE", "Canvas" ) IupShow( dialog ) IupMainLoop() IupClose() end procedure main()
I read this as mon-GWEE-see which is fun to say out loud.
That'd probably upset Greg...
Lol yeah, probably. I appreciate that Pete.
-Greg
8. Re: Widget Toolkits
- Posted by axtens_bruce Feb 27, 2023
- 1076 views
Wow, there's lots of mongooses (or is it mongeese?). If Greg's got dibs on the name "mongoose" one might want to use the Latin.
-Bruce
9. Re: Widget Toolkits
- Posted by petelomax Feb 27, 2023
- 1057 views
Waste of time. No one will use it.
Aw, poor irv! Yeah, I remember the stony silence your query was greeted with... and it I think it was over six months after you'd quit on it before I realised it might be useful to me...
Cheer up though, and you never know we might just enjoy building it for the heck of it and proving it can be done. But you are right, this is never gona be a miracle in and of itself.
10. Re: Widget Toolkits
- Posted by Icy_Viking Feb 27, 2023
- 1065 views
Hi all,
I was recently thinking of widget toolkits recently. I know there is the Win32 API, X11/Wayland, GTK, IUP, FLTK, etc. I was recently thinking of how useful it might be to start one. I was looking at the Win32 API and I think a new Win32lib would come in handy. Wrapping the Windows API would be an enormous task from top to bottom, but it would be pretty handy. With WSL/g, having a cross platform toolkit would benefit. Is there a wrapper for GTK4? Then there are others like IUP or FLTK. Greg's FFI library should help making wrapping one or some of these not as difficult as it would be in the past.
I've been revisiting IUP lately (basically starting over on my old "iup4eu" wrapper) and I now have a script that can regenerate the entire wrapper automatically in a few seconds. You can see the output of that here: iup.e. That file is only about 10% hand-coded while iup_export.e is about 50% hand-coded (everything except the function defs at the bottom). Using libffi definitely helps with IUP since some of the callbacks pass strings (which I've added better support for using libffi) and floats (which Euphoria does not support in callbacks at all). One neat trick is that I've got Icallback() using a map to avoid recreating callbacks. So helps clean up the code for registering callbacks with parameter types, as demonstrated below. But... (big but here) I'm about halfway done integrating libffi into the Euphoria backend (at least it builds now!) and I'd like to get that done first rather than relying on my very experimental libffi wrapper. And if we are going to write our own GUI toolkit for Euphoria, I'd like to implement classes first. I'm not a huge fan of OOP but everything in the GUI space is already built that way and I think it would make the whole process a lot easier and more manageable. I think IUP will suffice for now and we can package with the release of Euphoria 4.2.
include iup.e -- int function(Ihandle* ih, int button, int pressed, int x, int y, char* status); [in C] function button_cb( atom ih, integer button, integer pressed, integer x, integer y, sequence status ) return IUP_DEFAULT end function -- declare the callback with its name and parameter types, like this: Icallback( "button_cb", {C_POINTER,C_INT,C_INT,C_INT,C_INT,C_STRING} ) -- int function(Ihandle* ih, const char* filename, int num, int x, int y); [in C] function dropfiles_cb( atom ih, sequence filename, integer num, integer x, integer y ) return IUP_DEFAULT end function Icallback( "dropfiles_cb", {C_POINTER,C_STRING,C_INT,C_INT,C_INT} ) -- int function(Ihandle* ih, int op, float posx, float posy); [in C] function scroll_cb( atom ih, integer op, atom posx, atom posy ) return IUP_DEFAULT end function Icallback( "scroll_cb", {C_POINTER,C_INT,C_FLOAT,C_FLOAT} ) procedure main() IupOpen() atom canvas = IupCanvas( NULL ) IupSetAttribute( canvas, "BORDER", "NO" ) IupSetAttribute( canvas, "DROPFILESTARGET", "YES" ) IupSetAttribute( canvas, "SCROLLBAR", "YES" ) -- now Icallback() will find the existing callbacks declared -- above, which already have their parameter types defined: IupSetCallback( canvas, "BUTTON_CB", Icallback("button_cb") ) IupSetCallback( canvas, "DROPFILES_CB", Icallback("dropfiles_cb") ) IupSetCallback( canvas, "SCROLL_CB", Icallback("scroll_cb") ) atom dialog = IupDialog( canvas ) IupSetAttribute( dialog, "RASTERSIZE", "720x480" ) IupSetAttribute( dialog, "TITLE", "Canvas" ) IupShow( dialog ) IupMainLoop() IupClose() end procedure main()
I read this as mon-GWEE-see which is fun to say out loud.
That'd probably upset Greg...
Lol yeah, probably. I appreciate that Pete.
-Greg
That looks pretty handy. The fact that libffi is part of Euphoria now, well that sounds even better for wrapping various libraries. Hopefully 4.2.0 won't take super long before it is released.
11. Re: Widget Toolkits
- Posted by irv Apr 04, 2023
- 802 views
Is there a wrapper for GTK4? Then there are others like IUP or FLTK. Greg's FFI library should help making wrapping one or some of these not as difficult as it would be in the past.
EuGTK could be made to work with GTK4, with the addition of some ifdefs. I have no intention of wasting even 10 minutes of time doing this, since no one would use it.
12. Re: Widget Toolkits
- Posted by ChrisB (moderator) Apr 05, 2023
- 789 views
Definitely no one will use it if it's not available!
Go on - do it for the hell of it!
We appreciate you, really.
Cheers
Chris
13. Re: Widget Toolkits
- Posted by ChrisB (moderator) Apr 05, 2023
- 796 views
And I still think the biggest issue is a lack of well trumpeted, curated and maintained archive of libraries and programs for people to install and try out.
Cheers
Chris
14. Re: Widget Toolkits
- Posted by axtens_bruce Apr 05, 2023
- 769 views
And I still think the biggest issue is a lack of well trumpeted, curated and maintained archive of libraries and programs for people to install and try out.
CEAN - Comprehensive Euphoria Archive Network
-Bruce
Forked into: CEAN / CPAN / Pete's site
15. Re: Widget Toolkits
- Posted by katsmeow Apr 05, 2023
- 765 views
And I still think the biggest issue is a lack of well trumpeted, curated and maintained archive of libraries and programs for people to install and try out.
Cheers
Chris
Ditto.
Kat
16. Re: Widget Toolkits
- Posted by Bhupen1277 Apr 06, 2023
- 740 views
xpgui
The name to the seasoned computer user takes one back to the days of Windows XP.
Whether or not it woks on XP is not my criticism.
Most sensible people have Window 10, even Windows 11
So it would be psychologically counterproductive to call it XPGUI. Call it something like GUI10 and then still include ability for it to work with Windows XP
The whole effort should be to bring Euphoria and Phix to the current level, even in the naming of things like a GUI
17. Re: Widget Toolkits
- Posted by Icy_Viking Apr 07, 2023
- 733 views
There could be a new Win32lib using the new Windows API, but it would be a huge task. Also, it would be Windows only. Something like GTK4 would be cross platform, but again a huge task. How many people would use such GUI toolkits? Euphoria is a niche programming language.
18. Re: Widget Toolkits
- Posted by euphoric (admin) Apr 07, 2023
- 708 views
How many people would use such GUI toolkits?
I'm still using the old wxEuphoria GUI! (I'm not using Irv's GTK only because I've had no reason to switch from wxEuphoria. But should wxEuphoria ever become show-stopping, I would probably hop instantly to EuGTK or to pGUI (for Phix).)
I think the contest is between GTK and wxWidgets. To limit ourselves to a Windows-only GUI seems ill-advised at this point.
19. Re: Widget Toolkits
- Posted by Icy_Viking Apr 07, 2023
- 706 views
How many people would use such GUI toolkits?
I'm still using the old wxEuphoria GUI! (I'm not using Irv's GTK only because I've had no reason to switch from wxEuphoria. But should wxEuphoria ever become show-stopping, I would probably hop instantly to EuGTK or to pGUI (for Phix).)
I think the contest is between GTK and wxWidgets. To limit ourselves to a Windows-only GUI seems ill-advised at this point.
Well if wxWidgets is updated, I'd use it. I used to use it back in the day. I wouldn't mind using GTK or IUP for that matter.