Author Topic: O2 / IUP  (Read 15772 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
Re: O2 / IUP
« Reply #15 on: January 11, 2013, 06:01:33 PM »
Wrong WindowXP  :D

X

JRS

  • Guest
Re: O2 / IUP
« Reply #16 on: January 11, 2013, 06:25:48 PM »
Are you saying I need to translate Win32 via Windows 7 (32 to 64 bit OS) to work?

I have Windows 7 64 bit in my other partition I normally reserve for 64 bit Windows testing. I'll give this a try there.

FWIW Many Windows users are still using XP on their (part time) PC when not using a mobile device.



« Last Edit: January 11, 2013, 07:06:20 PM by JRS »

JRS

  • Guest
Re: O2 / IUP
« Reply #17 on: January 11, 2013, 06:51:42 PM »
Windows 7 (64 bit) doesn't work with the the same code I tried under XP. You must have a magical version of O2 that makes IUP listen to you.  ::)

I thought that maybe the iup.dll (MinGWGCCTDM) I had installed in the system32 directory was the issue. I renamed it so I was using the one you provided in the zip but still no change.




« Last Edit: January 11, 2013, 07:58:29 PM by JRS »

JRS

  • Guest
Re: O2 / IUP
« Reply #18 on: January 11, 2013, 08:44:00 PM »
This is IUP working on XP using ScriptBasic and the extension module (wrapper) I wrote.



Code: [Select]
' IUP Button / Event Example

IMPORT iup.bas

SUB Btn1_clicked
  PRINT "BUTTON 1 Event\n"
END SUB

SUB Btn2_clicked
  PRINT "BUTTON 2 Event\n"
END SUB

SUB Btn3_clicked
  PRINT "BUTTON 3 Event\n"
END SUB

SUB Win_exit
  Iup::ExitLoop = TRUE
END SUB

Iup::Open()
win = Iup::Create("dialog")
Iup::SetAttributes(win, "TITLE=\"Test Dialog\", SIZE=300x")
horzbox = Iup::Create("hbox")
Iup::SetAttributes(horzbox, "GAP=5")
btn1 = Iup::Create("button")
Iup::SetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL")
btn2 = Iup::Create("button")
Iup::SetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL")
btn3 = Iup::Create("button")
Iup::SetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL")
Iup::Append(horzbox, btn1)
Iup::Append(horzbox, btn2)
Iup::Append(horzbox, btn3)
Iup::Append(win, horzbox)
Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit()))
Iup::SetCallback(btn1,"ACTION",ADDRESS(Btn1_clicked()))
Iup::SetCallback(btn2,"ACTION",ADDRESS(Btn2_clicked()))
Iup::SetCallback(btn3,"ACTION",ADDRESS(Btn3_clicked()))
Iup::Show(win)
Iup::MainLoop()
Iup::Close()

C:\scriptbasic\test>sbiup iup_buttons.sb
BUTTON 1 Event
BUTTON 2 Event
BUTTON 3 Event

C:\scriptbasic\test>

* sbiup.exe - Windows version of ScriptBasic that doesn't pop a console window like the console version scriba does.
« Last Edit: January 11, 2013, 10:46:42 PM by JRS »

Charles Pegge

  • Guest
Re: O2 / IUP
« Reply #19 on: January 11, 2013, 11:13:48 PM »
Hi John and Peter,

In Oxygen your callback Subs should have the callback attribute, otherwise it will corrupt some of the registers used by IUP causing Exceptions.

I think this will resolve the problem.

Note wndproc() always requires this attribute because it is also called from outside of Oxygen.

Code: [Select]
sub Btn2_clicked() callback
  print "BUTTON 2 Event"
end sub

Charles
« Last Edit: January 11, 2013, 11:22:04 PM by Charles Pegge »

Peter

  • Guest
Re: O2 / IUP
« Reply #20 on: January 12, 2013, 12:17:34 AM »
Thanks Charles,

We need a callback tutorial !  :D

Code: [Select]
include "iup.inc" 
sys win 
 
Sub Btn1_clicked() callback
  IupMessage "OKAY","BUTTON 1 Event" 
End Sub 
 
Sub Btn2_clicked() callback
  IupMessage "OKAY","BUTTON 2 Event" 
End Sub 
 
