Author Topic: O2 / IUP  (Read 15770 times)

0 Members and 4 Guests are viewing this topic.

JRS

  • Guest
O2 / IUP
« on: January 09, 2013, 10:51:27 PM »
Peter,

I'm creating parallel threads on the AllBasic.INFO site showing BaCon and bc9 using IUP. If you have some spare time on your hands, could you do the O2 version of the demos for Windows?

John

Peter

  • Guest
Re: O2 / IUP
« Reply #1 on: January 10, 2013, 03:19:59 AM »
Hi JRS,

Read here.

Code: [Select]
#define IUP_TITLE  "TITLE"

%IUP_CLOSE =-3  
%IUP_ERROR = 1  

enum { IUP_DRAW_FILL, IUP_DRAW_STROKE, IUP_DRAW_STROKE_DASH }

typedef struct Ihandle_ {}
Ihandle_ Ihandle
typedef int (*Icallback)(Ihandle*)
typedef struct _IdrawCanvas {}
_IdrawCanvas IdrawCanvas

! IupOpen             Lib "iup.dll" (sys a,b) as sys  
! IupCreate           Lib "iup.dll" (string cname) as sys  
! IupSetAttributes    Lib "iup.dll" (sys ih,string strz) as sys  
! IupAppend           Lib "iup.dll" (sys ih, child) as sys  
! IupRefresh          Lib "iup.dll" (sys ih)  
! IupSetCallback      Lib "iup.dll" (sys ih, string sname, sys func) as sys  
! IupShow             Lib "iup.dll" (sys ih) as sys  
! IupShowXY           Lib "iup.dll" (Ihandle *ih, sys x, sys y) as sys
! IupSetFocus         Lib "iup.dll" (sys ih) as sys  
! IupRecordInput      Lib "iup.dll" (char *filename, sys mode) as sys
! IupPlayInput        Lib "iup.dll" (char *filename) as sys
! IupMainLoop         Lib "iup.dll" () as sys
! IupImageLibOpen     Lib "iup.dll" () as sys
! IupLoopStep         Lib "iup.dll" () as sys
! IupLoopStepWait     Lib "iup.dll" () as sys
! IupMainLoopLevel    Lib "iup.dll" () as sys
! IupClose            Lib "iup.dll" ()
! IupFlush            Lib "iup.dll" ()
! IupExitLoop         Lib "iup.dll" ()
! IupUpdate           Lib "iup.dll" (Ihandle *ih)
! IupUpdateChildren   Lib "iup.dll" (Ihandle *ih)
! IupRedraw           Lib "iup.dll" (Ihandle *ih, sys children)
! IupRefresh          Lib "iup.dll" (Ihandle *ih)
! IupRefreshChildren  Lib "iup.dll" (Ihandle *ih)  
! IupMapFont          Lib "iup.dll" (char *iupfont) as string
! IupUnMapFont        Lib "iup.dll" (char *driverfont) as string
! IupHelp             Lib "iup.dll" (string url) as sys
! IupLoad             Lib "iup.dll" (char *filename) as string
! IupLoadBuffer       Lib "iup.dll" (char *buffer) as string
! IupVersion          Lib "iup.dll" () as string
! IupVersionDate      Lib "iup.dll" () as string
! IupVersionNumber    Lib "iup.dll" () as sys
! IupSetLanguage      Lib "iup.dll" (char *lng)
! IupGetLanguage      Lib "iup.dll" () as string
! IupText             lib "iup.dll" (char *text)
! iupDrawCreateCanvas Lib "iup.dll" (Ihandle *ih) as sys
! iupDrawKillCanvas   Lib "iup.dll" (sys *dc)
! iupDrawFlush        Lib "iup.dll" (sys *dc)
! iupDrawUpdateSize   Lib "iup.dll" (sys *dc)
! iupDrawGetSize      Lib "iup.dll" (sys *dc, *w, *h)
! iupDrawLine         Lib "iup.dll" (sys *dc, x1, y1, x2, y2, byte r, g, b, sys style)
! iupDrawRectangle    Lib "iup.dll" (sys *dc, x1, y1, x2, y2, byte r, g, b, sys style)
! iupDrawArc          Lib "iup.dll" (sys *dc, x1, y1, x2, y2, double a1, a2, byte r, g, b, sys style)
! iupDrawPolygon      Lib "iup.dll" (sys *dc, *points, count, byte r, g, b, sys style)
! iupDrawText         Lib "iup.dll" (sys *dc, char *text, sys len, x, y, byte r, g, b, char *font)
! iupDrawImage        Lib "iup.dll" (sys *dc, char *name, sys make_inactive, x, y, *img_w, *img_h)
! iupDrawSetClipRect  Lib "iup.dll" (sys *dc, x1, y1, x2, y2)
! iupDrawResetClip    Lib "iup.dll" (sys *dc)

! iupDrawRectangleInvert  Lib "iup.dll" (sys *dc, x1, y1, x2, y2)
! iupDrawParentBackground Lib "iup.dll" (sys *dc)

sys canvas,font

Sub iText (sys x,y, string text, sys r,g,b)
    iupDrawText *canvas, text, len(text), x,y, r,g,b, 0
End Sub

IupOpen(0,0)
win = iupCreate "dialog"
iupSetAttributes win,"TITLE=INSANITY, SIZE=174x148"
iupShow win  
canvas = IupDrawCreateCanvas *win
iupDrawRectangle *canvas, 0,0, 244,238, 254,72,170, 1
iupDrawRectangle *canvas, 1,1, 243,237, 254,92,270, 1
iText 50,20, "SORRY MISTER IUP !",255,25,25
iText 80,100,"NO TIME !!",255,255,255
iText 20,120,"I GOT OWN STUPID WORKING.",255,255,100
iText 50,140,"AND THAT " + 500 + "x",55, 255, 10
iText 30,200,"THANK YOU FOR ENQUIRY",255,128,128
iupDrawFlush *canvas
IupMainLoop()
iupDrawKillCanvas *canvas
IupClose()
« Last Edit: January 10, 2013, 04:20:10 AM by peter »

JRS

  • Guest
Re: O2 / IUP
« Reply #2 on: January 10, 2013, 05:25:07 AM »
Thanks Peter for the code to get started with. I would like to use the IUP C header files as much as possible without redefinition in O2. I will try to get a O2 set of IUP example working once I finish with the bc9 (BCX fork) and ScriptBasic versions. I will chime in here from time to time with my progress/problems getting OxygenBasic working with IUP.

MrIup   :D

« Last Edit: January 10, 2013, 09:05:35 AM by JRS »

Peter

  • Guest
Re: O2 / IUP
« Reply #3 on: January 10, 2013, 10:44:09 PM »
Hi JRS,

A new IUP header and some Demos.
Code: [Select]
include "iup.inc"

IupOpen(0,0)
IupShow(IupDialog(IupLabel("Hello World!")))
IupMainLoop()
IupClose()

Code: [Select]
include "iup.inc"
sys win

Sub Btn1_clicked()
  PRINT "BUTTON 1 Event"
End Sub

Sub Btn2_clicked()
  PRINT "BUTTON 2 Event"
End Sub

Sub Btn3_clicked()
  PRINT "BUTTON 3 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")
IupAppend(horzbox, btn1)
IupAppend(horzbox, btn2)
IupAppend(horzbox, btn3)
IupAppend(win, horzbox)
IupSetFunction(btn1, Btn1_clicked)   'IupSetCallback crashed!
IupSetFunction(btn2, Btn2_clicked)   'IupSetCallback crashed!
IupSetFunction(btn3, Btn3_clicked)   'IupSetCallback crashed!
IupShow(win)
IupMainLoop()
IupClose()

Code: [Select]
include "iup.inc"

sys canvas,alpha,beta,ox=200,oy=140
single x,y,h

Sub Cone()
for alpha=0 to 360 step 8
    x = 100*cos(rad(alpha))
    y = sin(rad(alpha))*sin(rad(beta)) * 80
    h = 100*cos(rad(beta))
    iupDrawLine *canvas,ox,oy, ox+x,oy-(y-h), 255,255,255,1
next
End Sub

IupOpen(0,0)
win= iupCreate "dialog"
IupSetAttributes win,"TITLE=CONE,SIZE=300x200"
iupShow win  
canvas= IupDrawCreateCanvas *win
cone()
iupDrawFlush *canvas
iupMainLoop
iupDrawKillCanvas *canvas
iupDestroy win
iupClose

