1. /IUP/ Help needed with examples

I have a page of "predefined dialogs" in the wiki: http://openeuphoria.org/wiki/view/Predefined%20Dialogs.wc

Working Examples History

  1. ( ok ) IupAlarm
  2. ( ok ) IupColorDlg
  3. ( ok ) IupElementPropertiesDialog
  4. ( partial ) IupFileDlg
  5. ( ? return value ) IupFontDlg
  6. ( ok ) IupGetColor
  7. ( ? what is arq ) IupGetFile
  8. ( not decoded ) IupGetParam
  9. ( ? second argument ) IupGetText
  10. ( ok ) IupLayoutDialog
  11. ( not decoded ) IupListDialog
  12. ( ok ) IupMessage
  13. ( ok ) IupMessageDlg
  14. ( 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:

  1. IupLayoutDialog
  2. IupElementPropertiesDialog

If you have time, please help

thanks

_tom

new topic     » topic index » view message » categorize

2. Re: /IUP/ Help needed with examples

Hallo

i allready worked on FileDlg,FontDlg,ProgressDlg.

Please check them (i only checked them on my Win32 setup)

Andreas

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

3. Re: /IUP/ Help needed with examples

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

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

4. Re: /IUP/ Help needed with examples

jmduro said...

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

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

5. Re: /IUP/ Help needed with examples

_tom said...
  1. ( ? 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

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

6. Re: /IUP/ Help needed with examples

jmduro said...
_tom said...
  1. ( ? 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

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

7. Re: /IUP/ Help needed with examples

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?

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

8. Re: /IUP/ Help needed with examples

dr_can said...

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. getlost

-Greg

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

9. Re: /IUP/ Help needed with examples

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.)

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

10. Re: /IUP/ Help needed with examples

dr_can said...

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?

dr_can said...

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)

dr_can said...

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

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

11. Re: /IUP/ Help needed with examples

dr_can said...

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

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

12. Re: /IUP/ Help needed with examples

_tom said...
dr_can said...

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()  
new topic     » goto parent     » topic index » view message » categorize

13. Re: /IUP/ Help needed with examples

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

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

Search



Quick Links

User menu

Not signed in.

Misc Menu