|
Post by bigbass on Dec 9, 2012 21:07:49 GMT 1
Sadly. a thread was locked I was having fun with BaCon and lets look at iup as just another optional library we can use or not no obligations I find it rather easy from starting with knowing nothing at all about iup to converting code for BaCon in just a few hours I still havent figured out how to convert GTK to BaCon and have tried many times its painful to admit simply let the code speak if you like it use it if it looks ugly don't use it A BACON GUI to compile the official iup C code examples to get started easily then we convert the code to BaCon once we see that it compiles correctly first ' dnd-iup.bac 'Joe Arose "bigbass" 'Dec 8 2012
' Include the files for making a GUI. INCLUDE "/usr/share/BaCon/hug.bac" INIT
SUB entry_demo() ORIGINAL_FILE$ = GRAB$(My_entry) file_start$ = "file:///" 'get rid of drag n drop prefixed file:// IF REGEX(ORIGINAL_FILE$ , file_start$) THEN ORIGINAL_FILE$ = REPLACE$(ORIGINAL_FILE$ , file_start$, "/") ELSE ORIGINAL_FILE$ = GRAB$(My_entry) ENDIF 'not used for iup but you may need more options 'PKG_CONFIG_OPTIONS$ = EXEC$(CONCAT$("pkg-config ", "--cflags ", "--libs ", "gtk+-2.0")) NO_EXT_C$ = CONCAT$(CHOP$(ORIGINAL_FILE$, ".c ", 2))
PRINT NL$ PRINT "removed the .c --> ", NO_EXT_C$ PRINT NL$ 'PRINT "PKG_CONFIG_OPTIONS-->", PKG_CONFIG_OPTIONS$ PRINT NL$ ' special commands for iup used GCC_COMMAND$ = CONCAT$("gcc ", "-liup ", "-I/usr/include/iup " ," -o ") PRINT "GCC_COMMAND$-->" ,GCC_COMMAND$ PRINT NL$ 'the filtered or unfiltered file gets passed here 'we let your system open the file for viewing based on your defaults SYSTEM CONCAT$(GCC_COMMAND$, NO_EXT_C$, " " , ORIGINAL_FILE$ ) SYSTEM CONCAT$(" ", NO_EXT_C$, " &") END SUB
Mainwin = WINDOW( "DND iup C code compiler ", 350, 150)
My_label = MARK( "iup C code drag file name here ", 300, 30 ) ATTACH( Mainwin, My_label, 10, 10) FONT(My_label, "sans 12")
My_entry = ENTRY("", 320, 30) ATTACH( Mainwin, My_entry, 10, 40 ) CALLBACK(My_entry, entry_demo)
' Create a button. My_button = BUTTON("Compile",80, 30) ATTACH( Mainwin, My_button , 140, 115 ) CALLBACK(My_button, entry_demo)
' Create a button. My_button2 = BUTTON("QUIT", 80, 30) ATTACH( Mainwin, My_button2 , 240, 115) CALLBACK(My_button2, QUIT)
DISPLAY
|
|
|
Post by bigbass on Dec 9, 2012 21:10:43 GMT 1
BaCon compiled iup code *we can test the BaCon compiler ' iupdialog2.bac ' Ported to BaCon by bigbass from the iup dialog2.c official example
' BaCon compiler options PRAGMA OPTIONS -I/usr/include/iup PRAGMA INCLUDE iup/iup.h PRAGMA LDFLAGS iup PROTO IupOpen, IupMessage, IupClose, IupSetCallback, IupSetAttribute ,IupDialog ,IupShow ,IupDestroy , IupSetAttributeHandle ,IupMainLoop ,IupButton ,Icallback ,IupLabel
' Initializes IUP IupOpen(NULL,NULL)
' force close SUB quit_cb
PRINT "quit_cb forced close " IupClose();
END SUB
' Creating the button quit_bt = IupButton("Quit", 0); IupSetCallback(quit_bt, "ACTION", (Icallback)quit_cb);
' the container with a label and the button vbox = IupVbox(IupSetAttributes(IupLabel("Very Long Text Label"), "EXPAND=YES, ALIGNMENT=ACENTER"), quit_bt, 0); IupSetAttribute(vbox, "ALIGNMENT", "ACENTER"); IupSetAttribute(vbox, "MARGIN", "10x10"); IupSetAttribute(vbox, "GAP", "5");
' Creating the dialog dialog = IupDialog(vbox); IupSetAttribute(dialog, "TITLE", "Dialog Title"); IupSetAttributeHandle(dialog, "DEFAULTESC", quit_bt);
IupShow(dialog);
IupMainLoop();
IupDestroy(dialog); IupClose();
|
|
|
Post by bigbass on Dec 9, 2012 21:12:44 GMT 1
BaCon compiled iup code ' iuptabs2.bac ' IupTabs: Example in C ' Creates a IupTabs control. ' Ported to BaCon by bigbass from the iup tabs2.c official example modified to make simpler
' BaCon compiler options PRAGMA OPTIONS -I/usr/include/iup PRAGMA INCLUDE iup/iup.h PRAGMA LDFLAGS iup PROTO IupOpen, IupMessage, IupClose, IupVbox, IupSetAttribute , IupLabel, IupTabs ,IupButton ,IupHbox ,IupDialog ,IupShowXY ,IupMainLoop
' Initializes IUP IupOpen(NULL,NULL) vbox1 = IupVbox(IupLabel("Inside Tab A"), IupButton("Button A", ""), NULL); vbox2 = IupVbox(IupLabel("Inside Tab B"), IupButton("Button B", ""), NULL);
IupSetAttribute(vbox1, "TABTITLE", "Tab A"); IupSetAttribute(vbox2, "TABTITLE", "Tab B"); get2 = IupGetAttribute(vbox2, "TABTITLE", "Tab B"); PRINT get2 , " get2" tabs1 = IupTabs(vbox1, vbox2, NULL); PRINT vbox1 , " A" PRINT tabs1 , " tabs1" box = IupHbox(tabs1, NULL); IupSetAttribute(box, "MARGIN", "10x10"); IupSetAttribute(box, "GAP", "10"); PRINT box, " box" dlg = IupDialog(box); IupSetAttribute(dlg, "TITLE", "IupTabs"); IupSetAttribute(dlg, "SIZE", "100x80");
IupShowXY (dlg, IUP_CENTER, IUP_CENTER); IupMainLoop (); IupClose ();
|
|
|
Post by bigbass on Dec 9, 2012 21:24:34 GMT 1
BaCon compiled iup code ' iupmessage2.bac ' IupMessage Example
' BaCon compiler options PRAGMA OPTIONS -I/usr/include/iup PRAGMA INCLUDE iup/iup.h PRAGMA LDFLAGS iup PROTO IupOpen, IupMessage, IupClose,
' Initializes IUP IupOpen(NULL,NULL)
' Executes IupMessage IupMessage("IupMessage Example", "Press the button");
' Finishes IUP IupClose ();
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Dec 9, 2012 22:51:27 GMT 1
Another respected BaCon user agrees with you Joe.
|
|
|
Post by Pjot on Dec 10, 2012 18:37:11 GMT 1
Hi bigbass, I am sorry about that. But the reason that the thread was locked is that I do not accept arguing, berating and calling each other names in this forum, as some members were doing. If somebody has issues with some other forum member then take these somewhere else - send a PM, for example. So, please continue having fun with BaCon. Kind regards Peter
|
|
|
Post by bigbass on Dec 10, 2012 18:47:06 GMT 1
I trust your wisdom and decisions =========================== Here is the famous filedialog GUI to open files or save files from the system It took me some time to get this to work only because I couldn't figure out how to convert the C Code pointers to BaCon so I cheated and used USEC USEC Ihandle *filedlg; END USEC if anyone knows how to convert the C code between the USEC to BaCon it would be greatly appreciated ! P.S I love using HUG and BaCon as is ! . I just dont know how to myself convert GTK to make new widgets or convert GTK code yet if someone would like to take a simple C coded GTK widget and show how to convert it step by step it would be a great help the pointer part is still very confusing Anyway this works compiled by the BaCon compiler ported to BaCon compiling is easy (now with the new options added to the BaCon compiler! ) bacon iupfiledialog.bac
' iupfiledialog.bac ' IupFileDlg Example in C ported to BaCon by bigbass
PRAGMA OPTIONS -I/usr/include/iup PRAGMA INCLUDE iup/iup.h PRAGMA LDFLAGS iup PROTO IupOpen, IupClose, IupFileDlg, IupSetAttributes , IupPopup, IupMessage , IupGetInt ,IupSetLanguage ,IupGetInt ,IupGetInt ,IupGetAttribute ,IupDestroy , IupClose
USEC Ihandle *filedlg; END USEC IupOpen(NULL,NULL)
IupSetLanguage("ENGLISH"); filedlg = IupFileDlg()
IupSetAttributes(filedlg, "DIALOGTYPE = OPEN, TITLE = \"File Save\""); IupSetAttributes(filedlg, "FILTER = \"*.*\", FILTERINFO = \"ALL Files\"");
IupPopup(filedlg, IUP_CENTER, IUP_CENTER);
response = (IupGetInt(filedlg, "STATUS")) IF response = 1 THEN IupMessage("New file",IupGetAttribute(filedlg, "VALUE")); IF response = 0 THEN IupMessage("File already exists",IupGetAttribute(filedlg, "VALUE")); IF response = -1 THEN IupMessage("IupFileDlg","Operation Canceled"); PRINT response
IupDestroy(filedlg); IupClose(); END
======================================================== original C code below only to see what was changed to make it work ======================================================== /*IupFileDlg Example in C Shows a typical file-saving dialog. */ #include <stdlib.h> #include <stdio.h> #include <iup.h>
int main(int argc, char **argv) { Ihandle *filedlg; IupOpen(&argc, &argv); IupSetLanguage("ENGLISH"); filedlg = IupFileDlg(); IupSetAttributes(filedlg, "DIALOGTYPE = SAVE, TITLE = \"File Save\""); IupSetAttributes(filedlg, "FILTER = \"*.bmp\", FILTERINFO = \"Bitmap Files\"");
IupPopup(filedlg, IUP_CENTER, IUP_CENTER);
switch(IupGetInt(filedlg, "STATUS")) { case 1: IupMessage("New file",IupGetAttribute(filedlg, "VALUE")); break;
case 0 : IupMessage("File already exists",IupGetAttribute(filedlg, "VALUE")); break;
case -1 : IupMessage("IupFileDlg","Operation Canceled"); return 1; break; }
IupDestroy(filedlg); IupClose(); return EXIT_SUCCESS;
}
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Dec 10, 2012 19:58:53 GMT 1
I would have thought the USEH / ENDUSEH would of worked based on the docs.
I know Charles (OxygenBasic author) had to hack the iup.h include for this same reason.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Dec 10, 2012 20:03:02 GMT 1
Just remove post #18 forward and that thread is recoverable. A warning would have been sufficient.
Request: Please reopen the BaCon IUP thread.
|
|
|
Post by alexfish on Dec 10, 2012 23:51:39 GMT 1
Have managed to trackdown the brief API Here I am shooting in the dark and have not tried this if have "libiup.so" on the system then possible to crossmatch the API to the .so Can find what is in the .so with the nm command IE nm /path/to/libiup.so possible strout to file using the > ./myfile for reading Then from the two info's it may be possible to import the parts via bacon much the same as the From the download site "Import definitions when using HUG as a shared object" 'IE hug.so Since the API appears to be terse , it may need less args as regards the likes (long Char* etc etc) TYPE any* As said have not tried this , also the same rules may apply to the c code if compiling The Functions , try them as a .so also Noted from the site the use of LUA . thing there is a lua.bac on bacon site here again this is shooting in the dark Regards Alex Attachments:
|
|
|
Post by vovchik on Dec 11, 2012 11:33:24 GMT 1
Dear Joe, Keep up the good work. I would do your filedialog like the C code: ' iupfiledialog.bac ' IupFileDlg Example in C ported to BaCon by bigbass
PRAGMA OPTIONS -I/usr/include/iup PRAGMA INCLUDE iup/iup.h PRAGMA LDFLAGS iup PROTO IupOpen, IupClose, IupFileDlg, IupSetAttributes, IupPopup, IupMessage, IupGetInt, IupSetLanguage, IupGetInt, IupGetInt, IupGetAttribute, IupDestroy, IupClose
USEC Ihandle *filedlg; END USEC
IupOpen(NULL,NULL) IupSetLanguage("ENGLISH") filedlg = IupFileDlg() IupSetAttributes(filedlg, "DIALOGTYPE = OPEN, TITLE = \"File Save\"") IupSetAttributes(filedlg, "FILTER = \"*.*\", FILTERINFO = \"ALL Files\"") IupPopup(filedlg, IUP_CENTER, IUP_CENTER) response = (IupGetInt(filedlg, "STATUS")) SELECT response CASE 1 IupMessage("New file",IupGetAttribute(filedlg, "VALUE")) CASE 0 IupMessage("File already exists",IupGetAttribute(filedlg, "VALUE")) CASE -1 IupMessage("IupFileDlg","Operation Cancelled") END SELECT PRINT response IupDestroy(filedlg) IupClose() END
With kind regards, vovchik PS. Not much code to do the filedialog
|
|
|
Post by vovchik on Dec 11, 2012 12:32:03 GMT 1
Dear guys and gals,
As much as I like the IUP stuff, HUG is much more universal - runs on all Unix machines without extra dependencies. IUP presumes the existence of the IUP libs, and they are not universal...
With kind regards, vovchik
PS. We do not have universal APIs - maybe someday. But there is something positive in diversity. So, like Darwin, I like it all:)
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Dec 11, 2012 16:17:34 GMT 1
FWIW:
I static link IUP with my applications so IUP dependences aren't an issue. I think you will find this isn't a IUP specific issue and what we have to deal with using any third party libraries.
|
|
|
Post by vovchik on Dec 11, 2012 17:46:02 GMT 1
Dear jrs,
I have to try static linking and look then at the size. You may be on to something nice....Normally, I strip symbols and later do UPX to get a nice and tiny executable.
With kind regards, vovchik
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Dec 13, 2012 3:16:54 GMT 1
Speaking size, I got the BCX Hello World working and noticed a huge difference in the resulting executable size. BaCon-rwxrwxr-x 1 jrs jrs 49794 Dec 2 20:15 helloiup BCX-rwxrwxr-x 1 jrs jrs 8648 Dec 10 16:33 helloiup
|
|