1. /IUP/ Help needed with examples
- Posted by _tom (admin) Dec 23, 2015
- 2345 views
I have a page of "predefined dialogs" in the wiki: http://openeuphoria.org/wiki/view/Predefined%20Dialogs.wc
Working Examples History
- ( ok ) IupAlarm
- ( ok ) IupColorDlg
- ( ok ) IupElementPropertiesDialog
- ( partial ) IupFileDlg
- ( ? return value ) IupFontDlg
- ( ok ) IupGetColor
- ( ? what is arq ) IupGetFile
- ( not decoded ) IupGetParam
- ( ? second argument ) IupGetText
- ( ok ) IupLayoutDialog
- ( not decoded ) IupListDialog
- ( ok ) IupMessage
- ( ok ) IupMessageDlg
- ( incomplete ) IupProgressDlg
As you can see I can't get example programs to work with all dialogs. Some are just plain messy and for others I can't figure out the data-types.
These two dialogs are the basis of a "poor man's" ide:
If you have time, please help
thanks
_tom
2. Re: /IUP/ Help needed with examples
- Posted by andi49 Dec 23, 2015
- 2361 views
Hallo
i allready worked on FileDlg,FontDlg,ProgressDlg.
Please check them (i only checked them on my Win32 setup)
Andreas
3. Re: /IUP/ Help needed with examples
- Posted by jmduro Dec 24, 2015
- 2308 views
I proposed modifications to IupGetParam here:
http://openeuphoria.org/forum/m/129127.wc
Greg seemed to agree with this proposal but I didn't notice any change in existing code some weeks ago.
Jean-Marc
4. Re: /IUP/ Help needed with examples
- Posted by ghaberek (admin) Dec 24, 2015
- 2293 views
I proposed modifications to IupGetParam here:
http://openeuphoria.org/forum/m/129127.wc
Greg seemed to agree with this proposal but I didn't notice any change in existing code some weeks ago.
This is a change I hope to make before the next release. I am using IupGetParam in TEE right now (for the Bind dialog) so I need to re-write the whole Bind function before I can do a release.
-Greg
5. Re: /IUP/ Help needed with examples
- Posted by jmduro Jan 05, 2016
- 2190 views
- ( ? what is arq ) IupGetFile
I don't know why it is called arq: it should be filename. Here is what IUP documentation writes:
filename: This parameter is used as an input value to define the default filter and directory. Example: "../docs/*.txt". As an output value, it is used to contain the filename entered by the user.
Jean-Marc
6. Re: /IUP/ Help needed with examples
- Posted by ghaberek (admin) Jan 05, 2016
- 2195 views
- ( ? what is arq ) IupGetFile
I don't know why it is called arq: it should be filename. Here is what IUP documentation writes:
filename: This parameter is used as an input value to define the default filter and directory. Example: "../docs/*.txt". As an output value, it is used to contain the filename entered by the user.
It's called arq in iup.h so that's what comes through via the wrapper. I have to work on a better method of automatically correcting these one-off problems.
Until I get this wrapped correctly, here's how you'd call IupGetFile().
include std/machine.e include iup/iup.e function myIupGetFile( sequence filename = "" ) -- IUP documentation for IupGetFile states: -- "The string is limited to 4096 characters." atom arq = allocate_data( 4096 ) mem_set( arq, 0, 4096 ) poke( arq, filename ) integer result = c_func( xIupGetFile, {arq} ) if result != -1 then filename = peek_string( arq ) else -- user cancelled filename = "" end if free( arq ) return filename end function
Edit: I added an issue to work on this: IupGetFile should accept and return a sequence.
-Greg
7. Re: /IUP/ Help needed with examples
- Posted by dr_can Jan 07, 2016
- 2148 views
I am working through the Iup examples and also "A Basic Guide to using IupLua" (see http://www.luteus.biz/Download/LoriotPro_Doc/LUA/LUA_For_Windows/iup/iup.html)
I am trying a version of the Alert example:
-- Example 2 -- Alarm include gui/iup/iup.e constant reply = {"File saved sucessfully - leaving program", "File not saved - leaving program anyway", "Operation cancelled"} procedure main( sequence cmd = command_line() ) IupOpen( 0, {} ) integer b = IupAlarm("IupAlarm Example", "File not saved! Save it now?" ,"Yes" ,"No" ,"Cancel") -- Shows a message for each selected button printf(1, "The response is: %s", {reply[b]}) if getc(0) then end if IupMessage("Save File", reply[b]) IupClose() end procedure main()
Lines 14 & 15 are added to prove that b is correctly returned; why doesn't the IupMessage get invoked?
8. Re: /IUP/ Help needed with examples
- Posted by ghaberek (admin) Jan 07, 2016
- 2140 views
I am working through the Iup examples and also "A Basic Guide to using IupLua" (see http://www.luteus.biz/Download/LoriotPro_Doc/LUA/LUA_For_Windows/iup/iup.html)
I am trying a version of the Alert example:
snip
Lines 14 & 15 are added to prove that b is correctly returned; why doesn't the IupMessage get invoked?
I think you need to have a window defined for IupMessage to work correctly. Notice the line I added below:
-- Example 2 -- Alarm include gui/iup/iup.e constant reply = {"File saved sucessfully - leaving program", "File not saved - leaving program anyway", "Operation cancelled"} procedure main( sequence cmd = command_line() ) IupOpen( 0, {} ) integer b = IupAlarm("IupAlarm Example", "File not saved! Save it now?" ,"Yes" ,"No" ,"Cancel") -- Shows a message for each selected button printf(1, "The response is: %s", {reply[b]}) if getc(0) then end if IupShow( IupDialog( NULL ) ) -- show an empty dialog IupMessage("Save File", reply[b]) IupClose() end procedure main()
Now it works as you'd expect. I cannot explain why IupMessage requires a window and IupAlarm does not.
-Greg
9. Re: /IUP/ Help needed with examples
- Posted by dr_can Jan 07, 2016
- 2091 views
I found the same issue when "translating" the "Asking for Multiline Text" example (IupGetText usage) from Lua to Eu; same solution works there.
Thanks for the help. I'll keep going on those examples. Do you want me to post them anywhere once they work?
I think that if we are to make the EuIup library seem as easy and Euphoric as possible then IupGetFile has to have a sequence argument, to avoid expecting the user to invoke both allocate_string and poke_string; likewise IupGetText needs two sequence arguments for the same reason.
PS Can you think why neither the Lua nor the C examples need this "blank" dialog. Is it something in the (Eu) Iup library? (I didn't have to do anything like this when using Jeremy's library in the past.)
10. Re: /IUP/ Help needed with examples
- Posted by ghaberek (admin) Jan 07, 2016
- 2137 views
I found the same issue when "translating" the "Asking for Multiline Text" example (IupGetText usage) from Lua to Eu; same solution works there.
Thanks for the help. I'll keep going on those examples. Do you want me to post them anywhere once they work?
Tom had already worked on some of the examples and committed them to the repository. I can give you access as well. Are you familiar with Mercurial?
I think that if we are to make the EuIup IUP for Euphoria library seem as easy and Euphoric as possible then IupGetFile has to have a sequence argument, to avoid expecting the user to invoke both allocate_string and poke_string; likewise IupGetText needs two sequence arguments for the same reason.
I plan to do this. I need to get those changes baked into the wrapper. Feel free to open additional issues in the repository for any changes you feel need to be made. (That statement goes for everyone, BTW)
PS Can you think why neither the Lua nor the C examples need this "blank" dialog. Is it something in the (Eu) Iup library? (I didn't have to do anything like this when using Jeremy's library in the past.)
I actually tested your code in C and I had the same problem. The same solution was required there, too.
#include <stdio.h> #include <iup.h> const char* reply[] = {"File saved sucessfully - leaving program", "File not saved - leaving program anyway", "Operation cancelled"}; int main( int argc, char* argv[] ) { IupOpen( &argc, &argv ); int b = IupAlarm("IupAlarm Example", "File not saved! Save it now?", "Yes", "No", "Cancel"); printf("The response is: %s\n", reply[b-1]); IupShow( IupDialog(NULL) ); IupMessage("Save File", reply[b-1]); IupClose(); return 0; }
-Greg
11. Re: /IUP/ Help needed with examples
- Posted by _tom (admin) Jan 07, 2016
- 2092 views
I am trying a version of the Alert example:
-- Example 2 -- Alarm include gui/iup/iup.e constant reply = {"File saved sucessfully - leaving program", "File not saved - leaving program anyway", "Operation cancelled"} procedure main( sequence cmd = command_line() ) IupOpen( 0, {} ) integer b = IupAlarm("IupAlarm Example", "File not saved! Save it now?" ,"Yes" ,"No" ,"Cancel") -- Shows a message for each selected button printf(1, "The response is: %s", {reply[b]}) if getc(0) then end if IupMessage("Save File", reply[b]) IupClose() end procedure main()
Lines 14 & 15 are added to prove that b is correctly returned; why doesn't the IupMessage get invoked?
Try this:
include iup/iup.e constant reply = { "File saved sucessfully - leaving program", -- 1 "File not saved - leaving program anyway", -- 2 "Operation cancelled" -- 3 } IupOpen(NULL) integer b = IupAlarm( "IupAlarm Example", "File not saved! Save it now?", "Yes", "No", "Cancel" ) ? b -- 1 | 2 | 3 IupMessage( "Hello Message", reply[b] ) IupClose()
I can't explain, but I always remove lines of code until a program works.
_tom
12. Re: /IUP/ Help needed with examples
- Posted by dr_can Jan 08, 2016
- 2080 views
I am trying a version of the Alert example:
-- Example 2 -- Alarm include gui/iup/iup.e constant reply = {"File saved sucessfully - leaving program", "File not saved - leaving program anyway", "Operation cancelled"} procedure main( sequence cmd = command_line() ) IupOpen( 0, {} ) integer b = IupAlarm("IupAlarm Example", "File not saved! Save it now?" ,"Yes" ,"No" ,"Cancel") -- Shows a message for each selected button printf(1, "The response is: %s", {reply[b]}) if getc(0) then end if IupMessage("Save File", reply[b]) IupClose() end procedure main()
Lines 14 & 15 are added to prove that b is correctly returned; why doesn't the IupMessage get invoked?
Try this:
include iup/iup.e constant reply = { "File saved sucessfully - leaving program", -- 1 "File not saved - leaving program anyway", -- 2 "Operation cancelled" -- 3 } IupOpen(NULL) integer b = IupAlarm( "IupAlarm Example", "File not saved! Save it now?", "Yes", "No", "Cancel" ) ? b -- 1 | 2 | 3 IupMessage( "Hello Message", reply[b] ) IupClose()
I can't explain, but I always remove lines of code until a program works.
_tom
Whatever variation in IupOpen parameters, console interrogation, use or non-use of "main", Greg's addition of an empty dialog is always required. However, if you add the line:
IupShow( IupDialog( NULL ) ) -- show an empty dialog
before Line 1511 in iup.e
then the Lua example on the Iup site could be replicated via:
include gui/iup/iup.e constant hello = "Hello Message" IupOpen(NULL) switch IupAlarm( "IupAlarm Example", "File not saved! Save it now?", "Yes", "No", "Cancel" ) do case 1 then IupMessage(hello, "File saved sucessfully - leaving program") case 2 then IupMessage(hello, "File not saved - leaving program anyway") case 3 then IupMessage(hello, "Operation cancelled") end switch IupClose()
13. Re: /IUP/ Help needed with examples
- Posted by andi49 Jan 08, 2016
- 2079 views
Hi
these are the examples from the IUP side: They work
http://webserver2.tecgraf.puc-rio.br/iup/examples/Lua/message.lua
-- IupMessage Example in IupLua -- Shows a dialog with the message: “Click the button”. require( "iuplua" ) iup.Message ("IupMessage", "Press the button")
http://webserver2.tecgraf.puc-rio.br/iup/examples/C/message.c
/* IupMessage Example */ #include <stdlib.h> #include <stdio.h> /* IUP libraries include */ #include <iup.h> /* Main program */ int main(int argc, char **argv) { /* Initializes IUP */ IupOpen(&argc, &argv); /* Executes IupMessage */ IupMessage("IupMessage Example", "Press the button"); /* Finishes IUP */ IupClose (); /* Program finished successfully */ return EXIT_SUCCESS; }
Looking at http://webserver2.tecgraf.puc-rio.br/iup/en/dlg/iupmessage.html
IupMessage seemd to use PARENTDIALOG (even if it is not needed).
Maybe, (i say only maybe) if IupAlarm sets PARENTDIALOG and dies than IupMessage may use an invalid handle as parent and may die.
Just an idea.
Andreas