Sub Btn3_clicked() callback
  IupMessage "OKAY","BUTTON 3 Event" 
End Sub 
 
Sub Btn4_clicked() callback
  IupMessage "OKAY","BUTTON 4 Event" 
End Sub 

IupOpen 0,0 
win=IupCreate("dialog") 
IupSetAttributes win, "TITLE= Test Dialog, SIZE=300x" 
horzbox = IupCreate("hbox") 
IupSetAttributes(horzbox, "GAP=5") 
btn1 = IupCreate("button") 
IupSetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL") 
btn2 = IupCreate("button") 
IupSetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL") 
btn3 = IupCreate("button") 
IupSetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL") 

btn4 = IupCreate("button") 
IupSetAttributes(btn4, "TITLE=Button4, EXPAND=HORIZONTAL") 

IupAppend(horzbox, btn1) 
IupAppend(horzbox, btn2) 
IupAppend(horzbox, btn3) 
IupAppend(horzbox, btn4) 

IupAppend(win, horzbox) 
IupSetCallback(btn1, "ACTION", Btn1_clicked) 
IupSetCallback(btn2, "ACTION", Btn2_clicked) 
IupSetCallback(btn3, "ACTION", Btn3_clicked) 
IupSetCallback(btn4, "ACTION", Btn4_clicked) 

IupShow win 
IupMainLoop 
IupClose 

Peter

  • Guest
Re: O2 / IUP
« Reply #21 on: January 12, 2013, 12:20:10 AM »
Quote
You must have a magical version of O2 that makes IUP listen to you.
 

My Windows7 is by MicroSoft, yours is by Bill Gates  :D

Aurel

  • Guest
Re: O2 / IUP
« Reply #22 on: January 12, 2013, 12:36:06 AM »
No ...your IUP is from BillyTheGate.. ;D
Or maybe you need proper ipiyipi.dll like me from Lua51...grr :D :D :D

X

Charles Pegge

  • Guest
Re: O2 / IUP
« Reply #23 on: January 12, 2013, 03:10:45 AM »
You can also use external instead of callback

Or you can place all the callback subs inside an extern .. end extern block. Then you don't have to tag them individually. They are safe for the outside world to access.

Aurel

  • Guest
Re: O2 / IUP
« Reply #24 on: January 12, 2013, 06:04:20 AM »
Quote
You can also use external instead of callback
well i don't know that ,so on this way will work any GUI wraper
created in dll...i will try HMG from xHarbour... ::)

Charles Pegge

  • Guest
Re: O2 / IUP
« Reply #25 on: January 12, 2013, 06:54:42 AM »
These tags instruct the compiler to save extra registers: ebx esi and edi onto the stack at the start of a procedure, then pops them before returning.  This satisfies the stdcall and cdecl calling conventions. Internal Oxygen functions do not save these registers and assumes that the ebx register always references static/global variables and the run-time library. This saves significant processing time.

The same rules are applied to export procedures in a dll.
« Last Edit: January 12, 2013, 07:01:01 AM by Charles Pegge »

JRS

  • Guest
Re: O2 / IUP
« Reply #26 on: January 12, 2013, 09:28:19 AM »
That didn't change anything for me. I'm still seeing the SUBs doing the PRINTs before the buttons dialog appears. If I click on any of the buttons I get an exception error dialog.

Code: OxygenBasic
  1. sys win
  2.  
  3. Sub Btn1_clicked() CALLBACK
  4.   PRINT "BUTTON 1 Event"
  5. End Sub
  6.  
  7. Sub Btn2_clicked() CALLBACK
  8.   PRINT "BUTTON 2 Event"
  9. End Sub
  10.  
  11. Sub Btn3_clicked() CALLBACK
  12.   PRINT "BUTTON 3 Event"
  13. End Sub
  14.  
  15. IupOpen(0,0)
  16. win=IupCreate("dialog")
  17. IupSetAttributes win, "TITLE= Test Dialog, SIZE=300x"
  18. horzbox = IupCreate("hbox")
  19. IupSetAttributes(horzbox, "GAP=5")
  20. btn1 = IupCreate("button")
  21. IupSetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL")
  22. btn2 = IupCreate("button")
  23. IupSetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL")
  24. btn3 = IupCreate("button")
  25. IupSetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL")
  26. IupAppend(horzbox, btn1)
  27. IupAppend(horzbox, btn2)
  28. IupAppend(horzbox, btn3)
  29. IupAppend(win, horzbox)
  30. IupSetCallback(btn1,"ACTION",Btn1_clicked)
  31. IupSetCallback(btn2,"ACTION",Btn2_clicked)
  32. IupSetCallback(btn3,"ACTION",Btn3_clicked)
  33. IupShow(win)
  34. IupMainLoop()
  35. IupClose()
  36.  

