Re: Widget Toolkits

new topic     » goto parent     » topic index » view thread      » older message » newer message
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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu