1. IUP 3.31 Wrapper
- Posted by Icy_Viking Oct 25, 2023
- 1182 views
Hello all,
Well I did it! I made, rather updated my IUP wrapper for 3.31. However I can't figure why this example isn't working.
Wrapper here: https://github.com/gAndy50/IUPWrapper
#include <stdlib.h> #include <iup.h> int btn_count_cb( Ihandle *self ) { Ihandle* text = IupGetDialogChild(self, "TEXT"); int value = IupGetInt(text, "VALUE"); IupSetInt(text, "VALUE", ++value); return IUP_DEFAULT; }
--Counter example include std/ffi.e include iup.e public function btn_count_cb(object self) object text = IupGetDialogChild(self,"TEXT") atom val = IupGetInt(text,"VALUE") IupSetInt(text,"VAULE",val+1) return IUP_DEFAULT end function btn_count_cb(0) --being a number or NULL just causes a console window to briefly appear
As for the example a brief console window shows up then goes away. My guess is I need a more Euphoria way of using the callback or I'm missing something?
2. Re: IUP 3.31 Wrapper
- Posted by petelomax Oct 27, 2023
- 1081 views
- Last edited Oct 28, 2023
I can't figure why this example isn't working.
As for the example a brief console window shows up then goes away. My guess is I need a more Euphoria way of using the callback or I'm missing something?
You need to translate the rest of that example as well: https://www.tecgraf.puc-rio.br/iup/en/7gui/counter.c
Without an IupMainLoop() after an IupShow[XY](), most IUP programs would do nothing other than terminate immediately.
As-is, I would expect that IupGetDialogChild() call to either crash or return NULL since there is no interface element with a "NAME" of "TEXT",
and if it does not crash, simply g/set the meaningless "VALUE" attribute in the global environment, which wouldn't do anything useful/visible.
PS: there is also a "VAULE" typo in your translation, and you will probably need to change "object self" to "atom self" otherwise call_back() on it will complain.
3. Re: IUP 3.31 Wrapper
- Posted by Icy_Viking Oct 27, 2023
- 1055 views
I can't figure why this example isn't working.
As for the example a brief console window shows up then goes away. My guess is I need a more Euphoria way of using the callback or I'm missing something?
You need to translate the rest of that example as well: https://www.tecgraf.puc-rio.br/iup/en/7gui/counter.c
Without an IupMainLoop() after an IupShow[XY](), no IUP program would ever do anything other than terminate immediately.
As-is, I would expect that IupGetDialogChild() call to either crash or return NULL since there is no interface element with a "NAME" of "TEXT",
and if it does not crash, simply g/set the meaningless "VALUE" attribute in the global environment, which wouldn't do anything useful/visible.
PS: there is also a "VAULE" typo in your translation, and you will probably need to change "object self" to "atom self" otherwise call_back() on it will complain.
Alright, I fixed the typo and re-wrote the program in Euphoria. However nothing still shows up.
--Counter example include std/ffi.e include iup.e public function btn_count_cb() atom self = 0 object text = IupGetDialogChild(self,"TEXT") atom val = IupGetInt(text,"VALUE") IupSetInt(text,"VALUE",val+1) return IUP_DEFAULT end function atom id = routine_id("btn_count_cb") atom cb = call_back(id) procedure Main() IupOpen(NULL,NULL) atom button = IupButton("Count","") IupSetAttribute(button,"SIZE","60") atom text = IupText("") IupSetAttribute(text,"SIZE","60") IupSetAttribute(text,"NAME","TEXT") IupSetAttribute(text,"READONLY","YES") atom hbox = IupHbox(text,button) IupSetAttribute(hbox,"MARGIN","10x10") IupSetAttribute(hbox,"GAP","10") atom dlg = IupDialog(hbox) IupSetAttribute(dlg,"TITLE","Counter") IupSetInt(text,"VALUE",0) IupSetCallback(button,"ACTION",cb) IupShowXY(dlg,IUP_CENTER,IUP_CENTER) IupMainLoop() IupClose() end procedure Main()
This very simple example works just fine.
--Hello World Example include std/ffi.e --for NULL include iup.e public procedure Main() IupOpen(NULL,NULL) IupMessage("Hello World","Hello World from IUP") IupClose() end procedure Main()
4. Re: IUP 3.31 Wrapper
- Posted by petelomax Oct 28, 2023
- 1032 views
It is not wise to have IUP.e as well as iup.e ! - I ignored the first one.
(Using Phix) I had to kill IupImageLibOpen in iup.e since that's not in the iup.dll you provided.
I also had to hack IupHbox since that must always be null terminated.
(Phix/pGUI only ever uses IupHboxv, which is for us non-C lot after all)
-- xIupHbox = define_c_func(iup,"+IupHbox",{C_POINTER,C_INT},C_POINTER), xIupHbox = define_c_func(iup,"+IupHbox",{C_POINTER,C_PTR,C_PTR},C_POINTER), -- return c_func(xIupHbox,{child,x}) return c_func(xIupHbox,{child,x,NULL})
Renamed IupTextConvertLineColToPos as IupTextConvertLinColToPos
Made the callback "public function btn_count_cb(atom self)"
Also made it atom cb = call_back({'+',id}) [that may only be a Phix thing]
Then it all worked.
PS: note that I am not using/testing std/ffi.e at all.
5. Re: IUP 3.31 Wrapper
- Posted by ghaberek (admin) Oct 28, 2023
- 1028 views
I've already worked out a lot of the intricacies and nuances of using IUP with Euphoria. I had originally made "iup4eu" years ago but some of that got lost when BitBucket shutdown Mercurial repositories. I've since made even more progress on getting things working correctly. If anyone's willing to contribute, especially by porting the existing examples from C, I can raise my priority on getting that published as a separate project.
-Greg
6. Re: IUP 3.31 Wrapper
- Posted by Icy_Viking Oct 29, 2023
- 976 views
I've already worked out a lot of the intricacies and nuances of using IUP with Euphoria. I had originally made "iup4eu" years ago but some of that got lost when BitBucket shutdown Mercurial repositories. I've since made even more progress on getting things working correctly. If anyone's willing to contribute, especially by porting the existing examples from C, I can raise my priority on getting that published as a separate project.
-Greg
I wouldn't mind helping out. Writing the C examples in Euphoria. If you still have the iup4eu package.
7. Re: IUP 3.31 Wrapper
- Posted by petelomax Oct 30, 2023
- 976 views
- Last edited Oct 31, 2023
I could chip in too. In fact, just last week I identified 164 samples I should port from pGUI to xpGUI (2 done, 4 partly) so while not quite I am kinda working in that area anyway, and some of them may already be pretty close.
While I certainly don't want to hold anyone back, xpGUI is currently about 1/3 the complexity of IUP, and instead targets GTK or WinAPI, so if I ever finish it you might want to abandon(/mothball) IUP(/pGUI), like I plan to.