Peter's version of PRINT doesn't help either.

Code: OxygenBasic
  1. include "iup.inc"  
  2. sys win  
  3.  
  4. Sub Btn1_clicked() callback
  5.   IupMessage "OKAY","BUTTON 1 Event"  
  6. End Sub  
  7.  
  8. Sub Btn2_clicked() callback
  9.   IupMessage "OKAY","BUTTON 2 Event"  
  10. End Sub  
  11.  
  12. Sub Btn3_clicked() callback
  13.   IupMessage "OKAY","BUTTON 3 Event"  
  14. End Sub  
  15.  
  16. Sub Btn4_clicked() callback
  17.   IupMessage "OKAY","BUTTON 4 Event"  
  18. End Sub  
  19.  
  20. IupOpen 0,0  
  21. win=IupCreate("dialog")  
  22. IupSetAttributes win, "TITLE= Test Dialog, SIZE=300x"  
  23. horzbox = IupCreate("hbox")  
  24. IupSetAttributes(horzbox, "GAP=5")  
  25. btn1 = IupCreate("button")  
  26. IupSetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL")  
  27. btn2 = IupCreate("button")  
  28. IupSetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL")  
  29. btn3 = IupCreate("button")  
  30. IupSetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL")  
  31.  
  32. btn4 = IupCreate("button")  
  33. IupSetAttributes(btn4, "TITLE=Button4, EXPAND=HORIZONTAL")  
  34.  
  35. IupAppend(horzbox, btn1)  
  36. IupAppend(horzbox, btn2)  
  37. IupAppend(horzbox, btn3)  
  38. IupAppend(horzbox, btn4)  
  39.  
  40. IupAppend(win, horzbox)  
  41. IupSetCallback(btn1, "ACTION", Btn1_clicked)  
  42. IupSetCallback(btn2, "ACTION", Btn2_clicked)  
  43. IupSetCallback(btn3, "ACTION", Btn3_clicked)  
  44. IupSetCallback(btn4, "ACTION", Btn4_clicked)  
  45.  
  46. IupShow win  
  47. IupMainLoop  
  48. IupClose  
  49.  
« Last Edit: January 12, 2013, 09:44:59 AM by JRS »

Charles Pegge

  • Guest
Re: O2 / IUP
« Reply #27 on: January 12, 2013, 11:37:28 AM »
Hi John,

I think your callback setups should look like this:

passing the address of each sub rather than invoking them.

Code: OxygenBasic
  1. IupSetCallback(btn1, "ACTION", @Btn1_clicked)    
  2. IupSetCallback(btn2, "ACTION", @Btn2_clicked)    
  3. IupSetCallback(btn3, "ACTION", @Btn3_clicked)    
  4. IupSetCallback(btn4, "ACTION", @Btn4_clicked)    
  5.  

My testcode for this construct:

Code: [Select]
typedef int (*Icallback)(Ihandle*);

function setfunction(char*s,Icallback i) as sys
print "Set function addr " i
call i
end function

sub cb() callback
print "cb here"
end sub

setfunction("",@cb)


Charles

JRS

  • Guest
Re: O2 / IUP
« Reply #28 on: January 12, 2013, 11:47:52 AM »
Thanks Charles. That solved the problem.

Almost had it back then if I would of known about the callback reference needed for the SUBs.

http://www.oxygenbasic.org/forum/index.php?topic=602.msg4634#msg4634

How can we get theme support (manifest) working with O2?




Charles Pegge

  • Guest
Re: O2 / IUP
« Reply #29 on: January 12, 2013, 12:11:21 PM »
You will need to compile to an exe, then supply a manifest in the same folder:

myprog.exe.manifest

but I have never worked with manifests myself.

If your exe does not have an RTL included then you will need to have oxygen.dll in the same folder OR provide a pathmame in a file called oxygen.cfg

example:

..\..\oxygen.dll