X

Peter

  • Guest
Re: O2 / IUP
« Reply #4 on: January 11, 2013, 02:33:39 AM »
And so on
Code: [Select]
include "iup.inc"

IupOpen(0,0)
iupMessage "WARNING","Mayflies attack"
iupMainLoop() 
iupClose()

X

JRS

  • Guest
Re: O2 / IUP
« Reply #5 on: January 11, 2013, 05:46:54 AM »
WOW!

Thank you Peter. This was exactly what I was looking for.

JRS

  • Guest
Re: O2 / IUP
« Reply #6 on: January 11, 2013, 07:20:16 AM »
Peter,

Code: [Select]
IupSetFunction(btn1, Btn1_clicked)   'IupSetCallback crashed!
IupSetFunction(btn2, Btn2_clicked)   'IupSetCallback crashed!
IupSetFunction(btn3, Btn3_clicked)   'IupSetCallback crashed!

Just noticed that callbacks aren't working. I'm going to stop here until you guys figure out what the issue is.

FWIW: James Fuller posted as O2/IUP example a while back that had IupSetCallback() working.

Thanks for your help with the IUP on everything project.  :D

P.S. I would be happy to set you up an account on AllBasic.info if you like. Charles is already a member.

John

JRS

  • Guest
Re: O2 / IUP
« Reply #7 on: January 11, 2013, 09:26:24 AM »
I have made some progress with the callback issue using James's definition.

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

iup_buttons.o2bas
Code: [Select]
include "iup.inc"
sys win

Sub Btn1_clicked()
  PRINT "BUTTON 1 Event"
End Sub

Sub Btn2_clicked()
  PRINT "BUTTON 2 Event"
End Sub

Sub Btn3_clicked()
  PRINT "BUTTON 3 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")
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()



I'm getting exception when I click on any of the buttons.



It would be nice to have XP theme support in O2.   :o

Peter

  • Guest
Re: O2 / IUP
« Reply #8 on: January 11, 2013, 01:08:56 PM »
Hi JRS,

more and better,  IupCallback does go!
Code: [Select]
include "iup.inc"

Sub WinExit()
  IupExitLoop
End Sub

sys dlg,lbl

IupOpen 0,0
dlg = iupCreate "dialog"
lbl = IupLabel "HELLO  MISTER  IUP !"
IupSetCallback dlg,"IUP_CLOSE", WinExit
IupAppend dlg, lbl
IupShow dlg
IupMainLoop
IupClose

X

JRS

  • Guest
Re: O2 / IUP
« Reply #9 on: January 11, 2013, 04:09:28 PM »
Peter,

No luck with the new iup.inc file. Did you try the buttons example you posted that has a callback other than the IUP_CLOSE (works even without calling it)?

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

What is strange is that the PRINT statements are firing before the main dialog shows and when I press a button I get the exception error I posted earlier. Is there a chance you are using a newer version of O2 then I am?

John

Peter

  • Guest
Re: O2 / IUP
« Reply #10 on: January 11, 2013, 05:11:36 PM »
Hi JRS,

No crash here,  I found this little evil!
Try the new iup.inc. Report back.



X

JRS

  • Guest
Re: O2 / IUP
« Reply #11 on: January 11, 2013, 05:34:24 PM »
I reinstalled a fresh copy of O2 A39 and used the above example with your latest iup.inc.

Same problem.

* PRINT dialogs fire on startup
* Exception dialog when any button is pressed.

Running XP. (latest updates)

Peter

  • Guest
Re: O2 / IUP
« Reply #12 on: January 11, 2013, 05:40:56 PM »
Hi JRS,

I use this DLL.



X

JRS

  • Guest
Re: O2 / IUP
« Reply #13 on: January 11, 2013, 05:44:20 PM »
I'll give that a try. Attached is the build code dump for the iup_buttons.o2bas that I'm having issues with on my laptop.



X

JRS

  • Guest
Re: O2 / IUP
« Reply #14 on: January 11, 2013, 05:52:26 PM »
Nothing has changed with your Oxygen.dll.  :'(