1. Widget Toolkits

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.

new topic     » topic index » view message » categorize

2. Re: Widget Toolkits

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)

new topic     » goto parent     » topic index » view message » categorize

3. Re: Widget Toolkits

petelomax said...

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.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Widget Toolkits

petelomax said...

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

SmileOfTheDayChris

new topic     » goto parent     » topic index » view message » categorize

5. Re: Widget Toolkits

That'd probably upset Greg...

new topic     » goto parent     » topic index » view message » categorize

6. Re: Widget Toolkits

Icy_Viking said...

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() 
ChrisB said...

I read this as mon-GWEE-see which is fun to say out loud.

petelomax said...

That'd probably upset Greg...

Lol yeah, probably. I appreciate that Pete.

-Greg

new topic     » goto parent     » topic index » view message » categorize

7. Re: Widget Toolkits

Waste of time. No one will use it.

new topic     » goto parent     » topic index » view message » categorize

8. Re: Widget Toolkits

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

new topic     » goto parent     » topic index » view message » categorize

9. Re: Widget Toolkits

irv said...

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.

new topic     » goto parent     » topic index » view message » categorize

10. Re: Widget Toolkits

ghaberek said...
Icy_Viking said...

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() 
ChrisB said...

I read this as mon-GWEE-see which is fun to say out loud.

petelomax said...

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.

new topic     » goto parent     » topic index » view message » categorize

11. Re: Widget Toolkits

Icy_Viking said...

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.

new topic     » goto parent     » topic index » view message » categorize

12. Re: Widget Toolkits

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

new topic     » goto parent     » topic index » view message » categorize

13. Re: Widget Toolkits

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

new topic     » goto parent     » topic index » view message » categorize

14. Re: Widget Toolkits

ChrisB said...

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

new topic     » goto parent     » topic index » view message » categorize

15. Re: Widget Toolkits

ChrisB said...

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

new topic     » goto parent     » topic index » view message » categorize

16. Re: Widget Toolkits

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

new topic     » goto parent     » topic index » view message » categorize

17. Re: Widget Toolkits

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.

new topic     » goto parent     » topic index » view message » categorize

18. Re: Widget Toolkits

Icy_Viking said...

How many people would use such GUI toolkits?

I'm still using the old wxEuphoria GUI! grin (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.

new topic     » goto parent     » topic index » view message » categorize

19. Re: Widget Toolkits

euphoric said...
Icy_Viking said...

How many people would use such GUI toolkits?

I'm still using the old wxEuphoria GUI! grin (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.

new topic     » goto parent     » topic index » view message » categorize

20. Re: Widget Toolkits

Concerning reuseable code.

new topic     » goto parent     » topic index » view message » categorize

21. Re: Widget Toolkits

-)

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu