Author Topic: O2 / IUP  (Read 15768 times)

0 Members and 2 Guests are viewing this topic.

JRS

  • Guest
Re: O2 / IUP
« Reply #30 on: January 12, 2013, 12:46:47 PM »
I embedded the manifest in the Windows version of ScriptBasic but forgot how I did it. There are notes about  manifest embedding on the IUP site I'll have to dig up again.


Peter

  • Guest
Re: O2 / IUP
« Reply #31 on: January 12, 2013, 12:50:48 PM »
Hi Charles,

Here are the correct button.
Code: [Select]
include "iup.inc"
sys win

Sub Btn1_clicked() callback
  static sys a
  a +=1
  PRINT "BUTTON 1 Event  " + a "x pressed"
End Sub

Sub Btn2_clicked() callback
  static sys a
  a +=1
  PRINT "BUTTON 2 Event  " + a "x pressed"
End Sub

Sub Btn3_clicked() callback
  static sys a
  a +=1
  PRINT "BUTTON 3 Event  " + a "x pressed"
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")

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

IupSetCallback(btn1,"ACTION", @Btn1_clicked)   
IupSetCallback(btn2,"ACTION", @Btn2_clicked)   
IupSetCallback(btn3,"ACTION", @Btn3_clicked)   
IupShow(win)
IupMainLoop()
IupClose()

X

JRS

  • Guest
Re: O2 / IUP
« Reply #32 on: January 12, 2013, 01:40:45 PM »
Peter,

I get no event (PRINT) message boxes with your latest example and iup.inc file. How does the iupdef.inc get included into the program? Do you have any hints how to get theme support going in O2 beside the manifest file method?

Code: [Select]
! IupSetCallback      Lib "iup.dll" (sys ih, char *sname, sys func) as sys callback
' ! IupSetCallback      Lib "iup.dll" (iHandle *ih, char *sname, sys func) as sys callback

This revert of IupSetCallback() allowed your current example to run correctly.

John
« Last Edit: January 12, 2013, 02:11:14 PM by JRS »

Peter

  • Guest
Re: O2 / IUP
« Reply #33 on: January 12, 2013, 02:40:35 PM »
Hi JRS,

All runs correctly, is by master peter.
It should look like this:

X

JRS

  • Guest
Re: O2 / IUP
« Reply #34 on: January 12, 2013, 04:16:31 PM »
Quote
Windows XP/Vista/7 Visual Styles

Windows Visual Styles can be enabled using a manifest file. Uncomment the manifest file section in "iup.rc" file or copy it to your own resource file (you will need also to copy the manifest file "iup.manifest").

When using Visual C++ 8/9/10 with "iup.manifest", configure the linker properties of your project to do NOT generate a manifest file or the Windows Visual Styles from the RC file won't work.

If your Windows is using the Windows Classic theme or any other theme, IUP controls appearance will follow the system appearance only if you are using the manifest. If not using the manifest, then it will always look like Windows Classic.

Can someone show me how to use a .rc file with O2?

Here is a O2 forum link that already discusses this issue.

http://www.oxygenbasic.org/forum/index.php?topic=380.msg2755#msg2755

How can this be compiled into the application to allow theme support. I can't believe this hasn't come up before now. Win7 apps with a Win2000 look?

Can something like this be used?

Code: C
  1. // put it with other headers
  2.  
  3. #pragma comment( lib, "comctl32.lib")
  4.  
  5. #include <commctrl.h >
  6.  
  7. #pragma comment(linker, "/manifestdependency:\
  8.  
  9. "type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
  10. processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
  11.  
  12.  
  13. // put this call in WinMain() or elsewhere
  14.  
  15. InitCommonControls();
  16.  

The following O2 / IUP example is using a buttons.exe.manifest file for the style support. (just in case what I'm after isn't apparent)




« Last Edit: January 12, 2013, 08:12:42 PM by JRS »

Charles Pegge

  • Guest
Re: O2 / IUP
« Reply #35 on: January 13, 2013, 05:32:04 AM »
Hi John,

Some resource tools here. James Fuller provided the LinkRes2Exe.

I will include them in tools/compiling

X

JRS

  • Guest
Re: O2 / IUP
« Reply #36 on: January 13, 2013, 05:46:55 AM »
Thanks Charles. I will give this a try. I wonder if embedding the manifest in Oxygen.dll would work as a global solution?

Quote
LinkRes2Exe 1.02  (c)2006 by Mike Henning
Usage: LinkRes2Exe  file.res  file.exe [-verbose]

Code: [Select]
Z:\home\jrs\Downloads\OxygenBasic\restool>GoRC -?

GoRC.Exe Version 0.90.5 - Copyright Jeremy Gordon 1998/2009 - JG@JGnet.co.uk
Use this syntax in the command line:-

GoRC [command line switches] inputfile[.ext]

If the inputfile is RC, then by default, both RES and OBJ files are created
Override by using the /o or /r switch or by specifying an output file

Command line switches:-
/b=beep on error
/h=this help
/d=define a word (eg. /d WORD=0x345)
/e=empty output file allowed
/o=create OBJ file
/r=create RES file
/fo=specify output path/file eg. /fo myres.obj
            or /fo myres.obj, c:\res\myres.res
/machine AMD64 or /machine X64=object file to be in X64 (X86-64) format
            (default is X86 format for 32 bit Windows)
/ne /ni /nw=no error, information, warning messages respectively
/no=no output messages at all

Z:\home\jrs\Downloads\OxygenBasic\restool>
« Last Edit: January 13, 2013, 05:56:48 AM by JRS »

Peter

  • Guest
Re: O2 / IUP
« Reply #37 on: January 13, 2013, 06:26:18 AM »
Hi together,

Cheating!
« Last Edit: January 14, 2013, 02:19:31 AM by peter »

JRS

  • Guest
Re: O2 / IUP
« Reply #38 on: January 13, 2013, 06:52:12 AM »
Thanks Peter for all the hard work building the O2/IUP include files and providing a set of IUP DLLs. I think you need to add a repaint callback to your demo.

Code: [Select]
IupShow win  
cvas=IupDrawCreateCanvas (win)
IupSetCallback cvas,"ACTION", Text

This is a cheating way to get the canvas to show Peter. (use a callback (after dialog show) to invoke the SUB rather than create a real repainting callback to handle resize and off screen issues)  :P




« Last Edit: January 13, 2013, 04:16:23 PM by JRS »

JRS

  • Guest
Re: O2 / IUP
« Reply #39 on: January 13, 2013, 06:52:36 PM »
Charles,

I thought I would go back and see if I could get the IUP C header (iup.h) method working with the buttons demo. I'm using your modified iup.h you posted but getting this error.

Code: OxygenBasic
  1. 'SUB BTN1_CLICKED
  2.  
  3. jmp fwd _over_
  4. o2 !10
  5. .btn1_clicked
  6. (
  7. push ebp
  8. mov ebp,esp
  9. add esp,-64
  10. lea edi,[ebp-12]
  11. xor eax,eax
  12. mov ecx,16
  13. (
  14. mov [edi],eax
  15. add edi,4
  16. sub ecx,4
  17. jg repeat
  18. )
  19. ERROR:
  20. direct void type not usable: ihandle:
  21. WORD:   sub
  22. LINE:   9
  23.  



Code: OxygenBasic
  1. includepath "C:\iup\include\"  
  2. extern lib "iup.dll" cdecl  
  3. include "iup.o2h"
  4. end extern    
  5.  
  6. sys win, horzbox, btn1, btn2, btn3
  7.  
  8. Sub Btn1_clicked() callback
  9.   static sys a
  10.   a +=1
  11.   PRINT "BUTTON 1 Event  " + a "x pressed"
  12. End Sub
  13.  
  14. Sub Btn2_clicked() callback
  15.   static sys a
  16.   a +=1
  17.   PRINT "BUTTON 2 Event  " + a "x pressed"
  18. End Sub
  19.  
  20. Sub Btn3_clicked() callback
  21.   static sys a
  22.   a +=1
  23.   PRINT "BUTTON 3 Event  " + a "x pressed"
  24. End Sub
  25.  
  26. IupOpen(0,0)
  27. win=IupCreate("dialog")
  28. IupSetAttributes win, "TITLE= Test Dialog, SIZE=300x"
  29. horzbox = IupCreate("hbox")
  30. IupSetAttributes(horzbox, "GAP=5")
  31. btn1 = IupCreate("button")
  32.  
  33. IupSetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL")
  34. btn2 = IupCreate("button")
  35. IupSetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL")
  36. btn3 = IupCreate("button")
  37. IupSetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL")
  38.  
  39. IupAppend(horzbox, btn1)
  40. IupAppend(horzbox, btn2)
  41. IupAppend(horzbox, btn3)
  42. IupAppend(win, horzbox)
  43.  
  44. IupSetCallback(btn1,"ACTION", @Btn1_clicked)    
  45. IupSetCallback(btn2,"ACTION", @Btn2_clicked)  
  46. IupSetCallback(btn3,"ACTION", @Btn3_clicked)  
  47. IupShow(win)
  48. IupMainLoop()
  49. IupClose()
  50.  
« Last Edit: January 13, 2013, 08:23:27 PM by JRS »

JRS

  • Guest
Re: O2 / IUP
« Reply #40 on: January 13, 2013, 08:27:31 PM »
I got it to work.

Code: OxygenBasic
  1. Sub Btn1_clicked()as sys callback
  2.  

I tried to add an argument to the callback fuction which compiles fine but exceptions at runtime.

Code: OxygenBasic
  1. FUNCTION Btn1_clicked(sys this_button)as sys callback
  2.  

I believe the callback FUNCTIONs should look like this and return IUP_DEFAULT.

Code: OxygenBasic
  1. includepath "C:\iup\include\"  
  2. extern lib "iup.dll" cdecl  
  3. include "iup.o2h"
  4. end extern    
  5.  
  6. sys win, horzbox, btn1, btn2, btn3
  7.  
  8. FUNCTION Btn1_clicked()as sys callback
  9.   static sys a
  10.   a +=1
  11.   PRINT "BUTTON 1 Event  " + a "x pressed"
  12.   RETURN IUP_DEFAULT
  13. END FUNCTION
  14.  
  15. FUNCTION Btn2_clicked()as sys callback
  16.   static sys a
  17.   a +=1
  18.   PRINT "BUTTON 2 Event  " + a "x pressed"
  19.   RETURN IUP_DEFAULT
  20. END FUNCTION
  21.  
  22. FUNCTION Btn3_clicked()as sys callback
  23.   static sys a
  24.   a +=1
  25.   PRINT "BUTTON 3 Event  " + a "x pressed"
  26.   RETURN IUP_DEFAULT
  27. END FUNCTION
  28.  
  29. IupOpen(0,0)
  30. win=IupCreate("dialog")
  31. IupSetAttributes win, "TITLE= Test Dialog, SIZE=300x"
  32. horzbox = IupCreate("hbox")
  33. IupSetAttributes(horzbox, "GAP=5")
  34. btn1 = IupCreate("button")
  35.  
  36. IupSetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL")
  37. btn2 = IupCreate("button")
  38. IupSetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL")
  39. btn3 = IupCreate("button")
  40. IupSetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL")
  41.  
  42. IupAppend(horzbox, btn1)
  43. IupAppend(horzbox, btn2)
  44. IupAppend(horzbox, btn3)
  45. IupAppend(win, horzbox)
  46.  
  47. IupSetCallback(btn1,"ACTION", @Btn1_clicked)    
  48. IupSetCallback(btn2,"ACTION", @Btn2_clicked)  
  49. IupSetCallback(btn3,"ACTION", @Btn3_clicked)  
  50. IupShow(win)
  51. IupMainLoop()
  52. IupClose()
  53.  
« Last Edit: January 13, 2013, 09:16:38 PM by JRS »

Peter

  • Guest
Re: O2 / IUP
« Reply #41 on: January 14, 2013, 01:35:56 AM »
Quote
This is a cheating way to get the canvas to show Peter.

LOL
if you do not likes it, then throw it away easily!  
« Last Edit: January 14, 2013, 02:07:50 AM by peter »

Charles Pegge

  • Guest
Re: O2 / IUP
« Reply #42 on: January 14, 2013, 02:28:52 AM »
Hi John,

Fixed a bug relating to void types. New Oxygen below.

This version of your code will now work with an undoctored iup.h.

Note that I have put all the callbacks into an extern cdecl block. cdecl allows the callbacks to receive parameters without gagging (ie corrupting the stack on return).

Charles

Code: OxygenBasic
  1. includepath "iup\"    
  2. extern lib "iup.dll" cdecl    
  3. include "iup.h"
  4. end extern      
  5.  
  6. sys win, horzbox, btn1, btn2, btn3  
  7.  
  8. extern cdecl
  9.  
  10.  
  11. FUNCTION Btn1_clicked(iHandle* h) as sys  
  12.   static sys a  
  13.   a +=1  
  14.   PRINT "BUTTON 1 Event  " + a "x pressed"  
  15.   RETURN IUP_DEFAULT  
  16. END FUNCTION
  17.  
  18. FUNCTION Btn2_clicked(iHandle* h) as sys  
  19.   static sys a  
  20.   a +=1  
  21.   PRINT "BUTTON 2 Event  " + a "x pressed"  
  22.   RETURN IUP_DEFAULT  
  23. END FUNCTION  
  24.  
  25. FUNCTION Btn3_clicked(iHandle* h) as sys
  26.   static sys a  
  27.   a +=1  
  28.   PRINT "BUTTON 3 Event  " + a "x pressed"  
  29.   RETURN IUP_DEFAULT  
  30. END FUNCTION
  31.  
  32. end extern
  33.  
  34.  
  35. IupOpen(0,0)  
  36. win=IupCreate("dialog")  
  37. IupSetAttributes win, "TITLE= Test Dialog, SIZE=300x"  
  38. horzbox = IupCreate("hbox")  
  39. IupSetAttributes(horzbox, "GAP=5")  
  40. btn1 = IupCreate("button")  
  41.  
  42. IupSetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL")  
  43. btn2 = IupCreate("button")  
  44. IupSetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL")  
  45. btn3 = IupCreate("button")  
  46. IupSetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL")  
  47.  
  48. IupAppend(horzbox, btn1)  
  49. IupAppend(horzbox, btn2)  
  50. IupAppend(horzbox, btn3)  
  51. IupAppend(win, horzbox)  
  52.  
  53. IupSetCallback(btn1,"ACTION", @Btn1_clicked)      
  54. IupSetCallback(btn2,"ACTION", @Btn2_clicked)    
  55. IupSetCallback(btn3,"ACTION", @Btn3_clicked)    
  56. IupShow(win)  
  57. IupMainLoop()  
  58. IupClose()  
  59.  
« Last Edit: January 15, 2013, 07:35:35 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: O2 / IUP
« Reply #43 on: January 14, 2013, 02:56:01 AM »
This new version of Oxygen also supports dead code removal. It can take out all unused functions,subs and methods when the #compact directive is used. (Warning! If any Basic procedure is called exclusively from assembler, it will not be tagged as used, and will be thrown out!)

This allows programmers to work with large source code libraries, and still produce small binaries.

I have also extended the addr pseudo-instruction to resolve addresses of labels and string literals as well as variables.

.here
addr ecx,here


addr eax, "Hello World" '(must use eax for strings)

sys a,b,c
addr ecx,a


Charles
« Last Edit: January 14, 2013, 03:04:57 AM by Charles Pegge »

JRS

  • Guest
Re: O2 / IUP
« Reply #44 on: January 14, 2013, 06:13:20 AM »
Quote
if you do not likes it, then throw it away easily!

Your demo is a great introduction to using IUP canvas draw. It just has some repaint issues that I'm sure you can fix with a line or two of code.

Please don't take my desire to use C headers via your includes in a negative way. As you say, your a busy guy and I can't depend on anyone to maintain a set of custom IUP includes. I have seen FreeBASIC struggle with their external library .bi include files for years. I think we need to support Charles with his efforts to play nice with tools that everyone else uses.